Blame view

src/devices/PLC.py 906 Bytes
ddf59dd4   haribo   Remaniement :
1
from common.models import *
605b65e5   Jeremy   Update simulators
2
import abc
ddf59dd4   haribo   Remaniement :
3
from .Device import DeviceController
21598bc6   haribo   Date: 01/08/2016
4

e8e6f017   Jeremy   Reworked devices ...
5
6
7
8
'''
    Device controller for PLC.
    This class must implement set, get and do functions (DeviceController is an abstract)
'''
ddf59dd4   haribo   Remaniement :
9
class PLCController(DeviceController):
21598bc6   haribo   Date: 01/08/2016
10
11

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

    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...
26
27
28
29

    def getStatus(self):
        self.get("GlobalStatus")
        return "OK"