diff --git a/README.md b/README.md index cfe3d29..f59d238 100644 --- a/README.md +++ b/README.md @@ -71,18 +71,9 @@ Date: 26/04/2019 Author: E. Pallier -VERSION: 0.20.40 +VERSION: 0.20.41 -Comment: AgentDevice + AgentDeviceTelescopeStatus + AgentTelescopeRequester - - - Dans le détail : - - AgentDevice met à jour la table AgentDeviceTelescopeStatus - - AgentTelescopeRequester interroge AgentDevice - - Quelques bugfixes - - Mode opératoire: - ./pyros start agentDevice - ou, en mode simu: - ./pyros -t start agentTelescopeRequester,agentDevice +Comment: AgentDeviceTelescopeStatus : 1 seule ligne mise à jour dans la table - Scenario de test : - lancer agents A et B en mode simu (option -t): ./pyros.py -t start agentA,agentB @@ -97,6 +88,13 @@ Comment: AgentDevice + AgentDeviceTelescopeStatus + AgentTelescopeRequester - pour utiliser thread ou processus : il suffit de mettre la constante RUN_IN_THREAD de AgentA (ou AgentB ou AgentX) à False ou True - Historique des nouveautés implémentées : + - AgentDevice + AgentDeviceTelescopeStatus + AgentTelescopeRequester : + - AgentDevice met à jour la table AgentDeviceTelescopeStatus + - AgentTelescopeRequester interroge AgentDevice + - Mode opératoire: + ./pyros start agentDevice + ou, en mode simu: + ./pyros -t start agentTelescopeRequester,agentDevice - Génération automatique des diagrammes PlantUML avec "pyros update" - Implémentation complète du "Command state diag" - Nouveaux diagrammes UML pour Command (state diag) et Agent (activity diag) diff --git a/src/agent/AgentDevice.py b/src/agent/AgentDevice.py index fcd32da..42a391d 100755 --- a/src/agent/AgentDevice.py +++ b/src/agent/AgentDevice.py @@ -17,6 +17,8 @@ from devices_channel.client.telescope_controller_gemini import TelescopeControll class AgentDevice(Agent): + _agent_device_telescope_status = None + # FOR TEST ONLY # Run this agent in simulator mode SIMULATOR_MODE = False @@ -73,11 +75,22 @@ class AgentDevice(Agent): def __init__(self, name:str=None, config_filename=None, RUN_IN_THREAD=True, device_controller=TelescopeControllerGEMINI): if name is None: name = self.__class__.__name__ super().__init__(name, config_filename, RUN_IN_THREAD) - self._log.print(f"init done for {name}") + + # Initialize the device table status + # If table is empty, create a default 1st row + if not AgentDeviceTelescopeStatus.objects.exists(): + print("CREATE first row") + self._agent_device_telescope_status = AgentDeviceTelescopeStatus.objects.create(id=1) + # Get 1st row (will be updated at each iteration by routine_process() with current device status) + print("GET first row") + self._agent_device_telescope_status = AgentDeviceTelescopeStatus.objects.get(id=1) + + # Initialize the device socket # Port local AK 8085 = redirigé sur l’IP du tele 192.168.0.12 sur port 11110 HOST, PORT = "82.64.28.71", 11110 #HOST, PORT = "localhost", 11110 self.tele_ctrl = TelescopeControllerGEMINI(HOST, PORT, True) + self._log.print(f"init done for {name}") # @override @@ -144,7 +157,11 @@ class AgentDevice(Agent): if res.ok: print("OK") time.sleep(1) - AgentDeviceTelescopeStatus.objects.create(radec=myradec) + # Save current device status to DB + #AgentDeviceTelescopeStatus.objects.create(radec=myradec) + self._agent_device_telescope_status.radec = myradec + self._agent_device_telescope_status.save() + #time.sleep(3) self.print("ROUTINE PROCESS END") diff --git a/src/common/models.py b/src/common/models.py index a017423..ec06e4f 100644 --- a/src/common/models.py +++ b/src/common/models.py @@ -214,7 +214,8 @@ class Request(models.Model): """ class AgentDeviceTelescopeStatus(models.Model): - created = models.DateTimeField('status date', blank=True, null=True, auto_now_add=True) + #created = models.DateTimeField('status date', blank=True, null=True, auto_now_add=True) + updated = models.DateTimeField('status date', blank=True, null=True, auto_now=True) radec = models.CharField('agent mode', max_length=30, blank=True) class Meta: -- libgit2 0.21.2