Blame view

src/core/pyros_django/devices/CameraNIR.py 1.23 KB
bb0fbab1   haribo   Fini de mettre la...
1
from common.models import *
605b65e5   Jeremy   Update simulators
2
import abc
bb0fbab1   haribo   Fini de mettre la...
3
4
from .Device import DeviceController

e8e6f017   Jeremy   Reworked devices ...
5
6
7
'''
    Device controller for NIRCamera.
    This class must implement set, get and do functions (DeviceController is an abstract)
bd83eb17   Quentin Durand   Control command C...
8
    
e8e6f017   Jeremy   Reworked devices ...
9
'''
bd83eb17   Quentin Durand   Control command C...
10
11
12

#TODO: refactoriser cette classe, la seule méthode utilisée est sendMessage, les autres sont obsolètes

bb0fbab1   haribo   Fini de mettre la...
13
class NIRCameraController(DeviceController):
bb0fbab1   haribo   Fini de mettre la...
14
15
16

    def __init__(self):
        super().__init__("CameraNIR")
e8e6f017   Jeremy   Reworked devices ...
17
18
19
20
21
22
23
24
25
26
27
28
29

    def get(self, command: str, *args):
        message = "GET " + command + " " + " ".join([str(arg) for arg in args])
        self.sendMessage(message)
        return (self.blockAndReadMessage())

    def set(self, command: str, *args):
        message = "SET " + command + " " + " ".join([str(arg) for arg in args])
        return (self.sendMessage(message))

    def do(self, command: str, *args):
        message = "DO " + command + " " + " ".join([str(arg) for arg in args])
        return (self.sendMessage(message))
ce470283   Jeremy   Plc simulator fin...
30
31
32
33

    def getStatus(self):
        self.get("STATUS")
        return "OK"
678838ed   Jeremy   Weather ans insid...
34
35

    def park(self):
c72eb17a   Jeremy   Update celery task
36
37
38
39
40
        return 0

    def open_shutter(self):
        self.do("OPEN SHUTTER")
        return 0
bd83eb17   Quentin Durand   Control command C...
41
42
43
44

    def send_command(self, command):
        self.sendMessage(command)
        return self.blockAndReadMessage()