#ifndef __NETWORK_H_INCLUDED__ #define __NETWORK_H_INCLUDED__ #include #include #include using namespace std; /*** CONSTANTS ***/ const int Fixed_Byte_To_Checksum = 25; // the first byte is not considered //in the calculation of "BYTE 2" const int CONTROL_DATA_LEN = 27; // loop detector / lane type arrays char * const dp5[8] = { "ML_1", "ML_2", "ML_3", "ML_4", "ML_5", "ML_6", "HOV_Lane", "FYW_Conn"}; char * const dp6[8] = { "OS_1", "OS_2", "OS_3", "OS_4", "OS_5", "OS_6", "COLL_DIST_2", "COLL_DIST_OFF"}; char * const dp7[8] = { "DEMAND", "PASSAGE", "QUEUE", "RAMP_ON", "RAMP_OFF", "RAMP_HOV", "COLL_DIST_1", "COLL_DIST_ON"}; char * const dp8[8] = { "SD_1", "SD_2", "SD_3", "SD_4", "SD_5", "SD_6", "Pass_Vol_Count", "X"}; // FEP line: Represents a serial communication line from field stations to the // An FEP Line has several Loop Detector Stations (Stations) connected) typedef struct fep_line FEP_LINE; struct fep_line { int lineNum; vector lds; vector ldsIndex; // location in ldsMap short count; // actual count from caltrans int schedule; int lineInfo; long systemKey; long globalSeq; long schedleSeq; }; // Loop Detector: A single sensor that detects the volume, occupancy, and speed // in a single highway lane typedef struct loop LOOP; struct loop { // meta data long loopID; char *loop_loc; // dynamic data int vol; float occ; double spd; }; // Loop detector station: A single field station that contains multiple loops at // a location typedef struct Station STATION; struct Station { // Each lds has its own line_num and drop (Caltrans use) long lds; short line_num; short drop; vector loops; // LDS data unsigned char *dataPack; int length; // total length of data (max: 87) int pos; // pointer for data preparation int MlTotVol; // each 30 sec, the following will be updated int OppTotVol; // each 30 sec, the following will be updated }; // A helper structure used to pack the volume and occupancy at a loop into // a two byte message typedef struct volOcc VOLOCC; struct volOcc { char high; char low; }; #endif