Hello Tech-Talk,
I am working with PvaPy to create and update some PVs and am trying to work out how to configure the alarms for the pv.
I have created the object using the code below, which creates the ‘counter’ pv and updates the values (which I can see with a pvmonitor or a pvinfo).
initial_time = time.time()
seconds, nanoseconds = extract_seconds_and_nanoseconds_from_timestamp(initial_time)
timestamp = PvTimeStamp(seconds, nanoseconds, 0)
# configure display values
display = PvDisplay(0, 10, 'Test Display', 'Test Format', 'units')
# set up alarm - severity (0=NO_ALARM, 1=MINOR, 2=MAJOR, 3=INVALID, 4=UNDEFINED), status, message
alarm = PvAlarm()
alarm.setSeverity(0)
alarm.setMessage('test alarm message')
alarm_values = PvValueAlarm(FLOAT)
alarm_values.setHighAlarmLimit(9)
alarm_values.setLowAlarmLimit(2)
alarm_values.setHighWarningLimit(8)
alarm_values.setLowWarningLimit(3)
alarm_values.setHighAlarmSeverity(2)
alarm_values.setLowAlarmSeverity(2)
alarm_values.setHighWarningSeverity(1)
alarm_values.setLowWarningSeverity(1)
alarm_values.setActive(True)
pv = PvObject({
'value': FLOAT,
'timeStamp': timestamp,
'display': display,
'alarm': alarm,
'alarm_values': alarm_values
}, {
'timeStamp': timestamp.toDict(),
'display': display.toDict(),
'alarm': alarm.toDict(),
'alarm_values': alarm_values.toDict()
})
server = PvaServer()
server.addRecord('counter', pv)
c = 0
startTime = time.time()
try:
while True:
time.sleep(1)
if c == 11:
c = 0
seconds, nanoseconds = extract_seconds_and_nanoseconds_from_timestamp(time.time())
epics_message = {
'value': c,
'timeStamp': {
'secondsPastEpoch': seconds,
'nanoseconds': nanoseconds
}
}
pv.set(epics_message)
c += 0.5
finally:
server.stop()
This creates a PV with the following structure:
float value 10.5
time_t timeStamp 2021-06-07 13:31:45.733
long secondsPastEpoch 1623069105
int nanoseconds 732768297
int userTag 0
display_t display
double limitLow 0
double limitHigh 10
string description "Test Display"
string format "Test Format"
string units units
alarm_t alarm
int severity 0
int status 0
string message "test alarm message"
valueAlarm_t alarm_values
boolean active true
float lowAlarmLimit 2
float lowWarningLimit 3
float highWarningLimit 8
float highAlarmLimit 9
int lowAlarmSeverity 2
int lowWarningSeverity 1
int highWarningSeverity 1
int highAlarmSeverity 2
byte hysteresis 0
As you can hopefully see from the code, I have set up the alarms with severity 0 (NO_ALARM) to begin with and set the severity of the warnings and limits to be MINOR and MAJOR (2 and 3).
However, using this set-up I would expect to see the alarm messages raised when the value of the PV approaches 0 or 10, but no alarm messages are displayed. The only time I am able to see messages is if I set the severity of the alarm object
to be something other than 0, but this then raises alarm messages for all value states which is not the desired behaviour.
Is there something that I’m missing in the configuration of the alarms? Is there something that I need to set to ‘activate’ the logic behind the alarms?
Kathryn Baker (she/her)
Software Development for Accelerator Control Systems Graduate
Science and Technology Facilities Council
k.baker at stfc.ac.uk