#ifndef __NETWORK_H_INCLUDED__
#define __NETWORK_H_INCLUDED__

#include <stdlib.h>
#include <math.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"};

// FEP line: has several lds
typedef struct fep_line FEP_LINE;
struct  fep_line
{
	int             lineNum;
	vector<long>    lds;
	vector<long>    ldsIndex;	// location in ldsMap

	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;

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

typedef struct volOcc VOLOCC;
struct  volOcc
{
   char high;
   char low;
};


#endif
