Skip to content

Commit

Permalink
WIP #50
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Mar 23, 2020
1 parent 440b93b commit 17d6a32
Showing 1 changed file with 44 additions and 32 deletions.
76 changes: 44 additions & 32 deletions src/adl2pydm/output_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,13 @@ def write_block_valuator(self, parent, block, nm, qw):
self.write_channel(qw, pv)
self.write_tooltip(qw, pv)
self.write_direction(qw, block)
label = block.contents.get("label")
if label is not None:
logger.debug("breakpoint")
self.write_limits(qw, block)

self.writePropertyBoolean(qw, "showUnits", False, stdset="0")

# TODO:
# TODO: https://github.com/BCDA-APS/adl2pydm/issues/50
# self.assertEqualPropertyBool(w, "showValueLabel", False)
Expand All @@ -876,8 +881,15 @@ def write_block_valuator(self, parent, block, nm, qw):
# TODO: https://github.com/BCDA-APS/adl2pydm/issues/37
precision = block.contents.get("dPrecision")
if precision is not None:
precision = float(precision)
iprecision = int(precision)
if iprecision != precision:
logger.warning(
"truncation warning: "
f"precision {precision} truncated to {iprecision}"
)
self.writer.writeProperty(
qw, "precision", str(precision), tag="number")
qw, "precision", str(iprecision), tag="number", stdset="0")

def write_block_wheel_switch(self, parent, block, nm, qw):
pv = self.get_channel(block.contents["control"])
Expand Down Expand Up @@ -1011,6 +1023,37 @@ def write_geometry(self, parent, geom):
self.writer.writeTaggedString(rect, "height", str(geom.height))

def write_limits(self, qw, block):
label = block.contents.get("label")
# https://epics.anl.gov/EpicsDocumentation/ExtensionsManuals/MEDM/MEDM.html#Label
if label is None:
show = dict(limits=True, values=False)
elif label == "no decorations":
# TODO: For the Bar Monitor, only the background and the bar show
show = dict(limits=True, values=False)
elif label == "outline":
show = dict(limits=True, values=False)
elif label == "limits":
show = dict(limits=True, values=True)
elif label == "channel":
show = dict(limits=True, values=True)
self.writePropertyBoolean(qw, "showLimitLabels", show["limits"], stdset="0")
self.writePropertyBoolean(qw, "showValueLabel", show["values"], stdset="0")

if qw.attrib["class"] == "PyDMScaleIndicator":
self.writePropertyBoolean(qw, "limitsFromChannel", False, stdset="0")
hiLimitName = "userUpperLimit"
loLimitName = "userLowerLimit"
elif qw.attrib["class"] == "PyDMSlider":
hiLimitName = "userMaximum"
loLimitName = "userMinimum"
elif qw.attrib["class"] == "PyDMSpinbox":
hiLimitName = "maximum"
loLimitName = "minimum"
else:
raise NotImplementedError(
f"limits for {qw.attrib['class']} widget not handled"
)

if (
block.contents.get("hoprSrc") == "default"
or
Expand All @@ -1020,37 +1063,6 @@ def write_limits(self, qw, block):
precSrc = block.contents.get("precSrc")
precDefault = block.contents.get("precDefault")

label = block.contents.get("label")
# https://epics.anl.gov/EpicsDocumentation/ExtensionsManuals/MEDM/MEDM.html#Label
if label is None:
show = dict(limits=True, values=False)
elif label == "no decorations":
# TODO: For the Bar Monitor, only the background and the bar show
show = dict(limits=True, values=False)
elif label == "outline":
show = dict(limits=True, values=False)
elif label == "limits":
show = dict(limits=True, values=True)
elif label == "channel":
show = dict(limits=True, values=True)
self.writePropertyBoolean(qw, "showLimitLabels", show["limits"], stdset="0")
self.writePropertyBoolean(qw, "showValueLabel", show["values"], stdset="0")

if qw.attrib["class"] == "PyDMScaleIndicator":
self.writePropertyBoolean(qw, "limitsFromChannel", False, stdset="0")
hiLimitName = "userUpperLimit"
loLimitName = "userLowerLimit"
elif qw.attrib["class"] == "PyDMSlider":
hiLimitName = "userMaximum"
loLimitName = "userMinimum"
elif qw.attrib["class"] == "PyDMSpinbox":
hiLimitName = "maximum"
loLimitName = "minimum"
else:
raise NotImplementedError(
f"limits for {qw.attrib['class']} widget not handled"
)

self.writePropertyBoolean(qw, "userDefinedLimits", True, stdset="0")
self.writer.writeProperty(
qw,
Expand Down

0 comments on commit 17d6a32

Please sign in to comment.