Skip to content

Commit

Permalink
Added necessary PVI information for PCAP:ARM
Browse files Browse the repository at this point in the history
  • Loading branch information
evalott100 committed Sep 1, 2023
1 parent c13d7aa commit 82130ab
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 23 deletions.
15 changes: 12 additions & 3 deletions src/pandablocks_ioc/_pvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from epicsdbbuilder import RecordName
from pvi._format.dls import DLSFormatter
from pvi.device import (
LED,
ButtonPanel,
ComboBox,
Component,
Device,
Expand Down Expand Up @@ -61,9 +63,16 @@ def add_pvi_info(
useComboBox: bool = record_creation_func == builder.mbbOut

if record_creation_func == builder.Action:
# TODO: What value do I write? PandA uses an empty string
component = SignalX(record_name, record_name, value="")
access = "x"
if record_name == "PCAP:ARM":
component = SignalRW(
record_name, record_name, widget=ButtonPanel(), read_widget=LED()
)
access = "rw"

else:
# TODO: What value do I write? PandA uses an empty string
component = SignalX(record_name, record_name, value="")
access = "x"
elif writeable:
if useComboBox:
widget = ComboBox()
Expand Down
15 changes: 10 additions & 5 deletions src/pandablocks_ioc/ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1402,8 +1402,8 @@ def _make_action_write(
builder.Action,
int, # not bool, as that'll treat string "0" as true
PviGroup.OUTPUTS, # TODO: Not sure what group to use
ZNAM=ZNAM_STR,
ONAM=ONAM_STR,
ZNAM="",
ONAM="",
on_update=lambda v: updater.update(v),
)

Expand Down Expand Up @@ -1707,14 +1707,19 @@ def create_block_records(
if block == "PCAP":
# TODO: Need to add PVI Info here. Just use create_record_info?
# And why isn't this record in the record_dict?
builder.Action(

pcap_arm_record = builder.Action(
"PCAP:ARM",
ZNAM=ZNAM_STR,
ONAM=ONAM_STR,
ZNAM="Disarm",
ONAM="Arm",
on_update=self._arm_on_update,
DESC="Arm/Disarm the PandA",
)

add_pvi_info(
PviGroup.INPUTS, pcap_arm_record, EpicsName("PCAP:ARM"), builder.Action
)

HDF5RecordController(self._client, self._record_prefix)

return record_dict
Expand Down
53 changes: 43 additions & 10 deletions tests/test-bobfiles/PCAP.bob
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<name>Display</name>
<x>0</x>
<y>0</y>
<width>361</width>
<height>202</height>
<width>426</width>
<height>227</height>
<grid_step_x>4</grid_step_x>
<grid_step_y>4</grid_step_y>
<widget type="label" version="2.0.0">
Expand All @@ -12,7 +12,7 @@
<text>PCAP - TEST-PREFIX:</text>
<x use_class="true">0</x>
<y use_class="true">0</y>
<width>361</width>
<width>426</width>
<height>25</height>
<font use_class="true">
<font name="Header 1" family="Liberation Sans" style="BOLD" size="22.0">
Expand All @@ -29,8 +29,8 @@
<name>INPUTS</name>
<x>5</x>
<y>30</y>
<width>351</width>
<height>106</height>
<width>416</width>
<height>131</height>
<transparent>true</transparent>
<widget type="label" version="2.0.0">
<name>Label</name>
Expand All @@ -51,17 +51,50 @@
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>PCAP: GATE</text>
<text>PCAP: ARM</text>
<x>0</x>
<y>25</y>
<width>250</width>
<height>20</height>
</widget>
<widget type="action_button" version="3.0.0">
<name>ActionButton</name>
<pv_name>TEST-PREFIX:PCAP:ARM</pv_name>
<actions>
<action type="write_pv">
<pv_name>$(pv_name)</pv_name>
<value>1</value>
<description>WritePV</description>
</action>
</actions>
<text>o</text>
<x>255</x>
<y>25</y>
<width>60</width>
<height>20</height>
<tooltip>$(actions)</tooltip>
</widget>
<widget type="led" version="2.0.0">
<name>LED</name>
<pv_name>TEST-PREFIX:</pv_name>
<x>340</x>
<y>25</y>
<width>20</width>
<height>20</height>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>PCAP: GATE</text>
<x>0</x>
<y>50</y>
<width>250</width>
<height>20</height>
</widget>
<widget type="textentry" version="3.0.0">
<name>TextEntry</name>
<pv_name>TEST-PREFIX:PCAP:GATE</pv_name>
<x>255</x>
<y>25</y>
<y>50</y>
<width>60</width>
<height>20</height>
<horizontal_alignment>1</horizontal_alignment>
Expand All @@ -70,15 +103,15 @@
<name>Label</name>
<text>PCAP: GATE: DELAY</text>
<x>0</x>
<y>50</y>
<y>75</y>
<width>250</width>
<height>20</height>
</widget>
<widget type="textentry" version="3.0.0">
<name>TextEntry</name>
<pv_name>TEST-PREFIX:PCAP:GATE:DELAY</pv_name>
<x>255</x>
<y>50</y>
<y>75</y>
<width>60</width>
<height>20</height>
<horizontal_alignment>1</horizontal_alignment>
Expand All @@ -87,7 +120,7 @@
<widget type="group" version="2.0.0">
<name>PARAMETERS</name>
<x>5</x>
<y>141</y>
<y>166</y>
<width>351</width>
<height>56</height>
<transparent>true</transparent>
Expand Down
16 changes: 11 additions & 5 deletions tests/test_ioc_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ async def test_softioc_records_block(mocked_panda_standard_responses):
try:
arm_queue = asyncio.Queue()
m1 = camonitor(TEST_PREFIX + ":PCAP:ARM", arm_queue.put, datatype=str)
assert await asyncio.wait_for(arm_queue.get(), TIMEOUT) == "0"
assert await asyncio.wait_for(arm_queue.get(), TIMEOUT) == "Disarm"

await caput(TEST_PREFIX + ":PCAP:ARM", 1, wait=True, timeout=TIMEOUT)

assert await asyncio.wait_for(arm_queue.get(), TIMEOUT) == "1"
assert await asyncio.wait_for(arm_queue.get(), TIMEOUT) == "Arm"
finally:
m1.close()

Expand Down Expand Up @@ -360,13 +360,19 @@ async def test_create_softioc_arm_disarm(
try:
arm_queue = asyncio.Queue()
m1 = camonitor(TEST_PREFIX + ":PCAP:ARM", arm_queue.put, datatype=str)
assert await asyncio.wait_for(arm_queue.get(), TIMEOUT) == "0"
assert await asyncio.wait_for(arm_queue.get(), TIMEOUT) == "Disarm"

# Put PVs and check the ioc sets the values
await caput(TEST_PREFIX + ":PCAP:ARM", "1", wait=True, timeout=TIMEOUT)
assert await asyncio.wait_for(arm_queue.get(), TIMEOUT) == "1"
assert await asyncio.wait_for(arm_queue.get(), TIMEOUT) == "Arm"
await caput(TEST_PREFIX + ":PCAP:ARM", "0", wait=True, timeout=TIMEOUT)
assert await asyncio.wait_for(arm_queue.get(), TIMEOUT) == "0"
assert await asyncio.wait_for(arm_queue.get(), TIMEOUT) == "Disarm"

# Test you can also use "Arm" and "Disarm" instead of "1" and "0"
await caput(TEST_PREFIX + ":PCAP:ARM", "Arm", wait=True, timeout=TIMEOUT)
assert await asyncio.wait_for(arm_queue.get(), TIMEOUT) == "Arm"
await caput(TEST_PREFIX + ":PCAP:ARM", "Disarm", wait=True, timeout=TIMEOUT)
assert await asyncio.wait_for(arm_queue.get(), TIMEOUT) == "Disarm"

finally:
m1.close()
Expand Down

0 comments on commit 82130ab

Please sign in to comment.