/* test IsWarcIndex */ void test_IsWarcIndex(void **state) { assert_int_equal(IsWarcIndex(BANDINDEX_160), 0); assert_int_equal(IsWarcIndex(BANDINDEX_80), 0); assert_int_equal(IsWarcIndex(BANDINDEX_40), 0); assert_int_equal(IsWarcIndex(BANDINDEX_30), 1); assert_int_equal(IsWarcIndex(BANDINDEX_20), 0); assert_int_equal(IsWarcIndex(BANDINDEX_17), 1); assert_int_equal(IsWarcIndex(BANDINDEX_15), 0); assert_int_equal(IsWarcIndex(BANDINDEX_12), 1); assert_int_equal(IsWarcIndex(BANDINDEX_10), 0); }
int bm_isdupe( char *call, int band ) { int found = -1; struct t_qtc_store_obj *qtc_obj; /* spot for warc bands are never dupes */ if (IsWarcIndex(band)) return 0; found = searchcallarray(call); if (found == -1) /* new call */ return 0; if (qtcdirection > 0) { qtc_obj = qtc_get(call); if (qtc_obj->total > 0 && qtc_obj->total < 10) { return 0; } if (qtc_obj->total == 0 && (qtc_obj->capable > 0)) { return 0; } } if (worked[found].band & inxes[band]) { return 1; } else { return 0; } }
void bandmap_show() { /* * display depending on filter state * - all bands on/off * - all mode on/off * - dupes on/off * * If more entries to show than room in window, show around current frequency * * mark entries according to age, source and worked state. Mark new multis * - new brigth blue * - normal blue * - aged black * - worked small caps * - new multi underlined * - self announced stations * small preceeding letter for reporting station * * maybe show own frequency as dashline in other color * (maybee green highlighted) * - highligth actual spot if near its frequency * * Allow selection of one of the spots (switches to S&P) * - Ctrl-G as known * - '.' and cursor plus 'Enter' \Todo * - Test mouseclick.. \Todo * * '.' goes into map, shows help line above and supports * - cursormovement * - 'ESC' leaves mode * - 'Enter' selects spot * - 'B', 'D', 'M' switches filtering for band, dupes and mode on or off. */ GList *list; spot *data; int curx, cury; int bm_x, bm_y; int i,j; short dupe; float centerfrequency; if (!bm_initialized) { bm_init(); bm_initialized = 1; } /* acquire mutex * do not add new spots to allspots during * - aging and * - filtering * furthermore do not allow call lookup as long as * filtered spot array is build anew */ pthread_mutex_lock( &bm_mutex ); /* make array of spots to display * filter spotlist according to settings */ if (spots) g_ptr_array_free( spots, TRUE); /* free array */ spots = g_ptr_array_sized_new( 128 ); /* allocate new one */ list = allspots; while (list) { data = list->data; /* if spot is allband or allmode is set or band or mode matches * actual one than add it to the filtered 'spot' array * drop spots on WARC bands if in contest mode */ dupe = bm_isdupe(data->call, data->band); if ( (!contest || !IsWarcIndex(data->band)) && (bm_config.allband || (data->band == bandinx)) && (bm_config.allmode || (data->mode == trxmode)) && (bm_config.showdupes || !dupe)) { data -> dupe = dupe; g_ptr_array_add( spots, data ); } list = list->next; } pthread_mutex_unlock( &bm_mutex ); /* afterwards display filtered list around own QRG +/- some offest * (offset gets reset if we change frequency */ getyx( stdscr, cury, curx); /* remember cursor */ /* start in line 14, column 0 */ bm_y = 14; bm_x = 0; /* clear space for bandmap */ attrset(COLOR_PAIR(CB_DUPE)|A_BOLD); move(bm_y,0); /* do not overwrite # frequency */ for (j = 0; j < 67; j++) addch(' '); for (i = bm_y + 1; i < bm_y + 10; i++) { move (i,0); for (j = 0; j < 80; j++) addch (' '); } /* show info text */ bm_show_info(); /* split bandmap into two parts below and above current QRG. * Give both both parts equal size. * If there are less spots then reserved in the half * give the remaining room to the other half. * * These results in maximized usage of the bandmap display while * trying to keep the actual frequency in the center. */ unsigned int below_qrg = 0; unsigned int on_qrg = 0; unsigned int startindex, stopindex; centerfrequency = bm_get_center(bandinx, trxmode); /* calc number of spots below your current QRG */ for (i = 0; i < spots->len; i++) { data = g_ptr_array_index( spots, i ); if (data->freq <= (centerfrequency*1000 - TOLERANCE)) below_qrg++; else break; } /* check if current QRG is on a spot */ if (below_qrg < spots->len) { data = g_ptr_array_index( spots, below_qrg ); if (!(data->freq > centerfrequency*1000 + TOLERANCE)) on_qrg = 1; } /* calc the index into the spot array of the first spot to show */ { unsigned int max_below; unsigned int above_qrg = spots->len - below_qrg - on_qrg; if (above_qrg < 14) { max_below = 30 - above_qrg - 1; } else max_below = 15; startindex = (below_qrg < max_below)? 0 : (below_qrg - max_below); } /* calculate the index+1 of the last spot to show */ stopindex = (spots->len < startindex + 30 - (1 - on_qrg)) ? spots->len : (startindex + 30 - (1 - on_qrg)); /* correct calculations if we have no rig frequency to show */ if (trx_control == 0) { if (on_qrg) { on_qrg = 0; } else { stopindex += 1; } if (spots->len < stopindex) stopindex = spots->len; } /* show spots below QRG */ for (i = startindex; i < below_qrg; i++) { move (bm_y, bm_x); show_spot(g_ptr_array_index( spots, i )); next_spot_position(&bm_y, &bm_x); } /* show highlighted frequency marker or spot on QRG if rig control * is active */ if (trx_control != 0) { move (bm_y, bm_x); attrset(COLOR_PAIR(C_HEADER) | A_STANDOUT); if (!on_qrg) { printw ("%7.1f %s", centerfrequency, "============"); } else { show_spot_on_qrg(g_ptr_array_index( spots, below_qrg )); } next_spot_position(&bm_y, &bm_x); } /* show spots above QRG */ for (i = below_qrg + on_qrg; i < stopindex; i++) { move (bm_y, bm_x); show_spot(g_ptr_array_index( spots, i )); next_spot_position(&bm_y, &bm_x); } attroff (A_BOLD); move(cury, curx); /* reset cursor */ refreshp(); }