diff --git a/config/devices.properties b/config/devices.properties
index de674d5..41fc563 100644
--- a/config/devices.properties
+++ b/config/devices.properties
@@ -1,5 +1,5 @@
-img=ch.psi.pshell.prosilica.Prosilica|25001 "PacketSize=1522;PixelFormat=Mono8;BinningX=1;BinningY=1;RegionX=300;RegionY=200;Width=1000;Height=1000"|||false
-gripper_cam=ch.psi.pshell.imaging.MjpegSource|http://129.129.110.114/axis-cgi/mjpg/video.cgi||100|
+img=ch.psi.pshell.prosilica.Prosilica|25001 "PacketSize=1522;PixelFormat=Mono8;BinningX=1;BinningY=1;RegionX=300;RegionY=200;Width=1000;Height=1000;MulticastEnable=Off"|||false
+#gripper_cam=ch.psi.pshell.imaging.MjpegSource|http://129.129.110.114/axis-cgi/mjpg/video.cgi||100|
microscan=ch.psi.pshell.serial.TcpDevice|129.129.110.200:2001|||
microscan_cmd=ch.psi.pshell.serial.TcpDevice|129.129.110.200:2003|||
ue=LaserUE|COM4|||false
diff --git a/config/plugins.properties b/config/plugins.properties
index ded1585..00b35d6 100644
--- a/config/plugins.properties
+++ b/config/plugins.properties
@@ -1,3 +1,4 @@
+MjpegSource2.java=enabled
MXSC-1.10.0.jar=enabled
LN2.java=enabled
Hexiposi.java=enabled
diff --git a/devices/Time.properties b/devices/Time.properties
index 6d228d7..33011f0 100644
--- a/devices/Time.properties
+++ b/devices/Time.properties
@@ -1,4 +1,4 @@
-#Thu Mar 01 15:25:39 CET 2018
+#Wed Jun 27 10:48:14 CEST 2018
maxValue=NaN
minValue=NaN
offset=0.0
@@ -6,4 +6,5 @@ precision=-1
resolution=NaN
rotation=false
scale=1.0
+sign_bit=0
unit=null
diff --git a/devices/gripper_cam.properties b/devices/gripper_cam.properties
index 77b2bc4..6fc903f 100644
--- a/devices/gripper_cam.properties
+++ b/devices/gripper_cam.properties
@@ -1,4 +1,4 @@
-#Mon Jun 18 11:16:55 CEST 2018
+#Thu Jun 28 17:46:46 CEST 2018
flipHorizontally=false
flipVertically=false
grayscale=false
diff --git a/devices/led_ctrl_1.properties b/devices/led_ctrl_1.properties
index efe6ed5..7c71df6 100644
--- a/devices/led_ctrl_1.properties
+++ b/devices/led_ctrl_1.properties
@@ -1,5 +1,5 @@
-#Tue Jun 19 16:41:20 CEST 2018
-maxValue=0.4
+#Wed Jun 27 09:59:11 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 efe6ed5..7c71df6 100644
--- a/devices/led_ctrl_2.properties
+++ b/devices/led_ctrl_2.properties
@@ -1,5 +1,5 @@
-#Tue Jun 19 16:41:20 CEST 2018
-maxValue=0.4
+#Wed Jun 27 09:59:11 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 efe6ed5..7c71df6 100644
--- a/devices/led_ctrl_3.properties
+++ b/devices/led_ctrl_3.properties
@@ -1,5 +1,5 @@
-#Tue Jun 19 16:41:20 CEST 2018
-maxValue=0.4
+#Wed Jun 27 09:59:11 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 a37208e..e7b94e4 100644
--- a/devices/smart_magnet.properties
+++ b/devices/smart_magnet.properties
@@ -1,6 +1,6 @@
-#Fri Jun 22 11:07:01 CEST 2018
-holdingCurrent=10.0
+#Wed Jun 27 10:45:31 CEST 2018
+holdingCurrent=25.0
mountCurrent=35.0
remanenceCurrent=-10.0
-restingCurrent=5.0
-unmountCurrent=2.5
+restingCurrent=10.0
+unmountCurrent=5.0
diff --git a/plugins/Expert.form b/plugins/Expert.form
index 87a47c3..64d9d05 100644
--- a/plugins/Expert.form
+++ b/plugins/Expert.form
@@ -49,7 +49,7 @@
-
+
@@ -383,6 +383,7 @@
+
@@ -390,6 +391,7 @@
+
@@ -418,7 +420,12 @@
-
+
+
+
+
+
+
@@ -477,6 +484,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/Expert.java b/plugins/Expert.java
index 8868b86..7f11523 100644
--- a/plugins/Expert.java
+++ b/plugins/Expert.java
@@ -114,6 +114,8 @@ public class Expert extends Panel {
jLabel2 = new javax.swing.JLabel();
spinnerSegment = new javax.swing.JSpinner();
jLabel3 = new javax.swing.JLabel();
+ jLabel5 = new javax.swing.JLabel();
+ checkDatamatrix = new javax.swing.JCheckBox();
buttonMovePark = new javax.swing.JButton();
buttonHomingHexiposi = new javax.swing.JButton();
buttonMoveHome = new javax.swing.JButton();
@@ -309,6 +311,10 @@ public class Expert extends Panel {
jLabel3.setText("Sample:");
+ jLabel5.setText("Read DM:");
+
+ checkDatamatrix.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
+
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
@@ -319,13 +325,15 @@ public class Expert extends Panel {
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel1)
- .addComponent(jLabel4))
+ .addComponent(jLabel4)
+ .addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(checkForce)
.addComponent(spinnerSample, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerPuck, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(spinnerSegment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(spinnerSegment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(checkDatamatrix))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
@@ -352,7 +360,11 @@ public class Expert extends Panel {
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel4)
.addComponent(checkForce))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
+ .addComponent(jLabel5)
+ .addComponent(checkDatamatrix))
+ .addGap(0, 0, 0))
);
buttonMovePark.setText("Move Park");
@@ -627,7 +639,7 @@ public class Expert extends Panel {
.addComponent(panelRobot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(panelRobot1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(29, Short.MAX_VALUE))
+ .addContainerGap(23, Short.MAX_VALUE))
);
}// //GEN-END:initComponents
@@ -640,7 +652,8 @@ public class Expert extends Panel {
int puck = (Integer) spinnerPuck.getValue();
int sample = (Integer) spinnerSample.getValue();
String force = checkForce.isSelected() ? "True" : "False";
- execute("mount('" + segment + "'," + puck + "," + sample + ", force=" + force + ")");
+ String readDatamatrix = checkDatamatrix.isSelected() ? "True" : "False";
+ execute("mount('" + segment + "'," + puck + "," + sample + ", force=" + force + ", read_dm=" + readDatamatrix + ")");
}//GEN-LAST:event_buttonMountActionPerformed
@@ -779,11 +792,13 @@ public class Expert extends Panel {
private javax.swing.JButton buttonReleasePsys;
private javax.swing.JToggleButton buttonStream;
private javax.swing.JButton buttonUnmount;
+ private javax.swing.JCheckBox checkDatamatrix;
private javax.swing.JCheckBox checkForce;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
+ private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel2;
diff --git a/plugins/LN2.java b/plugins/LN2.java
index 20360f7..4fdeb64 100644
--- a/plugins/LN2.java
+++ b/plugins/LN2.java
@@ -37,6 +37,11 @@ public class LN2 extends Panel {
}
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ }
@Override
public void onStateChange(State state, State former) {
diff --git a/plugins/MXSC-1.10.0.jar b/plugins/MXSC-1.10.0.jar
index d9bb0b3..504236f 100644
Binary files a/plugins/MXSC-1.10.0.jar and b/plugins/MXSC-1.10.0.jar differ
diff --git a/plugins/MjpegSource2.java b/plugins/MjpegSource2.java
new file mode 100644
index 0000000..a4f55f7
--- /dev/null
+++ b/plugins/MjpegSource2.java
@@ -0,0 +1,149 @@
+
+import ch.psi.pshell.imaging.SourceBase;
+import ch.psi.pshell.imaging.SourceConfig;
+import ch.psi.pshell.imaging.Utils;
+import java.awt.image.BufferedImage;
+import java.io.BufferedInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.logging.Level;
+
+/**
+ * Image source receive frames from a mjpeg server.
+ */
+public class MjpegSource2 extends SourceBase {
+
+ final String url;
+ final boolean flushOnUpdate;
+
+ public MjpegSource2(String name, String url) {
+ this(name, url, false);
+ }
+
+ public MjpegSource2(String name, String url, boolean flushOnUpdate) {
+ super(name, new SourceConfig());
+ this.url = url;
+ this.flushOnUpdate = flushOnUpdate;
+ }
+
+ InputStream stream;
+
+ @Override
+ protected void doInitialize() throws IOException, InterruptedException {
+ super.doInitialize();
+ URL aux = new URL(url);
+ stream = aux.openStream();
+ // if (!stream.markSupported()) {
+ stream = new BufferedInputStream(stream);
+ // }
+ }
+
+ Thread monitoredThread;
+
+ @Override
+ protected void doSetMonitored(boolean value) {
+ if (value && (monitoredThread == null)) {
+ monitoredThread = new Thread(() -> {
+ try {
+ while (true) {
+ try {
+ doUpdate();
+ Thread.sleep(1);
+ } catch (IOException ex) {
+ getLogger().log(Level.FINE, null, ex);
+ }
+ }
+ } catch (InterruptedException ex) {
+ return;
+ }
+ });
+ monitoredThread.setDaemon(true);
+ monitoredThread.start();
+ } else if (!value && (monitoredThread != null)) {
+ monitoredThread.interrupt();
+ monitoredThread = null;
+ }
+ }
+
+ final byte[] START_OF_FRAME = {(byte) 0xFF, (byte) 0xD8};
+ final byte[] END_OF_FRAME = {(byte) 0xFF, (byte) 0xD9};
+ final int MAX_FRAME_SIZE = 512 * 1024;
+
+ @Override
+ protected void doUpdate() throws IOException, InterruptedException {
+ byte[] data = null;
+ if (stream != null) {
+ if (flushOnUpdate) {
+ flush();
+ }
+ try {
+ data = readData();
+ } catch (EOFException ex) {
+ //Try to reopen stream
+ doInitialize();
+ data = readData();
+ }
+ }
+ if (data == null) {
+ pushImage(null);
+ } else {
+ BufferedImage img = Utils.newImage(data);
+ pushImage(img);
+ }
+ }
+ byte[] readData() throws IOException {
+ if (stream != null) {
+ stream.mark(MAX_FRAME_SIZE);
+ int startOfFrame = waitBytes(START_OF_FRAME) - START_OF_FRAME.length;
+ if (startOfFrame >= 0) {
+ int endOfFrame = waitBytes(END_OF_FRAME);
+ if (endOfFrame >= 0) {
+ stream.reset();
+ stream.skip(startOfFrame);
+ int length = endOfFrame - END_OF_FRAME.length;
+ byte[] data = new byte[length];
+ stream.read(data, 0, length);
+ return data;
+ }
+ }
+ }
+ return null;
+ }
+
+ int waitBytes(byte[] data) throws IOException {
+ int index = 0;
+ int dataPos = 0;
+ while (true) {
+ int ret = stream.read();
+ if (ret < 0) {
+ throw new EOFException();
+ }
+ byte value = (byte) ret;
+ if (value == data[dataPos]) {
+ dataPos++;
+ if (dataPos == data.length) {
+ return (index + 1);
+ }
+ } else {
+ dataPos = 0;
+ }
+ index++;
+ if (index >= MAX_FRAME_SIZE) {
+ return -1;
+ }
+ }
+ }
+
+ public void flush() throws IOException {
+ //stream.skip(stream.available());
+ //TODO: Skipping won't make the current image to be displayed
+ stream.close();
+ stream = new URL(url).openStream();
+ if (!stream.markSupported()) {
+ stream = new BufferedInputStream(stream);
+ }
+ }
+
+}
diff --git a/script/devices/BarcodeReader.py b/script/devices/BarcodeReader.py
index fdbbc3a..e1f5b6d 100644
--- a/script/devices/BarcodeReader.py
+++ b/script/devices/BarcodeReader.py
@@ -4,6 +4,9 @@ class BarcodeReader(DeviceBase):
def doInitialize(self):
self.disable()
+ self.readout = None
+ self.processing = False
+ self.task_callable=None
def enable(self):
microscan_cmd.write("")
@@ -17,6 +20,7 @@ class BarcodeReader(DeviceBase):
self.state.assertReady()
try:
self.setState(State.Busy)
+ microscan.flush()
ret = microscan.waitString(int(timeout * 1000))
self.setCache(ret, None)
return ret
@@ -31,17 +35,38 @@ class BarcodeReader(DeviceBase):
def read(self,timeout=1.0):
- initial = self.state
- if initial == State.Disabled:
- self.enable()
+ if self.processing:
+ raise Exception("Ongoing read operation")
+ self.processing = True
try:
- return self.get()
- finally:
+ initial = self.state
if initial == State.Disabled:
- self.disable()
-
-
+ self.enable()
+ try:
+ return self.get(timeout)
+ finally:
+ if initial == State.Disabled:
+ self.disable()
+ finally:
+ self.processing = False
+ def _read_task(self, timeout):
+ global readout
+ self.readout = self.read(timeout)
+ return self.readout
+
+ def start_read(self, timeout=1.0):
+ self.readout = None
+ self.task_callable = fork((self._read_task, (timeout,)))
+
+ def get_readout(self):
+ return self.readout
+
+ def wait_readout(self):
+ if self.task_callable is not None:
+ join(self.task_callable)
+ self.task_callable = None
+ return self.readout
add_device(BarcodeReader("barcode_reader"), force = True)
diff --git a/script/devices/RobotSC.py b/script/devices/RobotSC.py
index 10f56f8..a8e3a21 100644
--- a/script/devices/RobotSC.py
+++ b/script/devices/RobotSC.py
@@ -19,12 +19,11 @@ simulation = False
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"])
- self.set_known_points(["pHome", "pPark", "pDewarHome", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome", "pHeater", "pHeaterBottom"])
+ self.set_known_points(["pHome", "pPark", "pDewarHome", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome", "pHeater", "pHeaterBottom", "pScanStop"])
self.setPolling(DEFAULT_ROBOT_POLLING)
def move_dewar(self):
@@ -60,6 +59,16 @@ class RobotSC(RobotTCP):
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
self.assert_scanner()
+ def move_scanner(self):
+ self.start_task('moveScanner')
+ self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
+ self.assert_scanner()
+
+ #def do_scan(self):
+ # self.start_task('doScan')
+ # self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
+ # self.assert_scan_stop()
+
def move_gonio(self):
self.start_task('moveGonio')
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
@@ -156,6 +165,9 @@ class RobotSC(RobotTCP):
def is_scanner(self):
return self.is_in_point("pScanHome")
+ #def is_scan_stop(self):
+ # return self.is_in_point("pScanStop")
+
def is_cleared(self):
#return self.is_home() or self.is_park() or self.is_dewar() or self.is_dewar_home()
return self.get_current_point() is not None
@@ -187,9 +199,15 @@ class RobotSC(RobotTCP):
def assert_scanner(self):
self.assert_in_point("pScanHome")
+ #def assert_scan_stop(self):
+ # self.assert_in_point("pScanStop")
+
def assert_cleared(self):
if not self.is_cleared():
- raise Exception("Robot not in cleared position")
+ raise Exception("Robot not in cleared position")
+
+ def wait_ready(self):
+ robot.waitState(State.Ready, 1000) #robot.state.assertReady()
if simulation:
#add_device(RobotSC("robot","129.129.126.92:1000"),force = True)
@@ -234,9 +252,4 @@ if joint_forces:
add_device(jf4(), force = True)
add_device(jf5(), force = True)
add_device(jf6(), force = True)
- add_device(jfc(), force = True)
-
-
-
-
-"""
\ No newline at end of file
+ add_device(jfc(), force = True)
\ No newline at end of file
diff --git a/script/devices/RobotTCP.py b/script/devices/RobotTCP.py
index 8c96c83..05c533c 100644
--- a/script/devices/RobotTCP.py
+++ b/script/devices/RobotTCP.py
@@ -3,6 +3,7 @@ import threading
FRAME_DEFAULT = "world"
FLANGE = "flange"
+MAX_NUMBER_PARAMETERS = 20
run("devices/RobotMotors")
@@ -129,7 +130,7 @@ class RobotTCP(TcpDevice, Stoppable):
def execute(self, command, *args, **kwargs):
timeout = None if (kwargs is None) or (not kwargs.has_key("timeout")) else kwargs["timeout"]
msg = str(command)
- if len(args)>10:
+ if len(args)>MAX_NUMBER_PARAMETERS:
raise Exception("Exceeded maximum number of parameters")
for i in range(len(args)):
msg += (self.cmd_separator if (i==0) else self.array_separator) + str(args[i])
@@ -671,7 +672,7 @@ class RobotTCP(TcpDevice, Stoppable):
#for task in tasks:
# if self.get_task_status(task)[0]>=0:
# raise Exception("Ongoing high-level task: " + task)
- ts = robot.get_tasks_status(*tasks)
+ ts = self.get_tasks_status(*tasks)
for i in range(len(ts)):
if ts[i] > 0:
raise Exception("Ongoing high-level task: " + tasks[i])
diff --git a/script/devices/SmartMagnet.py b/script/devices/SmartMagnet.py
index 523fc65..62f6bea 100644
--- a/script/devices/SmartMagnet.py
+++ b/script/devices/SmartMagnet.py
@@ -10,7 +10,7 @@ class SmartMagnet(DeviceBase):
}))
def doInitialize(self):
- DeviceBase.doInitialize(self)
+ super(SmartMagnet, self).doInitialize()
self.get_current()
def set_current(self, current):
@@ -93,7 +93,7 @@ class SmartMagnet(DeviceBase):
def set_remanence_current(self):
self.set_current(self.config.getFieldValue("remanenceCurrent"))
- def set_default_current():
+ def set_default_current(self):
if self.is_mounted():
self.set_holding_current()
else:
diff --git a/script/local.py b/script/local.py
index 83a42d9..ca79cd3 100644
--- a/script/local.py
+++ b/script/local.py
@@ -43,6 +43,7 @@ run("motion/move_park")
run("motion/move_scanner")
run("motion/dry")
run("motion/homing_hexiposi")
+run("motion/robot_recover")
run("imgproc/Utils")
run("tools/Math")
@@ -129,6 +130,8 @@ except:
print >> sys.stderr, traceback.format_exc()
+#gripper_cam.paused = True
+
###################################################################################################
# Global variables
###################################################################################################
diff --git a/script/motion/dry.py b/script/motion/dry.py
index 4912ef4..f4a70f6 100644
--- a/script/motion/dry.py
+++ b/script/motion/dry.py
@@ -34,7 +34,7 @@ def dry(heat_time, speed):
#Initial checks
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
diff --git a/script/motion/get_dewar.py b/script/motion/get_dewar.py
index cd2b598..7555edf 100644
--- a/script/motion/get_dewar.py
+++ b/script/motion/get_dewar.py
@@ -7,7 +7,7 @@ def get_dewar(segment, puck, sample, force=False):
assertValidAddress(segment, puck, sample)
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
hexiposi.assert_homed()
diff --git a/script/motion/get_gonio.py b/script/motion/get_gonio.py
index bd0f768..2123e2a 100644
--- a/script/motion/get_gonio.py
+++ b/script/motion/get_gonio.py
@@ -6,7 +6,7 @@ def get_gonio(force=False):
#Initial checks
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
diff --git a/script/motion/homing_hexiposi.py b/script/motion/homing_hexiposi.py
index a13af94..62944b4 100644
--- a/script/motion/homing_hexiposi.py
+++ b/script/motion/homing_hexiposi.py
@@ -5,7 +5,7 @@ def homing_hexiposi():
#Initial checks
robot.assert_no_task()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
#location = robot.get_current_point()
diff --git a/script/motion/mount.py b/script/motion/mount.py
index 7cb614c..14a5cda 100644
--- a/script/motion/mount.py
+++ b/script/motion/mount.py
@@ -1,4 +1,4 @@
-def mount(segment, puck, sample, force=False):
+def mount(segment, puck, sample, force=False, read_dm=False):
"""
"""
print "mount: ", segment, puck, sample, force
@@ -7,7 +7,7 @@ def mount(segment, puck, sample, force=False):
assertValidAddress(segment, puck, sample)
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
hexiposi.assert_homed()
@@ -29,8 +29,17 @@ def mount(segment, puck, sample, force=False):
robot.move_dewar()
robot.get_dewar(segment, puck, sample)
+
+ if read_dm:
+ barcode_reader.start_read(10.0)
+ robot.move_scanner()
+
robot.move_gonio()
+ if read_dm:
+ dm = barcode_reader.get_readout()
+ print "Datamatrix: " , dm
+
smart_magnet.set_mount_current()
try:
robot.put_gonio()
diff --git a/script/motion/move_dewar.py b/script/motion/move_dewar.py
index e829a25..3dfcbfe 100644
--- a/script/motion/move_dewar.py
+++ b/script/motion/move_dewar.py
@@ -6,7 +6,7 @@ def move_dewar():
#Initial checks
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
diff --git a/script/motion/move_gonio.py b/script/motion/move_gonio.py
index 8ce6389..82397f9 100644
--- a/script/motion/move_gonio.py
+++ b/script/motion/move_gonio.py
@@ -6,7 +6,7 @@ def move_gonio():
#Initial checks
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
diff --git a/script/motion/move_heater.py b/script/motion/move_heater.py
index bafe6bc..000e500 100644
--- a/script/motion/move_heater.py
+++ b/script/motion/move_heater.py
@@ -6,7 +6,7 @@ def move_heater():
#Initial checks
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
diff --git a/script/motion/move_home.py b/script/motion/move_home.py
index 932bd5d..30592d6 100644
--- a/script/motion/move_home.py
+++ b/script/motion/move_home.py
@@ -6,7 +6,7 @@ def move_home():
#Initial checks
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
diff --git a/script/motion/move_park.py b/script/motion/move_park.py
index 49a1735..e1715c0 100644
--- a/script/motion/move_park.py
+++ b/script/motion/move_park.py
@@ -6,7 +6,7 @@ def move_park():
#Initial checks
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
diff --git a/script/motion/move_scanner.py b/script/motion/move_scanner.py
index bd6c5bd..791e634 100644
--- a/script/motion/move_scanner.py
+++ b/script/motion/move_scanner.py
@@ -6,13 +6,21 @@ def move_scanner():
#Initial checks
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
#Enabling
- enable_motion()
+ enable_motion()
+ #barcode_reader.start_read(20.0)
if not robot.is_scanner():
robot.move_scanner()
+
+ #robot.do_scan()
+ #dm = barcode_reader.get_readout()
+ dm = barcode_reader.read(0.5)
+
+ print "Datamatrix: " , dm
+ #print "Datamatrix: " , barcode_reader.wait_readout()
\ No newline at end of file
diff --git a/script/motion/put_dewar.py b/script/motion/put_dewar.py
index aa3760d..079411e 100644
--- a/script/motion/put_dewar.py
+++ b/script/motion/put_dewar.py
@@ -7,7 +7,7 @@ def put_dewar(segment, puck, sample, force=False):
assertValidAddress(segment, puck, sample)
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
hexiposi.assert_homed()
diff --git a/script/motion/put_gonio.py b/script/motion/put_gonio.py
index b5e9f11..1044a14 100644
--- a/script/motion/put_gonio.py
+++ b/script/motion/put_gonio.py
@@ -6,7 +6,7 @@ def put_gonio(segment, puck, sample, force=False):
#Initial checks
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
diff --git a/script/motion/robot_recover.py b/script/motion/robot_recover.py
new file mode 100644
index 0000000..87e5d18
--- /dev/null
+++ b/script/motion/robot_recover.py
@@ -0,0 +1,16 @@
+def robot_recover():
+ """
+ """
+ print "robot_recover"
+
+ #Initial checks
+ robot.assert_no_task()
+ robot.reset_motion()
+ robot.wait_ready()
+
+ #Enabling
+ enable_motion()
+
+ #barcode_reader.start_read(20.0)
+
+ robot.robot_recover()
diff --git a/script/motion/unmount.py b/script/motion/unmount.py
index 9275ca4..851ef30 100644
--- a/script/motion/unmount.py
+++ b/script/motion/unmount.py
@@ -7,11 +7,15 @@ def unmount(segment, puck, sample, force=False):
assertValidAddress(segment, puck, sample)
robot.assert_no_task()
robot.reset_motion()
- robot.state.assertReady()
+ robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
hexiposi.assert_homed()
+ if smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) == False:
+ raise Exception("No pin detected on gonio")
+
+
#Enabling
enable_motion()
@@ -25,6 +29,11 @@ def unmount(segment, puck, sample, force=False):
if not robot.is_gonio():
robot.move_gonio()
- robot.get_gonio()
- robot.move_dewar()
- robot.put_dewar(segment, puck, sample)
+ smart_magnet.set_unmount_current()
+ try:
+ robot.get_gonio()
+ robot.move_dewar()
+ robot.put_dewar(segment, puck, sample)
+ finally:
+ smart_magnet.set_default_current()
+
diff --git a/script/test/TestBugPcAPI b/script/test/TestBugPcAPI
new file mode 100644
index 0000000..5be0f3e
--- /dev/null
+++ b/script/test/TestBugPcAPI
@@ -0,0 +1,4 @@
+while True:
+ img.initialize()
+ img.waitNext(10000)
+ time.sleep(2.0)
\ No newline at end of file
diff --git a/script/test/TestBugPcAPI.py b/script/test/TestBugPcAPI.py
new file mode 100644
index 0000000..7a3d186
--- /dev/null
+++ b/script/test/TestBugPcAPI.py
@@ -0,0 +1,30 @@
+import ch.psi.pshell.prosilica.Prosilica as Prosilica
+import ch.psi.pshell.device.Camera as Camera
+
+
+add_device(Prosilica("img", 25001, "PacketSize=1522;PixelFormat=Mono8;BinningX=1;BinningY=1;RegionX=300;RegionY=200;Width=1000;Height=1000;MulticastEnable=Off"), True)
+
+img.camera.setGrabMode(Camera.GrabMode.Continuous)
+img.camera.setTriggerMode(Camera.TriggerMode.Fixed_Rate)
+img.camera.setExposure(50.00)
+img.camera.setAcquirePeriod(200.00)
+img.camera.setGain(0.0)
+#img.camera.setROI(200, 0,1200,1200)
+"""
+img.camera.setROI(300, 200,1000,1000)
+img.config.rotation=17
+img.config.rotationCrop=True
+img.config.roiX,img.config.roiY, img.config.roiWidth,img.config.roiHeight = 50,50,900,900
+"""
+img.camera.setROI(int(get_setting("roi_x")), int(get_setting("roi_y")), int(get_setting("roi_w")), int(get_setting("roi_h")))
+
+img.camera.stop()
+img.camera.start()
+
+
+show_panel(img)
+#while True:
+# img.initialize()
+# img.waitNext(1000)
+# time.sleep(0.1)
+
diff --git a/script/test/TestBugPcAPI2.py b/script/test/TestBugPcAPI2.py
new file mode 100644
index 0000000..037fbb0
--- /dev/null
+++ b/script/test/TestBugPcAPI2.py
@@ -0,0 +1,6 @@
+import ch.psi.pshell.imaging.MjpegSource as MjpegSource
+MjpegSource2 = get_context().pluginManager.getDynamicClass("MjpegSource2")
+add_device(MjpegSource2("gripper_cam", "http://129.129.110.114/axis-cgi/mjpg/video.cgi"), True)
+gripper_cam.polling=100
+#gripper_cam.monitored = True
+show_panel(gripper_cam)
\ No newline at end of file
diff --git a/script/test/TestBugPcAPI3.py b/script/test/TestBugPcAPI3.py
new file mode 100644
index 0000000..6acb775
--- /dev/null
+++ b/script/test/TestBugPcAPI3.py
@@ -0,0 +1,4 @@
+while True:
+ img.initialize()
+ img.waitNext(1000)
+ time.sleep(0.1)
\ No newline at end of file
diff --git a/script/tools/RestartPuckDetection.py b/script/tools/RestartPuckDetection.py
index c15b009..2251921 100644
--- a/script/tools/RestartPuckDetection.py
+++ b/script/tools/RestartPuckDetection.py
@@ -4,3 +4,5 @@ CMD= "sudo systemctl stop puck_detection.service;sudo systemctl start puck_detec
ret = run("tools/SshExec")
set_return(ret)
+
+puck_detection.initialize()
\ No newline at end of file