Script execution

This commit is contained in:
gac-S_Changer
2017-02-24 12:14:20 +01:00
parent 40511d3eb0
commit fcb200f86a

View File

@@ -19,7 +19,7 @@ class RobotTCP(TcpDevice, Stoppable):
self.status = None
self.lock = threading.Lock()
def _sendReceive(self, msg_id, msg = ""):
def _sendReceive(self, msg_id, msg = "", timeout = None, retries = None):
tx = self.header if (self.header != None) else ""
tx = tx + msg_id + " " + msg
if (len(tx)>127):
@@ -38,10 +38,10 @@ class RobotTCP(TcpDevice, Stoppable):
raise Exception(rx[4:])
return rx[4:]
def call(self, msg):
def call(self, msg, timeout = None, retries = None):
id = "%03d" % self.msg_id
self.msg_id = (self.msg_id+1)%1000
return self._sendReceive(id, msg)
return self._sendReceive(id, msg, timeout, retries)
def execute(self, command, *argv):
msg = str(command)
@@ -59,8 +59,8 @@ class RobotTCP(TcpDevice, Stoppable):
if ev.strip() == "": return None
return ev
def evaluate(self, cmd):
ret = self.execute('eval', cmd)
def evaluate(self, cmd, timeout = self.timeout, retries = self.retries):
ret = self.execute('eval', cmd, timeout, retries)
if ret.strip() != "": raise Exception(ret)
def get_var(self, name):
@@ -160,12 +160,13 @@ class RobotTCP(TcpDevice, Stoppable):
if (ret==-1): raise Exception("The robot is not in remote working mode")
if (ret==-2): raise Exception("The monitor speed is under the control of the operator")
if (ret==-3): raise Exception("The specified speed is not supported")
def enable(self):
return self.evaluate("enablePower()")
#waits for power to be actually cut off
def disable(self):
return self.evaluate("disablePower()")
return self.evaluate("disablePower()", timeout=5000)
def is_calibrated(self):
return self.eval_bool("isCalibrated()")