#ifndef NETWORK_H
#define NETWORK_H
#include <vector>

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;
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"};

/*** NETWORK STRUCTS ***/
typedef struct loopagg LOOPAGG;
struct loopagg
{
   int		index;
   char	lane;			// how namy lanes at the detector station
   long	time;
   int		interval;
   int 	g_vol;
   float	g_occ;
   double	g_spd;
   int		*vol;
   float	*occ;
   double	*spd;
};

// FEP line: has several lds
typedef struct fep_line_lds FEP_LINE_LDS;
struct  fep_line_lds
{
   int		lineNum;
   vector<long> lds;
   vector<long> ldsIndex;	// location in ldsMap
   short	ldsNum;			// actual number of lds on the line

   short	count;	// actual count from caltrans
   int		schedule;
   int		lineInfo;
   long	systemKey;
   long	globalSeq;
   long	schedleSeq;
};
// Loop detector
typedef struct loop LOOP;
struct loop
{
   long loopID;
   char *loop_loc;

   int vol;
   float occ;
   double spd;
};

// Loop detector station: has several loops
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<LOOP*> loops;

   int		num;	// number of 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
