static bool init_freq_tables(void) { if (!frequencies_initialized) { init_freq_tables(frequencies); frequencies_initialized = true; } return true; }
freq_table_list_t get_matching_freq_tables( const QString &format, const QString &modulation, const QString &country) { QMutexLocker locker(&frequencies_lock); init_freq_tables(); freq_table_list_t list = get_matching_freq_tables_internal(format, modulation, country); freq_table_list_t new_list; for (uint i = 0; i < list.size(); i++) new_list.push_back(new FrequencyTable(*list[i])); return new_list; }
long long get_center_frequency( QString format, QString modulation, QString country, int freqid) { QMutexLocker locker(&frequencies_lock); init_freq_tables(); freq_table_list_t list = get_matching_freq_tables_internal(format, modulation, country); for (uint i = 0; i < list.size(); ++i) { int min_freqid = list[i]->name_offset; int max_freqid = min_freqid + ((list[i]->frequencyEnd - list[i]->frequencyStart) / list[i]->frequencyStep); if ((min_freqid <= freqid) && (freqid <= max_freqid)) return list[i]->frequencyStart + list[i]->frequencyStep * (freqid - min_freqid); } return -1; }
int main() { /* Starts profile as ALPHA_PROFILE: CC is not configured */ current_profile = ALPHA_PROFILE; do { if (current_profile != previous_profile) { if (current_profile == ALPHA_PROFILE) { printf("ALPHA PROFILE\n"); system("sh unuse_compcache.sh"); previous_profile = ALPHA_PROFILE; /* Save trained som in grids struct */ read_trained_som(NO_CC_DIR"saved_som.txt", grids); init_freq_tables(); read_freq_log(NO_CC_DIR"freq-pdf.log", freq_pdf); read_freq_log(NO_CC_DIR"freq-browser.log", freq_browser); read_freq_log(NO_CC_DIR"freq-canola.log", freq_canola); read_max_min_values(NO_CC_DIR"max_min_values.txt"); } else if (current_profile == BETA_PROFILE) { printf("BETA PROFILE\n"); system("sh unuse_compcache.sh"); system("sh use_compcache.sh 5120"); previous_profile = BETA_PROFILE; /* Save trained som in grids struct */ read_trained_som(WITH_CC_DIR"saved_som.txt", grids); init_freq_tables(); read_freq_log(WITH_CC_DIR"freq-pdf.log", freq_pdf); read_freq_log(WITH_CC_DIR"freq-browser.log", freq_browser); read_freq_log(WITH_CC_DIR"freq-canola.log", freq_canola); read_max_min_values(WITH_CC_DIR"max_min_values.txt"); } else if (current_profile == GAMA_PROFILE) { printf("GAMA PROFILE\n"); system("sh unuse_compcache.sh"); system("sh use_compcache.sh 10240"); system("echo 60 > /proc/sys/vm/swappiness"); previous_profile = GAMA_PROFILE; /* Save trained som in grids struct */ read_trained_som(WITH_CC_DIR"saved_som.txt", grids); init_freq_tables(); read_freq_log(WITH_CC_DIR"freq-pdf.log", freq_pdf); read_freq_log(WITH_CC_DIR"freq-browser.log", freq_browser); read_freq_log(WITH_CC_DIR"freq-canola.log", freq_canola); read_max_min_values(WITH_CC_DIR"max_min_values.txt"); } } current_profile = calculate_profile(); } while(1); return 0; }