TelescopeRemoteControlDefault.py
2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from django.conf import settings
from dashboard.models import Log
from devices.TelescopeRemoteControlAbstract import TelescopeRemoteControlAbstract
from devices.Telescope import TelescopeController
import os
class TelescopeRemoteControlDefault(TelescopeRemoteControlAbstract):
#
## Pour les classes a venir qui implémenteront des grammaires outils les commands matchers pointeront sur des méthodes fournies par AK
## et le exec_command appellera la méthode correspondante
#
def __init__(self, command, expert_mode):
super().__init__(command, expert_mode)
self._command_matcher_set = {
"COORD_RADEC": self.set,
"COORD_HADEC": self.set,
"COORD_ALTAZ": self.set,
"DRIFT_HADEC": self.set,
"ROTATOR_ANGLE": self.set
}
self._command_matcher_get = {
"INFORMATIONS": self.get,
"COORD_RADEC": self.get,
"COORD_HADEC": self.get,
"COORD_ALTAZ": self.get
}
self._command_matcher_do = {
"EVAL": self.do,
"HOMING": self.do,
"ZENITH": self.do,
"GOTO": self.do,
"STOP": self.do,
"DRIFT_ON": self.do,
"DRIFT_OFF": self.do,
"ROTATOR_GOTO": self.do
}
def exec_command(self):
#os.system("echo \"status :" + str(self._command) + "\" >> /home/portos/IRAP/pyros/src/commande_recu")
if self._command[0] == "GET":
self._current_matcher = self._command_matcher_get
elif self._command[0] == "SET":
self._current_matcher = self._command_matcher_set
elif self._command[0] == "DO":
self._current_matcher = self._command_matcher_do
else: return "KO: Unknown command"
if self._command[1] in self._current_matcher:
return self._current_matcher[self._command[1]]()
else:
return "KO: Unknown command"
'''
Locals methods for the generic grammar
'''
def do(self):
definitive_command = "DO " + self._command[1] + ' ' + ' '.join(self._command[2:])
response = self._telescope.send_command(definitive_command)
return response
def set(self):
definitive_command = "SET " + self._command[1] + ' ' + ' '.join(self._command[2:])
response = self._telescope.send_command(definitive_command)
return response
def get(self):
definitive_command = "GET " + self._command[1] #+ ' ' + ' '.join(self._command[2:])
response = self._telescope.send_command(definitive_command)
return response