Ejemplo n.º 1
0
int main(int argc, char** argv) {
	
	/* Get number of devices */
	int numberOfDevices;
	
	std::string input_filename = FILENAME_TESTFILE;
	std::string scope_filename = SCOPE_PARAMETERFILE;
	std::string output_filename =  OUTPUT_FILENAME;

	if(argc > 1) {
		input_filename = argv[1];	
		scope_filename = argv[1];
	}
	if(argc > 2) {
		output_filename = argv[2];
	}
	
	//std::cout << "Args read (" << input_filename << ", " << output_filename << ")" << std::endl;
    InputBuffer inputBuffer(CHUNK_BUFFER_COUNT, 1);
	
	/* Initialize input buffer (with dynamic elements) */
	ScopeReader::ScopeParameter parameter(scope_filename);
	//int nSegments = parameter.nbrSegments;
	//int nWaveforms = parameter.nbrWaveforms;
	int nSample = parameter.nbrSamples;
	ScopeReader reader(parameter, &inputBuffer, CHUNK_COUNT);
	GrayBatStream<Chunk> os(1,masterUri, fitterUri);
	
	std::thread sendingThread([&inputBuffer, &os](){
		while(inputBuffer.isFinished()) {
			inputBuffer.popTry([&os](Chunk& t){
				os.send(t);
			});
		}
		
		os.quit();
	});
	
	//std::cout << "Buffer created." << std::endl;

	reader.readToBuffer();
	
	//Make sure all results are written back
	sendingThread.join();
	return 0;	
}
Ejemplo n.º 2
0
// Method		 ->	IAG0010Socket::Start
// Param		 ->	IAG0010Event &e
// Returning	 ->	void
// Comments		 ->	Method starts the data transfer 
//					e is the reference to the event that becomes signalled when the transfer
//					has ended, data receiving and sending threads stopped and the connection
//					closed. When e is signalled, the main thread can exit
void IAG0010Socket::Start(IAG0010Event &eventTransferEnded)
{
	IAG0010Receive * objIAG0010Receive = NULL;
	IAG0010Send* objIAG0010Send = NULL;
	
	try
	{
		// Receiving thread creation and launching
		objIAG0010Receive = new IAG0010Receive(hClientSocket, eventSendOK, eventExitTyped,  outputFileName,eventTransferEnded);
		thread receivingThread(&IAG0010Receive::Run, objIAG0010Receive);
		

		// Sending thread creation and launching
		objIAG0010Send = new IAG0010Send(hClientSocket, eventSendOK, eventExitTyped,eventTransferEnded);
		thread sendingThread(&IAG0010Send::Run, objIAG0010Send);	
		
		receivingThread.join();
		sendingThread.join();
		
		_tcout << "IAG0010Socket:  Transfer thrads joined " << endl;

		delete objIAG0010Receive;
		delete objIAG0010Send;

	}
	catch (exception &ex)
	{
		ConnectionError = TRUE;

		if (!objIAG0010Receive) delete objIAG0010Receive;
		if (!objIAG0010Send)	delete objIAG0010Send;

		cout << ex.what() << endl;

		return;
	}
}