Commit c68253f197d5084a4290d013fe3185a122b87455

Authored by Etienne Pallier
1 parent 64b466e7
Exists in dev

AgentSST get_mode et status, remove CC_prev, ...

cp_private_dev_to_private.sh
1 1  
2 2 cp -p src/core/pyros_django/agent/AgentBasic.py privatedev/plugin/agent/AgentBasic.py
3 3 cp -p src/core/pyros_django/agent/AgentTriton.py privatedev/plugin/agent/AgentTriton.py
  4 +cp -p src/core/pyros_django/observation_manager/AgentImagesProcessor.py privatedev/plugin/agent/AgentImagesProcessor.py
4 5  
5 6 rsync -avh --delete --exclude '.gitignore' --exclude 'plugin/README' --exclude 'config/README' privatedev/ private/
6 7  
... ...
privatedev/config/tnc/observatory_tnc.yml
... ... @@ -345,6 +345,11 @@ OBSERVATORY:
345 345 protocol: privatedev/plugin/agent/AgentImagesProcessor_tnc_up1.py
346 346  
347 347 - AGENT:
  348 + name: AgentImagesProcessor_tnc_up1_ep
  349 + computer: EtienneComputer
  350 + protocol: privatedev/plugin/agent/AgentImagesProcessor_tnc_up1.py
  351 +
  352 + - AGENT:
