Last active
April 4, 2017 13:01
-
-
Save dchabot/3f63bd0f6c7b7e1644aeabaa82b03f5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
record(ao, "test:ao") { | |
field(ASG, "rps_threshold") | |
field(DRVH, "10") | |
field(DRVL, "0") | |
} | |
record(bo, "test:bo") { | |
field(ASG, "rps_lock") | |
field(ZNAM, "OUT") | |
field(ONAM, "IN") | |
} | |
record(ao, "test:ao2") { | |
field(DRVH, "5") | |
field(DRVL, "1") | |
} | |
record(bo, "test:permit") { | |
field(VAL, "0") | |
field(PINI, "1") # get rid of INVALID status | |
field(ZNAM, "DISABLED") | |
field(ONAM, "ENABLED") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ASG(DEFAULT) { | |
RULE(1,READ) | |
RULE(1,WRITE,TRAPWRITE) | |
} | |
ASG(rps_threshold) { | |
INPA("$(P):permit") | |
RULE(1, READ) | |
RULE(0, WRITE, TRAPWRITE) { | |
CALC("A=1") | |
} | |
RULE(1, WRITE, TRAPWRITE) { | |
CALC("A=0") | |
} | |
} | |
ASG(rps_lock) { | |
INPA("$(P):permit") | |
RULE(1, READ) | |
RULE(1, WRITE, TRAPWRITE) { | |
CALC("A=0") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import subprocess | |
import epics | |
def softioc(): | |
proc = subprocess.Popen(['softIoc', '-m', 'P=test', '-a', "crit_sig_rules.cfg", | |
'-d', "cas_test.db"], | |
stdin=subprocess.PIPE, | |
stdout=subprocess.PIPE) | |
return proc | |
def pvs(): | |
pvlist = ['test:ao', 'test:ao.DRVH', 'test:bo', 'test:ao2', | |
'test:permit'] | |
pvs = dict() | |
for name in pvlist: | |
pv = epics.PV(name) | |
pv.wait_for_connection() | |
pvs[pv.pvname] = pv | |
return pvs | |
if __name__ == '__main__': | |
proc = softioc() | |
pvs = pvs() | |
for pv in pvs.values(): | |
assert pv.connected | |
# with the Permit DISABLED, access should be r/w | |
assert pvs['test:permit'].get(as_string=True) == 'DISABLED' | |
# with the permit disabled, all test pvs should be readable/writable | |
for pv in pvs.values(): | |
assert pv.read_access and pv.write_access | |
# Activate the Permit. CAS rules are now active. | |
pvs['test:permit'].put(1, wait=True) | |
assert pvs['test:permit'].get(as_string=True) == 'ENABLED' | |
assert pvs['test:bo'].read_access is True | |
# XXX THIS FAILS AND IT SHOULD NOT XXX | |
assert pvs['test:bo'].write_access is False | |
# this would also fail | |
assert pvs['test:ao.DRVH'].write_access is False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment