This commit is contained in:
@@ -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||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -816,10 +816,7 @@
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="checkCompression" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="59" pref="59" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="checkCompression" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerPasses" linkSize="3" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="checkZigzag" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerLatency" linkSize="3" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
|
||||
@@ -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<Nameable> add_pos= (List<Nameable>) 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<String, Double> preActions = (Map) config.get("PRE_ACTIONS");
|
||||
List<Integer> range = (List) config.getOrDefault("RANGE", new ArrayList());
|
||||
Map<String, Double> preActions = (Map) config.get("PRE_ACTIONS");
|
||||
List<Integer> range = (List) config.getOrDefault("RANGE", new ArrayList());
|
||||
|
||||
List<String> positioners = (List) config.get("POSITIONERS");
|
||||
List<Double> start = (List) config.get("START");
|
||||
List<Double> stop = (List) config.get("STOP");
|
||||
List<Integer> steps = (List) config.get("STEPS");
|
||||
List<String> positioners = (List) config.get("POSITIONERS");
|
||||
List<Double> start = (List) config.get("START");
|
||||
List<Double> stop = (List) config.get("STOP");
|
||||
List<Integer> 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<String>) config.get("SENSORS"));
|
||||
setDevices(textSnapshots, (List<String>) config.get("SNAPS"));
|
||||
setDevices(textDiagnostics, (List<String>) config.get("DIAGS"));
|
||||
setDevices(textMonitors, (List<String>) 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<String>) config.get("SENSORS"));
|
||||
setDevices(textSnapshots, (List<String>) config.get("SNAPS"));
|
||||
setDevices(textDiagnostics, (List<String>) config.get("DIAGS"));
|
||||
setDevices(textMonitors, (List<String>) 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<String> 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});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
|
||||
16
script/scans/test/test1.json
Normal file
16
script/scans/test/test1.json
Normal file
@@ -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" ]
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user