示例#1
0
/**
* <summary>
* Main Program Entry Point.
* </summary>
*/
int main(int argc, const char** argv) 
{
	int retval = 0;
	WriteHeader();

	//Add all the arguments.
	s_args.AddMapEntries( s_argmap);
	s_s1.RegisterArgs( "s1", s_args);
	s_s2.RegisterArgs( "s2", s_args);

	//Parse the arguments.
	retval = s_args.Parse( argc, argv);
	if( retval > 0)
	{
		int addr = (int) s_args.GetLong( "address");
		try {
			addr = s_cfgDevice.Attach(addr);
			printf("Attached to ASR-2300 at address = %d\n", addr);

		} catch (std::runtime_error& re) {
			printf("Error:  %s0\n", re.what());
			return -1;
		}

		// Dump the device information
		DumpDeviceInformation();

		//Initialize the stream loggers.
		retval = s_s1.Init( s_args, &s_cfgDevice);
		if( retval == 0)
			retval = s_s2.Init( s_args, &s_cfgDevice);
	
		//Receive the data and store to disk.
		if( retval == 0)
		{
			s_s1.DisplayConfiguration();
			s_s2.DisplayConfiguration();

			s_cfgDevice.Dci0Transport().ClearReceiveQueue();

			retval = ReceiveData((size_t) (s_args.GetDouble("duration")*1000.0));
		}

		s_s1.Terminate();
		s_s2.Terminate();
		s_cfgDevice.Detach();
	}
	else //Arguments were not right.
	{
		PrintUsage();
	}
	return retval;
}