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

Question about alarms #48

Closed
douglasbeniz opened this issue May 7, 2019 · 4 comments
Closed

Question about alarms #48

douglasbeniz opened this issue May 7, 2019 · 4 comments

Comments

@douglasbeniz
Copy link

Hello again...

We're now trying to set an alarm to a PV.

Firstly, being honest, I still have a question if pvaPy should do this (in fact I'm helping someone else, so, I'm still understanding the requirements and why they decided to use pvaPy).

Then, what is desired (and my questions are: first, is possible to do it using pvaPy, second, how to do it):

  • set alarms
  • set limits (lolo, lo, hi, hihi)
  • if the value reaches limits, then alarms being set automatically.

Go to what we (they) did (and the alarms were not set automatically, as I expected because we didn't programme anything to set the alarms considering the value):

from pvaccess import *

# assigning some objects
# ----------------------------------------------
# PvTimeStamp(<long secondsPastEpoch>,
#             <int nanoseconds>,
#             <int userTag=-1>)
# ----------------------------------------------
ts      = PvTimeStamp(12345678, 12)
# ----------------------------------------------
# PvAlarm(<int severity>,
#         <int status>,
#         <string message>)
# ----------------------------------------------
alarm   = PvAlarm(13,-1,'testing an error!')

# creating a PV object
pv = PvObject(  {'value':           FLOAT,
                    'timeStamp':    ts,
                    'alarm':        alarm,
                    'descriptor':   STRING,
                    'lo':           FLOAT,
                    'lolo':         FLOAT,
                    'hi':           FLOAT,
                    'hihi':         FLOAT },
                {'value':           250.67
                    'timeStamp':    ts.toDict(),
                    'alarm':        alarm.toDict(),
                    'descriptor':   'A first test PV name 001',
                    'lo':           -321.15,
                    'lolo':         -321.75,
                    'hi':           32.65,
                    'hihi':         33.00} )

print(pv)

# ----------------------------------------------
# output
# ----------------------------------------------
douglasbeniz@douglasbeniz-thinkpad:~/Documents$ python pvaPy_example.py 
structure 
    string descriptor A first test PV name 001
    float hi 32.65
    float lo -321.15
    time_t timeStamp
        long secondsPastEpoch 12345678
        int userTag -1
        int nanoseconds 12
    alarm_t alarm
        int status -1
        string message testing an error!
        int severity 13
    float hihi 33
    float lolo -321.75
    float value 250.67
@sveseli
Copy link
Collaborator

sveseli commented May 29, 2019

PvaPy can process record on write using on write callback. Hence, if you wanted to do this using pvapy, you can (see https://epics.anl.gov/extensions/pvaPy/production/pvaccess.html#pvaserver). As far as I know, the underlying PV Database records are not doing any processing automatically at the moment.

@mrkraimer
Copy link
Contributor

I will start adding support for control and valueAlarm in PVRecord.
There is a method PVRecord::process that already has support for updating the timeStamp.
I will let it also implement control and valueAlarm if those fields exist at top level of record.

@douglasbeniz
Copy link
Author

PvaPy can process record on write using on write callback. Hence, if you wanted to do this using pvapy, you can (see https://epics.anl.gov/extensions/pvaPy/production/pvaccess.html#pvaserver). As far as I know, the underlying PV Database records are not doing any processing automatically at the moment.

Hey, Sinisa, thank you for your answer! To be honest, I expected something like that, I mean, we need to implement the behaviour when a PV value reaches such limits. I think we can use PvaServer by now...

I was studying channel monitors that seem to be an option already available, too.

@douglasbeniz
Copy link
Author

I will start adding support for control and valueAlarm in PVRecord.
There is a method PVRecord::process that already has support for updating the timeStamp.
I will let it also implement control and valueAlarm if those fields exist at top level of record.

That would be awesome, Marty! Thank you. I'll follow the next updates, so...

@sveseli sveseli closed this as completed Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants