/*============================================================================= Name: mpgPatternMod.c mpgPatternMod - 360Hz Pattern Modifier Processing mpgPatternModInit - 360Hz Pattern Modifier Processing Init mpgPatternModUser - User Input to Fixed Modifier Bits mpgPatternModCnt - 360Hz Pattern Countdown Modifier Bits mpgPatternModCntInit - Initialize Countdown Modifier Bit Processing mpgPatternModCntInp - User Input to Countdown Modifier Bit Processing mpgPatternModCntState - State of Countdown Modifier Bit Processing mpgPatternModEdef - 360Hz EDEF Processing mpgPatternModEdefInp - User Input to EDEF Processing mpgPatternModEdefState - EDEF Processing State mpgPatternModEdefSum - EDEF Summaries Abs: This file contains all subroutine support for the MPG IOC processing of pattern modifier bits. Rem: All functions called by the subroutine record get passed one argument: psub Pointer to the subroutine record data. Use: pointer Type: struct longSubRecord * Acc: read/write Mech: reference All functions return a long integer. 0 = OK, -1 = ERROR. The subroutine record ignores the status returned by the Init routines. For the calculation routines, the record status (STAT) is set to SOFT_ALARM (unless it is already set to LINK_ALARM due to severity maximization) and the severity (SEVR) is set to psub->brsv (BRSV - set by the user in the database though it is expected to be invalid). Auth: 04-dec-2006, S. Allison (saa) Rev: -----------------------------------------------------------------------------*/ #include "copyright_SLAC.h" /* SLAC copyright comments */ /*----------------------------------------------------------------------------- Mod: (newest to oldest) =============================================================================*/ #include /* for memset */ #include /* for calloc */ #include "longSubRecord.h" /* for struct longSubRecord */ #include "registryFunction.h" /* for epicsExport */ #include "epicsExport.h" /* for epicsRegisterFunction */ #include "epicsMutex.h" /* EPICS Mutex support */ #include "epicsTime.h" /* for epicsTimeGetCurrent */ #include "errlog.h" /* errlogPrintf */ #include "dbScan.h" /* for post_event */ #include "alarm.h" /* for *_ALARM */ #include "evrMessage.h" /* for evrMessagePattern_ts */ #include "evrTime.h" /* for EDEF_MAX */ #include "evrPattern.h" /* for MOD5_USER_MASK */ #include "mpgPattern.h" /* for mpgBykik_check */ /* Pattern RWMutex - to protect data below */ static epicsMutexId mpgPatternModRWMutex_ps = 0; /* EDEF Pattern table and bit masks */ typedef struct { /* Inputs */ epicsUInt32 mask; evrModifier_ta inclusion_a; evrModifier_ta exclusion_a; unsigned long beamCode; unsigned long avgCount; unsigned long measCount;/* 0xFFFFFFFF = forever */ unsigned long maxCount; /* avgCount * measCount */ /* Input/Outputs */ unsigned long control; /* 0 = off, 1 = on */ unsigned long controlOffCount; /* Counter before CTRL is turned off */ unsigned long avgCountSoFar; /* Number in average so far */ unsigned long countSoFar; /* Number of matches so far */ unsigned long countZero; /* countSoFar set to zero */ unsigned long inuse; /* 0 = available, 1 = in use */ } mpgPatternModEdef_ts; #define EDEF_SIZE 32 static mpgPatternModEdef_ts edef_as[EDEF_SIZE]; static epicsUInt32 edefInitMask = 0; static epicsUInt32 edefAllDoneMask = 0; static epicsUInt32 edefAvgDoneMask = 0; static epicsUInt32 edefMinorMask = 0; static epicsUInt32 edefMajorMask = 0; static epicsUInt32 edefInUse = 0; /* Modifier Bits using countdown */ typedef struct { ELLNODE node; /* for ELLIST */ /* Inputs */ epicsUInt32 mask; /* Modifier Bit Mask to change */ unsigned long index; /* Modifier Array Index to change */ unsigned long burst; /* 1 = set BURST bit in pattern */ unsigned long addOnMatch; /* 0 = remove on match, 1 = add on match */ unsigned long addNoMatch; /* 0 = remove on non-match, 1 = add on non-match. 2 = leave as-is on non-match */ evrModifier_ta inclusion_a; evrModifier_ta exclusion_a; unsigned long beamCode; unsigned long maxCount; /* 0xFFFFFFFF = forever */ /* Input/Outputs */ unsigned long control; /* 0=off, 1=single-shot, 2=burst */ unsigned long countSoFar; /* Countdown */ unsigned long countZero; /* countSoFar set to zero */ } mpgPatternModCnt_ts; static ELLLIST mod_s; /* Modifier bit list */ static epicsUInt32 modifier5UserMask = 0; /* Fixed bits in modifier 5 */ /*============================================================================= Name: mpgPatternModInit Abs: Initialization for 360Hz Processing of Pattern Modifier Bits Args: None. Rem: Call once by mpgPatternInit. Ret: -1 if mutex cannot be allocated or is already allocated. 0 if OK. ==============================================================================*/ int mpgPatternModInit(void) { /* If the mutex is already created, then this routine is being called more than once which is an error. */ if (mpgPatternModRWMutex_ps) return -1; /* Initialize Edef array and modifier bit list */ memset(edef_as, 0, sizeof(mpgPatternModEdef_ts) * EDEF_SIZE); ellInit(&mod_s); /* Create the mutex used by all other routines. */ mpgPatternModRWMutex_ps = epicsMutexCreate(); if (!mpgPatternModRWMutex_ps) return -1; return (0); } /*============================================================================= Name: mpgPatternModUser Abs: Fixed User Modifier Bit Mask Args: Type Name Access Description ------------------- ----------- ---------- ---------------------------- longSubRecord * psub read point to subroutine record Rem: Subroutine for IOC:LOCA:UNIT:MODIFIER5INP Inputs: A - Modifier Bit Mask Outputs: VAL - modifier5UserMask Side: Write to memory used by 360hz processing (mutex protected) Ret: 0 = OK, -1 = ERROR ==============================================================================*/ static long mpgPatternModUser(longSubRecord *psub) { psub->val = psub->a & MOD5_USER_MASK; /* Fixed bits in modifier 5 */ if ((!mpgPatternModRWMutex_ps) || epicsMutexLock(mpgPatternModRWMutex_ps)) return -1; modifier5UserMask = psub->val; epicsMutexUnlock(mpgPatternModRWMutex_ps); return 0; } /*============================================================================= Name: mpgPatternModCntInit Abs: Initialize User Input to Countdown Modifier Bit Processing Args: Type Name Access Description ------------------- ----------- ---------- ---------------------------- longSubRecord * psub read point to subroutine record Rem: Init Subroutine for PATT:LOCA:UNIT:NAME Inputs: None Outputs: A = number of this node in the list (0 = no node created) DPVT = Pointer to node in the linked list Side: Allocate memory and update mod_s linked list. Ret: 0 = OK, -1 = ERROR ==============================================================================*/ static long mpgPatternModCntInit(longSubRecord *psub) { if ((!mpgPatternModRWMutex_ps) || epicsMutexLock(mpgPatternModRWMutex_ps)) return -1; psub->dpvt = calloc(1,sizeof(mpgPatternModCnt_ts)); if (psub->dpvt) { ellAdd(&mod_s, &((mpgPatternModCnt_ts *)psub->dpvt)->node); psub->a = ellCount(&mod_s); } epicsMutexUnlock(mpgPatternModRWMutex_ps); if (!psub->dpvt) return -1; return 0; } /*============================================================================= Name: mpgPatternModCntInp Abs: User Input to Countdown Modifier Bit Processing Args: Type Name Access Description ------------------- ----------- ---------- ---------------------------- longSubRecord * psub read point to subroutine record Rem: Subroutine for PATT:LOCA:UNIT:NAME Inputs: DPVT - Pointer to node in linked list A - Node number in linked list B - Modifier bit Control (0 = off, 1 = single-shot, 2 = burst) C - Modifier Bit Mask to change (0 = make no change) D - Modifier Array Index (0 to EVR_MODIFIER_MAX-1) E - Max Pulses that modifiers are changed (0xFFFFFFFF = forever) F - Burst flag, 0 = no burst, 1 = burst (set BURST bit in pattern) G - AddOnMatch flag, 0 = remove mask on match 1 = add mask on match H - AddNoMatch flag, 0 = remove mask on non-match 1 = add mask on non-match 2 = leave as-is on non-match I - Beam Code (0 = use any beam code) J,K,L - Spare M - INCLUSION1 (for Modifier2) N - INCLUSION2 (for Modifier3) O - INCLUSION3 (for Modifier4) P - INCLUSION4 (for Modifier5) Q - INCLUSION5 (for Modifier6) R - EXCLUSION1 (for Modifier2) S - EXCLUSION2 (for Modifier3) T - EXCLUSION3 (for Modifier4) U - EXCLUSION4 (for Modifier5) V - EXCLUSION5 (for Modifier6) Outputs: None Side: Write to memory used by 360hz processing (mutex protected) Ret: 0 = OK, -1 = ERROR ==============================================================================*/ static long mpgPatternModCntInp(longSubRecord *psub) { int midx; epicsUInt32 *outp; long status; mpgPatternModCnt_ts *mod_ps = (mpgPatternModCnt_ts *)psub->dpvt; if ((!mod_ps) || (!mpgPatternModRWMutex_ps) || epicsMutexLock(mpgPatternModRWMutex_ps)) return -1; mod_ps->control = psub->b; mod_ps->mask = psub->c; mod_ps->index = psub->d; mod_ps->maxCount = psub->e; mod_ps->burst = psub->f; mod_ps->addOnMatch = psub->g; mod_ps->addNoMatch = psub->h; mod_ps->beamCode = psub->i; for (midx = 1, outp = &psub->m; midx < EVR_MODIFIER_MAX; midx++, outp++) mod_ps->inclusion_a[midx] = *outp; for (midx = 1, outp = &psub->r; midx < EVR_MODIFIER_MAX; midx++, outp++) mod_ps->exclusion_a[midx] = *outp; /* If all bits set in rate mask, then user wants to do the opposite with the mask on match, and nothing on no-match. */ if ((mod_ps->inclusion_a[4] & MOD5_RATE_MASK) == MOD5_RATE_MASK) { mod_ps->burst = 0; mod_ps->addNoMatch = 2; if (mod_ps->addOnMatch) { mod_ps->addOnMatch = 0; for (midx = 1, outp = &psub->m; midx < EVR_MODIFIER_MAX; midx++, outp++) mod_ps->inclusion_a[midx] = 0; for (midx = 1, outp = &psub->r; midx < EVR_MODIFIER_MAX; midx++, outp++) mod_ps->exclusion_a[midx] = 0; if (mod_ps->index < EVR_MODIFIER_MAX) mod_ps->inclusion_a[mod_ps->index] = mod_ps->mask; } else { mod_ps->addOnMatch = 1; mod_ps->inclusion_a[4] = 0; } } /* For single shot, only do one pulse at the next 1 second slot. */ if (mod_ps->control == 1) { mod_ps->maxCount = 1; mod_ps->inclusion_a[4] &= ~(MOD5_RATE_MASK); mod_ps->inclusion_a[4] |= MOD5_1HZ_MASK; } /* Override maxcount if there is an error. */ if (mod_ps->index >= EVR_MODIFIER_MAX) { mod_ps->maxCount = 0; status = -1; } else { status = 0; } /* See if user has turned off the checking. */ if ((!mod_ps->control) && mod_ps->countSoFar) { mod_ps->countSoFar = 0; mod_ps->countZero = 1; } epicsMutexUnlock(mpgPatternModRWMutex_ps); return status; } /*============================================================================= Name: mpgPatternModCntState Abs: State of Countdown Modifier Bit Processing Args: Type Name Access Description ------------------- ----------- ---------- ---------------------------- longSubRecord * psub read/write point to subroutine record Rem: Subroutine for PATT:LOCA:UNIT:NAMESTATE Processed on EVENT_MPG event. Inputs: DPVT - Pointer to node in linked list A - Node number in linked list (from mpgPatternModCntInp) B - Modifier bit Control (0 = off, 1 = single-shot, 2 = burst) Outputs: L - Control flag (0 = stop control, 1 = continue control) VAL - Countdown so far DPVT - Pointer to node in linked list Side: Read from memory used by 360hz processing (mutex protected) Ret: 0 = OK, -1 = ERROR ==============================================================================*/ static long mpgPatternModCntState(longSubRecord *psub) { mpgPatternModCnt_ts *mod_ps; psub->l = 1; psub->val = 0; if ((!mpgPatternModRWMutex_ps) || epicsMutexLock(mpgPatternModRWMutex_ps)) return -1; /* Get pointer to node in linked list - first time only */ if (!psub->dpvt) psub->dpvt = ellNth(&mod_s, (int)psub->a); if (psub->dpvt) { mod_ps = (mpgPatternModCnt_ts *)psub->dpvt; if (psub->b && (!mod_ps->control)) psub->l = 0; psub->val = mod_ps->countSoFar; } epicsMutexUnlock(mpgPatternModRWMutex_ps); if (!psub->dpvt) return -1; return 0; } /*============================================================================= Name: mpgPatternModCnt Abs: 360Hz Processing of Countdown Modifier Bits Args: Type Name Access Description ------------------- ----------- ---------- ---------------------------- evrModifier_ta modifier_a read/write Modifier Bit Mask Array Rem: Assume mpgPatternModRWMutex is already taken. Side: None. Ret: 0 = control not changed, 1 = control changed ==============================================================================*/ static int mpgPatternModCnt(evrModifier_ta modifier_a) { int changeFlag = 0; mpgPatternModCnt_ts *mod_ps; mod_ps = (mpgPatternModCnt_ts *)ellFirst(&mod_s); while(mod_ps) { if (mod_ps->countZero) { mod_ps->countZero = 0; changeFlag = 1; } /* Change modifier if requested */ if (mod_ps->control) { /* Check if this modifier is done - set changeFlag so that state record will be processed soon. */ if ((mod_ps->maxCount != 0xFFFFFFFF) && (mod_ps->maxCount <= mod_ps->countSoFar)) { mod_ps->control = 0; changeFlag = 1; /* If this pulse applies, change the modifier. */ } else if (evrPatternCheck(mod_ps->beamCode, 0, mod_ps->inclusion_a, mod_ps->exclusion_a, modifier_a)) { mod_ps->countSoFar++; if (mod_ps->mask) { if (mod_ps->addOnMatch) modifier_a[mod_ps->index] |= mod_ps->mask; else modifier_a[mod_ps->index] &= ~(mod_ps->mask); } if (mod_ps->burst) modifier_a[MOD2_IDX] |= EVG_BURST; /* If this pulse doesn't apply, add or remove the mask if requested. */ } else if (mod_ps->mask) { if (mod_ps->addNoMatch == 0) modifier_a[mod_ps->index] &= ~(mod_ps->mask); else if (mod_ps->addNoMatch == 1) modifier_a[mod_ps->index] |= mod_ps->mask; } } mod_ps = (mpgPatternModCnt_ts *)ellNext(&mod_ps->node); } return(changeFlag); } /*============================================================================= Name: mpgPatternModEdefInp Abs: User Input to EDEF Checking Args: Type Name Access Description ------------------- ----------- ---------- ---------------------------- longSubRecord * psub read point to subroutine record Rem: Subroutine for EDEF:LOCA:UNIT:PATTERNCHECK Inputs: A - EDEF Number (starting from 1) B - EDEF Initialize Flag C - EDEF AVGCNT D - EDEF Severity F - EDEF In-Use Flag (0=EDEF not reserved (blank NAME), 1 = EDEF reserved) G, H - Spare I - EDEF Beam Code (0 = use any beam code) J,K,L - Spare M - EDEF INCLUSION1 (for Modifier2) N - EDEF INCLUSION2 (for Modifier3) O - EDEF INCLUSION3 (for Modifier4) P - EDEF INCLUSION4 (for Modifier5) Q - EDEF INCLUSION5 (for Modifier6) R - EDEF EXCLUSION1 (for Modifier2) S - EDEF EXCLUSION2 (for Modifier3) T - EDEF EXCLUSION3 (for Modifier4) U - EDEF EXCLUSION4 (for Modifier5) V - EDEF EXCLUSION5 (for Modifier6) X - EDEF MEASCNT (= 0xFFFFFFFF means forever) Y - EDEF MEASCNT * AVGCNT = CNTMAX Z - EDEF control (0=off, 1=on) Outputs: B - EDEF Init flag reset to 0. E - EDEF Index Side: Write to memory used by 360hz processing (mutex protected) Ret: 0 = OK, -1 = ERROR ==============================================================================*/ static long mpgPatternModEdefInp(longSubRecord *psub) { int midx; epicsUInt32 *outp; unsigned long mask; psub->e = psub->a - 1; if (psub->e >= EDEF_SIZE) return -1; mask = 1 << psub->e; if ((!(mask & MOD5_EDEF_MASK)) && (!(mask & MOD5_ACQ_MASK))) return -1; if ((!mpgPatternModRWMutex_ps) || epicsMutexLock(mpgPatternModRWMutex_ps)) return -1; for (midx = 1, outp = &psub->m; midx < EVR_MODIFIER_MAX; midx++, outp++) edef_as[psub->e].inclusion_a[midx] = *outp; for (midx = 1, outp = &psub->r; midx < EVR_MODIFIER_MAX; midx++, outp++) edef_as[psub->e].exclusion_a[midx] = *outp; edef_as[psub->e].mask = mask; edef_as[psub->e].beamCode = psub->i; edef_as[psub->e].avgCount = psub->c; edef_as[psub->e].measCount = psub->x; edef_as[psub->e].maxCount = psub->y; edef_as[psub->e].inuse = psub->f; edefInUse = 0; for (midx = 0; midx < EDEF_MAX; midx++) { if (edef_as[midx].inuse) edefInUse++; } /* If control has changed and it's now on, reset counters. */ if (edef_as[psub->e].control != psub->z) { edef_as[psub->e].control = psub->z; edef_as[psub->e].countZero = 1; if (edef_as[psub->e].control) { if (psub->e < EDEF_MAX) edefInitMask |= edef_as[psub->e].mask; edef_as[psub->e].controlOffCount = 0; edef_as[psub->e].avgCountSoFar = 0; edef_as[psub->e].countSoFar = 0; } } if (psub->b) { psub->b = 0; if (psub->e < EDEF_MAX) edefInitMask |= edef_as[psub->e].mask; edef_as[psub->e].controlOffCount = 0; edef_as[psub->e].avgCountSoFar = 0; if (edef_as[psub->e].countSoFar) { edef_as[psub->e].countSoFar = 0; edef_as[psub->e].countZero = 1; } } if (psub->e < EDEF_MAX) { if (psub->d == MINOR_ALARM) { edefMinorMask |= edef_as[psub->e].mask; edefMajorMask |= edef_as[psub->e].mask; } else if (psub->d == MAJOR_ALARM) { edefMinorMask &= ~(edef_as[psub->e].mask); edefMajorMask |= edef_as[psub->e].mask; } else { edefMinorMask &= ~(edef_as[psub->e].mask); edefMajorMask &= ~(edef_as[psub->e].mask); } } epicsMutexUnlock(mpgPatternModRWMutex_ps); return 0; } /*============================================================================= Name: mpgPatternModEdefState Abs: EDEF Measurement Count Args: Type Name Access Description ------------------- ----------- ---------- ---------------------------- longSubRecord * psub read/write point to subroutine record Rem: Subroutine for EDEF:LOCA:UNIT:CNT Inputs: A - EDEF Number (starting from 1) B - EDEF control (0=off, 1=on) Outputs: E - EDEF Index K - # of counts since control off L - Control off (0 = don't turn control off, 1 = turn control off) VAL - Number of Matches so far Side: Read from memory used by 360hz processing (mutex protected) Ret: 0 = OK, -1 = ERROR ==============================================================================*/ static long mpgPatternModEdefState(longSubRecord *psub) { psub->e = psub->a - 1; psub->k = 0; psub->l = 0; psub->val = 0; if (psub->e >= EDEF_SIZE) return -1; if ((!mpgPatternModRWMutex_ps) || epicsMutexLock(mpgPatternModRWMutex_ps)) return -1; psub->k = edef_as[psub->e].controlOffCount; if (psub->b && (!edef_as[psub->e].control)) psub->l = 1; psub->val = edef_as[psub->e].countSoFar; epicsMutexUnlock(mpgPatternModRWMutex_ps); return 0; } /*============================================================================= Name: mpgPatternModEdefSum Abs: EDEF Summary Counts Args: Type Name Access Description ------------------- ----------- ---------- ---------------------------- longSubRecord * psub read/write point to subroutine record Rem: Subroutine for IOC:LOCA:UNIT:EDEFAVAIL Inputs: None Outputs: K - Maximum Number of EDEFs L - Number of EDEFs In-Use VAL - Number of EDEFs Available Side: Read from memory used by other processing (mutex protected) Ret: 0 = OK, -1 = ERROR ==============================================================================*/ static long mpgPatternModEdefSum(longSubRecord *psub) { if ((!mpgPatternModRWMutex_ps) || epicsMutexLock(mpgPatternModRWMutex_ps)) return -1; psub->val = EDEF_MAX - edefInUse; psub->k = EDEF_MAX; psub->l = edefInUse; epicsMutexUnlock(mpgPatternModRWMutex_ps); return 0; } /*============================================================================= Name: mpgPatternModEdef Abs: 360Hz EDEF Processing Check to see if current beam pulse is to be used in any current event measurement definition. Args: Type Name Access Description ------------------- ----------- ---------- ---------------------------- evrModifier_ta modifier_a read/write Modifier Bit Mask Array Rem: Assume mpgPatternModRWMutex is already taken. Side: None. Ret: 0 = control not changed, 1 = control changed ==============================================================================*/ static int mpgPatternModEdef(evrModifier_ta modifier_a) { int idx; int changeFlag = 0; for (idx = EDEF_SIZE-1; idx >=0; idx--) { if (edef_as[idx].countZero) { edef_as[idx].countZero = 0; changeFlag = 1; } if (edef_as[idx].control) { /* if pattern beam code == EDEF beamcode. if zero, use any beam code */ if (evrPatternCheck(edef_as[idx].beamCode, 0, edef_as[idx].inclusion_a, edef_as[idx].exclusion_a, modifier_a)) { /* if the last cycle is done, turn CTRL off now. EVR IOCs should be finished now. */ if ((edef_as[idx].measCount != 0xFFFFFFFF) && (edef_as[idx].countSoFar >= edef_as[idx].maxCount)) { edef_as[idx].control = 0; if (idx < EDEF_MAX) { edefAllDoneMask |= edef_as[idx].mask; edefAvgDoneMask |= edef_as[idx].mask; } changeFlag = 1; /* Set bit in modifer5 so that EVR IOCs will use the data on this pulse. */ } else { modifier_a[MOD5_IDX] |= edef_as[idx].mask; edef_as[idx].countSoFar++; edef_as[idx].avgCountSoFar++; /* If the average is done, set a bit in the avgdone mask so that EVR IOCs finish their averages. */ if (edef_as[idx].avgCountSoFar >= edef_as[idx].avgCount) { if (idx < EDEF_MAX) edefAvgDoneMask |= edef_as[idx].mask; edef_as[idx].avgCountSoFar = 0; } } /* Don't let CTRL stay on too long after measurements are done. */ } else if ((edef_as[idx].measCount != 0xFFFFFFFF) && (edef_as[idx].countSoFar >= edef_as[idx].maxCount)) { edef_as[idx].controlOffCount++; if (edef_as[idx].controlOffCount > MODULO720_COUNT) { edef_as[idx].control = 0; if (idx < EDEF_MAX) { edefAllDoneMask |= edef_as[idx].mask; edefAvgDoneMask |= edef_as[idx].mask; } changeFlag = 1; } } } } return(changeFlag); } /*============================================================================= Name: mpgPatternMod Abs: 360Hz Processing of the Pattern Modifier Bits Args: Type Name Access Description ------------------- ----------- ---------- ---------------------------- evrMessagePattern_ts * pattern_ps read/write Pattern Rem: None. Side: None Ret: -1 if mutex error, 0 if OK. ==============================================================================*/ int mpgPatternMod(evrMessagePattern_ts *pattern_ps) { int changeFlag = 0; if ((!mpgPatternModRWMutex_ps) || epicsMutexLock(mpgPatternModRWMutex_ps)) { pattern_ps->modifier_a[MOD1_IDX] |= MPG_IPLING; return -1; } pattern_ps->modifier_a[MOD5_IDX] |= modifier5UserMask; pattern_ps->edefInitMask = edefInitMask; pattern_ps->edefMinorMask = edefMinorMask; pattern_ps->edefMajorMask = edefMajorMask; edefInitMask = 0; /* Don't change modifier bits that depend on a good pattern. */ if (!(pattern_ps->modifier_a[MOD1_IDX] & MPG_IPLING)) { if (mpgPatternModCnt(pattern_ps->modifier_a)) changeFlag = 1; mpgBykik_check(pattern_ps); if (mpgPatternModEdef(pattern_ps->modifier_a)) changeFlag = 1; } /* Let EVR IOCs know that an EDEF is finished so they can fill in the BSA arrays, in case the last meas was missed. No room in the existing pattern for another mask so put the bits in the high unused 10 bits of the severity masks (KLUGE!). */ if (edefAllDoneMask) { pattern_ps->edefMinorMask |= (edefAllDoneMask & 0x003FF) << 20; pattern_ps->edefMajorMask |= (edefAllDoneMask & 0xFFC00) << 10; edefAllDoneMask = 0; } pattern_ps->edefAvgDoneMask = edefAvgDoneMask; edefAvgDoneMask = 0; epicsMutexUnlock(mpgPatternModRWMutex_ps); /* Post an event if anything has changed or if we're at the 2 second mark. */ if (changeFlag || (pattern_ps->modifier_a[MOD1_IDX] & MODULO720_MASK)) post_event(EVENT_MPG); return 0; } epicsRegisterFunction(mpgPatternModUser); epicsRegisterFunction(mpgPatternModCntInit); epicsRegisterFunction(mpgPatternModCntInp); epicsRegisterFunction(mpgPatternModCntState); epicsRegisterFunction(mpgPatternModEdefInp); epicsRegisterFunction(mpgPatternModEdefState); epicsRegisterFunction(mpgPatternModEdefSum);