114 lines
3.9 KiB
Java
114 lines
3.9 KiB
Java
/*
|
|
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
|
|
*/
|
|
|
|
import ch.psi.jcae.Channel;
|
|
import ch.psi.jcae.ChannelException;
|
|
import ch.psi.pshell.device.Device;
|
|
import ch.psi.pshell.device.DeviceAdapter;
|
|
import ch.psi.pshell.device.DeviceListener;
|
|
import ch.psi.pshell.epics.ChannelDouble;
|
|
import ch.psi.pshell.epics.Epics;
|
|
import ch.psi.pshell.epics.EpicsRegister;
|
|
import ch.psi.pshell.ui.Panel;
|
|
import ch.psi.utils.State;
|
|
import java.util.concurrent.TimeoutException;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public class Marco extends javax.swing.JPanel {
|
|
|
|
public Marco() {
|
|
initComponents();
|
|
}
|
|
public Marco (String params) {
|
|
initComponents();
|
|
//connect("XPROLUFT");
|
|
connect("");
|
|
}
|
|
|
|
ChannelDouble channel;
|
|
|
|
//Overridable callbacks
|
|
public void onInitialize(int runCount) {
|
|
initComponents();
|
|
connect("");
|
|
}
|
|
|
|
public void connect(String device) {
|
|
try {
|
|
ChannelDouble channel = new ChannelDouble(device+"SIM-MMAC3:STR:2", device+"SIM-MMAC3:STR:2", 3);
|
|
channel.setMonitored(true);
|
|
channel.initialize();
|
|
|
|
channel.addListener(new DeviceAdapter() {
|
|
@Override
|
|
public void onValueChanged(Device device, Object value, Object former) {
|
|
Double val = (Double )value;
|
|
valueText.setText(String.valueOf(val));
|
|
valueText.setToolTipText(device.getName());
|
|
}
|
|
});
|
|
//channel.close();
|
|
} catch (Exception ex) {
|
|
System.out.println(ex.toString());
|
|
}
|
|
}
|
|
|
|
public void onStateChange(State state, State former) {
|
|
|
|
}
|
|
|
|
public void onExecutedFile(String fileName, Object result) {
|
|
}
|
|
|
|
|
|
//Callback to perform update - in event thread
|
|
protected void doUpdate() {
|
|
}
|
|
|
|
public void animate(String deviceName) {
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
private void initComponents() {
|
|
|
|
jLabel2 = new javax.swing.JLabel();
|
|
valueText = new javax.swing.JTextField();
|
|
|
|
jLabel2.setText("Value:");
|
|
|
|
valueText.setEditable(false);
|
|
|
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
|
this.setLayout(layout);
|
|
layout.setHorizontalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addContainerGap()
|
|
.addComponent(jLabel2)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addComponent(valueText, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addContainerGap(226, Short.MAX_VALUE))
|
|
);
|
|
layout.setVerticalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addGap(0, 0, 0)
|
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
.addComponent(valueText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addComponent(jLabel2))
|
|
.addGap(0, 0, 0))
|
|
);
|
|
}// </editor-fold>//GEN-END:initComponents
|
|
|
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
private javax.swing.JLabel jLabel2;
|
|
private javax.swing.JTextField valueText;
|
|
// End of variables declaration//GEN-END:variables
|
|
}
|