Scan private master axis

This commit is contained in:
gac-x09la
2022-01-19 11:03:26 +01:00
parent 919c6f8a98
commit 34661df5b9
7 changed files with 297 additions and 24 deletions
+4 -4
View File
@@ -1,4 +1,4 @@
#Wed Dec 08 11:53:43 CET 2021
LastRunDate=211208
DaySequentialNumber=16
FileSequentialNumber=96
#Wed Jan 19 10:05:40 CET 2022
LastRunDate=220119
DaySequentialNumber=1
FileSequentialNumber=97
+18
View File
@@ -0,0 +1,18 @@
#Tue Jan 18 17:01:53 CET 2022
slave2Positions=-1.0|1.5
offset=0.0
maxValue=NaN
slave5Positions=null
rotation=false
precision=-1
scale=1.0
slave4Positions=null
resolution=NaN
mode=LINEAR
minValue=NaN
unit=null
slave1Positions=-1.0|2.0
slave3Positions=null
sign_bit=0
masterPositions=-1.0|1.0
slave6Positions=null
+18
View File
@@ -0,0 +1,18 @@
#Wed Jan 19 10:53:26 CET 2022
slave2Positions=null
offset=0.0
maxValue=NaN
slave5Positions=null
rotation=false
precision=-1
scale=1.0
slave4Positions=null
resolution=NaN
mode=LINEAR
minValue=NaN
unit=null
slave1Positions=null
slave3Positions=null
sign_bit=0
masterPositions=null
slave6Positions=null
+25 -9
View File
@@ -970,9 +970,17 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane8" pref="743" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="buttonEditMaster" min="-2" pref="100" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="buttonPrivateMasterAxis" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jScrollPane8" pref="743" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="buttonEditMaster" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@@ -980,14 +988,14 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="buttonEditMaster" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="jScrollPane8" pref="282" max="32767" attributes="0"/>
<Component id="jScrollPane8" pref="238" max="32767" attributes="0"/>
<Component id="buttonEditMaster" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="13" max="-2" attributes="0"/>
<Component id="buttonPrivateMasterAxis" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -1037,6 +1045,14 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonEditMasterActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="buttonPrivateMasterAxis">
<Properties>
<Property name="text" type="java.lang.String" value="Create private master axis"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonPrivateMasterAxisActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel1">
+152 -11
View File
@@ -4,8 +4,10 @@ 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.MasterPositionerConfig;
import ch.psi.pshell.device.Motor;
import ch.psi.pshell.device.Positioner;
import ch.psi.pshell.device.PositionerBase;
import ch.psi.pshell.device.ProcessVariable;
import ch.psi.pshell.device.ReadonlyProcessVariable;
import ch.psi.pshell.device.Register;
@@ -205,6 +207,19 @@ public class SIStem extends PanelProcessor {
}
}
boolean hasDevice(ProcessVariable dev) {
return (hasDevice(dev, modelInactive) || hasDevice(dev, modelFixed) || hasDevice(dev, modelScanned));
}
boolean hasDevice(ProcessVariable dev, DefaultTableModel model) {
for (int i = 0; i < model.getRowCount(); i++) {
if (model.getValueAt(i, 0).equals(dev.getName())) {
return true;
}
}
return false;
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
@@ -376,7 +391,20 @@ public class SIStem extends PanelProcessor {
config.put("PASSES", spinnerPasses.getValue());
config.put("ZIGZAG", checkZigzag.isSelected());
config.put("COMPRESSION", checkCompression.isSelected());
if (privateMasterAxis!=null){
Map masterAxis = new HashMap();
masterAxis.put("NAME", privateMasterAxis.getName());
masterAxis.put("MASTER", privateMasterAxis.getMaster().getName());
List<String> slaves = new ArrayList<>();
for (Positioner p : privateMasterAxis.getSlaves()){
slaves.add(p.getName());
}
masterAxis.put("SLAVES", slaves);
masterAxis.put("CONFIG", privateMasterAxis.getConfig());
config.put("MASTER_AXIS", masterAxis);
}
String json = JsonSerializer.encode(config, true);
Files.write(currentFile.toPath(), json.getBytes());
updateControls();
@@ -391,6 +419,32 @@ public class SIStem extends PanelProcessor {
String json = new String(Files.readAllBytes(path));
currentFile = path.toFile();
Map config = (Map) JsonSerializer.decode(json, Map.class);
Map<String, Object> masterAxis = (Map) config.get("MASTER_AXIS");
if (masterAxis!=null){
String name = (String) masterAxis.get("NAME");
String master = (String) masterAxis.get("MASTER");
List<String> slaves = (List<String>) masterAxis.get("SLAVES");
Map<String, Object> cfg = (Map<String, Object>) masterAxis.get("CONFIG");
Positioner[] slaveDevices = new PositionerBase[slaves.size()];
for (int i=0; i<slaves.size(); i++){
slaveDevices[i] = (Positioner)getDevice(slaves.get(i));
}
MasterPositioner dev = new MasterPositioner(name, (PositionerBase)getDevice(master), slaveDevices);
if (cfg!=null){
//TODO
}
if (getContext().getDevicePool().addDevice(dev, false, true)){
privateMasterAxis = dev;
updateMaster();
buttonPrivateMasterAxis.setSelected(true);
if (!hasDevice(privateMasterAxis)){
modelInactive.addRow(new Object[]{name});
}
}
}
Map<String, Double> preActions = (Map) config.get("PRE_ACTIONS");
List<Integer> range = (List) config.getOrDefault("RANGE", new ArrayList());
@@ -456,6 +510,7 @@ public class SIStem extends PanelProcessor {
@Override
public void clear() {
currentFile = null;
deletePrivateMasterAxis();
for (JComboBox combo : deviceCombos) {
combo.setSelectedIndex(0);
}
@@ -502,6 +557,7 @@ public class SIStem extends PanelProcessor {
@Override
protected void onUnloaded() {
deletePrivateMasterAxis();
if (queueProcessor != null) {
getContext().getPluginManager().unloadPlugin(queueProcessor);
getApp().exit(this);
@@ -618,6 +674,62 @@ public class SIStem extends PanelProcessor {
}
updateControls();
}
MasterPositioner privateMasterAxis;
void createPrivateMasterAxis() throws Exception{
deletePrivateMasterAxis();
String name = getString("Enter name of the device:", "");
if ((name!=null) && (!name.isBlank())){
name=name.trim();
if (getContext().getDevicePool().getByName(name)!=null){
throw new Exception("Device name in use");
}
String[] motorNames = getContext().getDevicePool().getAllNamesOrderedByName(Motor.class);
String master = getString("Enter master motor:", motorNames, null);
if (master!=null){
ArrayList<String> slaves = new ArrayList<>();
boolean finished = false;
motorNames=Arr.removeEquals(motorNames, master);
while (!finished){
String slave = getString("Enter slave motor " + (slaves.size()+1) +":", motorNames, null);
if (slave!=null){
motorNames=Arr.removeEquals(motorNames, slave);
slaves.add(slave);
}
if((slave==null)||(motorNames.length==0)){
if (slaves.size()<1){
return;
}
Positioner[] slaveDevices = new PositionerBase[slaves.size()];
for (int i=0; i<slaves.size(); i++){
slaveDevices[i] = (Positioner)getDevice(slaves.get(i));
}
MasterPositioner dev = new MasterPositioner(name, (PositionerBase)getDevice(master), slaveDevices);
if (getContext().getDevicePool().addDevice(dev, false, true)){
privateMasterAxis = dev;
updateMaster();
modelInactive.addRow(new Object[]{name});
}
return;
}
}
}
}
}
void deletePrivateMasterAxis(){
if (privateMasterAxis!=null){
getContext().getDevicePool().removeDevice(privateMasterAxis, true);
removeDevice(privateMasterAxis, modelInactive, -1);
removeDevice(privateMasterAxis, modelFixed, -1);
removeDevice(privateMasterAxis, modelScanned, -1);
privateMasterAxis= null;
updateMaster();
buttonPrivateMasterAxis.setSelected(false);
}
}
void updateLens() throws Exception {
String lens = (String) comboLens.getSelectedItem();
@@ -917,6 +1029,7 @@ public class SIStem extends PanelProcessor {
jScrollPane8 = new javax.swing.JScrollPane();
tableMaster = new javax.swing.JTable();
buttonEditMaster = new javax.swing.JButton();
buttonPrivateMasterAxis = new javax.swing.JCheckBox();
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
tableInactive = new javax.swing.JTable();
@@ -1439,9 +1552,7 @@ public class SIStem extends PanelProcessor {
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel11Layout.createSequentialGroup()
.addComponent(checkCompression)
.addGap(59, 59, 59))
.addComponent(checkCompression)
.addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(checkZigzag)
.addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@@ -1545,15 +1656,27 @@ public class SIStem extends PanelProcessor {
}
});
buttonPrivateMasterAxis.setText("Create private master axis");
buttonPrivateMasterAxis.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonPrivateMasterAxisActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
jPanel6.setLayout(jPanel6Layout);
jPanel6Layout.setHorizontalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 743, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(buttonEditMaster, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addComponent(buttonPrivateMasterAxis)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanel6Layout.createSequentialGroup()
.addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 743, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(buttonEditMaster, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel6Layout.setVerticalGroup(
@@ -1561,10 +1684,11 @@ public class SIStem extends PanelProcessor {
.addGroup(jPanel6Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addComponent(buttonEditMaster)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)))
.addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE)
.addComponent(buttonEditMaster))
.addGap(13, 13, 13)
.addComponent(buttonPrivateMasterAxis)
.addContainerGap())
);
jTabbedPane1.addTab("Master Axis", jPanel6);
@@ -2022,6 +2146,22 @@ public class SIStem extends PanelProcessor {
}
}//GEN-LAST:event_tableMasterMouseClicked
private void buttonPrivateMasterAxisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPrivateMasterAxisActionPerformed
try {
if (buttonPrivateMasterAxis.isSelected() != (privateMasterAxis!=null)){
if (buttonPrivateMasterAxis.isSelected()) {
createPrivateMasterAxis();
} else {
deletePrivateMasterAxis();
}
}
} catch (Exception ex) {
showException(ex);
} finally{
buttonPrivateMasterAxis.setSelected(privateMasterAxis!=null);
}
}//GEN-LAST:event_buttonPrivateMasterAxisActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton butonPlot;
@@ -2031,6 +2171,7 @@ public class SIStem extends PanelProcessor {
private javax.swing.JButton buttonData;
private javax.swing.JButton buttonEditMaster;
private javax.swing.JButton buttonOpen;
private javax.swing.JCheckBox buttonPrivateMasterAxis;
private javax.swing.JButton buttonSave;
private javax.swing.JButton buttonScienta;
private javax.swing.JButton buttonStart;
+30
View File
@@ -0,0 +1,30 @@
{
"PASSES" : 1,
"STOP" : [ 1.0, 2.0 ],
"DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ],
"MASTER_AXIS" : {
"MASTER" : "phi",
"SLAVES" : [ "x", "y" ],
"NAME" : "test"
},
"PRE_ACTIONS" : {
"scienta.passEnergyDev" : "20",
"scienta.acquisitionModeDev" : "Fixed",
"scienta.energyModeDev" : "Kinetic",
"scienta.lensModeDev" : "Transmission",
"scienta.detectorModeDev" : "ADC",
"scienta.slices" : 512,
"scienta.channels" : 512,
"y" : 0.1
},
"COMPRESSION" : true,
"SENSORS" : [ "scienta.dataMatrix", "keithley11" ],
"ZIGZAG" : true,
"SETTLING_TIME" : 0.0,
"MONITORS" : [ "current" ],
"START" : [ 0.0, 1.0 ],
"RANGE" : [ null, null, null, null ],
"POSITIONERS" : [ "x", "test" ],
"STEPS" : [ 9, 2 ],
"SNAPS" : [ "acmi", "energy", "exit_slit", "fe_horiz_width", "fe_vert_width", "helium_valve", "master", "tcmp", "temp_boot1", "temp_boot2", "temp_cryopump", "temp_cryostat", "temp_headmech", "temp_sample1", "temp_sample2", "temp_shield" ]
}
+50
View File
@@ -0,0 +1,50 @@
{
"PASSES" : 1,
"STOP" : [ 1.0, 2.0 ],
"DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ],
"MASTER_AXIS" : {
"CONFIG" : {
"fileName" : "/sls/X09LA/data/X09LA/pshell/home/devices/test.properties",
"precision" : -1,
"offset" : 0.0,
"scale" : 1.0,
"unit" : "null",
"sign_bit" : 0,
"resolution" : "NaN",
"minValue" : "NaN",
"maxValue" : "NaN",
"rotation" : false,
"mode" : "LINEAR",
"masterPositions" : [ -1.0, 1.0 ],
"slave1Positions" : [ -1.0, 2.0 ],
"slave2Positions" : [ -1.0, 1.5 ],
"slave3Positions" : null,
"slave4Positions" : null,
"slave5Positions" : null,
"slave6Positions" : null
},
"MASTER" : "phi",
"SLAVES" : [ "x", "y" ],
"NAME" : "test"
},
"PRE_ACTIONS" : {
"scienta.passEnergyDev" : "20",
"scienta.acquisitionModeDev" : "Fixed",
"scienta.energyModeDev" : "Kinetic",
"scienta.lensModeDev" : "Transmission",
"scienta.detectorModeDev" : "ADC",
"scienta.slices" : 512,
"scienta.channels" : 512,
"y" : 0.1
},
"COMPRESSION" : true,
"SENSORS" : [ "scienta.dataMatrix", "keithley11" ],
"ZIGZAG" : true,
"SETTLING_TIME" : 0.0,
"MONITORS" : [ "current" ],
"START" : [ 0.0, 1.0 ],
"RANGE" : [ null, null, null, null ],
"POSITIONERS" : [ "x", "test" ],
"STEPS" : [ 9, 2 ],
"SNAPS" : [ "acmi", "energy", "exit_slit", "fe_horiz_width", "fe_vert_width", "helium_valve", "master", "tcmp", "temp_boot1", "temp_boot2", "temp_cryopump", "temp_cryostat", "temp_headmech", "temp_sample1", "temp_sample2", "temp_shield" ]
}