Blame view

src/devices/CameraVISRemoteControlDefault.py 2.95 KB
d3faf327   Quentin Durand   Command control D...
1
2
3
from devices.CameraRemoteControlAbstract import CameraRemoteControlAbstract
from devices import CameraVIS

bd83eb17   Quentin Durand   Control command C...
4
5
6
7
'''
        Class binding method for real grammar corresponding to the generic command received in the command_matchers   
'''

d3faf327   Quentin Durand   Command control D...
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class CameraVISRemoteControlDefault(CameraRemoteControlAbstract):
    def __init__(self, command, expert_mode, chosen_camera):
        super().__init__(command, expert_mode)
        if chosen_camera == "ddrago_r":
            self._camera = CameraVIS.VISCameraController()
        else:                                                   #TODO: Pour l'instant pas de différence DRRAGO RED et BLUE a vor plus tard
            self._camera = CameraVIS.VISCameraController()

        self._command_matcher_set = {
            "WINDOW": self.set,
            "READMODE [MODE 1]": self.set,
            "READMODE [MODE 2]": self.set,
            "READMODE [MODE 3]": self.set,
            "FILENAME": self.set,
            "HEADER": self.set,
            "READOUT_FREQUENCY": self.set,
            "FILTER [FILTER 1]": self.set,
            "FILTER [FILTER 2]": self.set,
bd83eb17   Quentin Durand   Control command C...
26
27
28
            "FILTER [FILTER 3]": self.set,
            "BINNING": self.set,
            "EXPOSURE": self.set
d3faf327   Quentin Durand   Command control D...
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
74
75
76
77
78
79
80
81
82
        }
        self._command_matcher_get = {
            "STATUS": self.get,
            "SETUP": self.get,
            "TIMER": self.get
       }
        self._command_matcher_do = {
            "COOLER ON": self.do,
            "COOLER OFF": self.do,
            "DOME SHUTTER OPEN": self.do,
            "DOME SHUTTER CLOSE": self.do,
            "DOME SHUTTER SYNCHRO": self.do,
            "START": self.do,
            "ABORT": self.do,
            "STOP": 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._camera.send_command(definitive_command)
        return response

    def set(self):
        definitive_command = "SET " + self._command[1] + ' ' + ' '.join(self._command[2:])
        response = self._camera.send_command(definitive_command)
        return response

    def get(self):
        definitive_command = "GET " + self._command[1] #+ ' ' + ' '.join(self._command[2:])
        response = self._camera.send_command(definitive_command)
        return response