Commit 6b45c841 authored by Matias Guijarro's avatar Matias Guijarro

Merge branch 'wago_bugfix' into 'master'

Wago bugfix

Closes #1263

See merge request bliss/bliss!1881
parents 5005fb54 385daeb5
......@@ -685,3 +685,10 @@ def rounder(template_number, number):
return numpy.format_float_positional(
number, precision=precision, unique=False, trim="-"
)
class ShellStr(str):
"""Subclasses str to give a nice representation in the Bliss shell"""
def __info__(self):
return str(self)
......@@ -25,6 +25,7 @@ from bliss.common.logtools import log_debug, log_error, log_exception
from bliss.common.counter import SamplingCounter
from bliss.controllers.counter import counter_namespace, SamplingCounterController
from bliss.controllers.wago.helpers import splitlines, to_signed, register_type_to_int
from bliss.common.utils import ShellStr
"""
EXPLANATION AND NAMING CONVENTION
......@@ -1440,7 +1441,7 @@ class WagoController:
f"Last response: Check code (should be like 0xaa 0x01 version tag + version num) is {check:02X}",
)
log_debug(self, f"Last response: Ack (should be 0 or 2) is {ack}")
raise TimeoutError(f"ACK not received")
raise MissingFirmware(f"ACK not received")
try:
check, _, ack = self.client.read_input_registers(
addr, "H" * size, timeout=self.timeout
......@@ -1652,8 +1653,6 @@ class WagoController:
"""
Wago Status information
"""
from bliss.shell.standard import ShellStr
out = ""
if not self.coupler:
out += f"Controller series code (INFO_SERIES) : {self.series}\n"
......@@ -2084,7 +2083,6 @@ class Wago(SamplingCounterController):
self.__interlock_load_config(reloaded_config)
from bliss.shell.standard import ShellStr
from bliss.controllers.wago.interlocks import interlock_download as download
from bliss.controllers.wago.interlocks import interlock_compare as compare
from bliss.controllers.wago.interlocks import interlock_upload as upload
......@@ -2127,7 +2125,6 @@ class Wago(SamplingCounterController):
return ShellStr("\n".join(repr_))
def interlock_to_yml(self):
from bliss.common.standard import ShellStr
from bliss.controllers.wago.interlocks import interlock_to_yml as to_yml
from bliss.controllers.wago.interlocks import interlock_download as download
......
......@@ -35,6 +35,7 @@ from bliss.common.standard import __move
from bliss.common import measurementgroup
from bliss.common.soft_axis import SoftAxis
from bliss.common.counter import SoftCounter
from bliss.common.utils import ShellStr
# objects given to Bliss shell user
from bliss.common.standard import mv, mvr, move
......@@ -93,13 +94,6 @@ _FLOAT_FORMAT = ".05f"
_log = logging.getLogger("bliss.shell.standard")
class ShellStr(str):
"""Subclasses str to give a nice representation in the Bliss shell"""
def __info__(self):
return str(self)
def _print_errors_with_traceback(errors, device_type="motor"):
""" RE-raise caught errors with original traceback """
for (label, error_with_traceback_obj) in errors:
......
from bliss.common.utils import flatten, merge
from bliss.common.utils import flatten, merge, ShellStr
import numpy
......@@ -12,3 +12,9 @@ def test_flatten():
def test_merge():
assert merge([[1, 2], [3]]) == [1, 2, 3]
assert merge([[1, 2], [[3, 4]], [5]]) == [1, 2, [3, 4], 5]
def test_shell_str():
raw_s = "<hi>"
s = ShellStr(raw_s)
assert s.__info__() == raw_s
......@@ -10,7 +10,7 @@ from bliss.controllers.wago.helpers import (
wordarray_to_bytestring,
)
from bliss.controllers.wago.wago import WagoController, ModulesConfig
from bliss.controllers.wago.wago import WagoController, ModulesConfig, MissingFirmware
from bliss.controllers.wago.interlocks import (
interlock_parse_relay_line,
interlock_parse_channel_line,
......@@ -369,3 +369,15 @@ def test_wago_status(capsys, default_session, wago_mockup):
for info in "module0 module1 module2 module3".split():
assert info in captured.out
assert "Given mapping does match Wago attached modules" in captured.out
def test_wago_interlock_methods(default_session, wago_mockup):
wago = default_session.config.get("wago_simulator")
with pytest.raises(MissingFirmware):
wago.interlock_to_yml()
with pytest.raises(MissingFirmware):
wago.interlock_upload()
with pytest.raises(MissingFirmware):
wago.interlock_reset(1)
with pytest.raises(MissingFirmware):
wago.interlock_state()
import pytest
def test_wagogroup_get(default_session, wago_mockup):
wago = default_session.config.get("wago_simulator")
wago_group = default_session.config.get("wago_group")
......@@ -13,8 +16,8 @@ def test_wagogroup_set(default_session, wago_mockup, clean_gevent):
wago_group.set("foh2ctrl", 1, 1, 1, 1, "o10v1", -4.0)
assert wago_group.get("foh2ctrl") == [1, 1, 1, 1]
assert wago.get("foh2ctrl") == [1, 1, 1, 1]
assert wago_group.get("o10v1") == -4.0
assert wago.get("o10v1") == -4.0
assert wago_group.get("o10v1") == pytest.approx(-4.0, .001)
assert wago.get("o10v1") == pytest.approx(-4.0, .001)
def test_wagogroup_counters(default_session, wago_mockup, clean_gevent):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment