Closedown

This commit is contained in:
x07maop
2015-08-24 10:14:35 +02:00
parent a39e103e94
commit 7b7d808339
5 changed files with 66 additions and 64 deletions
+1
View File
@@ -0,0 +1 @@
sample=ch.psi.pshell.imaging.MjpegSource http://x07ma-cam-5/axis-cgi/mjpg/video.cgi
+39 -39
View File
@@ -33,18 +33,18 @@ import ch.psi.pshell.ui.Panel;
*
*/
public class EnergyScan extends Panel {
public EnergyScan() {
initComponents();
buttonDefaultsActionPerformed(null);
}
ChannelDoubleArray data;
ChannelDoubleArray edata;
ChannelDoubleArray idata;
ChannelDoubleArray fdata;
ChannelInteger count;
double[] offsets = new double[4];
//Overridable callbacks
@@ -53,22 +53,22 @@ public class EnergyScan extends Panel {
super.onStart();
loadConfig();
}
@Override
public void onInitialize(int runCount) {
super.onInitialize(runCount);
count = (ChannelInteger) getController().getDevicePool().getByName("count");
data = (ChannelDoubleArray) getController().getDevicePool().getByName("data");
edata = (ChannelDoubleArray) getController().getDevicePool().getByName("edata");
idata = (ChannelDoubleArray) getController().getDevicePool().getByName("idata");
fdata = (ChannelDoubleArray) getController().getDevicePool().getByName("fdata");
getController().getDevicePool().getByName("count").addListener(new DeviceListener() {
@Override
public void onStateChanged(Device device, State state, State former) {
}
@Override
public void onValueChanged(Device device, Object value, Object former) {
update();
@@ -77,14 +77,14 @@ public class EnergyScan extends Panel {
update();
//loadConfig();
}
@Override
public void onStateChange(State state, State former) {
setEnabled(state == State.Ready);
}
long scanStartTimestamp;
@Override
public void onExecutedFile(String fileName, Object result) {
try {
@@ -113,34 +113,34 @@ public class EnergyScan extends Panel {
showException(ex);
}
}
@Override
protected void doUpdate() {
plot();
}
void stopScan() throws Exception {
evalAsync("caput('START', 'STOP')");
}
Path getConfigFile() {
return Paths.get(getController().getSetup().getConfigPath(), "energy_scan.properties");
}
enum Mode {
plus,
minus,
lh,
lv
}
Mode[] batch;
int batchIndex;
LinePlotBase scanPlot;
LinePlotSeries scanSeries;
@Override
public void setEnabled(boolean value) {
super.setEnabled(value);
@@ -154,7 +154,7 @@ public class EnergyScan extends Panel {
buttonPlot.setEnabled(value);
checkParameterControls();
}
void checkParameterControls() {
boolean enabled = isEnabled() && (comboRunType.getSelectedIndex() == 0);
for (Component c : panelParameters.getComponents()) {
@@ -164,7 +164,7 @@ public class EnergyScan extends Panel {
}
spinnerAlpha.setEnabled(enabled && comboMode.getSelectedItem().equals("LINEAR"));
}
void plot() {
try {
if ((scanPlot != null) && (scanSeries != null) && scanPlot.isShowing() && (count != null)) {
@@ -214,7 +214,7 @@ public class EnergyScan extends Panel {
ex.printStackTrace();
}
}
void loadConfig() {
DefaultComboBoxModel model = (DefaultComboBoxModel) comboSetup.getModel();
model.removeAllElements();
@@ -230,7 +230,7 @@ public class EnergyScan extends Panel {
} catch (Exception ex) {
}
}
String expandPath(String path) {
long time = System.currentTimeMillis();
String mode;
@@ -241,7 +241,7 @@ public class EnergyScan extends Panel {
} else {
mode = "lin_" + String.format("%1.0f", (Double) spinnerAlpha.getValue());
}
path = path.replaceAll("\\{date\\}", Chrono.getTimeStr(time, "YYYYMMdd"));
path = path.replaceAll("\\{time\\}", Chrono.getTimeStr(time, "HHmmss"));
path = path.replaceAll("\\{year\\}", Chrono.getTimeStr(time, "YYYY"));
@@ -251,7 +251,7 @@ public class EnergyScan extends Panel {
path = path.replaceAll("\\{mode\\}", mode);
return path;
}
void setMode(Mode mode) {
switch (mode) {
case plus:
@@ -274,11 +274,11 @@ public class EnergyScan extends Panel {
return;
}
}
boolean isManualRun() {
return (comboRunType.getSelectedIndex() == 0);
}
void setElement() throws Exception {
Properties prop = new Properties();
prop.load(new FileInputStream(getConfigFile().toFile()));
@@ -292,13 +292,13 @@ public class EnergyScan extends Panel {
spinnerE2.setValue(Double.valueOf(tokens[1].trim()));
spinnerTime.setValue(Double.valueOf(tokens[2].trim()));
spinnerDelay.setValue(Double.valueOf(tokens[3].trim()));
offsets[0] = Double.valueOf(tokens[4].trim());
offsets[1] = Double.valueOf(tokens[5].trim());
offsets[2] = Double.valueOf(tokens[6].trim());
offsets[3] = Double.valueOf(tokens[7].trim());
}
void setRunType() throws Exception {
switch (comboRunType.getSelectedIndex()) {
case 0: //Manual
@@ -330,7 +330,7 @@ public class EnergyScan extends Panel {
}
checkParameterControls();
}
void run() throws ControllerStateException {
HashMap args = new HashMap();
Double e1 = (Double) spinnerE1.getValue();
@@ -342,35 +342,35 @@ public class EnergyScan extends Panel {
args.put("MODE", comboMode.getSelectedItem().toString());
args.put("OFFSET", (Double) spinnerOffset.getValue());
args.put("ALPHA", (Double) spinnerAlpha.getValue());
String file = expandPath(textFile.getText());
args.put("FILE", file);
String folder = expandPath(textFolder.getText());
args.put("FOLDER", folder);
scanStartTimestamp = System.currentTimeMillis();
buttonAbort.setEnabled(true);
runAsync("EnergyScan", args).handle((ok, ex) -> {
buttonAbort.setEnabled(false);
if (ex != null){
if (ex != null) {
getLogger().log(Level.WARNING, null, ex);
}
}
return ok;
});
if (scanPlot != null) {
scanPlot.getAxis(Plot.AxisId.X).setRange(Math.min(e1, e2), Math.max(e1, e2));
}
}
void startPlot() throws Exception {
PlotDescriptor descriptors = new PlotDescriptor("Energy Scan");
ArrayList<LinePlot> plots = getController().plot(new PlotDescriptor[]{descriptors}, null);
scanPlot = (LinePlotBase) plots.get(0);
scanSeries = scanPlot.getSeries(0);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
@@ -833,7 +833,7 @@ public class EnergyScan extends Panel {
showException(ex);
}
}//GEN-LAST:event_comboSetupActionPerformed
EditorDialog dlgConfig;
private void buttonConfigureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigureActionPerformed
try {
@@ -847,7 +847,7 @@ public class EnergyScan extends Panel {
editor.setTitle("Energy Scan Configuration");
}
dlgConfig.setSize(680, 320);
showWindow(dlgConfig);
showWindow(dlgConfig);
} catch (Exception ex) {
showException(ex);
}
+2 -2
View File
@@ -138,7 +138,7 @@
<Component class="javax.swing.JSpinner" name="spinnerE1">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="690.0" maximum="9999.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
<SpinnerModel initial="707.9" maximum="9999.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
@@ -151,7 +151,7 @@
<Component class="javax.swing.JSpinner" name="spinnerE2">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="755.0" maximum="9999.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
<SpinnerModel initial="703.9" maximum="9999.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
+21 -18
View File
@@ -5,6 +5,7 @@
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import java.awt.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Level;
import javax.swing.JLabel;
@@ -13,14 +14,14 @@ import javax.swing.JLabel;
*
*/
public class HystScan extends Panel {
final static boolean POP_SCRIPT_EXCEPTIONS = true;
public HystScan() {
initComponents();
}
//Overridable callbacks
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
@@ -35,13 +36,11 @@ public class HystScan extends Panel {
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
@Override
public void setEnabled(boolean value) {
super.setEnabled(value);
@@ -51,7 +50,7 @@ public class HystScan extends Panel {
c.setEnabled(value);
}
}
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@@ -79,12 +78,12 @@ public class HystScan extends Panel {
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel1.setText("E1:");
spinnerE1.setModel(new javax.swing.SpinnerNumberModel(690.0d, 0.0d, 9999.0d, 1.0d));
spinnerE1.setModel(new javax.swing.SpinnerNumberModel(707.9d, 0.0d, 9999.0d, 1.0d));
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("E2:");
spinnerE2.setModel(new javax.swing.SpinnerNumberModel(755.0d, 0.0d, 9999.0d, 1.0d));
spinnerE2.setModel(new javax.swing.SpinnerNumberModel(703.9d, 0.0d, 9999.0d, 1.0d));
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel8.setText("Ramp Rate:");
@@ -237,21 +236,25 @@ public class HystScan extends Panel {
HashMap args = new HashMap();
Double e1 = (Double) spinnerE1.getValue();
Double e2 = (Double) spinnerE2.getValue();
args.put("E1", e1);
args.put("E2", e2);
//args.put("E1", e1);
//args.put("E2", e2);
ArrayList<Double> energies = new ArrayList<>();
energies.add(e1);
energies.add(e2);
args.put("ENERGIES", energies);
args.put("START_FIELD", (Double) spinnerStartField.getValue());
args.put("END_FIELD", (Double) spinnerEndField.getValue());
args.put("RAMP_RATE", (Double) spinnerRampRate.getValue());
args.put("ENERGY_CHANGE_SLEEP", (Double) spinnerSleep.getValue());
buttonAbort.setEnabled(true);
runAsync("HystScan", args).handle((ok, ex) -> {
buttonAbort.setEnabled(false);
if (ex != null){
getLogger().log(Level.WARNING, null, ex);
}
return ok;
});
runAsync("HystScan", args).handle((ok, ex) -> {
buttonAbort.setEnabled(false);
if (ex != null) {
getLogger().log(Level.WARNING, null, ex);
}
return ok;
});
} catch (Exception ex) {
showException(ex);
}
+3 -5
View File
@@ -1,12 +1,14 @@
#Script imported from: Fe_hyst_plus.xml
#Parameters
"""
START_FIELD = -0.2
END_FIELD = 0.2
ENERGIES = (707.90, 703.90)
RAMP_RATE = 2.0
ENERGY_CHANGE_SLEEP = 0.5
"""
raise Exception("")
#Pre-actions
#cawait('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's')
#caput('X07MA-ID:MODE', 'CIRC +')
@@ -79,10 +81,6 @@ caputq("X07MA-PC-MAG:STARTRAMP.PROC", 1)
index = 0
while(True):
#Dimension 2START_FIELD = -0.2
END_FIELD = 0.2
ENERGIES = (707.90, 703.90)
RAMP_RATE = 2.0
#ArrayPositioner Energy
for setpoint2 in ENERGIES:
Energy.put(setpoint2, timeout=None) # TODO: Set appropriate timeout