Commit 02c126762fb9e1066675d434257d71131fe6e881

Authored by Etienne Pallier
1 parent a3b570b0
Exists in dev

Renamed Agent Status names

CHANGELOG
  1 +
  2 +07-11-2022 (EP): v0.6.7.3
  3 + - Renamed Agent Status names
  4 +
1 5 07-11-2022 (AKo): v0.6.7.2
2 6 - Improve agents commands view (add status filter)
3 7 - Add port configuration for phpmyadmin in docker-compose.yml
... ...
VERSION
1   -0.6.7.2
2 1 \ No newline at end of file
  2 +0.6.7.3
3 3 \ No newline at end of file
... ...
src/core/pyros_django/agent/Agent.py
... ... @@ -1072,7 +1072,7 @@ class Agent:
1072 1072  
1073 1073 def __main_loop(self, nb_iter:int=None, FOR_REAL:bool=True):
1074 1074  
1075   - self.__set_and_log_status(self.AGT_STATUS.IN_MAIN_LOOP)
  1075 + self.__set_and_log_status(self.AGT_STATUS.IN_MAIN_LOOP_START)
1076 1076  
1077 1077 self.__main_loop_start(nb_iter)
1078 1078 #if not self.DO_MAIN_LOOP: return
... ... @@ -1194,7 +1194,8 @@ class Agent:
1194 1194 log.info('-'*6 + "CMD finished WITH EXCEPTION ")
1195 1195 self.__process_exception(self.CCE)
1196 1196 self.__CCE = None
1197   - if self.is_in_test_mode():
  1197 + print("my name is", self.__CC.sender, self.__class__.__name__)
  1198 + if self.is_in_test_mode() and self.__CC.sender==self.__class__.__name__ :
1198 1199 self.__TEST_check_current_cmd_res_and_status()
1199 1200 #self.CC = None
1200 1201  
... ... @@ -1397,7 +1398,7 @@ class Agent:
1397 1398 def __start_cmd(self, cmd:AgentCmd)->None:
1398 1399 ''' Processing the next pending command (self.__CC) '''
1399 1400 #cmd = self.__CC
1400   - self.__set_and_log_status(self.AGT_STATUS.IN_GET_NEXT_CMD)
  1401 + self.__set_and_log_status(self.AGT_STATUS.IN_MAIN_LOOP_GET_NEXT_CMD)
1401 1402  
1402 1403 #print()
1403 1404 #print()
... ... @@ -1535,7 +1536,7 @@ class Agent:
1535 1536 print()
1536 1537 log.info("*"*10+ " ROUTINE BEFORE (START) "+ "*"*10+ '\n')
1537 1538  
1538   - self.__set_and_log_status(self.AGT_STATUS.IN_ROUTINE_BEF)
  1539 + self.__set_and_log_status(self.AGT_STATUS.IN_MAIN_LOOP_ROUTINE_BEFORE)
1539 1540 self._routine_process_before_body()
1540 1541  
1541 1542 print()
... ... @@ -1562,7 +1563,7 @@ class Agent:
1562 1563 print()
1563 1564 log.info("*"*10+ " ROUTINE AFTER (START) "+ "*"*10+ '\n')
1564 1565  
1565   - self.__set_and_log_status(self.AGT_STATUS.IN_ROUTINE_AFT)
  1566 + self.__set_and_log_status(self.AGT_STATUS.IN_MAIN_LOOP_ROUTINE_AFTER)
