Versions Compared

Key

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

...

Code Block
breakoutModewide
languagec
//---------------------------------------------------------
//            Main
//---------------------------------------------------------
//  Main function:
//		- Hypothesis: IP communication with ACE
//      - Use aceOut from Agnos tutorials
//
//  Visibility: Public
//  Hypothesis: --
//  Reference: --
//
int main(int argc, char** argv)
{
	// Communication
	int port, length;
	char address[50]="";
	// Trace for debugging
	char tmp[1000]="";

	// Get Communication parameters from ini file
	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);

	// Set up ACE's options
	aceSetUIDisplay(bTRUE);
	// Activate SDK to access to ACE services
	aceSetMode(pmSDK);

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

	char* parameters;

	// Initialize GPI
	// This is platform dependent. On Kizis AVT, this set PCSC readers' name from agnos.ini
	gpiMain(0,&parameters);

	tTimerHandler MaxTimer=0, timer1=0, timer2=0;
	tTimerState state;
	tTimerTime sec, microsec;

	gpiResetTimers();
	gpiGetMaxTimer(&MaxTimer);
	sprintf(tmp,"Max Timer: %i\n",MaxTimer);
	aceOut(tmp);

	gpiGetTimer(&timer1);
	sprintf(tmp,"Timer 1 is: %i\n",timer1);
	aceOut(tmp);

	gpiGetTimerState(timer1,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i \n",timer1,state);
	aceOut(tmp);

	gpiStartTimer(timer1,0,0);

	gpiGetTimer(&timer2);
	sprintf(tmp,"Timer 2 is: %i\n",timer2);
	aceOut(tmp);

	gpiGetTimerState(timer2,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i \n",timer2,state);
	aceOut(tmp);


	gpiStartTimer(timer2,0,0);

	gpiGetTimerState(timer1,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i\n",timer1,state);
	aceOut(tmp);

	gpiGetTimerState(timer2,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i\n",timer2,state);
	aceOut(tmp);

	gpiSleep(5000);

	gpiStopTimer(timer1);

	gpiGetTimerState(timer1,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i\n",timer1,state);
	aceOut(tmp);

	gpiGetTimerTime(timer1,&sec,&microsec);
	sprintf(tmp,"Elapse Time (%i) =  %lu seconds, %lu micro-seconds\n",timer1,sec,microsec);
	aceOut(tmp);

	gpiGetTimerState(timer2,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i\n",timer2,state);
	aceOut(tmp);

	gpiSleep(5000);

	gpiStopTimer(timer2);

	gpiGetTimerState(timer2,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i\n",timer2,state);
	aceOut(tmp);

	gpiGetTimerTime(timer2,&sec,&microsec);
	sprintf(tmp,"Elapse Time (%i) =  %lu seconds, %lu micro-seconds\n",timer2,sec,microsec);
	aceOut(tmp);

	gpiRestartTimer(timer1);

	gpiSleep(5000);

	gpiStopTimer(timer1);

	gpiGetTimerState(timer1,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i\n",timer1,state);
	aceOut(tmp);

	gpiGetTimerTime(timer1,&sec,&microsec);
	sprintf(tmp,"Elapse Time (%i) =  %lu seconds, %lu micro-seconds\n",timer1,sec,microsec);
	aceOut(tmp);

	gpiFreeTimer(timer1);
	gpiFreeTimer(timer2);

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

	return 0;
}

...