/* * ce_subMTBsts.c An EPICS subroutine record code module. * * This module will be used with a SUBroutine record to interface with * a LabVIEW program (EPICS_EDDTG.exe) to monitor * an MTB module in a PC from EPICS. * ce_subMTBsts to be used to deconstruct embedded status * information generated by this module. * See also subroutine ce_MTBctl.c for controlling an MTB channel. * * Reference the document "EPICS/LabVIEW MTB Programming Guide" to * determine the field-usage and bit-meanings, etc... * * Rev 0 17NOV03 ps Created * */ #include #include #include #include #include #include #include long ce_MTBstsInit(psub) struct subRecord *psub; { /* clear UDF */ psub->udf = 0; return(0); } long ce_MTBsts(psub) struct subRecord *psub; { int StatusWord1, StatusWord2; /* get inputs */ StatusWord1 = psub->a; StatusWord2 = psub->b; /* deconstruct word 1 */ /* bits 0-15 used by external MBBID record to deode individual bits */ psub->e = (StatusWord1>>16 & 0xFF); /* monitored EDD event code */ /* bits 24-31 are spare */ /* deconstruct word 2 */ psub->f = StatusWord2 & 0x7; /* personality nuumeric */ psub->g = (StatusWord2>>3 & 0x7); /* board number */ psub->h = (StatusWord2>>6 & 0x7); /* channel number */ psub->i = (StatusWord2>>9 & 0x7); /* number of MTB found */ psub->j = (StatusWord2>>12 & 0x3); /* watchdog counter */ psub->k = (StatusWord2>>14 & 0xFF); /* last event */ psub->val =( StatusWord2>>22 & 0x1F); /* 5-bit staus code */ /* bits 27-31 are spare */ return(0); }