Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

...

The very step to avoid difficult integration times: unit test the external communication with ACE.

Code Block
breakoutModewide
languagec
// NAME.......  Tutorial #1
// PURPOSE....	This code presents how to connect onto ACE and to use aceOut
//
//	Hypothesis and optimizations:
//		Communication between ACE and acceptance device is IP
//
// PROJECT....  Wiki
// REFERENCES.	--
//
// Copyright ©2005-2020 - 9164-4187 QUEBEC INC (“AMADIS”), All Rights Reserved
//
//---------------------------------------------------------
//            Main
//---------------------------------------------------------
int main(int argc, char** argv)
{
	// Communication
	int port, length;
	char address[50]="";

	// Get Communication parameters from ini file
	// These paramerters maybe wired inside the code for training purposes
	xgpiIniSetFilename("agnos.ini");
	xgpiIniGetString("COM", "Address", 50, address, &length);
	xgpiIniGetNumeric("COM", "Port", &port);

	// Initialize ACE
	// Initialize generic communication interface
	assert(tcpInit(0) == TCP_NO_ERROR);
	// Create server and client
	assert(comtcpOpen(&gACEServerCOMTCP, TCP_SERVER, 0, port) == COM_NO_ERROR);
	assert(comtcpOpen(&gACEClientCOMTCP, TCP_CLIENT, address, 1979) == COM_NO_ERROR);
	// Set ACE with server and client 
	aceInitializeCommunication(&gACEServerCOMTCP.com,&gACEClientCOMTCP.com);
	
	// Initialize running mode
	aceSetMode(pmSDK);

	// Set ACE option
	aceSetUIDisplay(bTRUE);

	// Trace into ACE
	aceOut("Training Session - BEGIN\n");
	aceOut("Hello World!\n");
	aceOut("Training Session - END\n");

	return 0;
}

Tutorial #2: initialize language and payment context

...

Code Block
breakoutModewide
languagec
// NAME.......  Tutorial #2
// PURPOSE....	This code presents how to intialize language and payment contexts
//
//	Hypothesis and optimizations:
//		Communication between ACE and acceptance device is IP
//
// PROJECT....  Wiki
// REFERENCES.	--
//
// Copyright ©2005-2020 - 9164-4187 QUEBEC INC (“AMADIS”), All Rights Reserved
//
//---------------------------------------------------------
//            Main
//---------------------------------------------------------
int main(int argc, char** argv)
{
	// Communication
	int port, length;
	char address[50]="";
	// Trace for debugging
	char tmp[100]="";
	// Payment Contexts
	tPaymentContext* pay = &gPaymentCtx;
	tOutComeParameter* out = &gOutcome;
	// System's language
	tByte availableLanguage=0;
	tByte currentLanguage = 0;

	// Get Communication parameters from ini file
	// These paramerters maybe wired inside the code for training purposes	xgpiIniSetFilename("agnos.ini");
	xgpiIniGetString("COM", "Address", 50, address, &length);
	xgpiIniGetNumeric("COM", "Port", &port);

	// Initialize ACE
	// Initialize generic communication interface
	assert(tcpInit(0) == TCP_NO_ERROR);
	// Create server and client
	assert(comtcpOpen(&gACEServerCOMTCP, TCP_SERVER, 0, port) == COM_NO_ERROR);
	assert(comtcpOpen(&gACEClientCOMTCP, TCP_CLIENT, address, 1979) == COM_NO_ERROR);
	// Set ACE with server and client 
	aceInitializeCommunication(&gACEServerCOMTCP.com,&gACEClientCOMTCP.com);

	// Initialize running mode
	aceSetMode(pmSDK);

	// Set up ACE's options
	aceSetUIDisplay(bTRUE);


	aceOut("Training Session - BEGIN\n");
	aceOut("Hello World!\n");// set default language (merchant language indeed)

	// Initialize lines, columns and set string table from lang.ini
	gpiInitializeDisplay("lang.ini",&availableLanguage,NULL);
	sprintf(tmp,"Available lang.: %i\n",availableLanguage);
	aceOut(tmp);

	// Initialize payment context and outcome
	pmwInitializePaymentContext(pay);
	pmwSetLanguage(pay,currentLanguage); // Don't forget to propagate language in payment context for further processing
	currentLanguage = pmwGetLanguage(pay);
	pmwInitializeOutComeParameter(out);

	// Important to perform these initializations after pmwInitializePaymentContext
	pay->mAmount = &gAmount;
	pay->mCashBack = &gCashBack;
	pay->mTransactionType = (tTransactionType)0x00;
	gAmount = gCashBack = 0;

	gpiDisplayMessageByID(gpi_true,currentLanguage,WELCOME);

	gpiDisplayMessageByID(gpi_true,currentLanguage+1,THANKS); // Assuming that there are at least 2 languages

	aceOut("Training Session - END\n");

	return 0;
}

...