Commit 285d72a8259af2fecf81bb3789008ac04c5dbd17
1 parent
bf9c26eb
Exists in
dev
traitement complet des "agent level specific" commands
Showing
4 changed files
with
27 additions
and
13 deletions
Show diff stats
src/core/pyros_django/agent/Agent.py
@@ -648,7 +648,7 @@ class Agent: | @@ -648,7 +648,7 @@ class Agent: | ||
648 | # CASE 1 - AGENT LEVEL command | 648 | # CASE 1 - AGENT LEVEL command |
649 | # => I process it directly without asking my DC | 649 | # => I process it directly without asking my DC |
650 | # => Simple action, short execution time, so I execute it directly (in current main thread, not in parallel) | 650 | # => Simple action, short execution time, so I execute it directly (in current main thread, not in parallel) |
651 | - if self._is_agent_level_cmd(cmd): | 651 | + if self.is_agent_level_cmd(cmd): |
652 | print("********** AGENT LEVEL CMD *********") | 652 | print("********** AGENT LEVEL CMD *********") |
653 | try: | 653 | try: |
654 | self._exec_agent_cmd(cmd) | 654 | self._exec_agent_cmd(cmd) |
@@ -1181,8 +1181,8 @@ class Agent: | @@ -1181,8 +1181,8 @@ class Agent: | ||
1181 | else: | 1181 | else: |
1182 | return getattr(self, func)() | 1182 | return getattr(self, func)() |
1183 | 1183 | ||
1184 | - def _is_agent_level_cmd(self, cmd:Command): | ||
1185 | - return cmd.is_agent_level_general_cmd() or self._is_agent_level_specific_cmd(cmd) | 1184 | + def is_agent_level_cmd(self, cmd:Command): |
1185 | + return cmd.is_agent_general_cmd() or self._is_agent_specific_cmd(cmd) | ||
1186 | 1186 | ||
1187 | ''' | 1187 | ''' |
1188 | def _exec_agent_cmd(self, cmd:Command): | 1188 | def _exec_agent_cmd(self, cmd:Command): |
@@ -1374,11 +1374,14 @@ class Agent: | @@ -1374,11 +1374,14 @@ class Agent: | ||
1374 | assert last_cmd.get_result() == "SHOULD BE DONE NOW" | 1374 | assert last_cmd.get_result() == "SHOULD BE DONE NOW" |
1375 | 1375 | ||
1376 | nb_asserted = 0 | 1376 | nb_asserted = 0 |
1377 | + nb_agent_general = 0 | ||
1377 | nb_unknown = 0 | 1378 | nb_unknown = 0 |
1378 | nb_unimplemented = 0 | 1379 | nb_unimplemented = 0 |
1379 | for cmd in commands: | 1380 | for cmd in commands: |
1380 | assert cmd.is_executed() or cmd.is_killed() or cmd.is_skipped() | 1381 | assert cmd.is_executed() or cmd.is_killed() or cmd.is_skipped() |
1381 | nb_asserted += 1 | 1382 | nb_asserted += 1 |
1383 | + if cmd.is_agent_general_cmd(): | ||
1384 | + nb_agent_general += 1 | ||
1382 | if cmd.name == "do_unknown": | 1385 | if cmd.name == "do_unknown": |
1383 | assert cmd.is_skipped() | 1386 | assert cmd.is_skipped() |
1384 | #assert "UnimplementedGenericCmdException" in cmd.get_result() | 1387 | #assert "UnimplementedGenericCmdException" in cmd.get_result() |
@@ -1389,8 +1392,12 @@ class Agent: | @@ -1389,8 +1392,12 @@ class Agent: | ||
1389 | assert cmd.is_skipped() | 1392 | assert cmd.is_skipped() |
1390 | assert "UnimplementedGenericCmdException" in cmd.get_result() | 1393 | assert "UnimplementedGenericCmdException" in cmd.get_result() |
1391 | nb_unimplemented += 1 | 1394 | nb_unimplemented += 1 |
1395 | + assert nb_commands_to_send == nb_asserted | ||
1392 | print(nb_commands_to_send, "cmds I had to send <==>", nb_asserted, "cmds executed (or killed)") | 1396 | print(nb_commands_to_send, "cmds I had to send <==>", nb_asserted, "cmds executed (or killed)") |
1393 | - print("Among them,", nb_unimplemented, "unimplemented command(s) and", nb_unknown, "unknown command(s) ==> UnimplementedGenericCmdException raised then command was skipped") | 1397 | + print("Among them:") |
1398 | + print(f"- {nb_agent_general} AGENT general command(s)") | ||
1399 | + print("-", nb_unimplemented, "unimplemented command(s) => UnimplementedGenericCmdException raised then command was skipped") | ||
1400 | + print("-", nb_unknown, "unknown command(s) => skipped") | ||
1394 | assert nb_asserted == nb_commands_to_send | 1401 | assert nb_asserted == nb_commands_to_send |
1395 | 1402 | ||
1396 | # Specific (detailed) test (to be overriden by subclass) | 1403 | # Specific (detailed) test (to be overriden by subclass) |
src/core/pyros_django/agent/AgentDeviceSBIG.py
@@ -25,8 +25,10 @@ class AgentDeviceSBIG(AgentDevice): | @@ -25,8 +25,10 @@ class AgentDeviceSBIG(AgentDevice): | ||
25 | # Agent level specific commands | 25 | # Agent level specific commands |
26 | # @override superclass Agent | 26 | # @override superclass Agent |
27 | AGENT_SPECIFIC_COMMANDS = [ | 27 | AGENT_SPECIFIC_COMMANDS = [ |
28 | - "do_sbig_specific1", | ||
29 | - "set_sbig_specific2", | 28 | + "do_ad_sbig_specific1", |
29 | + "set_ad_sbig_specific2", | ||
30 | + "do_ad_sbig_specific3_unimplemented", | ||
31 | + "do_ad_sbig_specific4_unimplemented", | ||
30 | ] | 32 | ] |
31 | 33 | ||
32 | _agent_device_telescope_status = None | 34 | _agent_device_telescope_status = None |
@@ -54,7 +56,6 @@ class AgentDeviceSBIG(AgentDevice): | @@ -54,7 +56,6 @@ class AgentDeviceSBIG(AgentDevice): | ||
54 | 56 | ||
55 | 57 | ||
56 | 58 | ||
57 | - | ||
58 | """ | 59 | """ |
59 | ================================================================= | 60 | ================================================================= |
60 | FUNCTIONS RUN INSIDE MAIN THREAD | 61 | FUNCTIONS RUN INSIDE MAIN THREAD |
@@ -138,11 +139,15 @@ class AgentDeviceSBIG(AgentDevice): | @@ -138,11 +139,15 @@ class AgentDeviceSBIG(AgentDevice): | ||
138 | super().do_log() | 139 | super().do_log() |
139 | 140 | ||
140 | 141 | ||
141 | - def do_sbig_specific10(self): | 142 | + ''' |
143 | + AGENT LEVEL SPECIFIC COMMANDS | ||
144 | + ''' | ||
145 | + def do_ad_sbig_specific1(self): | ||
142 | print("processing do_sbig_specific1... ") | 146 | print("processing do_sbig_specific1... ") |
143 | - def set_sbig_specific20(self): | 147 | + def set_ad_sbig_specific2(self): |
144 | print("processing set_sbig_specific2... ") | 148 | print("processing set_sbig_specific2... ") |
145 | 149 | ||
150 | + | ||
146 | # @Override | 151 | # @Override |
147 | def get_device_status(self): | 152 | def get_device_status(self): |
148 | 153 |
src/core/pyros_django/agent/AgentMultiRequester.py
@@ -21,7 +21,7 @@ class AgentMultiRequester(Agent): | @@ -21,7 +21,7 @@ class AgentMultiRequester(Agent): | ||
21 | # Run the assertion tests at the end | 21 | # Run the assertion tests at the end |
22 | TEST_WITH_FINAL_TEST = True | 22 | TEST_WITH_FINAL_TEST = True |
23 | #TEST_MAX_DURATION_SEC = None | 23 | #TEST_MAX_DURATION_SEC = None |
24 | - TEST_MAX_DURATION_SEC = 100 | 24 | + TEST_MAX_DURATION_SEC = 110 |
25 | # Who should I send commands to ? | 25 | # Who should I send commands to ? |
26 | #TEST_COMMANDS_DEST = "myself" | 26 | #TEST_COMMANDS_DEST = "myself" |
27 | #TEST_COMMANDS_DEST = "AgentDeviceTelescopeGemini" | 27 | #TEST_COMMANDS_DEST = "AgentDeviceTelescopeGemini" |
@@ -96,10 +96,12 @@ class AgentMultiRequester(Agent): | @@ -96,10 +96,12 @@ class AgentMultiRequester(Agent): | ||
96 | 'ad_sensor UNKNOWN_NATIVE_CMD', | 96 | 'ad_sensor UNKNOWN_NATIVE_CMD', |
97 | 97 | ||
98 | 'ad_filtersel do_unimplemented', | 98 | 'ad_filtersel do_unimplemented', |
99 | - 'ad_filtersel do_sbig_specific1', | 99 | + 'ad_filtersel do_ad_sbig_specific1', |
100 | + 'ad_filtersel do_ad_sbig_specific3_unimplemented', | ||
100 | 'ad_filtersel do_unknown', | 101 | 'ad_filtersel do_unknown', |
101 | - 'ad_filtersel set_sbig_specific2', | 102 | + 'ad_filtersel set_ad_sbig_specific2', |
102 | 'ad_shutter do_unimplemented', | 103 | 'ad_shutter do_unimplemented', |
104 | + 'ad_filtersel do_ad_sbig_specific4_unimplemented', | ||
103 | 'ad_sensor do_unimplemented', | 105 | 'ad_sensor do_unimplemented', |
104 | 106 | ||
105 | #'ad_mount do_init', | 107 | #'ad_mount do_init', |
src/core/pyros_django/common/models.py
@@ -706,7 +706,7 @@ class Command(models.Model): | @@ -706,7 +706,7 @@ class Command(models.Model): | ||
706 | 706 | ||
707 | # --- BOOLEAN (test) functions --- | 707 | # --- BOOLEAN (test) functions --- |
708 | 708 | ||
709 | - def is_agent_level_general_cmd(self): | 709 | + def is_agent_general_cmd(self): |
710 | """ | 710 | """ |
711 | Is this a general command ? | 711 | Is this a general command ? |
712 | It is the case if command is of style "do_set:state:idle" or "do_restart" or "do_flush"... | 712 | It is the case if command is of style "do_set:state:idle" or "do_restart" or "do_flush"... |