Commit f098fd909120ec182a7c78073fe90b731fc5fb42
1 parent
bcf29d0f
Exists in
dev
bugfix client et test Gemini (et ajout 2 scripts pour run facile)
2 nouveaux scripts shell: - GEMINI_test.sh - GEMINI_run_client.sh
Showing
8 changed files
with
40 additions
and
27 deletions
Show diff stats
test_gemini.sh renamed to GEMINI_test.sh
src/core/pyros_django/agent/AgentDeviceGemini.py
... | ... | @@ -151,8 +151,12 @@ class AgentDeviceGemini(AgentDevice): |
151 | 151 | dev_time = str(res) |
152 | 152 | time.sleep(1) |
153 | 153 | |
154 | - #cmd="get radec" | |
154 | + # For a dcc command, both methods work: | |
155 | + # - Guess wich dcc can exec this command | |
155 | 156 | cmd="get_radec" |
157 | + # OR | |
158 | + # - I tell you explicitely which one it is : "Mount" | |
159 | + cmd="Mount.get_radec" | |
156 | 160 | res = self._device_ctrl.exec_cmd(cmd) |
157 | 161 | self.printd("result is", str(res)) |
158 | 162 | if res.ok: print("OK") | ... | ... |
src/core/pyros_django/agent/AgentMultiRequester.py
src/device_controller/abstract_component/device_controller.py
... | ... | @@ -11,6 +11,7 @@ To be used as a base class (interface) for any concrete socket client telescope |
11 | 11 | import copy |
12 | 12 | import functools |
13 | 13 | import logging |
14 | +import pprint | |
14 | 15 | import socket |
15 | 16 | import sys |
16 | 17 | import threading |
... | ... | @@ -660,14 +661,25 @@ class DeviceController(): |
660 | 661 | def has_native_cmd_for_generic(self, generic_cmd:DeviceCommand): |
661 | 662 | return self._my_cmds.get_native_infos_for_generic_cmd(generic_cmd.name) not in [None, []] |
662 | 663 | |
663 | - # check if generic cmd exists (in dictionary) | |
664 | + # check if generic cmd exists | |
664 | 665 | def is_valid_generic_cmd(self, cmd:DeviceCommand): |
665 | 666 | #print("_my_cmds", self._my_cmds) |
667 | + # 1) If a DCC given, return search result in this DCC commands | |
668 | + if cmd.devtype: return self.get_dc_component_for_type(cmd.devtype).has_generic_command(cmd) | |
669 | + # 2) Search in my general commands | |
670 | + if self.has_generic_command(cmd): return True | |
671 | + # 3) Search in all my DCCs | |
672 | + for dcc in self._my_dc_components: | |
673 | + if dcc.has_generic_command(cmd): return True | |
674 | + # 4) not found | |
675 | + return False | |
676 | + ''' | |
666 | 677 | ##if not cmd.devtype: return self._my_cmds.get(cmd.name) is not None |
667 | 678 | if not cmd.devtype: return self.has_generic_command(cmd) |
668 | 679 | if not self.has_dc_component_for_type(cmd.devtype): return False |
669 | 680 | ##return self.get_dc_component_for_type(cmd.devtype)._my_cmds.get(cmd.name) is not None |
670 | 681 | return self.get_dc_component_for_type(cmd.devtype).has_generic_command(cmd) |
682 | + ''' | |
671 | 683 | |
672 | 684 | # check if generic cmd exists and is implemented as a native cmd (in dictionary) |
673 | 685 | def is_implemented_generic_cmd(self, cmd:DeviceCommand): |
... | ... | @@ -728,12 +740,12 @@ class DeviceController(): |
728 | 740 | # GENERIC command (pyros grammar) |
729 | 741 | #if generic_cmd is not False: |
730 | 742 | if cmd.is_generic(): |
731 | - if not self.is_valid_generic_cmd(cmd): raise UnknownGenericCmdException(cmd.name) | |
732 | 743 | print("GENERIC COMMAND") |
744 | + if not self.is_valid_generic_cmd(cmd): raise UnknownGenericCmdException(cmd.name) | |
733 | 745 | #return self.exec_generic_cmd(generic_cmd, args) |
734 | 746 | try: |
735 | 747 | res = self.exec_generic_cmd(cmd.name, cmd.args, cmd.devtype) |
736 | - except (DCCNotFoundException, UnimplementedGenericCmdException) as e: | |
748 | + except (UnimplementedGenericCmdException, DCCNotFoundException) as e: | |
737 | 749 | print(f"EXCEPTION caught by {type(self).__name__} (from DC)", e) |
738 | 750 | raise |
739 | 751 | return res |
... | ... | @@ -884,7 +896,10 @@ class DeviceController(): |
884 | 896 | #log_d("\n\nGENERIC Command to send is "+generic_cmd) |
885 | 897 | print("\n\n(DC): GENERIC Command to execute is ", generic_cmd) |
886 | 898 | ##print("(DC): My ("+type(self).__name__+") commands are:", self._gen2nat_cmds) |
887 | - print("(DC): My ("+type(self).__name__+") commands are:", self._my_cmds.get()) | |
899 | + #print("(DC): My ("+type(self).__name__+") commands are:", self._my_cmds.get()) | |
900 | + #print("(DC): My ("+type(self).__name__+") commands are:", self._my_cmds.get()) | |
901 | + print("(DC): My ("+type(self).__name__+") commands are:") | |
902 | + pprint.pprint(self._my_cmds.get()) | |
888 | 903 | |
889 | 904 | dcc, native_cmd_infos = self.get_dcc_and_native_cmd_for_generic(generic_cmd) |
890 | 905 | print("native_cmd_infos", native_cmd_infos) | ... | ... |
src/device_controller/abstract_component/mount.py
... | ... | @@ -91,6 +91,7 @@ class DC_Mount(DeviceController): |
91 | 91 | 'set_ra': [], |
92 | 92 | 'get_dec': [], |
93 | 93 | 'set_dec': [], |
94 | + #'get_radec': [get_radec], | |
94 | 95 | 'get_radec': ['get_radec'], |
95 | 96 | 'set_radec': ['set_radec'], |
96 | 97 | |
... | ... | @@ -98,10 +99,10 @@ class DC_Mount(DeviceController): |
98 | 99 | 'set_longitude': [], |
99 | 100 | 'get_latitude': [], |
100 | 101 | 'set_latitude': [], |
101 | - | |
102 | + | |
102 | 103 | 'get_velocity': [], |
103 | 104 | 'set_velocity': [], |
104 | - | |
105 | + | |
105 | 106 | # DO commands: |
106 | 107 | ##'do_init': ['do_init'], |
107 | 108 | ##'do_park': [], | ... | ... |
src/device_controller/concrete_component/gemini/client_telescope_gemini_controller_run.py
... | ... | @@ -102,14 +102,14 @@ def main(): |
102 | 102 | # Do MANUAL mode execution |
103 | 103 | while True: |
104 | 104 | |
105 | - tele_ctrl.print_available_commands() | |
105 | + tele_ctrl.print_available_cmds() | |
106 | 106 | #req = input("\n(EXPERT MODE) REQUEST TO SERVER [ex: '6' (ACK), ':GD#' (Get Dec), ':GR#' (Get RA)'], (ENTER to quit): ").strip() |
107 | 107 | cmd = input("REQUEST TO SERVER (ENTER to quit): >>> ").strip() |
108 | 108 | if not cmd: break |
109 | 109 | |
110 | 110 | #cmd = DeviceCommand(cmd) |
111 | 111 | #res = tele_ctrl.execute_cmd(cmd.replace(' ', '_')) |
112 | - res = tele_ctrl.execute_cmd(cmd) | |
112 | + res = tele_ctrl.exec_cmd(cmd) | |
113 | 113 | print("result is", str(res)) |
114 | 114 | if res.ok: print("OK") |
115 | 115 | #print("result.txt is", res.txt) | ... | ... |
src/device_controller/concrete_component/gemini/gemini_controller.py
... | ... | @@ -223,19 +223,19 @@ class DC_Gemini(DeviceController): |
223 | 223 | # Possible answers: |
224 | 224 | # - B# while the initial startup message is being displayed (new in L4), |
225 | 225 | # - b# while waiting for the selection of the Startup Mode, |
226 | - # - S# during a Cold Start (new in L4), G# after completed startup | |
227 | - 'get_ack': [Protocol.COMMAND6, 'G', 'B','b','S'], | |
226 | + # - S# during a Cold Start (new in L4), | |
227 | + # - G# after completed startup | |
228 | + 'get_ack': [Protocol.COMMAND6, 'G', 'B','b','S'], | |
228 | 229 | |
229 | 230 | # General commands for the Gemini controller |
230 | 231 | 'get_date': ['GC', 'bidon'], |
231 | 232 | 'set_date': ['SC'], |
232 | 233 | 'get_time': ['GL'], |
233 | 234 | 'set_time': ['SL'], |
234 | - } | |
235 | + } | |
235 | 236 | MY_GEN2NAT_CMDS_MOUNT = { |
236 | 237 | |
237 | 238 | # GET & SET commands |
238 | - ##'get_ack': [Protocol.COMMAND6, 'G', 'B','b','S'], # B# while the initial startup message is being displayed (new in L4), b# while waiting for the selection of the Startup Mode, S# during a Cold Start (new in L4), G# after completed startup. | |
239 | 239 | |
240 | 240 | # RA-DEC (p109-110) |
241 | 241 | #:Sr<hh>:<mm>.<m># or :Sr<hh>:<mm>:<ss># |
... | ... | @@ -278,7 +278,7 @@ class DC_Gemini(DeviceController): |
278 | 278 | 'do_prec_refr': ['p3'], |
279 | 279 | |
280 | 280 | # for test only |
281 | - 'gem_only':[], | |
281 | + 'gem_only': [], | |
282 | 282 | |
283 | 283 | 'do_move': ['MS', '0', '1Object below horizon.', '2No object selected.', '3Manual Control.', '4Position unreachable.', '5Not aligned.', '6Outside Limits.' ], |
284 | 284 | 'do_movenorth': ['Mn'], |
... | ... | @@ -290,18 +290,6 @@ class DC_Gemini(DeviceController): |
290 | 290 | MY_GEN2NAT_CMDS = { |
291 | 291 | # My GENERAL commands |
292 | 292 | **MY_GEN2NAT_CMDS_GENERAL, |
293 | - ''' | |
294 | - 'get_ack': [Protocol.COMMAND6, 'G', 'B','b','S'], | |
295 | - # B# while the initial startup message is being displayed (new in L4), | |
296 | - # b# while waiting for the selection of the Startup Mode, | |
297 | - # S# during a Cold Start (new in L4), G# after completed startup. | |
298 | - | |
299 | - # General commands for the Gemini controller | |
300 | - 'get_date': ['GC'], | |
301 | - 'set_date': ['SC'], | |
302 | - 'get_time': ['GL'], | |
303 | - 'set_time': ['SL'], | |
304 | - ''' | |
305 | 293 | |
306 | 294 | # SPECIFIC commands for my DCCs |
307 | 295 | 'DC_Mount' : MY_GEN2NAT_CMDS_MOUNT | ... | ... |