| 1 | #ifndef NETWORK_H |
|---|
| 2 | #define NETWORK_H |
|---|
| 3 | #include <vector> |
|---|
| 4 | |
|---|
| 5 | using namespace std; |
|---|
| 6 | |
|---|
| 7 | /*** CONSTANTS ***/ |
|---|
| 8 | const int Fixed_Byte_To_Checksum = 25; // the first byte is not considered in the calculation of "BYTE 2" |
|---|
| 9 | const int CONTROL_DATA_LEN = 27; |
|---|
| 10 | char * const dp5[8] = { "ML_1", "ML_2", "ML_3", "ML_4", "ML_5", |
|---|
| 11 | "ML_6", "HOV_Lane", "FYW_Conn"}; |
|---|
| 12 | char * const dp6[8] = { "OS_1", "OS_2", "OS_3", "OS_4", "OS_5", |
|---|
| 13 | "OS_6", "COLL_DIST_2", "COLL_DIST_OFF"}; |
|---|
| 14 | char * const dp7[8] = { "DEMAND", "PASSAGE", "QUEUE", "RAMP_ON", |
|---|
| 15 | "RAMP_OFF", "RAMP_HOV", "COLL_DIST_1", "COLL_DIST_ON"}; |
|---|
| 16 | char * const dp8[8] = { "SD_1", "SD_2", "SD_3", "SD_4", "SD_5", |
|---|
| 17 | "SD_6", "Pass_Vol_Count", "X"}; |
|---|
| 18 | |
|---|
| 19 | /*** NETWORK STRUCTS ***/ |
|---|
| 20 | typedef struct loopagg LOOPAGG; |
|---|
| 21 | struct loopagg |
|---|
| 22 | { |
|---|
| 23 | int index; |
|---|
| 24 | char lane; // how namy lanes at the detector station |
|---|
| 25 | long time; |
|---|
| 26 | int interval; |
|---|
| 27 | int g_vol; |
|---|
| 28 | float g_occ; |
|---|
| 29 | double g_spd; |
|---|
| 30 | int *vol; |
|---|
| 31 | float *occ; |
|---|
| 32 | double *spd; |
|---|
| 33 | }; |
|---|
| 34 | |
|---|
| 35 | // FEP line: has several lds |
|---|
| 36 | typedef struct fep_line_lds FEP_LINE_LDS; |
|---|
| 37 | struct fep_line_lds |
|---|
| 38 | { |
|---|
| 39 | int lineNum; |
|---|
| 40 | vector<long> lds; |
|---|
| 41 | vector<long> ldsIndex; // location in ldsMap |
|---|
| 42 | short ldsNum; // actual number of lds on the line |
|---|
| 43 | |
|---|
| 44 | short count; // actual count from caltrans |
|---|
| 45 | int schedule; |
|---|
| 46 | int lineInfo; |
|---|
| 47 | long systemKey; |
|---|
| 48 | long globalSeq; |
|---|
| 49 | long schedleSeq; |
|---|
| 50 | }; |
|---|
| 51 | // Loop detector |
|---|
| 52 | typedef struct loop LOOP; |
|---|
| 53 | struct loop |
|---|
| 54 | { |
|---|
| 55 | long loopID; |
|---|
| 56 | char *loop_loc; |
|---|
| 57 | |
|---|
| 58 | int vol; |
|---|
| 59 | float occ; |
|---|
| 60 | double spd; |
|---|
| 61 | }; |
|---|
| 62 | |
|---|
| 63 | // Loop detector station: has several loops |
|---|
| 64 | typedef struct Station STATION; |
|---|
| 65 | struct Station |
|---|
| 66 | { |
|---|
| 67 | // Each lds has its own line_num and drop (Caltrans use) |
|---|
| 68 | long lds; |
|---|
| 69 | short line_num; |
|---|
| 70 | short drop; |
|---|
| 71 | |
|---|
| 72 | vector<LOOP*> loops; |
|---|
| 73 | |
|---|
| 74 | int num; // number of loops |
|---|
| 75 | // LDS data |
|---|
| 76 | unsigned char *dataPack; |
|---|
| 77 | int length; // total length of data (max: 87) |
|---|
| 78 | int pos; // pointer for data preparation |
|---|
| 79 | int MlTotVol; // each 30 sec, the following will be updated |
|---|
| 80 | int OppTotVol; // each 30 sec, the following will be updated |
|---|
| 81 | }; |
|---|
| 82 | // A helper structure used to pack the volume and occupancy at a loop into |
|---|
| 83 | // // a two byte message |
|---|
| 84 | typedef struct volOcc VOLOCC; |
|---|
| 85 | struct volOcc |
|---|
| 86 | { |
|---|
| 87 | char high; |
|---|
| 88 | char low; |
|---|
| 89 | }; |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | #endif |
|---|