Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove units sp option, add vent status and SP #4

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 51 additions & 13 deletions pace5000Sup/pace5000.db
Original file line number Diff line number Diff line change
Expand Up @@ -233,23 +233,14 @@ record(stringout, "$(P)UNITS:SP") {
field(SIML, "$(P)SIM")
field(SIOL, "$(P)SIM:UNITS:SP")
field(SDIS, "$(P)DISABLE")
info(INTEREST, "HIGH")
info(archive, "VAL")
}

record(stringout, "$(P)UNITS:SP_NO_ACTION") {
field(DESC, "Set Device Units but do not Action")
info(INTEREST, "LOW")
# Enforce units at startup
field(VAL, "Bar")
field(PINI, "YES")
info(INTEREST, "HIGH")
info(archive, "VAL")
}

record(stringout, "$(P)UNITS:SP:_SETTER") {
field(DESC, "Propagate string value to setpoint")
field(OMSL, "closed_loop")
field(DOL, "$(P)UNITS:SP_NO_ACTION")
field(OUT, "$(P)UNITS:SP CA")
}

#############################################

record(bi, "$(P)STATE") {
Expand Down Expand Up @@ -330,6 +321,53 @@ record(ai, "$(P)LIMIT:LOWER") {
info(archive, "VAL")
}

record(longin, "$(P)VENT_THRESHOLD") {
field(DTYP, "Soft Channel")
field(VAL, "$(VENT_THRESHOLD=5)")
}

record(mbbi, "$(P)VENT_STATUS") {
field(DTYP, "stream")
field(SCAN, "1 second")
field(INP, "@pace5000.proto getVent $(PORT)")
field(ZRVL, "0")
field(ZRST, "Vent OK")
field(ONVL, "1")
field(ONST, "Vent in progress")
field(TWVL, "2")
field(TWST, "Vent finished")
field(SIML, "$(P)SIM")
field(SIOL, "$(P)SIM:VENT_STATUS")
field(SDIS, "$(P)DISABLE")
info(archive, "VAL")
}

record(bo, "$(P)VENT:SP") {
field(DESC, "Start/abort venting")
field(ZNAM, "ABORT")
field(ONAM, "START")
field(FLNK, "$(P)VENT:SP:CALC.PROC")
}

record(calcout, "$(P)VENT:SP:CALC")
{
field(DESC, "vent if rbv<threshold")
field(INPA, "$(P)PRESSURE")
field(INPB, "$(P)VENT_THRESHOLD")
field(CALC, "(A<=B)?1:0")
field(OUT, "$(P)VENT:SP:OUT PP")
}

record(bo, "$(P)VENT:SP:OUT") {
field(DTYP, "stream")
field(OUT, "@pace5000.proto setVent $(PORT)")
info(archive, "VAL")
field(SIML, "$(P)SIM")
field(SIOL, "$(P)SIM:VENT:SP:OUT")
field(SDIS, "$(P)DISABLE")
field(UDFS, "No alarm")
}

#############################################

record(stringin, "$(P)ERROR") {
Expand Down
9 changes: 9 additions & 0 deletions pace5000Sup/pace5000.proto
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ getFSV {
in ":INST:SENS:FULL %f, %(\$1)f";
}

getVent {
out ":SOUR:VENT?";
in ":SOUR:VENT %d";
}

setVent {
out ":SOUR:VENT %d";
}

getError {
out ":SYST:ERR?";
in ":SYST:ERR %80c";
Expand Down
9 changes: 9 additions & 0 deletions system_tests/lewis_emulators/Pace5000/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ def reset(self):
self.limit_upper = 0.0
self.limit_lower = 0.0
self.error = "0, No error"
self.vent_status = 0

def vent(self, start):
if start == 1:
self.vent_status = 1
self.pressure = 0
self.vent_status = 2
else:
self.vent_status = 1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def __init__(self):
CmdBuilder(self.set_pressure_sp).escape(":SOUR:PRES:LEV:IMM:AMPL").spaces(at_least_one=True).float().eos().build(),
CmdBuilder(self.get_slew).escape(":SOUR:PRES:SLEW?").eos().build(),
CmdBuilder(self.set_slew).escape(":SOUR:PRES:SLEW").spaces(at_least_one=True).float().eos().build(),
CmdBuilder(self.get_vent).escape(":SOUR:VENT?").eos().build(),
CmdBuilder(self.set_vent).escape(":SOUR:VENT").spaces(at_least_one=True).int().eos().build(),
CmdBuilder(self.get_slew_mode).escape(":SOUR:PRES:SLEW:MODE?").eos().build(),
CmdBuilder(self.set_slew_mode).escape(":SOUR:PRES:SLEW:MODE").spaces(at_least_one=True).string().eos().build(),
CmdBuilder(self.get_units).escape(":UNIT:PRES?").eos().build(),
Expand Down Expand Up @@ -60,6 +62,14 @@ def get_slew(self):
@conditional_reply("connected")
def set_slew(self, value):
self.device.slew = value

@conditional_reply("connected")
def get_vent(self):
return f":SOUR:VENT {self.device.vent_status}"

@conditional_reply("connected")
def set_vent(self, value):
self.device.vent(value)

@conditional_reply("connected")
def get_slew_mode(self):
Expand Down
26 changes: 24 additions & 2 deletions system_tests/tests/pace5000.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,35 @@ def _set(self, pv, value):
def test_WHEN_read_only_pv_set_THEN_pv_read_correctly(self, _, pv, value):
self._set(pv, value)
self.ca.assert_that_pv_is(pv, value)


@skip_if_recsim("requires emulator logic")
def test_WHEN_pressure_above_vent_threshold_THEN_cannot_vent(self):
threshold = 5
pressure = 12.0
self._set("PRESSURE", pressure)
self.ca.assert_that_pv_is("PRESSURE", pressure)
self.ca.set_pv_value("VENT_THRESHOLD", threshold)
self.ca.set_pv_value("VENT:SP", 1)
self.ca.assert_that_pv_is_not("VENT:SP:OUT", 1)
self.ca.assert_that_pv_is("VENT_STATUS.RVAL", 0)
self.ca.assert_that_pv_is("PRESSURE", pressure)

@skip_if_recsim("requires emulator logic")
def test_WHEN_pressure_below_vent_threshold_THEN_can_vent(self):
threshold = 5
pressure = 3.0
self._set("PRESSURE", pressure)
self.ca.assert_that_pv_is("PRESSURE", pressure)
self.ca.set_pv_value("VENT_THRESHOLD", threshold)
self.ca.set_pv_value("VENT:SP", 1)
self.ca.assert_that_pv_is("VENT_STATUS.RVAL", 2)
self.ca.assert_that_pv_is("PRESSURE", 0)

@parameterized.expand(parameterized_list([
("PRESSURE:SP:RBV", "PRESSURE:SP", 0.5),
("SLEW", "SLEW:SP", 0.3),
("SLEW:MODE", "SLEW:MODE:SP", "LIN"),
("UNITS", "UNITS:SP", "ATM"),
("STATE", "STATE:SP", "Control")
]))
def test_WHEN_pv_set_THEN_pv_read_correctly(self, _, pv, sp, value):
Expand All @@ -88,7 +111,6 @@ def test_WHEN_pv_set_THEN_pv_read_correctly(self, _, pv, sp, value):
("PRESSURE:SP:RBV", "PRESSURE:SP_NO_ACTION", 0.5),
("SLEW", "SLEW:SP_NO_ACTION", 0.3),
("SLEW:MODE", "SLEW:MODE:SP_NO_ACTION", "LIN"),
("UNITS", "UNITS:SP_NO_ACTION", "ATM"),
("STATE", "STATE:SP_NO_ACTION", "Control")
]))
def test_GIVEN_no_action_setpoint_set_WHEN_action_triggered_THEN_pv_set_correctly(self, _, pv, sp_no_action, value):
Expand Down