diff --git a/config/devices.properties b/config/devices.properties
index 2d25ecf..c1ab6a9 100644
--- a/config/devices.properties
+++ b/config/devices.properties
@@ -15,7 +15,7 @@ id_status=ch.psi.pshell.epics.ChannelString|X09LA-ID:OFFS-MNTR|Read||true
shutter=ch.psi.pshell.epics.DiscretePositioner|X09LA-SIS:OPEN|||true
grating=ch.psi.pshell.epics.DiscretePositioner|X09LA-PGM-GRCH:GRATING X09LA-PGM:grating|||true
pgm_cff=ch.psi.pshell.epics.Positioner|X09LA-PGM:cff.A.SETP X09LA-PGM:cff.A.VAL|||true
-$photon_energy=ch.psi.pshell.epics.Positioner|X09LA-PHS:E_SP X09LA-PGM:rbkenergy|||true
+photon_energy=ch.psi.pshell.epics.Positioner|X09LA-PHS:E_SP X09LA-PGM:rbkenergy|||true
oper_mode=ch.psi.pshell.epics.DiscretePositioner|X09LA-PHS-E:OPT|||true
temp_cryostat=ch.psi.pshell.epics.ReadonlyProcessVariable|X09LA-PC-LAKESHORE:TEMP_RBV|Read||false
temp_sample1=ch.psi.pshell.epics.ReadonlyProcessVariable|X09LA-PC-LAKESHORE:TEMP-B|Read||
diff --git a/config/variables.properties b/config/variables.properties
index a483c7e..caf1831 100644
--- a/config/variables.properties
+++ b/config/variables.properties
@@ -1,4 +1,4 @@
-#Tue Dec 07 14:58:23 CET 2021
-LastRunDate=211207
-DaySequentialNumber=1
-FileSequentialNumber=80
+#Wed Dec 08 11:53:43 CET 2021
+LastRunDate=211208
+DaySequentialNumber=16
+FileSequentialNumber=96
diff --git a/plugins/SIStem.form b/plugins/SIStem.form
index a93ce6e..0a14b5f 100644
--- a/plugins/SIStem.form
+++ b/plugins/SIStem.form
@@ -816,10 +816,7 @@
-
-
-
-
+
diff --git a/plugins/SIStem.java b/plugins/SIStem.java
index 3cba2e9..e8e711b 100644
--- a/plugins/SIStem.java
+++ b/plugins/SIStem.java
@@ -1,6 +1,7 @@
import ch.psi.pshell.core.Context;
import ch.psi.pshell.core.JsonSerializer;
+import ch.psi.pshell.core.Nameable;
import ch.psi.pshell.device.DiscretePositioner;
import ch.psi.pshell.device.MasterPositioner;
import ch.psi.pshell.device.Motor;
@@ -72,7 +73,7 @@ public class SIStem extends PanelProcessor {
final JComboBox[] scientaCombos;
final JTextField[] scientaRangeFields;
final JComboBox[] deviceCombos;
-
+ String[] additionalPositioners ;
boolean intialized;
public SIStem() {
@@ -207,48 +208,59 @@ public class SIStem extends PanelProcessor {
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
- if (runCount == 0) {
+ if ((runCount == 0)&&(getFileName()==null)) {
clear();
}
- if (getState()==State.Ready){
- onStateChange(State.Ready, State.Initializing);
+
+ if (!intialized) {
+ try {
+ Class enumClass = (Class) eval("scienta.getLensModeClass()", true);
+ String[] mode_position = (String[]) eval("id_mode.getPositions()", true);
+ String[] grating_position = (String[]) eval("grating.getPositions()", true);
+ List add_pos= (List) eval("get_additional_positioners()", true);
+ additionalPositioners = new String[add_pos.size()];
+ for (int i=0; i< add_pos.size(); i++){
+ additionalPositioners[i]=add_pos.get(i).getName();
+ }
+ SwingUtilities.invokeLater(() -> {
+ try {
+ SwingUtils.setEnumCombo(comboLens, enumClass, true);
+ SwingUtils.insertCombo(comboLens, "", 0);
+ comboLens.setSelectedIndex(0);
+
+ comboPol.setModel(new DefaultComboBoxModel(mode_position));
+ SwingUtils.insertCombo(comboPol, "", 0);
+ comboPol.setSelectedIndex(0);
+
+ comboGrating.setModel(new DefaultComboBoxModel(grating_position));
+ SwingUtils.insertCombo(comboGrating, "", 0);
+ comboGrating.setSelectedIndex(0);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ Logger.getLogger(SIStem.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ String filename = getFileName();
+ clear();
+ if (filename!=null){
+ try {
+ open(filename);
+ } catch (IOException ex) {
+ Logger.getLogger(SIStem.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ });
+ intialized = true;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ Logger.getLogger(SIStem.class.getName()).log(Level.SEVERE, null, ex);
+ }
}
+
updateMaster();
}
@Override
public void onStateChange(State state, State former) {
- if (!intialized) {
- if ((state == State.Ready) && (former == State.Initializing)) {
- try {
- Class enumClass = (Class) eval("scienta.getLensModeClass()");
- String[] mode_position = (String[]) eval("id_mode.getPositions()");
- String[] grating_position = (String[]) eval("grating.getPositions()");
- SwingUtilities.invokeLater(() -> {
- try {
- SwingUtils.setEnumCombo(comboLens, enumClass, true);
- SwingUtils.insertCombo(comboLens, "", 0);
- comboLens.setSelectedIndex(0);
-
- comboPol.setModel(new DefaultComboBoxModel(mode_position));
- SwingUtils.insertCombo(comboPol, "", 0);
- comboPol.setSelectedIndex(0);
-
- comboGrating.setModel(new DefaultComboBoxModel(grating_position));
- SwingUtils.insertCombo(comboGrating, "", 0);
- comboGrating.setSelectedIndex(0);
- } catch (Exception ex) {
- ex.printStackTrace();
- Logger.getLogger(SIStem.class.getName()).log(Level.SEVERE, null, ex);
- }
- });
- intialized = true;
- } catch (Exception ex) {
- ex.printStackTrace();
- Logger.getLogger(SIStem.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
updateControls();
}
@@ -373,69 +385,72 @@ public class SIStem extends PanelProcessor {
@Override
public void open(String fileName) throws IOException {
clear();
- if (fileName != null) {
- Path path = Paths.get(fileName);
- String json = new String(Files.readAllBytes(path));
- currentFile = path.toFile();
- Map config = (Map) JsonSerializer.decode(json, Map.class);
+ try{
+ if (fileName != null) {
+ Path path = Paths.get(fileName);
+ String json = new String(Files.readAllBytes(path));
+ currentFile = path.toFile();
+ Map config = (Map) JsonSerializer.decode(json, Map.class);
- Map preActions = (Map) config.get("PRE_ACTIONS");
- List range = (List) config.getOrDefault("RANGE", new ArrayList());
+ Map preActions = (Map) config.get("PRE_ACTIONS");
+ List range = (List) config.getOrDefault("RANGE", new ArrayList());
- List positioners = (List) config.get("POSITIONERS");
- List start = (List) config.get("START");
- List stop = (List) config.get("STOP");
- List steps = (List) config.get("STEPS");
+ List positioners = (List) config.get("POSITIONERS");
+ List start = (List) config.get("START");
+ List stop = (List) config.get("STOP");
+ List steps = (List) config.get("STEPS");
- for (String name : preActions.keySet()) {
- for (JComboBox combo : deviceCombos) {
- if (name.equals(combo.getName())) {
- combo.setSelectedItem(String.valueOf(preActions.get(name)));
- break;
+ for (String name : preActions.keySet()) {
+ for (JComboBox combo : deviceCombos) {
+ if (name.equals(combo.getName())) {
+ combo.setSelectedItem(String.valueOf(preActions.get(name)));
+ break;
+ }
+ }
+ for (JComboBox combo : scientaCombos) {
+ if (name.equals(combo.getName())) {
+ combo.setSelectedItem(String.valueOf(preActions.get(name)));
+ break;
+ }
}
- }
- for (JComboBox combo : scientaCombos) {
- if (name.equals(combo.getName())) {
- combo.setSelectedItem(String.valueOf(preActions.get(name)));
- break;
+ for (JTextField text : Arr.append(scientaFloatFields, scientaIntFields)) {
+ if (name.equals(text.getName())) {
+ text.setText(String.valueOf(preActions.get(name)));
+ break;
+ }
+ }
+ for (int i = 0; i < range.size(); i++) {
+ if (range.get(i) != null) {
+ scientaRangeFields[i].setText(String.valueOf(range.get(i)).trim());
+ }
+ }
+ Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class);
+ if (pos != null) {
+ addDevice(pos, modelFixed, -1, new Object[]{name, preActions.get(name), pos.getUnit()});
}
}
- for (JTextField text : Arr.append(scientaFloatFields, scientaIntFields)) {
- if (name.equals(text.getName())) {
- text.setText(String.valueOf(preActions.get(name)));
- break;
+ for (int i = 0; i < positioners.size(); i++) {
+ String name = positioners.get(i);
+ Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class);
+ if (pos != null) {
+ addDevice(pos, modelScanned, -1, new Object[]{name, start.get(i), stop.get(i), steps.get(i) + 1, pos.getUnit()});
}
}
- for (int i = 0; i < range.size(); i++) {
- if (range.get(i) != null) {
- scientaRangeFields[i].setText(String.valueOf(range.get(i)).trim());
- }
- }
- Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class);
- if (pos != null) {
- addDevice(pos, modelFixed, -1, new Object[]{name, preActions.get(name), pos.getUnit()});
- }
+
+ setDevices(textSensors, (List) config.get("SENSORS"));
+ setDevices(textSnapshots, (List) config.get("SNAPS"));
+ setDevices(textDiagnostics, (List) config.get("DIAGS"));
+ setDevices(textMonitors, (List) config.get("MONITORS"));
+
+ spinnerLatency.setValue(config.get("SETTLING_TIME"));
+ spinnerPasses.setValue(config.get("PASSES"));
+ checkZigzag.setSelected((Boolean) config.get("ZIGZAG"));
+ checkCompression.setSelected((Boolean) config.get("COMPRESSION"));
+ updateDetectorPlot();
}
- for (int i = 0; i < positioners.size(); i++) {
- String name = positioners.get(i);
- Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class);
- if (pos != null) {
- addDevice(pos, modelScanned, -1, new Object[]{name, start.get(i), stop.get(i), steps.get(i) + 1, pos.getUnit()});
- }
- }
-
- setDevices(textSensors, (List) config.get("SENSORS"));
- setDevices(textSnapshots, (List) config.get("SNAPS"));
- setDevices(textDiagnostics, (List) config.get("DIAGS"));
- setDevices(textMonitors, (List) config.get("MONITORS"));
-
- spinnerLatency.setValue(config.get("SETTLING_TIME"));
- spinnerPasses.setValue(config.get("PASSES"));
- checkZigzag.setSelected((Boolean) config.get("ZIGZAG"));
- checkCompression.setSelected((Boolean) config.get("COMPRESSION"));
- updateDetectorPlot();
+ } finally{
+ updateControls();
}
- updateControls();
}
@Override
@@ -510,14 +525,15 @@ public class SIStem extends PanelProcessor {
List names = new ArrayList<>();
names.addAll(Arrays.asList(getContext().getDevicePool().getAllNamesOrderedByName(Motor.class)));
names.addAll(Arrays.asList(getContext().getDevicePool().getAllNamesOrderedByName(MasterPositioner.class)));
- names.add("energy");
- names.add("exit_slit");
- names.add("fe_vert_width");
- names.add("fe_horiz_width");
- names.add("cff");
-
- for (String name : names) {
- modelInactive.addRow(new Object[]{name});
+ if (!names.isEmpty()){
+ if (additionalPositioners!=null){
+ for (String name:additionalPositioners){
+ names.add(name);
+ }
+ }
+ for (String name : names) {
+ modelInactive.addRow(new Object[]{name});
+ }
}
}
diff --git a/script/local.py b/script/local.py
index 3c87455..b89878a 100644
--- a/script/local.py
+++ b/script/local.py
@@ -2,7 +2,15 @@
# Deployment specific global definitions - executed after startup.py
###################################################################################################
-
+def get_additional_positioners():
+ ret = []
+ try:
+ for dev in [exit_slit, fe_vert_width, fe_horiz_width, cff, energy]:
+ ret.append(dev)
+ except:
+ log("Error getting additional positioner: " + str(sys.exc_info()[1]))
+ return ret
+
###################################################################################################
# Device initialization
@@ -11,7 +19,10 @@ class Energy(PositionerBase):
def __init__(self, name, config):
ControlledVariableBase.__init__(self, name, photon_energy.config)
self.setReadback(photon_energy.getReadback())
-
+
+ def take(self):
+ return photon_energy.take()
+
def doRead(self):
return photon_energy.read()
@@ -66,6 +77,9 @@ class Cff(PositionerBase):
def doRead(self):
return pgm_cff.read()
+ def take(self):
+ return pgm_cff.take()
+
def doWrite(self, val):
if not pgm_cff.isInPosition(val):
change_photon_pars(_cff=val)
@@ -109,6 +123,7 @@ fe_state.setSettlingCondition(FeSettlingCondition())
oper_mode.getSetpoint().setBlockingWrite(True)
photon_energy.setSettlingCondition(IdSettlingCondition())
id_mode.setSettlingCondition(IdSettlingCondition())
+id_mode.setpoint.blockingWrite=True
grating.setSettlingCondition(GrSettlingCondition())
pgm_cff.setSettlingCondition(CffSettlingCondition())
diff --git a/script/scans/scan1.json b/script/scans/test/scan1.json
similarity index 100%
rename from script/scans/scan1.json
rename to script/scans/test/scan1.json
diff --git a/script/scans/scan2.json b/script/scans/test/scan2.json
similarity index 100%
rename from script/scans/scan2.json
rename to script/scans/test/scan2.json
diff --git a/script/scans/scan3.json b/script/scans/test/scan3.json
similarity index 100%
rename from script/scans/scan3.json
rename to script/scans/test/scan3.json
diff --git a/script/scans/scan4.json b/script/scans/test/scan4.json
similarity index 100%
rename from script/scans/scan4.json
rename to script/scans/test/scan4.json
diff --git a/script/scans/scan5.json b/script/scans/test/scan5.json
similarity index 100%
rename from script/scans/scan5.json
rename to script/scans/test/scan5.json
diff --git a/script/scans/test/test1.json b/script/scans/test/test1.json
new file mode 100644
index 0000000..3a3e694
--- /dev/null
+++ b/script/scans/test/test1.json
@@ -0,0 +1,16 @@
+{
+ "PASSES" : 1,
+ "STOP" : [ 42.0 ],
+ "DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ],
+ "PRE_ACTIONS" : { },
+ "COMPRESSION" : true,
+ "SENSORS" : [ "scienta.dataMatrix" ],
+ "ZIGZAG" : false,
+ "SETTLING_TIME" : 0.0,
+ "MONITORS" : [ "current" ],
+ "START" : [ 40.0 ],
+ "RANGE" : [ null, null, null, null ],
+ "POSITIONERS" : [ "energy" ],
+ "STEPS" : [ 4 ],
+ "SNAPS" : [ "acmi", "cff", "energy", "exit_slit", "fe_horiz_width", "fe_vert_width", "helium_valve", "master", "pgm_cff", "photon_energy", "tcmp", "temp_boot1", "temp_boot2", "temp_cryopump", "temp_cryostat", "temp_headmech", "temp_sample1", "temp_sample2", "temp_shield" ]
+}
\ No newline at end of file
diff --git a/script/templates/SIStem.py b/script/templates/SIStem.py
index da90e62..6f48543 100644
--- a/script/templates/SIStem.py
+++ b/script/templates/SIStem.py
@@ -29,6 +29,7 @@ def load_parameters(name):
if NAME:
load_parameters(NAME)
+reinit(None)
#Enforece parameter types
positioners = string_to_obj(POSITIONERS)
@@ -50,7 +51,7 @@ if "grating" in PRE_ACTIONS.keys():
if (_id_mode is not None) or (_grating is not None):
print _id_mode, _grating
change_photon_pars(_id_mode=_id_mode, _grating=_grating)
-1/0
+
#Execute pre-actions
for key in PRE_ACTIONS.keys():
if key=="eval":
@@ -73,7 +74,7 @@ if COMPRESSION:
set_exec_pars(compression=[scienta.dataMatrix])
-def before_read(pos, scan):
+def before_read(pos, scan):
trigger_scienta()
@@ -82,12 +83,15 @@ def after_read(rec, scan):
pass
try:
- ret= ascan (positioners, sensors, start, end, steps, \
- latency= latency, relative=False, passes=passes, zigzag=zigzag, \
- before_read=before_read, after_read=after_read, \
- snaps=SNAPS, diags=DIAGS, monitors=MONITORS)
+ if len(positioners)==0:
+ ret= tscan (sensors, 1,0, passes=passes, \
+ before_read=before_read, after_read=after_read, \
+ snaps=SNAPS, diags=DIAGS, monitors=MONITORS)
+ else:
+ ret= ascan (positioners, sensors, start, end, steps, \
+ latency= latency, relative=False, passes=passes, zigzag=zigzag, \
+ before_read=before_read, after_read=after_read, \
+ snaps=SNAPS, diags=DIAGS, monitors=MONITORS)
finally:
scienta.zeroSupplies()
- pass
-