Startup
This commit is contained in:
130
plugins/Marco.java
Normal file
130
plugins/Marco.java
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* 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 Panel {
|
||||
|
||||
public Marco() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
ChannelDouble channel;
|
||||
|
||||
//Overridable callbacks
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
try {
|
||||
ChannelDouble channel = new ChannelDouble("MyChannel", "TESTIOC:TESTSINUS:SinCalc", 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));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//channel.close();
|
||||
|
||||
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChange(State state, State former) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecutedFile(String fileName, Object result) {
|
||||
}
|
||||
|
||||
|
||||
//Callback to perform update - in event thread
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
valuePanel = new ch.psi.pshell.swing.DeviceValuePanel();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
valueText = new javax.swing.JTextField();
|
||||
|
||||
jLabel1.setText("Value:");
|
||||
|
||||
valuePanel.setDeviceName("marco");
|
||||
|
||||
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()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(valuePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(valueText, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap(226, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(23, 23, 23)
|
||||
.addComponent(jLabel1))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(valuePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(valueText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(20, 20, 20))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private ch.psi.pshell.swing.DeviceValuePanel valuePanel;
|
||||
private javax.swing.JTextField valueText;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
Reference in New Issue
Block a user