Commit 8902a770b185c2a1ac3650db3d6380d810d06196
1 parent
e848fbef
Exists in
dev
ctrl-c available sooner : from restart loop and not only from main_loop as before
Showing
25 changed files
with
332 additions
and
438 deletions
Show diff stats
.gitignore
@@ -19,7 +19,6 @@ BASE_TEMPLATE.HTML | @@ -19,7 +19,6 @@ BASE_TEMPLATE.HTML | ||
19 | 19 | ||
20 | *.swp | 20 | *.swp |
21 | /.settings/ | 21 | /.settings/ |
22 | -#/.pydevproject | ||
23 | 22 | ||
24 | #src/images/*_* | 23 | #src/images/*_* |
25 | #src/alert_manager/twistd* | 24 | #src/alert_manager/twistd* |
@@ -27,6 +26,7 @@ BASE_TEMPLATE.HTML | @@ -27,6 +26,7 @@ BASE_TEMPLATE.HTML | ||
27 | #src/common/migrations/0* | 26 | #src/common/migrations/0* |
28 | #src/common/migrations_LOCAL/0* | 27 | #src/common/migrations_LOCAL/0* |
29 | #src/monitoring/plc_config.json | 28 | #src/monitoring/plc_config.json |
29 | +src/core/pyros_django/majordome/doc/AgentMajordome_object_diag_error.html | ||
30 | 30 | ||
31 | # LOGS | 31 | # LOGS |
32 | /config/logs/* | 32 | /config/logs/* |
@@ -85,4 +85,4 @@ src/core/pyros_django/misc/fixtures/tests/test_import_seq.yml | @@ -85,4 +85,4 @@ src/core/pyros_django/misc/fixtures/tests/test_import_seq.yml | ||
85 | *.moi | 85 | *.moi |
86 | *.moi.* | 86 | *.moi.* |
87 | 87 | ||
88 | -privatedev/plugin/agent/triton/triton/CATALOGUES | ||
89 | \ No newline at end of file | 88 | \ No newline at end of file |
89 | +privatedev/plugin/agent/triton/triton/CATALOGUES |
.pydevproject deleted
@@ -1,58 +0,0 @@ | @@ -1,58 +0,0 @@ | ||
1 | -<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
2 | -<?eclipse-pydev version="1.0"?><pydev_project> | ||
3 | - | ||
4 | - | ||
5 | - | ||
6 | - | ||
7 | - | ||
8 | - | ||
9 | - | ||
10 | - <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> | ||
11 | - | ||
12 | - | ||
13 | - | ||
14 | - | ||
15 | - | ||
16 | - | ||
17 | - | ||
18 | - <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property> | ||
19 | - | ||
20 | - | ||
21 | - | ||
22 | - | ||
23 | - | ||
24 | - | ||
25 | - | ||
26 | - <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> | ||
27 | - | ||
28 | - <path>/${PROJECT_DIR_NAME}/src</path> | ||
29 | - | ||
30 | - <path>/${PROJECT_DIR_NAME}/simulators</path> | ||
31 | - | ||
32 | - </pydev_pathproperty> | ||
33 | - | ||
34 | - | ||
35 | - | ||
36 | - | ||
37 | - | ||
38 | - | ||
39 | - | ||
40 | - <pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION"> | ||
41 | - <key>DJANGO_MANAGE_LOCATION</key> | ||
42 | - <value>src/core/pyros_django/manage.py</value> | ||
43 | - <key>DJANGO_SETTINGS_MODULE</key> | ||
44 | - <value>core.pyros_django.pyros.settings</value> | ||
45 | - <key>PY</key> | ||
46 | - <value>37</value> | ||
47 | - </pydev_variables_property> | ||
48 | - | ||
49 | - | ||
50 | - | ||
51 | - | ||
52 | - | ||
53 | - | ||
54 | - | ||
55 | - <pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH"> | ||
56 | - <path>/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS_SOFT/PYROS201806/venv/venv_py3_pyros/lib/python3.7/site-packages</path> | ||
57 | - </pydev_pathproperty> | ||
58 | -</pydev_project> |
cp_private_dev_to_private.sh
1 | 1 | ||
2 | cp -p src/core/pyros_django/agent/AgentBasic.py privatedev/plugin/agent/AgentBasic.py | 2 | cp -p src/core/pyros_django/agent/AgentBasic.py privatedev/plugin/agent/AgentBasic.py |
3 | 3 | ||
4 | -rsync -avh --delete privatedev/ private/ | 4 | +rsync -avh --delete --exclude '.gitignore' --exclude 'plugin/README' --exclude 'config/README' privatedev/ private/ |
5 | + | ||
5 | #cp -r ./privatedev/* ./private/ | 6 | #cp -r ./privatedev/* ./private/ |
6 | 7 |
private/.gitignore
1 | # Ignore everything in those directories | 1 | # Ignore everything in those directories |
2 | -plugins/* | 2 | +plugin/* |
3 | config/* | 3 | config/* |
4 | -# Except this file | 4 | +# Except these files |
5 | !.gitignore | 5 | !.gitignore |
6 | -!plugins/README | ||
7 | -!config/README | ||
8 | \ No newline at end of file | 6 | \ No newline at end of file |
7 | +!plugin/README | ||
8 | +!config/README |
privatedev/plugin/agent/AgentBasic.py
@@ -47,7 +47,7 @@ class AgentBasic(Agent): | @@ -47,7 +47,7 @@ class AgentBasic(Agent): | ||
47 | # on DEV | 47 | # on DEV |
48 | #COMMIT_ONLY = False | 48 | #COMMIT_ONLY = False |
49 | # on commit only | 49 | # on commit only |
50 | - COMMIT_ONLY = False | 50 | + COMMIT_ONLY = True |
51 | 51 | ||
52 | # @override | 52 | # @override |
53 | _TEST_COMMANDS_LIST = [ | 53 | _TEST_COMMANDS_LIST = [ |
src/core/pyros_django/agent/Agent.py
@@ -626,8 +626,6 @@ class Agent: | @@ -626,8 +626,6 @@ class Agent: | ||
626 | _my_client_agents_aliases = [] | 626 | _my_client_agents_aliases = [] |
627 | _my_client_agents = {} | 627 | _my_client_agents = {} |
628 | 628 | ||
629 | - _iter_num = None | ||
630 | - | ||
631 | # Log object | 629 | # Log object |
632 | _log = None | 630 | _log = None |
633 | 631 | ||
@@ -645,13 +643,13 @@ class Agent: | @@ -645,13 +643,13 @@ class Agent: | ||
645 | # Declaration of Instance attributes, default values | 643 | # Declaration of Instance attributes, default values |
646 | #self.UP_SINCE = datetime.utcnow() | 644 | #self.UP_SINCE = datetime.utcnow() |
647 | self.__UP_SINCE = datetime.now(tz=timezone.utc) | 645 | self.__UP_SINCE = datetime.now(tz=timezone.utc) |
648 | - self.__current_cmd = None | 646 | + self.__current_cmd :AgentCmd = None |
649 | self.name = "Generic Agent" | 647 | self.name = "Generic Agent" |
650 | - self.__status = None | ||
651 | - self.__mode = None | 648 | + self.__status :str = None |
649 | + self.__mode :str = None | ||
652 | self.unit = None | 650 | self.unit = None |
653 | self.TEST_COMMANDS = None | 651 | self.TEST_COMMANDS = None |
654 | - | 652 | + self.__iter_num :int = 0 |
655 | 653 | ||
656 | #print(AgentSurvey.MODE_CHOICES.IDLE) | 654 | #print(AgentSurvey.MODE_CHOICES.IDLE) |
657 | #sys.exit() | 655 | #sys.exit() |
@@ -1030,82 +1028,68 @@ class Agent: | @@ -1030,82 +1028,68 @@ class Agent: | ||
1030 | ###############@ | 1028 | ###############@ |
1031 | # REPEAT UNTIL not DO_RESTART_LOOP | 1029 | # REPEAT UNTIL not DO_RESTART_LOOP |
1032 | self.DO_RESTART_LOOP = True | 1030 | self.DO_RESTART_LOOP = True |
1031 | + | ||
1033 | while self.DO_RESTART_LOOP: | 1032 | while self.DO_RESTART_LOOP: |
1034 | - | ||
1035 | - log.info("*"*10+ " STARTING RESTART LOOP "+ "*"*10+ '\n') | ||
1036 | - | ||
1037 | # By default, no restart after exit from main loop | 1033 | # By default, no restart after exit from main loop |
1038 | self.DO_RESTART_LOOP = False | 1034 | self.DO_RESTART_LOOP = False |
1039 | - | ||
1040 | - self.start_time = time.time() | ||
1041 | - #log.debug("on est ici: " + os.getcwd()) | ||
1042 | - | ||
1043 | - self.__load_config() | ||
1044 | - | ||
1045 | - self.__print_TEST_MODE() | ||
1046 | - | ||
1047 | - self._init() | ||
1048 | - ''' testing log: | ||
1049 | - self.log_e("ERROR") | ||
1050 | - self.log_c("FATAL critical ERROR") | ||
1051 | - ''' | ||
1052 | - #self.log_w("WARNING", "watch your step !") | ||
1053 | - #log.warning("WARNING"+ "watch your step !") | ||
1054 | - | ||
1055 | - # Avoid blocking on false "running" commands | ||
1056 | - # (old commands that stayed with "running" status when agent was killed) | ||
1057 | - AgentCmd.delete_commands_with_running_status_for_agent(self.name) | ||
1058 | - | ||
1059 | - self._iter_num = 1 | ||
1060 | - | ||
1061 | - ############# | ||
1062 | - # MAIN loop # | ||
1063 | - ############@ | ||
1064 | - self.DO_MAIN_LOOP = True | ||
1065 | - while self.DO_MAIN_LOOP: | ||
1066 | - try: | ||
1067 | - self.__main_loop(nb_iter,FOR_REAL) | ||
1068 | - #if not self.DO_MAIN_LOOP: break | ||
1069 | - except KeyboardInterrupt: # CTRL-C | ||
1070 | - # In case of CTRL-C, kill the current thread (process) before dying (in error) | ||
1071 | - #log.info("CTRL-C Interrupted, I kill the current thread (process) before exiting (if exists)") | ||
1072 | - log.info("CTRL-C Interrupted, trying to stop cleanly") | ||
1073 | - #self._kill_running_device_cmd_if_exists("USER_CTRLC") | ||
1074 | - #self.do_things_before_exit("USER_CTRLC") | ||
1075 | - ##self._cleanup_before_exit("USER_CTRLC") | ||
1076 | - self.do_stop("asap") | ||
1077 | - exit(1) | ||
1078 | - | ||
1079 | - # TEST mode only | ||
1080 | - self.__TEST_test_results() | ||
1081 | - #if self._DO_EXIT: exit(0) | 1035 | + try: |
1036 | + self.__restart_loop(nb_iter,FOR_REAL) | ||
1037 | + except KeyboardInterrupt: # CTRL-C | ||
1038 | + # In case of CTRL-C, kill the current thread (process) before dying (in error) | ||
1039 | + #log.info("CTRL-C Interrupted, I kill the current thread (process) before exiting (if exists)") | ||
1040 | + log.info("CTRL-C Interrupted, trying to stop cleanly") | ||
1041 | + break | ||
1042 | + #self._kill_running_device_cmd_if_exists("USER_CTRLC") | ||
1043 | + #self.do_things_before_exit("USER_CTRLC") | ||
1044 | + ##self._cleanup_before_exit("USER_CTRLC") | ||
1045 | + ###self.do_stop("asap") | ||
1046 | + ###exit(1) | ||
1047 | + | ||
1048 | + # exit | ||
1049 | + self.do_stop("asap") | ||
1082 | 1050 | ||
1083 | 1051 | ||
1052 | + def __restart_loop(self, nb_iter:int=None, FOR_REAL:bool=True): | ||
1053 | + log.info("*"*10+ " STARTING RESTART LOOP "+ "*"*10+ '\n') | ||
1084 | 1054 | ||
1085 | - def __cleanup_before_exit(self, stopper_agent_name:str=None): | ||
1086 | - if not stopper_agent_name: stopper_agent_name = self.name | ||
1087 | - #self._set_status(self.STATUS_EXIT) | ||
1088 | - ##self._log_agent_state() | 1055 | + self.start_time = time.time() |
1056 | + #log.debug("on est ici: " + os.getcwd()) | ||
1089 | 1057 | ||
1090 | - log.info("Trying to stop cleanly") | ||
1091 | - log.info("Before exiting, Here are (if exists) the current (still) pending commands (time ordered) :") | ||
1092 | - #commands = AgentCmd.get_commands_sent_to_agent(self.name) | ||
1093 | - commands = AgentCmd.get_pending_and_running_commands_for_agent(self.name) | ||
1094 | - AgentCmd.show_commands(commands, True) | ||
1095 | - ##self.do_flush_commands() | ||
1096 | - #if self.TEST_MODE and self.TEST_WITH_FINAL_TEST and self.TEST_COMMANDS_DEST == "myself": self.simulator_test_results() | ||
1097 | - if self.TEST_MODE and self.TEST_WITH_FINAL_TEST: | ||
1098 | - self.__TEST_test_results() | ||
1099 | - #self._DO_EXIT=True | ||
1100 | - #exit(0) | 1058 | + self.__load_config() |
1101 | 1059 | ||
1102 | - self._do_things_before_exit(stopper_agent_name) | ||
1103 | - ##self._set_and_log_status(self.AGT_STATUS.EXITING) | 1060 | + self.__print_TEST_MODE() |
1104 | 1061 | ||
1105 | - #def _kill_running_device_cmd_if_exists(self, abort_cmd_sender): | ||
1106 | - # to be overriden by subclass | ||
1107 | - def _do_things_before_exit(self, stopper_agent_name:str=None): | ||
1108 | - pass | 1062 | + self._init() |
1063 | + ''' testing log: | ||
1064 | + self.log_e("ERROR") | ||
1065 | + self.log_c("FATAL critical ERROR") | ||
1066 | + ''' | ||
1067 | + #self.log_w("WARNING", "watch your step !") | ||
1068 | + #log.warning("WARNING"+ "watch your step !") | ||
1069 | + | ||
1070 | + # Avoid blocking on false "running" commands | ||
1071 | + # (old commands that stayed with "running" status when agent was killed) | ||
1072 | + AgentCmd.delete_commands_with_running_status_for_agent(self.name) | ||
1073 | + | ||
1074 | + ############# | ||
1075 | + # MAIN loop # | ||
1076 | + ############@ | ||
1077 | + self.__iter_num = 1 | ||
1078 | + self.DO_MAIN_LOOP = True | ||
1079 | + while self.DO_MAIN_LOOP: | ||
1080 | + # EXIT because of nb of iterations ? | ||
1081 | + if nb_iter is not None: | ||
1082 | + # Bad number of iterations or nb iterations reached => exit | ||
1083 | + if nb_iter <= 0 or nb_iter < self.__iter_num: | ||
1084 | + log.info(f"Exit because number of iterations asked ({nb_iter}) has been reached") | ||
1085 | + break | ||
1086 | + self.__main_loop(nb_iter,FOR_REAL) | ||
1087 | + self.__iter_num += 1 | ||
1088 | + #if not self.DO_MAIN_LOOP: break | ||
1089 | + | ||
1090 | + # TEST mode only | ||
1091 | + self.__TEST_test_results() | ||
1092 | + #if self._DO_EXIT: exit(0) | ||
1109 | 1093 | ||
1110 | 1094 | ||
1111 | def __main_loop(self, nb_iter:int=None, FOR_REAL:bool=True): | 1095 | def __main_loop(self, nb_iter:int=None, FOR_REAL:bool=True): |
@@ -1204,26 +1188,53 @@ class Agent: | @@ -1204,26 +1188,53 @@ class Agent: | ||
1204 | 1188 | ||
1205 | self.__main_loop_end() | 1189 | self.__main_loop_end() |
1206 | 1190 | ||
1207 | - self._iter_num += 1 | ||
1208 | 1191 | ||
1209 | 1192 | ||
1210 | 1193 | ||
1194 | + def __cleanup_before_exit(self, stopper_agent_name:str=None): | ||
1195 | + if not stopper_agent_name: stopper_agent_name = self.name | ||
1196 | + #self._set_status(self.STATUS_EXIT) | ||
1197 | + ##self._log_agent_state() | ||
1198 | + | ||
1199 | + log.info("Trying to stop cleanly") | ||
1200 | + log.info("Before exiting, Here are (if exists) the current (still) pending commands (time ordered) :") | ||
1201 | + #commands = AgentCmd.get_commands_sent_to_agent(self.name) | ||
1202 | + commands = AgentCmd.get_pending_and_running_commands_for_agent(self.name) | ||
1203 | + AgentCmd.show_commands(commands, True) | ||
1204 | + ##self.do_flush_commands() | ||
1205 | + #if self.TEST_MODE and self.TEST_WITH_FINAL_TEST and self.TEST_COMMANDS_DEST == "myself": self.simulator_test_results() | ||
1206 | + if self.TEST_MODE and self.TEST_WITH_FINAL_TEST: | ||
1207 | + self.__TEST_test_results() | ||
1208 | + #self._DO_EXIT=True | ||
1209 | + #exit(0) | ||
1210 | + | ||
1211 | + self._do_things_before_exit(stopper_agent_name) | ||
1212 | + ##self._set_and_log_status(self.AGT_STATUS.EXITING) | ||
1213 | + | ||
1214 | + #def _kill_running_device_cmd_if_exists(self, abort_cmd_sender): | ||
1215 | + # to be overriden by subclass | ||
1216 | + def _do_things_before_exit(self, stopper_agent_name:str=None): | ||
1217 | + pass | ||
1218 | + | ||
1219 | + | ||
1211 | def __main_loop_start(self, nb_iter:int=None): | 1220 | def __main_loop_start(self, nb_iter:int=None): |
1212 | 1221 | ||
1213 | for i in range(3): print() | 1222 | for i in range(3): print() |
1214 | #self.printd("-"*80) | 1223 | #self.printd("-"*80) |
1215 | log.info("*"*90) | 1224 | log.info("*"*90) |
1216 | - log.info("*"*20 + f" {self.name} : MAIN LOOP ITERATION {self._iter_num} (START) " + "*"*20) | 1225 | + log.info("*"*20 + f" {self.name} : MAIN LOOP ITERATION #{self.__iter_num} (START) " + "*"*20) |
1217 | log.info("*"*90 + '\n') | 1226 | log.info("*"*90 + '\n') |
1218 | #self.print(f"Iteration {self._iter_num}") | 1227 | #self.print(f"Iteration {self._iter_num}") |
1219 | 1228 | ||
1229 | + ''' | ||
1220 | # EXIT because of nb of iterations ? | 1230 | # EXIT because of nb of iterations ? |
1221 | if nb_iter is not None: | 1231 | if nb_iter is not None: |
1222 | # Bad number of iterations or nb iterations reached => exit | 1232 | # Bad number of iterations or nb iterations reached => exit |
1223 | - if nb_iter <= 0 or nb_iter < self._iter_num: | 1233 | + if nb_iter <= 0 or nb_iter < self.__iter_num: |
1224 | log.info(f"Exit because number of iterations asked ({nb_iter}) has been reached") | 1234 | log.info(f"Exit because number of iterations asked ({nb_iter}) has been reached") |
1225 | self.DO_MAIN_LOOP = False | 1235 | self.DO_MAIN_LOOP = False |
1226 | return | 1236 | return |
1237 | + ''' | ||
1227 | 1238 | ||
1228 | # Temporizing (delay) : Wait a random number of sec before starting iteration | 1239 | # Temporizing (delay) : Wait a random number of sec before starting iteration |
1229 | # (to avoid to busy to much the processor) | 1240 | # (to avoid to busy to much the processor) |
@@ -1552,7 +1563,7 @@ class Agent: | @@ -1552,7 +1563,7 @@ class Agent: | ||
1552 | # | 1563 | # |
1553 | 1564 | ||
1554 | def get_state(self): | 1565 | def get_state(self): |
1555 | - return f"MODE is {self.__get_mode()} ; STATUS is {self.get_status()} ; ITERATION #{self._iter_num}" | 1566 | + return f"MODE is {self.__get_mode()} ; STATUS is {self.get_status()} ; ITERATION #{self.__iter_num}" |
1556 | 1567 | ||
1557 | def show_state(self): | 1568 | def show_state(self): |
1558 | log.info(self.get_state()) | 1569 | log.info(self.get_state()) |
@@ -1824,7 +1835,7 @@ class Agent: | @@ -1824,7 +1835,7 @@ class Agent: | ||
1824 | #self._agent_survey = AgentSurvey.objects.get(name=self.name) | 1835 | #self._agent_survey = AgentSurvey.objects.get(name=self.name) |
1825 | self.__agent_survey.mode = self.__get_mode() | 1836 | self.__agent_survey.mode = self.__get_mode() |
1826 | self.__agent_survey.status = self.get_status() | 1837 | self.__agent_survey.status = self.get_status() |
1827 | - self.__agent_survey.iteration = self._iter_num | 1838 | + self.__agent_survey.iteration = self.__iter_num |
1828 | self.__agent_survey.save() | 1839 | self.__agent_survey.save() |
1829 | #self._agent_survey.save(update_fields=["mode", "status"]) | 1840 | #self._agent_survey.save(update_fields=["mode", "status"]) |
1830 | 1841 |
src/core/pyros_django/agent/AgentA.py
@@ -77,8 +77,8 @@ class AgentA(Agent): | @@ -77,8 +77,8 @@ class AgentA(Agent): | ||
77 | self._log.print("init done") | 77 | self._log.print("init done") |
78 | 78 | ||
79 | # @override | 79 | # @override |
80 | - def init(self): | ||
81 | - super().init() | 80 | + def _init(self): |
81 | + super()._init() | ||
82 | # --- Set the mode according the startmode value | 82 | # --- Set the mode according the startmode value |
83 | ##agent_alias = self.__class__.__name__ | 83 | ##agent_alias = self.__class__.__name__ |
84 | ##self.set_mode_from_config(agent_alias) | 84 | ##self.set_mode_from_config(agent_alias) |
src/core/pyros_django/agent/AgentB.py
@@ -62,8 +62,8 @@ class AgentB(Agent): | @@ -62,8 +62,8 @@ class AgentB(Agent): | ||
62 | self._log.print("init done") | 62 | self._log.print("init done") |
63 | 63 | ||
64 | # @override | 64 | # @override |
65 | - def init(self): | ||
66 | - super().init() | 65 | + def _init(self): |
66 | + super()._init() | ||
67 | # --- Set the mode according the startmode value | 67 | # --- Set the mode according the startmode value |
68 | ##agent_alias = self.__class__.__name__ | 68 | ##agent_alias = self.__class__.__name__ |
69 | ##self.set_mode_from_config(agent_alias) | 69 | ##self.set_mode_from_config(agent_alias) |
src/core/pyros_django/agent/AgentBasic.py
@@ -47,7 +47,7 @@ class AgentBasic(Agent): | @@ -47,7 +47,7 @@ class AgentBasic(Agent): | ||
47 | # on DEV | 47 | # on DEV |
48 | #COMMIT_ONLY = False | 48 | #COMMIT_ONLY = False |
49 | # on commit only | 49 | # on commit only |
50 | - COMMIT_ONLY = False | 50 | + COMMIT_ONLY = True |
51 | 51 | ||
52 | # @override | 52 | # @override |
53 | _TEST_COMMANDS_LIST = [ | 53 | _TEST_COMMANDS_LIST = [ |
src/core/pyros_django/agent/AgentC.py
@@ -84,8 +84,8 @@ class AgentC(Agent): | @@ -84,8 +84,8 @@ class AgentC(Agent): | ||
84 | ###self._log.print("init done") | 84 | ###self._log.print("init done") |
85 | 85 | ||
86 | # @override | 86 | # @override |
87 | - def init(self): | ||
88 | - super().init() | 87 | + def _init(self): |
88 | + super()._init() | ||
89 | # --- Set the mode according the startmode value | 89 | # --- Set the mode according the startmode value |
90 | ##agent_alias = self.__class__.__name__ | 90 | ##agent_alias = self.__class__.__name__ |
91 | ##self.set_mode_from_config(agent_alias) | 91 | ##self.set_mode_from_config(agent_alias) |
src/core/pyros_django/agent/AgentDevice.py
@@ -205,9 +205,9 @@ class AgentDevice(Agent): | @@ -205,9 +205,9 @@ class AgentDevice(Agent): | ||
205 | pass | 205 | pass |
206 | 206 | ||
207 | # @override | 207 | # @override |
208 | - def init(self): | 208 | + def _init(self): |
209 | 209 | ||
210 | - super().init() | 210 | + super()._init() |
211 | # --- Set the mode according the startmode value | 211 | # --- Set the mode according the startmode value |
212 | ##agent_alias = self.__class__.__name__ | 212 | ##agent_alias = self.__class__.__name__ |
213 | ##self.set_mode_from_config(agent_alias) | 213 | ##self.set_mode_from_config(agent_alias) |
@@ -307,7 +307,7 @@ class AgentDevice(Agent): | @@ -307,7 +307,7 @@ class AgentDevice(Agent): | ||
307 | def is_device_level_cmd(self, cmd: AgentCmd): | 307 | def is_device_level_cmd(self, cmd: AgentCmd): |
308 | return self._device_ctrl.is_valid_cmd(DeviceCmd(cmd.full_name)) | 308 | return self._device_ctrl.is_valid_cmd(DeviceCmd(cmd.full_name)) |
309 | 309 | ||
310 | - def process_device_level_cmd(self): | 310 | + def _process_device_level_cmd(self): |
311 | log.info("(DEVICE LEVEL CMD)") | 311 | log.info("(DEVICE LEVEL CMD)") |
312 | try: | 312 | try: |
313 | self.exec_device_cmd_if_possible(cmd) | 313 | self.exec_device_cmd_if_possible(cmd) |
@@ -331,7 +331,7 @@ class AgentDevice(Agent): | @@ -331,7 +331,7 @@ class AgentDevice(Agent): | ||
331 | # @override superclass (Agent) method | 331 | # @override superclass (Agent) method |
332 | def exec_device_cmd_if_possible(self, cmd:AgentCmd): | 332 | def exec_device_cmd_if_possible(self, cmd:AgentCmd): |
333 | 333 | ||
334 | - self._set_status(self.STATUS_SPECIFIC_PROCESS) | 334 | + self.__set_status(self.STATUS_SPECIFIC_PROCESS) |
335 | #self.print(f"Starting execution of a DEVICE cmd {cmd}") | 335 | #self.print(f"Starting execution of a DEVICE cmd {cmd}") |
336 | self.print("Starting execution of a DEVICE cmd...") | 336 | self.print("Starting execution of a DEVICE cmd...") |
337 | self.printd(cmd) | 337 | self.printd(cmd) |
@@ -421,7 +421,7 @@ class AgentDevice(Agent): | @@ -421,7 +421,7 @@ class AgentDevice(Agent): | ||
421 | 421 | ||
422 | 422 | ||
423 | # @override superclass (Agent) | 423 | # @override superclass (Agent) |
424 | - def TEST_test_results_other(self, commands): | 424 | + def _TEST_test_results_other(self, commands): |
425 | # (EP) moved from Agent | 425 | # (EP) moved from Agent |
426 | # Now test that any "AD get_xx" following a "AD set_xx value" command has result = value | 426 | # Now test that any "AD get_xx" following a "AD set_xx value" command has result = value |
427 | for i,cmd_set in enumerate(commands): | 427 | for i,cmd_set in enumerate(commands): |
@@ -435,7 +435,7 @@ class AgentDevice(Agent): | @@ -435,7 +435,7 @@ class AgentDevice(Agent): | ||
435 | 435 | ||
436 | 436 | ||
437 | # @override parent class (Agent) | 437 | # @override parent class (Agent) |
438 | - def do_things_before_exit(self, abort_cmd_sender): | 438 | + def _do_things_before_exit(self, abort_cmd_sender): |
439 | self._kill_running_device_cmd_if_exists(abort_cmd_sender) | 439 | self._kill_running_device_cmd_if_exists(abort_cmd_sender) |
440 | 440 | ||
441 | def _kill_running_device_cmd_if_exists(self, abort_cmd_sender): | 441 | def _kill_running_device_cmd_if_exists(self, abort_cmd_sender): |
src/core/pyros_django/agent/AgentDeviceGemini.py
@@ -102,8 +102,8 @@ class AgentDeviceGemini(AgentDevice): | @@ -102,8 +102,8 @@ class AgentDeviceGemini(AgentDevice): | ||
102 | ##self._log.self.printd(f"init done for {name}") | 102 | ##self._log.self.printd(f"init done for {name}") |
103 | 103 | ||
104 | 104 | ||
105 | - def init(self): | ||
106 | - super().init() | 105 | + def _init(self): |
106 | + super()._init() | ||
107 | # Telescope (long) init | 107 | # Telescope (long) init |
108 | # TODO: | 108 | # TODO: |
109 | 109 |
src/core/pyros_django/agent/AgentDeviceSBIG.py
@@ -101,8 +101,8 @@ class AgentDeviceSBIG(AgentDevice): | @@ -101,8 +101,8 @@ class AgentDeviceSBIG(AgentDevice): | ||
101 | ##self._log.self.printd(f"init done for {name}") | 101 | ##self._log.self.printd(f"init done for {name}") |
102 | 102 | ||
103 | 103 | ||
104 | - def init(self): | ||
105 | - super().init() | 104 | + def _init(self): |
105 | + super()._init() | ||
106 | # Telescope (long) init | 106 | # Telescope (long) init |
107 | # TODO: | 107 | # TODO: |
108 | 108 |
src/core/pyros_django/agent/AgentMultiRequester.py
@@ -293,8 +293,8 @@ class AgentMultiRequester(Agent): | @@ -293,8 +293,8 @@ class AgentMultiRequester(Agent): | ||
293 | self.printd(f"init done") | 293 | self.printd(f"init done") |
294 | 294 | ||
295 | # @override | 295 | # @override |
296 | - def init(self): | ||
297 | - super().init() | 296 | + def _init(self): |
297 | + super()._init() | ||
298 | # --- Set the mode according the startmode value | 298 | # --- Set the mode according the startmode value |
299 | ##agent_alias = self.__class__.__name__ | 299 | ##agent_alias = self.__class__.__name__ |
300 | ##self.set_mode_from_config(agent_alias) | 300 | ##self.set_mode_from_config(agent_alias) |
@@ -403,7 +403,7 @@ class AgentMultiRequester(Agent): | @@ -403,7 +403,7 @@ class AgentMultiRequester(Agent): | ||
403 | ''' | 403 | ''' |
404 | 404 | ||
405 | # @override | 405 | # @override |
406 | - def TEST_test_results_main(self, commands): | 406 | + def _TEST_test_results_main(self, commands): |
407 | #nb_asserted = super().simulator_test_results_main(commands) | 407 | #nb_asserted = super().simulator_test_results_main(commands) |
408 | nb_asserted = 0 | 408 | nb_asserted = 0 |
409 | ''' | 409 | ''' |
src/core/pyros_django/agent/AgentTelescopeRequester.py
@@ -78,8 +78,8 @@ class AgentTelescopeRequester(Agent): | @@ -78,8 +78,8 @@ class AgentTelescopeRequester(Agent): | ||
78 | self._log.print(f"init done") | 78 | self._log.print(f"init done") |
79 | 79 | ||
80 | # @override | 80 | # @override |
81 | - def init(self): | ||
82 | - super().init() | 81 | + def _init(self): |
82 | + super()._init() | ||
83 | # --- Set the mode according the startmode value | 83 | # --- Set the mode according the startmode value |
84 | ##agent_alias = self.__class__.__name__ | 84 | ##agent_alias = self.__class__.__name__ |
85 | ##self.set_mode_from_config(agent_alias) | 85 | ##self.set_mode_from_config(agent_alias) |
src/core/pyros_django/agent/AgentX.py
@@ -9,7 +9,7 @@ import sys | @@ -9,7 +9,7 @@ import sys | ||
9 | #from common.models import Command | 9 | #from common.models import Command |
10 | 10 | ||
11 | sys.path.append("..") | 11 | sys.path.append("..") |
12 | -from agent.Agent import Agent, extract_parameters | 12 | +from agent.Agent import Agent, __extract_parameters |
13 | 13 | ||
14 | 14 | ||
15 | 15 | ||
@@ -55,8 +55,8 @@ class AgentX(Agent): | @@ -55,8 +55,8 @@ class AgentX(Agent): | ||
55 | super().__init__(name, config_filename, RUN_IN_THREAD) | 55 | super().__init__(name, config_filename, RUN_IN_THREAD) |
56 | 56 | ||
57 | # @override | 57 | # @override |
58 | - def init(self): | ||
59 | - super().init() | 58 | + def _init(self): |
59 | + super()._init() | ||
60 | # --- Set the mode according the startmode value | 60 | # --- Set the mode according the startmode value |
61 | ##agent_alias = self.__class__.__name__ | 61 | ##agent_alias = self.__class__.__name__ |
62 | ##self.set_mode_from_config(agent_alias) | 62 | ##self.set_mode_from_config(agent_alias) |
@@ -168,7 +168,7 @@ if __name__ == "__main__": | @@ -168,7 +168,7 @@ if __name__ == "__main__": | ||
168 | # with process | 168 | # with process |
169 | #RUN_IN_THREAD=False | 169 | #RUN_IN_THREAD=False |
170 | 170 | ||
171 | - TEST_MODE, configfile = extract_parameters() | 171 | + TEST_MODE, configfile = __extract_parameters() |
172 | #agent = AgentX() | 172 | #agent = AgentX() |
173 | agent = AgentX("AgentX", configfile, RUN_IN_THREAD) | 173 | agent = AgentX("AgentX", configfile, RUN_IN_THREAD) |
174 | agent.setSimulatorMode(TEST_MODE) | 174 | agent.setSimulatorMode(TEST_MODE) |
src/core/pyros_django/agent/doc/AgentDevice_class_diag.pu deleted
@@ -1,46 +0,0 @@ | @@ -1,46 +0,0 @@ | ||
1 | - | ||
2 | -@startuml | ||
3 | - | ||
4 | -/' | ||
5 | -UML class Diagram : can be displayed with PlantUML (plugin for Eclipse or for PyCharm) | ||
6 | - | ||
7 | -PlantUML: | ||
8 | -- How to install : https://projects.irap.omp.eu/projects/pyros/wiki/Project_Development#PlantUML | ||
9 | -- Eclipse plugin : http://plantuml.com/eclipse | ||
10 | -- class diagrams : http://plantuml.com/class-diagram | ||
11 | -- sequence diagrams : http://plantuml.com/sequence-diagram | ||
12 | -- state diagrams : http://plantuml.com/state-diagram | ||
13 | -- Use Case diagrams : http://plantuml.com/use-case-diagram | ||
14 | -- OLD Activity diagrams : http://plantuml.com/activity-diagram-legacy | ||
15 | -- NEW Activity diagrams : http://plantuml.com/activity-diagram-beta | ||
16 | -- Pre-processing (include...) : http://plantuml.com/preprocessing | ||
17 | -- GANTT diagrams : http://plantuml.com/gantt-diagram | ||
18 | -- REAL WORLD EXAMPLES !!! : https://real-world-plantuml.com/ | ||
19 | -- For Python: | ||
20 | - - https://github.com/SamuelMarks/python-plantuml | ||
21 | - - https://pythonhosted.org/plantuml/ | ||
22 | - | ||
23 | -UML diagrams theory : https://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/index.html | ||
24 | -'/ | ||
25 | - | ||
26 | -title | ||
27 | -__**AgentDevice class diagram**__ | ||
28 | -end title | ||
29 | - | ||
30 | - | ||
31 | - | ||
32 | -/' Abstract Devices Controllers '/ | ||
33 | - | ||
34 | -Agent <|-- AgentDevice | ||
35 | -AgentDevice --> DeviceController | ||
36 | - | ||
37 | -AgentDevice <|-- AgentDeviceTelescopeGemini | ||
38 | -AgentDevice <|-- AgentDeviceSBIG | ||
39 | - | ||
40 | -AgentDeviceTelescopeGemini --> TelescopeGeminiController | ||
41 | -TelescopeGeminiController o-- TelescopeGeminiSimulator | ||
42 | - | ||
43 | -AgentDeviceSBIG --> SBIGController | ||
44 | -SBIGController o-- SBIGSimulator | ||
45 | - | ||
46 | -@enduml |
src/core/pyros_django/agent/doc/AgentDevice_sequence_diag.pu deleted
@@ -1,146 +0,0 @@ | @@ -1,146 +0,0 @@ | ||
1 | - | ||
2 | -@startuml | ||
3 | - | ||
4 | -' --- Agent SEQUENCE DIAGRAM (plantUML) --- | ||
5 | - | ||
6 | -' Syntax => http://plantuml.com/fr/sequence-diagram | ||
7 | - | ||
8 | -' What is the current version of PlantUML (and Java) used ? | ||
9 | -' startuml | ||
10 | -' version | ||
11 | -' enduml | ||
12 | - | ||
13 | - | ||
14 | -title | ||
15 | -__**AgentDevice Sequence Diagram (example with AgentDeviceSBIG)**__ | ||
16 | -<size:10><i>Version 19-11-2019</i></size> | ||
17 | - | ||
18 | -end title | ||
19 | -'(E. Pallier) | ||
20 | - | ||
21 | -autonumber | ||
22 | - | ||
23 | -/' 5 participants (actors) '/ | ||
24 | -participant AgentDeviceSBIG | ||
25 | -participant DC_SBIG | ||
26 | -participant Channel | ||
27 | -participant DCC as "DCC (DC_Filter, DC_Shutter, or DC_Sensor...)" | ||
28 | -participant SBIG as "DS_SBIG (or real SBIG DEVICE)" #red | ||
29 | - | ||
30 | - | ||
31 | -== _init_(config_filename) # <i>python __init_()</i> == | ||
32 | -'group NEW INSTANCE(config_filename) # (python init()) | ||
33 | - AgentDeviceSBIG --> AgentDeviceSBIG: Initializes superclass\n (AgentDevice and then Agent)\n with my config_filename,\n my DC class (i.e. DC_SBIG),\n my host and my port | ||
34 | - AgentDeviceSBIG --> AgentDeviceSBIG: (Agent:) self.config =\n ConfigPyros(config_filename) | ||
35 | - AgentDeviceSBIG --> AgentDeviceSBIG: (Agent:) _set_mode_from_config() | ||
36 | -'end | ||
37 | - | ||
38 | -'group run() # <i>infinite loop</i> | ||
39 | - | ||
40 | -== run() # <i>infinite loop</i>== | ||
41 | - | ||
42 | - == run.init() == | ||
43 | - 'group init() | ||
44 | - 'create DC_SBIG | ||
45 | - AgentDeviceSBIG --> DC_SBIG** : Create instance of my DC\n with my host and port | ||
46 | - DC_SBIG --> DC_SBIG: initializes superclass\n (DeviceController) with\n my channel_type, protocol,\n commands... | ||
47 | - 'create Channel | ||
48 | - DC_SBIG --> Channel** : (DeviceController:) my_channel =\n new Channel(channel_type, host, port) | ||
49 | - DC_SBIG --> SBIG** : (DeviceController, if simulator mode:)\n Launch simulator DS_SBIG in thread | ||
50 | - 'create DCC | ||
51 | - DC_SBIG --> DCC** : Create my dcc1, dcc2, ..., dccN instance(s) | ||
52 | - DCC --> DCC: Initializes my superclass\n (DeviceController) with\n given DC_SBIG my_channel,\n protocol, commands... | ||
53 | - AgentDeviceSBIG --> DC_SBIG: _connect_to_device() | ||
54 | - DC_SBIG --> Channel: _my_channel._connect_to_server() | ||
55 | - Channel --> SBIG: mysock.connect(HOST, PORT) | ||
56 | - 'end group init() | ||
57 | - | ||
58 | - == run.main_loop() # <i>infinite loop</i> == | ||
59 | - 'group main_loop() # <i>infinite loop</i> | ||
60 | - AgentDeviceSBIG --> AgentDeviceSBIG: _load_config() # reload only if changed | ||
61 | - AgentDeviceSBIG --> AgentDeviceSBIG: _log_agent_status() | ||
62 | - group routine_process() | ||
63 | - group get_device_status() # <i>DIRECT execution, NO THREAD (see details below in THREAD section)</i> | ||
64 | - AgentDeviceSBIG --> DC_SBIG: execute_cmd(ROUTINE_COMMAND) | ||
65 | - note left #aqua | ||
66 | - DIRECT execution, | ||
67 | - NO THREAD | ||
68 | - end note | ||
69 | - DC_SBIG --> SBIG: REQUEST | ||
70 | - ... | ||
71 | - 'DC_SBIG <-- SBIG: ANSWER | ||
72 | - return ANSWER | ||
73 | - AgentDeviceSBIG <-- DC_SBIG: ANSWER | ||
74 | - AgentDeviceSBIG --> AgentDeviceSBIG: Save status in DB | ||
75 | - end | ||
76 | - end | ||
77 | - | ||
78 | - | ||
79 | - group command_process_if_exists() | ||
80 | - alt if new COMMAND | ||
81 | - | ||
82 | - alt AGENT LEVEL COMMAND (i.e. Agent level, immediate short execution, GENERAL or SPECIFIC) | ||
83 | - AgentDeviceSBIG --> AgentDeviceSBIG: _exec_agent_cmd(cmd) | ||
84 | - | ||
85 | - else DEVICE LEVEL COMMAND (i.e. DC level, execution will be in thread) | ||
86 | - | ||
87 | - group exec_device_cmd_if_possible() | ||
88 | - | ||
89 | - alt AgentDevice is IDLE => SKIP command (ignored) | ||
90 | - | ||
91 | - else A device command is already running in a thread => do not execute COMMAND for now (try again at next iteration) | ||
92 | - | ||
93 | - else COMMAND is not implemented => UnimplementedGenericCmdException | ||
94 | - | ||
95 | - else ELSE => RUN COMMAND in a THREAD (running _thread_exec_device_cmd() which runs exec_device_cmd(COMMAND)) | ||
96 | - AgentDeviceSBIG --> DC_SBIG: execute_cmd(COMMAND) | ||
97 | - note left #aqua | ||
98 | - EXECUTION | ||
99 | - IN A THREAD | ||
100 | - end note | ||
101 | - | ||
102 | - /' in DC_SBIG : '/ | ||
103 | - autonumber stop | ||
104 | - alt NATIVE COMMAND (i.e. SBIG grammar) | ||
105 | - group execute_native_cmd(COMMAND) | ||
106 | - DC_SBIG --> SBIG: REQUEST | ||
107 | - 'DC_SBIG <-- SBIG: ANSWER | ||
108 | - return ANSWER | ||
109 | - end group | ||
110 | - | ||
111 | - else GENERIC COMMAND (i.e. PYROS grammar) | ||
112 | - group execute_generic_cmd(COMMAND) | ||
113 | - alt COMMAND is GENERAL (i.e. DC_SBIG level) | ||
114 | - DC_SBIG --> SBIG: REQUEST | ||
115 | - 'DC_SBIG <-- SBIG: ANSWER | ||
116 | - return ANSWER | ||
117 | - else COMMAND is SPECIFIC (i.e. for one of my dcc's, ex: DC_Filter) | ||
118 | - DC_SBIG --> DCC: execute_generic_cmd(COMMAND) | ||
119 | - DCC --> SBIG: REQUEST | ||
120 | - 'DCC <-- SBIG: ANSWER | ||
121 | - return ANSWER | ||
122 | - DC_SBIG <-- DCC: ANSWER | ||
123 | - end alt | ||
124 | - end group | ||
125 | - | ||
126 | - end alt NATIVE or GENERIC ? | ||
127 | - | ||
128 | - AgentDeviceSBIG <-- DC_SBIG: ANSWER | ||
129 | - | ||
130 | - end group RUN COMMAND in a THREAD | ||
131 | - | ||
132 | - end group exec_device_cmd_if_possible() | ||
133 | - | ||
134 | - else BAD COMMAND => COMMAND is ignored | ||
135 | - | ||
136 | - end alt GENERAL or SPECIFIC ? | ||
137 | - | ||
138 | - end alt new COMMAND ? | ||
139 | - end group command_process_if_exists() | ||
140 | - | ||
141 | - 'end group main_loop() | ||
142 | - | ||
143 | -'end group run() | ||
144 | - | ||
145 | - | ||
146 | -@enduml |
src/core/pyros_django/agent/doc/Agent_activity_diag_SIMPLE.pu
0 โ 100644
@@ -0,0 +1,109 @@ | @@ -0,0 +1,109 @@ | ||
1 | + | ||
2 | +@startuml | ||
3 | + | ||
4 | + | ||
5 | +' --- Agent & AgentDevice ACTIVIY DIAGRAM (plantUML) --- | ||
6 | + | ||
7 | +' NEW syntax => http://plantuml.com/fr/activity-diagram-beta | ||
8 | +' OLD syntax => http://plantuml.com/fr/activity-diagram-legacy | ||
9 | +' (See also https://plantweb.readthedocs.io) | ||
10 | +' (See also https://pythonhosted.org/plantuml) | ||
11 | + | ||
12 | +' What is the current version of PlantUML (and Java) used ? | ||
13 | +' startuml | ||
14 | +' version | ||
15 | +' enduml | ||
16 | + | ||
17 | +' Exemple de skin utilisable (celui de ChemCam) : | ||
18 | +' skinparam activity { | ||
19 | +' StartColor red | ||
20 | +' EndColor Silver | ||
21 | +' BackgroundColor Peru | ||
22 | +' BackgroundColor<< Begin >> Olive | ||
23 | +' BorderColor Peru | ||
24 | +' FontName Impact | ||
25 | +' } | ||
26 | + | ||
27 | +title | ||
28 | +__**Agent (Activity Diagram, simplified)**__ | ||
29 | +<size:10><i>Version 03-10-2022 (E. Pallier)</i></size> | ||
30 | + | ||
31 | +end title | ||
32 | + | ||
33 | + | ||
34 | +'|Agent| | ||
35 | +start | ||
36 | + | ||
37 | +skinparam LegendBackgroundColor yellow | ||
38 | +skinparam LegendBorderColor red | ||
39 | +legend top right | ||
40 | + Every important step is logged in database, | ||
41 | + with these information : | ||
42 | + mode, status, and #iteration | ||
43 | +endlegend | ||
44 | + | ||
45 | + | ||
46 | + | ||
47 | + | ||
48 | +:RESTART = False; | ||
49 | +note right | ||
50 | + By default, do not restart | ||
51 | +end note | ||
52 | + | ||
53 | +repeat | ||
54 | + :load_config(); | ||
55 | + :init(); | ||
56 | + :MAIN_LOOP = True; | ||
57 | + note right | ||
58 | + By default, redo main loop | ||
59 | + end note | ||
60 | + repeat | ||
61 | + partition main_loop() { | ||
62 | + :reload_config_if_changed(); | ||
63 | + ':log_agent_status(); | ||
64 | + 'note right | ||
65 | + ' Log this agent state in DB : (mode, status, and #iteration) | ||
66 | + 'end note | ||
67 | + | ||
68 | + '#green:routine_process_before(); | ||
69 | + :**routine_process_before()**; | ||
70 | + note right | ||
71 | + Only if NOT in IDLE mode | ||
72 | + Only if previous routine_process_before() finished | ||
73 | + Only if routine_process_after() finished (can be run in parallel) | ||
74 | + end note | ||
75 | + | ||
76 | + :**exec_next_valid_cmd_if_exists()**; | ||
77 | + note right | ||
78 | + Only if new command received | ||
79 | + Only if previous command finished (can be run in parallel) | ||
80 | + Command can be of 3 types : | ||
81 | + - Agent General cmd : always executed (sequential exec) | ||
82 | + - Agent Specific cmd : only executed if in ATTENTIVE mode | ||
83 | + - Other cmd (device) : only executed if in ATTENTIVE mode | ||
84 | + Exceptions can be raised : CmdInvalid, CmdUnimplemented, CmdExecError, CmdExecTimeout | ||
85 | + end note | ||
86 | + | ||
87 | + 'if (DO_RESTART or DO_STOP ?) then (yes) | ||
88 | + ' :MAIN_LOOP = False; | ||
89 | + ' if (DO_RESTART ?) then (yes) | ||
90 | + ' :RESTART = True; | ||
91 | + ' endif | ||
92 | + 'else (no) | ||
93 | + '#green:process_routine_after(); | ||
94 | + :**process_routine_after()**; | ||
95 | + note right | ||
96 | + Only if NOT in IDLE mode | ||
97 | + Only if previous process_routine_after() finished | ||
98 | + Only if routine_process_before() finished (can be run in parallel) | ||
99 | + (not executed if cmd was STOP or RESTART, or if exception occurred) | ||
100 | + end note | ||
101 | + 'endif | ||
102 | + | ||
103 | + } | ||
104 | + repeat while (MAIN_LOOP ?) is (yes) not (no) | ||
105 | +repeat while (RESTART ?) is (yes) not (no) | ||
106 | + | ||
107 | +stop | ||
108 | + | ||
109 | +@enduml |
src/core/pyros_django/common/doc/models_Command_state_diag.pu
1 | 1 | ||
2 | -@startuml | 2 | +@startuml Command state diagram |
3 | 3 | ||
4 | ' --- Command STATE DIAGRAM --- | 4 | ' --- Command STATE DIAGRAM --- |
5 | ' (see http://plantuml.com/fr/state-diagram) | 5 | ' (see http://plantuml.com/fr/state-diagram) |
6 | 6 | ||
7 | title | 7 | title |
8 | __**models.Command class : State Diagram**__ | 8 | __**models.Command class : State Diagram**__ |
9 | +<i>Version : 13/09/2022 (EP)</i> | ||
9 | 10 | ||
10 | end title | 11 | end title |
11 | 12 | ||
12 | -[*] --> PENDING : **created by sender** | 13 | +[*] --> CMD_PENDING : ** cmd created by sender** |
13 | 14 | ||
14 | ' --- (1) PENDING --- | 15 | ' --- (1) PENDING --- |
15 | -PENDING: + s_deposit_time \n+ r_read_time | ||
16 | -PENDING --> RUNNING : **launched** | ||
17 | -PENDING --> SKIPPED: **recipient is IDLE** | ||
18 | -PENDING --> EXPIRED: **command is too old** | ||
19 | -PENDING --> INVALIDATED: **cancelled by sender** | 16 | +CMD_PENDING: + s_deposit_time \n+ r_read_time |
20 | 17 | ||
21 | -' --- (2) RUNNING, SKIPPED, or EXPIRED --- | ||
22 | -RUNNING: + r_start_time | ||
23 | -RUNNING --> EXECUTED : **finished** | ||
24 | -RUNNING --> KILLED: \l**aborted** \n(by sender or other allowed agent, \nwith command "abort" or "exit") | 18 | +' Normal case |
19 | +CMD_PENDING --> CMD_RUNNING : **launched** | ||
25 | 20 | ||
26 | -SKIPPED: + end_time | ||
27 | -SKIPPED --> [*] | 21 | +' Exception cases |
22 | +CMD_PENDING --> CMD_INVALID : **invalid cmd** \n(unknown or bad args) | ||
23 | +CMD_PENDING --> CMD_UNIMPLEMENTED : **cmd known but**\n **not implemented** | ||
24 | +CMD_PENDING --> CMD_SKIPPED: **recipient agent**\n **is IDLE** | ||
25 | +CMD_PENDING --> CMD_EXPIRED: **cmd is expired** \n(no more valid) | ||
28 | 26 | ||
29 | -EXPIRED --> [*] | ||
30 | -EXPIRED: + end_time \n+ killer_agent_name | 27 | +CMD_INVALID: + r_end_time |
28 | +CMD_INVALID --> [*] | ||
31 | 29 | ||
32 | -INVALIDATED --> [*] | ||
33 | -INVALIDATED: + end_time \n+ killer_agent_name | 30 | +CMD_UNIMPLEMENTED: + r_end_time |
31 | +CMD_UNIMPLEMENTED --> [*] | ||
34 | 32 | ||
35 | -' --- (3) PROCESSED or KILLED --- | ||
36 | -EXECUTED: + end_time | ||
37 | -EXECUTED --> [*] | 33 | +CMD_SKIPPED: + r_end_time |
34 | +CMD_SKIPPED --> [*] | ||
38 | 35 | ||
39 | -KILLED --> [*] | ||
40 | -KILLED: + end_time \n+ killer_agent_name | 36 | +CMD_EXPIRED: + r_end_time |
37 | +CMD_EXPIRED --> [*] | ||
38 | + | ||
39 | + | ||
40 | +' --- (2) RUNNING --- | ||
41 | +CMD_RUNNING: + r_start_time | ||
42 | +CMD_RUNNING --> CMD_EXECUTED : **(OK)**\n **finished** | ||
43 | +CMD_RUNNING --> CMD_EXEC_ERROR : **(KO)**\n **execution error** | ||
44 | +CMD_RUNNING --> CMD_EXEC_TIMEOUT : **(KO)**\n **execution timeout** | ||
45 | +CMD_RUNNING --> CMD_EXEC_KILLED: \l**(KO)**\n **aborted (by other agent)** \n (with "do_stop_current cmd" or "do_stop now") | ||
46 | + | ||
47 | +' --- PROCESSED or interrupted --- | ||
48 | +CMD_EXECUTED: + r_end_time | ||
49 | +CMD_EXECUTED --> [*] | ||
50 | + | ||
51 | +CMD_EXEC_ERROR : + r_end_time | ||
52 | +CMD_EXEC_ERROR --> [*] | ||
53 | + | ||
54 | +CMD_EXEC_TIMEOUT : + r_end_time | ||
55 | +CMD_EXEC_TIMEOUT --> [*] | ||
56 | + | ||
57 | +CMD_EXEC_KILLED: + r_end_time \n+ killer_agent_name | ||
58 | +CMD_EXEC_KILLED --> [*] | ||
41 | 59 | ||
42 | @enduml | 60 | @enduml |
src/core/pyros_django/routine_manager/doc/ObservationSequence_SO_state_diag.pu
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | 6 | ||
7 | title | 7 | title |
8 | __**Observation Sequence (SO) - State Diagram**__ | 8 | __**Observation Sequence (SO) - State Diagram**__ |
9 | -<size:10><i>Version 7-2-2022 (E. Pallier)</i></size> | 9 | +<size:10><i>Version 9-2-2022 (E. Pallier)</i></size> |
10 | 10 | ||
11 | end title | 11 | end title |
12 | 12 | ||
@@ -47,11 +47,10 @@ TBP --> SF07_PLN | @@ -47,11 +47,10 @@ TBP --> SF07_PLN | ||
47 | 47 | ||
48 | state SF07_PLN as "SF07-PLN - Observation Sequence Planning" #cyan | 48 | state SF07_PLN as "SF07-PLN - Observation Sequence Planning" #cyan |
49 | state PLND as "PLANNED (PLND)": planned for current/coming night | 49 | state PLND as "PLANNED (PLND)": planned for current/coming night |
50 | -state UNPL as "UNPLANNABLE (UNPL)": unplannable \n neither for current/coming night\n neither for next one | 50 | +state UNPL as "UNPLANNABLE (UNPL)": unplannable for current/coming night |
51 | state End_SF07 <<end>> | 51 | state End_SF07 <<end>> |
52 | 52 | ||
53 | -SF07_PLN --> SF07_PLN: **PLAN/SCHEDULE** \n<i>(unplannable for current/coming night, \n <i>but ok for next one) | ||
54 | -SF07_PLN --> UNPL: **PLAN/SCHEDULE** | 53 | +SF07_PLN --> UNPL |
55 | UNPL --> End_SF07 | 54 | UNPL --> End_SF07 |
56 | SF07_PLN --> PLND: **PLAN/SCHEDULE** | 55 | SF07_PLN --> PLND: **PLAN/SCHEDULE** |
57 | 56 | ||
@@ -65,14 +64,14 @@ PLND --> SF08_EXE | @@ -65,14 +64,14 @@ PLND --> SF08_EXE | ||
65 | '/ | 64 | '/ |
66 | 65 | ||
67 | state SF08_EXE as "SF08-EXE - Observation Sequence Execution" #cyan | 66 | state SF08_EXE as "SF08-EXE - Observation Sequence Execution" #cyan |
68 | -state E_RUN as "REC_DOING (R_RUN)": Sequence exec running... | 67 | +state E_RUN as "REC_RUNNING (R_RUN)": Sequence exec running... |
69 | state E_CCLD as "REC_STOPPED (R_CCLD)": Sequence exec cancelled | 68 | state E_CCLD as "REC_STOPPED (R_CCLD)": Sequence exec cancelled |
70 | -state E_END as "REC_DONE (R_END)": Sequence exec finished | 69 | +state E_END as "REC_FINISHED (R_END)": Sequence exec finished |
71 | state can_exec <<choice>> | 70 | state can_exec <<choice>> |
72 | 71 | ||
73 | SF08_EXE -d-> can_exec | 72 | SF08_EXE -d-> can_exec |
74 | can_exec --> E_RUN: [can be executed]\n **EXEC** | 73 | can_exec --> E_RUN: [can be executed]\n **EXEC** |
75 | -can_exec --> TBP: [can't be executed] \n <i>(too late or \n <i>observing conditions not met) | 74 | +can_exec --> TBP: [can't be executed] \n <i>(too late or \n <i>observing conditions \n not good enough) |
76 | 75 | ||
77 | E_RUN --> E_CCLD: **exec cancelled** | 76 | E_RUN --> E_CCLD: **exec cancelled** |
78 | E_CCLD --> TBP: **go back to planning**\n <i>(don't keep incomplete Sequence) | 77 | E_CCLD --> TBP: **go back to planning**\n <i>(don't keep incomplete Sequence) |
@@ -88,16 +87,12 @@ E_END --> SF11_IPC | @@ -88,16 +87,12 @@ E_END --> SF11_IPC | ||
88 | '/ | 87 | '/ |
89 | 88 | ||
90 | state SF11_IPC as "SF11-IPC - Sequence Images ProCessing" #cyan | 89 | state SF11_IPC as "SF11-IPC - Sequence Images ProCessing" #cyan |
91 | -state P_RUN as "PROC_DOING (P_RUN)": Sequence process running... | ||
92 | -state P_STOP as "PROC_STOPPED (P_STOP)": Sequence process temporarily stopped | ||
93 | -state P_CCLD as "PROC_CANCELLED (P_CCLD)": Sequence process definitively cancelled/aborted | ||
94 | -state P_END as "PROC_DONE (P_END)": Sequence process finished | ||
95 | -state End_SF11 <<end>> | 90 | +state P_RUN as "PROC_RUNNING (P_RUN)": Sequence process running... |
91 | +state P_STOP as "PROC_STOPPED (P_STOP)": Sequence process stopped | ||
92 | +state P_END as "PROC_FINISHED (P_END)": Sequence process finished | ||
96 | 93 | ||
97 | SF11_IPC --> P_RUN: **PROCESS** | 94 | SF11_IPC --> P_RUN: **PROCESS** |
98 | 95 | ||
99 | -P_RUN --> P_CCLD: **process cancelled** | ||
100 | -P_CCLD --> End_SF11 | ||
101 | P_RUN --> P_STOP: **process stopped** | 96 | P_RUN --> P_STOP: **process stopped** |
102 | P_STOP --> E_END | 97 | P_STOP --> E_END |
103 | P_RUN --> P_END: **process finished** | 98 | P_RUN --> P_END: **process finished** |
@@ -112,15 +107,11 @@ P_END --> SF12_IAN | @@ -112,15 +107,11 @@ P_END --> SF12_IAN | ||
112 | '/ | 107 | '/ |
113 | 108 | ||
114 | state SF12_IAN as "SF12-IAN - Sequence Images ANalysis" #cyan | 109 | state SF12_IAN as "SF12-IAN - Sequence Images ANalysis" #cyan |
115 | -state A_RUN as "ANL_DOING (A_RUN)": Sequence analysis running... | 110 | +state A_RUN as "ANL_RUNNING (A_RUN)": Sequence analysis running... |
116 | state A_STOP as "ANL_STOPPED (A_STOP)": Sequence analysis temporarily stopped | 111 | state A_STOP as "ANL_STOPPED (A_STOP)": Sequence analysis temporarily stopped |
117 | -state A_CCLD as "ANL_CANCELLED (A_CCLD)": Sequence analysis definitively cancelled/aborted | ||
118 | -state A_END as "ANL_DONE (A_END)": Sequence analysis finished | ||
119 | -state End_SF12 <<end>> | 112 | +state A_END as "ANL_FINISHED (A_END)": Sequence analysis finished |
120 | 113 | ||
121 | SF12_IAN --> A_RUN: **ANALYSE** | 114 | SF12_IAN --> A_RUN: **ANALYSE** |
122 | -A_RUN --> A_CCLD: **analysis cancelled** | ||
123 | -A_CCLD --> End_SF12 | ||
124 | A_RUN --> A_STOP: **process stopped** | 115 | A_RUN --> A_STOP: **process stopped** |
125 | A_STOP --> P_END | 116 | A_STOP --> P_END |
126 | A_RUN --> A_END: **analysis finished** | 117 | A_RUN --> A_END: **analysis finished** |
@@ -135,14 +126,11 @@ A_END --> SF13_IAF | @@ -135,14 +126,11 @@ A_END --> SF13_IAF | ||
135 | '/ | 126 | '/ |
136 | 127 | ||
137 | state SF13_IAF as "SF13-IAF - Sequence Images Archiving & Fetching" #cyan | 128 | state SF13_IAF as "SF13-IAF - Sequence Images Archiving & Fetching" #cyan |
138 | -state Z_RUN as "ZIP_DOING (Z_RUN)": Sequence archiving running... | 129 | +state Z_RUN as "ZIP_RUNNING (Z_RUN)": Sequence archiving running... |
139 | state Z_STOP as "ZIP_STOPPED (Z_STOP)": Sequence archiving temporarily stopped | 130 | state Z_STOP as "ZIP_STOPPED (Z_STOP)": Sequence archiving temporarily stopped |
140 | -state Z_CCLD as "ZIP_CANCELLED (Z_CCLD)": Sequence archiving definitively cancelled/aborted | ||
141 | -state Z_END as "ZIP_DONE (Z_END)": Sequence archiving finished | 131 | +state Z_END as "ZIP_FINISHED (Z_END)": Sequence archiving finished |
142 | 132 | ||
143 | SF13_IAF --> Z_RUN: **ARCHIVE** | 133 | SF13_IAF --> Z_RUN: **ARCHIVE** |
144 | -Z_RUN --> Z_CCLD: **archiving cancelled** | ||
145 | -Z_CCLD --> [*] | ||
146 | Z_RUN --> Z_STOP: **archiving stopped** | 134 | Z_RUN --> Z_STOP: **archiving stopped** |
147 | Z_STOP --> A_END | 135 | Z_STOP --> A_END |
148 | Z_RUN --> Z_END: **archiving finished** | 136 | Z_RUN --> Z_END: **archiving finished** |
src/device_controller/concrete_component/gemini/proof_of_concept_for_Protocol.py
@@ -63,10 +63,14 @@ class DCGem(DC): | @@ -63,10 +63,14 @@ class DCGem(DC): | ||
63 | self.dc1.encap() | 63 | self.dc1.encap() |
64 | 64 | ||
65 | 65 | ||
66 | -dcg = DCGem() | ||
67 | -print ("gem toto is", dcg.toto) | ||
68 | -print ("dc1 toto is", dcg.dc1.toto) | ||
69 | -#dcg.Protoc.encap(dcg) | ||
70 | -##dcg.encap() | 66 | +def main(): |
67 | + dcg = DCGem() | ||
68 | + print ("gem toto is", dcg.toto) | ||
69 | + print ("dc1 toto is", dcg.dc1.toto) | ||
70 | + #dcg.Protoc.encap(dcg) | ||
71 | + ##dcg.encap() | ||
71 | 72 | ||
72 | 73 | ||
74 | +if __name__ == "__main__": | ||
75 | + """Comment on Main function execution""" | ||
76 | + main() |
src/device_controller/concrete_component/gemini/proof_of_concept_for_logging/proof_of_concept_for_logging.py
@@ -70,14 +70,20 @@ def do_logs(): | @@ -70,14 +70,20 @@ def do_logs(): | ||
70 | 70 | ||
71 | # logger.debug(), info(), warning(), error(), critical() | 71 | # logger.debug(), info(), warning(), error(), critical() |
72 | 72 | ||
73 | -print("\nlevel is DEBUG:") | ||
74 | -logger.setLevel(logging.DEBUG) | ||
75 | -do_logs() | 73 | +def main(): |
74 | + print("\nlevel is DEBUG:") | ||
75 | + logger.setLevel(logging.DEBUG) | ||
76 | + do_logs() | ||
76 | 77 | ||
77 | -print("\nlevel is INFO:") | ||
78 | -logger.setLevel(logging.INFO) | ||
79 | -do_logs() | 78 | + print("\nlevel is INFO:") |
79 | + logger.setLevel(logging.INFO) | ||
80 | + do_logs() | ||
80 | 81 | ||
81 | -print("\nlevel is CRITICAL:") | ||
82 | -logger.setLevel(logging.CRITICAL) | ||
83 | -do_logs() | ||
84 | \ No newline at end of file | 82 | \ No newline at end of file |
83 | + print("\nlevel is CRITICAL:") | ||
84 | + logger.setLevel(logging.CRITICAL) | ||
85 | + do_logs() | ||
86 | + | ||
87 | + | ||
88 | +if __name__ == "__main__": | ||
89 | + """Comment on Main function execution""" | ||
90 | + main() |
src/device_controller/concrete_component/gemini/proof_of_concept_for_multi_inherit.py
@@ -74,16 +74,21 @@ class DCSBIG(DCGeneral, DC1,DC2,DC3): | @@ -74,16 +74,21 @@ class DCSBIG(DCGeneral, DC1,DC2,DC3): | ||
74 | print("DCSBIG toto") | 74 | print("DCSBIG toto") |
75 | 75 | ||
76 | 76 | ||
77 | -print(DCSBIG.mro()) | ||
78 | -#dc1 = DC1('toto') | ||
79 | -#dc1.print_name() | ||
80 | -#print(DCGem.__mro__) | ||
81 | -dcs = DCSBIG() | ||
82 | -dcs.print_name() | ||
83 | -print(dcs.a) | ||
84 | -print(dcs.b) | ||
85 | -dcs.printall() | ||
86 | - | ||
87 | -# DC1 goto | ||
88 | -#dcs.goto() | ||
89 | - | 77 | +def main(): |
78 | + print(DCSBIG.mro()) | ||
79 | + #dc1 = DC1('toto') | ||
80 | + #dc1.print_name() | ||
81 | + #print(DCGem.__mro__) | ||
82 | + dcs = DCSBIG() | ||
83 | + dcs.print_name() | ||
84 | + print(dcs.a) | ||
85 | + print(dcs.b) | ||
86 | + dcs.printall() | ||
87 | + | ||
88 | + # DC1 goto | ||
89 | + #dcs.goto() | ||
90 | + | ||
91 | + | ||
92 | +if __name__ == "__main__": | ||
93 | + """Comment on Main function execution""" | ||
94 | + main() |
src/device_controller/concrete_component/gemini/server_telescope_gemini_simulator_run.py
@@ -2,10 +2,12 @@ | @@ -2,10 +2,12 @@ | ||
2 | 2 | ||
3 | import sys | 3 | import sys |
4 | 4 | ||
5 | +##sys.path.append("..") | ||
6 | +sys.path.append("../..") | ||
5 | 7 | ||
6 | -sys.path.append("..") | 8 | +from channels.server_udp_or_tcp import get_SocketServer_UDP_TCP |
9 | +##from 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 | 10 | #from device_controller.concrete_component.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP |
8 | -from device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP | ||
9 | #from server.server_udp_or_tcp import get_SocketServer_UDP_TCP | 11 | #from server.server_udp_or_tcp import get_SocketServer_UDP_TCP |
10 | 12 | ||
11 | HOST, PORT = "localhost", 11110 | 13 | HOST, PORT = "localhost", 11110 |