#ifndef INCUBATOR #define INCUBATOR 1 #define UNIX 1 #define LINUX 1 const int ALARMS = 100; const int INCUBATORS_PER_PORT = 1; const int PORTS = 2; const int INCUBATORS = 2; //// Add any additional ports here const char SERIAL_PORT_0[64] = "/dev/ttyR3"; const char SERIAL_PORT_1[64] = "/dev/ttyR5"; const int PORT0_ADDRESS = 0xc800; const int PORT1_ADDRESS = 0xc800; const int MAX_PORTS = 10; //---------------Include files-------------------------------------------// #include #include #include // For index() in Solaris #include #include #include #include #include #include #include #include #include // Needed for semaphores & ipc #include #include #include #ifndef __u32 #define __u32 unsigned int #endif // These are needed for serial I/O #include #include #include #include #include // For syslog #include //---------------#define's-------------------------// #define min(a,b) (((a)<(b)) ? (a) : (b)) #define max(a,b) (((a)>(b)) ? (a) : (b)) #define swapbyte(a,b){ ccc=(a); (a)=(b); (b)=ccc; } #define swap(a,b) { g.swap_temp=(a); (a)=(b); (b)=g.swap_temp; } #define fswap(a,b) { g.fswap_temp=(a); (a)=(b); (b)=g.fswap_temp; } #define dswap(a,b) { g.dswap_temp=(a); (a)=(b); (b)=g.dswap_temp; } #define sgn(a) ( (a)>0 ? (1) : ( (a)<0 ? (-1) : (0) ) ) #define uchar unsigned char #define uint unsigned int #define ulong unsigned long #define ushort unsigned short int typedef struct Alarm { char *command; // command line double threshold; // Temp above which to send alarm int inc; // 0 to 3 incubator number int state; // 0=0ff 1=on 2=ringing }; typedef struct Incubator { int port; // 0,1,2,3 for ttyS0, etc char *location; // incubator location from file char *state_string; // label that goes with each state char *inc_string; // incubator name from file double temp; // temperature if available int state; // 0=0ff 1=on 2=ringing }; const int FILENAMELENGTH=1024; // max. length of a filename int between(int a,int b,int c); int open_port(const char *port_name, int port_address); void initialize_app_globals(void); void alarm_ring(int alarm); void handle_input(int inc, int fd); void print(int row, int col, int number); void print(int row, int col, double number); void print(int row, int col, char *string); void print_status(int incubator); void remove_terminal_cr(char *s); void monitor(int fd[]); void log_temperatures(int inc); int find_command_start(char *string); #endif // ifndef INCUBATOR