From 0bf0cbd212c770edb2afc6b57ae586307e22f720 Mon Sep 17 00:00:00 2001 From: kmpeters Date: Wed, 13 Nov 2013 21:43:36 +0000 Subject: [PATCH] Modified motorUtil to also provide name of motor every time .DMOV field changes. This will allow smart clients to maintain a list of moving motors. --- motorApp/Db/motorUtil.db | 7 +++++++ motorApp/MotorSrc/motorUtil.cc | 33 +++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/motorApp/Db/motorUtil.db b/motorApp/Db/motorUtil.db index 1f05f16c..ef5a7d5a 100644 --- a/motorApp/Db/motorUtil.db +++ b/motorApp/Db/motorUtil.db @@ -34,6 +34,13 @@ record(calc, "$(P)alldoneBlink") { field(INPB, "$(P)alldoneBlink") } +# Allow smart clients to maintain a list of moving motors +record(waveform, "$(P)movingDiff") { + field(DESC, "Motor w/ last dmov change") + field(NELM, "62") + field(FTVL, "CHAR") +} + #! Further lines contain data used by VisualDCT #! View(50,124,1.3) #! Record("$(P)allstop",100,343,0,0,"$(P)allstop") diff --git a/motorApp/MotorSrc/motorUtil.cc b/motorApp/MotorSrc/motorUtil.cc index 2e8e1eb3..41f8669b 100644 --- a/motorApp/MotorSrc/motorUtil.cc +++ b/motorApp/MotorSrc/motorUtil.cc @@ -63,7 +63,7 @@ static void moving(int, chid, short); typedef struct motor_pv_info { - char name[PVNAME_SZ]; /* pv names limited to 28 chars + term. in dbDefs.h */ + char name[PVNAME_SZ]; /* pv names limited to 60 chars + term. in dbDefs.h */ chid chid_dmov; /* Channel id for .DMOV */ chid chid_stop; /* Channel id for .STOP */ int in_motion; @@ -80,9 +80,9 @@ int numMotors = 0; static Motor_pv_info *motorArray; static char **motorlist = 0; static char *vme; -static int old_numMotorsMoving = -1; -static short old_alldone_value = -1; -static chid chid_allstop, chid_moving, chid_alldone; +static int old_numMotorsMoving = 0; +static short old_alldone_value = 1; +static chid chid_allstop, chid_moving, chid_alldone, chid_movingdiff; /* ----- ---------------- ----- */ @@ -142,9 +142,14 @@ static int motorUtil_task(void *arg) strcat(temp, "alldone.VAL"); chid_alldone = getChID(temp); - if (!chid_moving || !chid_alldone) { - errlogPrintf("Failed to connect to %smoving or %salldone.\n" - "Check prefix matches Db\n", vme, vme); + /* setup $(P)movingDiff */ + strcpy(temp, vme); + strcat(temp, "movingDiff.VAL"); + chid_movingdiff = getChID(temp); + + if (!chid_moving || !chid_alldone || !chid_movingdiff) { + errlogPrintf("Failed to connect to %smoving or %salldone or %smovingDiff.\n" + "Check prefix matches Db\n", vme, vme, vme); ca_task_exit(); return ERROR; } @@ -287,15 +292,23 @@ static void moving(int callback_motor_index, chid callback_chid, { short new_alldone_value, done = 1, not_done = 0; int numMotorsMoving, status; + char diffChar; + char diffStr[PVNAME_STRINGSZ+1]; if (motorUtil_debug) errlogPrintf("%s is %s\n", motorArray[callback_motor_index].name, (callback_dmov) ? "STOPPED" : "MOVING"); - if (callback_dmov) + if (callback_dmov) + { motorArray[callback_motor_index].in_motion = 0; + diffChar = '-'; + } else + { motorArray[callback_motor_index].in_motion = 1; + diffChar = '+'; + } numMotorsMoving = motorMovingCount(); @@ -333,6 +346,10 @@ static void moving(int callback_motor_index, chid callback_chid, /* give $(P)moving the appropriate value */ ca_put(DBR_LONG, chid_moving, &numMotorsMoving); + + /* Tell which motor's dmov changed */ + sprintf(diffStr, "%c%s", diffChar, motorArray[callback_motor_index].name); + ca_array_put(DBR_CHAR, strlen(diffStr)+1, chid_movingdiff, diffStr); old_numMotorsMoving = numMotorsMoving; }