Commit 1630b227 authored by Claudio Scafuri's avatar Claudio Scafuri 💬
Browse files

some fixing in case of errors

parent 45871064
......@@ -59,7 +59,7 @@ class DataAcquisitionThread(threading.Thread):
threading.Thread.__init__(self)
self.disconnected_hardware = True
self.fault = True
self.wait_time = 5
self.wait_time = 10
self.problems: List[str] = []
self.log_list: List[str] = []
self.device = device
......@@ -107,7 +107,7 @@ class DataAcquisitionThread(threading.Thread):
"interrotta"
)
self.connected_socket = False
self.sock.shutdown(1)
self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close()
break
except Exception as e:
......@@ -120,8 +120,11 @@ class DataAcquisitionThread(threading.Thread):
finally:
if 'sock' in vars():
self.device.debug_stream('Closing socket')
self.sock.shutdown(1)
self.sock.close()
try:
self.sock.shutdown(1)
self.sock.close()
except Exception as e:
self.device.error_stream('dev_%d socket error %s' % (i, e))
def get_connected_socket(self, timeout: float = 5) -> socket.socket:
try:
......
......@@ -135,7 +135,7 @@ class WaterSensor (PyTango.LatestDeviceImpl):
def read_board00(self, attr):
self.debug_stream("In read_board00()")
#----- PROTECTED REGION ID(WaterSensor.board00_read) ENABLED START -----#
if self._state == PyTango.DevState.UNKNOWN :
if self._state == PyTango.DevState.UNKNOWN or not self.board_ok[0] :
attr.set_quality(PyTango.AttrQuality.ATTR_INVALID, True)
else:
attr.set_value(self.boards[0])
......@@ -145,7 +145,7 @@ class WaterSensor (PyTango.LatestDeviceImpl):
def read_board01(self, attr):
self.debug_stream("In read_board01()")
#----- PROTECTED REGION ID(WaterSensor.board01_read) ENABLED START -----#
if self._state == PyTango.DevState.UNKNOWN :
if self._state == PyTango.DevState.UNKNOWN or not self.board_ok[1] :
attr.set_quality(PyTango.AttrQuality.ATTR_INVALID, True)
else:
attr.set_value(self.boards[1])
......@@ -155,7 +155,7 @@ class WaterSensor (PyTango.LatestDeviceImpl):
def read_board02(self, attr):
self.debug_stream("In read_board02()")
#----- PROTECTED REGION ID(WaterSensor.board02_read) ENABLED START -----#
if self._state == PyTango.DevState.UNKNOWN :
if self._state == PyTango.DevState.UNKNOWN or not self.board_ok[2] :
attr.set_quality(PyTango.AttrQuality.ATTR_INVALID, True)
else:
attr.set_value(self.boards[2])
......@@ -165,7 +165,7 @@ class WaterSensor (PyTango.LatestDeviceImpl):
def read_board03(self, attr):
self.debug_stream("In read_board03()")
#----- PROTECTED REGION ID(WaterSensor.board03_read) ENABLED START -----#
if self._state == PyTango.DevState.UNKNOWN :
if self._state == PyTango.DevState.UNKNOWN or not self.board_ok[3] :
attr.set_quality(PyTango.AttrQuality.ATTR_INVALID, True)
else:
attr.set_value(self.boards[3])
......@@ -175,7 +175,7 @@ class WaterSensor (PyTango.LatestDeviceImpl):
def read_board04(self, attr):
self.debug_stream("In read_board04()")
#----- PROTECTED REGION ID(WaterSensor.board04_read) ENABLED START -----#
if self._state == PyTango.DevState.UNKNOWN :
if self._state == PyTango.DevState.UNKNOWN or not self.board_ok[4] :
attr.set_quality(PyTango.AttrQuality.ATTR_INVALID, True)
else:
attr.set_value(self.boards[4])
......@@ -185,7 +185,7 @@ class WaterSensor (PyTango.LatestDeviceImpl):
def read_board05(self, attr):
self.debug_stream("In read_board05()")
#----- PROTECTED REGION ID(WaterSensor.board05_read) ENABLED START -----#
if self._state == PyTango.DevState.UNKNOWN :
if self._state == PyTango.DevState.UNKNOWN or not self.board_ok[5] :
attr.set_quality(PyTango.AttrQuality.ATTR_INVALID, True)
else:
attr.set_value(self.boards[5])
......@@ -195,7 +195,7 @@ class WaterSensor (PyTango.LatestDeviceImpl):
def read_board06(self, attr):
self.debug_stream("In read_board06()")
#----- PROTECTED REGION ID(WaterSensor.board06_read) ENABLED START -----#
if self._state == PyTango.DevState.UNKNOWN :
if self._state == PyTango.DevState.UNKNOWN or not self.board_ok[6] :
attr.set_quality(PyTango.AttrQuality.ATTR_INVALID, True)
else:
attr.set_value(self.boards[6])
......@@ -205,7 +205,7 @@ class WaterSensor (PyTango.LatestDeviceImpl):
def read_board07(self, attr):
self.debug_stream("In read_board07()")
#----- PROTECTED REGION ID(WaterSensor.board07_read) ENABLED START -----#
if self._state == PyTango.DevState.UNKNOWN :
if self._state == PyTango.DevState.UNKNOWN or not self.board_ok[7] :
attr.set_quality(PyTango.AttrQuality.ATTR_INVALID, True)
else:
attr.set_value(self.boards[7])
......@@ -215,7 +215,7 @@ class WaterSensor (PyTango.LatestDeviceImpl):
def read_board08(self, attr):
self.debug_stream("In read_board08()")
#----- PROTECTED REGION ID(WaterSensor.board08_read) ENABLED START -----#
if self._state == PyTango.DevState.UNKNOWN :
if self._state == PyTango.DevState.UNKNOWN or not self.board_ok[8] :
attr.set_quality(PyTango.AttrQuality.ATTR_INVALID, True)
else:
attr.set_value(self.boards[8])
......@@ -225,7 +225,7 @@ class WaterSensor (PyTango.LatestDeviceImpl):
def read_board09(self, attr):
self.debug_stream("In read_board09()")
#----- PROTECTED REGION ID(WaterSensor.board09_read) ENABLED START -----#
if self._state == PyTango.DevState.UNKNOWN :
if self._state == PyTango.DevState.UNKNOWN or not self.board_ok[9] :
attr.set_quality(PyTango.AttrQuality.ATTR_INVALID, True)
else:
attr.set_value(self.boards[9])
......@@ -235,7 +235,7 @@ class WaterSensor (PyTango.LatestDeviceImpl):
def read_board10(self, attr):
self.debug_stream("In read_board10()")
#----- PROTECTED REGION ID(WaterSensor.board10_read) ENABLED START -----#
if self._state == PyTango.DevState.UNKNOWN :
if self._state == PyTango.DevState.UNKNOWN or not self.board_ok[10] :
attr.set_quality(PyTango.AttrQuality.ATTR_INVALID, True)
else:
attr.set_value(self.boards[10])
......@@ -245,7 +245,7 @@ class WaterSensor (PyTango.LatestDeviceImpl):
def read_board11(self, attr):
self.debug_stream("In read_board11()")
#----- PROTECTED REGION ID(WaterSensor.board11_read) ENABLED START -----#
if self._state == PyTango.DevState.UNKNOWN :
if self._state == PyTango.DevState.UNKNOWN or not self.board_ok[11] :
attr.set_quality(PyTango.AttrQuality.ATTR_INVALID, True)
else:
attr.set_value(self.boards[11])
......
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