Skip to content
Snippets Groups Projects
Commit aa44b2e2 authored by Martin Teichmann's avatar Martin Teichmann
Browse files

DeviceVar write added to devices

parent 5c0c5a31
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ class AnalogInput(Device): ...@@ -15,7 +15,7 @@ class AnalogInput(Device):
It will read from there and return the result in its It will read from there and return the result in its
parameter `value`. parameter `value`.
""" """
value = DeviceVar() value = DeviceVar(write=False)
data = TerminalVar() data = TerminalVar()
def __init__(self, data): def __init__(self, data):
...@@ -34,7 +34,7 @@ class AnalogOutput(Device): ...@@ -34,7 +34,7 @@ class AnalogOutput(Device):
This device can be linked to an analog output of a terminal. This device can be linked to an analog output of a terminal.
It will write the `value` to that terminal. It will write the `value` to that terminal.
""" """
value = DeviceVar() value = DeviceVar(write=True)
data = TerminalVar() data = TerminalVar()
def __init__(self, data): def __init__(self, data):
...@@ -54,7 +54,7 @@ class DigitalInput(Device): ...@@ -54,7 +54,7 @@ class DigitalInput(Device):
It will read from there and return the result in its It will read from there and return the result in its
parameter `value`. parameter `value`.
""" """
value = DeviceVar() value = DeviceVar(write=False)
data = TerminalVar() data = TerminalVar()
def __init__(self, data): def __init__(self, data):
...@@ -73,7 +73,7 @@ class DigitalOutput(Device): ...@@ -73,7 +73,7 @@ class DigitalOutput(Device):
This device can be linked to an analog output of a terminal. This device can be linked to an analog output of a terminal.
It will write the `value` to that terminal. It will write the `value` to that terminal.
""" """
value = DeviceVar() value = DeviceVar(write=True)
data = TerminalVar() data = TerminalVar()
def __init__(self, data): def __init__(self, data):
...@@ -92,8 +92,8 @@ class PWM(Device): ...@@ -92,8 +92,8 @@ class PWM(Device):
This device can be linked to an analog output of a terminal. This device can be linked to an analog output of a terminal.
It will write the `value` to that terminal. It will write the `value` to that terminal.
""" """
seed = DeviceVar("I") seed = DeviceVar("I", write=True)
value = DeviceVar("I") value = DeviceVar("I", write=True)
data = TerminalVar() data = TerminalVar()
def __init__(self, data): def __init__(self, data):
...@@ -110,7 +110,7 @@ class PWM(Device): ...@@ -110,7 +110,7 @@ class PWM(Device):
class Counter(Device): class Counter(Device):
"""A fake device counting the loops""" """A fake device counting the loops"""
count = DeviceVar("I") count = DeviceVar("I", write=False)
def program(self): def program(self):
self.count += 1 self.count += 1
...@@ -127,12 +127,12 @@ class Motor(Device): ...@@ -127,12 +127,12 @@ class Motor(Device):
enable = TerminalVar() enable = TerminalVar()
current_position = DeviceVar() current_position = DeviceVar()
set_velocity = DeviceVar() set_velocity = DeviceVar(write=True)
set_enable = DeviceVar() set_enable = DeviceVar(write=True)
max_velocity = DeviceVar() max_velocity = DeviceVar(write=True)
max_acceleration = DeviceVar() max_acceleration = DeviceVar(write=True)
target = DeviceVar() target = DeviceVar(write=True)
proportional = DeviceVar() proportional = DeviceVar(write=True)
def update(self): def update(self):
velocity = self.proportional * (self.target - self.encoder) velocity = self.proportional * (self.target - self.encoder)
......
...@@ -158,8 +158,8 @@ class TerminalVar: ...@@ -158,8 +158,8 @@ class TerminalVar:
class DeviceVar(ArrayGlobalVarDesc): class DeviceVar(ArrayGlobalVarDesc):
def __init__(self, size="I"): def __init__(self, size="I", write=False):
super().__init__(FastSyncGroup.properties, size) super().__init__(FastSyncGroup.properties, size, write)
def __get__(self, instance, owner): def __get__(self, instance, owner):
if instance is None: if instance is None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment