Commit f9993140 authored by Matias Guijarro's avatar Matias Guijarro
Browse files

Merge branch 'pepu_info' into 'master'

Pepu info + load_config_from_file

See merge request !3876
parents af0c9a30 30dce25f
Pipeline #50652 passed with stages
in 115 minutes and 48 seconds
......@@ -476,7 +476,7 @@ class Command:
return f"{self.__class__.__name__}[{self._host}:{self._port}]"
def __info__(self):
info_str = "TCP COMMAND: host={self._host} port={self._port} \n"
info_str = f"TCP COMMAND: host={self._host} port={self._port} \n"
return info_str
@property
......
......@@ -82,10 +82,10 @@ def _command(cnx, cmd, data=None, pre_cmd=None, timeout=None):
if ioex.errno == 113:
_msg = f"IOError no {ioex.errno}:{errno.errorcode[ioex.errno]}"
_msg += f"\nmessage={os.strerror(ioex.errno)} "
_msg += f"\nPlease check that icepap controller '{cnx._host}' is ON"
_msg += f"\nPlease check that controller '{cnx._host}' is ON"
else:
_msg = f"IOError no {ioex.errno} : {ioex.strerror}"
_msg += f"\nCannot communicate with icepap controller: '{cnx._host}'"
_msg += f"\nCannot communicate with controller: '{cnx._host}'"
raise CommunicationError(_msg) from ioex
......
......@@ -17,7 +17,6 @@ import numpy
from bliss.comm.util import get_comm, TCP
from bliss.controllers.motors.icepap import _command, _ackcommand
from bliss.controllers.counter import CounterController
from bliss.common.counter import Counter
......@@ -317,14 +316,6 @@ class BaseChannel(object):
def pepu(self):
return self._pepu()
# Counter shortcut
@property
def counters(self):
from bliss.scanning.acquisition.pepu import PepuCounter
return PepuCounter(self)
class BaseChannelINOUT(BaseChannel):
......@@ -539,6 +530,9 @@ class PEPU(CounterController):
dance_info = DeviceAttr("DINFO", str, None)
config = DeviceConfigAttr()
config_file_name = None
_last_loaded_config_file_name = None
def __init__(self, name, config, master_controller=None):
super().__init__(name, master_controller=master_controller)
......@@ -551,6 +545,8 @@ class PEPU(CounterController):
url = "command://" + url
config["tcp"]["url"] = url
self.config_file_name = config.get("config_file", None)
self.conn = get_comm(config, TCP, eol="\n")
self.in_channels = dict([(i, ChannelIN(self, i)) for i in self.IN_CHANNELS])
......@@ -629,6 +625,23 @@ class PEPU(CounterController):
def raw_write_read(self, message, data=None):
return _ackcommand(self.conn, message, data=data)
def load_config_from_file(self, file_name=None):
"""
Load PEPU config from file (file name taken from YML config or
passed as argument)
"""
if file_name is None and self.config_file_name is None:
raise ValueError("No config file name specified")
if file_name is None:
file_to_load = self.config_file_name
else:
file_to_load = file_name
with open(file_to_load, mode="r") as config_file:
self.config = config_file.read()
self._last_loaded_config_file_name = file_to_load
def reboot(self):
self.raw_write("REBOOT")
self.conn.close()
......@@ -685,7 +698,16 @@ class PEPU(CounterController):
return self.raw_write_read(cmd)
def __info__(self):
return "{0}(name={1!r})".format(type(self).__name__, self.name)
info_str = f"{type(self).__name__} (name={self.name})\n"
if self._last_loaded_config_file_name is not None:
info_str += (
f"Last config file loaded = {self._last_loaded_config_file_name}\n"
)
info_str += f"{self.conn.__info__()}\n"
return info_str
class PepuCounter(Counter):
......
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