Blame view

src/core/pyros_django/devices/Telescope.py 1.13 KB
ddf59dd4   haribo   Remaniement :
1
from common.models import *
605b65e5   Jeremy   Update simulators
2
import abc
ddf59dd4   haribo   Remaniement :
3
from .Device import DeviceController
ac26ad2b   haribo   Date: 22/07/2016
4

e8e6f017   Jeremy   Reworked devices ...
5
6
7
8
'''
    Device controller for Telescope.
    This class must implement set, get and do functions (DeviceController is an abstract)
'''
ddf59dd4   haribo   Remaniement :
9
class TelescopeController(DeviceController):
9774228b   haribo   Date: 22/06/2016
10
11

    def __init__(self):
bb0fbab1   haribo   Fini de mettre la...
12
        super().__init__("Telescope")
e8e6f017   Jeremy   Reworked devices ...
13
14
15
16
17
18
19
20

    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])
7e40048f   Quentin Durand   Implementation ba...
21
22
23
        self.sendMessage(message)
        response = self.blockAndReadMessage()
        return response
e8e6f017   Jeremy   Reworked devices ...
24
25
26

    def do(self, command: str, *args):
        message = "DO " + command + " " + " ".join([str(arg) for arg in args])
7e40048f   Quentin Durand   Implementation ba...
27
28
29
        self.sendMessage(message)
        response = self.blockAndReadMessage()
        return response
ce470283   Jeremy   Plc simulator fin...
30

c78dc38b   Quentin Durand   Classe abstraite ...
31
32
33
34
    def send_command(self, command):
        self.sendMessage(command)
        return self.blockAndReadMessage()

ce470283   Jeremy   Plc simulator fin...
35
36
37
    def getStatus(self):
        self.get("STATUS")
        return "OK"