@@ -11,8 +11,13 @@ public FileManager(String _fileName)
11
11
this .fileName = _fileName ;
12
12
}
13
13
14
- public void save_array (double [][]process_signal , double [][]control_signal )
14
+
15
+ public void save_pid_signals (double [][]setpoint , double [][]signal , double [][]control )
15
16
{
17
+ /*
18
+ * Este método genera una archivo con cuatro columnas que corresponden a:
19
+ * datos_tiempo datos_setpoint datos_control datos_salida_planta
20
+ * */
16
21
BufferedWriter bufferedWriter = null ;
17
22
FileWriter fileWriter = null ;
18
23
PrintWriter printWriter = null ;
@@ -21,9 +26,8 @@ public void save_array(double [][]process_signal, double [][]control_signal)
21
26
fileWriter = new FileWriter (this .fileName , true );
22
27
bufferedWriter = new BufferedWriter (fileWriter );
23
28
printWriter = new PrintWriter (bufferedWriter );
24
- // formato del archivo ( time_signal, process_signal, control_signal )
25
- for (int i = 0 ; i < process_signal [0 ].length ; i ++)
26
- bufferedWriter .write (String .format ("%f\t %f\t %f\n " , process_signal [0 ][i ], process_signal [1 ][i ], control_signal [1 ][i ]));
29
+ for (int i = 0 ; i < signal [0 ].length ; i ++) //time //setpoint //control //plant's output
30
+ bufferedWriter .write (String .format ("%f\t %f\t %f\t %f\n " , signal [0 ][i ], setpoint [1 ][i ], control [1 ][i ], signal [1 ][i ]));
27
31
28
32
}
29
33
catch (IOException e )
@@ -45,6 +49,48 @@ public void save_array(double [][]process_signal, double [][]control_signal)
45
49
{
46
50
47
51
}
52
+ } //finally
53
+ }// save_pid_signals
54
+
55
+
56
+ public void save_array (double [][]process_signal , double [][]stimuli )
57
+ {
58
+ /*
59
+ * Este método genera una archivo con tres columnas que corresponden a:
60
+ * datos_tiempo datos_señal_salida_planta datos_señal_entrada_planta
61
+ *
62
+ * */
63
+ BufferedWriter bufferedWriter = null ;
64
+ FileWriter fileWriter = null ;
65
+ PrintWriter printWriter = null ;
66
+ try
67
+ {
68
+ fileWriter = new FileWriter (this .fileName , true );
69
+ bufferedWriter = new BufferedWriter (fileWriter );
70
+ printWriter = new PrintWriter (bufferedWriter );
71
+ for (int i = 0 ; i < process_signal [0 ].length ; i ++) //time data //plant's output //stimuli signal (e.g. step)
72
+ bufferedWriter .write (String .format ("%f\t %f\t %f\n " , process_signal [0 ][i ], process_signal [1 ][i ], stimuli [1 ][i ]));
73
+
48
74
}
49
- }
50
- }
75
+ catch (IOException e )
76
+ {
77
+ System .out .println ("Error escribiendo el archivo" );
78
+ }
79
+ finally
80
+ {
81
+ try
82
+ {
83
+ if (bufferedWriter != null )
84
+ {
85
+ bufferedWriter .close ();
86
+ printWriter .close ();
87
+ fileWriter .close ();
88
+ }
89
+ }
90
+ catch (IOException e )
91
+ {
92
+
93
+ }
94
+ } //finally
95
+ }//save_array
96
+ } // class FileManager
0 commit comments