Skip to content
Snippets Groups Projects
Commit f4e7babe authored by Milan Prica's avatar Milan Prica :skier:
Browse files

ForceReference(dir) becomes ReferenceForward and ReferenceBackward. Additional...

ForceReference(dir) becomes ReferenceForward and ReferenceBackward. Additional attribute permission modifications.
parent 87f5f8fb
No related branches found
Tags 1.0.5
No related merge requests found
...@@ -206,24 +206,29 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -206,24 +206,29 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
print "Socket connection raised exception.\n" print "Socket connection raised exception.\n"
self.status_string = "Socket Failed: " + str(e) self.status_string = "Socket Failed: " + str(e)
self.error_stream(self.status_string) self.error_stream(self.status_string)
self.socket_alive = False
#------------------------------------------------------------------ #------------------------------------------------------------------
# Checks if the controller is connected. # Checks if the controller is connected.
# Returns True/False # Returns True/False
#------------------------------------------------------------------ #------------------------------------------------------------------
def socket_check(self): def socket_check(self):
if self.socket.state() != PyTango.DevState.ON: try:
# Try to reconnect once...
self.debug_stream("Socket not in ON, reconnect.")
self.socket_reconnect()
time.sleep(0.2)
if self.socket.state() != PyTango.DevState.ON: if self.socket.state() != PyTango.DevState.ON:
self.set_state(PyTango.DevState.FAULT) # Try to reconnect once...
self.status_string = "Socket device not in ON state. INIT failed." self.debug_stream("Socket not in ON, reconnect.")
self.debug_stream("Socket still not in ON, init failed.") self.socket_reconnect()
return False time.sleep(0.2)
self.debug_stream("Socket device is in ON.") if self.socket.state() != PyTango.DevState.ON:
return True self.set_state(PyTango.DevState.FAULT)
self.status_string = "Socket device not in ON state. INIT failed."
self.debug_stream("Socket still not in ON, init failed.")
return False
self.debug_stream("Socket device is in ON.")
return True
except:
self.socket_alive = False
return False
#------------------------------------------------------------------ #------------------------------------------------------------------
# Write socket utility # Write socket utility
...@@ -580,7 +585,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -580,7 +585,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
self.socket_write(cmd_str) self.socket_write(cmd_str)
def is_Acceleration_allowed(self, req_type): def is_Acceleration_allowed(self, req_type):
return req_type is PyTango.AttReqType.READ_REQ or (self.get_state() not in (PyTango.DevState.MOVING, PyTango.DevState.FAULT,) and self.sensor_present) return req_type is PyTango.AttReqType.READ_REQ or (self.sensor_present and self.get_state() not in (PyTango.DevState.MOVING, PyTango.DevState.FAULT,))
def read_Velocity(self, attr): def read_Velocity(self, attr):
# self.debug_stream("In read_Velocity()") # self.debug_stream("In read_Velocity()")
...@@ -606,7 +611,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -606,7 +611,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
self.socket_write(cmd_str) self.socket_write(cmd_str)
def is_Velocity_allowed(self, req_type): def is_Velocity_allowed(self, req_type):
return req_type is PyTango.AttReqType.READ_REQ or (self.get_state() not in (PyTango.DevState.MOVING, PyTango.DevState.FAULT,) and self.sensor_present) return req_type is PyTango.AttReqType.READ_REQ or (self.sensor_present and self.get_state() not in (PyTango.DevState.MOVING, PyTango.DevState.FAULT,))
def read_HoldTime(self, attr): def read_HoldTime(self, attr):
# self.debug_stream("In read_HoldTime()") # self.debug_stream("In read_HoldTime()")
...@@ -629,7 +634,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -629,7 +634,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
self.socket_write(cmd_str) self.socket_write(cmd_str)
def is_HoldTime_allowed(self, req_type): def is_HoldTime_allowed(self, req_type):
return self.sensor_present return req_type is PyTango.AttReqType.READ_REQ or (self.sensor_present and self.get_state() not in (PyTango.DevState.MOVING, PyTango.DevState.FAULT,))
def read_LSInvert(self, attr): def read_LSInvert(self, attr):
# self.debug_stream("In read_LSInvert()") # self.debug_stream("In read_LSInvert()")
...@@ -684,7 +689,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -684,7 +689,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
self.socket_write(cmd_str) self.socket_write(cmd_str)
def is_LSOffset_allowed(self, req_type): def is_LSOffset_allowed(self, req_type):
return req_type is PyTango.AttReqType.READ_REQ or (self.get_state() not in (PyTango.DevState.MOVING, PyTango.DevState.FAULT,) and self.sensor_present) return req_type is PyTango.AttReqType.READ_REQ or (self.sensor_present and self.get_state() not in (PyTango.DevState.MOVING, PyTango.DevState.FAULT,))
def read_HighLimitPosition(self, attr): def read_HighLimitPosition(self, attr):
# self.debug_stream("In read_HighLimitPosition()") # self.debug_stream("In read_HighLimitPosition()")
...@@ -708,7 +713,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -708,7 +713,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
self.socket_write(cmd_str) self.socket_write(cmd_str)
def is_HighLimitPosition_allowed(self, req_type): def is_HighLimitPosition_allowed(self, req_type):
return req_type is PyTango.AttReqType.READ_REQ or (self.get_state() not in (PyTango.DevState.MOVING, PyTango.DevState.FAULT,) and self.sensor_present) return req_type is PyTango.AttReqType.READ_REQ or (self.sensor_present and self.get_state() not in (PyTango.DevState.MOVING, PyTango.DevState.FAULT,))
def read_LowLimitPosition(self, attr): def read_LowLimitPosition(self, attr):
# self.debug_stream("In read_LowLimitPosition()") # self.debug_stream("In read_LowLimitPosition()")
...@@ -732,7 +737,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -732,7 +737,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
self.socket_write(cmd_str) self.socket_write(cmd_str)
def is_LowLimitPosition_allowed(self, req_type): def is_LowLimitPosition_allowed(self, req_type):
return req_type is PyTango.AttReqType.READ_REQ or (self.get_state() not in (PyTango.DevState.MOVING, PyTango.DevState.FAULT,) and self.sensor_present) return req_type is PyTango.AttReqType.READ_REQ or (self.sensor_present and self.get_state() not in (PyTango.DevState.MOVING, PyTango.DevState.FAULT,))
def read_Amplitude(self, attr): def read_Amplitude(self, attr):
# self.debug_stream("In read_Amplitude()") # self.debug_stream("In read_Amplitude()")
...@@ -892,13 +897,14 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -892,13 +897,14 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
PyTango.Except.throw_exception("Read Sensor Enabled Failed", "Unexpected reply format", "read_SensorEnabled()") PyTango.Except.throw_exception("Read Sensor Enabled Failed", "Unexpected reply format", "read_SensorEnabled()")
attr.set_value(self.attr_SensorEnabled_read) attr.set_value(self.attr_SensorEnabled_read)
def write_SensorPowerMode(self, attr): def write_SensorPowerMode(self, attr):
# self.debug_stream("In write_SensorEnabled()") # self.debug_stream("In write_SensorEnabled()")
data = attr.get_write_value() data = attr.get_write_value()
cmd_str = ":CHAN" + self.chan + ":SENS:MODE " + str(data) cmd_str = ":CHAN" + self.chan + ":SENS:MODE " + str(data)
self.socket_write(cmd_str) self.socket_write(cmd_str)
def is_SensorPowerMode_allowed(self, req_type):
return req_type is PyTango.AttReqType.READ_REQ or (self.sensor_present and self.get_state() not in (PyTango.DevState.MOVING, PyTango.DevState.FAULT,))
def read_IsReferenced(self, attr): def read_IsReferenced(self, attr):
attr.set_value(self.attr_IsReferenced_read) attr.set_value(self.attr_IsReferenced_read)
...@@ -907,7 +913,6 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -907,7 +913,6 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
attr.set_value(self.attr_IsCalibrated_read) attr.set_value(self.attr_IsCalibrated_read)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Smaract_mcs2 command methods # Smaract_mcs2 command methods
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
...@@ -945,9 +950,9 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -945,9 +950,9 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
def Reference(self): def Reference(self):
self.debug_stream("In Reference()") self.debug_stream("In Reference()")
if self.attr_IsReferenced_read: # if self.attr_IsReferenced_read:
self.debug_stream("Already referenced. Do nothing.") # self.debug_stream("Already referenced. Do nothing.")
return # return
# Evaluate the last known physical position based on the values stored in tango db # Evaluate the last known physical position based on the values stored in tango db
# and pick the referencing direction accordingly: # and pick the referencing direction accordingly:
# Referencing/Calibrating mode 0 is forward (default), 1 is backward # Referencing/Calibrating mode 0 is forward (default), 1 is backward
...@@ -1000,23 +1005,38 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -1000,23 +1005,38 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
return self.sensor_present return self.sensor_present
def ForceReference(self, ref_mode): def ReferenceForward(self):
self.debug_stream("In ForceReference()") self.debug_stream("In ReferenceForward()")
if self.attr_IsReferenced_read: # if self.attr_IsReferenced_read:
self.debug_stream("Already referenced. Do nothing.") # self.debug_stream("Already referenced. Do nothing.")
return # return
if ref_mode not in [0, 1]: ref_mode = 0
return
cmd_str = ":CHAN" + self.chan + ":REF:OPT " + str(ref_mode) cmd_str = ":CHAN" + self.chan + ":REF:OPT " + str(ref_mode)
self.socket_write(cmd_str) self.socket_write(cmd_str)
# start actual referencing: # start actual referencing:
cmd_str = ":REF" + self.chan cmd_str = ":REF" + self.chan
self.socket_write(cmd_str) self.socket_write(cmd_str)
def is_ForceReference_allowed(self): def is_ReferenceForward_allowed(self):
return self.sensor_present return self.sensor_present
def ReferenceBackward(self):
self.debug_stream("In ReferenceBackward()")
# if self.attr_IsReferenced_read:
# self.debug_stream("Already referenced. Do nothing.")
# return
ref_mode = 1
cmd_str = ":CHAN" + self.chan + ":REF:OPT " + str(ref_mode)
self.socket_write(cmd_str)
# start actual referencing:
cmd_str = ":REF" + self.chan
self.socket_write(cmd_str)
def is_ReferenceBackward_allowed(self):
return self.sensor_present
def Go(self): def Go(self):
# self.debug_stream("In Go()") # self.debug_stream("In Go()")
if self.attr_NextPosition_read != self.attr_Position_read: if self.attr_NextPosition_read != self.attr_Position_read:
...@@ -1024,7 +1044,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -1024,7 +1044,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
self.move_abs(self.attr_NextPosition_read) self.move_abs(self.attr_NextPosition_read)
def is_Go_allowed(self): def is_Go_allowed(self):
return self.get_state() in (PyTango.DevState.ON,) and self.sensor_present return self.sensor_present and self.get_state() in (PyTango.DevState.ON,)
def StepUp(self): def StepUp(self):
...@@ -1111,7 +1131,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -1111,7 +1131,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
self.socket_write(cmd_str) self.socket_write(cmd_str)
def is_DefinePosition_allowed(self): def is_DefinePosition_allowed(self):
return self.get_state() in (PyTango.DevState.ON,) and self.sensor_present return self.sensor_present and self.get_state() in (PyTango.DevState.ON,)
def GoToHighLimit(self): def GoToHighLimit(self):
...@@ -1122,7 +1142,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -1122,7 +1142,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
self.move_abs(self.attr_HighLimitPosition_read) self.move_abs(self.attr_HighLimitPosition_read)
def is_GoToHighLimit_allowed(self): def is_GoToHighLimit_allowed(self):
return self.get_state() in (PyTango.DevState.ON,) and self.sensor_present return self.sensor_present and self.get_state() in (PyTango.DevState.ON,)
def GoToLowLimit(self): def GoToLowLimit(self):
...@@ -1133,7 +1153,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl): ...@@ -1133,7 +1153,7 @@ class Smaract_mcs2 (PyTango.Device_4Impl):
self.move_abs(self.attr_LowLimitPosition_read) self.move_abs(self.attr_LowLimitPosition_read)
def is_GoToLowLimit_allowed(self): def is_GoToLowLimit_allowed(self):
return self.get_state() in (PyTango.DevState.ON,) and self.sensor_present return self.sensor_present and self.get_state() in (PyTango.DevState.ON,)
def Stop(self): def Stop(self):
...@@ -1236,8 +1256,11 @@ class Smaract_mcs2Class(PyTango.DeviceClass): ...@@ -1236,8 +1256,11 @@ class Smaract_mcs2Class(PyTango.DeviceClass):
'Reference': 'Reference':
[[PyTango.DevVoid, "none"], [[PyTango.DevVoid, "none"],
[PyTango.DevVoid, "none"]], [PyTango.DevVoid, "none"]],
'ForceReference': 'ReferenceForward':
[[PyTango.DevShort, "direction 0=fwd, 1=bkw"], [[PyTango.DevShort, "none"],
[PyTango.DevVoid, "none"]],
'ReferenceBackward':
[[PyTango.DevShort, "none"],
[PyTango.DevVoid, "none"]], [PyTango.DevVoid, "none"]],
'Go': 'Go':
[[PyTango.DevVoid, "none"], [[PyTango.DevVoid, "none"],
...@@ -1295,7 +1318,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass): ...@@ -1295,7 +1318,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass):
positioners and in degrees/s^2 for rotary positioners. \ positioners and in degrees/s^2 for rotary positioners. \
The valid range is 0..10. A value of 0 (default) deactivates \ The valid range is 0..10. A value of 0 (default) deactivates \
the acceleration control feature.", the acceleration control feature.",
'memorized':"false", 'memorized':"true",
}], }],
'Velocity': 'Velocity':
[[PyTango.DevDouble, [[PyTango.DevDouble,
...@@ -1307,7 +1330,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass): ...@@ -1307,7 +1330,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass):
'description': "Defines the speed in mm/s for linear positioners \ 'description': "Defines the speed in mm/s for linear positioners \
and in degrees/s for rotary positioners. The valid range is 0..100. \ and in degrees/s for rotary positioners. The valid range is 0..100. \
A value of 0 (default) deactivates the speed control feature.", A value of 0 (default) deactivates the speed control feature.",
'memorized':"false", 'memorized':"true",
}], }],
'Frequency': 'Frequency':
[[PyTango.DevLong, [[PyTango.DevLong,
...@@ -1318,7 +1341,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass): ...@@ -1318,7 +1341,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass):
'min value': "1", 'min value': "1",
'description': "Open-loop steps frequency in Hertz.\ 'description': "Open-loop steps frequency in Hertz.\
The default value is 100. Used in stepper mode only.", The default value is 100. Used in stepper mode only.",
'memorized':"false", 'memorized':"true",
}], }],
'Amplitude': 'Amplitude':
[[PyTango.DevLong, [[PyTango.DevLong,
...@@ -1330,7 +1353,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass): ...@@ -1330,7 +1353,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass):
'description': "Voltage in binary form, the valid range is 1..65535 \ 'description': "Voltage in binary form, the valid range is 1..65535 \
A value of 65535 (max) equals to 100 Volts. Lower amplitude values \ A value of 65535 (max) equals to 100 Volts. Lower amplitude values \
result in a smaller step width. Used in stepper mode only.", result in a smaller step width. Used in stepper mode only.",
'memorized':"false", 'memorized':"true",
}], }],
'Voltage': 'Voltage':
[[PyTango.DevDouble, [[PyTango.DevDouble,
...@@ -1435,7 +1458,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass): ...@@ -1435,7 +1458,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass):
'description': "If selected, write Position is disabled. \ 'description': "If selected, write Position is disabled. \
Instead, the next position attribute must be set and \ Instead, the next position attribute must be set and \
Go command executed.", Go command executed.",
'memorized':"true" 'memorized':"true",
}], }],
'HighLimitPosition': 'HighLimitPosition':
[[PyTango.DevDouble, [[PyTango.DevDouble,
...@@ -1444,7 +1467,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass): ...@@ -1444,7 +1467,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass):
{ {
'description': "High limit position in mm for linear sensors \ 'description': "High limit position in mm for linear sensors \
and in degrees for rotary sensors.", and in degrees for rotary sensors.",
'memorized':"false", 'memorized':"true",
}], }],
'LowLimitPosition': 'LowLimitPosition':
[[PyTango.DevDouble, [[PyTango.DevDouble,
...@@ -1453,7 +1476,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass): ...@@ -1453,7 +1476,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass):
{ {
'description': "Low limit position in mm for linear sensors \ 'description': "Low limit position in mm for linear sensors \
and in degrees for rotary sensors.", and in degrees for rotary sensors.",
'memorized':"false", 'memorized':"true",
}], }],
'PositionBackup': 'PositionBackup':
[[PyTango.DevDouble, [[PyTango.DevDouble,
...@@ -1473,7 +1496,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass): ...@@ -1473,7 +1496,7 @@ class Smaract_mcs2Class(PyTango.DeviceClass):
'min value':"0", 'min value':"0",
'description': "Selects the mode. Must be either \ 'description': "Selects the mode. Must be either \
0 (disabled), 1 (enabled) or 2 (powersave).", 0 (disabled), 1 (enabled) or 2 (powersave).",
'memorized':"false", 'memorized':"true",
}], }],
'IsCalibrated': 'IsCalibrated':
[[PyTango.DevBoolean, [[PyTango.DevBoolean,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment