From 2dc3101718a87e687e7a2834ef915ae3ba44cd9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Mon, 11 Dec 2023 08:43:52 +0100 Subject: [PATCH 1/3] Add MINP for soft motors Make it possible to set bits of the MSTA field for soft motors. Add a new input link, called MINP, beside the existing DINP and RINP MINP will read the new MSTA bits, but filter out the RA_DONE bit. The RA_DONE bit will be taken from DINP (as before) and the RA_DONE bit inside MINP will be ignored, preserving the RA_DONE coming from DINP Note that the MINP needs to follow the bit-definition in MSTA. It may update RA_PLUS_LS, RA_MINUS_LS. RA_HOMED or other bits may be set as well, whatever the application needs. MINP may be pointed to the output of a calc or transform record. --- motorApp/MotorSrc/motorRecord.dbd | 6 ++++++ motorApp/SoftMotorSrc/devSoft.cc | 17 +++++++++++++++++ motorApp/SoftMotorSrc/devSoft.h | 1 + motorApp/SoftMotorSrc/devSoftAux.cc | 20 ++++++++++++++++++-- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/motorApp/MotorSrc/motorRecord.dbd b/motorApp/MotorSrc/motorRecord.dbd index be7c549de..82106dc6f 100644 --- a/motorApp/MotorSrc/motorRecord.dbd +++ b/motorApp/MotorSrc/motorRecord.dbd @@ -754,6 +754,12 @@ recordtype(motor) { special(SPC_MOD) interest(1) } + field(MINP,DBF_INLINK) { + prompt("MSTA Input Link") + promptgroup(GUI_COMMON) + special(SPC_MOD) + interest(1) + } field(RINP,DBF_INLINK) { prompt("RMP Input Link") promptgroup(GUI_COMMON) diff --git a/motorApp/SoftMotorSrc/devSoft.cc b/motorApp/SoftMotorSrc/devSoft.cc index 55d291384..6773f001f 100644 --- a/motorApp/SoftMotorSrc/devSoft.cc +++ b/motorApp/SoftMotorSrc/devSoft.cc @@ -254,6 +254,23 @@ void soft_dinp_func(struct motorRecord *mr, short newdinp) } } +void soft_minp_func(struct motorRecord *mr, short newminp) +{ + msta_field status; + unsigned int old_RA_DONE; + if (interruptAccept != TRUE) + return; + + status.All = mr->msta; + old_RA_DONE = status.Bits.RA_DONE; + Debug(5, "update(): old msta=0x%04x newminp=0x%04x for %s.\n", + mr->msta, (unsigned)newminp, mr->name); + + status.All = newminp; + status.Bits.RA_DONE = old_RA_DONE; + mr->msta = status.All; + soft_process(mr); +} void soft_rinp_func(struct motorRecord *mr, long newrinp) { diff --git a/motorApp/SoftMotorSrc/devSoft.h b/motorApp/SoftMotorSrc/devSoft.h index 470091cd2..4f99e2f04 100644 --- a/motorApp/SoftMotorSrc/devSoft.h +++ b/motorApp/SoftMotorSrc/devSoft.h @@ -57,6 +57,7 @@ struct motor_node { extern long soft_init(int); extern long soft_init_record(void *); extern void soft_dinp_func(struct motorRecord *, short); +extern void soft_minp_func(struct motorRecord *, short); extern void soft_rdbl_func(struct motorRecord *, double); extern void soft_rinp_func(struct motorRecord *, long); extern void soft_motor_callback(CALLBACK *); diff --git a/motorApp/SoftMotorSrc/devSoftAux.cc b/motorApp/SoftMotorSrc/devSoftAux.cc index 05a049622..289437628 100644 --- a/motorApp/SoftMotorSrc/devSoftAux.cc +++ b/motorApp/SoftMotorSrc/devSoftAux.cc @@ -66,6 +66,7 @@ static inline void Debug(int level, const char *format, ...) } STATIC void soft_dinp(struct event_handler_args); +STATIC void soft_minp(struct event_handler_args); STATIC void soft_rdbl(struct event_handler_args); STATIC void soft_rinp(struct event_handler_args); STATIC EPICSTHREADFUNC soft_motor_task(void *); @@ -78,6 +79,11 @@ STATIC void soft_dinp(struct event_handler_args args) soft_dinp_func((struct motorRecord *) args.usr, *((short *) args.dbr)); } +STATIC void soft_minp(struct event_handler_args args) +{ + soft_minp_func((struct motorRecord *) args.usr, *((short *) args.dbr)); +} + STATIC void soft_rdbl(struct event_handler_args args) { @@ -162,7 +168,7 @@ STATIC EPICSTHREADFUNC soft_motor_task(void *parm) { struct motorRecord *mr; struct motor_node *node; - chid dinp, rdbl, rinp; + chid dinp, minp, rdbl, rinp; epicsEventId wait_forever; epicsEventWait(soft_motor_sem); /* Wait for dbLockInitRecords() to execute. */ @@ -195,7 +201,17 @@ STATIC EPICSTHREADFUNC soft_motor_task(void *parm) { ptr->default_done_behavior = true; } - + if (((mr->minp.type == PV_LINK) || + (mr->minp.type == CA_LINK) || + (mr->minp.type == DB_LINK)) && + (mr->minp.value.pv_link.pvname != NULL)) + { + Debug(5, "devSoftAux::soft_motor_task: adding minp link for motor %s link=%s\n", mr->name, mr->minp.value.pv_link.pvname); + SEVCHK(ca_search(mr->minp.value.pv_link.pvname, &minp),"ca_search() failure"); + SEVCHK(ca_add_event(DBR_SHORT, minp, soft_minp, mr, NULL),"ca_add_event() failure"); + SEVCHK(ca_pend_io((float) 5.0), "MINP link failure"); + } + if ((mr->urip != 0) && ((mr->rdbl.type == PV_LINK) || (mr->rdbl.type == CA_LINK) || From 4a902d082634418e50caf6b881af2c353bf7ae8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Tue, 6 Feb 2024 10:34:49 +0100 Subject: [PATCH 2/3] Bugfix for MINP: it is a long When implementing the MINP (MSTA input) it was overseen, that MSTA is defined as 32 bit (where only 15 bits are used). Correct this: use long instead of short. --- motorApp/SoftMotorSrc/devSoft.cc | 2 +- motorApp/SoftMotorSrc/devSoft.h | 2 +- motorApp/SoftMotorSrc/devSoftAux.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/motorApp/SoftMotorSrc/devSoft.cc b/motorApp/SoftMotorSrc/devSoft.cc index 6773f001f..aab385233 100644 --- a/motorApp/SoftMotorSrc/devSoft.cc +++ b/motorApp/SoftMotorSrc/devSoft.cc @@ -254,7 +254,7 @@ void soft_dinp_func(struct motorRecord *mr, short newdinp) } } -void soft_minp_func(struct motorRecord *mr, short newminp) +void soft_minp_func(struct motorRecord *mr, long newminp) { msta_field status; unsigned int old_RA_DONE; diff --git a/motorApp/SoftMotorSrc/devSoft.h b/motorApp/SoftMotorSrc/devSoft.h index 4f99e2f04..c000b18b5 100644 --- a/motorApp/SoftMotorSrc/devSoft.h +++ b/motorApp/SoftMotorSrc/devSoft.h @@ -57,7 +57,7 @@ struct motor_node { extern long soft_init(int); extern long soft_init_record(void *); extern void soft_dinp_func(struct motorRecord *, short); -extern void soft_minp_func(struct motorRecord *, short); +extern void soft_minp_func(struct motorRecord *, long); extern void soft_rdbl_func(struct motorRecord *, double); extern void soft_rinp_func(struct motorRecord *, long); extern void soft_motor_callback(CALLBACK *); diff --git a/motorApp/SoftMotorSrc/devSoftAux.cc b/motorApp/SoftMotorSrc/devSoftAux.cc index 289437628..780d0d470 100644 --- a/motorApp/SoftMotorSrc/devSoftAux.cc +++ b/motorApp/SoftMotorSrc/devSoftAux.cc @@ -81,7 +81,7 @@ STATIC void soft_dinp(struct event_handler_args args) STATIC void soft_minp(struct event_handler_args args) { - soft_minp_func((struct motorRecord *) args.usr, *((short *) args.dbr)); + soft_minp_func((struct motorRecord *) args.usr, *((long *) args.dbr)); } From 3df5ad8911f4c4eee866b7c1426620c835c42960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Wed, 24 Apr 2024 13:21:43 +0200 Subject: [PATCH 3/3] motorRecord.html: Add the MINP field Add the MINP field: It is "similar" to e.g. DINP --- docs/motorRecord.html | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/motorRecord.html b/docs/motorRecord.html index 4e9255ce8..2a922a85b 100644 --- a/docs/motorRecord.html +++ b/docs/motorRecord.html @@ -725,6 +725,13 @@

Field Descriptions

In addition to fields common to all record types (se SHORT
+ + MINP + R/W + MSTA Input Link + INLINK +
+ MDEL @@ -2047,6 +2054,14 @@

Field Descriptions

In addition to fields common to all record types (se link is used to set the DONE bit in the MSTA field; which in turn sets the DMOV field. + + MINP + R/W + MSTA Input Link + INLINK + If Soft Channel device support is specified, the value specified by this + link is used to set most bits of the MSTA field - all except the DONE bit, which comes through DINP + RINP R/W @@ -2065,11 +2080,11 @@

Field Descriptions

In addition to fields common to all record types (se

Soft Channel Device Driver

- The Soft Channel database links (i.e., DINP, RINP and STOO) are only processed + The Soft Channel database links (i.e., DINP, MINP, RINP and STOO) are only processed when the Soft Channel device driver is selected.  These links are ignored when using any other Motor Record device driver.

- The input links (i.e., DINP, RDBL and RINP) are monitored for value changes by a + The input links (i.e., DINP, MINP, RDBL and RINP) are monitored for value changes by a CA event task.  Users must choose either a dial input link (RDBL) or a raw input link (RINP), but not both. At this time, the above links are not dynamically retargetable.