1566 1567 self._routine_process_after_body()
1567 1568  
1568 1569 print()
... ... @@ -2026,7 +2027,7 @@ class Agent:
2026 2027 OLD version was :
2027 2028 Return still VALID (not expired) command
2028 2029 """
2029   - self.__set_and_log_status(self.AGT_STATUS.IN_GET_NEXT_CMD)
  2030 + self.__set_and_log_status(self.AGT_STATUS.IN_MAIN_LOOP_GET_NEXT_CMD)
2030 2031 log.info("Looking for a new received command to process (sent by another agent):")
2031 2032  
2032 2033 # 1) Get all pending commands for me (return if None)
... ...
src/core/pyros_django/agent/doc/Agent_activity_diag_SIMPLE_async.pu
... ... @@ -24,6 +24,7 @@
24 24 ' FontName Impact
25 25 ' }
26 26  
  27 +
27 28 title
28 29 __**Agent activity diagram (simplified)**__
29 30 <size:10><i>Agent async v2 (run loop) - Version 28-10-2022 (E. Pallier)</i></size>
... ... @@ -34,8 +35,10 @@ end title
34 35 '|Agent|
35 36 start
36 37  
  38 +skinparam ConditionEndStyle hline
37 39 skinparam LegendBackgroundColor yellow
38 40 skinparam LegendBorderColor red
  41 +
39 42 legend top right
40 43 Every important step is logged in database,
41 44 with these information :
... ... @@ -71,14 +74,13 @@ repeat
71 74 'end note
72 75  
73 76 '#green:routine_process_before();
74   - :**routine_process_before()**;
  77 + #lightblue:**routine_process_before()**;
75 78 note right
76 79 Only if NOT in IDLE mode
77 80 Only if previous routine_process_after() finished (can be run in parallel)
78 81 end note
79 82  
80   - :**CC = start_next_received_cmd_if_exists()**;
81   - :cmd = **start_next_received_cmd_if_possible_and_exists()**;
  83 + #lightblue:cmd = **start_next_received_cmd_if_possible_and_exists()**;
82 84 note right
83 85 ONLY possible if :
84 86 - no current command CC
... ... @@ -86,19 +88,19 @@ repeat
86 88 - current command CC finished (can be run in parallel)
87 89 OR
88 90 - PRIORITY cmd received
89   - --> Then start and return next received cmd (only if exists)
90   - --> Otherwise, return None
91   - This may throw Exception (CmdInvalid, CmdUnimplemented, CmdExecError, CmdExecTimeout...) : stored in CCE
  91 +
  92 + Then start and return next received cmd (only if exists, otherwise return None)
  93 + This may throw **Exception** (CmdInvalid, CmdUnimplemented, CmdExecError, CmdExecTimeout...) => stored in **CCE**
92 94  
93 95 Command received can be of 3 types :
94   - - Agent General cmd :s always executed (sequential exec)
  96 + - Agent General cmd : always executed (sequential exec)
95 97 - Agent Specific cmd : only executed if in ATTENTIVE mode
96 98 - Other cmd (device) : only executed if in ATTENTIVE mode
97 99 end note
98   - if (cmd) then
  100 + if (cmd ?) then (yes)
99 101 :CC_prev = CC
100 102 CC = cmd;
101   - else ( no)
  103 + else (no)
102 104 endif
103 105  
104 106 if (CC.is_running() and CC.is_exec_timeout()) then (yes)
... ... @@ -115,7 +117,7 @@ repeat
115 117 else ( no)
116 118 endif
117 119 note right
118   - If current cmd is finished => display cmd state and then process exception if existss
  120 + If current cmd is finished => display cmd state and then process exception if exists
119 121 end note
120 122  
121 123 'if (DO_RESTART or DO_STOP ?) then (yes)
... ... @@ -125,7 +127,7 @@ repeat
125 127 ' endif
126 128 'else (no)
127 129 '#green:process_routine_after();
128   - :**routine_process_after()**;
  130 + #lightblue:**routine_process_after()**;
129 131 note right
130 132 (not executed if cmd was STOP or RESTART)
131 133 Only if NOT in IDLE mode
... ...
src/core/pyros_django/common/models.py
... ... @@ -342,12 +342,12 @@ class AgentSurvey(models.Model):
342 342 STATUS_CHOICES = Choices(
343 343 'LAUNCHED',
344 344 'INITIALIZING',
345   - 'IN_MAIN_LOOP',
346   - 'IN_ROUTINE_BEF',
347   - 'IN_GET_NEXT_CMD',
348   - 'IN_ROUTINE_AFT',
349   - 'EXITING',
350   - 'RESTARTING',
  345 + 'IN_MAIN_LOOP_START',
  346 + 'IN_MAIN_LOOP_ROUTINE_BEFORE',
  347 + 'IN_MAIN_LOOP_GET_NEXT_CMD',
  348 + 'IN_MAIN_LOOP_ROUTINE_AFTER',
  349 + 'EXITING', # STOP or HARD restart
  350 + 'RESTARTING', # SOFT restart
351 351 )
352 352  
353 353 name = models.CharField(max_length=50, unique=True)
... ... @@ -362,7 +362,7 @@ class AgentSurvey(models.Model):
362 362 #default = MODE_CHOICES.ATTENTIVE
363 363 )
364 364 status = models.CharField(
365   - max_length=15, blank=True, choices=STATUS_CHOICES)
  365 + max_length=30, blank=True, choices=STATUS_CHOICES)
366 366 iteration = models.IntegerField(blank=True, null=True)
367 367 nb_restart_max = models.IntegerField(blank=True,null=True,default=3)
368 368 current_nb_restart = models.IntegerField(blank=True,null=True,default=0)
... ...