Skip to content

Commit

Permalink
Add MINP for soft motors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tboegi committed Dec 11, 2023
1 parent f8a3239 commit 2dc3101
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
6 changes: 6 additions & 0 deletions motorApp/MotorSrc/motorRecord.dbd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions motorApp/SoftMotorSrc/devSoft.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions motorApp/SoftMotorSrc/devSoft.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
20 changes: 18 additions & 2 deletions motorApp/SoftMotorSrc/devSoftAux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand All @@ -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)
{
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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) ||
Expand Down

0 comments on commit 2dc3101

Please sign in to comment.