Commit 6a3f890b2f180116962778377ab8db5d512044c2
1 parent
5feea9d6
Exists in
dev
AgentDeviceTelescopeStatus : 1 seule ligne mise à jour dans la table
Showing
3 changed files
with
30 additions
and
14 deletions
Show diff stats
README.md
... | ... | @@ -71,18 +71,9 @@ Date: 26/04/2019 |
71 | 71 | |
72 | 72 | Author: E. Pallier |
73 | 73 | |
74 | -VERSION: 0.20.40 | |
74 | +VERSION: 0.20.41 | |
75 | 75 | |
76 | -Comment: AgentDevice + AgentDeviceTelescopeStatus + AgentTelescopeRequester | |
77 | - | |
78 | - - Dans le détail : | |
79 | - - AgentDevice met à jour la table AgentDeviceTelescopeStatus | |
80 | - - AgentTelescopeRequester interroge AgentDevice | |
81 | - - Quelques bugfixes | |
82 | - - Mode opératoire: | |
83 | - ./pyros start agentDevice | |
84 | - ou, en mode simu: | |
85 | - ./pyros -t start agentTelescopeRequester,agentDevice | |
76 | +Comment: AgentDeviceTelescopeStatus : 1 seule ligne mise à jour dans la table | |
86 | 77 | |
87 | 78 | - Scenario de test : |
88 | 79 | - lancer agents A et B en mode simu (option -t): ./pyros.py -t start agentA,agentB |
... | ... | @@ -97,6 +88,13 @@ Comment: AgentDevice + AgentDeviceTelescopeStatus + AgentTelescopeRequester |
97 | 88 | - pour utiliser thread ou processus : il suffit de mettre la constante RUN_IN_THREAD de AgentA (ou AgentB ou AgentX) à False ou True |
98 | 89 | |
99 | 90 | - Historique des nouveautés implémentées : |
91 | + - AgentDevice + AgentDeviceTelescopeStatus + AgentTelescopeRequester : | |
92 | + - AgentDevice met à jour la table AgentDeviceTelescopeStatus | |
93 | + - AgentTelescopeRequester interroge AgentDevice | |
94 | + - Mode opératoire: | |
95 | + ./pyros start agentDevice | |
96 | + ou, en mode simu: | |
97 | + ./pyros -t start agentTelescopeRequester,agentDevice | |
100 | 98 | - Génération automatique des diagrammes PlantUML avec "pyros update" |
101 | 99 | - Implémentation complète du "Command state diag" |
102 | 100 | - Nouveaux diagrammes UML pour Command (state diag) et Agent (activity diag) | ... | ... |
src/agent/AgentDevice.py
... | ... | @@ -17,6 +17,8 @@ from devices_channel.client.telescope_controller_gemini import TelescopeControll |
17 | 17 | |
18 | 18 | class AgentDevice(Agent): |
19 | 19 | |
20 | + _agent_device_telescope_status = None | |
21 | + | |
20 | 22 | # FOR TEST ONLY |
21 | 23 | # Run this agent in simulator mode |
22 | 24 | SIMULATOR_MODE = False |
... | ... | @@ -73,11 +75,22 @@ class AgentDevice(Agent): |
73 | 75 | def __init__(self, name:str=None, config_filename=None, RUN_IN_THREAD=True, device_controller=TelescopeControllerGEMINI): |
74 | 76 | if name is None: name = self.__class__.__name__ |
75 | 77 | super().__init__(name, config_filename, RUN_IN_THREAD) |
76 | - self._log.print(f"init done for {name}") | |
78 | + | |
79 | + # Initialize the device table status | |
80 | + # If table is empty, create a default 1st row | |
81 | + if not AgentDeviceTelescopeStatus.objects.exists(): | |
82 | + print("CREATE first row") | |
83 | + self._agent_device_telescope_status = AgentDeviceTelescopeStatus.objects.create(id=1) | |
84 | + # Get 1st row (will be updated at each iteration by routine_process() with current device status) | |
85 | + print("GET first row") | |
86 | + self._agent_device_telescope_status = AgentDeviceTelescopeStatus.objects.get(id=1) | |
87 | + | |
88 | + # Initialize the device socket | |
77 | 89 | # Port local AK 8085 = redirigé sur l’IP du tele 192.168.0.12 sur port 11110 |
78 | 90 | HOST, PORT = "82.64.28.71", 11110 |
79 | 91 | #HOST, PORT = "localhost", 11110 |
80 | 92 | self.tele_ctrl = TelescopeControllerGEMINI(HOST, PORT, True) |
93 | + self._log.print(f"init done for {name}") | |
81 | 94 | |
82 | 95 | |
83 | 96 | # @override |
... | ... | @@ -144,7 +157,11 @@ class AgentDevice(Agent): |
144 | 157 | if res.ok: print("OK") |
145 | 158 | time.sleep(1) |
146 | 159 | |
147 | - AgentDeviceTelescopeStatus.objects.create(radec=myradec) | |
160 | + # Save current device status to DB | |
161 | + #AgentDeviceTelescopeStatus.objects.create(radec=myradec) | |
162 | + self._agent_device_telescope_status.radec = myradec | |
163 | + self._agent_device_telescope_status.save() | |
164 | + | |
148 | 165 | |
149 | 166 | #time.sleep(3) |
150 | 167 | self.print("ROUTINE PROCESS END") | ... | ... |
src/common/models.py
... | ... | @@ -214,7 +214,8 @@ class Request(models.Model): |
214 | 214 | """ |
215 | 215 | |
216 | 216 | class AgentDeviceTelescopeStatus(models.Model): |
217 | - created = models.DateTimeField('status date', blank=True, null=True, auto_now_add=True) | |
217 | + #created = models.DateTimeField('status date', blank=True, null=True, auto_now_add=True) | |
218 | + updated = models.DateTimeField('status date', blank=True, null=True, auto_now=True) | |
218 | 219 | radec = models.CharField('agent mode', max_length=30, blank=True) |
219 | 220 | |
220 | 221 | class Meta: | ... | ... |