Skip to content

Commit 2dc3101

Browse files
committed
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.
1 parent f8a3239 commit 2dc3101

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

motorApp/MotorSrc/motorRecord.dbd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,12 @@ recordtype(motor) {
754754
special(SPC_MOD)
755755
interest(1)
756756
}
757+
field(MINP,DBF_INLINK) {
758+
prompt("MSTA Input Link")
759+
promptgroup(GUI_COMMON)
760+
special(SPC_MOD)
761+
interest(1)
762+
}
757763
field(RINP,DBF_INLINK) {
758764
prompt("RMP Input Link")
759765
promptgroup(GUI_COMMON)

motorApp/SoftMotorSrc/devSoft.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,23 @@ void soft_dinp_func(struct motorRecord *mr, short newdinp)
254254
}
255255
}
256256

257+
void soft_minp_func(struct motorRecord *mr, short newminp)
258+
{
259+
msta_field status;
260+
unsigned int old_RA_DONE;
261+
if (interruptAccept != TRUE)
262+
return;
263+
264+
status.All = mr->msta;
265+
old_RA_DONE = status.Bits.RA_DONE;
266+
Debug(5, "update(): old msta=0x%04x newminp=0x%04x for %s.\n",
267+
mr->msta, (unsigned)newminp, mr->name);
268+
269+
status.All = newminp;
270+
status.Bits.RA_DONE = old_RA_DONE;
271+
mr->msta = status.All;
272+
soft_process(mr);
273+
}
257274

258275
void soft_rinp_func(struct motorRecord *mr, long newrinp)
259276
{

motorApp/SoftMotorSrc/devSoft.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct motor_node {
5757
extern long soft_init(int);
5858
extern long soft_init_record(void *);
5959
extern void soft_dinp_func(struct motorRecord *, short);
60+
extern void soft_minp_func(struct motorRecord *, short);
6061
extern void soft_rdbl_func(struct motorRecord *, double);
6162
extern void soft_rinp_func(struct motorRecord *, long);
6263
extern void soft_motor_callback(CALLBACK *);

motorApp/SoftMotorSrc/devSoftAux.cc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static inline void Debug(int level, const char *format, ...)
6666
}
6767

6868
STATIC void soft_dinp(struct event_handler_args);
69+
STATIC void soft_minp(struct event_handler_args);
6970
STATIC void soft_rdbl(struct event_handler_args);
7071
STATIC void soft_rinp(struct event_handler_args);
7172
STATIC EPICSTHREADFUNC soft_motor_task(void *);
@@ -78,6 +79,11 @@ STATIC void soft_dinp(struct event_handler_args args)
7879
soft_dinp_func((struct motorRecord *) args.usr, *((short *) args.dbr));
7980
}
8081

82+
STATIC void soft_minp(struct event_handler_args args)
83+
{
84+
soft_minp_func((struct motorRecord *) args.usr, *((short *) args.dbr));
85+
}
86+
8187

8288
STATIC void soft_rdbl(struct event_handler_args args)
8389
{
@@ -162,7 +168,7 @@ STATIC EPICSTHREADFUNC soft_motor_task(void *parm)
162168
{
163169
struct motorRecord *mr;
164170
struct motor_node *node;
165-
chid dinp, rdbl, rinp;
171+
chid dinp, minp, rdbl, rinp;
166172
epicsEventId wait_forever;
167173

168174
epicsEventWait(soft_motor_sem); /* Wait for dbLockInitRecords() to execute. */
@@ -195,7 +201,17 @@ STATIC EPICSTHREADFUNC soft_motor_task(void *parm)
195201
{
196202
ptr->default_done_behavior = true;
197203
}
198-
204+
if (((mr->minp.type == PV_LINK) ||
205+
(mr->minp.type == CA_LINK) ||
206+
(mr->minp.type == DB_LINK)) &&
207+
(mr->minp.value.pv_link.pvname != NULL))
208+
{
209+
Debug(5, "devSoftAux::soft_motor_task: adding minp link for motor %s link=%s\n", mr->name, mr->minp.value.pv_link.pvname);
210+
SEVCHK(ca_search(mr->minp.value.pv_link.pvname, &minp),"ca_search() failure");
211+
SEVCHK(ca_add_event(DBR_SHORT, minp, soft_minp, mr, NULL),"ca_add_event() failure");
212+
SEVCHK(ca_pend_io((float) 5.0), "MINP link failure");
213+
}
214+
199215
if ((mr->urip != 0) &&
200216
((mr->rdbl.type == PV_LINK) ||
201217
(mr->rdbl.type == CA_LINK) ||

0 commit comments

Comments
 (0)