Skip to content

Commit be7699d

Browse files
committed
add group_input
1 parent 5649bca commit be7699d

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

src/abb_robot_client/rws.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,26 @@ def set_analog_io(self, signal: str, value: Union[int, float], network: str = "L
470470
payload = {"mode": "value", "lvalue": value}
471471
_res = self._do_post("rw/iosystem/signals/" + network + "/" + unit + "/" + signal + "?action=set", payload)
472472

473+
def get_group_io(self, signal: str, network: str = "", unit: str = "") -> int:
474+
"""
475+
This is the same as get_digital_io(). Get the value of a group IO signal.
476+
"""
477+
return self.get_digital_io(signal, network, unit)
478+
479+
def set_group_io(self, signal: str, value: int, network: str = "", unit: str = ""):
480+
"""
481+
Set the value of an group IO signal.
482+
WARNNING: This will just write an int to the group, make sure to convert the value to the correct bit pattern first.
483+
484+
:param value: The value of the signal.
485+
:param signal: The name of the signal
486+
:param network: The network the signal is on. The default `Local` will work for most signals.
487+
:param unit: The drive unit of the signal. The default `DRV_1` will work for most signals.
488+
"""
489+
lvalue = str(value)
490+
payload = {"lvalue": lvalue}
491+
_res = self._do_post("rw/iosystem/signals/" + network + "/" + unit + "/" + signal + "?action=set", payload)
492+
473493
def get_rapid_variables(self, task: str = "T_ROB1") -> List[str]:
474494
"""
475495
Get a list of the persistent variables in a task

src/abb_robot_client/rws2.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,30 @@ def set_analog_io(self, signal: str, value: Union[int, float], network: str = ""
408408
payload = {"mode": "value", "lvalue": value}
409409
_res = self._do_post(f"rw/iosystem/signals/{network}/{unit}/{signal}/set-value?mastership=implicit", payload)
410410

411+
def get_group_io(self, signal: str, network: str = "", unit: str = "") -> int:
412+
"""
413+
This is the same as get_digital_io(). Get the value of a group IO signal.
414+
"""
415+
return self.get_digital_io(signal, network, unit)
416+
417+
def set_group_io(self, signal: str, value: int, network: str = "", unit: str = ""):
418+
"""
419+
Set the value of an group IO signal.
420+
WARNNING: This will just write an int to the group, make sure to convert the value to the correct bit pattern first.
421+
422+
:param value: The value of the signal.
423+
:param signal: The name of the signal
424+
:param network: The network the signal is on. The default `Local` will work for most signals.
425+
:param unit: The drive unit of the signal. The default `DRV_1` will work for most signals.
426+
"""
427+
lvalue = value
428+
payload = {"lvalue": lvalue}
429+
if network and unit:
430+
url = f"rw/iosystem/signals/{network}/{unit}/{signal}/set-value?mastership=implicit"
431+
else:
432+
url = f"rw/iosystem/signals/{signal}/set-value?mastership=implicit"
433+
_res = self._do_post(url, payload)
434+
411435
# def get_rapid_variables(self, task: str="T_ROB1") -> List[str]:
412436
# """
413437
# Get a list of the persistent variables in a task

src/abb_robot_client/rws_mock.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,13 @@ def get_analog_io(self, signal: str, network: str = "", unit: str = "") -> float
164164

165165
def set_analog_io(self, signal: str, value: int | float, network: str = "", unit: str = "") -> None:
166166
self._aio[signal] = float(value)
167+
168+
def get_group_io(self, signal: str, network: str = "", unit: str = "") -> int:
169+
return int(self._dio.get(signal, 0))
167170

171+
def set_group_io(self, signal: str, value: bool | int, network: str = "", unit: str = "") -> None:
172+
self._dio[signal] = value
173+
168174
# RAPID variables
169175
def _qualify_var(self, var: str, task: str) -> str:
170176
return f"{task}/{var}" if task else var

0 commit comments

Comments
 (0)