156 lines
5.2 KiB
Java
156 lines
5.2 KiB
Java
|
|
import ch.psi.pshell.framework.ScriptProcessor;
|
|
import ch.psi.pshell.framework.Task;
|
|
import ch.psi.pshell.utils.State;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public class TestScript extends ScriptProcessor {
|
|
|
|
//TODO: set script name
|
|
public static final String SCRIPT_NAME = "test/TestScript";
|
|
|
|
public TestScript() {
|
|
initComponents();
|
|
}
|
|
|
|
|
|
//Overridable callbacks
|
|
@Override
|
|
public void onInitialize(int runCount) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onStateChange(State state, State former) {
|
|
spinnerSamples.setEnabled(state.isReady());
|
|
spinnerInterval.setEnabled(state.isReady());
|
|
}
|
|
|
|
@Override
|
|
public void onExecutedFile(String fileName, Object result) {
|
|
}
|
|
|
|
@Override
|
|
public void onTaskFinished(Task task) {
|
|
}
|
|
|
|
@Override
|
|
protected void onTimer() {
|
|
}
|
|
|
|
@Override
|
|
protected void onLoaded() {
|
|
|
|
}
|
|
|
|
@Override
|
|
protected void onUnloaded() {
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
protected void onStartingExecution(Map<String, Object> args) throws Exception{
|
|
}
|
|
|
|
@Override
|
|
protected void onFinishedExecution(Map<String, Object> args, Object ret, Throwable t) throws Exception{
|
|
}
|
|
|
|
|
|
//Invoked by 'update()' to update components in the event thread
|
|
@Override
|
|
protected void doUpdate() {
|
|
}
|
|
|
|
|
|
@Override
|
|
public String getScript(){
|
|
return SCRIPT_NAME;
|
|
}
|
|
|
|
@Override
|
|
public Map<String, Object> getArgs(){
|
|
//TODO: add script arguments
|
|
Map<String, Object> ret = new HashMap<>();
|
|
ret.put("samples", ((Number)spinnerSamples.getValue()).intValue());
|
|
ret.put("interval", ((Number)spinnerInterval.getValue()).doubleValue());
|
|
return ret;
|
|
}
|
|
|
|
@Override
|
|
public boolean canPause() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public void clear() {
|
|
spinnerSamples.setValue(10);
|
|
spinnerInterval.setValue(0.1);
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
private void initComponents() {
|
|
|
|
jLabel1 = new javax.swing.JLabel();
|
|
jLabel2 = new javax.swing.JLabel();
|
|
spinnerInterval = new javax.swing.JSpinner();
|
|
spinnerSamples = new javax.swing.JSpinner();
|
|
|
|
jLabel1.setText("Samples:");
|
|
|
|
jLabel2.setText("Interval:");
|
|
|
|
spinnerInterval.setModel(new javax.swing.SpinnerNumberModel(0.1d, 0.001d, 1000.0d, 1.0d));
|
|
|
|
spinnerSamples.setModel(new javax.swing.SpinnerNumberModel(10, 1, 1000, 1));
|
|
|
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
|
this.setLayout(layout);
|
|
layout.setHorizontalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addGap(60, 60, 60)
|
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addComponent(jLabel2)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
.addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addComponent(jLabel1)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addComponent(spinnerSamples, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
|
.addContainerGap(74, Short.MAX_VALUE))
|
|
);
|
|
|
|
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerInterval, spinnerSamples});
|
|
|
|
layout.setVerticalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addGap(26, 26, 26)
|
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
.addComponent(jLabel1)
|
|
.addComponent(spinnerSamples, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
.addComponent(jLabel2)
|
|
.addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addContainerGap(94, Short.MAX_VALUE))
|
|
);
|
|
}// </editor-fold>//GEN-END:initComponents
|
|
|
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
private javax.swing.JLabel jLabel1;
|
|
private javax.swing.JLabel jLabel2;
|
|
private javax.swing.JSpinner spinnerInterval;
|
|
private javax.swing.JSpinner spinnerSamples;
|
|
// End of variables declaration//GEN-END:variables
|
|
}
|