/* SNC Version 2.0.11: Fri Apr 25 13:59:57 2008: ../countAlarms.stt */ /* Event flags */ #define changeFlag 1 /* Program "countAlarms" */ #include "seqCom.h" #define NUM_SS 1 #define NUM_CHANNELS 9 #define NUM_EVENTS 1 #define NUM_QUEUES 0 #define MAX_STRING_SIZE 40 #define ASYNC_OPT FALSE #define CONN_OPT FALSE #define DEBUG_OPT FALSE #define MAIN_OPT FALSE #define NEWEF_OPT TRUE #define REENT_OPT FALSE extern struct seqProgram countAlarms; /* Variable declarations */ static int i; static int majorCount; static int minorCount; static int invalidCount; static int showCount; static float delaySecs = 5.0; static float sevrArray[5]; /* Not used (avoids compilation warnings) */ struct UserVar { int dummy; }; /* Entry handler */ static void entry_handler(SS_ID ssId, struct UserVar *pVar) { } /* Code for state "init" in state set "count" */ /* Delay function for state "init" in state set "count" */ static void D_count_init(SS_ID ssId, struct UserVar *pVar) { # line 42 "../countAlarms.stt" seq_delayInit(ssId, 0, (1)); } /* Event function for state "init" in state set "count" */ static long E_count_init(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 42 "../countAlarms.stt" if (seq_delay(ssId, 0)) { *pNextState = 1; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "init" in state set "count" */ static void A_count_init(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 41 "../countAlarms.stt" printf("initializing count sequence\n"); } return; } } /* Code for state "countAlarms" in state set "count" */ /* Delay function for state "countAlarms" in state set "count" */ static void D_count_countAlarms(SS_ID ssId, struct UserVar *pVar) { # line 85 "../countAlarms.stt" } /* Event function for state "countAlarms" in state set "count" */ static long E_count_countAlarms(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 85 "../countAlarms.stt" if (seq_efTestAndClear(ssId, changeFlag)) { *pNextState = 1; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "countAlarms" in state set "count" */ static void A_count_countAlarms(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 49 "../countAlarms.stt" majorCount = 0; minorCount = 0; invalidCount = 0; showCount = 0; # line 69 "../countAlarms.stt" for (i = 0; i < 5; ++i) { if (seq_pvConnected(ssId, 0 /* sevrArray */ + (i)) == 0) ++invalidCount; else { if (sevrArray[i] == 1) ++minorCount; if (sevrArray[i] == 2) ++majorCount; if (sevrArray[i] == 3) ++invalidCount; } } # line 71 "../countAlarms.stt" printf("result:\n"); printf(" major: %d\n", majorCount); printf(" minor: %d\n", minorCount); printf(" invalid: %d\n", invalidCount); # line 77 "../countAlarms.stt" showCount = invalidCount > 0 ? invalidCount : majorCount > 0 ? majorCount : minorCount > 0 ? minorCount : 0; # line 79 "../countAlarms.stt" seq_pvPut(ssId, 5 /* majorCount */, 0); seq_pvPut(ssId, 6 /* minorCount */, 0); seq_pvPut(ssId, 7 /* invalidCount */, 0); # line 83 "../countAlarms.stt" seq_pvPut(ssId, 8 /* showCount */, 0); } return; } } /* Exit handler */ static void exit_handler(SS_ID ssId, struct UserVar *pVar) { } /************************ Tables ***********************/ /* Database Blocks */ static struct seqChan seqChan[NUM_CHANNELS] = { {"TESTDP.SEVR", (void *)&sevrArray[0], "sevrArray[0]", "float", 1, 2, 1, 1, 0, 0, 0}, {"TESTDP1.SEVR", (void *)&sevrArray[1], "sevrArray[1]", "float", 1, 3, 1, 1, 0, 0, 0}, {"TESTDP2.SEVR", (void *)&sevrArray[2], "sevrArray[2]", "float", 1, 4, 1, 1, 0, 0, 0}, {"TESTDP3.SEVR", (void *)&sevrArray[3], "sevrArray[3]", "float", 1, 5, 1, 1, 0, 0, 0}, {"TESTDP4.SEVR", (void *)&sevrArray[4], "sevrArray[4]", "float", 1, 6, 1, 1, 0, 0, 0}, {"{area}:{subsys}:MAJORCOUNT", (void *)&majorCount, "majorCount", "int", 1, 7, 0, 0, 0, 0, 0}, {"{area}:{subsys}:MINORCOUNT", (void *)&minorCount, "minorCount", "int", 1, 8, 0, 0, 0, 0, 0}, {"{area}:{subsys}:INVCOUNT", (void *)&invalidCount, "invalidCount", "int", 1, 9, 0, 0, 0, 0, 0}, {"{area}:{subsys}:SHOWCOUNT", (void *)&showCount, "showCount", "int", 1, 10, 0, 0, 0, 0, 0}, }; /* Event masks for state set count */ /* Event mask for state init: */ static bitMask EM_count_init[] = { 0x00000000, }; /* Event mask for state countAlarms: */ static bitMask EM_count_countAlarms[] = { 0x00000002, }; /* State Blocks */ static struct seqState state_count[] = { /* State "init" */ { /* state name */ "init", /* action function */ (ACTION_FUNC) A_count_init, /* event function */ (EVENT_FUNC) E_count_init, /* delay function */ (DELAY_FUNC) D_count_init, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_count_init, /* state options */ (0)}, /* State "countAlarms" */ { /* state name */ "countAlarms", /* action function */ (ACTION_FUNC) A_count_countAlarms, /* event function */ (EVENT_FUNC) E_count_countAlarms, /* delay function */ (DELAY_FUNC) D_count_countAlarms, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_count_countAlarms, /* state options */ (0)}, }; /* State Set Blocks */ static struct seqSS seqSS[NUM_SS] = { /* State set "count" */ { /* ss name */ "count", /* ptr to state block */ state_count, /* number of states */ 2, /* error state */ -1}, }; /* Program parameter list */ static char prog_param[] = ""; /* State Program table (global) */ struct seqProgram countAlarms = { /* magic number */ 20000315, /* *name */ "countAlarms", /* *pChannels */ seqChan, /* numChans */ NUM_CHANNELS, /* *pSS */ seqSS, /* numSS */ NUM_SS, /* user variable size */ 0, /* *pParams */ prog_param, /* numEvents */ NUM_EVENTS, /* encoded options */ (0 | OPT_NEWEF), /* entry handler */ (ENTRY_FUNC) entry_handler, /* exit handler */ (EXIT_FUNC) exit_handler, /* numQueues */ NUM_QUEUES, }; /* Register sequencer commands and program */ void countAlarmsRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&countAlarms); } epicsExportRegistrar(countAlarmsRegistrar);