From 60f21340c98e799cf5a0475de84c674703360e0b Mon Sep 17 00:00:00 2001 From: Etienne Pallier Date: Wed, 2 Oct 2019 17:48:11 +0200 Subject: [PATCH] diagramme général des classes assez complet (agent, device et channel) --- src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu | 16 ++++++++++++---- src/device_controller/abstract_component/base.py | 21 +++++++++++---------- src/device_controller/concrete_component/sbig/sbig_controller.py | 6 ++---- 3 files changed, 25 insertions(+), 18 deletions(-) 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 059fa5b..d0a499f 100755 --- a/src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu +++ b/src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu @@ -77,11 +77,12 @@ AgentDeviceSBIG_CXZ347 --> DeviceControllerSBIG :use object DeviceSimulatorSBIG #lightblue DeviceControllerSBIG o- DeviceSimulatorSBIG +DeviceControllerSBIG --|> DeviceControllerAbstract DeviceControllerSBIG <---> sbig_device :> channel/socket -DeviceControllerSBIG --|> DeviceControllerDetectorSensor -DeviceControllerSBIG --|> DeviceControllerDetectorShutter -DeviceControllerSBIG --|> DeviceControllerFilterSelector +DeviceControllerSBIG o-down- DeviceControllerDetectorSensor +DeviceControllerSBIG o-down- DeviceControllerDetectorShutter +DeviceControllerSBIG o-down- DeviceControllerFilterSelector DeviceControllerDetectorSensor --|> DeviceControllerAbstract DeviceControllerDetectorShutter --|> DeviceControllerAbstract @@ -92,9 +93,16 @@ class DeviceControllerTelescope #lightblue object DeviceControllerTelescopeGemini <> #lightblue AgentDeviceTelescopeGemini_A1CZ3 --> DeviceControllerTelescopeGemini :use object DeviceSimulatorTelescopeGemini #lightblue -DeviceControllerTelescopeGemini o-.left. DeviceSimulatorTelescopeGemini +DeviceControllerTelescopeGemini o-left- DeviceSimulatorTelescopeGemini DeviceControllerTelescopeGemini <---> gemini_device :> channel/socket DeviceControllerTelescopeGemini --|> DeviceControllerTelescope DeviceControllerTelescope --|> DeviceControllerAbstract + +/' Channels '/ +ClientChannel <|-- ClientSerial +ClientChannel <|-- ClientSocket +ClientChannel <|-- ClientUSB +DeviceControllerAbstract o-- ClientChannel + @enduml diff --git a/src/device_controller/abstract_component/base.py b/src/device_controller/abstract_component/base.py index 7b6da17..248797b 100755 --- a/src/device_controller/abstract_component/base.py +++ b/src/device_controller/abstract_component/base.py @@ -103,7 +103,8 @@ class DeviceCommand: return cmd_name.startswith('do_') or cmd_name.startswith('get_') or cmd_name.startswith('set_') def is_generic(self): - return DeviceCommand.is_generic_cmd_name(self.full_name) + return self.is_generic_cmd_name(self.full_name) + #return DeviceCommand.is_generic_cmd_name(self.full_name) #return self.name.startswith('do_') or self.name.startswith('get_') or self.name.startswith('set_') @property @@ -181,8 +182,8 @@ class DeviceControllerAbstract(): _device_host = "localhost" _device_port = None - # List of device component types (by default, None) - _my_dc_component_types = [] + # List of device controller (dc) components (by default, None) + _my_dc_components = [] # ClientChannel used by the device controller (to be set during __init__ via set_client_channel()) my_channel = None @@ -415,10 +416,10 @@ class DeviceControllerAbstract(): # ex1: None # ex2: "Telescope" (is in "AgentDeviceTelescopeGemini") if dc_component_type is None or dc_component_type in self.__class__.__name__ : return self - for dcct in self._my_dc_component_types: - #if dc_component_type in type(dcct): + for dcct in self._my_dc_components: print(dc_component_type, "in ?", dcct.__class__.__name__) - if dc_component_type in dcct.__class__.__name__: + #if dc_component_type in dcct.__class__.__name__: + if dc_component_type in type(dcct).__name__: return dcct raise Exception("NO DEVICE CONTROLLER COMPONENT FOUND FOR THIS TYPE: "+dc_component_type) @@ -543,10 +544,10 @@ class DeviceControllerAbstract(): :param value: only for a "set_" cmd ''' - # If generic_cmd is for a specific device component, pass it to this device component (instead of me) + # If generic_cmd is for a specific device component (dc), pass it to this dc (instead of me) print(dc_component_type, "is not in ???", None, self.__class__.__name__) - if dc_component_type: ####if dc_component_type and dc_component_type not in self.__class__.__name__ : + if dc_component_type: dc = self.get_dc_component_for_type(dc_component_type) print("*** EXECUTÉ PAR COMPONENT", dc) return dc.execute_generic_cmd(generic_cmd, values_to_set) @@ -587,9 +588,9 @@ class DeviceControllerAbstract(): native_res = self.execute_native_cmd(native_cmd) ok = True if not awaited_res_if_ok else (native_res == awaited_res_if_ok) return GenericResult(native_res, ok) - - + + ''' **************************** **************************** diff --git a/src/device_controller/concrete_component/sbig/sbig_controller.py b/src/device_controller/concrete_component/sbig/sbig_controller.py index f53cbe2..c03c9af 100755 --- a/src/device_controller/concrete_component/sbig/sbig_controller.py +++ b/src/device_controller/concrete_component/sbig/sbig_controller.py @@ -107,12 +107,10 @@ class DeviceControllerSBIG(DeviceControllerAbstract): myDC_detector_sensor = DeviceControllerDetectorSensor(device_host, device_port, "SOCKET-UDP", 1024, DEBUG) myDC_detector_shutter = DeviceControllerDetectorShutter(device_host, device_port, "SOCKET-UDP", 1024, DEBUG) myDC_filter_selector = DeviceControllerFilterSelector(device_host, device_port, "SOCKET-UDP", 1024, DEBUG) - self._my_device_component_types.append(myDC_detector_sensor) - self._my_device_component_types.append(myDC_detector_shutter) - self._my_device_component_types.append(myDC_filter_selector) + # @override superclass empty list + self._my_dc_components = [myDC_detector_sensor, myDC_detector_shutter, myDC_filter_selector] - # @overwrite def formated_cmd(self, cmd:str, values_to_set:str=None)->str: if values_to_set != None: -- libgit2 0.21.2