diff --git a/config/config.properties b/config/config.properties index 12dbfc1..393cf29 100644 --- a/config/config.properties +++ b/config/config.properties @@ -1,5 +1,6 @@ -#Wed Jun 13 10:31:31 CEST 2018 +#Mon Sep 17 09:27:01 CEST 2018 autoSaveScanData=true +commandExecutionEvents=false createSessionFiles=true dataLayout=default dataPath={data}/{year}_{month}/{date}/{date}_{time}_{name} @@ -11,7 +12,7 @@ dataServerPort=-1 depthDimension=0 hostName=null instanceName=MXSC -logDaysToLive=-1 +logDaysToLive=30 logLevel=Fine logLevelConsole=Off logPath={logs}/{date}_{time} diff --git a/devices/img.properties b/devices/img.properties index 785c9ea..9dffde8 100644 --- a/devices/img.properties +++ b/devices/img.properties @@ -1,4 +1,4 @@ -#Thu Aug 30 15:04:59 CEST 2018 +#Wed Sep 12 14:06:31 CEST 2018 colormap=Grayscale colormapAutomatic=false colormapMax=18.133 @@ -9,16 +9,16 @@ grayscale=false invert=false rescaleFactor=1.0 rescaleOffset=0.0 -roiHeight=887 -roiWidth=887 -roiX=59 -roiY=56 -rotation=229.76067253596318 +roiHeight=899 +roiWidth=893 +roiX=48 +roiY=45 +rotation=230.05382605006437 rotationCrop=true scale=1.0 -spatialCalOffsetX=-444.0 -spatialCalOffsetY=-444.0 -spatialCalScaleX=0.5295623677991782 -spatialCalScaleY=0.5294932790504361 +spatialCalOffsetX=-447.0 +spatialCalOffsetY=-450.0 +spatialCalScaleX=0.5262180258614136 +spatialCalScaleY=0.5227145226413789 spatialCalUnits=mm transpose=false diff --git a/devices/led_ctrl_1.properties b/devices/led_ctrl_1.properties index e363697..02e7676 100644 --- a/devices/led_ctrl_1.properties +++ b/devices/led_ctrl_1.properties @@ -1,5 +1,5 @@ -#Fri Aug 24 20:52:17 CEST 2018 -maxValue=0.4 +#Tue Sep 11 11:02:40 CEST 2018 +maxValue=1.0 minValue=0.0 offset=0.0 precision=2 diff --git a/devices/led_ctrl_2.properties b/devices/led_ctrl_2.properties index e363697..02e7676 100644 --- a/devices/led_ctrl_2.properties +++ b/devices/led_ctrl_2.properties @@ -1,5 +1,5 @@ -#Fri Aug 24 20:52:17 CEST 2018 -maxValue=0.4 +#Tue Sep 11 11:02:40 CEST 2018 +maxValue=1.0 minValue=0.0 offset=0.0 precision=2 diff --git a/devices/led_ctrl_3.properties b/devices/led_ctrl_3.properties index e363697..02e7676 100644 --- a/devices/led_ctrl_3.properties +++ b/devices/led_ctrl_3.properties @@ -1,5 +1,5 @@ -#Fri Aug 24 20:52:17 CEST 2018 -maxValue=0.4 +#Tue Sep 11 11:02:40 CEST 2018 +maxValue=1.0 minValue=0.0 offset=0.0 precision=2 diff --git a/devices/smart_magnet.properties b/devices/smart_magnet.properties index 86d4f7c..0a1a7c4 100644 --- a/devices/smart_magnet.properties +++ b/devices/smart_magnet.properties @@ -1,4 +1,4 @@ -#Fri Aug 24 14:18:31 CEST 2018 +#Wed Sep 12 12:51:56 CEST 2018 holdingCurrent=30.0 mountCurrent=35.0 remanenceCurrent=-10.0 diff --git a/plugins/Commands.form b/plugins/Commands.form index 97e6aa0..a1a2ffe 100644 --- a/plugins/Commands.form +++ b/plugins/Commands.form @@ -40,43 +40,51 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -104,7 +112,10 @@ - + + + + @@ -112,8 +123,8 @@ - + @@ -438,6 +449,14 @@ + + + + + + + + diff --git a/plugins/Commands.java b/plugins/Commands.java index eecc33f..98f8b76 100644 --- a/plugins/Commands.java +++ b/plugins/Commands.java @@ -145,6 +145,7 @@ public class Commands extends Panel { spinnerDrySpeed = new ch.psi.utils.swing.HorizontalSpinner(); buttonRecover = new javax.swing.JButton(); buttonEnableAll = new javax.swing.JButton(); + buttonMoveCold = new javax.swing.JButton(); panelCommands.setBorder(javax.swing.BorderFactory.createTitledBorder("Commands")); @@ -338,43 +339,55 @@ public class Commands extends Panel { } }); + buttonMoveCold.setText("Move Cold"); + buttonMoveCold.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonMoveColdActionPerformed(evt); + } + }); + javax.swing.GroupLayout panelCommandsLayout = new javax.swing.GroupLayout(panelCommands); panelCommands.setLayout(panelCommandsLayout); panelCommandsLayout.setHorizontalGroup( panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panelCommandsLayout.createSequentialGroup() .addContainerGap() - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addComponent(buttonRecover, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonMoveHeater, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonMoveGonio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonMovePark, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonGetGonio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonPutGonio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonMount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonUnmount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonGetDewar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonPutDewar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonDry, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGap(18, 18, Short.MAX_VALUE) .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCommandsLayout.createSequentialGroup() - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonMoveScanner, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonMoveHome, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonMoveDewar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonHomingHexiposi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGap(1, 1, 1)) - .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonEnableAll, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(panelCommandsLayout.createSequentialGroup() - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel6) - .addComponent(jLabel7)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(spinnerDrySpeed, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE) - .addComponent(spinnerDryTime)))) + .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(buttonRecover, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonMoveHeater, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonMovePark, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonGetGonio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonPutGonio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonMount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonUnmount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonGetDewar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonPutDewar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonDry, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(buttonMoveCold, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCommandsLayout.createSequentialGroup() + .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonMoveScanner, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonMoveHome, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonMoveDewar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonHomingHexiposi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(1, 1, 1)) + .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonEnableAll, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(panelCommandsLayout.createSequentialGroup() + .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel6) + .addComponent(jLabel7)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(spinnerDrySpeed, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE) + .addComponent(spinnerDryTime)))) + .addComponent(buttonMoveGonio, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); @@ -399,15 +412,17 @@ public class Commands extends Panel { .addComponent(buttonGetGonio) .addComponent(buttonHomingHexiposi)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonPutGonio) + .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonPutGonio) + .addComponent(buttonMoveGonio)) .addGap(18, 18, 18) .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonMovePark) .addComponent(buttonMoveHome)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(buttonMoveGonio) - .addComponent(buttonMoveDewar)) + .addComponent(buttonMoveDewar) + .addComponent(buttonMoveCold)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonMoveHeater) @@ -529,6 +544,10 @@ public class Commands extends Panel { execute("robot_recover()"); }//GEN-LAST:event_buttonRecoverActionPerformed + private void buttonMoveColdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMoveColdActionPerformed + execute("move_cold()"); + }//GEN-LAST:event_buttonMoveColdActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonDry; private javax.swing.JButton buttonEnableAll; @@ -536,6 +555,7 @@ public class Commands extends Panel { private javax.swing.JButton buttonGetGonio; private javax.swing.JButton buttonHomingHexiposi; private javax.swing.JButton buttonMount; + private javax.swing.JButton buttonMoveCold; private javax.swing.JButton buttonMoveDewar; private javax.swing.JButton buttonMoveGonio; private javax.swing.JButton buttonMoveHeater; diff --git a/plugins/MXSC-1.10.0.jar b/plugins/MXSC-1.10.0.jar index 3789066..4781233 100644 Binary files a/plugins/MXSC-1.10.0.jar and b/plugins/MXSC-1.10.0.jar differ diff --git a/script/data/pucks.py b/script/data/pucks.py new file mode 100644 index 0000000..7a0cc43 --- /dev/null +++ b/script/data/pucks.py @@ -0,0 +1,14 @@ +def get_puck_names(): + return [str(a)+str(b) for a in BLOCKS for b in range(1,6)] + + +def get_puck_info(): + ret = [] + #for puck in get_puck_names(): + for puck in BasePlate.pucks: + ret.append({"address" : str(puck.name), "status": str(puck.status), "barcode" : str(puck.id)}) + return ret + + +def get_puck_obj(address): + return BasePlate.getChild(address) \ No newline at end of file diff --git a/script/data/samples.py b/script/data/samples.py index 7db91a4..0580943 100644 --- a/script/data/samples.py +++ b/script/data/samples.py @@ -1,23 +1,279 @@ import json import org.python.core.PyDictionary as PyDictionary - +SAMPLE_INFO_KEYS = ["userName", "dewarName", "puckName", "puckBarcode", "puckType", "puckAddress", + "sampleName", "samplePosition", "sampleStatus", "sampleMountCount"] samples_info = [] + def set_samples_info(info): global samples_info if (is_string(info)): info = json.loads(info) if not is_list(info): raise Exception("Sample info must be a list (given object type is " + str(type(info)) + ")") - #for sample in info: - # if not (type(sample) is PyDictionary): - # raise Exception("Sample info element must be a dictionary (given object type is " + str(type(sample)) + ")") + #Sanitize list + remove = [] + for sample in info: + try: + if set(sample.keys()) != set(SAMPLE_INFO_KEYS): + raise Exception() + except: + remove.append(sample) + for el in remove: + info.remove(el) + print "Invalid samples info element: " + str(el) samples_info = info - return samples_info + save_samples_info() + #Trust beamline on assignments, so update puck info + update_puck_table() + +def clear_samples_info(): + set_samples_info([]) +def save_samples_info(): + data = get_samples_info(True) + output_file = open( get_context().setup.expandPath("{context}/samples_info.json") , "w") + output_file.write(data) + output_file.close() +def restore_samples_info(): + try: + inputfile = open(get_context().setup.expandPath("{context}/samples_info.json"), "r") + info = inputfile.read() + except: + print >> sys.stderr, "Error reading sample info file: " + str(sys.exc_info()[1]) + info = [] + set_samples_info(info) + def get_samples_info(as_json=True): global sample_info - return json.dumps(samples_info) if as_json else samples_info \ No newline at end of file + return json.dumps(samples_info) if as_json else samples_info + +def has_puck_datamatrix(datamatrix): + if samples_info is not None: + for si in samples_info: + if si["puckBarcode"] == datamatrix: + return True + return False + +def add_puck_datamatrix(barcode, address = "", dewar = "Unknown", user = "Unknown", puck = "Unknown", type = "unipuck", sample_prefix = "Sample"): + if has_puck_datamatrix(barcode): + raise Exception("Datamatrix already defined: " + str(barcode)) + for s in range(1,17): + info = \ + { "userName": user, \ + "dewarName": dewar, \ + "puckName": puck, \ + "puckBarcode": address if barcode is None else barcode, \ + "puckType": type, \ + "puckAddress": address,\ + "sampleName": sample_prefix + " " + str(s), \ + "samplePosition": str(s),\ + "sampleStatus": "Unknown", \ + "sampleMountCount": "0", + } + samples_info.append(info) + save_samples_info() + +def remove_puck_datamatrix(barcode): + remove = [] + for si in samples_info: + if si["puckBarcode"] == barcode: + remove.append(si) + for el in remove: samples_info.remove(el) + save_samples_info() + +def set_puck_datamatrix(puck, datamatrix): + if puck is None: + puck = "" + if datamatrix is None: + datamatrix = "" + if samples_info is not None: + for si in samples_info: + if si["puckBarcode"] == datamatrix: + si["puckAddress"] = puck + elif si["puckAddress"] == puck: + si["puckAddress"] = "" + save_samples_info() + +def reset_puck_datamatrix(puck = None): + if samples_info is not None: + for si in samples_info: + if (si["puckAddress"] == puck) or (puck is None): + si["puckAddress"] = "" + save_samples_info() + +def get_puck_datamatrix(): + ret = {} + for si in samples_info: + if si["puckBarcode"] is not None and si["puckBarcode"]!="": + ret[si["puckBarcode"]] = si["puckAddress"] + return ret + +def get_puck_address(barcode): + try: + return get_puck_datamatrix()[barcode] + except: + return None + + +def update_puck_table(): + dms = get_puck_datamatrix() + for barcode in dms.keys(): + address = dms[barcode] + puck = get_puck_obj(address) + if puck is not None: + puck.id = barcode + + +#Sample mount/unmount + +def update_samples_info_sample_mount(puck_address, sample_position, sample_detected): + try: + if (samples_info is not None) and (puck_address is not None): + for si in samples_info: + if str(si["puckAddress"]) == str(puck_address) and str(si["samplePosition"]) == str(sample_position): + if sample_detected: + if si["sampleStatus"] != "Mounted": + si["sampleStatus"] = "Mounted" + try: + mount_count = int(si["sampleMountCount"]) + except: + mount_count = 0 + si["sampleMountCount"] = mount_count + 1 + else: + si["sampleStatus"] = "Unknown" + save_samples_info() + return + except: + pass + +def update_samples_info_sample_unmount(puck_address, sample_position): + try: + if (samples_info is not None) and (puck_address is not None): + for si in samples_info: + if str(si["puckAddress"]) == str(puck_address) and str(si["samplePosition"]) == str(sample_position): + si["sampleStatus"] = "HasBeenMounted" + save_samples_info() + return + except: + pass + + + +test_sample_data = [ \ + { "userName": "Alexandre", \ + "dewarName": "TEST", \ + "puckName": "My puck", \ + "puckBarcode": "AAA0001", \ + "puckType": "unipuck", \ + "puckAddress": "A1",\ + "sampleName": "MySample 1", \ + "samplePosition": 1,\ + "sampleStatus": "Present", \ + "sampleMountCount": 0, + } , \ + { "userName": "Alexandre", \ + "dewarName": "TEST", \ + "puckName": "My puck", \ + "puckBarcode": "AAA0001", \ + "puckType": "unipuck", \ + "puckAddress": "A1",\ + "sampleName": "MySample 2", \ + "samplePosition": 2,\ + "sampleStatus": "Present", \ + "sampleMountCount": 0, + } , \ + { "userName": "Alexandre", \ + "dewarName": "TEST", \ + "puckName": "My puck", \ + "puckBarcode": "AAA0001", \ + "puckType": "unipuck", \ + "puckAddress": "A1",\ + "sampleName": "MySample 3", \ + "samplePosition": 3,\ + "sampleStatus": "Present", \ + "sampleMountCount": 0, + } , \ + { "userName": "Alexandre", \ + "dewarName": "TEST", \ + "puckName": "My puck", \ + "puckBarcode": "AAA0001", \ + "puckType": "unipuck", \ + "puckAddress": "A1",\ + "sampleName": "MySample 4", \ + "samplePosition": 4,\ + "sampleStatus": "Present", \ + "sampleMountCount": 0, + } , \ + { "userName": "Alexandre", \ + "dewarName": "TEST", \ + "puckName": "My puck", \ + "puckBarcode": "AAA0001", \ + "puckType": "unipuck", \ + "puckAddress": "A1",\ + "sampleName": "MySample 5", \ + "samplePosition": 5,\ + "sampleStatus": "Present", \ + "sampleMountCount": 0, + } , \ + + { "userName": "Alexandre", \ + "dewarName": "TEST", \ + "puckName": "My puck", \ + "puckBarcode": "AAA0002", \ + "puckType": "unipuck", \ + "puckAddress": "C2",\ + "sampleName": "MySample 1", \ + "samplePosition": 1,\ + "sampleStatus": "Present", \ + "sampleMountCount": 0, + } , \ + { "userName": "Alexandre", \ + "dewarName": "TEST", \ + "puckName": "My puck", \ + "puckBarcode": "AAA0002", \ + "puckType": "unipuck", \ + "puckAddress": "C2",\ + "sampleName": "MySample 2", \ + "samplePosition": 2,\ + "sampleStatus": "Present", \ + "sampleMountCount": 0, + } , \ + { "userName": "Alexandre", \ + "dewarName": "TEST", \ + "puckName": "My puck", \ + "puckBarcode": "AAA0002", \ + "puckType": "unipuck", \ + "puckAddress": "C2",\ + "sampleName": "MySample 3", \ + "samplePosition": 3,\ + "sampleStatus": "Present", \ + "sampleMountCount": 0, + } , \ + { "userName": "Alexandre", \ + "dewarName": "TEST", \ + "puckName": "My puck", \ + "puckBarcode": "AAA0002", \ + "puckType": "unipuck", \ + "puckAddress": "C2",\ + "sampleName": "MySample 4", \ + "samplePosition": 4,\ + "sampleStatus": "Present", \ + "sampleMountCount": 0, + } , \ + { "userName": "Alexandre", \ + "dewarName": "TEST", \ + "puckName": "My puck", \ + "puckBarcode": "AAA0002", \ + "puckType": "unipuck", \ + "puckAddress": "C2",\ + "sampleName": "MySample 5", \ + "samplePosition": 5,\ + "sampleStatus": "Present", \ + "sampleMountCount": 0, + } , \ + ] + \ No newline at end of file diff --git a/script/devices/RobotSC.py b/script/devices/RobotSC.py index 2024fff..fb61510 100644 --- a/script/devices/RobotSC.py +++ b/script/devices/RobotSC.py @@ -22,8 +22,8 @@ joint_forces = False class RobotSC(RobotTCP): def __init__(self, name, server, timeout = 1000, retries = 1): RobotTCP.__init__(self, name, server, timeout, retries) - self.set_tasks(["getDewar", "putDewar", "putGonio", "getGonio", "robotRecover", "moveDewar", "movePark", "moveGonio","moveHeater", "moveScanner","moveHome"]) - self.set_known_points(["pPark", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome", "pHeater", "pHeaterBottom", "pScanStop","pHelium", "pHome"]) + self.set_tasks(["getDewar", "putDewar", "putGonio", "getGonio", "robotRecover", "moveDewar", "moveCold", "movePark", "moveGonio","moveHeater", "moveScanner","moveHome"]) + self.set_known_points(["pPark", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome", "pHeater", "pHeaterBottom", "pScanStop","pHelium", "pHome", "pCold"]) self.setPolling(DEFAULT_ROBOT_POLLING) def move_dewar(self): @@ -31,6 +31,11 @@ class RobotSC(RobotTCP): self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_dewar() + def move_cold(self): + self.start_task('moveCold') + self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) + self.assert_cold() + def move_home(self): self.start_task('moveHome') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) @@ -141,6 +146,9 @@ class RobotSC(RobotTCP): def is_park(self): return self.is_in_point("pPark") + + def is_cold(self): + return self.is_in_point("pCold") def is_home(self): return self.is_in_point("pHome") @@ -175,6 +183,9 @@ class RobotSC(RobotTCP): def assert_heater_home(self): self.assert_in_point("pHeaterHome") + + def assert_cold(self): + self.assert_in_point("pCold") def assert_heater(self): self.assert_in_point("pHeater") diff --git a/script/devices/Wago.py b/script/devices/Wago.py index 6650c86..c6fe109 100644 --- a/script/devices/Wago.py +++ b/script/devices/Wago.py @@ -125,7 +125,7 @@ def release_psys(): # Drier ################################################################################################### -MAX_HEATER_TIME = 15000 +MAX_HEATER_TIME = 45000 def set_air_stream(state): diff --git a/script/local.py b/script/local.py index 168cd01..1d173b2 100644 --- a/script/local.py +++ b/script/local.py @@ -7,6 +7,8 @@ from ch.psi.pshell.modbus import ModbusTCP import ch.psi.mxsc.Controller as Controller import ch.psi.pshell.core.Nameable as Nameable import ch.psi.utils.Chrono as Chrono +import ch.psi.mxsc.Controller as Controller + run("setup/Layout") @@ -76,6 +78,7 @@ add_device(img.getCamera(), force = True) ################################################################################################### run("data/samples") +run("data/pucks") run("motion/tools") run("motion/mount") run("motion/unmount") @@ -88,6 +91,7 @@ run("motion/move_gonio") run("motion/move_heater") run("motion/move_home") run("motion/move_park") +run("motion/move_cold") run("motion/move_scanner") run("motion/dry") run("motion/homing_hexiposi") @@ -216,7 +220,7 @@ for l in dewar_level.listeners: dewar_level.addListener(dewar_level_listener) dewar_level_listener.onValueChanged(dewar_level, dewar_level.take(), None) - + ################################################################################################### @@ -230,10 +234,15 @@ cover_detection_debug = False def is_puck_loading(): - return robot.state == State.Ready and robot.take()["pos"] == 'pPark' and feedback_psys_safety.take() == False + return robot.state == State.Ready and robot.take()["pos"] == 'pPark' and \ + feedback_psys_safety.take() == False and \ + not guiding_tool_park.read() update() +add_device(Controller.getInstance().basePlate, True) +restore_samples_info() + print "Initialization complete" \ No newline at end of file diff --git a/script/motion/get_dewar.py b/script/motion/get_dewar.py index b082cf6..d0559fc 100644 --- a/script/motion/get_dewar.py +++ b/script/motion/get_dewar.py @@ -4,7 +4,7 @@ def get_dewar(segment, puck, sample, force=False): print "get_dewar: ", segment, puck, sample, force #Initial checks - assertValidAddress(segment, puck, sample) + assert_valid_address(segment, puck, sample) assert_puck_detected(segment, puck) robot.assert_no_task() diff --git a/script/motion/mount.py b/script/motion/mount.py index 815dce6..a153c17 100644 --- a/script/motion/mount.py +++ b/script/motion/mount.py @@ -4,7 +4,7 @@ def mount(segment, puck, sample, force=False, read_dm=False): print "mount: ", segment, puck, sample, force start = time.time() #Initial checks - assertValidAddress(segment, puck, sample) + assert_valid_address(segment, puck, sample) assert_puck_detected(segment, puck) robot.assert_no_task() @@ -45,8 +45,11 @@ def mount(segment, puck, sample, force=False, read_dm=False): smart_magnet.set_mount_current() try: robot.put_gonio() - robot.move_dewar() - if smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) == False: + robot.move_dewar() + sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) + #TODO: Should do on finally? + update_samples_info_sample_mount(get_puck_name(segment, puck), sample, sample_detected) + if sample_detected == False: raise Exception("No pin detected on gonio") finally: smart_magnet.set_default_current() diff --git a/script/motion/move_cold.py b/script/motion/move_cold.py new file mode 100644 index 0000000..52dc9c9 --- /dev/null +++ b/script/motion/move_cold.py @@ -0,0 +1,18 @@ +def move_cold(): + """ + """ + print "move_cold" + + #Initial checks + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + robot.assert_cleared() + #robot.assert_in_known_point() + + #Enabling + enable_motion() + + + if not robot.is_cold(): + robot.move_cold() \ No newline at end of file diff --git a/script/motion/put_dewar.py b/script/motion/put_dewar.py index 2f66fae..7d5c74d 100644 --- a/script/motion/put_dewar.py +++ b/script/motion/put_dewar.py @@ -4,7 +4,7 @@ def put_dewar(segment, puck, sample, force=False): print "put_dewar: ", segment, puck, sample, force #Initial checks - assertValidAddress(segment, puck, sample) + assert_valid_address(segment, puck, sample) assert_puck_detected(segment, puck) robot.assert_no_task() diff --git a/script/motion/tools.py b/script/motion/tools.py index 2cc47d5..2be0cbf 100644 --- a/script/motion/tools.py +++ b/script/motion/tools.py @@ -128,7 +128,7 @@ def update_tool(tool=None, x_offset=0.0, y_offset=0.0, z_offset=0.0): robot.save_program() -def assertValidAddress(segment, puck, sample): +def assert_valid_address(segment, puck, sample): if is_string(segment): segment = ord(segment.upper()) - ord('A') +1 if segment<=0 or segment >6: @@ -137,4 +137,20 @@ def assertValidAddress(segment, puck, sample): raise Exception ("Invalid puck") if sample<=0 or sample >16: raise Exception ("Invalid sample") - \ No newline at end of file + +def get_puck_name(segment, puck): + try: + assert_valid_address(segment, puck, 1) + if type(segment) is int: + segment = chr( ord('A') + (pos-1)) + elif type(segment) is str: + segment = pos.upper() + else: + return None + return segment + str(puck) + except: + return None + + + + \ No newline at end of file diff --git a/script/motion/unmount.py b/script/motion/unmount.py index d12f73f..ebebf29 100644 --- a/script/motion/unmount.py +++ b/script/motion/unmount.py @@ -4,7 +4,7 @@ def unmount(segment, puck, sample, force=False): print "unmount: ", segment, puck, sample, force #Initial checks - assertValidAddress(segment, puck, sample) + assert_valid_address(segment, puck, sample) assert_puck_detected(segment, puck) robot.assert_no_task() @@ -34,6 +34,8 @@ def unmount(segment, puck, sample, force=False): smart_magnet.set_unmount_current() try: robot.get_gonio() + #TODO: Shuld check if smart magnet detection is off? + update_samples_info_sample_unmount(get_puck_name(segment, puck)) robot.move_dewar() robot.put_dewar(segment, puck, sample) finally: diff --git a/script/test/TestCameraStability2.py b/script/test/TestCameraStability2.py index 30ef8bc..c6ef878 100644 --- a/script/test/TestCameraStability2.py +++ b/script/test/TestCameraStability2.py @@ -1,11 +1,14 @@ -cover_detection_debug=False - -for pos in ['A', 'B', 'C', 'D', 'E', 'F']: - print "Moving to ", pos - hexiposi.move(pos) - ret = run("imgproc/CoverDetection") - det = ret[0] - print "Detected: ", det - if det != pos: - raise "Position error" +cover_detection_debug=True +while True: + for pos in ['A', 'B', 'C', 'D', 'E', 'F']: + print "Moving to ", pos + hexiposi.move(pos) + move_home() + move_park() + time.sleep(2.0) + ret = run("imgproc/CoverDetection") + det = ret[0] + print "Detected: ", det + if det != pos: + raise Exception("Position error")