diff --git a/cp_private_dev_to_private.sh b/cp_private_dev_to_private.sh index 257c926..ca32942 100755 --- a/cp_private_dev_to_private.sh +++ b/cp_private_dev_to_private.sh @@ -1,6 +1,7 @@ cp -p src/core/pyros_django/agent/AgentBasic.py privatedev/plugin/agent/AgentBasic.py cp -p src/core/pyros_django/agent/AgentTriton.py privatedev/plugin/agent/AgentTriton.py +cp -p src/core/pyros_django/observation_manager/AgentImagesProcessor.py privatedev/plugin/agent/AgentImagesProcessor.py rsync -avh --delete --exclude '.gitignore' --exclude 'plugin/README' --exclude 'config/README' privatedev/ private/ diff --git a/privatedev/config/tnc/observatory_tnc.yml b/privatedev/config/tnc/observatory_tnc.yml index 0ed1bb1..508b712 100644 --- a/privatedev/config/tnc/observatory_tnc.yml +++ b/privatedev/config/tnc/observatory_tnc.yml @@ -345,6 +345,11 @@ OBSERVATORY: protocol: privatedev/plugin/agent/AgentImagesProcessor_tnc_up1.py - AGENT: + name: AgentImagesProcessor_tnc_up1_ep + computer: EtienneComputer + protocol: privatedev/plugin/agent/AgentImagesProcessor_tnc_up1.py + + - AGENT: name: AgentTriton computer: AKoralewskiPersoComputer protocol: private/plugin/agent/AgentTriton.py diff --git a/pyros.py b/pyros.py index 176a1ce..2ca942d 100755 --- a/pyros.py +++ b/pyros.py @@ -60,7 +60,7 @@ AGENTS = { "AgentM": "monitoring", "AgentSP": "scientific_programs", "AgentScheduler": "scheduler", - "AgentImagesProcessor": "observation_manager", + "agentImagesProcessor": "observation_manager", "AgentImagesCalibrator": "observation_manager", "agentSST": "agent", "Agent": "agent", diff --git a/src/core/pyros_django/agent/Agent.py b/src/core/pyros_django/agent/Agent.py index b85e17d..8fddc91 100755 --- a/src/core/pyros_django/agent/Agent.py +++ b/src/core/pyros_django/agent/Agent.py @@ -618,7 +618,7 @@ class Agent: self.__CC :Optional[AgentCmd] = None self.__CC_thread :Union[StoppableThreadEvenWhenSleeping, multiprocessing.Process] = None # Previous Command running - self.__CC_prev :Optional[AgentCmd] = None + ##self.__CC_prev :Optional[AgentCmd] = None # Current Command exception (if occurs) self.__CCE :Optional[Exception] = None self.name = "Generic Agent" @@ -678,7 +678,7 @@ class Agent: name=self.name, validity_duration=60, #mode=self.__mode, - mode = self.__get_mode(), + mode = self.get_mode(), #status=self.__status, status=self.get_status(), iteration=-1 @@ -1089,7 +1089,8 @@ class Agent: # MAIN loop # ############@ self.__iter_num = 1 - self.__CC, self.__CC_thread, self.__CC_prev, self.__CCE = None, None, None, None + #self.__CC, self.__CC_thread, self.__CC_prev, self.__CCE = None, None, None, None + self.__CC, self.__CC_thread, self.__CCE = None, None, None self.DO_MAIN_LOOP = True while self.DO_MAIN_LOOP: # EXIT because of nb of iterations ? @@ -1368,8 +1369,9 @@ class Agent: wait_nbsec = 2 # Waiting for (previous) current command still running if need be (if exists) - while self.__CC_prev and self.__CC_prev.is_running(): - log.info(f"The previous command {self.__CC_prev.name} is still running => Waiting for it to finish (waiting {wait_nbsec} sec...)") + #while self.__CC_prev and self.__CC_prev.is_running(): + while self.__CC and self.__CC.is_running(): + log.info(f"The current command {self.__CC.name} is still running => Waiting for it to finish (waiting {wait_nbsec} sec...)") self.waitfor(wait_nbsec) ''' @@ -1716,12 +1718,12 @@ class Agent: # def get_state(self)->str: - return f"MODE is {self.__get_mode()} ; STATUS is {self.get_status()} ; ITERATION #{self.__iter_num}" + return f"MODE is {self.get_mode()} ; STATUS is {self.get_status()} ; ITERATION #{self.__iter_num}" def show_state(self): log.info(self.get_state()) #log.info(f"CURRENT MODE is {self.__mode} (status is {self.__status})") - #log.info(f"CURRENT MODE is {self.__get_mode()} (status is {self.get_status()})") + #log.info(f"CURRENT MODE is {self.get_mode()} (status is {self.get_status()})") # # - STATUS MANAGEMENT @@ -1752,12 +1754,11 @@ class Agent: # # - GET - def __get_mode(self)->AgentSurvey.MODE_CHOICES: - return self.__mode + # Test mode - def IS_MODE_IDLE(self)->bool: return self.__get_mode() == AgentSurvey.MODE_CHOICES.IDLE - def IS_MODE_ROUTINE(self)->bool: return self.__get_mode() == AgentSurvey.MODE_CHOICES.ROUTINE - def IS_MODE_ATTENTIVE(self)->bool: return self.__get_mode() == AgentSurvey.MODE_CHOICES.ATTENTIVE + def IS_MODE_IDLE(self)->bool: return self.get_mode() == AgentSurvey.MODE_CHOICES.IDLE + def IS_MODE_ROUTINE(self)->bool: return self.get_mode() == AgentSurvey.MODE_CHOICES.ROUTINE + def IS_MODE_ATTENTIVE(self)->bool: return self.get_mode() == AgentSurvey.MODE_CHOICES.ATTENTIVE # @deprecated def IS_IDLE(self): return self.IS_MODE_IDLE() # @deprecated @@ -1983,7 +1984,7 @@ class Agent: # only necessary when using process (not necessary with threads) #with transaction.atomic(): #self._agent_survey = AgentSurvey.objects.get(name=self.name) - self.__agent_survey.mode = self.__get_mode() + self.__agent_survey.mode = self.get_mode() self.__agent_survey.status = self.get_status() self.__agent_survey.iteration = self.__iter_num self.__agent_survey.save() @@ -2834,6 +2835,7 @@ class Agent: self.do_flush_pending_commands() def get_mode(self)->str: + return self.__mode return "MODE is " + self.__mode #def set_mode(self, mode:Season)->str: @@ -2886,7 +2888,8 @@ class Agent: ##raise CmdExceptionBadArgs(self.CC) #FIXME: TODO def __do_stop_current_cmd_if_exists(self): - if self.__CC_prev and self.__CC_prev.is_running(): + #if self.__CC_prev and self.__CC_prev.is_running(): + if self.__CC and self.__CC.is_running(): log.info("Aborting current running command if exists...") pass diff --git a/src/core/pyros_django/agent/AgentSST.py b/src/core/pyros_django/agent/AgentSST.py index 1b40349..9aaf1ee 100644 --- a/src/core/pyros_django/agent/AgentSST.py +++ b/src/core/pyros_django/agent/AgentSST.py @@ -60,8 +60,8 @@ class AgentSST(Agent): self._agent_survey = AgentSurvey.objects.create( name=self.name, validity_duration=60, - mode=self.mode, - status=self.status, + mode=self.get_mode(), + status=self.get_status(), iteration=-1 ) WITH_DOCKER = False diff --git a/src/core/pyros_django/observation_manager/AgentImagesProcessor.py b/src/core/pyros_django/observation_manager/AgentImagesProcessor.py index 689e314..02d5d74 100755 --- a/src/core/pyros_django/observation_manager/AgentImagesProcessor.py +++ b/src/core/pyros_django/observation_manager/AgentImagesProcessor.py @@ -49,7 +49,7 @@ class AgentImagesProcessor(Agent): _TEST_COMMANDS_LIST = [ # Format : ("self cmd_name cmd_args", timeout, "expected_result", expected_status), (True, "self do_create_test_images_1", 200, '', Agent.CMD_STATUS.CMD_EXECUTED), - (True, "self do_exit", 500, "STOPPING", Agent.CMD_STATUS.CMD_EXECUTED), + (True, "self do_stop asap", 500, "STOPPING", Agent.CMD_STATUS.CMD_EXECUTED), ] """ -- libgit2 0.21.2