From aa44b2e2833c3e3f2c1e62802b2334737b19de92 Mon Sep 17 00:00:00 2001 From: Martin Teichmann <martin.teichmann@xfel.eu> Date: Thu, 25 Feb 2021 19:52:14 +0100 Subject: [PATCH] DeviceVar write added to devices --- ebpfcat/devices.py | 26 +++++++++++++------------- ebpfcat/ebpfcat.py | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ebpfcat/devices.py b/ebpfcat/devices.py index 38af1e7..11a3340 100644 --- a/ebpfcat/devices.py +++ b/ebpfcat/devices.py @@ -15,7 +15,7 @@ class AnalogInput(Device): It will read from there and return the result in its parameter `value`. """ - value = DeviceVar() + value = DeviceVar(write=False) data = TerminalVar() def __init__(self, data): @@ -34,7 +34,7 @@ class AnalogOutput(Device): This device can be linked to an analog output of a terminal. It will write the `value` to that terminal. """ - value = DeviceVar() + value = DeviceVar(write=True) data = TerminalVar() def __init__(self, data): @@ -54,7 +54,7 @@ class DigitalInput(Device): It will read from there and return the result in its parameter `value`. """ - value = DeviceVar() + value = DeviceVar(write=False) data = TerminalVar() def __init__(self, data): @@ -73,7 +73,7 @@ class DigitalOutput(Device): This device can be linked to an analog output of a terminal. It will write the `value` to that terminal. """ - value = DeviceVar() + value = DeviceVar(write=True) data = TerminalVar() def __init__(self, data): @@ -92,8 +92,8 @@ class PWM(Device): This device can be linked to an analog output of a terminal. It will write the `value` to that terminal. """ - seed = DeviceVar("I") - value = DeviceVar("I") + seed = DeviceVar("I", write=True) + value = DeviceVar("I", write=True) data = TerminalVar() def __init__(self, data): @@ -110,7 +110,7 @@ class PWM(Device): class Counter(Device): """A fake device counting the loops""" - count = DeviceVar("I") + count = DeviceVar("I", write=False) def program(self): self.count += 1 @@ -127,12 +127,12 @@ class Motor(Device): enable = TerminalVar() current_position = DeviceVar() - set_velocity = DeviceVar() - set_enable = DeviceVar() - max_velocity = DeviceVar() - max_acceleration = DeviceVar() - target = DeviceVar() - proportional = DeviceVar() + set_velocity = DeviceVar(write=True) + set_enable = DeviceVar(write=True) + max_velocity = DeviceVar(write=True) + max_acceleration = DeviceVar(write=True) + target = DeviceVar(write=True) + proportional = DeviceVar(write=True) def update(self): velocity = self.proportional * (self.target - self.encoder) diff --git a/ebpfcat/ebpfcat.py b/ebpfcat/ebpfcat.py index d15a982..d10ca31 100644 --- a/ebpfcat/ebpfcat.py +++ b/ebpfcat/ebpfcat.py @@ -158,8 +158,8 @@ class TerminalVar: class DeviceVar(ArrayGlobalVarDesc): - def __init__(self, size="I"): - super().__init__(FastSyncGroup.properties, size) + def __init__(self, size="I", write=False): + super().__init__(FastSyncGroup.properties, size, write) def __get__(self, instance, owner): if instance is None: -- GitLab