45 |
|
public HostDisplayPanel() { |
46 |
|
// set up the Panel |
47 |
|
setLayout(new BorderLayout()); |
48 |
< |
_east.add(_timeToHeartBeat); |
48 |
> |
|
49 |
> |
_heartbeatTimer = new PacketTimer(Integer.parseInt(Configuration.getInstance().getProperty("Host.TCPUpdateTime"))); |
50 |
> |
_dataTimer = new PacketTimer(Integer.parseInt(Configuration.getInstance().getProperty("Host.UDPUpdateTime"))); |
51 |
> |
_east.add(_heartbeatTimer); |
52 |
> |
_west.add(_dataTimer); |
53 |
> |
|
54 |
|
add(_east, "East"); |
55 |
+ |
add(_west, "West"); |
56 |
|
add(_center, "Center"); |
57 |
|
|
58 |
|
// add all the DataComponents that we know about |
101 |
|
|
102 |
|
// a simple way to handle heatbeats - this WILL change |
103 |
|
if ((packet.getParam("packet.attributes.type")).equals("heartbeat")) { |
104 |
< |
_timeToHeartBeat.setValue(_max); |
104 |
> |
_heartbeatTimer.reset(); |
105 |
> |
if(_heartbeatTimerThread == null){ |
106 |
> |
_heartbeatTimerThread = new Thread(_heartbeatTimer); |
107 |
> |
_heartbeatTimerThread.start(); |
108 |
> |
} |
109 |
|
|
110 |
|
// must be a normal data packet, update the display |
111 |
< |
} else { |
112 |
< |
_timeToHeartBeat.setValue(_timeToHeartBeat.getValue() - 1); |
111 |
> |
} else if((packet.getParam("packet.attributes.type")).equals("data")) { |
112 |
> |
_dataTimer.reset(); |
113 |
> |
if(_dataTimerThread == null){ |
114 |
> |
_dataTimerThread = new Thread(_dataTimer); |
115 |
> |
_dataTimerThread.start(); |
116 |
> |
} |
117 |
|
|
118 |
|
// iterate over the packets data |
119 |
|
Set packetSet = packet.getSet(); |
132 |
|
try { |
133 |
|
((DataComponent) _components.get(dataKey)).setValue(packet.getParam(dataKey)); |
134 |
|
} catch (DataFormatException e) { |
135 |
< |
Conient.addMessage("WARNING: " + e.getMessage()); |
135 |
> |
Conient.addMessage("WARNING{host display}: " + e.getMessage()); |
136 |
|
displaySucessful = false; |
137 |
|
} |
138 |
|
} |
182 |
|
* |
183 |
|
*/ |
184 |
|
private boolean displaySucessful = true; |
185 |
+ |
|
186 |
|
/** |
187 |
< |
* The east panel, currently used for the heartbeat ticker. |
187 |
> |
* The east panel, currently used for the heartbeat timer. |
188 |
|
*/ |
189 |
|
private final JPanel _east = new JPanel(); |
190 |
|
|
191 |
|
/** |
192 |
+ |
* The west panel, currently used for the data timer. |
193 |
+ |
*/ |
194 |
+ |
private final JPanel _west = new JPanel(); |
195 |
+ |
|
196 |
+ |
/** |
197 |
|
* The centre panel, where all the data is displayed. |
198 |
|
*/ |
199 |
|
private final JPanel _center = new JPanel(); |
201 |
|
_center.setLayout(new BoxLayout(_center, BoxLayout.Y_AXIS)); |
202 |
|
} |
203 |
|
|
204 |
< |
/** |
205 |
< |
* The minimum value of the heatbeat progress bar |
206 |
< |
*/ |
207 |
< |
private int _min = 0; |
204 |
> |
private final PacketTimer _heartbeatTimer; |
205 |
> |
private final PacketTimer _dataTimer; |
206 |
> |
private Thread _heartbeatTimerThread = null; |
207 |
> |
private Thread _dataTimerThread = null; |
208 |
|
|
189 |
– |
/** |
190 |
– |
* The maximum value of the heatbeat progress bar |
191 |
– |
*/ |
192 |
– |
private int _max = 6; |
193 |
– |
|
194 |
– |
/** |
195 |
– |
* This progress bar indicates time till next heartbeat. |
196 |
– |
*/ |
197 |
– |
private JProgressBar _timeToHeartBeat = new JProgressBar(JProgressBar.VERTICAL, _min, _max); |
198 |
– |
{ |
199 |
– |
_timeToHeartBeat.setValue(_max); |
200 |
– |
} |
201 |
– |
|
209 |
|
//---STATIC ATTRIBUTES--- |
210 |
|
|
211 |
|
} |