#ifndef _ELVLOG
#define _ELVLOG

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include <libusb-1.0/libusb.h>
#include "tcfp_parser.h"
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>

#define PORTNO 5323

#define MCOMP 0x09db
#define USB7204 0x00f0

#define VENDOR_CONTROL_IN 0xC0
#define VENDOR_CONTROL_OUT 0x40

#define MESSAGE_REQUEST 0x80
#define VALUE_REQUEST 0x81

#define WVALUE 0
#define WINDEX 0

#define MAXBUF 64

#define FLASHLED  "DEV:FLASHLED/5"
#define MFGSER  "?DEV:MFGSER"
#define FRMVER  "?DEV:FWV"
#define SLOPE  "?AI{0}:SLOPE"
#define OFFSET  "?AI{0}:OFFSET"
#define CHMODE  "AI:CHMODE=DIFF"
#define QCHMODEQ  "?AI:CHMODE"
//range is fixed at +/-10V in SE mode
#define AI0RANGE  "AI{0}:RANGE="
#define AI1RANGE  "AI{1}:RANGE=BIP5V"
#define AI0READ  "?AI{0}:VALUE"
#define AI1READ  "?AI{1}:VALUE"
#define AO0OUT  "AO{0}:VALUE=0"
#define DIOIN  "DIO{0}:DIR=IN"
#define DIOOUT  "DIO{0}:DIR=OUT"
#define DIOVALUE "DIO{0}:VALUE=000"

//Pick the pointer and set the channel
//at location of chchar
#define CHCHAR 3
char bip1v[]="AI{0}:RANGE=BIP1V";
char bip1pt25v[]="AI{0}:RANGE=BIP1PT25V";
char bip2v[]="AI{0}:RANGE=BIP2V";
char bip2pt5v[]="AI{0}:RANGE=BIP2PT5V";
char bip4v[]="AI{0}:RANGE=BIP4V";
char bip5v[]="AI{0}:RANGE=BIP5V";
char bip10v[]="AI{0}:RANGE=BIP10V";
char bip20v[]="AI{0}:RANGE=BIP20V";

//range key values
#define BIP1V     "BIP1V"
#define BIP1PT25V "BIP1PT25V"
#define BIP2V     "BIP2V"
#define BIP2PT5V  "BIP2PT5V"
#define BIP4V     "BIP4V"
#define BIP5V     "BIP5V"
#define BIP10V    "BIP10V"
#define BIP20V    "BIP20V"

#define SEMODE    "SE"
#define DIFFMODE  "DIFF"

#define MAXSTRING 255
#define MAXHEADER 32
#define MAXTABLE 32
#define MODELENGTH 5
#define CHANNELS 8
#define MAXFORMAT 10
#define GFCHANNELS 8

typedef struct
{
 char header[MAXHEADER];
 char format[MAXFORMAT];
 char *range;
 double slope;
 double intercept;
 double reading;
}channelData;

typedef struct
{
 char header[MAXHEADER];
 char format[MAXFORMAT];
 int settleTime;
 double reading;
}gfData;

typedef struct
{
 char *cFile;
 TCFP_config_data *configDataValue;
 char logFilename[MAXSTRING];
 char dbFilename[MAXSTRING];      //where it is stored
 char mode[MODELENGTH] ;                       //SE of DIFF
 char metaname[MAXTABLE];
 int secPerSamp;
 channelData channel[CHANNELS];
 gfData gfchannel[GFCHANNELS];

} configurationData;

#endif