diff --git a/config/variables.properties b/config/variables.properties
index caf1831..6400f9f 100644
--- a/config/variables.properties
+++ b/config/variables.properties
@@ -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
diff --git a/devices/test.properties b/devices/test.properties
new file mode 100644
index 0000000..e496b7e
--- /dev/null
+++ b/devices/test.properties
@@ -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
diff --git a/devices/test1.properties b/devices/test1.properties
new file mode 100644
index 0000000..33540c2
--- /dev/null
+++ b/devices/test1.properties
@@ -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
diff --git a/plugins/SIStem.form b/plugins/SIStem.form
index 0a14b5f..be62243 100644
--- a/plugins/SIStem.form
+++ b/plugins/SIStem.form
@@ -970,9 +970,17 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -980,14 +988,14 @@
-
+
-
-
-
-
-
+
+
+
+
+
@@ -1037,6 +1045,14 @@
+
+
+
+
+
+
+
+
diff --git a/plugins/SIStem.java b/plugins/SIStem.java
index e8e711b..49adfd4 100644
--- a/plugins/SIStem.java
+++ b/plugins/SIStem.java
@@ -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 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 masterAxis = (Map) config.get("MASTER_AXIS");
+ if (masterAxis!=null){
+ String name = (String) masterAxis.get("NAME");
+ String master = (String) masterAxis.get("MASTER");
+ List slaves = (List) masterAxis.get("SLAVES");
+ Map cfg = (Map) masterAxis.get("CONFIG");
+ Positioner[] slaveDevices = new PositionerBase[slaves.size()];
+ for (int i=0; i preActions = (Map) config.get("PRE_ACTIONS");
List 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 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