Ejemplo n.º 1
0
int
main(int argc, char *argv[])
{
   int i = isatty(fileno(stdin));
   double din, dout;
   int r;
   int done = 0;
   do  {
      if(i != 0){
         printf("Enter a number: ");
      }
      r = scanf("%lg", &din);
      if (r != 1) {
         if (feof(stdin)) {
            done = 1;
         } else if (r == 0){
            printf("Junk on the input.  Sorry.\n");
            exit(EXIT_FAILURE);
         } else {
            perror("Input");
            exit(EXIT_FAILURE);
         }
      }else {
      dout = sigs(din);
      printf("In: %g; out: %g\n", din, dout);
      }
   } while (!done);
   if(i != 0){
      printf("\n\nBye-bye\n");
   }
  
  return EXIT_SUCCESS;
}
Ejemplo n.º 2
0
Archivo: main.cpp Proyecto: ATNoG/ODiMM
int main(int argc, char** argv)
{
	opmip::setup_crash_handler();

	try {
		size_t                       concurrency = boost::thread::hardware_concurrency();
		boost::asio::io_service      ios(concurrency);
		boost::asio::signal_set      sigs(ios, SIGINT, SIGTERM);

		sigs.async_wait(boost::bind(signal_handler, _1, drv, boost::ref(mag)));

		//start odimm code here

		boost::thread_group tg;
		for (size_t i = 1; i < concurrency; ++i)
			tg.create_thread(boost::bind(&boost::asio::io_service::run, &ios));

		ios.run();
		tg.join_all();

	} catch(opmip::exception& e) {
		std::cerr << e.what() << std::endl;
		return 1;

	} catch(std::exception& e) {
		std::cerr << "exception: " << e.what() << std::endl;
		return 1;
	}

	return 0;
}
Ejemplo n.º 3
0
/** extract times from signal producer
 *
 * extract the time values from the signal producer and puts it into
 * the corrosponding tdc like array
 *
 * @param thePair container for tdc like array mapped to the corrosponding
 *                signalproducer.
 *
 * @author Lutz Foucar
 */
void extactTimes(pair<SignalProducer*,vector<double> > & thePair)
{
  vector<double> &tdcarray(thePair.second);
  tdcarray.clear();
  SignalProducer::signals_t &sigs(thePair.first->output());
  SignalProducer::signals_t::const_iterator sigsIt(sigs.begin());
  for (;sigsIt !=sigs.end(); ++sigsIt)
    tdcarray.push_back((*sigsIt)[time]);
}