1:#ifndef INC_templateh 2:#define INC_templateh 3:/*--------------------------------------------------------------------------- 4: 5: FILENAME: 6: template.h 7: 8: PURPOSE: 9: Provide the radlib template process definitions. 10: 11: REVISION HISTORY: 12: Date Engineer Revision Remarks 13: 01/01/2004 Your Name 0 Original 14: 15: NOTES: 16: All references to "template" should be replaced by a meaningful 17: process name, including the file names and data structures. 18: 19:----------------------------------------------------------------------------*/ 20: 21:// System include files 22:#include <unistd.h> 23:#include <stdio.h> 24:#include <stdlib.h> 25:#include <sys/time.h> 26:#include <sys/types.h> 27:#include <sys/wait.h> 28:#include <string.h> 29:#include <signal.h> 30: 31:// radlib include files 32:#include <radsysdefs.h> 33:#include <radsemaphores.h> 34:#include <radbuffers.h> 35:#include <radqueue.h> 36:#include <radtimers.h> 37:#include <radevents.h> 38:#include <radtimeUtils.h> 39:#include <radprocess.h> 40:#include <radstates.h> 41:#include <radconffile.h> 42:#include <radmsgRouter.h> 43: 44:// Local include files 45: 46: 47:// process definitions 48: 49:// this is the unique ID for the "template" radlib system 50:#define TEMPLATE_SYSTEM_ID 11 51: 52:// common macros for radlib process creation and use 53:#define PROC_NAME_TEMPLATE "templated" 54:#define TEMPLATE_LOCK_FILENAME "template.pid" 55:#define PROC_NAME_TEMPLATE2 "template2d" 56:#define TEMPLATE2_LOCK_FILENAME "template2.pid" 57:#define TEMPLATE_CONFIG_FILENAME "template.conf" 58:#define PROC_NUM_TIMERS_TEMPLATE 4 59: 60:#define TEMPLATE_TIMER1_PERIOD 15000 // 15 seconds 61:#define TEMPLATE_TIMER2_PERIOD 33000 // 33 seconds 62: 63: 64:typedef enum 65:{ 66: TEMPLATE_TIMER_NUM1 = 1, 67: TEMPLATE_TIMER_NUM2 = 2 68:} ProcessTimers; 69: 70: 71:// the "template" process work area 72:typedef struct 73:{ 74: pid_t myPid; 75: STATES_ID stateMachine; 76: char fileDev[256]; 77: TIMER_ID timerNum1; 78: TIMER_ID timerNum2; 79: int verboseMode; 80: int exiting; 81:} TEMPLATE_WORK; 82: 83: 84:// define the states for the state machine 85:typedef enum 86:{ 87: TEMPLATE_STATE_IDLE = 0, 88: TEMPLATE_STATE_RUN, 89: TEMPLATE_STATE_ERROR 90:} TEMPLATE_STATES; 91: 92:// define the template message IDs 93:enum 94:{ 95: TEMPLATE_MSGID_USER_REQUEST = 100, 96: TEMPLATE_MSGID_USER_RESPONSE = 101 97:}; 98: 99:// define the USER_REQUEST message 100:typedef struct 101:{ 102: int number; 103:} TEMPLATE_MSG_USER_REQUEST; 104: 105:// define the USER_RESPONSE message 106:typedef struct 107:{ 108: int number; 109: int numberOfPrimes; 110:} TEMPLATE_MSG_USER_RESPONSE; 111: 112: 113:// prototype the state handlers 114:extern int templateIdleState (int state, void *stimulus, void *data); 115:extern int templateRunState (int state, void *stimulus, void *data); 116:extern int templateErrorState (int state, void *stimulus, void *data); 117: 118:extern int template2IdleState (int state, void *stimulus, void *data); 119:extern int template2RunState (int state, void *stimulus, void *data); 120:extern int template2ErrorState (int state, void *stimulus, void *data); 121: 122: 123:// function prototypes 124: 125: 126: 127:#endif 128: