Commit 9beeb060d1338edef9287aae1c76eb325ca09254
1 parent
377b7053
Exists in
dev
Ajout des 3 composants SBIG
Showing
7 changed files
with
263 additions
and
21 deletions
Show diff stats
src/core/pyros_django/agent/AgentDeviceSBIG.py
... | ... | @@ -38,7 +38,7 @@ class AgentDeviceSBIG(AgentDevice): |
38 | 38 | #WITH_SIMULATOR = True |
39 | 39 | # - How many seconds should I be running ? |
40 | 40 | #TEST_MAX_DURATION_SEC = None |
41 | - TEST_MAX_DURATION_SEC = 70 | |
41 | + TEST_MAX_DURATION_SEC = 110 | |
42 | 42 | # - Who should I send commands to ? |
43 | 43 | #TEST_COMMANDS_DEST = "myself" |
44 | 44 | ##TEST_COMMANDS_DEST = "AgentB" | ... | ... |
src/core/pyros_django/agent/AgentMultiRequester.py
... | ... | @@ -21,7 +21,7 @@ class AgentMultiRequester(Agent): |
21 | 21 | # Run the assertion tests at the end |
22 | 22 | TEST_WITH_FINAL_TEST = True |
23 | 23 | #TEST_MAX_DURATION_SEC = None |
24 | - TEST_MAX_DURATION_SEC = 75 | |
24 | + TEST_MAX_DURATION_SEC = 120 | |
25 | 25 | # Who should I send commands to ? |
26 | 26 | #TEST_COMMANDS_DEST = "myself" |
27 | 27 | #TEST_COMMANDS_DEST = "AgentDeviceTelescopeGemini" |
... | ... | @@ -31,8 +31,8 @@ class AgentMultiRequester(Agent): |
31 | 31 | # Ask receiver to delete all its previous commands |
32 | 32 | 'ad_tele do_flush_commands', |
33 | 33 | 'ad_filtersel do_flush_commands', |
34 | - ##'ad_shutter:do_flush_commands', | |
35 | - ##'ad_sensor:do_flush_commands', | |
34 | + 'ad_shutter do_flush_commands', | |
35 | + 'ad_sensor do_flush_commands', | |
36 | 36 | |
37 | 37 | #'ad_tele:go_active', |
38 | 38 | 'ad_tele set_state active', |
... | ... | @@ -51,8 +51,8 @@ class AgentMultiRequester(Agent): |
51 | 51 | |
52 | 52 | 'ad_tele do_init', |
53 | 53 | 'ad_filtersel do_init', |
54 | - ##'ad_shutter:do_init', | |
55 | - ##'ad_sensor:do_init', | |
54 | + 'ad_shutter do_init', | |
55 | + 'ad_sensor do_init', | |
56 | 56 | |
57 | 57 | 'ad_tele do_goto_radec 15 20', |
58 | 58 | 'ad_filtersel do_goto 3', |
... | ... | @@ -66,8 +66,8 @@ class AgentMultiRequester(Agent): |
66 | 66 | # Now stop all my device agent clients: |
67 | 67 | 'ad_tele do_exit', |
68 | 68 | 'ad_filtersel do_exit', |
69 | - ##'ad_shutter:do_exit', | |
70 | - ##'ad_sensor:do_exit', | |
69 | + 'ad_shutter do_exit', | |
70 | + 'ad_sensor do_exit', | |
71 | 71 | ] |
72 | 72 | |
73 | 73 | TEST_COMMANDS_LIST_SBIG_ONLY = [ |
... | ... | @@ -184,7 +184,7 @@ class AgentMultiRequester(Agent): |
184 | 184 | #'ad_tele': 'AgentDeviceTelescopeGemini.Telescope', |
185 | 185 | self._my_client_agents = { |
186 | 186 | 'ad_tele': 'AgentDeviceTelescopeGemini', |
187 | - 'ad_filtersel': 'AgentDeviceSBIG.FilterSelector', | |
187 | + 'ad_filtersel': 'AgentDeviceSBIG.FilterSelector', | |
188 | 188 | 'ad_shutter': 'AgentDeviceSBIG.DetectorShutter', |
189 | 189 | 'ad_sensor': 'AgentDeviceSBIG.DetectorSensor', |
190 | 190 | } | ... | ... |
src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu
... | ... | @@ -63,14 +63,16 @@ AgentMajordome -d-> AgentDeviceSensor1 : sends cmd to |
63 | 63 | AgentMajordome -d-> AgentDeviceTelescope1 : sends cmd to |
64 | 64 | AgentMajordome -d-> AgentDeviceShutter2 : sends cmd to |
65 | 65 | |
66 | +/' SBIG '/ | |
66 | 67 | class AgentDeviceSBIG_CXZ347 <<Singleton>> #lightgreen |
67 | 68 | AgentDeviceSBIG_CXZ347 -u-|> AgentDevice |
68 | - | |
69 | 69 | AgentDeviceFilterSelector1 --> AgentDeviceSBIG_CXZ347 :alias of |
70 | 70 | AgentDeviceShutter1 --> AgentDeviceSBIG_CXZ347 :alias of |
71 | 71 | AgentDeviceSensor1 --> AgentDeviceSBIG_CXZ347 :alias of |
72 | + | |
73 | +/' Gemini '/ | |
72 | 74 | class AgentDeviceTelescopeGemini_A1CZ3 #lightblue |
73 | -AgentDeviceTelescopeGemini_A1CZ3 -u--> AgentDevice | |
75 | +AgentDeviceTelescopeGemini_A1CZ3 -u--|> AgentDevice | |
74 | 76 | AgentDeviceTelescope1 --> AgentDeviceTelescopeGemini_A1CZ3 :alias of |
75 | 77 | |
76 | 78 | |
... | ... | @@ -115,6 +117,9 @@ DeviceControllerTelescope --|> DeviceControllerAbstract |
115 | 117 | |
116 | 118 | |
117 | 119 | /' Channels '/ |
120 | +class ClientSerial #lightred | |
121 | +class ClientSocket #lightred | |
122 | +class ClientUSB #lightred | |
118 | 123 | ClientChannel <|-- ClientSerial |
119 | 124 | ClientChannel <|-- ClientSocket |
120 | 125 | ClientChannel <|-- ClientUSB | ... | ... |
src/device_controller/concrete_component/sbig/sbig_controller.py
... | ... | @@ -22,8 +22,8 @@ from device_controller.abstract_component.filter_selector import DeviceControlle |
22 | 22 | from device_controller.abstract_component.detector_shutter import DeviceControllerDetectorShutter |
23 | 23 | ''' |
24 | 24 | from device_controller.concrete_component.sbig.sbig_filter_selector_controller import DeviceControllerFilterSelectorSBIG |
25 | -#from device_controller.concrete_component.sbig.sbig_detector_sensor_controller import DeviceControllerDetectorSensorSBIG | |
26 | -#from device_controller.concrete_component.sbig.sbig_detector_shutter_controller import DeviceControllerDetectorShutterSBIG | |
25 | +from device_controller.concrete_component.sbig.sbig_detector_sensor_controller import DeviceControllerDetectorSensorSBIG | |
26 | +from device_controller.concrete_component.sbig.sbig_detector_shutter_controller import DeviceControllerDetectorShutterSBIG | |
27 | 27 | |
28 | 28 | #from src.client.socket_client_telescope_abstract import Position, UnknownCommandException, TimeoutException, SocketClientTelescopeAbstract |
29 | 29 | ##from src_socket.client.socket_client_telescope_abstract import * |
... | ... | @@ -127,8 +127,8 @@ class DeviceControllerSBIG(DeviceControllerAbstract): |
127 | 127 | #my_dcc_detector_shutter = |
128 | 128 | # @override superclass empty list |
129 | 129 | self._my_dc_components = [ |
130 | - #DeviceControllerDetectorSensorSBIG(device_host, device_port, self.my_channel, 1024, DEBUG), | |
131 | - #DeviceControllerDetectorShutterSBIG(device_host, device_port, self.my_channel, 1024, DEBUG), | |
130 | + DeviceControllerDetectorSensorSBIG(device_host, device_port, self.my_channel, 1024, DEBUG), | |
131 | + DeviceControllerDetectorShutterSBIG(device_host, device_port, self.my_channel, 1024, DEBUG), | |
132 | 132 | DeviceControllerFilterSelectorSBIG(device_host, device_port, self.my_channel, 1024, DEBUG) |
133 | 133 | ] |
134 | 134 | ... | ... |
src/device_controller/concrete_component/sbig/sbig_detector_sensor_controller.py
0 โ 100755
... | ... | @@ -0,0 +1,120 @@ |
1 | +#!/usr/bin/env python3 | |
2 | + | |
3 | +""" Client Detector Sensor implementation | |
4 | +To be used as a concrete class to system control such a device | |
5 | +""" | |
6 | + | |
7 | +# Standard library imports | |
8 | +#import socket | |
9 | +#import logging | |
10 | +import sys | |
11 | +import time | |
12 | + | |
13 | +# Third party imports | |
14 | +# None | |
15 | + | |
16 | +# Local application imports | |
17 | +sys.path.append('../../..') | |
18 | +from device_controller.abstract_component.detector_sensor import DeviceControllerDetectorSensor | |
19 | +# TODO: AVIRER | |
20 | +from device_controller.abstract_component.base import UnknownCommandException | |
21 | + | |
22 | +# Default timeouts | |
23 | +TIMEOUT_SEND = 10 | |
24 | +TIMEOUT_RECEIVE = 10 | |
25 | + | |
26 | + | |
27 | +# TODO: AVIRER | |
28 | +TERMINATOR = '\x00' | |
29 | +COMMAND5 = '050000' | |
30 | +COMMAND6 = '\x00\x06\x00' | |
31 | +COMMAND6_SIMPLE = '6' | |
32 | + | |
33 | + | |
34 | + | |
35 | +class DeviceControllerDetectorSensorSBIG(DeviceControllerDetectorSensor): | |
36 | + | |
37 | + # TODO: AVIRER | |
38 | + request_num = 0 | |
39 | + request_num_nb_digits = 4 | |
40 | + request_num_format = '{:0'+str(request_num_nb_digits)+'d}' | |
41 | + STAMP_FILLER = '0' * (8 - request_num_nb_digits) | |
42 | + | |
43 | + | |
44 | + ''' Commands dictionary | |
45 | + 'generic-command-name': ['native-command-name', 'awaited_result_if_ok', 'other-awaited-results if not ok...], | |
46 | + ''' | |
47 | + # @overwrite | |
48 | + _cmd_device_concrete = { | |
49 | + # GET @ SET commands | |
50 | + | |
51 | + # RA-DEC (p109-110) | |
52 | + #:Sr<hh>:<mm>.<m># or :Sr<hh>:<mm>:<ss># | |
53 | + #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 | |
54 | + #:Sd{+-}<dd>{*ยฐ}<mm># or :Sd{+- }<dd>{*ยฐ:}<mm>:<ss> | |
55 | + #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" | |
56 | + #'RADEC': [('GR','GD'), ''], | |
57 | + #'ra': ['GR', None, 'Sr', None, 'commentaire'], | |
58 | + # get_radec and set_radec are already defined in abstract class | |
59 | + | |
60 | + 'get_timezone': ['GG'], | |
61 | + 'set_timezone': ['SG', '1'], | |
62 | + | |
63 | + # ALT-AZ (p?) | |
64 | + #"ALT-AZ": [('GA','GZ'), ''], | |
65 | + | |
66 | + # LONG-LAT | |
67 | + #"LONGLAT": [('Gg','Gt'), ''], | |
68 | + | |
69 | + "get_hangle": ['GH'], | |
70 | + | |
71 | + #"get_maxvel": ['Gv'], | |
72 | + | |
73 | + 'get_date': ['GC'], | |
74 | + 'set_date': ['SC'], | |
75 | + 'get_time': ['GL'], | |
76 | + 'set_time': ['SL'], | |
77 | + | |
78 | + # DO commands | |
79 | + # defined in abstract class: | |
80 | + 'do_init': ['GC'], | |
81 | + 'do_goto': ['GL'], | |
82 | + 'do_park': ['hP'], | |
83 | + 'do_stop': ['Q'], | |
84 | + } | |
85 | + | |
86 | + | |
87 | + # @overwrite | |
88 | + def __init__(self, device_host:str="localhost", device_port:int=11110, channel=None, buffer_size=1024, DEBUG=False): | |
89 | + super().__init__(device_host, device_port, channel, 1024, DEBUG) | |
90 | + | |
91 | + # TODO: AVIRER | |
92 | + # @overwrite | |
93 | + def formated_cmd(self, cmd:str, values_to_set:str=None)->str: | |
94 | + if values_to_set != None: | |
95 | + for value_to_set in values_to_set: | |
96 | + cmd += value_to_set | |
97 | + if cmd not in (COMMAND6, COMMAND5): | |
98 | + cmd += '#' | |
99 | + if cmd not in ('bC#','bW#','bR#'): | |
100 | + cmd=':'+cmd | |
101 | + return cmd | |
102 | + | |
103 | + # TODO: AVIRER | |
104 | + def encapsulate_data_to_send(self, command:str): | |
105 | + if command == COMMAND6_SIMPLE: command = COMMAND6 | |
106 | + if command not in (COMMAND6, COMMAND5): | |
107 | + if len(command) < 3: raise UnknownCommandException() | |
108 | + if not (command[-1]=='#'): raise UnknownCommandException() | |
109 | + if not (command[0]==':') and command not in ('bC#','bW#','bR#'): raise UnknownCommandException() | |
110 | + self.request_num += 1 | |
111 | + request_num_str = self.request_num_format.format(self.request_num) | |
112 | + self.last_stamp = request_num_str + self.STAMP_FILLER | |
113 | + data_encapsulated = self.last_stamp + command + TERMINATOR | |
114 | + return data_encapsulated | |
115 | + | |
116 | + | |
117 | +if __name__ == "__main__": | |
118 | + import doctest | |
119 | + doctest.testmod() | |
120 | + sys.exit() | ... | ... |
src/device_controller/concrete_component/sbig/sbig_detector_shutter_controller.py
0 โ 100755
... | ... | @@ -0,0 +1,120 @@ |
1 | +#!/usr/bin/env python3 | |
2 | + | |
3 | +""" Client Detector Shutter implementation | |
4 | +To be used as a concrete class to system control such a device | |
5 | +""" | |
6 | + | |
7 | +# Standard library imports | |
8 | +#import socket | |
9 | +#import logging | |
10 | +import sys | |
11 | +import time | |
12 | + | |
13 | +# Third party imports | |
14 | +# None | |
15 | + | |
16 | +# Local application imports | |
17 | +sys.path.append('../../..') | |
18 | +from device_controller.abstract_component.detector_shutter import DeviceControllerDetectorShutter | |
19 | +# TODO: AVIRER | |
20 | +from device_controller.abstract_component.base import UnknownCommandException | |
21 | + | |
22 | +# Default timeouts | |
23 | +TIMEOUT_SEND = 10 | |
24 | +TIMEOUT_RECEIVE = 10 | |
25 | + | |
26 | + | |
27 | +# TODO: AVIRER | |
28 | +TERMINATOR = '\x00' | |
29 | +COMMAND5 = '050000' | |
30 | +COMMAND6 = '\x00\x06\x00' | |
31 | +COMMAND6_SIMPLE = '6' | |
32 | + | |
33 | + | |
34 | + | |
35 | +class DeviceControllerDetectorShutterSBIG(DeviceControllerDetectorShutter): | |
36 | + | |
37 | + # TODO: AVIRER | |
38 | + request_num = 0 | |
39 | + request_num_nb_digits = 4 | |
40 | + request_num_format = '{:0'+str(request_num_nb_digits)+'d}' | |
41 | + STAMP_FILLER = '0' * (8 - request_num_nb_digits) | |
42 | + | |
43 | + | |
44 | + ''' Commands dictionary | |
45 | + 'generic-command-name': ['native-command-name', 'awaited_result_if_ok', 'other-awaited-results if not ok...], | |
46 | + ''' | |
47 | + # @overwrite | |
48 | + _cmd_device_concrete = { | |
49 | + # GET @ SET commands | |
50 | + | |
51 | + # RA-DEC (p109-110) | |
52 | + #:Sr<hh>:<mm>.<m># or :Sr<hh>:<mm>:<ss># | |
53 | + #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 | |
54 | + #:Sd{+-}<dd>{*ยฐ}<mm># or :Sd{+- }<dd>{*ยฐ:}<mm>:<ss> | |
55 | + #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" | |
56 | + #'RADEC': [('GR','GD'), ''], | |
57 | + #'ra': ['GR', None, 'Sr', None, 'commentaire'], | |
58 | + # get_radec and set_radec are already defined in abstract class | |
59 | + | |
60 | + 'get_timezone': ['GG'], | |
61 | + 'set_timezone': ['SG', '1'], | |
62 | + | |
63 | + # ALT-AZ (p?) | |
64 | + #"ALT-AZ": [('GA','GZ'), ''], | |
65 | + | |
66 | + # LONG-LAT | |
67 | + #"LONGLAT": [('Gg','Gt'), ''], | |
68 | + | |
69 | + "get_hangle": ['GH'], | |
70 | + | |
71 | + #"get_maxvel": ['Gv'], | |
72 | + | |
73 | + 'get_date': ['GC'], | |
74 | + 'set_date': ['SC'], | |
75 | + 'get_time': ['GL'], | |
76 | + 'set_time': ['SL'], | |
77 | + | |
78 | + # DO commands | |
79 | + # defined in abstract class: | |
80 | + 'do_init': ['GC'], | |
81 | + 'do_goto': ['GL'], | |
82 | + 'do_park': ['hP'], | |
83 | + 'do_stop': ['Q'], | |
84 | + } | |
85 | + | |
86 | + | |
87 | + # @overwrite | |
88 | + def __init__(self, device_host:str="localhost", device_port:int=11110, channel=None, buffer_size=1024, DEBUG=False): | |
89 | + super().__init__(device_host, device_port, channel, 1024, DEBUG) | |
90 | + | |
91 | + # TODO: AVIRER | |
92 | + # @overwrite | |
93 | + def formated_cmd(self, cmd:str, values_to_set:str=None)->str: | |
94 | + if values_to_set != None: | |
95 | + for value_to_set in values_to_set: | |
96 | + cmd += value_to_set | |
97 | + if cmd not in (COMMAND6, COMMAND5): | |
98 | + cmd += '#' | |
99 | + if cmd not in ('bC#','bW#','bR#'): | |
100 | + cmd=':'+cmd | |
101 | + return cmd | |
102 | + | |
103 | + # TODO: AVIRER | |
104 | + def encapsulate_data_to_send(self, command:str): | |
105 | + if command == COMMAND6_SIMPLE: command = COMMAND6 | |
106 | + if command not in (COMMAND6, COMMAND5): | |
107 | + if len(command) < 3: raise UnknownCommandException() | |
108 | + if not (command[-1]=='#'): raise UnknownCommandException() | |
109 | + if not (command[0]==':') and command not in ('bC#','bW#','bR#'): raise UnknownCommandException() | |
110 | + self.request_num += 1 | |
111 | + request_num_str = self.request_num_format.format(self.request_num) | |
112 | + self.last_stamp = request_num_str + self.STAMP_FILLER | |
113 | + data_encapsulated = self.last_stamp + command + TERMINATOR | |
114 | + return data_encapsulated | |
115 | + | |
116 | + | |
117 | +if __name__ == "__main__": | |
118 | + import doctest | |
119 | + doctest.testmod() | |
120 | + sys.exit() | ... | ... |
src/device_controller/concrete_component/sbig/sbig_filter_selector_controller.py
1 | 1 | #!/usr/bin/env python3 |
2 | 2 | |
3 | -""" Client FilterSelector implementation | |
4 | -To be used as a concrete class to system control a filter selector | |
3 | +""" Client Filter Selector implementation | |
4 | +To be used as a concrete class to system control such a device | |
5 | 5 | """ |
6 | 6 | |
7 | 7 | # Standard library imports |
... | ... | @@ -112,12 +112,9 @@ class DeviceControllerFilterSelectorSBIG(DeviceControllerFilterSelector): |
112 | 112 | self.last_stamp = request_num_str + self.STAMP_FILLER |
113 | 113 | data_encapsulated = self.last_stamp + command + TERMINATOR |
114 | 114 | return data_encapsulated |
115 | - | |
116 | - | |
117 | 115 | |
118 | 116 | |
119 | 117 | if __name__ == "__main__": |
120 | - | |
121 | 118 | import doctest |
122 | 119 | doctest.testmod() |
123 | - exit() | |
120 | + sys.exit() | ... | ... |