348 353 name: AgentTriton
349 354 computer: AKoralewskiPersoComputer
350 355 protocol: private/plugin/agent/AgentTriton.py
... ...
pyros.py
... ... @@ -60,7 +60,7 @@ AGENTS = {
60 60 "AgentM": "monitoring",
61 61 "AgentSP": "scientific_programs",
62 62 "AgentScheduler": "scheduler",
63   - "AgentImagesProcessor": "observation_manager",
  63 + "agentImagesProcessor": "observation_manager",
64 64 "AgentImagesCalibrator": "observation_manager",
65 65 "agentSST": "agent",
66 66 "Agent": "agent",
... ...
src/core/pyros_django/agent/Agent.py
... ... @@ -618,7 +618,7 @@ class Agent:
618 618 self.__CC :Optional[AgentCmd] = None
619 619 self.__CC_thread :Union[StoppableThreadEvenWhenSleeping, multiprocessing.Process] = None
620 620 # Previous Command running
621   - self.__CC_prev :Optional[AgentCmd] = None
  621 + ##self.__CC_prev :Optional[AgentCmd] = None
622 622 # Current Command exception (if occurs)
623 623 self.__CCE :Optional[Exception] = None
624 624 self.name = "Generic Agent"
... ... @@ -678,7 +678,7 @@ class Agent:
678 678 name=self.name,
679 679 validity_duration=60,
680 680 #mode=self.__mode,
681   - mode = self.__get_mode(),
  681 + mode = self.get_mode(),
682 682 #status=self.__status,
683 683 status=self.get_status(),
684 684 iteration=-1
... ... @@ -1089,7 +1089,8 @@ class Agent:
1089 1089 # MAIN loop #
1090 1090 ############@
1091 1091 self.__iter_num = 1
1092   - self.__CC, self.__CC_thread, self.__CC_prev, self.__CCE = None, None, None, None
  1092 + #self.__CC, self.__CC_thread, self.__CC_prev, self.__CCE = None, None, None, None
  1093 + self.__CC, self.__CC_thread, self.__CCE = None, None, None
1093 1094 self.DO_MAIN_LOOP = True
1094 1095 while self.DO_MAIN_LOOP:
1095 1096 # EXIT because of nb of iterations ?
... ... @@ -1368,8 +1369,9 @@ class Agent:
1368 1369 wait_nbsec = 2
1369 1370  
1370 1371 # Waiting for (previous) current command still running if need be (if exists)
1371   - while self.__CC_prev and self.__CC_prev.is_running():
1372   - log.info(f"The previous command {self.__CC_prev.name} is still running => Waiting for it to finish (waiting {wait_nbsec} sec...)")
  1372 + #while self.__CC_prev and self.__CC_prev.is_running():
  1373 + while self.__CC and self.__CC.is_running():
  1374 + log.info(f"The current command {self.__CC.name} is still running => Waiting for it to finish (waiting {wait_nbsec} sec...)")
1373 1375 self.waitfor(wait_nbsec)
1374 1376  
1375 1377 '''
... ... @@ -1716,12 +1718,12 @@ class Agent:
1716 1718 #
1717 1719  
1718 1720 def get_state(self)->str:
1719   - return f"MODE is {self.__get_mode()} ; STATUS is {self.get_status()} ; ITERATION #{self.__iter_num}"
  1721 + return f"MODE is {self.get_mode()} ; STATUS is {self.get_status()} ; ITERATION #{self.__iter_num}"
1720 1722  
1721 1723 def show_state(self):
1722 1724 log.info(self.get_state())
1723 1725 #log.info(f"CURRENT MODE is {self.__mode} (status is {self.__status})")
1724   - #log.info(f"CURRENT MODE is {self.__get_mode()} (status is {self.get_status()})")
  1726 + #log.info(f"CURRENT MODE is {self.get_mode()} (status is {self.get_status()})")
1725 1727  
1726 1728 #
1727 1729 # - STATUS MANAGEMENT
... ... @@ -1752,12 +1754,11 @@ class Agent:
1752 1754 #
1753 1755  
1754 1756 # - GET
1755   - def __get_mode(self)->AgentSurvey.MODE_CHOICES:
1756   - return self.__mode
  1757 +
1757 1758 # Test mode
1758   - def IS_MODE_IDLE(self)->bool: return self.__get_mode() == AgentSurvey.MODE_CHOICES.IDLE
1759   - def IS_MODE_ROUTINE(self)->bool: return self.__get_mode() == AgentSurvey.MODE_CHOICES.ROUTINE
1760   - def IS_MODE_ATTENTIVE(self)->bool: return self.__get_mode() == AgentSurvey.MODE_CHOICES.ATTENTIVE
  1759 + def IS_MODE_IDLE(self)->bool: return self.get_mode() == AgentSurvey.MODE_CHOICES.IDLE
  1760 + def IS_MODE_ROUTINE(self)->bool: return self.get_mode() == AgentSurvey.MODE_CHOICES.ROUTINE
  1761 + def IS_MODE_ATTENTIVE(self)->bool: return self.get_mode() == AgentSurvey.MODE_CHOICES.ATTENTIVE
1761 1762 # @deprecated
1762 1763 def IS_IDLE(self): return self.IS_MODE_IDLE()
1763 1764 # @deprecated
... ... @@ -1983,7 +1984,7 @@ class Agent:
1983 1984 # only necessary when using process (not necessary with threads)
1984 1985 #with transaction.atomic():
1985 1986 #self._agent_survey = AgentSurvey.objects.get(name=self.name)
1986   - self.__agent_survey.mode = self.__get_mode()
  1987 + self.__agent_survey.mode = self.get_mode()
1987 1988 self.__agent_survey.status = self.get_status()
1988 1989 self.__agent_survey.iteration = self.__iter_num
1989 1990 self.__agent_survey.save()
... ... @@ -2834,6 +2835,7 @@ class Agent:
2834 2835 self.do_flush_pending_commands()
2835 2836  
2836 2837 def get_mode(self)->str:
  2838 + return self.__mode
2837 2839 return "MODE is " + self.__mode
2838 2840  
2839 2841 #def set_mode(self, mode:Season)->str:
... ... @@ -2886,7 +2888,8 @@ class Agent:
2886 2888 ##raise CmdExceptionBadArgs(self.CC)
2887 2889 #FIXME: TODO
2888 2890 def __do_stop_current_cmd_if_exists(self):
2889   - if self.__CC_prev and self.__CC_prev.is_running():
  2891 + #if self.__CC_prev and self.__CC_prev.is_running():
  2892 + if self.__CC and self.__CC.is_running():
2890 2893 log.info("Aborting current running command if exists...")
2891 2894 pass
2892 2895  
... ...
src/core/pyros_django/agent/AgentSST.py
... ... @@ -60,8 +60,8 @@ class AgentSST(Agent):
60 60 self._agent_survey = AgentSurvey.objects.create(
61 61 name=self.name,
62 62 validity_duration=60,
63   - mode=self.mode,
64   - status=self.status,
  63 + mode=self.get_mode(),
  64 + status=self.get_status(),
65 65 iteration=-1
66 66 )
67 67 WITH_DOCKER = False
... ...
src/core/pyros_django/observation_manager/AgentImagesProcessor.py
... ... @@ -49,7 +49,7 @@ class AgentImagesProcessor(Agent):
49 49 _TEST_COMMANDS_LIST = [
50 50 # Format : ("self cmd_name cmd_args", timeout, "expected_result", expected_status),
51 51 (True, "self do_create_test_images_1", 200, '', Agent.CMD_STATUS.CMD_EXECUTED),
52   - (True, "self do_exit", 500, "STOPPING", Agent.CMD_STATUS.CMD_EXECUTED),
  52 + (True, "self do_stop asap", 500, "STOPPING", Agent.CMD_STATUS.CMD_EXECUTED),
53 53 ]
54 54  
55 55 """
... ...