void runGraphData(){ gROOT->ProcessLine(".L graphData.c+"); graphData(); }
int main(int argc, char *argv[]) { std::cout << "INAV SERVER v" << INAV_VERSION << std::endl; std::vector<Thread *> threads; int returnCode; //Print Help std::string parsedString = parser( argc, argv, "-h" ); if( parsedString.size() > 0 ) printHelp(); parsedString = parser( argc, argv, "--help" ); if( parsedString.size() > 0 ) printHelp(); //Check for debug parsedString = parser( argc, argv, "-vv" ); if( parsedString.size() > 0 ) inav::DEBUG = true; //check log file if (!inav::log) { std::cerr << "Unable to write to log file: " << inav::logFile << std::endl; exit(-1); } log("INAV starting up!"); //check command line options //check if we should print out pcap capabile devices parsedString = parser( argc, argv, "-ls" ); if ( parsedString == "set" ) { log( "Server started with -ls option printing devices and halting..." ); printDevices(); exit(-1); } std::string device = parser( argc, argv, "-i" ); if( device == "set" ) { log( "WARNING: device flag given but no device specified! CANNOT CONTINUE" ); exit( -1 ); } std::cout << "Device(s) set to " << device << std::endl; log( "Device(s) set to " + device ); std::vector< std::string > devices; if( device.size() != 0 ) devices = parseCommas( device ); //Setup pcap file input std::string file = parser( argc, argv, "-f" ); if( file == "set" ) { log( "WARNING: input selected as pcap file with no file specified. CANNOT CONTINUE" ); exit( -1 ); } std::cout << "File(s) set to " << file << std::endl; log( "File(s) set to " + file ); std::vector< std::string > files; if( file.size() != 0 ) files = parseCommas( file ); std::string cvsFile = parser( argc, argv, "-c" ); if( cvsFile == "set" ) { log( "WARNING: input for cvs files is blank. CANNOT CONTINUE" ); exit( -1 ); } std::cout << "CVSFile(s) Set To " << cvsFile << std::endl; log( "CVSFILE(s) Set To " + cvsFile ); std::vector< std::string > cvsFiles; if( cvsFile.size() != 0 ) cvsFiles = parseCommas( cvsFile ); //Creating different datastructures SnifferData snifferTemplate( inav::coutMutex, inav::logMutex, &inav::log ); snifferTemplate.setDevice( device ); FilterData filterData( inav::coutMutex, inav::logMutex, &inav::log ); GraphData graphData( inav::coutMutex, inav::logMutex, &inav::log ); log( "Creating Sniffer Thread(s)" ); std::vector< std::string >::iterator sitr; for( sitr = devices.begin(); sitr != devices.end(); ++sitr ) { //Set up sniffing threads SnifferDataHolder snifferDataHolder; SnifferData *snifferData = new SnifferData( snifferTemplate ); snifferData->setDevice( *sitr ); snifferDataHolder.snifferData = snifferData; snifferDataHolder.filterData = &filterData; Thread* thread = new Thread( sniffer ); thread->start( (void *) &snifferDataHolder ); threads.push_back( thread ); } log( "Creating Sniffer Offline Tread(s)" ); for( sitr = files.begin(); sitr != files.end(); ++sitr ) { //Set up pcap file threads SnifferDataHolder snifferDataHolder; SnifferData *snifferData = new SnifferData( snifferTemplate ); snifferData->setDevice( *sitr ); snifferDataHolder.snifferData = snifferData; snifferDataHolder.filterData = &filterData; Thread* thread = new Thread( snifferOffline ); thread->start( (void*) &snifferDataHolder ); threads.push_back( thread ); } log( "Creating cvsFile Input Thread(s) " ); for( sitr = cvsFiles.begin(); sitr != cvsFiles.end(); ++sitr ) { //Set up pcap file threads SnifferDataHolder snifferDataHolder; SnifferData *snifferData = new SnifferData( snifferTemplate ); snifferData->setDevice( *sitr ); snifferDataHolder.snifferData = snifferData; snifferDataHolder.filterData = &filterData; Thread* thread = new Thread( cvsSniffer ); thread->start( (void*)&snifferDataHolder ); threads.push_back( thread ); } //Set up Bandwidth Monitor Thread BandwidthDataHolder bandwidthDataHolder; bandwidthDataHolder.filterData = &filterData; bandwidthDataHolder.graphData = &graphData; log( "Creating Bandwidth Monitor Thread" ); Thread* thread = new Thread( bandwidthMonitor ); thread->start( (void*)&bandwidthDataHolder ); threads.push_back( thread ); //Set up client thread std::string port = parser( argc, argv, "-p" ); int portnum = communication::ServerPort; if( port.size() > 0 ) { log( "Seting port to " + port ); portnum = atoi( port.c_str() ); } ClientCommData clientCommData( inav::coutMutex, inav::logMutex, &inav::log, portnum ); clientCommData.filterData = &filterData; clientCommData.graphData = &graphData; log( "Creating Communication Thread" ); thread = new Thread( communicationChannel ); thread->start( (void*)&clientCommData ); threads.push_back( thread ); std::string debug = parser( argc, argv, "--debug" ); if( debug.size() > 0 ) { DebugData debugData; debugData.filterData = &filterData; debugData.graphData = &graphData; Thread* thread = new Thread( debugThread ); thread->start( (void*)&debugData ); threads.push_back( thread ); } //Wait for threads to exit //(void*) std::vector<Thread*>::iterator itr; for( itr = threads.begin(); itr != threads.end(); ++itr ) { log( "Deleting Thread... " ); (*itr)->join(); } log( "INAV server halting!" ); return 0; }
int main (int argc, char **argv) { // Variables for recording the time. time_t rawtime; struct tm * timeinfo; // Variables for describing the scan. float startvalue,endvalue,stepsize; // Variables for storing text char fileName[BUFSIZE],comments[BUFSIZE]; // A file used to indicate that we are collecting data. char dataCollectionFileName[] = "/home/pi/.takingData"; // Used to store error codes int err; FILE *dataCollectionFlagFile, *fp; /* Check to make sure that the proper arguments were supplied. */ if (argc==5) { startvalue=atof(argv[1]); endvalue=atof(argv[2]); stepsize=atof(argv[3]); strcpy(comments,argv[4]); } else { printf("Usage:\n"); printf("$ sudo ./RbAbsorbScan <begin> <end> <step> <comments>\n"); printf(" (0.0 - 117.5) \n"); return 0; } // Indicate that data is being collected. dataCollectionFlagFile=fopen(dataCollectionFileName,"w"); if (!dataCollectionFlagFile) { printf("Unable to open file: %s\n",dataCollectionFileName); exit(1); } initializeBoard(); initializeUSB1208(); if (endvalue>117.5) endvalue=117.5; if (startvalue>117.5) endvalue=117.5; if (startvalue<0) startvalue=0; if (endvalue<0) endvalue=0; if (startvalue>endvalue) { printf("error: startvalue > endvalue.\nYeah, i could just swap them in code.. or you could just enter them in correctly. :-)\n"); return 1; } // Get file name. use format "RbAbs"+$DATE+$TIME+".dat" time(&rawtime); timeinfo=localtime(&rawtime); struct stat st = {0}; strftime(fileName,BUFSIZE,"/home/pi/RbData/%F",timeinfo); if (stat(fileName, &st) == -1){ // Create the directory for the Day's data mkdir(fileName,S_IRWXU | S_IRWXG | S_IRWXO ); } strftime(fileName,BUFSIZE,"/home/pi/RbData/%F/RbAbs%F_%H%M%S.dat",timeinfo); printf("\n%s\n",fileName); writeFileHeader(fileName, comments); fp=fopen(fileName,"a"); if (!fp) { printf("unable to open file: %s\n",fileName); exit(1); } err=setMirror(0); if(err>0) printf("Error Occured While setting Flip Mirror: %d\n",err); collectAndRecordData(fileName, startvalue, endvalue, stepsize); setVortexPiezo(45.0); // Return Piezo to 45.0 V closeUSB1208(); graphData(fileName); fclose(dataCollectionFlagFile); remove(dataCollectionFileName); return 0; }