-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
203 lines (146 loc) · 6.07 KB
/
Copy pathMain.java
File metadata and controls
203 lines (146 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
package wf;
import java.io.IOException;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import wf.util.LoadTask;
import wf.util.RetrieveDateAndTime;
import wf.view.MainController;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
public class Main extends Application {
private AnchorPane main_ap;
private Scene main_scene;
private FXMLLoader loader = new FXMLLoader();
private static MainController mainController = new MainController();
private static LoadTask loadTask = LoadTask.getInstance();
@Override
public void start(Stage primaryStage) {
try {
// Load root layout from fxml file.
loader.setLocation(Main.class.getResource("view/Main.fxml"));
main_ap = (AnchorPane) loader.load();
// Show the scene containing the root layout.
main_scene = new Scene(main_ap);
main_scene.getStylesheets().clear();
main_scene.getStylesheets().add(Main.class.getResource("/wf/view/application.css").toExternalForm());
primaryStage.setScene(main_scene);
primaryStage.setTitle("Waveform Analyzer V 1.0");
primaryStage.setResizable(false);
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
event.consume();
}
});
mainController = loader.<MainController>getController();
updateTextArea(RetrieveDateAndTime.getDateAndTime() + " - Welcome to Waveform Analyzer 1.0!");
primaryStage.show();
} catch (IOException e) {
e.printStackTrace();
}
/*
String selectedDirectory = "C:\\Users\\fschirru\\Desktop\\MyDocuments\\Catania_Data\\Catania_2015\\Catania_2\\Data_Catania_Run2\\UnpackedData\\PT01_merged";
String CsvFile = "\\C2lowratePT01";
String fileNumber = "";
String tempFileNumber = "";
String fileExtention = ".csv";
String FieldDelimiter = ",";
String fileName = "";
String maxNumberOfFiles = "10000";
int fileToBeProcessed = 10;
int convertionFactor = 1000000000;
int waveformIndex = 87;
int oscilloscopeChannel = 2;
int fileLines = 0;
List<Double> traceTime = new ArrayList<>();
Map<Integer, List<Double>> ch1Values_map = new HashMap<Integer, List<Double>>();
Map<Integer, List<Double>> ch2Values_map = new HashMap<Integer, List<Double>>();
Map<Integer, List<Double>> ch3Values_map = new HashMap<Integer, List<Double>>();
Map<Integer, List<Double>> ch4Values_map = new HashMap<Integer, List<Double>>();
List<Map<Integer, List<Double>>> mapValues = new ArrayList<>();
mapValues.add(ch1Values_map);
mapValues.add(ch2Values_map);
mapValues.add(ch3Values_map);
mapValues.add(ch4Values_map);
for(int f = 0; f < fileToBeProcessed; f++) {
List<Double> ch1Values = new ArrayList<>();
List<Double> ch2Values = new ArrayList<>();
List<Double> ch3Values = new ArrayList<>();
List<Double> ch4Values = new ArrayList<>();
fileName = "";
fileNumber = "";
tempFileNumber = "";
tempFileNumber = String.valueOf(f);
for(int s = 0; s < (maxNumberOfFiles.length() - tempFileNumber.length()); s++) {
fileNumber = fileNumber + "0";
}
fileNumber = fileNumber + String.valueOf(f);
fileName = selectedDirectory + CsvFile + fileNumber + fileExtention;
BufferedReader br;
try {
br = new BufferedReader(new FileReader(fileName));
String line;
while ((line = br.readLine()) != null) {
String[] fields = line.split(FieldDelimiter, -1);
if( f == 0) { //time scale processed only for the first file
traceTime.add(Double.parseDouble(fields[2]));
fileLines++;
}
ch1Values.add(Double.parseDouble(fields[1]));
ch2Values.add(Double.parseDouble(fields[3]));
ch3Values.add(Double.parseDouble(fields[5]));
ch4Values.add(Double.parseDouble(fields[7]));
}
ch1Values_map.put(f, ch1Values);
ch2Values_map.put(f, ch2Values);
ch3Values_map.put(f, ch3Values);
ch4Values_map.put(f, ch4Values);
} catch (FileNotFoundException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
//defining the axes
final NumberAxis xAxis = new NumberAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Time (ns)");
//creating the chart
final LineChart<Number,Number> lineChart =
new LineChart<Number,Number>(xAxis,yAxis);
lineChart.setTitle("Waveform");
//defining a series
XYChart.Series<Number, Number> series = new XYChart.Series<>();
series.setName("");
//populating the series with data
for(int l = 0; l < fileLines; l++) {
series.getData().add(new XYChart.Data<Number, Number>(traceTime.get(l)*convertionFactor, mapValues.get(oscilloscopeChannel-1).get(waveformIndex).get(l)));
}
lineChart.getData().add(series);
*/
/*
try {
//BorderPane root = new BorderPane();
Scene scene = new Scene(lineChart,800,600);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.setTitle("Line Chart Sample");
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
} */
mainController.initialize();
}
public static void updateTextArea(String message) {
mainController.updateTextArea(message);
}
public static void main(String[] args) {
launch(args);
}
public static LoadTask getLoadTask() {
return loadTask;
}
}