This commit is contained in:
221
plugins/NewJPanel.java
Normal file
221
plugins/NewJPanel.java
Normal file
@@ -0,0 +1,221 @@
|
||||
|
||||
import ch.psi.pshell.device.Device;
|
||||
import ch.psi.pshell.device.DeviceAdapter;
|
||||
import ch.psi.utils.State;
|
||||
import java.awt.Color;
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author gac-S_Changer
|
||||
*/
|
||||
public class NewJPanel extends javax.swing.JPanel {
|
||||
|
||||
/**
|
||||
* Creates new form NewJPanel
|
||||
*/
|
||||
public NewJPanel() {
|
||||
initComponents();
|
||||
|
||||
|
||||
((Device) getDevice("hexiposi")).addListener(new DeviceAdapter() {
|
||||
@Override
|
||||
public void onStateChanged(Device device, State state, State former) {
|
||||
updateHexiposiState(state);
|
||||
}
|
||||
});
|
||||
updateHexiposiState(((Device) getDevice("hexiposi")).getState());
|
||||
|
||||
((Device) getDevice("air_pressure_ok")).addListener(new DeviceAdapter() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
updateAirPressure(value);
|
||||
}
|
||||
});
|
||||
updateAirPressure(((Device) getDevice("air_pressure_ok")).take());
|
||||
|
||||
((Device) getDevice("n2_pressure_ok")).addListener(new DeviceAdapter() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
updateN2Pressure(value);
|
||||
}
|
||||
});
|
||||
updateN2Pressure(((Device) getDevice("n2_pressure_ok")).take());
|
||||
|
||||
((Device) getDevice("feedback_local_safety")).addListener(new DeviceAdapter() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
updateLocalSafety(value);
|
||||
}
|
||||
});
|
||||
updateLocalSafety(((Device) getDevice("feedback_local_safety")).take());
|
||||
|
||||
((Device) getDevice("feedback_psys_safety")).addListener(new DeviceAdapter() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
updatePsysSafety(value);
|
||||
}
|
||||
});
|
||||
updatePsysSafety(((Device) getDevice("feedback_psys_safety")).take());
|
||||
}
|
||||
|
||||
void updateHexiposiState(State state){
|
||||
ledLidControlActive.setColor(state.isInitialized() ? Color.GREEN : Color.BLACK );
|
||||
ledLidInitialized.setColor((state.isNormal()&& state !=State.Disabled) ? Color.GREEN : Color.BLACK);
|
||||
}
|
||||
|
||||
void updateAirPressure(Object value){
|
||||
if ((value == null) || !(value instanceof Boolean)){
|
||||
ledAirPressure.setColor(Color.BLACK);
|
||||
} else if ((Boolean)value){
|
||||
ledAirPressure.setColor(Color.GREEN);
|
||||
} else {
|
||||
ledAirPressure.setColor(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
void updateN2Pressure(Object value){
|
||||
if ((value == null) || !(value instanceof Boolean)){
|
||||
ledN2Pressure.setColor(Color.BLACK);
|
||||
} else if ((Boolean)value){
|
||||
ledN2Pressure.setColor(Color.GREEN);
|
||||
} else {
|
||||
ledN2Pressure.setColor(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
void updateLocalSafety(Object value){
|
||||
if ((value == null) || !(value instanceof Boolean)){
|
||||
ledLocalSafety.setColor(Color.BLACK);
|
||||
} else if ((Boolean)value){
|
||||
ledLocalSafety.setColor(Color.GREEN);
|
||||
} else {
|
||||
ledLocalSafety.setColor(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
void updatePsysSafety(Object value){
|
||||
if ((value == null) || !(value instanceof Boolean)){
|
||||
ledPsysSafety.setColor(Color.BLACK);
|
||||
} else if ((Boolean)value){
|
||||
ledPsysSafety.setColor(Color.GREEN);
|
||||
} else {
|
||||
ledPsysSafety.setColor(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jPanel11 = new javax.swing.JPanel();
|
||||
ledAirPressure = new ch.psi.pshell.swing.Led();
|
||||
jLabel15 = new javax.swing.JLabel();
|
||||
jLabel16 = new javax.swing.JLabel();
|
||||
ledN2Pressure = new ch.psi.pshell.swing.Led();
|
||||
jLabel19 = new javax.swing.JLabel();
|
||||
ledLocalSafety = new ch.psi.pshell.swing.Led();
|
||||
jLabell20 = new javax.swing.JLabel();
|
||||
ledPsysSafety = new ch.psi.pshell.swing.Led();
|
||||
|
||||
jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder("System Status"));
|
||||
|
||||
jLabel15.setText("Air Pressure");
|
||||
|
||||
jLabel16.setText("N2 Pressure");
|
||||
|
||||
jLabel19.setText("Local Safety");
|
||||
|
||||
jLabell20.setText("Psys Safety");
|
||||
|
||||
javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
|
||||
jPanel11.setLayout(jPanel11Layout);
|
||||
jPanel11Layout.setHorizontalGroup(
|
||||
jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel11Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel11Layout.createSequentialGroup()
|
||||
.addComponent(ledAirPressure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel15))
|
||||
.addGroup(jPanel11Layout.createSequentialGroup()
|
||||
.addComponent(ledN2Pressure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel16))
|
||||
.addGroup(jPanel11Layout.createSequentialGroup()
|
||||
.addComponent(ledLocalSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel19))
|
||||
.addGroup(jPanel11Layout.createSequentialGroup()
|
||||
.addComponent(ledPsysSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabell20)))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
jPanel11Layout.setVerticalGroup(
|
||||
jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel11Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(ledAirPressure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel15))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(ledN2Pressure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel16))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(ledLocalSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel19))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(ledPsysSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabell20)))
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(142, 142, 142)
|
||||
.addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGap(143, 143, 143)))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(84, 84, 84)
|
||||
.addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGap(84, 84, 84)))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel15;
|
||||
private javax.swing.JLabel jLabel16;
|
||||
private javax.swing.JLabel jLabel19;
|
||||
private javax.swing.JLabel jLabell20;
|
||||
private javax.swing.JPanel jPanel11;
|
||||
private ch.psi.pshell.swing.Led ledAirPressure;
|
||||
private ch.psi.pshell.swing.Led ledLocalSafety;
|
||||
private ch.psi.pshell.swing.Led ledN2Pressure;
|
||||
private ch.psi.pshell.swing.Led ledPsysSafety;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
Reference in New Issue
Block a user