from gpilib2.rpc import rpc
[docs]class mcds:
"""Access and control devices at the :term:`MCD` level
Args:
rpc (:py:class:`~gpilib2.rpc`):
rpc object. sim status and verbosity will be set
based on its settings.
Attributes:
rpc (:py:class:`~gpilib2.rpc`):
rpc object for communications
"""
def __init__(self, rpc: rpc) -> None:
"""Define all components
Args:
rpc (:py:class:`~gpilib2.rpc`):
rpc object. sim status and verbosity will be set
based on its settings.
"""
self.rpc = rpc
def __str__(self) -> str:
"""Generate pretty string representation of all MCD Axes"""
names = self.rpc.mcdaxisnames.reshape(self.rpc.nmcd, self.rpc.nax)
inits = (
self.rpc.read_gmb_values(self.rpc.mcdaxisinited)
.astype(bool)
.reshape(self.rpc.nmcd, self.rpc.nax)
)
datums = (
self.rpc.read_gmb_values(self.rpc.mcdaxisdatumed)
.astype(bool)
.reshape(self.rpc.nmcd, self.rpc.nax)
)
sims = (
self.rpc.read_gmb_values(self.rpc.mcdaxissimed)
.astype(bool)
.reshape(self.rpc.nmcd, self.rpc.nax)
)
# find longest name in each MCD
mxlens = [max([len(max(n, key=len)), 12]) + 1 for n in names]
hline = "-" * (sum(mxlens) + 7) + "\n"
out = hline + "| "
for j, l in enumerate(mxlens):
out += "{0: >{1}}|".format(j + 1, l)
out += "\n" + hline
for j, (name, init, datum, sim) in enumerate(
zip(
names.transpose(),
inits.transpose(),
datums.transpose(),
sims.transpose(),
)
):
out += "|{}|".format(j + 1)
for l, n in zip(mxlens, name):
out += "{0: <{1}}|".format(n, l)
out += "\n"
for bname, bval in zip(['INIT', 'DATUM', 'SIM'], [init, datum, sim]):
out += "| |"
for l, v in zip(mxlens, bval):
out += "{0: >{1}}:{2: >6}|".format(bname, l-7, str(v))
out += "\n"
out += hline
return out