paulscherrerinstitute / pcaspy

Portable Channel Access Server in Python
BSD 3-Clause "New" or "Revised" License
32 stars 24 forks source link

short type status/severity not updated #62

Closed xresende closed 5 years ago

xresende commented 5 years ago

server.py:

from pcaspy import Driver, SimpleServer

prefix = 'MTEST:'
pvdb = { 'SHORT': {'type': 'short'}, 'INT': {'type': 'int'}, }

class myDriver(Driver):
    def __init__(self):
        """."""
        Driver.__init__(self)
        self.tid = None
    def write(self, reason, value):
        """."""
        if reason in ('SHORT', 'INT'):
            self.setParam(reason, value)
        self.updatePV(reason)

if __name__ == '__main__':
    server = SimpleServer()
    server.createPV(prefix, pvdb)
    driver = myDriver()
    while True:
        server.process(0.1)

client:

import epics

pvshort = epics.PV('MTEST:SHORT')
pvshort.value = 13
print(pvshort.info)

pvint = epics.PV('MTEST:INT')
pvint.value = 14
print(pvint.info)

Output:

== MTEST:SHORT  (time_short) ==
   value      = 13
   char_value = '13'
   count      = 1
   nelm       = 1
   type       = time_short
   units      = 
   host       = lnls561-linux:5064
   access     = read/write
   status     = 17
   severity   = 3
   timestamp  = 1552655964.652 (2019-03-15 10:19:24.65152)
   posixseconds        = 1552655964.0
   nanoseconds= 651517835
   upper_ctrl_limit    = 0
   lower_ctrl_limit    = 0
   upper_disp_limit    = 0
   lower_disp_limit    = 0
   upper_alarm_limit   = 0
   lower_alarm_limit   = 0
   upper_warning_limit = 0
   lower_warning_limit = 0
   PV is internally monitored, with 0 user-defined callbacks:
=============================
== MTEST:INT  (time_long) ==
   value      = 14
   char_value = '14'
   count      = 1
   nelm       = 1
   type       = time_long
   units      = 
   host       = lnls561-linux:5064
   access     = read/write
   status     = 0
   severity   = 0
   timestamp  = 1552655964.675 (2019-03-15 10:19:24.67463)
   posixseconds        = 1552655964.0
   nanoseconds= 674635823
   upper_ctrl_limit    = 0
   lower_ctrl_limit    = 0
   upper_disp_limit    = 0
   lower_disp_limit    = 0
   upper_alarm_limit   = 0
   lower_alarm_limit   = 0
   upper_warning_limit = 0
   lower_warning_limit = 0
   PV is internally monitored, with 0 user-defined callbacks:
=============================
xiaoqiangwang commented 5 years ago

Thanks for spotting the mistake. It is fixed in master.