Commit 4783e5b56cb853095c4e4ccc45c1ea6d55783710
1 parent
0f78ae38
Exists in
dev
GROS RENOMMAGE des chemins des modules des devices controller...
(les paths vers les modules étaient trop longs et redondants)
Showing
38 changed files
with
363 additions
and
62 deletions
Show diff stats
.gitignore
HOWTO_TEST.txt
... | ... | @@ -20,7 +20,9 @@ |
20 | 20 | $ ./pyros.py -ts start agentDeviceTelescopeGemini,agentTelescopeRequester |
21 | 21 | - test with REAL telescope : |
22 | 22 | $ ./pyros.py -t start agentDeviceTelescopeGemini,agentTelescopeRequester |
23 | - | |
23 | +- (3) Test with agentMultiRequester (AgentMajordome like) sending commands to several device agents at once : the Gemini telescope device agent (or its simulator), and the SBIG device agent : | |
24 | + $ ./pyros.py -t start agentDeviceTelescopeGemini,agentMultiRequester | |
25 | + | |
24 | 26 | (C) Interactive testing: |
25 | 27 | $ ./pyros.py shell |
26 | 28 | ... | ... |
pyros.py
... | ... | @@ -35,8 +35,10 @@ AGENTS = { |
35 | 35 | "agentB" : "AgentB", |
36 | 36 | "agentM" : "AgentM", |
37 | 37 | #"agentDevice" : "AgentDevice", |
38 | - "agentDeviceTelescopeGemini" : "agentDeviceTelescopeGemini", | |
38 | + "agentDeviceTelescopeGemini" : "AgentDeviceTelescopeGemini", | |
39 | + "agentDeviceSBIG" : "AgentDeviceSBIG", | |
39 | 40 | "agentTelescopeRequester" : "AgentTelescopeRequester", |
41 | + "agentMultiRequester" : "AgentMultiRequester", | |
40 | 42 | "webserver" : "webserver", |
41 | 43 | "monitoring" : "monitoring", |
42 | 44 | "majordome" : "majordome", | ... | ... |
src/core/pyros_django/agent/Agent.py
... | ... | @@ -362,6 +362,8 @@ class Agent: |
362 | 362 | _current_specific_cmd = None |
363 | 363 | _current_specific_thread = None |
364 | 364 | |
365 | + # List of agents I will send commands to | |
366 | + _my_client_agents = {} | |
365 | 367 | |
366 | 368 | _iter_num = None |
367 | 369 | |
... | ... | @@ -401,6 +403,16 @@ class Agent: |
401 | 403 | if self.config.get_last_errno() != self.config.NO_ERROR: |
402 | 404 | raise Exception(f"Bad config file name '{config_filename}', error {str(self.config.get_last_errno())}: {str(self.config.get_last_errmsg())}") |
403 | 405 | |
406 | + #TODO: : à mettre dans la config | |
407 | + self._my_client_agents = { | |
408 | + ''' | |
409 | + 'AgentDeviceTelescope1': 'AgentDeviceTelescopeGemini', | |
410 | + 'AgentDeviceFilterSelector1': 'AgentDeviceSBIG', | |
411 | + 'AgentDeviceShutter1': 'AgentDeviceSBIG', | |
412 | + 'AgentDeviceSensor1': 'AgentDeviceSBIG', | |
413 | + ''' | |
414 | + } | |
415 | + | |
404 | 416 | ### self._agent_logs = AgentLogs.objects.create(name=self.name, message="Step __init__") |
405 | 417 | self.printdb("Step __init__") |
406 | 418 | |
... | ... | @@ -460,6 +472,17 @@ class Agent: |
460 | 472 | else: |
461 | 473 | time.sleep(nbsec) |
462 | 474 | |
475 | + def _get_real_agent_name_for_alias(self, agent_alias_name:str): | |
476 | + if not self._my_client_agents: return agent_alias_name | |
477 | + return self._my_client_agents[agent_alias_name] | |
478 | + | |
479 | + def build_cmd(self, recipient_agent_alias_name, cmd_name): | |
480 | + return Command( | |
481 | + sender=self.name, | |
482 | + recipient=self._get_real_agent_name_for_alias(recipient_agent_alias_name), | |
483 | + name=cmd_name | |
484 | + ) | |
485 | + | |
463 | 486 | def run(self, nb_iter:int=None, FOR_REAL:bool=True): |
464 | 487 | """ |
465 | 488 | FOR_REAL: set to False if you don't want Agent to send commands to devices but just print messages without really doing anything |
... | ... | @@ -568,7 +591,7 @@ class Agent: |
568 | 591 | self.print("-"*20, "MAIN LOOP ITERATION (END)", "-"*20) |
569 | 592 | #self.do_log(LOG_DEBUG, "Ending main loop iteration") |
570 | 593 | |
571 | - # (simulator only) Exit if max duration is reached | |
594 | + # (Test only) Exit if max duration is reached | |
572 | 595 | if self.TEST_MAX_DURATION_SEC and (time.time()-self.start_time > self.TEST_MAX_DURATION_SEC): |
573 | 596 | self.print("Exit because of max duration set to ", self.TEST_MAX_DURATION_SEC, "s") |
574 | 597 | self.kill_running_specific_cmd_if_exists(self.name) |
... | ... | @@ -831,7 +854,7 @@ class Agent: |
831 | 854 | #ex: send_command(“AgentX”,”GENERIC”,”EVAL”,“3+4”) |
832 | 855 | ex: send_command(“AgentX”,"EVAL”,“3+4”) |
833 | 856 | """ |
834 | - return Command.send_command(self.name, to_agent, cmd_name, cmd_args) | |
857 | + return Command.send_command(self.name, self._get_real_agent_name_for_alias(to_agent), cmd_name, cmd_args) | |
835 | 858 | |
836 | 859 | def get_next_valid_and_not_running_command(self)->Command: |
837 | 860 | """ |
... | ... | @@ -1144,11 +1167,13 @@ class Agent: |
1144 | 1167 | self.WITH_SIMULATOR=mode |
1145 | 1168 | |
1146 | 1169 | def simulator_get_next_command_to_send(self)->Command: |
1147 | - cmd_name = next(self.TEST_COMMANDS, None) | |
1170 | + cmd = next(self.TEST_COMMANDS, None) | |
1148 | 1171 | #return cmd_name |
1149 | - if cmd_name is None: return None | |
1150 | - recipient_agent = self.name if self.TEST_COMMANDS_DEST=="myself" else self.TEST_COMMANDS_DEST | |
1151 | - return Command(sender=self.name, recipient=recipient_agent, name=cmd_name) | |
1172 | + if cmd is None: return None | |
1173 | + agent_recipient,cmd_name = cmd.split(':') | |
1174 | + ##recipient_agent = self.name if self.TEST_COMMANDS_DEST=="myself" else self.TEST_COMMANDS_DEST | |
1175 | + #return Command(sender=self.name, recipient=recipient_agent, name=cmd_name) | |
1176 | + return self.build_cmd(agent_recipient, cmd_name) | |
1152 | 1177 | |
1153 | 1178 | """ |
1154 | 1179 | def simulator_send_next_command(self): | ... | ... |
src/core/pyros_django/agent/AgentDevice.py
... | ... | @@ -10,7 +10,9 @@ import time |
10 | 10 | sys.path.append("..") |
11 | 11 | from agent.Agent import Agent, build_agent |
12 | 12 | from common.models import AgentDeviceStatus, get_or_create_unique_row_from_model |
13 | + | |
13 | 14 | sys.path.append("../../..") |
15 | +from device_controller.abstract_component.base import DeviceControllerAbstract | |
14 | 16 | |
15 | 17 | ##log = L.setupLogger("AgentXTaskLogger", "AgentX") |
16 | 18 | |
... | ... | @@ -81,7 +83,7 @@ class AgentDevice(Agent): |
81 | 83 | # @override |
82 | 84 | #def __init__(self, name:str=None, config_filename=None, RUN_IN_THREAD=True, device_controller, host, port): |
83 | 85 | #def __init__(self, name:str, config_filename, RUN_IN_THREAD, device_controller, host, port, device_simulator): |
84 | - def __init__(self, config_filename, RUN_IN_THREAD, device_controller, host, port, device_simulator): | |
86 | + def __init__(self, config_filename, RUN_IN_THREAD, device_controller:DeviceControllerAbstract, host, port, device_simulator): | |
85 | 87 | ##if name is None: name = self.__class__.__name__ |
86 | 88 | #super().__init__(name, config_filename, RUN_IN_THREAD) |
87 | 89 | super().__init__(config_filename, RUN_IN_THREAD) |
... | ... | @@ -234,7 +236,7 @@ class AgentDevice(Agent): |
234 | 236 | |
235 | 237 | # Define your own command step(s) here |
236 | 238 | def cmd_step(self, step:int): |
237 | - cmd = self._current_specific_cmd | |
239 | + cmd = self._current_specific_cmd | |
238 | 240 | res = self._device_ctrl.execute_cmd(cmd.name) |
239 | 241 | cmd.set_result(str(res)) |
240 | 242 | print("result is", str(res)) | ... | ... |
src/core/pyros_django/agent/AgentDeviceSBIG.py
... | ... | @@ -11,11 +11,11 @@ sys.path.append("..") |
11 | 11 | from agent.AgentDevice import AgentDevice, build_agent |
12 | 12 | from common.models import AgentDeviceTelescopeStatus, get_or_create_unique_row_from_model |
13 | 13 | sys.path.append("../../..") |
14 | -##from devices_controller.devices_controller_concrete.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
14 | +##from device_controller.concrete_component.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
15 | 15 | |
16 | -from devices_controller.devices_controller_concrete.device_controller_Gemini.telescope_gemini_simulator import TelescopeGEMINISimulator | |
16 | +from device_controller.concrete_component.sbig.device_simulator_SBIG import DeviceSimulatorSBIG | |
17 | 17 | |
18 | -from devices_controller.devices_controller_concrete.device_controller_Gemini.telescope_controller_gemini import TelescopeControllerGEMINI | |
18 | +from device_controller.concrete_component.sbig.SBIG import DeviceControllerSBIG | |
19 | 19 | ##log = L.setupLogger("AgentXTaskLogger", "AgentX") |
20 | 20 | |
21 | 21 | |
... | ... | @@ -66,9 +66,9 @@ class AgentDeviceSBIG(AgentDevice): |
66 | 66 | super().__init__( |
67 | 67 | config_filename, |
68 | 68 | RUN_IN_THREAD, |
69 | - device_controller=TelescopeControllerGEMINI, | |
69 | + device_controller=DeviceControllerSBIG, | |
70 | 70 | host=self.HOST, port=self.PORT, |
71 | - device_simulator=TelescopeGEMINISimulator) | |
71 | + device_simulator=DeviceSimulatorSBIG) | |
72 | 72 | |
73 | 73 | # Initialize the device table status |
74 | 74 | # If table is empty, create a default 1st row |
... | ... | @@ -86,7 +86,7 @@ class AgentDeviceSBIG(AgentDevice): |
86 | 86 | # Port local AK 8085 = redirigé sur l’IP du tele 192.168.0.12 sur port 11110 |
87 | 87 | ##HOST, PORT = "82.64.28.71", 11110 |
88 | 88 | #HOST, PORT = "localhost", 11110 |
89 | - ##self.tele_ctrl = TelescopeControllerGEMINI(HOST, PORT, True) | |
89 | + ##self.tele_ctrl = TelescopeControllerGemini(HOST, PORT, True) | |
90 | 90 | ##self._log.print(f"init done for {name}") |
91 | 91 | |
92 | 92 | |
... | ... | @@ -101,7 +101,7 @@ class AgentDeviceSBIG(AgentDevice): |
101 | 101 | #HOST, PORT = "localhost", 11110 |
102 | 102 | #with get_SocketServer_UDP_TCP(HOST, PORT, "UDP") as myserver: |
103 | 103 | #with get_SocketServer_UDP_TCP(self.HOST, self.PORT, "UDP") as myserver: myserver.serve_forever() |
104 | - TelescopeGEMINISimulator.serve_forever(self.PORT) | |
104 | + TelescopeGeminiSimulator.serve_forever(self.PORT) | |
105 | 105 | ''' |
106 | 106 | myserver = get_SocketServer_UDP_TCP(self.HOST, self.PORT, "UDP") |
107 | 107 | myserver.serve_forever() |
... | ... | @@ -171,7 +171,7 @@ if __name__ == "__main__": |
171 | 171 | # with process |
172 | 172 | #RUN_IN_THREAD=False |
173 | 173 | |
174 | - agent = build_agent(AgentDeviceTelescopeGemini, RUN_IN_THREAD=RUN_IN_THREAD) | |
174 | + agent = build_agent(AgentDeviceSBIG, RUN_IN_THREAD=RUN_IN_THREAD) | |
175 | 175 | ''' |
176 | 176 | TEST_MODE, WITH_SIM, configfile = extract_parameters() |
177 | 177 | #agent = AgentX() | ... | ... |
src/core/pyros_django/agent/AgentDeviceTelescopeGemini.py
... | ... | @@ -11,11 +11,11 @@ sys.path.append("..") |
11 | 11 | from agent.AgentDevice import AgentDevice, build_agent |
12 | 12 | from common.models import AgentDeviceTelescopeStatus, get_or_create_unique_row_from_model |
13 | 13 | sys.path.append("../../..") |
14 | -##from devices_controller.devices_controller_concrete.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
14 | +##from device_controller.concrete_component.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
15 | 15 | |
16 | -from devices_controller.devices_controller_concrete.device_controller_Gemini.device_simulator_telescope_gemini import DeviceSimulatorTelescopeGemini | |
16 | +from device_controller.concrete_component.gemini.gemini_telescope_simulator import DeviceSimulatorTelescopeGemini | |
17 | 17 | |
18 | -from devices_controller.devices_controller_concrete.device_controller_Gemini.device_controller_telescope_gemini import DeviceControllerTelescopeGemini | |
18 | +from device_controller.concrete_component.gemini.gemini_telescope_controller import DeviceControllerTelescopeGemini | |
19 | 19 | ##log = L.setupLogger("AgentXTaskLogger", "AgentX") |
20 | 20 | |
21 | 21 | ... | ... |
... | ... | @@ -0,0 +1,268 @@ |
1 | +#!/usr/bin/env python3 | |
2 | + | |
3 | + | |
4 | +import sys | |
5 | +##import utils.Logger as L | |
6 | + | |
7 | +##from .Agent import Agent | |
8 | +sys.path.append("..") | |
9 | +from agent.Agent import Agent, build_agent | |
10 | + | |
11 | + | |
12 | +##log = L.setupLogger("AgentXTaskLogger", "AgentX") | |
13 | + | |
14 | + | |
15 | + | |
16 | +class AgentMultiRequester(Agent): | |
17 | + | |
18 | + # FOR TEST ONLY | |
19 | + # Run this agent in simulator mode | |
20 | + TEST_MODE = True | |
21 | + # Run the assertion tests at the end | |
22 | + TEST_WITH_FINAL_TEST = True | |
23 | + #TEST_MAX_DURATION_SEC = None | |
24 | + TEST_MAX_DURATION_SEC = 75 | |
25 | + # Who should I send commands to ? | |
26 | + #TEST_COMMANDS_DEST = "myself" | |
27 | + #TEST_COMMANDS_DEST = "AgentDeviceTelescopeGemini" | |
28 | + # Scenario to be executed | |
29 | + TEST_COMMANDS_LIST = [ | |
30 | + # Ask receiver to delete all its previous commands | |
31 | + 'AgentDeviceTelescope1:flush_commands', | |
32 | + 'AgentDeviceFilterSelector1:flush_commands', | |
33 | + 'AgentDeviceShutter1:flush_commands', | |
34 | + 'AgentDeviceSensor1:flush_commands', | |
35 | + | |
36 | + 'AgentDeviceTelescope1:go_active', | |
37 | + | |
38 | + # Because of this command, the receiver agent : | |
39 | + # - will no more send any new command | |
40 | + # - will only execute "generic" commands (and not the "specific" ones) | |
41 | + 'AgentDeviceTelescope1:go_idle', | |
42 | + | |
43 | + # Not executed (skipped) because receiver agent is now "idle" | |
44 | + #"specific0", | |
45 | + | |
46 | + # Because of this command, the receiver agent | |
47 | + # will now be able to send new commands | |
48 | + 'AgentDeviceTelescope1:go_active', | |
49 | + | |
50 | + # Executed because recipient agent is now "active" | |
51 | + #"specific1", | |
52 | + 'AgentDeviceTelescope1:get radec', | |
53 | + # should abort previous command (specific1) | |
54 | + #"abort", | |
55 | + | |
56 | + # Executed completely because no abort | |
57 | + #"specific2", | |
58 | + | |
59 | + # fully executed, result is 7 | |
60 | + #"eval 4+3", | |
61 | + | |
62 | + 'AgentDeviceTelescope1:go_idle', | |
63 | + | |
64 | + # Now stop all my device agent clients: | |
65 | + 'AgentDeviceTelescope1:exit', | |
66 | + 'AgentDeviceFilterSelector1:exit', | |
67 | + 'AgentDeviceShutter1:exit', | |
68 | + 'AgentDeviceSensor1:exit', | |
69 | + | |
70 | + ] | |
71 | + | |
72 | + | |
73 | + | |
74 | + """ | |
75 | + ================================================================= | |
76 | + FUNCTIONS RUN INSIDE MAIN THREAD | |
77 | + ================================================================= | |
78 | + """ | |
79 | + | |
80 | + # @override | |
81 | + #def __init__(self, name:str=None, config_filename=None, RUN_IN_THREAD=True): | |
82 | + def __init__(self, config_filename=None, RUN_IN_THREAD=True): | |
83 | + ##if name is None: name = self.__class__.__name__ | |
84 | + #super().__init__(name, config_filename, RUN_IN_THREAD) | |
85 | + super().__init__(config_filename, RUN_IN_THREAD) | |
86 | + | |
87 | + #TODO: : à mettre dans la config | |
88 | + self._my_client_agents = { | |
89 | + 'AgentDeviceTelescope1': 'AgentDeviceTelescopeGemini', | |
90 | + 'AgentDeviceFilterSelector1': 'AgentDeviceSBIG', | |
91 | + 'AgentDeviceShutter1': 'AgentDeviceSBIG', | |
92 | + 'AgentDeviceSensor1': 'AgentDeviceSBIG', | |
93 | + } | |
94 | + | |
95 | + #self._log.print(f"init done for {self.name}") | |
96 | + self._log.print(f"init done") | |
97 | + | |
98 | + # @override | |
99 | + def init(self): | |
100 | + super().init() | |
101 | + # --- Set the mode according the startmode value | |
102 | + ##agent_alias = self.__class__.__name__ | |
103 | + ##self.set_mode_from_config(agent_alias) | |
104 | + | |
105 | + ''' | |
106 | + # @override | |
107 | + def load_config(self): | |
108 | + super().load_config() | |
109 | + ''' | |
110 | + | |
111 | + ''' | |
112 | + # @override | |
113 | + def update_survey(self): | |
114 | + super().update_survey() | |
115 | + ''' | |
116 | + | |
117 | + ''' | |
118 | + # @override | |
119 | + def get_next_command(self): | |
120 | + return super().get_next_command() | |
121 | + ''' | |
122 | + | |
123 | + # @override | |
124 | + def do_log(self): | |
125 | + super().do_log() | |
126 | + | |
127 | + | |
128 | + | |
129 | + """ | |
130 | + ================================================================= | |
131 | + FUNCTIONS RUN INSIDE A SUB-THREAD (OR A PROCESS) (thread_*()) | |
132 | + ================================================================= | |
133 | + """ | |
134 | + | |
135 | + # Define your own command step(s) here | |
136 | + def cmd_step1(self, step:int): | |
137 | + cmd = self._current_specific_cmd | |
138 | + cmd.result = f"in step #{step}/{self._thread_total_steps_number}" | |
139 | + cmd.save() | |
140 | + """ | |
141 | + if self.RUN_IN_THREAD: | |
142 | + print("(save from thread)") | |
143 | + cmd.save() | |
144 | + else: | |
145 | + #@transaction.atomic | |
146 | + print("(save from process)") | |
147 | + with transaction.atomic(): | |
148 | + cmd.save() | |
149 | + #Command.objects.select_for_update() | |
150 | + """ | |
151 | + | |
152 | + def cmd_step2(self, step:int): | |
153 | + self.cmd_step1(step) | |
154 | + def cmd_step3(self, step:int): | |
155 | + self.cmd_step1(step) | |
156 | + def cmd_step4(self, step:int): | |
157 | + self.cmd_step1(step) | |
158 | + | |
159 | + """ | |
160 | + # @override | |
161 | + def thread_exec_specific_cmd_step(self, step:int, sleep_time:float=1.0): | |
162 | + self.thread_stop_if_asked() | |
163 | + cmd = self._current_specific_cmd | |
164 | + print(f">>>>> Thread (cmd {cmd.name}): step #{step}/5") | |
165 | + self.sleep(sleep_time) | |
166 | + """ | |
167 | + | |
168 | + ''' | |
169 | + # @override | |
170 | + def exec_specific_cmd_start(self, cmd:Command, from_thread=True): | |
171 | + super().exec_specific_cmd_start(cmd, from_thread) | |
172 | + ''' | |
173 | + | |
174 | + | |
175 | + # @override | |
176 | + def thread_exec_specific_cmd_main(self): | |
177 | + # This is optional | |
178 | + self.thread_set_total_steps_number(5) | |
179 | + | |
180 | + # HERE, write your own scenario | |
181 | + | |
182 | + # scenario OK | |
183 | + self.thread_exec_specific_cmd_step(1, self.cmd_step1, 1) | |
184 | + self.thread_exec_specific_cmd_step(2, self.cmd_step2, 3) | |
185 | + self.thread_exec_specific_cmd_step(3, self.cmd_step1, 5) | |
186 | + self.thread_exec_specific_cmd_step(4, self.cmd_step3, 10) | |
187 | + self.thread_exec_specific_cmd_step(5, self.cmd_step1, 4) | |
188 | + # ... as many as you need | |
189 | + | |
190 | + """ autre scenario | |
191 | + self.thread_exec_specific_cmd_step(1, self.cmd_step1, 1) | |
192 | + self.thread_exec_specific_cmd_step(2, self.cmd_step2, 2) | |
193 | + self.thread_exec_specific_cmd_step(3, self.cmd_step1, 2) | |
194 | + self.thread_exec_specific_cmd_step(4, self.cmd_step3, 2) | |
195 | + self.thread_exec_specific_cmd_step(5, self.cmd_step1, 3) | |
196 | + """ | |
197 | + | |
198 | + ''' | |
199 | + # @override | |
200 | + def exec_specific_cmd_end(self, cmd:Command, from_thread=True): | |
201 | + super().exec_specific_cmd_end(cmd, from_thread) | |
202 | + ''' | |
203 | + | |
204 | + # @override | |
205 | + def simulator_test_results_main(self, commands): | |
206 | + nb_asserted = 0 | |
207 | + for cmd in commands: | |
208 | + if cmd.name == "flush_commands": | |
209 | + assert cmd.is_executed() | |
210 | + nb_asserted+=1 | |
211 | + # 2 times | |
212 | + if cmd.name == "go_active": | |
213 | + assert cmd.is_executed() | |
214 | + nb_asserted+=1 | |
215 | + # 2 times | |
216 | + if cmd.name == "go_idle": | |
217 | + assert cmd.is_executed() | |
218 | + nb_asserted+=1 | |
219 | + if cmd.name == "get radec": | |
220 | + assert cmd.is_executed() | |
221 | + #assert cmd.result == "06:10:38,+89:41:02" | |
222 | + nb_asserted+=1 | |
223 | + """ | |
224 | + if cmd.name == "specific0": | |
225 | + assert cmd.is_skipped() | |
226 | + assert cmd.result == "in step #5/5" | |
227 | + nb_asserted+=1 | |
228 | + if cmd.name == "specific1": | |
229 | + assert cmd.is_killed() | |
230 | + nb_asserted+=1 | |
231 | + if cmd.name == "specific2": | |
232 | + assert cmd.is_executed() | |
233 | + assert cmd.result == "in step #5/5" | |
234 | + nb_asserted+=1 | |
235 | + if cmd.name == "eval 4+3": | |
236 | + assert cmd.is_executed() | |
237 | + assert cmd.get_result() == "7" | |
238 | + nb_asserted+=1 | |
239 | + if cmd.name in ("abort"): | |
240 | + assert cmd.is_executed() | |
241 | + nb_asserted+=1 | |
242 | + """ | |
243 | + if cmd.name in ("exit"): | |
244 | + assert cmd.is_executed() | |
245 | + nb_asserted+=1 | |
246 | + return nb_asserted | |
247 | + | |
248 | + | |
249 | +""" | |
250 | +================================================================= | |
251 | + MAIN FUNCTION | |
252 | +================================================================= | |
253 | +""" | |
254 | +if __name__ == "__main__": | |
255 | + # with thread | |
256 | + RUN_IN_THREAD=True | |
257 | + # with process | |
258 | + #RUN_IN_THREAD=False | |
259 | + | |
260 | + agent = build_agent(AgentMultiRequester, RUN_IN_THREAD=RUN_IN_THREAD) | |
261 | + ''' | |
262 | + TEST_MODE, WITH_SIM, configfile = extract_parameters() | |
263 | + #agent = AgentX() | |
264 | + agent = AgentTelescopeRequester("AgentTelescopeRequester", configfile, RUN_IN_THREAD) | |
265 | + agent.setSimulatorMode(TEST_MODE) | |
266 | + print(agent) | |
267 | + ''' | |
268 | + agent.run() | ... | ... |
src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu
... | ... | @@ -52,11 +52,11 @@ object AgentDeviceShutter2 |
52 | 52 | |
53 | 53 | |
54 | 54 | /' Use l,r,u,d for left, right, up, or down row alignement '/ |
55 | -AgentMajordome -d-> AgentDeviceFilterSelector1 : sends command to | |
56 | -AgentMajordome -d-> AgentDeviceShutter1 : sends command to | |
57 | -AgentMajordome -d-> AgentDeviceSensor1 : sends command to | |
58 | -AgentMajordome -d-> AgentDeviceTelescope1 : sends command to | |
59 | -AgentMajordome -d-> AgentDeviceShutter2 : sends command to | |
55 | +AgentMajordome -d-> AgentDeviceFilterSelector1 : sends cmd to | |
56 | +AgentMajordome -d-> AgentDeviceShutter1 : sends cmd to | |
57 | +AgentMajordome -d-> AgentDeviceSensor1 : sends cmd to | |
58 | +AgentMajordome -d-> AgentDeviceTelescope1 : sends cmd to | |
59 | +AgentMajordome -d-> AgentDeviceShutter2 : sends cmd to | |
60 | 60 | |
61 | 61 | object AgentDeviceSBIG_CXZ347 <<Singleton>> |
62 | 62 | ... | ... |
src/devices_controller/.gitignore renamed to src/device_controller/.gitignore
src/devices_controller/README.md renamed to src/device_controller/README.md
src/devices_controller/__init__.py renamed to src/device_controller/__init__.py
src/devices_controller/devices_controller_abstract_component/device_controller_abstract.py renamed to src/device_controller/abstract_component/base.py
... | ... | @@ -22,9 +22,10 @@ import time |
22 | 22 | sys.path.append("..") |
23 | 23 | # from src_socket/client/ |
24 | 24 | sys.path.append("../../..") |
25 | +sys.path.append("../../../..") | |
25 | 26 | #import src.core.pyros_django.utils.celme as celme |
26 | 27 | import src.core.celme as celme |
27 | -from devices_controller.logs import * | |
28 | +from device_controller.logs import * | |
28 | 29 | |
29 | 30 | |
30 | 31 | # Local application imports |
... | ... | @@ -32,9 +33,9 @@ from devices_controller.logs import * |
32 | 33 | #from src.client.socket_client_abstract import UnknownCommandException, SocketClientAbstract |
33 | 34 | ##from src_socket.client.socket_client_abstract import * |
34 | 35 | ##from src_device.client.client_channel import * |
35 | -from devices_controller.channels.client_channel_socket import ClientChannelSocket | |
36 | -from devices_controller.channels.client_channel_serial import ClientChannelSerial | |
37 | -from devices_controller.channels.client_channel_usb import ClientChannelUSB | |
36 | +from device_controller.channels.client_channel_socket import ClientChannelSocket | |
37 | +from device_controller.channels.client_channel_serial import ClientChannelSerial | |
38 | +from device_controller.channels.client_channel_usb import ClientChannelUSB | |
38 | 39 | |
39 | 40 | |
40 | 41 | ... | ... |
src/devices_controller/devices_controller_abstract_component/device_controller_detector_sensor.py renamed to src/device_controller/abstract_component/detector_sensor.py
... | ... | @@ -19,9 +19,9 @@ import src.core.celme as celme |
19 | 19 | |
20 | 20 | |
21 | 21 | # Local application imports |
22 | -#from devices_controller.devices_controller_abstract_component.device_controller_abstract import * | |
22 | +#from device_controller.abstract_component.base import * | |
23 | 23 | sys.path.append("../..") |
24 | -from devices_controller.devices_controller_abstract_component.device_controller_abstract import * | |
24 | +from device_controller.abstract_component.base import * | |
25 | 25 | |
26 | 26 | |
27 | 27 | # Default timeouts | ... | ... |
src/devices_controller/devices_controller_abstract_component/device_controller_detector_shutter.py renamed to src/device_controller/abstract_component/detector_shutter.py
... | ... | @@ -19,9 +19,9 @@ import src.core.celme as celme |
19 | 19 | |
20 | 20 | |
21 | 21 | # Local application imports |
22 | -#from devices_controller.devices_controller_abstract_component.device_controller_abstract import * | |
22 | +#from device_controller.abstract_component.base import * | |
23 | 23 | sys.path.append("../..") |
24 | -from devices_controller.devices_controller_abstract_component.device_controller_abstract import * | |
24 | +from device_controller.abstract_component.base import * | |
25 | 25 | |
26 | 26 | |
27 | 27 | # Default timeouts | ... | ... |
src/devices_controller/devices_controller_abstract_component/device_controller_filter_selector.py renamed to src/device_controller/abstract_component/filter_selector.py
... | ... | @@ -19,9 +19,9 @@ import src.core.celme as celme |
19 | 19 | |
20 | 20 | |
21 | 21 | # Local application imports |
22 | -#from devices_controller.devices_controller_abstract_component.device_controller_abstract import * | |
22 | +#from device_controller.abstract_component.base import * | |
23 | 23 | sys.path.append("../..") |
24 | -from devices_controller.devices_controller_abstract_component.device_controller_abstract import * | |
24 | +from device_controller.abstract_component.base import * | |
25 | 25 | |
26 | 26 | |
27 | 27 | # Default timeouts | ... | ... |
src/devices_controller/devices_controller_abstract_component/device_controller_plc.py renamed to src/device_controller/abstract_component/plc.py
... | ... | @@ -27,7 +27,7 @@ import src.core.celme as celme |
27 | 27 | # Local application imports |
28 | 28 | #sys.path.append('../..') |
29 | 29 | #from src.client.socket_client_abstract import UnknownCommandException, SocketClientAbstract |
30 | -from src_device.client.device_controller_abstract import * | |
30 | +from src_device.client.base import * | |
31 | 31 | |
32 | 32 | |
33 | 33 | ... | ... |
src/devices_controller/devices_controller_abstract_component/device_controller_telescope.py renamed to src/device_controller/abstract_component/telescope.py
... | ... | @@ -28,7 +28,7 @@ import src.core.celme as celme |
28 | 28 | #sys.path.append('../..') |
29 | 29 | #from src.client.socket_client_abstract import UnknownCommandException, SocketClientAbstract |
30 | 30 | ##from src_socket.client.socket_client_abstract import * |
31 | -from devices_controller.devices_controller_abstract_component.device_controller_abstract import * | |
31 | +from device_controller.abstract_component.base import * | |
32 | 32 | |
33 | 33 | |
34 | 34 | ... | ... |
src/devices_controller/channels/client_channel.py renamed to src/device_controller/channels/client_channel.py
src/devices_controller/channels/client_channel_serial.py renamed to src/device_controller/channels/client_channel_serial.py
src/devices_controller/channels/client_channel_socket.py renamed to src/device_controller/channels/client_channel_socket.py
src/devices_controller/channels/client_channel_usb.py renamed to src/device_controller/channels/client_channel_usb.py
src/devices_controller/devices_controller_concrete/device_controller_AK/.emptyfile renamed to src/device_controller/concrete_component/ak/.emptyfile
src/devices_controller/devices_controller_concrete/device_controller_AK/device_controller_plc_ak.py renamed to src/device_controller/concrete_component/ak/ak_plc_controller.py
src/devices_controller/devices_controller_concrete/device_simulator_common/server_udp_or_tcp.py renamed to src/device_controller/concrete_component/device_simulator_common/server_udp_or_tcp.py
src/devices_controller/devices_controller_concrete/device_controller_Gemini/.emptyfile renamed to src/device_controller/concrete_component/gemini/.emptyfile
src/devices_controller/devices_controller_concrete/device_controller_Gemini/client_telescope_gemini_controller_run.py renamed to src/device_controller/concrete_component/gemini/client_telescope_gemini_controller_run.py
... | ... | @@ -8,13 +8,13 @@ import sys |
8 | 8 | ''' |
9 | 9 | (1) |
10 | 10 | sys.path.append("../../..") |
11 | -from devices_controller.devices_controller_concrete.device_controller_Gemini.telescope_controller_gemini import TelescopeControllerGemini | |
11 | +from device_controller.concrete_component.gemini.telescope_controller_gemini import TelescopeControllerGemini | |
12 | 12 | ou (2) |
13 | 13 | #sys.path.append("..") |
14 | -#from device_controller_Gemini.telescope_controller_gemini import TelescopeControllerGemini | |
14 | +#from gemini.telescope_controller_gemini import TelescopeControllerGemini | |
15 | 15 | ou (3) |
16 | 16 | ''' |
17 | -from device_controller_telescope_gemini import DeviceControllerTelescopeGemini | |
17 | +from gemini_telescope_controller import DeviceControllerTelescopeGemini | |
18 | 18 | |
19 | 19 | #DEBUG = False |
20 | 20 | DEBUG = True | ... | ... |
src/devices_controller/devices_controller_concrete/device_controller_Gemini/device_controller_telescope_gemini.py renamed to src/device_controller/concrete_component/gemini/gemini_telescope_controller.py
... | ... | @@ -15,10 +15,11 @@ import time |
15 | 15 | |
16 | 16 | # Local application imports |
17 | 17 | sys.path.append('../../..') |
18 | +from device_controller.abstract_component.base import UnknownCommandException | |
18 | 19 | #from src.client.socket_client_telescope_abstract import Position, UnknownCommandException, TimeoutException, SocketClientTelescopeAbstract |
19 | 20 | ##from src_socket.client.socket_client_telescope_abstract import * |
20 | -#from devices_controller.devices_controller_abstract_component.telescope_controller_abstract import * | |
21 | -from devices_controller.devices_controller_abstract_component.device_controller_telescope import * | |
21 | +#from device_controller.abstract_component.telescope_controller_abstract import * | |
22 | +from device_controller.abstract_component.telescope import * | |
22 | 23 | |
23 | 24 | # Default timeouts |
24 | 25 | TIMEOUT_SEND = 10 | ... | ... |
src/devices_controller/devices_controller_concrete/device_controller_Gemini/device_simulator_telescope_gemini.py renamed to src/device_controller/concrete_component/gemini/gemini_telescope_simulator.py
... | ... | @@ -6,9 +6,9 @@ import sys |
6 | 6 | #sys.path.append("..") |
7 | 7 | #sys.path.append("../..") |
8 | 8 | #sys.path.append("../../..") |
9 | -#from devices_controller.devices_controller_concrete.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
9 | +#from device_controller.concrete_component.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
10 | 10 | #from device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP |
11 | -from devices_controller.devices_controller_concrete.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
11 | +from device_controller.concrete_component.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
12 | 12 | #from server.server_udp_or_tcp import get_SocketServer_UDP_TCP |
13 | 13 | |
14 | 14 | HOST = "localhost" | ... | ... |
src/devices_controller/devices_controller_concrete/device_controller_Gemini/server_telescope_gemini_simulator_run.py renamed to src/device_controller/concrete_component/gemini/server_telescope_gemini_simulator_run.py
... | ... | @@ -4,7 +4,7 @@ import sys |
4 | 4 | |
5 | 5 | |
6 | 6 | sys.path.append("..") |
7 | -#from devices_controller.devices_controller_concrete.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
7 | +#from device_controller.concrete_component.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
8 | 8 | from device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP |
9 | 9 | #from server.server_udp_or_tcp import get_SocketServer_UDP_TCP |
10 | 10 | ... | ... |
src/devices_controller/devices_controller_concrete/device_controller_SBIG/device_controller_SBIG.py renamed to src/device_controller/concrete_component/sbig/sbig_controller.py
... | ... | @@ -16,22 +16,21 @@ import time |
16 | 16 | |
17 | 17 | # Local application imports |
18 | 18 | |
19 | -# devices_controller/ | |
19 | +# device_controller/ | |
20 | 20 | sys.path.append('../../..') |
21 | 21 | |
22 | 22 | # src/ |
23 | 23 | sys.path.append('../../../..') |
24 | 24 | |
25 | -#from src.client.socket_client_telescope_abstract import Position, UnknownCommandException, TimeoutException, SocketClientTelescopeAbstract | |
26 | -##from src_socket.client.socket_client_telescope_abstract import * | |
27 | -#from devices_controller.devices_controller_abstract_component.telescope_controller_abstract import * | |
25 | +from device_controller.abstract_component.base import UnknownCommandException | |
26 | +#from device_controller.abstract_component.telescope_controller_abstract import * | |
28 | 27 | |
29 | 28 | #TODO: Heritage ou plutot COMPOSITION ? |
30 | 29 | # The SBIG controller has 3 capabilities : filter selector, detector sensor, and detector shutter |
31 | -#from devices_controller.devices_controller_abstract_component.device_controller_abstract import * | |
32 | -from devices_controller.devices_controller_abstract_component.device_controller_filter_selector import DeviceControllerFilterSelector | |
33 | -from devices_controller.devices_controller_abstract_component.device_controller_detector_sensor import DeviceControllerDetectorSensor | |
34 | -from devices_controller.devices_controller_abstract_component.device_controller_detector_shutter import DeviceControllerDetectorShutter | |
30 | +#from device_controller.abstract_component.base import * | |
31 | +from device_controller.abstract_component.filter_selector import DeviceControllerFilterSelector | |
32 | +from device_controller.abstract_component.detector_sensor import DeviceControllerDetectorSensor | |
33 | +from device_controller.abstract_component.detector_shutter import DeviceControllerDetectorShutter | |
35 | 34 | |
36 | 35 | # Default timeouts |
37 | 36 | TIMEOUT_SEND = 10 | ... | ... |
src/devices_controller/devices_controller_concrete/device_controller_SBIG/device_simulator_SBIG.py renamed to src/device_controller/concrete_component/sbig/sbig_simulator.py
... | ... | @@ -6,9 +6,9 @@ import sys |
6 | 6 | #sys.path.append("..") |
7 | 7 | #sys.path.append("../..") |
8 | 8 | #sys.path.append("../../..") |
9 | -#from devices_controller.devices_controller_concrete.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
9 | +#from device_controller.concrete_component.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
10 | 10 | #from device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP |
11 | -from devices_controller.devices_controller_concrete.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
11 | +from device_controller.concrete_component.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
12 | 12 | #from server.server_udp_or_tcp import get_SocketServer_UDP_TCP |
13 | 13 | |
14 | 14 | HOST = "localhost" | ... | ... |
src/devices_controller/doc/Device_controller_class_diag.pu renamed to src/device_controller/doc/Device_controller_class_diag.pu
src/devices_controller/doc/Device_controller_class_diag_multiinheritance_OLD.pu renamed to src/device_controller/doc/Device_controller_class_diag_multiinheritance_OLD.pu
src/devices_controller/doc/generate_diagrams.sh renamed to src/device_controller/doc/generate_diagrams.sh
src/devices_controller/logs.py renamed to src/device_controller/logs.py
src/devices_controller/test/.gitignore renamed to src/device_controller/test/.gitignore
src/devices_controller/test/test_client_gemini.py renamed to src/device_controller/test/test_client_gemini.py
... | ... | @@ -7,9 +7,9 @@ import unittest |
7 | 7 | import sys |
8 | 8 | sys.path.append('..') |
9 | 9 | sys.path.append('../..') |
10 | -from devices_controller.devices_controller_concrete.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
10 | +from device_controller.concrete_component.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | |
11 | 11 | #from src_socket.client.socket_client_telescope_gemini import SocketClientTelescopeGemini |
12 | -import devices_controller.devices_controller_concrete.device_controller_Gemini.device_controller_telescope_gemini as gemini | |
12 | +import device_controller.concrete_component.gemini.gemini_telescope_controller as gemini | |
13 | 13 | |
14 | 14 | #HOST, PORT = "localhost", 9999 |
15 | 15 | #HOST, PORT = "localhost", 20001 | ... | ... |