Skip to content

Draft: DeviceProxy: expose new query event system methods

This is sistem MR to the cppTango!1500

Here we expose new methods. Can be used like:

import time
import json

from tango import EventType, ApiUtil
from tango.utils import EventCallback
from tango.server import Device, attribute, command
from tango.test_utils import DeviceTestContext

cb = EventCallback()

class MyDevice(Device):

    def init_device(self):
        super().init_device()
        self.set_change_event("attr", True, False)

    @attribute
    def attr(self):
        return 1

    @command
    def send_event(self):
        self.push_change_event("attr", 2)


if __name__ == "__main__":
    api_util = ApiUtil.instance()
    api_util.enable_event_system_perf_mon(True)
    with DeviceTestContext(MyDevice, timeout=60000, process=True) as proxy:
        eid = proxy.subscribe_event("attr", EventType.CHANGE_EVENT, cb)
        proxy.send_event()
        time.sleep(1)
        data = json.loads(api_util.query_event_system())
        print(json.dumps(data, indent=4))

Result:

Ready to accept request
Ready to accept request
2025-10-16 11:22:23.955671 TEST/NODB/MYDEVICE ATTR#DBASE=NO CHANGE [ATTR_VALID] 1.0
2025-10-16 11:22:23.958421 TEST/NODB/MYDEVICE ATTR#DBASE=NO CHANGE [ATTR_VALID] 2.0
{
    "version": 1,
    "server": null,
    "client": {
        "event_callbacks": {
            "tango://haso102ym.desy.de:0/test/nodb/mydevice/attr#dbase=no.idl5_change": {
                "channel_name": "tango://haso102ym.desy.de:0/dserver/mydevice/mydevice#dbase=no",
                "callback_count": 1,
                "server_counter": 1,
                "event_count": 1,
                "missed_event_count": 0,
                "discarded_event_count": 1,
                "last_resubscribed": null
            }
        },
        "not_connected": [],
        "event_channels": {
            "tango://haso102ym.desy.de:0/dserver/mydevice/mydevice#dbase=no": {
                "endpoint": "tcp://127.0.0.1:45215"
            }
        },
        "perf": [
            {
                "attr_name": "attr#dbase=no",
                "micros_since_last_event": null,
                "sleep_micros": 20191,
                "process_micros": 204,
                "first_callback_latency_micros": 193,
                "callback_count": 1,
                "wake_count": 5,
                "discarded": false
            },
            {
                "attr_name": "",
                "micros_since_last_event": 214,
                "sleep_micros": 6,
                "process_micros": 2,
                "first_callback_latency_micros": null,
                "callback_count": 0,
                "wake_count": 1,
                "discarded": true
            }
        ]
    }
}

Docu to be added if MR in cppTango will be merged

Edited by Yury Matveev

Merge request reports

Loading