Commit 7a002959 authored by bliss administrator's avatar bliss administrator
Browse files

Applying shutter type configuration when setting the shutter type.

parent 3d083369
......@@ -117,14 +117,6 @@ class IsgShutter(BaseShutter):
return Shutter.MANUAL
#@property
#def fsversion(self):
#log_info(self,"fsversion entering")
#reply = self._query("?VER")
#log_info(self,"fsversion leaving")
#return reply
def fsreset(self):
""" Reset the shutter box"""
log_info(self,"fsreset entering")
......@@ -239,38 +231,13 @@ class IsgShutter(BaseShutter):
# Serial line protocol
#def _send(self,msg):
#"""
#write to the device and no read back
#No return
#"""
#send_str = msg + "\r"
#send_utf8 = send_str.encode("utf-8")
#try:
#self._serial.write(send_utf8)
#except PyTango.ConnectionFailed:
## most likely that the Tango Server died
#raise RuntimeError(
#"Tango Serial server is not running anymore. Raised by instance %s" % self.name
#)
#except Exception as e:
## No clue.. Try to catch it next time
#raise RuntimeError(
#"Error when trying to communicate with device. Error is %s and instance is %s" % \
#(type(e), self.name)
#)
#def _query(self,msg):
def _query(self, cmd, timeout=None):
"""
write_readline to the device
gives back a formatted str stripped of the EOL character
"""
#send_str = msg + "\r"
#send_utf8 = send_str.encode("utf-8")
try:
#reply_utf8 = self._serial.write_readline(send_utf8)
try:
self._serial.flush()
self._serial._write((cmd + "\r\n").encode())
......@@ -298,10 +265,6 @@ class IsgShutter(BaseShutter):
"Error when trying to communicate with %s. Command %s returned %s" % \
(self.name, cmd, type(e))
)
#reply_str = reply_utf8.decode("utf-8")
## remove EOL chars
#reply = reply_str.rstrip()
#return reply
def RESET(self):
""" Reset the module"""
......@@ -322,7 +285,21 @@ class IsgShutter(BaseShutter):
else:
print ("\nThe external trigger mode can be set to ON or OFF\n")
@property
def LOWPWR(self):
""" Read the low power mode"""
return self._query("?LOWPWR")
@LOWPWR.setter
def LOWPWR(self, mode):
""" Set the low power mode"""
if mode == "ON" or mode == "OFF":
cmd = "LOWPWR " + mode
self._query(cmd)
else:
print ("\nThe low power mode can be set to ON or OFF\n")
@property
def ISGMODE(self):
""" Read ISGMODE (protected mode")"""
......@@ -339,6 +316,10 @@ class IsgShutter(BaseShutter):
else:
print ("\nThe protected mode can be set to ON or OFF\n")
#
# Protected parameters!
# ISGMODE must be ON
#
@property
def SHTYPE(self):
......@@ -352,28 +333,22 @@ class IsgShutter(BaseShutter):
raise RuntimeError("Cannot modify sutter type! ISGMODE is OFF!")
if sh_type == "ID19" or sh_type == "ID17":
# apply shutter type
cmd = "SHTYPE " + sh_type
self._query(cmd)
else:
print ("\nThe shutter type must be ID19 or ID17\n")
@property
def LOWPWR(self):
""" Read the low power mode"""
return self._query("?LOWPWR")
@SHTYPE.setter
def LOWPWR(self, mode):
""" Set the low power mode"""
if mode == "ON" or mode == "OFF":
cmd = "LOWPWR " + mode
self._query(cmd)
# get the shutter type configuration
conf_dict = self.config["shtype"][sh_type]
# apply timing configuration
for key in conf_dict:
cmd = key + " " + str(conf_dict[key])
self._query(cmd)
# display config
print (self.__info__())
else:
print ("\nThe low power mode can be set to ON or OFF\n")
print ("\nThe shutter type must be ID19 or ID17\n")
@property
def TUP(self):
""" Read the TUP parameter in ms"""
......@@ -383,7 +358,7 @@ class IsgShutter(BaseShutter):
def TUP(self, timeval):
""" Set the TUP parameter in ms. Limits 4 < timeval < 60ms"""
if self.__isgmode == "OFF":
raise RuntimeError("Cannot modify sutter type! ISGMODE is OFF!")
raise RuntimeError("Cannot modify TUP parameter! ISGMODE is OFF!")
timeval = int(timeval)
if timeval < 4 or timeval > 60:
......@@ -401,7 +376,7 @@ class IsgShutter(BaseShutter):
def TDOWN(self, timeval):
""" Set the TDOWN parameter in ms. Limits 0 < timeval < 30ms"""
if self.__isgmode == "OFF":
raise RuntimeError("Cannot modify sutter type! ISGMODE is OFF!")
raise RuntimeError("Cannot modify TDOWN parameter! ISGMODE is OFF!")
timeval = int(timeval)
if timeval < 0 or timeval > 30:
......@@ -410,3 +385,113 @@ class IsgShutter(BaseShutter):
cmd = "TDOWN " + str(timeval)
self._query(cmd)
@property
def VMAX(self):
""" Read the VMAX parameter in Volt"""
return self._query("?VMAX")
@VMAX.setter
def VMAX(self, voltval):
""" Set the VMAX parameter in Volt."""
if self.__isgmode == "OFF":
raise RuntimeError("Cannot modify VMAX parameter! ISGMODE is OFF!")
voltval = int(voltval)
# Maximum voltage not in documentation, cannot check!
cmd = "VMAX " + str(voltval)
self._query(cmd)
@property
def VUP(self):
""" Read the VUP parameter in Volt"""
return self._query("?VUP")
@VUP.setter
def VUP(self, voltval):
""" Set the VUP parameter in Volt. Limits 0 < voltval < Vmax"""
if self.__isgmode == "OFF":
raise RuntimeError("Cannot modify VUP parameter! ISGMODE is OFF!")
voltval = int(voltval)
if voltval < 0 or voltval > self.VMAX:
print ("\nVUP parameter limits: 0 < voltval < Vmax\n")
else:
cmd = "VUP " + str(voltval)
self._query(cmd)
@property
def VDOWN(self):
""" Read the VDOWN parameter in Volt"""
return self._query("?VDOWN")
@VDOWN.setter
def VDOWN(self, voltval):
""" Set the VDOWN parameter in Volt. Limits -Vmax < voltval < 0"""
if self.__isgmode == "OFF":
raise RuntimeError("Cannot modify VDOWN parameter! ISGMODE is OFF!")
voltval = int(voltval)
if voltval < (-1 * self.VMAX) or voltval > 0:
print ("\nVDOWN parameter limits: -Vmax < voltval < 0\n")
else:
cmd = "VDOWN " + str(voltval)
self._query(cmd)
@property
def VLOW(self):
""" Read the VLOW parameter in Volt"""
return self._query("?VLOW")
@VLOW.setter
def VLOW(self, voltval):
""" Set the VLOW parameter in Volt. Limits 0 < voltval < 24"""
if self.__isgmode == "OFF":
raise RuntimeError("Cannot modify VLOW parameter! ISGMODE is OFF!")
voltval = int(voltval)
if voltval < 0 or voltval > 24:
print ("\nVLOW parameter limits: 0 < voltval < 24\n")
else:
cmd = "VLOW " + str(voltval)
self._query(cmd)
@property
def PWRDEL(self):
""" Read the PWRDEL parameter in ms"""
return self._query("?PWRDEL")
@PWRDEL.setter
def PWRDEL(self, timeval):
""" Set the PWRDEL parameter in ms. Limits 0 < timeval < TUP"""
if self.__isgmode == "OFF":
raise RuntimeError("Cannot modify PWRDEL parameter! ISGMODE is OFF!")
timeval = int(timeval)
if timeval < 0 or timeval > self.TUP:
print ("\nVPWRDEL parameter limits: 0 < timeval < TUP\n")
else:
cmd = "PWRDEL " + str(timeval)
self._query(cmd)
@property
def DOWNDEL(self):
""" Read the DOWNDEL parameter in ms"""
return self._query("?DOWNDEL")
@DOWNDEL.setter
def DOWNDEL(self, timeval):
""" Set the DOWNDEL parameter in ms. Limits not ducumented"""
if self.__isgmode == "OFF":
raise RuntimeError("Cannot modify DOWNDEL parameter! ISGMODE is OFF!")
timeval = int(timeval)
#if timeval < 0 or timeval > self.TDOWN:
# print ("\nVDOWNDEL parameter limits: 0 < timeval < TDOWN\n")
#else:
# cmd = "DOWNDEL " + str(timeval)
# self._query(cmd)
cmd = "DOWNDEL " + str(timeval)
self._query(cmd)
Markdown is supported
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