This commit is contained in:
gac-S_Changer
2018-03-19 11:36:12 +01:00
parent dd1359858b
commit 388734cb8b
35 changed files with 590 additions and 204 deletions
+11
View File
@@ -0,0 +1,11 @@
def enable_barcode_reader():
microscan_cmd.write("<H>")
def disable_barcode_reader():
microscan_cmd.write("<I>")
def read_barcode(timeout):
try:
return microscan.waitString(int(timeout * 1000))
except:
return None
+17
View File
@@ -0,0 +1,17 @@
class LaserDistance(ReadonlyRegisterBase):
def __init__(self):
ReadonlyRegisterBase.__init__(self, "laser_distance")
def doRead(self):
ret = ue.readable.read()
ret = 0.0 if math.isnan(ret) else ret
return ret
class ListenerAI (DeviceListener):
def onValueChanged(self, device, value, former):
laser_distance.setCache( 0.0 if math.isnan(value) else value, None)
listenerAI = ListenerAI()
ue.addListener(listenerAI)
laser_distance=LaserDistance()
add_device(laser_distance, True)
+25
View File
@@ -0,0 +1,25 @@
import ch.psi.pshell.device.DiscretePositionerBase as DiscretePositionerBase
class LedPositioner(DiscretePositionerBase):
def __init__(self):
DiscretePositionerBase.__init__(self, "led_ctrl", ["On", "Off"])
self.setState(State.Ready)
self.val = self.doReadReadback()
def doRead(self):
return self.val
def doReadReadback(self):
return "On" if get_led_state() else "Off"
def doWrite(self, val):
self.val = val
if self.val == "On":
set_led_state(True)
else:
set_led_state(False)
add_device(LedPositioner(), True)
led_ctrl.polling = 1000
+2 -2
View File
@@ -17,12 +17,12 @@ class RobotCartesianMotor (PositionerBase):
self.setCache(self.doRead(), None)
def doRead(self):
return float("nan") if self.robot.cartesian_destination is None else float(robot.cartesian_destination[self.index])
return float("nan") if self.robot.cartesian_destination is None else float(self.robot.cartesian_destination[self.index])
def doWrite(self, value):
if self.robot.cartesian_destination is not None:
print "Move " + ROBOT_MOTORS[self.index] + " to " + str(value)
robot.cartesian_destination[self.index] = float(value)
self.robot.cartesian_destination[self.index] = float(value)
self.robot.set_pnt(robot.cartesian_destination , "tcp_p")
self.robot.movel("tcp_p", self.robot.tool , DESC_SCAN)
+4
View File
@@ -70,6 +70,9 @@ robot.high_level_tasks = ["mount", "firstmount"]
robot.set_tool(TOOL_CALIBRATION)
robot.setPolling(500)
robot.set_motors_enabled(True)
robot.set_joint_motors_enabled(True)
#robot.set_monitor_speed(20)
@@ -110,5 +113,6 @@ if joint_forces:
add_device(jfc(), force = True)
"""
+5 -5
View File
@@ -48,11 +48,10 @@ class RobotTCP(TcpDevice, Stoppable):
def set_tool(self,tool):
self.tool = tool
#self.tool_trsf = self.get_tool_trsf()
self.evaluate("tcp_curtool=" + tool)
if self.cartesian_motors_enabled:
self.update()
for m in self.cartesian_motors:
m.initialize()
m.update()
self.update()
self.set_motors_enabled(True)
def get_tool(self):
@@ -449,7 +448,8 @@ class RobotTCP(TcpDevice, Stoppable):
try:
start = time.time()
#sts = self._sendReceive("EVT").strip().split(self.array_separator)
sts = self.execute("get_status", self.current_task, self.tool, self.frame)
#sts = self.execute("get_status", self.current_task, self.tool, self.frame)
sts = self.execute("get_status", self.current_task)
self._update_working_mode(int(sts[0]), int(sts[1]))
self.powered = sts[2] == "1"
self.speed = int(sts[3])
+111
View File
@@ -0,0 +1,111 @@
"""
wago=ch.psi.pshell.modbus.ModbusTCP|wago-mxsc-1:502|||
relays=ch.psi.pshell.modbus.DigitalOutputArray|wago 0 16||1000|
release_local_safety=ch.psi.pshell.modbus.DigitalOutput|wago 0|||
release_psys_safety=ch.psi.pshell.modbus.DigitalOutput|wago 1|||
ln2_main_power=ch.psi.pshell.modbus.DigitalOutput|wago 2|||
rim_heater=ch.psi.pshell.modbus.DigitalOutput|wago 3|||
phase_separator_ln2=ch.psi.pshell.modbus.DigitalOutput|wago 4|||
dewar_ln2=ch.psi.pshell.modbus.DigitalOutput|wago 5|||false
valve_he_chamber=ch.psi.pshell.modbus.DigitalOutput|wago 6|||
gripper_dryer=ch.psi.pshell.modbus.DigitalOutput|wago 7|||
valve_1=ch.psi.pshell.modbus.DigitalOutput|wago 8|||
valve_2=ch.psi.pshell.modbus.DigitalOutput|wago 9|||
valve_3=ch.psi.pshell.modbus.DigitalOutput|wago 10|||
valve_4=ch.psi.pshell.modbus.DigitalOutput|wago 11|||
#spare_do_1=ch.psi.pshell.modbus.DigitalOutput|wago 12|||
#spare_do_2=ch.psi.pshell.modbus.DigitalOutput|wago 13|||
#spare_do_3=ch.psi.pshell.modbus.DigitalOutput|wago 14|||
#spare_do_4=ch.psi.pshell.modbus.DigitalOutput|wago 15|||
phase_separator_level=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 0||1000|
dewar_level=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 1||1000|
rim_heater_temp=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 2||1000|
air_pressure=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 3||1000|
n2_pressure=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 4||1000|
#spare_ai_1=ch.psi.pshell.modbus.AnalogInput|wago 5|||
#spare_ai_2=ch.psi.pshell.modbus.AnalogInput|wago 6|||
#spare_ai_3=ch.psi.pshell.modbus.AnalogInput|wago 7|||
led_ctrl_1=ch.psi.pshell.modbus.ProcessVariable|wago 0|||
led_ctrl_2=ch.psi.pshell.modbus.ProcessVariable|wago 1|||
led_ctrl_3=ch.psi.pshell.modbus.ProcessVariable|wago 2|||
"""
###################################################################################################
# Leds
###################################################################################################
def set_led_state(value):
"""
Turn leds on and off
"""
if value:
led_ctrl_1.write(led_ctrl_1.config.maxValue)
led_ctrl_2.write(led_ctrl_2.config.maxValue)
led_ctrl_3.write(led_ctrl_3.config.maxValue)
else:
led_ctrl_1.write(0.0)
led_ctrl_2.write(0.0)
led_ctrl_3.write(0.0)
def get_led_state():
"""
Returns led state (on/off)
"""
return led_ctrl_1.read() > 0
#TODO: The range should be set automatically reading LN2 sensor.
def set_led_range(room_temp = True):
"""
Led range should be limitted in room temperature
"""
max_val = 0.40 if room_temp else 1.20
led_ctrl_1.config.maxValue = max_val
led_ctrl_1.config.save()
led_ctrl_2.config.maxValue = max_val
led_ctrl_2.config.save()
led_ctrl_3.config.maxValue = max_val
led_ctrl_3.config.save()
led_ctrl_1.initialize()
led_ctrl_2.initialize()
led_ctrl_3.initialize()
if led_ctrl_1.read() > max_val:
led_ctrl_1.write(max_val)
if led_ctrl_2.read() > max_val:
led_ctrl_2.write(max_val)
if led_ctrl_3.read() > max_val:
led_ctrl_3.write(max_val)
def is_led_room_temp():
return led_ctrl_1.config.maxValue <= 0.50
###################################################################################################
# Safety release
###################################################################################################
def release_local():
"""
Release local safety
"""
release_local_safety.write(False)
time.sleep(0.01)
release_local_safety.write(True)
time.sleep(0.01)
release_local_safety.write(False)
def release_psys():
"""
Release psys safety
"""
release_psys_safety.write(False)
time.sleep(0.01)
release_psys_safety.write(True)
time.sleep(0.01)
release_psys_safety.write(False)