Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

cannot open include file:

#include "StdAfx.h"
#include 
#include "TciCons.h"
#include "tftai.h"
#define TFTime __time32_t
#include "tfdescr.h"
#include "exinfo.h"
#include "tai.h"
#include 
#include 
#include 
#include 

#include "..includedrvstandard.h"
#include "..includedrvtool.h"			// prototypes driver development
#include "..includeUniTCPIPImports.h" // prototypes and defines to TCP/IP communication library
#include "..includeunicode.h"
#include "TsTCPAlarmItem.h"

#define DRIVER_NAME		_T("TSTCP")
static TCHAR szDrvVersion[] = _T("1.1.01");

unsigned long localtime_julian(long tim);

int ServiceRequest( COM_RESP_REC& com_resp_rec );

#define BUFSIZE1 512*1024 


CTciCons::CTciCons(void)
{
	nProtocol = PROTOCOL_DB2;
	pArchive = NULL;
	pSetup = NULL;  
	pSetupExtra = NULL;
	memset( &CpcRespRec, 0, sizeof(CpcRespRec));
	memset( &Db2Params, 0, sizeof(Db2Params));
	memset( &Db2, 0, sizeof(Db2));
	memset( &Db1, 0, sizeof(Db1));
	dnl_buf = new unsigned char[BUFSIZE1];

	strncpy( CpcRespRec.com_req.idnum, "EM002", 10);

	memcpy( CpcRespRec.com_req.scode,"0000",4 );
	strncpy(CpcRespRec.com_req.phone_nbr, "T166.131.58.7/12345", 25);
	CpcRespRec.com_req.comport = 11;							
	//CpcRespRec.com_req.baud = 9600;	
	CpcRespRec.com_req.linktime = 0;							
	CpcRespRec.com_req.retries = 3;
	strcpy( CpcRespRec.com_req.work_station_id,"EM002");
	CpcRespRec.com_req.rem_dev_type = 0;	// FCU
	CpcRespRec.com_req.time_out = 10;
	CpcRespRec.com_req.com_type = 10;		// tcp/ip
	
	Db2.bCompressed = 0;
	Db2.MaxDataBlockSize = 1024;
	Db2.MaxPacketSize = 8 * 1024;	
	Db2.RemoteRespTimeoutSecs = 10;
	Db2.retries = 3;
	Db2.RemoteACKTimeoutSecs = 10;
	Db2.CharacterTimeoutSecs = 2;

	/*Db1.retries = 3;
	Db1Params.nCollectDays = 0;
	Db1Params.nDataResolution = 0;
	Db1Params.nReqType = 0;*/

	memset(&GlobalpbutRespRec, 0, sizeof(GlobalpbutRespRec));
	memset(&GlobalkdtRespRec, 0, sizeof(GlobalkdtRespRec));
	memset(&GlobalValve, 0, sizeof(GlobalValve));
}

CTciCons::~CTciCons(void)
{
	delete dnl_buf;
	if(pArchive)
		ReleaseArchive(pArchive);
	if(pSetup)
		delete pSetup;
	if(pSetupExtra)
		delete [] pSetupExtra;
}

////////////// Driver Configuration standard functions  /////////////////
//
// The functions not declared are replace by default functions

int CTciCons::ProcessCommand(int cmd)
{
char bfr[80];
ULONG now;
int opt=cmd;
if(opt<0)
{
	if(nProtocol==PROTOCOL_DB1)
		opt=GetDB1Option();
	else
		opt=GetDB2Option();
}
if(opt==0||opt==100) return 0;
if(opt==1||opt==101)
{
	if(nProtocol==PROTOCOL_DB1)
	{
		nProtocol=PROTOCOL_DB2;
		CpcRespRec.com_req.linktime=0;
		CpcRespRec.com_req.com_type=10;
	}
	else
	{
		nProtocol=PROTOCOL_DB1;
		CpcRespRec.com_req.linktime=1;
		CpcRespRec.com_req.com_type=0;
	}
	return -1;
}
CpcRespRec.com_req.dnl_buf=(char*)dnl_buf;
switch(opt)
{
case 2:
	BuildRegisterRequest(&CpcRespRec.com_req,&Db2,9,0,0,1);
    ServiceRequest(CpcRespRec);
	ShowRegisters();
	break;
case 3:
	float tmp[3];
	tmp[0]=(float)1003;
	tmp[1]=(float)0.7;
	tmp[2]=(float)0;
	BuildRegisterDownload(&CpcRespRec.com_req,&Db2,9,0,1,1,(char *)tmp,4);
	AddRegisterDownload(&CpcRespRec.com_req,9,0,4,1,(char *)(tmp+1),4);
	ServiceRequest(CpcRespRec);
	ShowStatus();
	break;
}
delete CpcRespRec.rsp_buf;
memset(bfr,0,sizeof(bfr));
gets(bfr);
if(strlen(bfr)==0) return -1;
return atoi(bfr);
}
int CTciCons::GetDB1Option()
{
	
}
int CTciCons::GetDB2Option()
{
	int rtn = 0;
	char buffer[25];
	printf( "_____________________________ 
");
//	printf( "DB2 Protocol - Choose an Option!
");
	printf( "Ready To Poll!
");
	printf( "0) To quit
");
	//printf( "1) Switch to DB1
");
	printf( "3) Read Register
");
	printf( "4) Write Register
");
	memset(buffer, 0, sizeof(buffer));
	gets(buffer);
	if(strlen(buffer) == 0) return 0;
	return atoi(buffer);
}
 
PREVIOUS NEXT
Tagged: #open #include
ADD COMMENT
Topic
Name
8+6 =