/*============================================================================= Name: loopFcom.c Abs: Auth: 12 aug 2009, dROGIND created Rev: -----------------------------------------------------------------------------*/ #include "copyright_SLAC.h" /* SLAC copyright comments */ /*----------------------------------------------------------------------------- Mod: (newest to oldest) 26 june 2009, DROGIND created =============================================================================*/ #include "debugPrint.h" #ifdef DEBUG_PRINT #include int loopFcomFlag = DP_INFO; #endif /* c includes */ #include /* memcpy */ #include /* debug sin function */ #include /* posix clock_gettime for diagnostics */ /* fcom */ #include /* fcom function calls */ #include /* fcomLCLSPV2FcomId */ #include /* the bpm fcom data structure */ #include /* the blen fcom data structure */ /* loop includes */ #include "ffGlob.h" /* thread vars, etc - must be first include */ #include "ffTypes.h" /* LOCAL */ #include "loopDev.h" /* loop_as data struct */ #include "loopFcom.h" /* function prototypes */ LOCAL void loopFcomAssignDataAccess (device_ts *device); LOCAL void loopFcomSaveMeasData( FcomBlob* blob_ps, int loop, int i); LOCAL int loopFcomSubscribe (ffThread_te ffThread_e); LOCAL int loopFcomSendActBlobs (ffThread_te ffThread_e); LOCAL int loopFcomSendStateBlobs (ffThread_te ffThread_e); LOCAL int loopFcomVerifyBlob(FcomID id, FcomBlobRef blob_ps ); LOCAL void loopFcomShowBlob(FcomID id, FcomBlobRef blob_ps ); /*----------------------------------------------------------------------- Name: loopFcomInit Abs: initializes loop fcom IDs and store them in loop_as Args: Rem: go through all names and store the FCOM ID for the device/state store the fcom ID whether it is used or not - this is done every time the loop is reconfigured. Also subscribe to all meas devices - for now, we will never unsubscribe Finally, discover the data type for each device so that the fcom data can be stored by ATTRIBUTE type. assign the fcom data access. for example: BPMs have an X, Y and TMIT value in their fcom data packet, the X, Y, TMIT data must be copied from the appropriate location in the fcom packet to the loopRT_as struct for this loop. Side: this is called ONLY ONCE on loop startup. NOT called for reconfiguration or on ON/OFF transitions Ret: int fcom error code ----------------------------------------------------------------------*/ int loopFcomInit (ffThread_te ffThread_e) { int i; loopDev_ts *loop_ps; int status = OKOK; int loop = ffThreads_as[ffThread_e].loopNum; loop_ps = &loop_as[loop]; for (i=0;imeasNum; i++) { loop_ps->measDev_as[i].fcomId = fcomLCLSPV2FcomID ((char*)loop_ps->measDev_as[i].pvName_ca); loopFcomAssignDataAccess(&loop_ps->measDev_as[i]); } for (i=0;iactNum; i++) { loop_ps->actDev_as[i].fcomId = fcomLCLSPV2FcomID ((char*)loop_ps->actDev_as[i].pvName_ca); } for (i=0;istateNum; i++) { loop_ps->state_as[i].fcomId = fcomLCLSPV2FcomID ((char*)loop_ps->state_as[i].pvName_ca); } /* subscribe to all the meas devices */ status = loopFcomSubscribe(ffThread_e); return(status); } /*----------------------------------------------------------------------- Name: loopFcomAssignDataAccess Abs: assign data access index for this measurement data Args: Rem: Side: Ret: int fcom error code ----------------------------------------------------------------------*/ LOCAL void loopFcomAssignDataAccess (device_ts *device) { device->fcomAccessId = fcDefault; if (strstr((char *)device->pvName_ca, ":X")) device->fcomAccessId = fcBpmX; else if (strstr((char *)device->pvName_ca, ":Y")) device->fcomAccessId = fcBpmY; else if (strstr((char *)device->pvName_ca, ":TMIT")) device->fcomAccessId = fcBpmT; else if (strstr((char *)device->pvName_ca, ":ARAW")) device->fcomAccessId = fcBlenAr; else if (strstr((char *)device->pvName_ca, ":AIMAX")) device->fcomAccessId = fcBlenAi; else if (strstr((char *)device->pvName_ca, ":BRAW")) device->fcomAccessId = fcBlenBr; else if (strstr((char *)device->pvName_ca, ":BIMAX")) device->fcomAccessId = fcBlenBi; DEBUGPRINT(DP_INFO, loopFcomFlag, ("loopFcomAccessID: %s has accessID %d\n", (char *)device->pvName_ca, device->fcomAccessId )); } /*----------------------------------------------------------------------- Name: loopFcomSubscribe Abs: subscribe to this loop's measurement data Args: Rem: go through all meas devices and subscribe. Side: fcomSubscribe nests, so here where there can be BPM X AND BPM Y subcriptions (for example) the subscribe is called twice on the same id. Must use loopFcomUnsubscribe to unwind all subscriptions Ret: int fcom error code ----------------------------------------------------------------------*/ LOCAL int loopFcomSubscribe (ffThread_te ffThread_e) { int i; int status = OKOK; int loop = ffThreads_as[ffThread_e].loopNum; loopDev_ts *loop_ps = &loop_as[loop]; for (i=0;imeasNum; i++) { status = fcomSubscribe(loop_ps->measDev_as[i].fcomId, FCOM_ASYNC_GET); DEBUGPRINT(DP_INFO, loopFcomFlag, ("loopFcomSubscribe: subscribe to fcomId =0x%lx status = %s\n", loop_ps->measDev_as[i].fcomId, fcomStrerror(status) )); } return (status); } /*----------------------------------------------------------------------- Name: loopFcomUnsubscribe Abs: Unsubscribe to this loop's measurement data Args: Rem: go through all meas devices and unsubscribe from the fcomId Side: fcomSubscribe nests, so here where there can be BPM X AND BPM Y subcriptions (for example) the subscribe is called twice on the same id. Must use loopFcomUnsubscribe to unwind all subscriptions Ret: int fcom error code ----------------------------------------------------------------------*/ int loopFcomUnsubscribe (ffThread_te ffThread_e) { int i; int status = OKOK; int loop = ffThreads_as[ffThread_e].loopNum; loopDev_ts *loop_ps = &loop_as[loop]; for (i=0;imeasNum; i++) { status = fcomUnsubscribe(loop_ps->measDev_as[i].fcomId); DEBUGPRINT(DP_INFO, loopFcomFlag, ("loopFcomUnsubscribe: Unsubscribe to fcomId =0x%lx status = %s\n", loop_ps->measDev_as[i].fcomId, fcomStrerror(status) )); } return (status); } /*----------------------------------------------------------------------- Name: loopFcomGetBlobs Abs: reads the fcom data from the measurement devices, verifys data, checks the timestamp Args: loop_as pointer to loop_as entry Rem: go through all names and get the latest blobs from these devices compare timestamps together and with waitEvent.current_time Side: Ret: int fcom error code ----------------------------------------------------------------------*/ int loopFcomGetBlobs (ffThread_te ffThread_e) { int i; int goodnum; int status = OKOK; ffThread_ts *ffLoop_ps = &ffThreads_as[ffThread_e]; int loop = ffLoop_ps->loopNum; loopDev_ts *loop_ps = &loop_as[loop]; epicsTimeStamp blobTime_s; epicsTimeStamp begin_s, end_s; epicsInt32 blob_pId, pIdDiff; /* count the number of iterations */ loopRT_as[loop].meas.diag_s.iterations++ ; loopRT_as[loop].meas.num = loop_ps->measNum; /* I know this is done too often...*/ /* get the time from fiducial */ epicsTimeGetCurrent(&begin_s); loopRT_as[loop].timeFromFiducial =timeDiff(ffWakeupEvents_s.clockTime_s, begin_s); goodnum = 0; /* counts good data packets */ loopRT_as[loop].meas.numused = 0; /* get fcom data for each 'used' measurement device */ for (i=0;imeasNum; i++) { if (loop_ps->measDev_as[i].used) { loopRT_as[loop].meas.numused++; loopRT_as[loop].meas.used_au[i]=1; if ( (status = fcomGetBlob(loop_ps->measDev_as[i].fcomId, &(loop_ps->measDev_as[i].blob_ps), 0))) { loopRT_as[loop].meas.diag_s.fcom_err++ ; loopRT_as[loop].meas.diag_as[i].fcom_err++ ; DEBUGPRINT(DP_ERROR, loopFcomFlag, ("loopFcom: fcomGetBlob %s error: %s \n", (char *) loop_ps->measDev_as[i].pvName_ca, fcomStrerror(status))); loop_ps->measDev_as[i].blob_ps = NULL; } else { if ( (status = loopFcomVerifyBlob(loop_ps->measDev_as[i].fcomId, loop_ps->measDev_as[i].blob_ps )) ) { loopRT_as[loop].meas.diag_s.fcom_err++ ; loopRT_as[loop].meas.diag_as[i].fcom_err++ ; DEBUGPRINT(DP_ERROR, loopFcomFlag, ("loopFcom: fcomVerifyBlob %s error \n", (char *) loop_ps->measDev_as[i].pvName_ca)); } else { blobTime_s.secPastEpoch = loop_ps->measDev_as[i].blob_ps->fc_tsHi; blobTime_s.nsec = loop_ps->measDev_as[i].blob_ps->fc_tsLo; blob_pId = PULSEID(blobTime_s); pIdDiff = blob_pId - ffWakeupEvents_s.pulseId; if (pIdDiff !=0) { if (pIdDiff >0) { loopRT_as[loop].meas.diag_s.late++; loopRT_as[loop].meas.diag_as[i].late++; } else { if (pIdDiff<0) { loopRT_as[loop].meas.diag_s.old++; loopRT_as[loop].meas.diag_as[i].old++; } else DEBUGPRINT(DP_INFO, loopFcomFlag, ("loopFcom: %s pulseidDiff = %d \n", (char *) loop_ps->measDev_as[i].pvName_ca, pIdDiff)); } } else { loopFcomSaveMeasData(loop_ps->measDev_as[i].blob_ps, loop, i); loopRT_as[loop].meas.diag_s.good++ ; loopRT_as[loop].meas.diag_as[i].good++ ; goodnum++; } } /* release the blob! This needs to be added back when testing done*/ /*fcomReleaseBlob( &(loop_ps->measDev_as[i].blob_ps));*/ } } else loopRT_as[loop].meas.used_au[i]=0; } /* count the good measurement sets */ if (loopRT_as[loop].meas.numused==goodnum) loopRT_as[loop].meas.numgood++; /* get the process time */ epicsTimeGetCurrent( &end_s); loopRT_as[loop].timeLoopProcess =timeDiff(begin_s, end_s); return (status); } /*----------------------------------------------------------------------- Name: loopFcomReleaseBlobs Abs: releases all the blobs collected by this loop iteration Args: ffThread_e index into ffThreads_as struct for this loop Rem: Side: Ret: void ----------------------------------------------------------------------*/ void loopFcomReleaseBlobs (ffThread_te ffThread_e) { int i; ffThread_ts *ffLoop_ps = &ffThreads_as[ffThread_e]; int loop = ffLoop_ps->loopNum; loopDev_ts *loop_ps = &loop_as[loop]; /* release blob for each 'used' measurement device */ for (i=0;imeasNum; i++) { if ( (loop_ps->measDev_as[i].used ) && (loop_ps->measDev_as[i].blob_ps !=NULL) ) fcomReleaseBlob(&(loop_ps->measDev_as[i].blob_ps)); } } /*----------------------------------------------------------------------- Name: loopFcomVerifyBlob Abs: verifies the fcom version, id, and timestamp Args: FcomId id, FcomBlobRef blob pointer, int *rc_p pointer to memcmp return code Rem: Side: Ret: int return code OKOK or NOT_OK rc_p >0 if the blob timestamp is later than the fiducial timestamp rc_p <0 of the blob timestamp is earlier (old blob) rc_p==0 if timestamps match ----------------------------------------------------------------------*/ LOCAL int loopFcomVerifyBlob(FcomID id, FcomBlobRef blob_ps ) { /* get pulse id from blob */ if (blob_ps!=NULL) { /* ensure the fcom blob header values are what we expect */ if ((blob_ps->fc_vers == FCOM_PROTO_VERSION) &&(blob_ps->fc_idnt == id)) { return OKOK; } return NOT_OK; } return NOT_OK; } /*----------------------------------------------------------------------- Name: loopFcomSaveMeasData Abs: save meas data into the loopRT_as runtime data arrays Args: Rem: Side: Ret: int fcom return code ----------------------------------------------------------------------*/ LOCAL void loopFcomSaveMeasData( FcomBlob* blob_ps, int loop, int i) { /* DEBUGPRINT(DP_ERROR, loopFcomFlag, ("loopFcomSaveMeasData: blob data = %f, from dev i=%d, cnt=%d\n", blob_ps->fc_flt[0], i, cnt)); */ /* now store the data value from the fcom blob */ switch ( loop_as[loop].measDev_as[i].fcomAccessId) { case fcDefault: loopRT_as[loop].meas.val_ad[i] = blob_ps->fc_dbl[0]; break; case fcBpmX: loopRT_as[loop].meas.val_ad[i] = blob_ps->fcbl_bpm_X; break; case fcBpmY: loopRT_as[loop].meas.val_ad[i] = blob_ps->fcbl_bpm_Y; break; case fcBpmT: loopRT_as[loop].meas.val_ad[i] = blob_ps->fcbl_bpm_T; break; case fcBlenAr: loopRT_as[loop].meas.val_ad[i] = blob_ps->fcbl_blen_araw; break; case fcBlenAi: loopRT_as[loop].meas.val_ad[i] = blob_ps->fcbl_blen_aimax; break; case fcBlenBr: loopRT_as[loop].meas.val_ad[i] = blob_ps->fcbl_blen_braw; break; case fcBlenBi: loopRT_as[loop].meas.val_ad[i] = blob_ps->fcbl_blen_bimax; break; default: loopRT_as[loop].meas.val_ad[i] = blob_ps->fc_flt[0]; break; } } /*----------------------------------------------------------------------- Name: loopFcomGetDebugBlobs Abs: makes dummy fcom data for the measurement devices, used to test the mq send to ffEpicsSend thread, and storage to PVs Args: loop_as pointer to loop_as entry Rem: go through all meas devices and create dummy data in loopRT_as Side: Ret: int fcom error code ----------------------------------------------------------------------*/ int loopFcomGetDebugBlobs (ffThread_te ffThread_e) { int i, cnt; int status = OKOK; ffThread_ts *ffLoop_ps = &ffThreads_as[ffThread_e]; int loop = ffLoop_ps->loopNum; loopDev_ts *loop_ps = &loop_as[loop]; /* get fcom data for each 'used' measurement device */ cnt = 0; for (i=0;imeasNum; i++) { if (loop_ps->measDev_as[i].used) { /* store the index of this meas device as the value for debug */ loopRT_as[loop].meas.val_ad[i] = sin(loopRT_as[loop].count) + cnt; loopRT_as[loop].meas.used_au[i] = 1; cnt++; } else loopRT_as[loop].meas.used_au[i] = 0; } loopRT_as[loop].meas.numused = cnt; loopRT_as[loop].meas.num =loop_ps->measNum; DEBUGPRINT(DP_DEBUG, loopFcomFlag, ("loopFcomDebugBlobs: got %d blobs out of %d\n", cnt,loop_ps->measNum )); return (status); } /*----------------------------------------------------------------------- Name: loopFcomSendBlobs Abs: sends the Fcom actuator command and states data Args: Rem: Side: Ret: int fcom return code ----------------------------------------------------------------------*/ int loopFcomSendBlobs (ffThread_te ffThread_e) { int status = OKOK; /*DEBUGPRINT(DP_DEBUG, loopFcomFlag,("loopFcom:sendBlobs sending...\n"));*/ if ((status = loopFcomSendActBlobs(ffThread_e))==OKOK) { status = loopFcomSendStateBlobs(ffThread_e); } return status; } /*----------------------------------------------------------------------- Name: loopFcomSendActBlobs Abs: sends the Fcom actuator commands as individual groups Args: ffThread_e index into ffThreads_as global structure Rem: actuator commands are always sent as individual packets as blobs Side: Ret: int fcom return code ----------------------------------------------------------------------*/ LOCAL int loopFcomSendActBlobs (ffThread_te ffThread_e) { int i, rc; ffThread_ts *ffLoop_ps = &ffThreads_as[ffThread_e]; int loop = ffLoop_ps->loopNum; loopDev_ts *loop_ps = &loop_as[loop]; FcomBlob blob; epicsTimeStamp time_s, timeActive_s; epicsInt32 pulseId, pulseIdActive, pIdDiff; int status = OKOK; loopRT_as[loop].act.diag_s.iterations++; if (loopRT_as[loop].act.numused ==0) { /*DEBUGPRINT(DP_DEBUG, loopFcomFlag,("loopFcom: sendActs no acts to send \n"));*/ return(status); } /* get the current pulse id get it two ways to compare*/ rc = evrTimeGetFromPipeline(&time_s, evrTimeCurrent, 0,0,0,0,0); rc = evrTimeGetFromPipeline(&timeActive_s, evrTimeActive, 0,0,0,0,0); pulseId = PULSEID(time_s); pulseIdActive = PULSEID(timeActive_s); /* preload the blob with the evrTimeActive time */ blob.fc_vers = FCOM_PROTO_VERSION; blob.fc_tsHi = timeActive_s.secPastEpoch; blob.fc_tsLo = timeActive_s.nsec; blob.fc_stat = 0; blob.fc_type = FCOM_EL_DOUBLE; blob.fc_nelm = 1; /* each actuator command is sent in its own group */ for (i=0; i< loop_ps->actNum; i++) { /* set up the blob */ if (loopRT_as[loop].act.used_au[i]) { blob.fc_idnt = loop_ps->actDev_as[i].fcomId; blob.fc_dbl = (double *) &loopRT_as[loop].act.val_ad[i]; /*DEBUGPRINT(DP_DEBUG, loopFcomFlag, ("loopFcom:sendActs adding act i=%d, val=%f, blob fcomid = (0x%lx). blob val=%f\n", i, loopRT_as[loop].act.val_ad[i], blob.fc_idnt, blob.fc_dbl[0]));*/ if ( (status = fcomPutBlob(&blob)) ) { loopRT_as[loop].act.diag_s.fcom_err++; DEBUGPRINT(DP_ERROR, loopFcomFlag, ("loopFcom: fcomPutBlob %s error: %s \n", (char *) loop_ps->actDev_as[i].pvName_ca, fcomStrerror(status))); } else { /* sent the packet, save timing stats */ pIdDiff = pulseId-ffWakeupEvents_s.pulseId; if ( pIdDiff ) { if (pIdDiff>0) { /* sending late - not on same timeslot */ loopRT_as[loop].act.diag_s.late++; pIdDiff = pulseIdActive - ffWakeupEvents_s.pulseId; if (pIdDiff ) { /* really late - not even the same pulse we'll put this stat in 'old'*/ loopRT_as[loop].act.diag_s.old++; } } } else { loopRT_as[loop].act.diag_s.good++ ; } } } } return status; } /*----------------------------------------------------------------------- Name: loopFcomSendStateBlobs Abs: sends the Fcom states data all in one group Args: ffThread_e index into ffThreads_as global structure Rem: states data is always sent together in one group packet Side: Ret: int fcom return code ----------------------------------------------------------------------*/ LOCAL int loopFcomSendStateBlobs (ffThread_te ffThread_e) { int i, rc; ffThread_ts* ffLoop_ps = &ffThreads_as[ffThread_e]; int loop = ffLoop_ps->loopNum; loopDev_ts* loop_ps = &loop_as[loop]; FcomGroup group; FcomBlob blob; double data[1]; epicsTimeStamp time_s, timeActive_s; unsigned int pulseId, pulseIdActive; int status = OKOK; loopRT_as[loop].state.diag_s.iterations++; if (loopRT_as[loop].state.num ==0) { /* DEBUGPRINT(DP_DEBUG, loopFcomFlag,("loopFcom: sendStates no states to send \n"));*/ return(status); } /* get a group */ if ( (status=fcomAllocGroup(FCOM_ID_ANY, &group)) ) { loopRT_as[loop].state.diag_s.fcom_err++; DEBUGPRINT(DP_ERROR, loopFcomFlag, ("loopFcom: sendStates:fcomAllocGroup error: %s \n", fcomStrerror(status))); return(status); } /* get the current pulse id get it two ways to compare*/ rc = evrTimeGetFromPipeline(&time_s, evrTimeCurrent, 0,0,0,0,0); rc = evrTimeGetFromPipeline(&timeActive_s, evrTimeActive, 0,0,0,0,0); pulseId = PULSEID(time_s); pulseIdActive = PULSEID(timeActive_s); /* preload the blob */ blob.fc_vers = FCOM_PROTO_VERSION; blob.fc_tsHi = ffWakeupEvents_s.current_time_s.secPastEpoch; blob.fc_tsLo = ffWakeupEvents_s.current_time_s.nsec; blob.fc_stat = 0; blob.fc_type = FCOM_EL_DOUBLE; blob.fc_nelm = 1; blob.fc_dbl = &(data[0]); /* all states are sent as one group */ for (i=0; i< loop_ps->stateNum; i++) { /* set up the blob */ if (loopRT_as[loop].state.used_au[i]) { blob.fc_idnt = loop_ps->state_as[i].fcomId; blob.fc_dbl = (double *) &loopRT_as[loop].state.val_ad[i]; /*DEBUGPRINT(DP_DEBUG, loopFcomFlag, ("loopFcom:sendStates adding state i=%d, val=%f, blob fcomid = (0x%lx). blob val=%f\n", i, loopRT_as[loop].act.val_ad[i], blob.fc_idnt, blob.fc_dbl[0]));*/ if ( (status = fcomAddGroup(group, &blob)) ) { loopRT_as[loop].state.diag_s.fcom_err++; DEBUGPRINT(DP_ERROR, loopFcomFlag, ("loopFcom: sendStates:fcomAddGroup %s error: %s \n", (char *) loop_ps->state_as[i].pvName_ca, fcomStrerror(status))); fcomFreeGroup(group); return (status); } else { /* loaded the packet, save timing stats */ if ( (rc=memcmp(&(pulseId),&(ffWakeupEvents_s.pulseId),sizeof(unsigned int))) ) { if (rc>0) { /* sending late - not on same timeslot */ loopRT_as[loop].act.diag_s.late++; if ( (rc=memcmp(&(pulseIdActive),&(ffWakeupEvents_s.pulseId),sizeof(unsigned int))) ) { if (rc>0) /* really late - not even the same pulse we'll put this stat in 'old'*/ loopRT_as[loop].act.diag_s.old++; else /* weird - this pulse Id Active is before wakup pulse id! */ DEBUGPRINT(DP_ERROR, loopFcomFlag, ("loopFcom: fcomPutBlob %s error: send pulseIdActive is before measurement! \n", (char *) loop_ps->actDev_as[i].pvName_ca)); } } else { /* weird - this pulse Id is before we processed! */ DEBUGPRINT(DP_ERROR, loopFcomFlag, ("loopFcom: fcomPutBlob %s error: send pulseId is before measurement! \n", (char *) loop_ps->actDev_as[i].pvName_ca)); } } else { loopRT_as[loop].act.diag_s.good++ ; } } } } if ( (status = fcomPutGroup(group)) ) { DEBUGPRINT(DP_ERROR, loopFcomFlag, ("loopFcom: sendStates fcomPutGroup error\n")); } group = 0; return status; } /*----------------------------------------------------------------------- Name: loopFcomShowBlobs Abs: shows all the blobs collected by this loop iteration Args: ffThread_e index into ffThreads_as struct for this loop Rem: get the latest blobs and print details Side: Ret: void ----------------------------------------------------------------------*/ void loopFcomShowBlobs (ffThread_te ffThread_e) { int i; ffThread_ts *ffLoop_ps = &ffThreads_as[ffThread_e]; int loop = ffLoop_ps->loopNum; loopDev_ts *loop_ps = &loop_as[loop]; DEBUGPRINT(DP_DEBUG, loopFcomFlag, (" loopFcomShowBlobs: DEBUG wakeup pulseId=%u\n",ffWakeupEvents_s.pulseId)); /* get fcom data for each 'used' measurement device */ for (i=0;imeasNum; i++) { if ( (loop_ps->measDev_as[i].used ) && (loop_ps->measDev_as[i].blob_ps!=NULL) ) loopFcomShowBlob(loop_ps->measDev_as[i].fcomId, loop_ps->measDev_as[i].blob_ps); } } /*----------------------------------------------------------------------- Name: loopFcomShowBlob Abs: prints the blob contents Args: Rem: Side: Ret: int fcom return code ----------------------------------------------------------------------*/ LOCAL void loopFcomShowBlob(FcomID id, FcomBlobRef blob_ps ) { /* get pulse id from blob */ epicsTimeStamp time_s; time_s.secPastEpoch = blob_ps->fc_tsHi; time_s.nsec = blob_ps->fc_tsLo; epicsUInt32 blobpId = (epicsUInt32) PULSEID(time_s ); if (blob_ps !=NULL) { DEBUGPRINT(DP_DEBUG, loopFcomFlag, (" fc_tsHi=%u\n fc_tsLo=%u, blob pulseId=%u\n", (unsigned)blob_ps->fc_tsHi,(unsigned) blob_ps->fc_tsLo, (unsigned)blobpId)); DEBUGPRINT(DP_DEBUG, loopFcomFlag, (" fc_vers =%d\n fc_type = %d\n fc_idnt=0x%lx\n", blob_ps->fc_vers, blob_ps->fc_type, blob_ps->fc_idnt)); DEBUGPRINT(DP_DEBUG, loopFcomFlag, (" fc_nelm=%d\n fc_flt[0]=%f\n fc_flt[1]=%f\n fc_flt[2]=%f\n fc_flt[3]=%f\n", blob_ps->fc_nelm, blob_ps->fc_flt[0], blob_ps->fc_flt[1], blob_ps->fc_flt[2],blob_ps->fc_flt[3])); } else DEBUGPRINT(DP_DEBUG, loopFcomFlag,("showBlob: no blob to show\n")); } /*----------------------------------------------------------------------- Name: loopFcomShowDiags Abs: shows all the diagnostics collected on this loop iteration Args: ffThread_e index into ffThreads_as struct for this loop Rem: get the latest diags and print details Side: using DB_FATAL so it always shows when called Ret: void ----------------------------------------------------------------------*/ void loopFcomShowDiags (const int loop) { /* show meas diagnostics */ if (loop_as[loop].measNum>0) { DEBUGPRINT(DP_DEBUG,loopFcomFlag, ("per %ld iterations with %d measurements: old meas = %ld, good meas = %ld, late meas= %ld, fcom errs = %ld, total pkts = %ld\n", loopRT_as[loop].meas.diag_s.iterations, loop_as[loop].measNum, loopRT_as[loop].meas.diag_s.old, loopRT_as[loop].meas.diag_s.good, loopRT_as[loop].meas.diag_s.late, loopRT_as[loop].meas.diag_s.fcom_err, (loopRT_as[loop].meas.diag_s.good+ loopRT_as[loop].meas.diag_s.old+ loopRT_as[loop].meas.diag_s.late+ loopRT_as[loop].meas.diag_s.fcom_err))); } /* show states diagnostics */ if (loop_as[loop].stateNum>0) { DEBUGPRINT(DP_DEBUG,loopFcomFlag, ("per %ld iterations with %d states:good states = %ld, late states= %ld, fcom errs = %ld, total pkts = %ld\n", loopRT_as[loop].state.diag_s.iterations, loop_as[loop].stateNum, loopRT_as[loop].state.diag_s.good, loopRT_as[loop].state.diag_s.late, loopRT_as[loop].state.diag_s.fcom_err, (loopRT_as[loop].state.diag_s.good+ loopRT_as[loop].state.diag_s.late+ loopRT_as[loop].state.diag_s.fcom_err))); } /* show acts diagnostics */ if (loop_as[loop].actNum>0) { DEBUGPRINT(DP_DEBUG,loopFcomFlag, ("per %ld iterations with %d actuators:good acts=%ld, late acts=%ld, really late acts=%ld, fcom errs=%ld, total pkts=%ld\n", loopRT_as[loop].act.diag_s.iterations, loop_as[loop].actNum, loopRT_as[loop].act.diag_s.good, loopRT_as[loop].act.diag_s.late, loopRT_as[loop].meas.diag_s.old, loopRT_as[loop].act.diag_s.fcom_err, (loopRT_as[loop].act.diag_s.good+ loopRT_as[loop].meas.diag_s.old+ loopRT_as[loop].act.diag_s.late+ loopRT_as[loop].act.diag_s.fcom_err))); } }