diff --git a/src/core/pyros_django/agent/AgentDeviceSBIG.py b/src/core/pyros_django/agent/AgentDeviceSBIG.py index 328f77e..ee8ae11 100755 --- a/src/core/pyros_django/agent/AgentDeviceSBIG.py +++ b/src/core/pyros_django/agent/AgentDeviceSBIG.py @@ -38,7 +38,7 @@ class AgentDeviceSBIG(AgentDevice): #WITH_SIMULATOR = True # - How many seconds should I be running ? #TEST_MAX_DURATION_SEC = None - TEST_MAX_DURATION_SEC = 70 + TEST_MAX_DURATION_SEC = 110 # - Who should I send commands to ? #TEST_COMMANDS_DEST = "myself" ##TEST_COMMANDS_DEST = "AgentB" diff --git a/src/core/pyros_django/agent/AgentMultiRequester.py b/src/core/pyros_django/agent/AgentMultiRequester.py index ca926c2..78acf17 100755 --- a/src/core/pyros_django/agent/AgentMultiRequester.py +++ b/src/core/pyros_django/agent/AgentMultiRequester.py @@ -21,7 +21,7 @@ class AgentMultiRequester(Agent): # Run the assertion tests at the end TEST_WITH_FINAL_TEST = True #TEST_MAX_DURATION_SEC = None - TEST_MAX_DURATION_SEC = 75 + TEST_MAX_DURATION_SEC = 120 # Who should I send commands to ? #TEST_COMMANDS_DEST = "myself" #TEST_COMMANDS_DEST = "AgentDeviceTelescopeGemini" @@ -31,8 +31,8 @@ class AgentMultiRequester(Agent): # Ask receiver to delete all its previous commands 'ad_tele do_flush_commands', 'ad_filtersel do_flush_commands', - ##'ad_shutter:do_flush_commands', - ##'ad_sensor:do_flush_commands', + 'ad_shutter do_flush_commands', + 'ad_sensor do_flush_commands', #'ad_tele:go_active', 'ad_tele set_state active', @@ -51,8 +51,8 @@ class AgentMultiRequester(Agent): 'ad_tele do_init', 'ad_filtersel do_init', - ##'ad_shutter:do_init', - ##'ad_sensor:do_init', + 'ad_shutter do_init', + 'ad_sensor do_init', 'ad_tele do_goto_radec 15 20', 'ad_filtersel do_goto 3', @@ -66,8 +66,8 @@ class AgentMultiRequester(Agent): # Now stop all my device agent clients: 'ad_tele do_exit', 'ad_filtersel do_exit', - ##'ad_shutter:do_exit', - ##'ad_sensor:do_exit', + 'ad_shutter do_exit', + 'ad_sensor do_exit', ] TEST_COMMANDS_LIST_SBIG_ONLY = [ @@ -184,7 +184,7 @@ class AgentMultiRequester(Agent): #'ad_tele': 'AgentDeviceTelescopeGemini.Telescope', self._my_client_agents = { 'ad_tele': 'AgentDeviceTelescopeGemini', - 'ad_filtersel': 'AgentDeviceSBIG.FilterSelector', + 'ad_filtersel': 'AgentDeviceSBIG.FilterSelector', 'ad_shutter': 'AgentDeviceSBIG.DetectorShutter', 'ad_sensor': 'AgentDeviceSBIG.DetectorSensor', } diff --git a/src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu b/src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu index 022c468..158d585 100755 --- a/src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu +++ b/src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu @@ -63,14 +63,16 @@ AgentMajordome -d-> AgentDeviceSensor1 : sends cmd to AgentMajordome -d-> AgentDeviceTelescope1 : sends cmd to AgentMajordome -d-> AgentDeviceShutter2 : sends cmd to +/' SBIG '/ class AgentDeviceSBIG_CXZ347 <> #lightgreen AgentDeviceSBIG_CXZ347 -u-|> AgentDevice - AgentDeviceFilterSelector1 --> AgentDeviceSBIG_CXZ347 :alias of AgentDeviceShutter1 --> AgentDeviceSBIG_CXZ347 :alias of AgentDeviceSensor1 --> AgentDeviceSBIG_CXZ347 :alias of + +/' Gemini '/ class AgentDeviceTelescopeGemini_A1CZ3 #lightblue -AgentDeviceTelescopeGemini_A1CZ3 -u--> AgentDevice +AgentDeviceTelescopeGemini_A1CZ3 -u--|> AgentDevice AgentDeviceTelescope1 --> AgentDeviceTelescopeGemini_A1CZ3 :alias of @@ -115,6 +117,9 @@ DeviceControllerTelescope --|> DeviceControllerAbstract /' Channels '/ +class ClientSerial #lightred +class ClientSocket #lightred +class ClientUSB #lightred ClientChannel <|-- ClientSerial ClientChannel <|-- ClientSocket ClientChannel <|-- ClientUSB diff --git a/src/device_controller/concrete_component/sbig/sbig_controller.py b/src/device_controller/concrete_component/sbig/sbig_controller.py index d7a20b1..d02810f 100755 --- a/src/device_controller/concrete_component/sbig/sbig_controller.py +++ b/src/device_controller/concrete_component/sbig/sbig_controller.py @@ -22,8 +22,8 @@ from device_controller.abstract_component.filter_selector import DeviceControlle from device_controller.abstract_component.detector_shutter import DeviceControllerDetectorShutter ''' from device_controller.concrete_component.sbig.sbig_filter_selector_controller import DeviceControllerFilterSelectorSBIG -#from device_controller.concrete_component.sbig.sbig_detector_sensor_controller import DeviceControllerDetectorSensorSBIG -#from device_controller.concrete_component.sbig.sbig_detector_shutter_controller import DeviceControllerDetectorShutterSBIG +from device_controller.concrete_component.sbig.sbig_detector_sensor_controller import DeviceControllerDetectorSensorSBIG +from device_controller.concrete_component.sbig.sbig_detector_shutter_controller import DeviceControllerDetectorShutterSBIG #from src.client.socket_client_telescope_abstract import Position, UnknownCommandException, TimeoutException, SocketClientTelescopeAbstract ##from src_socket.client.socket_client_telescope_abstract import * @@ -127,8 +127,8 @@ class DeviceControllerSBIG(DeviceControllerAbstract): #my_dcc_detector_shutter = # @override superclass empty list self._my_dc_components = [ - #DeviceControllerDetectorSensorSBIG(device_host, device_port, self.my_channel, 1024, DEBUG), - #DeviceControllerDetectorShutterSBIG(device_host, device_port, self.my_channel, 1024, DEBUG), + DeviceControllerDetectorSensorSBIG(device_host, device_port, self.my_channel, 1024, DEBUG), + DeviceControllerDetectorShutterSBIG(device_host, device_port, self.my_channel, 1024, DEBUG), DeviceControllerFilterSelectorSBIG(device_host, device_port, self.my_channel, 1024, DEBUG) ] diff --git a/src/device_controller/concrete_component/sbig/sbig_detector_sensor_controller.py b/src/device_controller/concrete_component/sbig/sbig_detector_sensor_controller.py new file mode 100755 index 0000000..4c5896a --- /dev/null +++ b/src/device_controller/concrete_component/sbig/sbig_detector_sensor_controller.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python3 + +""" Client Detector Sensor implementation +To be used as a concrete class to system control such a device +""" + +# Standard library imports +#import socket +#import logging +import sys +import time + +# Third party imports +# None + +# Local application imports +sys.path.append('../../..') +from device_controller.abstract_component.detector_sensor import DeviceControllerDetectorSensor +# TODO: AVIRER +from device_controller.abstract_component.base import UnknownCommandException + +# Default timeouts +TIMEOUT_SEND = 10 +TIMEOUT_RECEIVE = 10 + + +# TODO: AVIRER +TERMINATOR = '\x00' +COMMAND5 = '050000' +COMMAND6 = '\x00\x06\x00' +COMMAND6_SIMPLE = '6' + + + +class DeviceControllerDetectorSensorSBIG(DeviceControllerDetectorSensor): + + # TODO: AVIRER + request_num = 0 + request_num_nb_digits = 4 + request_num_format = '{:0'+str(request_num_nb_digits)+'d}' + STAMP_FILLER = '0' * (8 - request_num_nb_digits) + + + ''' Commands dictionary + 'generic-command-name': ['native-command-name', 'awaited_result_if_ok', 'other-awaited-results if not ok...], + ''' + # @overwrite + _cmd_device_concrete = { + # GET @ SET commands + + # RA-DEC (p109-110) + #:Sr:.# or :Sr::# + #Sets the object's Right Ascension and the object status to "Not Selected". The :Sd# command has to follow to complete the selection. The subsequent use of the :ON...# command is recommended + #:Sd{+-}
{*°}# or :Sd{+- }
{*°:}: + #Sets the object's declination. It is important that the :Sr# command has been send prior. Internal calculations are done that may take up to 0.5 seconds. If the coordinate selection is valid the object status is set to "Selected" + #'RADEC': [('GR','GD'), ''], + #'ra': ['GR', None, 'Sr', None, 'commentaire'], + # get_radec and set_radec are already defined in abstract class + + 'get_timezone': ['GG'], + 'set_timezone': ['SG', '1'], + + # ALT-AZ (p?) + #"ALT-AZ": [('GA','GZ'), ''], + + # LONG-LAT + #"LONGLAT": [('Gg','Gt'), ''], + + "get_hangle": ['GH'], + + #"get_maxvel": ['Gv'], + + 'get_date': ['GC'], + 'set_date': ['SC'], + 'get_time': ['GL'], + 'set_time': ['SL'], + + # DO commands + # defined in abstract class: + 'do_init': ['GC'], + 'do_goto': ['GL'], + 'do_park': ['hP'], + 'do_stop': ['Q'], + } + + + # @overwrite + def __init__(self, device_host:str="localhost", device_port:int=11110, channel=None, buffer_size=1024, DEBUG=False): + super().__init__(device_host, device_port, channel, 1024, DEBUG) + + # TODO: AVIRER + # @overwrite + def formated_cmd(self, cmd:str, values_to_set:str=None)->str: + if values_to_set != None: + for value_to_set in values_to_set: + cmd += value_to_set + if cmd not in (COMMAND6, COMMAND5): + cmd += '#' + if cmd not in ('bC#','bW#','bR#'): + cmd=':'+cmd + return cmd + + # TODO: AVIRER + def encapsulate_data_to_send(self, command:str): + if command == COMMAND6_SIMPLE: command = COMMAND6 + if command not in (COMMAND6, COMMAND5): + if len(command) < 3: raise UnknownCommandException() + if not (command[-1]=='#'): raise UnknownCommandException() + if not (command[0]==':') and command not in ('bC#','bW#','bR#'): raise UnknownCommandException() + self.request_num += 1 + request_num_str = self.request_num_format.format(self.request_num) + self.last_stamp = request_num_str + self.STAMP_FILLER + data_encapsulated = self.last_stamp + command + TERMINATOR + return data_encapsulated + + +if __name__ == "__main__": + import doctest + doctest.testmod() + sys.exit() diff --git a/src/device_controller/concrete_component/sbig/sbig_detector_shutter_controller.py b/src/device_controller/concrete_component/sbig/sbig_detector_shutter_controller.py new file mode 100755 index 0000000..59910e2 --- /dev/null +++ b/src/device_controller/concrete_component/sbig/sbig_detector_shutter_controller.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python3 + +""" Client Detector Shutter implementation +To be used as a concrete class to system control such a device +""" + +# Standard library imports +#import socket +#import logging +import sys +import time + +# Third party imports +# None + +# Local application imports +sys.path.append('../../..') +from device_controller.abstract_component.detector_shutter import DeviceControllerDetectorShutter +# TODO: AVIRER +from device_controller.abstract_component.base import UnknownCommandException + +# Default timeouts +TIMEOUT_SEND = 10 +TIMEOUT_RECEIVE = 10 + + +# TODO: AVIRER +TERMINATOR = '\x00' +COMMAND5 = '050000' +COMMAND6 = '\x00\x06\x00' +COMMAND6_SIMPLE = '6' + + + +class DeviceControllerDetectorShutterSBIG(DeviceControllerDetectorShutter): + + # TODO: AVIRER + request_num = 0 + request_num_nb_digits = 4 + request_num_format = '{:0'+str(request_num_nb_digits)+'d}' + STAMP_FILLER = '0' * (8 - request_num_nb_digits) + + + ''' Commands dictionary + 'generic-command-name': ['native-command-name', 'awaited_result_if_ok', 'other-awaited-results if not ok...], + ''' + # @overwrite + _cmd_device_concrete = { + # GET @ SET commands + + # RA-DEC (p109-110) + #:Sr:.# or :Sr::# + #Sets the object's Right Ascension and the object status to "Not Selected". The :Sd# command has to follow to complete the selection. The subsequent use of the :ON...# command is recommended + #:Sd{+-}
{*°}# or :Sd{+- }
{*°:}: + #Sets the object's declination. It is important that the :Sr# command has been send prior. Internal calculations are done that may take up to 0.5 seconds. If the coordinate selection is valid the object status is set to "Selected" + #'RADEC': [('GR','GD'), ''], + #'ra': ['GR', None, 'Sr', None, 'commentaire'], + # get_radec and set_radec are already defined in abstract class + + 'get_timezone': ['GG'], + 'set_timezone': ['SG', '1'], + + # ALT-AZ (p?) + #"ALT-AZ": [('GA','GZ'), ''], + + # LONG-LAT + #"LONGLAT": [('Gg','Gt'), ''], + + "get_hangle": ['GH'], + + #"get_maxvel": ['Gv'], + + 'get_date': ['GC'], + 'set_date': ['SC'], + 'get_time': ['GL'], + 'set_time': ['SL'], + + # DO commands + # defined in abstract class: + 'do_init': ['GC'], + 'do_goto': ['GL'], + 'do_park': ['hP'], + 'do_stop': ['Q'], + } + + + # @overwrite + def __init__(self, device_host:str="localhost", device_port:int=11110, channel=None, buffer_size=1024, DEBUG=False): + super().__init__(device_host, device_port, channel, 1024, DEBUG) + + # TODO: AVIRER + # @overwrite + def formated_cmd(self, cmd:str, values_to_set:str=None)->str: + if values_to_set != None: + for value_to_set in values_to_set: + cmd += value_to_set + if cmd not in (COMMAND6, COMMAND5): + cmd += '#' + if cmd not in ('bC#','bW#','bR#'): + cmd=':'+cmd + return cmd + + # TODO: AVIRER + def encapsulate_data_to_send(self, command:str): + if command == COMMAND6_SIMPLE: command = COMMAND6 + if command not in (COMMAND6, COMMAND5): + if len(command) < 3: raise UnknownCommandException() + if not (command[-1]=='#'): raise UnknownCommandException() + if not (command[0]==':') and command not in ('bC#','bW#','bR#'): raise UnknownCommandException() + self.request_num += 1 + request_num_str = self.request_num_format.format(self.request_num) + self.last_stamp = request_num_str + self.STAMP_FILLER + data_encapsulated = self.last_stamp + command + TERMINATOR + return data_encapsulated + + +if __name__ == "__main__": + import doctest + doctest.testmod() + sys.exit() diff --git a/src/device_controller/concrete_component/sbig/sbig_filter_selector_controller.py b/src/device_controller/concrete_component/sbig/sbig_filter_selector_controller.py index ff48272..d539803 100755 --- a/src/device_controller/concrete_component/sbig/sbig_filter_selector_controller.py +++ b/src/device_controller/concrete_component/sbig/sbig_filter_selector_controller.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 -""" Client FilterSelector implementation -To be used as a concrete class to system control a filter selector +""" Client Filter Selector implementation +To be used as a concrete class to system control such a device """ # Standard library imports @@ -112,12 +112,9 @@ class DeviceControllerFilterSelectorSBIG(DeviceControllerFilterSelector): self.last_stamp = request_num_str + self.STAMP_FILLER data_encapsulated = self.last_stamp + command + TERMINATOR return data_encapsulated - - if __name__ == "__main__": - import doctest doctest.testmod() - exit() + sys.exit() -- libgit2 0.21.2