-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindow.java
More file actions
102 lines (96 loc) · 3.44 KB
/
Window.java
File metadata and controls
102 lines (96 loc) · 3.44 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
import javax.swing.JFrame;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JButton;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
public class Window extends JFrame
{
private static final long serialVersionUID = 1L;
final XYSeries output_I;
final XYSeries input_I;
final XYSeries setpoint_I;
final XYSeries output_II;
final XYSeries input_II;
final XYSeries setpoint_II;
final XYSeriesCollection collectionData;
final JFreeChart display;
public JTextField txt_server_ip;
public JTextField txt_setpoint_temp;
public JTextField txt_setpoint_flow;
public JButton btn_server_start;
public JButton btn_server_stop;
public Window()
{
this.setTitle("Real Time Control Viewer App");
this.setBounds(600,440,800,550);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
/*Parameters panel*/
JPanel parametersPanel = new JPanel();
JLabel lbl_server_ip = new JLabel("Server IP");
JLabel lbl_setpoint_I = new JLabel("Setpoint Temp.(v)");
JLabel lbl_setpoint_II = new JLabel("Setpoint Flow.(v)");
txt_setpoint_temp = new JTextField("1.0");
txt_setpoint_flow = new JTextField("2.0");
txt_server_ip = new JTextField("192.168.0.10");
txt_setpoint_temp.setHorizontalAlignment(JTextField.CENTER);
txt_setpoint_flow.setHorizontalAlignment(JTextField.CENTER);
txt_server_ip.setHorizontalAlignment(JTextField.CENTER);
btn_server_start = new JButton("Send Values");
btn_server_stop = new JButton("Stop Session");
btn_server_start.setActionCommand("start");
btn_server_stop.setActionCommand("stop");
parametersPanel.setLayout(new GridLayout(4, 2,10,10));
parametersPanel.add(lbl_server_ip);
parametersPanel.add(txt_server_ip);
parametersPanel.add(lbl_setpoint_I);
parametersPanel.add(txt_setpoint_temp);
parametersPanel.add(lbl_setpoint_II);
parametersPanel.add(txt_setpoint_flow);
parametersPanel.add(btn_server_start);
parametersPanel.add(btn_server_stop);
mainPanel.add(parametersPanel, BorderLayout.EAST);
this.getContentPane().add(mainPanel, BorderLayout.EAST);
// Setup the Chart panel
input_I = new XYSeries("PID Temp.");
output_I = new XYSeries("Temp.");
setpoint_I = new XYSeries("Setpoint Temp.");
input_II = new XYSeries("PID Flow");
output_II = new XYSeries("Flow");
setpoint_II = new XYSeries("Setpoint Flow");
input_I.clear();
output_I.clear();
setpoint_I.clear();
input_II.clear();
output_II.clear();
setpoint_II.clear();
collectionData = new XYSeriesCollection();
collectionData.addSeries(input_I);
collectionData.addSeries(output_I);
collectionData.addSeries(setpoint_I);
collectionData.addSeries(input_II);
collectionData.addSeries(output_II);
collectionData.addSeries(setpoint_II);
display = ChartFactory.createXYLineChart("Realtime Process Dynamics",
"Time",
"Amplitude",
collectionData,
PlotOrientation.VERTICAL,
true,
true,
false);
JPanel rt_panel = new ChartPanel(display);
this.getContentPane().add(rt_panel, BorderLayout.CENTER);
this.setVisible(true);
}
}