From cd94cb3b7e028aad18b8e56840b68c8d2afdbc94 Mon Sep 17 00:00:00 2001 From: Benjamin Labrecque Date: Wed, 8 Jul 2026 12:11:16 +0200 Subject: [PATCH] chore: add callback PV to template --- .../AGEBD-SERVICE-{{service_name_upper}}.py.jinja | 12 +++++++++--- .../current/ioc/{{service_name_upper}}.template | 10 ++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/templates/service/{{service_id}}-{{service_name_lower}}/current/app/src/AGEBD-SERVICE-{{service_name_upper}}.py.jinja b/templates/service/{{service_id}}-{{service_name_lower}}/current/app/src/AGEBD-SERVICE-{{service_name_upper}}.py.jinja index 38ca439..403a4cd 100644 --- a/templates/service/{{service_id}}-{{service_name_lower}}/current/app/src/AGEBD-SERVICE-{{service_name_upper}}.py.jinja +++ b/templates/service/{{service_id}}-{{service_name_lower}}/current/app/src/AGEBD-SERVICE-{{service_name_upper}}.py.jinja @@ -43,7 +43,9 @@ class PVs(BasePVs): # TODO: class attribute names usually lowercase # usually it is advisable to trigger the mainloop of a service on changes of certain PVs: - self.CallbackPV = PV("...", auto_monitor=dbr.DBE_VALUE) + self.CallbackPV = PV( + "AGEBD-{{ service_name_upper }}:CALLBACK", auto_monitor=dbr.DBE_VALUE + ) # TODO: ok? class Service(BaseService[PVs]): @@ -77,13 +79,17 @@ class Service(BaseService[PVs]): ####################################################################################### # here goes all the code that your service # is supposed to be running in any case, e.g., + # update some pvs/vals - self.pvs.my_pv1.put("MY_PV1 value") - self.pvs.my_pv2.put("MY_PV2 value") + # self.pvs.my_pv1.put("MY_PV1 value") + # self.pvs.my_pv2.put("MY_PV2 value") + + # get some pvs/vals self.val1 = self.pvs.my_pv1.get() self.val2 = self.pvs.my_pv2.get() print(self.val1) print(self.val2) + # maybe sleep to limit the update loop execution rate sleep(1) ####################################################################################### diff --git a/templates/service/{{service_id}}-{{service_name_lower}}/current/ioc/{{service_name_upper}}.template b/templates/service/{{service_id}}-{{service_name_lower}}/current/ioc/{{service_name_upper}}.template index 59bd9ae..857d84a 100644 --- a/templates/service/{{service_id}}-{{service_name_lower}}/current/ioc/{{service_name_upper}}.template +++ b/templates/service/{{service_id}}-{{service_name_lower}}/current/ioc/{{service_name_upper}}.template @@ -24,4 +24,14 @@ record(bo, "$(DEVICE):BO") { field(OSV, "NO_ALARM") field(VAL, "1") field(PINI, "YES") +} + +# TODO: ok? +record(bo, "$(DEVICE):CALLBACK") { + field(DESC, "Callback PV to listen to for changes") + field(ASG, "READONLY") + field(ZSV, "MINOR") + field(OSV, "NO_ALARM") + field(VAL, "1") + field(PINI, "YES") } \ No newline at end of file