@@ -10,8 +10,10 @@ public class ThreadServer extends Thread
10
10
{
11
11
private int usbPort ;
12
12
private double ts ;
13
- private double step_time ;
14
13
private double setpoint ;
14
+ private double Kp ;
15
+ private double Ki ;
16
+ private double Kd ;
15
17
private int server_answer = 2958 ;
16
18
private int valid_client_request = 45862 ;
17
19
private int finish = 0 ;
@@ -105,6 +107,7 @@ public void terminate()
105
107
// option to save the captured data
106
108
double [][] logged_signal = this .gui .process_output .toArray ();
107
109
double [][] control_signal = this .gui .process_input .toArray ();
110
+ double [][] setpoint_signal = this .gui .process_setpoint .toArray ();
108
111
109
112
// Dialogo para seleccionar donde almacenar el archivo
110
113
JFileChooser fileChooser = new JFileChooser ();
@@ -114,9 +117,8 @@ public void terminate()
114
117
if (userSelection == JFileChooser .APPROVE_OPTION )
115
118
{
116
119
File fileToSave = fileChooser .getSelectedFile ();
117
- System .out .println ("Save as file: " + fileToSave .getAbsolutePath ());
118
120
FileManager fileSaving = new FileManager (fileToSave .getAbsolutePath ());
119
- fileSaving .save_array ( logged_signal , control_signal );
121
+ fileSaving .save_pid_signals ( setpoint_signal , logged_signal , control_signal );
120
122
System .out .println ("Archivo guardado" );
121
123
}
122
124
else
@@ -129,22 +131,26 @@ public void terminate()
129
131
public void run ()
130
132
{
131
133
double output_process_val = 0.0 ;
132
- double input_process_val = 0.0 ;
134
+ double input_process_val = 0.0 ; //PID computed values
133
135
double time_value = 0.0 ;
134
136
135
137
// get user parameters
136
138
this .usbPort = Integer .parseInt (this .gui .txt_port .getText ());
137
139
this .ts = Double .parseDouble (this .gui .txt_sample_time .getText ());
138
140
this .setpoint = Double .parseDouble (this .gui .txt_setpoint .getText ());
139
- this .step_time = Double .parseDouble (this .gui .txt_step_time .getText ());
141
+ this .Kp = Double .parseDouble (this .gui .txt_kp .getText ());
142
+ this .Ki = Double .parseDouble (this .gui .txt_ki .getText ());
143
+ this .Kd = Double .parseDouble (this .gui .txt_kd .getText ());
140
144
141
145
// Send parámeters
142
146
try
143
147
{
144
148
out .writeInt (this .usbPort );
145
149
out .writeDouble (this .ts );
146
150
out .writeDouble (this .setpoint );
147
- out .writeDouble (this .step_time );
151
+ out .writeDouble (this .Kp );
152
+ out .writeDouble (this .Ki );
153
+ out .writeDouble (this .Kd );
148
154
}
149
155
catch (IOException e )
150
156
{
@@ -162,13 +168,14 @@ public void run()
162
168
input_process_val = this .in .readDouble ();
163
169
time_value = this .in .readDouble ();
164
170
out .writeInt (this .finish );
165
- } catch (IOException e )
171
+ } catch (IOException e )
166
172
{
167
173
System .out .println ("No se pudo hacer la lectura de la señal o la transferencia del finish" );
168
174
e .printStackTrace ();
169
175
}
170
176
this .gui .process_output .add (time_value , output_process_val );
171
177
this .gui .process_input .add (time_value , input_process_val );
178
+ this .gui .process_setpoint .add (time_value , this .setpoint );
172
179
}
173
180
try
174
181
{
0 commit comments