This commit is contained in:
boccioli_m
2015-12-04 07:57:21 +01:00
parent 82c5aed6d3
commit a404ec6c7a
2 changed files with 51 additions and 20 deletions

View File

@@ -4,6 +4,7 @@ import ch.psi.jcae.ChannelException;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.device.DeviceAdapter;
import ch.psi.pshell.epics.ChannelDouble;
import ch.psi.pshell.epics.ChannelString;
import ch.psi.utils.State;
import gov.aps.jca.CAException;
import gov.aps.jca.Context;
@@ -28,12 +29,35 @@ public class Kollimators extends javax.swing.JPanel {
/**
* Creates new form Kollimators
*
* !!!! COMPULSORY FOR THE CALL FROM THE PLUGIN TESTINGLIST !!!!!
* .
* Called by TestingList when it opens this panel.
* @param params currently not used
*/
public Kollimators(String params) {
initComponents();
}
/**
* animate the panel (caget/caset)
* !!!! COMPULSORY FOR THE CALL FROM THE PLUGIN TESTINGLIST !!!!!
* .
* Called from TestingList when it starts animating this panel.
* This function MUST EXISTS in every custom panel callable from TestingList
* @param deviceName string containing the device name (without pv name, i.e. KMA5 and not KMA5:COM:1)
*/
public void animate(String deviceName) {
g_deviceName = deviceName;
jLabelDeviceName.setText(deviceName);
connectString(deviceName+":STA:2", jTextSta);
connect(deviceName+":DIST:2", jTextDist);
connect(deviceName+":IST1:1", jTextIst1);
connect(deviceName+":IST2:1", jTextIst2);
connect(deviceName+":REF1:1", jTextRef1);
connect(deviceName+":REF2:1", jTextRef2);
connect(deviceName+":IST1:1", jTextDir);//TODO: real channel??
connect(deviceName+":STA2:1", jTextRes);//TODO: real channel??
}
ChannelDouble channel;
String g_deviceName;
@@ -69,26 +93,33 @@ public class Kollimators extends javax.swing.JPanel {
System.out.println(ex.toString());
}
}
/**
* animate the panel (caget/caset).
* Called from TestingList.
* This function MUST EXISTS in every custom panel callable from TestingList
* @param deviceName string containing the device name (without pv name, i.e. KMA5 and not KMA5:COM:1)
* Connect to the PVs.
* And animate the corresponding test field on the panel.
*
* @param channelName name of the channel to connect to. Example: KMA5:STA2:1
* @param textField name of the text field to animate with the value of the channel
*/
public void animate(String deviceName) {
g_deviceName = deviceName;
jLabelDeviceName.setText(deviceName);
connect(deviceName+":STA2:1", jTextSta);
connect(deviceName+":IST1:1", jTextDist);
connect(deviceName+":IST1:1", jTextIst1);
connect(deviceName+":IST2:1", jTextIst2);
connect(deviceName+":REF1:1", jTextRef1);
connect(deviceName+":REF2:1", jTextRef2);
connect(deviceName+":IST1:1", jTextDir);
connect(deviceName+":STA2:1", jTextRes);
}
public void connectString(String channelName, JTextField textField) {
try {
ChannelString channel = new ChannelString(channelName, channelName);
channel.setMonitored(true);
channel.initialize();
channel.addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device channelName, Object value, Object former) {
String val = (String )value;
textField.setText(val);
textField.setToolTipText(channelName.getName());
}
});
//channel.close();
} catch (Exception ex) {
System.out.println(ex.toString());
}
}
/**
* Send stop command to the motor.