void one_measurement(int seconds, char *workload) { create_all_usb_devices(); start_power_measurement(); devices_start_measurement(); start_process_measurement(); start_cpu_measurement(); if (workload && workload[0]) { if (system(workload)) fprintf(stderr, _("Unknown issue running workload!\n")); } else { do_sleep(seconds); } end_cpu_measurement(); end_process_measurement(); collect_open_devices(); devices_end_measurement(); end_power_measurement(); process_cpu_data(); process_process_data(); /* output stats */ process_update_display(); report_summary(); w_display_cpu_cstates(); w_display_cpu_pstates(); if (reporttype != REPORT_OFF) { report_display_cpu_cstates(); report_display_cpu_pstates(); } report_process_update_display(); tuning_update_display(); end_process_data(); global_joules_consumed(); compute_bundle(); show_report_devices(); report_show_open_devices(); report_devices(); ahci_create_device_stats_table(); store_results(measurement_time); end_cpu_data(); }
void one_measurement(int seconds, char *workload) { create_all_usb_devices(); start_power_measurement(); devices_start_measurement(); start_process_measurement(); start_cpu_measurement(); if (workload && workload[0]) { system(workload); } else { do_sleep(seconds); } end_cpu_measurement(); end_process_measurement(); collect_open_devices(); devices_end_measurement(); end_power_measurement(); process_cpu_data(); process_process_data(); /* output stats */ process_update_display(); report_summary(); w_display_cpu_cstates(); w_display_cpu_pstates(); report_display_cpu_cstates(); report_display_cpu_pstates(); report_process_update_display(); tuning_update_display(); end_process_data(); global_joules_consumed(); compute_bundle(); show_report_devices(); report_show_open_devices(); report_devices(); store_results(measurement_time); end_cpu_data(); }
int main (int argc, char *argv[]) { int numbytes; static char buf[MAXBUFLEN]; //int c; //int ret = 0; prog = strdup( base_name(argv[0]) ); /* program header */ std::cout << prog << " - a communication radio based on VoIP with IAX/Asterisk" << std::endl; std::cout << "Original (c) 2007-2011 by H. Wirtz <*****@*****.**>" << std::endl; std::cout << "OSX and Windows ports 2012 by Yves Sablonier and Geoff R. McLane, respectively." << std::endl; std::cout << "Version " << FGCOM_VERSION << " build " << SVN_REV << " date " << __DATE__ << ", at " << __TIME__ << std::endl; std::cout << "Using iaxclient library Version " << iaxc_version (tmp) << std::endl; std::cout << std::endl; /* init values */ voipserver = DEFAULT_VOIP_SERVER; fgserver = DEFAULT_FG_SERVER; port = DEFAULT_FG_PORT; username = DEFAULT_USER; password = DEFAULT_PASSWORD; codec_option = DEFAULT_CODEC; mode = 0; /* 0 = ATC mode, 1 = FG mode */ positions_file = (char *) DEFAULT_POSITIONS_FILE; frequency_file = (char *) SPECIAL_FREQUENCIES_FILE; #ifndef _WIN32 /* catch signals */ signal (SIGINT, quit); signal (SIGQUIT, quit); signal (SIGTERM, quit); #endif /* setup iax */ #ifdef HAVE_IAX12 if (iaxc_initialize (DEFAULT_MAX_CALLS)) #else if (iaxc_initialize (DEFAULT_IAX_AUDIO, DEFAULT_MAX_CALLS)) #endif fatal_error ("cannot initialize iaxclient!\nHINT: Have you checked the mic and speakers?"); initialized = 1; // option parser fgcomInitOptions (fgcomOptionArray, argc, argv); // codec if (codec_option) { switch (codec_option) { case 'u': codec = IAXC_FORMAT_ULAW; break; case 'a': codec = IAXC_FORMAT_ALAW; break; case 'g': codec = IAXC_FORMAT_GSM; break; case '7': codec = IAXC_FORMAT_G726; break; case 's': codec = IAXC_FORMAT_SPEEX; break; } } // airport if (airport_option) { strtoupper (airport_option, airport, sizeof (airport)); } // input level if (level_in > 1.0) { level_in = 1.0; } if (level_in < 0.0) { level_in = 0.0; } // output level if (level_out > 1.0) { level_out = 1.0; } if (level_out < 0.0) { level_out = 0.0; } // microphone boost if (mic_boost) { iaxc_mic_boost_set (1); } if (list_audio) { std::cout << "Input audio devices:" << std::endl; std::cout << report_devices (IAXC_AD_INPUT) << std::endl; std::cout << "Output audio devices:" << std::endl; std::cout << report_devices (IAXC_AD_OUTPUT) << std::endl; iaxc_shutdown (); exit (1); } if (audio_in) { set_device (audio_in, 0); } if (audio_out) { set_device (audio_out, 1); } //#ifdef DEBUG /* Print any remaining command line arguments (not options). */ //if (optind < argc) { // printf ("non-option ARGV-elements: "); // while (optind < argc) // printf ("%s ", argv[optind++]); // putchar ('\n'); //} //#endif /* checking consistency of arguments */ if (frequency > 0.0 && frequency < 1000.0) { if (strlen (airport) == 0 || strlen (airport) > 4) { strcpy (airport, "ZZZZ"); } /* airport and frequency are given => ATC mode */ mode = 0; } else { /* no airport => FG mode */ mode = 1; } /* Read special frequencies file (if exists). * If no file $(INSTALL_DIR)/special_frequencies.txt exists, then default frequencies * are used and are hard coded. */ if (fix_input_files()) { /* adjust default input per OS */ fatal_error ("cannot adjust default input files per OS!\nHINT: Maybe recompile with larger buffer."); } if((special_frequencies = read_special_frequencies(frequency_file)) == 0) { std::cout << "Failed to load file [" << frequency_file << "]!\nUsing internal defaults." << std::endl; special_frequencies = special_frq; } else { std::cout << "Loaded file [" << frequency_file << "]." << std::endl; } /* read airport frequencies and positions */ airportlist = read_airports (positions_file); /* never returns if fail! */ /* preconfigure iax */ std::cout << "Initializing IAX client as " << username << ":" << "xxxxxxxxxxx@" << voipserver << std::endl; iaxc_set_callerid (const_cast < char *>(username), const_cast < char *>("0125252525122750")); iaxc_set_formats (codec, IAXC_FORMAT_ULAW | IAXC_FORMAT_GSM | IAXC_FORMAT_SPEEX); iaxc_set_event_callback (iaxc_callback); iaxc_start_processing_thread (); if (username && password && voipserver) { reg_id = iaxc_register (const_cast < char *>(username), const_cast < char *>(password), const_cast < char *>(voipserver)); #ifdef DEBUG std::cout << "DEBUG: Registered as '" << username << "' at '" << voipserver << "'." << std::endl; #endif } else { std::cout << "Failed iaxc_register!\nHINT: Check user name, pwd and ip of server." << std::endl; exitcode = 130; quit (0); } iaxc_millisleep (DEFAULT_MILLISLEEP); /* main loop */ #ifdef DEBUG std::cout << "Entering main loop in mode " << mode_map[mode] << "." << std::endl; #endif if (mode == 1) { /* only in FG mode */ netInit (); netSocket fgsocket; fgsocket.open (false); fgsocket.bind (fgserver, port); /* mute mic, speaker on */ iaxc_input_level_set (0); iaxc_output_level_set (level_out); ulClock clock; clock.update (); double next_update = clock.getAbsTime () + DEFAULT_ALARM_TIMER; /* get data from flightgear */ while (1) { clock.update (); double wait = next_update - clock.getAbsTime (); if (wait > 0.001) { netSocket *readsockets[2] = { &fgsocket, 0 }; if (fgsocket.select (readsockets, readsockets + 1, (int) (wait * 1000)) == 1) { netAddress their_addr; if ((numbytes = fgsocket.recvfrom (buf, MAXBUFLEN - 1, 0, &their_addr)) == -1) { perror ("recvfrom"); exit (1); } buf[numbytes] = '\0'; #ifdef DEBUG std:: cout << "DEBUG: got packet from " << their_addr.getHost () << ":" << their_addr.getPort () << std::endl; std::cout << "packet is " << numbytes << " bytes long" << std::endl; std:: cout << "packet contains \"" << buf << "\"" << std::endl; #endif process_packet (buf); } } else { alarm_handler (0); clock.update (); next_update = clock.getAbsTime () + DEFAULT_ALARM_TIMER; } } } else { /* only in ATC mode */ struct pos p; /* mic on, speaker on */ iaxc_input_level_set (level_in); iaxc_output_level_set (level_out); /* get geo positions of the airport */ p = posbyicao (airportlist, airport); icao2number (airport, frequency, tmp); #ifdef DEBUG printf ("DEBUG: dialing %s %3.3f MHz: %s\n", airport, frequency, tmp); #endif do_iaxc_call (username, password, voipserver, tmp); /* iaxc_select_call (0); */ while (1) { /* sleep endless */ ulSleep (3600); } } /* should never be reached */ exitcode = 999; quit (0); }