id
int64
0
755k
file_name
stringlengths
3
109
file_path
stringlengths
13
185
content
stringlengths
31
9.38M
size
int64
31
9.38M
language
stringclasses
1 value
extension
stringclasses
11 values
total_lines
int64
1
340k
avg_line_length
float64
2.18
149k
max_line_length
int64
7
2.22M
alphanum_fraction
float64
0
1
repo_name
stringlengths
6
65
repo_stars
int64
100
47.3k
repo_forks
int64
0
12k
repo_open_issues
int64
0
3.4k
repo_license
stringclasses
9 values
repo_extraction_date
stringclasses
92 values
exact_duplicates_redpajama
bool
2 classes
near_duplicates_redpajama
bool
2 classes
exact_duplicates_githubcode
bool
2 classes
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
2 classes
near_duplicates_githubcode
bool
2 classes
near_duplicates_stackv1
bool
2 classes
near_duplicates_stackv2
bool
1 class
751,193
soundconf.cxx
w1hkj_fldigi/src/soundcard/soundconf.cxx
// ---------------------------------------------------------------------------- // soundconf.cxx // // Copyright (C) 2008-2010, Stelios Bounanos, M0GLD // Copyright (C) 2014 David Freese, W1HKJ // Copyright (C) 2015 Robert Stiles, KK5VD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #if USE_PORTAUDIO # include <map> # include <list> #endif #include <cstdlib> #include <cstring> #include <string> #if USE_OSS # include <glob.h> #endif #include "soundconf.h" #include "sound.h" #include "main.h" #include "configuration.h" #include "confdialog.h" #include "debug.h" #include "util.h" LOG_FILE_SOURCE(debug::LOG_AUDIO); double std_sample_rates[] = { 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0, 44100.0, 48000.0, 88200.0, 96000.0, 192000.0, -1.0 }; static void init_oss(void) { #if USE_OSS #ifdef __FreeBSD__ char *last = NULL; char *curr = NULL; char *p; #endif glob_t gbuf; glob("/dev/dsp*", 0, NULL, &gbuf); if (gbuf.gl_pathc == 0) { AudioOSS->deactivate(); btnAudioIO[SND_IDX_OSS]->deactivate(); menuOSSDev->deactivate(); return; } for (size_t i = 0; i < gbuf.gl_pathc; i++) { #ifdef __FreeBSD__ if (curr) free(curr); curr = strdup(gbuf.gl_pathv[i]); p = strrchr(curr, '.'); if (p) *p = '\0'; if (last != NULL) { if (strcmp(last, curr) == 0) continue; } menuOSSDev->add(curr); if (last) free(last); last = curr; curr = NULL; #else menuOSSDev->add(gbuf.gl_pathv[i]); #endif } #ifdef __FreeBSD__ if (last) free(last); if (curr) free(curr); #endif if (progdefaults.OSSdevice.length() == 0 && gbuf.gl_pathc) progdefaults.OSSdevice = gbuf.gl_pathv[0]; menuOSSDev->value(progdefaults.OSSdevice.c_str()); globfree(&gbuf); menuOSSDev->activate(); #endif // USE_OSS } #if USE_PORTAUDIO std::map<PaHostApiTypeId, unsigned> pa_api_prio; struct padev { public: padev(const PaDeviceInfo* dev_, PaDeviceIndex idx_, PaHostApiTypeId api_) : dev(dev_), idx(idx_), api(api_) { } bool operator<(const padev& rhs) const { return pa_api_prio.find(api) != pa_api_prio.end() && pa_api_prio.find(rhs.api) != pa_api_prio.end() && pa_api_prio[api] < pa_api_prio[rhs.api]; } const PaDeviceInfo* dev; PaDeviceIndex idx; PaHostApiTypeId api; }; static PaDeviceIndex get_default_portaudio_device(int dir) { #ifndef __linux__ goto ret_def; #else // Recent PortAudio snapshots prefer ALSA over OSS for the default device, but there are // still versions out there that try OSS first. We check the default host api type and, // if it is not ALSA, return the ALSA default device instead. PaHostApiIndex api_idx; if ((api_idx = Pa_GetDefaultHostApi()) < 0) goto ret_def; const PaHostApiInfo* host_api; if ((host_api = Pa_GetHostApiInfo(api_idx)) == NULL || host_api->type == paALSA) goto ret_def; LOG_DEBUG("Default host API is %s, trying default ALSA %s device instead", host_api->name, (dir == 0 ? "input" : "output")); api_idx = Pa_GetHostApiCount(); if (api_idx < 0) goto ret_def; for (PaHostApiIndex i = 0; i < api_idx; i++) if ((host_api = Pa_GetHostApiInfo(i)) && host_api->type == paALSA) return dir == 0 ? host_api->defaultInputDevice : host_api->defaultOutputDevice; #endif // __linux__ ret_def: return dir == 0 ? Pa_GetDefaultInputDevice() : Pa_GetDefaultOutputDevice(); } #include <cerrno> std::string str_pa_devices; static void init_portaudio(void) { try { SoundPort::initialize(); } catch (const SndException& e) { // if (e.error() == ENODEV) // don't complain if there are no devices // return; str_pa_devices.assign("\nPortaudio devices init failure:"); str_pa_devices.assign(e.what()); AudioPort->deactivate(); btnAudioIO[SND_IDX_PORT]->deactivate(); if (progdefaults.btnAudioIOis == SND_IDX_PORT) progdefaults.btnAudioIOis = SND_IDX_NULL; return; } pa_api_prio.clear(); #if defined(__APPLE__) pa_api_prio[paASIO] = 0; pa_api_prio[paCoreAudio] = 1; #elif defined(__WOE32__) pa_api_prio[paASIO] = 0; pa_api_prio[paWASAPI] = 1; pa_api_prio[paMME] = 2; pa_api_prio[paDirectSound] = 3; #else pa_api_prio[paALSA] = 0; pa_api_prio[paJACK] = 1; pa_api_prio[paOSS] = 2; #endif std::list<padev> devlist; int devnbr = 0; for (SoundPort::device_iterator idev = SoundPort::devices().begin(); idev != SoundPort::devices().end(); ++idev) { devlist.push_back( padev(*idev, idev - SoundPort::devices().begin(), Pa_GetHostApiInfo((*idev)->hostApi)->type) ); devnbr++; } devlist.sort(); str_pa_devices.assign("\nPortaudio devices:\n"); PaHostApiTypeId first_api = devlist.begin()->api; for (std::list<padev>::const_iterator ilist = devlist.begin(); ilist != devlist.end(); ilist++) { std::string menu_item; std::string::size_type i = 0; if (ilist->api != first_api) { // add a submenu menu_item.append(Pa_GetHostApiInfo(ilist->dev->hostApi)->name).append(" devices/"); i = menu_item.length(); } menu_item.append(ilist->dev->name); str_pa_devices.append(menu_item).append("\n"); // backslash-escape any slashes in the device name while ((i = menu_item.find('/', i)) != std::string::npos) { menu_item.insert(i, 1, '\\'); i += 2; } // add to menu if (ilist->dev->maxInputChannels > 0) menuPortInDev->add(menu_item.c_str(), 0, NULL, reinterpret_cast<void *>(ilist->idx), 0); if (ilist->dev->maxOutputChannels > 0) { menuPortOutDev->add(menu_item.c_str(), 0, NULL, reinterpret_cast<void *>(ilist->idx), 0); menuAlertsDev->add(menu_item.c_str(), 0, NULL, reinterpret_cast<void *>(ilist->idx), 0); } } if (progdefaults.PortInDevice.length() == 0) { if (progdefaults.PAdevice.length() == 0) { PaDeviceIndex def = get_default_portaudio_device(0); if (def != paNoDevice) { progdefaults.PortInDevice = (*(SoundPort::devices().begin() + def))->name; progdefaults.PortInIndex = def; } } else progdefaults.PortInDevice = progdefaults.PAdevice; } if (progdefaults.PortOutDevice.length() == 0) { if (progdefaults.PAdevice.length() == 0) { PaDeviceIndex def = get_default_portaudio_device(1); if (def != paNoDevice) { progdefaults.PortOutDevice = (*(SoundPort::devices().begin() + def))->name; progdefaults.PortOutIndex = def; } } else progdefaults.PortOutDevice = progdefaults.PAdevice; } if (progdefaults.AlertDevice.length() == 0) { PaDeviceIndex def = get_default_portaudio_device(1); if (def != paNoDevice) { progdefaults.AlertDevice = (*(SoundPort::devices().begin() + def))->name; progdefaults.AlertIndex = def; } } // select the correct menu items pa_set_dev(menuPortInDev, progdefaults.PortInDevice, progdefaults.PortInIndex); pa_set_dev(menuPortOutDev, progdefaults.PortOutDevice, progdefaults.PortOutIndex); pa_set_dev(menuAlertsDev, progdefaults.AlertDevice, progdefaults.AlertIndex); } int pa_set_dev(Fl_Choice *loc_choice, std::string loc_dev_name, int loc_dev_index) { const Fl_Menu_Item *loc_menu = (Fl_Menu_Item *)0; int loc_size = 0; int loc_dev_found = PA_DEV_NOT_FOUND; int loc_idx = -1; if(!loc_choice) return loc_dev_found; loc_menu = loc_choice->menu(); loc_size = loc_choice->size(); for (int loc_i = 0; loc_i < loc_size - 1; loc_i++, loc_menu++) { if (loc_menu->label() && loc_dev_name == loc_menu->label()) { loc_idx = loc_i; loc_dev_found = PA_DEV_FOUND; if (reinterpret_cast<intptr_t>(loc_menu->user_data()) == loc_dev_index || loc_dev_found == -1) { // exact match, or index was never saved loc_dev_found = PA_EXACT_DEV_FOUND; } } } if (loc_idx >= 0) { loc_choice->value(loc_idx); loc_choice->set_changed(); } return loc_dev_found; } #else static void init_portaudio(void) { } #endif // USE_PORTAUDIO static void build_srate_listbox(Fl_ListBox* lbox, const double* rates, size_t length, double defrate = -1.0) { lbox->clear(); lbox->add("Auto"); lbox->add("Native"); char s[16]; for (size_t i = 0; i < length; i++) { if (defrate != rates[i]) snprintf(s, sizeof(s), "%.0f", rates[i]); else snprintf(s, sizeof(s), "%.0f (native)", rates[i]); lbox->add(s); } } int sample_rate_converters[FLDIGI_NUM_SRC] = { SRC_SINC_BEST_QUALITY, SRC_SINC_MEDIUM_QUALITY, SRC_SINC_FASTEST #if !(defined(__ppc__) || defined(__powerpc__) || defined(__PPC__)) , SRC_LINEAR #endif }; static void sound_init_options(void) { build_srate_listbox(menuInSampleRate, std_sample_rates, sizeof(std_sample_rates)/sizeof(*std_sample_rates) - 1); build_srate_listbox(menuOutSampleRate, std_sample_rates, sizeof(std_sample_rates)/sizeof(*std_sample_rates) - 1); for (int i = 0; i < FLDIGI_NUM_SRC; i++) menuSampleConverter->add(src_get_name(sample_rate_converters[i])); // Warn if we are using ZOH if (progdefaults.sample_converter == SRC_ZERO_ORDER_HOLD) { progdefaults.sample_converter = SRC_LINEAR; LOG_WARN("The Zero Order Hold sample rate converter should not be used! " "Your setting has been changed to Linear."); } #if defined(__ppc__) || defined(__powerpc__) || defined(__PPC__) // SRC_LINEAR may crash with 11025Hz modems. Change to SINC_FASTEST. if (progdefaults.sample_converter == SRC_LINEAR) { progdefaults.sample_converter = SRC_SINC_FASTEST; LOG_WARN("Linear sample rate converter may not work on this architecture. " "Your setting has been changed to Fastest Sinc"); } #endif for (int i = 0; i < FLDIGI_NUM_SRC; i++) { if (sample_rate_converters[i] == progdefaults.sample_converter) { menuSampleConverter->index(i); menuSampleConverter->tooltip(src_get_description(progdefaults.sample_converter)); break; } } menuOSSDev->value(progdefaults.OSSdevice.c_str()); inpPulseServer->value(progdefaults.PulseServer.c_str()); char sr[20]; if (progdefaults.in_sample_rate == SAMPLE_RATE_UNSET && (progdefaults.in_sample_rate = progdefaults.sample_rate) == SAMPLE_RATE_UNSET) progdefaults.in_sample_rate = SAMPLE_RATE_NATIVE; else if (progdefaults.in_sample_rate < SAMPLE_RATE_OTHER) menuInSampleRate->index(progdefaults.in_sample_rate); else { snprintf(sr, sizeof(sr), "%d", progdefaults.in_sample_rate); for (int i = SAMPLE_RATE_NATIVE + 1; i < menuInSampleRate->lsize(); i++) { menuInSampleRate->index(i); if (strstr(menuInSampleRate->value(), sr)) break; } } if (progdefaults.out_sample_rate == SAMPLE_RATE_UNSET && (progdefaults.out_sample_rate = progdefaults.sample_rate) == SAMPLE_RATE_UNSET) progdefaults.out_sample_rate = SAMPLE_RATE_NATIVE; else if (progdefaults.out_sample_rate < SAMPLE_RATE_OTHER) menuOutSampleRate->index(progdefaults.out_sample_rate); else { snprintf(sr, sizeof(sr), "%d", progdefaults.out_sample_rate); for (int i = SAMPLE_RATE_NATIVE + 1; i < menuOutSampleRate->lsize(); i++) { menuOutSampleRate->index(i); if (strstr(menuOutSampleRate->value(), sr)) break; } } cntRxRateCorr->value(progdefaults.RX_corr); cntTxRateCorr->value(progdefaults.TX_corr); cntTxOffset->value(progdefaults.TxOffset); } #if USE_PULSEAUDIO # include <pulse/context.h> # include <pulse/mainloop.h> # include <pulse/version.h> # if PA_API_VERSION < 12 static inline int PA_CONTEXT_IS_GOOD(pa_context_state_t x) { return x == PA_CONTEXT_CONNECTING || x == PA_CONTEXT_AUTHORIZING || x == PA_CONTEXT_SETTING_NAME || x == PA_CONTEXT_READY; } # endif static bool probe_pulseaudio(void) { pa_mainloop* loop = pa_mainloop_new(); if (!loop) return false; bool ok = false; pa_context* context = pa_context_new(pa_mainloop_get_api(loop), PACKAGE_TARNAME); if (context && pa_context_connect(context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL) >= 0) { pa_context_state_t state; do { // iterate main loop until the context connection fails or becomes ready if (!(ok = (pa_mainloop_iterate(loop, 1, NULL) >= 0 && PA_CONTEXT_IS_GOOD(state = pa_context_get_state(context))))) break; } while (state != PA_CONTEXT_READY); } if (context) { pa_context_disconnect(context); pa_context_unref(context); } pa_mainloop_free(loop); return ok; } #else static bool probe_pulseaudio(void) { return false; } #endif // USE_PULSEAUDIO void sound_init(void) { init_oss(); init_portaudio(); // set the Sound Card configuration tab to the correct initial values #if !USE_OSS AudioOSS->deactivate(); btnAudioIO[SND_IDX_OSS]->deactivate(); #endif #if !USE_PORTAUDIO AudioPort->deactivate(); btnAudioIO[SND_IDX_PORT]->deactivate(); #endif #if !USE_PULSEAUDIO AudioPulse->deactivate(); btnAudioIO[SND_IDX_PULSE]->deactivate(); inpPulseServer->deactivate(); #endif if (progdefaults.btnAudioIOis == SND_IDX_UNKNOWN || !btnAudioIO[progdefaults.btnAudioIOis]->active()) { // or saved sound api now disabled int io[4] = { SND_IDX_PORT, SND_IDX_PULSE, SND_IDX_OSS, SND_IDX_NULL }; if (probe_pulseaudio()) { // prefer pulseaudio io[0] = SND_IDX_PULSE; io[1] = SND_IDX_PORT; } for (size_t i = 0; i < sizeof(io)/sizeof(*io); i++) { if (btnAudioIO[io[i]]->active()) { progdefaults.btnAudioIOis = io[i]; break; } } } sound_init_options(); sound_update(progdefaults.btnAudioIOis); } void sound_close(void) { #if USE_PORTAUDIO SoundPort::terminate(); #endif } void sound_update(unsigned idx) { // radio button for (size_t i = 0; i < sizeof(btnAudioIO)/sizeof(*btnAudioIO); i++) btnAudioIO[i]->value(i == idx); // devices menuOSSDev->deactivate(); menuPortInDev->deactivate(); menuPortOutDev->deactivate(); // settings menuInSampleRate->deactivate(); menuOutSampleRate->deactivate(); progdefaults.btnAudioIOis = idx; switch (idx) { #if USE_OSS case SND_IDX_OSS: scDevice[0] = scDevice[1] = menuOSSDev->value(); menuOSSDev->activate(); break; #endif #if USE_PORTAUDIO case SND_IDX_PORT: menuPortInDev->activate(); menuPortOutDev->activate(); if (menuPortInDev->text()) scDevice[0] = menuPortInDev->text(); if (menuPortOutDev->text()) scDevice[1] = menuPortOutDev->text(); { Fl_ListBox* listbox[2] = { menuInSampleRate, menuOutSampleRate }; for (size_t i = 0; i < 2; i++) { char* label = strdup(listbox[i]->value()); const std::vector<double>& srates = SoundPort::get_supported_rates(scDevice[i], i); switch (srates.size()) { case 0: // startup; no devices initialised yet build_srate_listbox(listbox[i], std_sample_rates, sizeof(std_sample_rates)/sizeof(*std_sample_rates) - 1); break; case 1: // default sample rate only, build menu with all std rates build_srate_listbox(listbox[i], std_sample_rates, sizeof(std_sample_rates)/sizeof(*std_sample_rates) - 1, srates[0]); break; default: // first element is default sample rate, build menu with rest build_srate_listbox(listbox[i], &srates[0] + 1, srates.size() - 1, srates[0]); break; } for (int j = 0; j < listbox[i]->lsize(); j++) { listbox[i]->index(j); if (strstr(listbox[i]->value(), label)) break; } free(label); listbox[i]->activate(); } } break; #endif #if USE_PULSEAUDIO case SND_IDX_PULSE: scDevice[0] = scDevice[1] = inpPulseServer->value(); break; #endif case SND_IDX_NULL: scDevice[0] = scDevice[1] = ""; break; }; }
15,896
C++
.cxx
494
29.45749
108
0.683737
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,194
navtex.cxx
w1hkj_fldigi/src/navtex/navtex.cxx
// --------------------------------------------------------------------- // // navtex.cxx // // Copyright (C) 2011-2016 // Remi Chateauneu, F4ECW // Rik van Riel, AB1KW, <riel@surriel.com> // // This file is part of fldigi. Adapted from code contained in JNX // source code distribution. // JNX Copyright (C) Paul Lutus // http://www.arachnoid.com/JNX/index.html // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Sync using multicorrelator, instead of null crossings // Rik van Riel, AB1KW, <riel@surriel.com> // // Null crossings are somewhat noisy, and the code to keep the navtex // decoder in sync with the incoming signal using null crossings was // rather fragile. // // Use a multicorrelator instead, which relies on the averaged magnitude // of the signal accumulator to sync the decoder with the incoming signal. // // When debugging the code, the multicorrelator mostly corrects the // modem forward in time, which can be explained by the fact that a // bit takes 110.25 samples, while the code uses 110. When the NAVTEX // transmitter is running at exactly 100 baud, one can expect to see // the decoder get adjusted 25 times a second, to make up for the // difference between 11000 and 11025. // // When multiple signals are on the air simultaneously, the null crossing // code would often lose track of the signal. The multicorrelator seems // to be more stable in this situation, though of course when both signals // are close in strength things do not get decoded right. // // The signal sampling spread of 1/6 of the width of a bit was set through // trial and error. A larger spread increases the signal difference between // early, prompt, and late samples, but reduces the accumulator value seen // by the demodulator. A smaller spread increases the accumulator value seen, // but makes it harder to lock on in noisy conditions. // --------------------------------------------------------------------- // --------------------------------------------------------------------- // low pass mark & space individually // Rik van Riel, AB1KW, <riel@surriel.com> // // Putting individual low pass filters on mark and space seems to // result in an improved ability to overcome pulse noise, and decode // weaker navtex signals. // // I have not found any signal where the performance of the codec // got worse with this change. // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Correct display metric // Rik van Riel, AB1KW, <riel@surriel.com> // // The NAVTEX display_metric() function was buggy, in that decayavg // returns the decayed value, but does not store it. It always put // the current value in the metric, and kept avg_ratio at 0.0. // // This resulted in a somewhat chaotic, and not very useful metric // display. Copy over the S/N calculation from the RTTY code, because // that code seems to work well. // Also print the S/N in Status2, like the RTTY code and other modes // do. // Copying over the RTTY S/N code wholesale might still not be // enough, since the NAVTEX wave form appears to be somewhat // different from RTTY. However, at least we have something // now, and the metric used for squelch seems to work again. // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Correct display metric // Rik van Riel, AB1KW, <riel@surriel.com> // // Widen afc filter for 'jump 90 Hz' code // // When the NAVTEX code spots a power imbalance of more than a factor // 5 between mark and space, it will shift the frequency by 90 Hz. // This is reported to help with some signals. // // However, it breaks with some other signals, which have a different // spectral distribution between mark and space, with a spectrum looking // something like this: // // * // * // * // ** // ****** *** // ******** ****** // ********** ******** // ******************************************** // ********************************************** // // In this spectrum, mark & space have a similar amount of energy, // but that is only apparent when the comparison between them is // done on a wider sample than 10 Hz. // // Sampling 30 Hz instead seems to result in a more stable AFC. // --------------------------------------------------------------------- // --------------------------------------------------------------------- // use exact bit length // Rik van Riel, AB1KW, <riel@surriel.com> // // With a baud rate of 100 and a sample rate of 11025, the number // of bits per sample is 110.25. Approximating this with 110 bits // per sample results in the decoder continuously chasing after the // signal, and losing it more easily during transient noise or // interference events. // // Simply changing the variable type from int to double makes life // a little easier on the bit tracking code. // // The accumulator does not seem to care that it gets an extra sample // every 4 bit periods. // --------------------------------------------------------------------- // --------------------------------------------------------------------- // improvements to the multi correlator // Rik van Riel, AB1KW, <riel@surriel.com> // // While the multi correlator for bit sync was a nice improvement over // the null crossing tracking, it did lose sync too easily in the presence // of transient noise or interference, and was full of magic adjustments. // // Replace the magic adjustments with a calculation, which makes the multi // correlator able to ride out transient noise or interference, and then // make a larger adjustment all at once (if needed). // --------------------------------------------------------------------- // --------------------------------------------------------------------- // use same mark/space detector as RTTY modem // Rik van Riel, AB1KW, <riel@surriel.com> // // Switch the NAVTEX modem over to the same mark/spac decoder, with W7AY's // automatic threshold correction algorithm, like the RTTY modem uses. // // The noise subtraction is a little different than in the RTTY modem; // the algorithm used in W7AY's code seems to work a little better with // the noise present at 518 kHz, when compared to the algorithm used in // the RTTY modem. // // I have compared this detector to a correlation detector; the latter // appears to be a little more sensitive, which includes higher // sensitivity to noise. With a 250 Hz filter on the radio, the // correlation detector might be a little bit better, while with the // filter on the radio opened up to 4kHz wide, this detector appears // to be more robust. // // On signals with a large mark/space power imbalance, or where the power // distribution in one of the two throws off the automatic frequency // correction, this decoder is able to handle signals that neither of // the alternatives tested does. // --------------------------------------------------------------------- #include <math.h> #include <stdlib.h> #include <stdio.h> #include <ctype.h> #include <memory.h> #include <assert.h> #include <list> #include <vector> #include <string> #include <queue> #include <deque> #include <map> #include <iostream> #include <sstream> #include <fstream> #include <stdexcept> #include "config.h" #include "configuration.h" #include "fl_digi.h" #include "debug.h" #include "gettext.h" #include "navtex.h" #include "logbook.h" #include "coordinate.h" #include "misc.h" #include "status.h" #include "strutil.h" #include "kmlserver.h" #include "record_loader.h" #include "fftfilt.h" #include "strutil.h" #include "FL/fl_ask.H" pthread_mutex_t navtex_filter_mutex = PTHREAD_MUTEX_INITIALIZER; /// This models a line of the file defining Navtex stations. class NavtexRecord { std::string m_country ; std::string m_country_code ; double m_frequency ; char m_origin ; std::string m_callsign ; std::string m_name ; CoordinateT::Pair m_coordinates ; std::string m_locator ; /// Reads a CSV file. static const char m_delim = ';'; public: NavtexRecord() : m_frequency(0.0) , m_origin('?') , m_name( _("Unknown station") ) {} char origin(void) const { return m_origin; }; const CoordinateT::Pair & coordinates() const { return m_coordinates; } double frequency(void) const { return m_frequency; }; const std::string & country() const { return m_country; } const std::string & name() const { return m_name; } const std::string & callsign() const { return m_callsign; } /// Example: Azores;AZR;490.0;J;CTH;Horta;38 32 N;28 38 W;II;PP friend std::istream & operator>>( std::istream & istrm, NavtexRecord & rec ) { std::string input_str ; if( ! std::getline( istrm, input_str ) ) return istrm ; std::stringstream str_strm( input_str ); if( read_until_delim( m_delim, str_strm, rec.m_country ) && read_until_delim( m_delim, str_strm /* Country code */ ) && read_until_delim( m_delim, str_strm, rec.m_frequency ) && read_until_delim( m_delim, str_strm, rec.m_origin ) && read_until_delim( m_delim, str_strm, rec.m_callsign ) && read_until_delim( m_delim, str_strm, rec.m_name ) && read_until_delim( m_delim, str_strm, rec.m_coordinates.latitude() ) && read_until_delim( m_delim, str_strm, rec.m_coordinates.longitude() ) && read_until_delim( m_delim, str_strm /* Zone */ ) && read_until_delim( m_delim, str_strm /* Language */ ) && ( rec.m_coordinates.latitude().is_lon() == false ) && ( rec.m_coordinates.longitude().is_lon() == true ) ) { return istrm ; } istrm.setstate(std::ios::eofbit); return istrm ; } }; /// Navtex catalog of stations is used when logging to ADIF file: It gives the station name, callsign etc... class NavtexCatalog : public RecordLoader< NavtexCatalog > { // TODO: Consider a multimap<char, NavtexRecord> typedef std::deque< NavtexRecord > CatalogType ; CatalogType m_catalog ; /// Frequency more or less 1 %: 485-494 kHz, 512-523 kHz etc... static bool freq_close( double freqA, double freqB ) { static const double freq_ratio = 1.01 ; return ( freqA < freqB * freq_ratio ) || ( freqA * freq_ratio > freqB ); } /// Tells if this is a reasonable Navtex frequency. static bool freq_acceptable( double freq ) { return freq_close( freq, 490.0 ) || freq_close( freq, 518.0 ) || freq_close( freq, 4209.5 ); } void Clear() { m_catalog.clear(); } bool ReadRecord( std::istream & istrm ) { NavtexRecord tmp ; istrm >> tmp ; if( istrm || istrm.eof() ) { m_catalog.push_back( tmp ); return true ; } return false ; } /// Minimal edit distance (Levenshtein) between the pattern and any token of the string. static double DistToStationName( const std::string & msg, const std::string & pattern ) { std::stringstream strm( msg ); /// Any big number is OK, if bigger than any string length. double currDist = 1.7976931348623157e+308; // DBL_MAX ; typedef std::istream_iterator<std::string> StrmIterStr ; for( StrmIterStr itStrm( strm ); itStrm != StrmIterStr(); ++itStrm ) { const std::string tmp = *itStrm ; currDist = std::min( currDist, (double)levenshtein( tmp, pattern ) ); } return currDist ; } public: std::string base_filename() const { return "NAVTEX_Stations.csv"; } const char * Description() const { return _("Navtex stations"); } /// Usual frequencies are 490, 518 or 4209 kiloHertz. const NavtexRecord * FindStation( long long freq_ll, char origin, const std::string & maidenhead, const std::string & msg) { if( maidenhead.empty() ) return NULL; if( m_catalog.empty() ) { int nbRecs = LoadAndRegister(); static bool error_signaled = false ; if( nbRecs <= 0 ) { LOG_WARN("Error reading Navtex stations file"); if(error_signaled == false) { fl_alert("Cannot read Navtex file %s", storage_filename().first.c_str() ); error_signaled = true ; return NULL; } } error_signaled = false ; } const CoordinateT::Pair coo( maidenhead ); /// Possible Navtex stations stored by closer first. typedef std::multimap< double, CatalogType::const_iterator > SolutionType ; SolutionType solDistKm; double freq = freq_ll / 1000.0 ; // As kiloHertz in the data file. bool okFreq = freq_acceptable( freq ); //LOG_INFO("Operator Maidenhead=%s lon=%lf lat=%lf okFreq=%d Origin=%c", // maidenhead.c_str(), coo.longitude().angle(), coo.latitude().angle(), okFreq, origin ); for( CatalogType::const_iterator it = m_catalog.begin(), en = m_catalog.end(); it != en ; ++it ) { /// The origin letters must be identical. if( origin != it->origin() ) continue ; /// The two frequencies must be close more or less 10%. bool freqClose = freq_close( freq, it->frequency() ); if( okFreq && ! freqClose ) continue ; /// Solutions are stored smallest distance first. double dist = coo.distance( it->coordinates() ); solDistKm.insert( SolutionType::value_type( dist, it ) ); } /// No station found. if( solDistKm.empty() ) return NULL; /// Only one station, no ambiguity. SolutionType::iterator begSolKm = solDistKm.begin(); if( solDistKm.size() == 1 ) return & ( *begSolKm->second ); SolutionType solStrDist ; // Maybe some station names appear but not others. This can be for example "Maltaradio", "Cullercoat", "Limnos" etc... for( SolutionType::iterator itSolKm = begSolKm, endSolKm = solDistKm.end(); itSolKm != endSolKm; ++itSolKm ) { std::stringstream strm ; strm << itSolKm->second->coordinates(); // LOG_INFO("Name=%s Dist=%lf %s", itSolKm->second->name().c_str(), itSolKm->first, strm.str().c_str() ); // The message is in uppercase anyway, so no need to convert. double str_dist = DistToStationName( msg, ucasestr( itSolKm->second->name() ) ); solStrDist.insert( SolutionType::value_type( str_dist, itSolKm->second ) ); } // There are at least two elements, so we can do this. SolutionType::iterator begSolStr = solStrDist.begin(); SolutionType::iterator nxtSolStr = begSolStr; ++nxtSolStr ; // The first message only contains a string very similar to a radio station. if( (begSolStr->first < 2) && ( nxtSolStr->first > 2 ) ) { //LOG_INFO("Levenshtein beg=%lf beg_name=%s next=%lf next_name=%s", // begSolStr->first, begSolStr->second->name().c_str(), // nxtSolStr->first, nxtSolStr->second->name().c_str() ); return & (*begSolStr->second) ; } // There are at least two elements, and more than one station name, or none of them, // is contained in the message. // Just returns the closest element. return & ( *begSolKm->second ); // Now we could search for a coordinate in the message, and we will keep the station which is the closest // to this coordinate. We wish to do that anyway in order to map things in KML. // Possible formats are -(This is experimental): // 67-04.0N 032-25.7E // 47-29'30N 003-16'00W // 6930.1N 01729.9E // 48-21'45N 004-31'45W // 58-37N 003-32W // 314408N 341742E // 42-42N 005-10E // 54-02.3N 004-45.8E // 55-20.76N 014-45.27E // 55-31.1 N 012-44.7 E // 5330.4N 01051.5W // 43 45.0 N - 015 44.8 E // 34-33.7N 012-28.7E // 51 10.55 N - 001 51.02 E // 51.21.67N 002.13.29E // 73 NORTH 14 EAST // 58-01.20N 005-27.08W // 50.56N 007.00,5W // 5630,1N- 00501,6E // LAT. 41.06N - LONG 012.57E // 42 40 01 N - 018 05 10 E // 40 25 31N - 18 15 30E // 40-32.2N 000-33.5E // 58-01.2 NORTH 005-27.1 WEST // 39-07,7N 026-39,2E // // ESTIMATED LIMIT OF ALL KNOWN ICE: // 4649N 5411W TO 4530N 5400W TO // 4400N 4900W TO 4545N 4530W TO // 4715N 4530W TO 5000N 4715W TO // 5530N 5115W TO 5700N 5545W. // } }; // NavtexCatalog static const unsigned char code_to_ltrs[128] = { //0 1 2 3 4 5 6 7 8 9 a b c d e f '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', // 0 '_', '_', '_', '_', '_', '_', '_', 'J', '_', '_', '_', 'F', '_', 'C', 'K', '_', // 1 '_', '_', '_', '_', '_', '_', '_', 'W', '_', '_', '_', 'Y', '_', 'P', 'Q', '_', // 2 '_', '_', '_', '_', '_', 'G', '_', '_', '_', 'M', 'X', '_', 'V', '_', '_', '_', // 3 '_', '_', '_', '_', '_', '_', '_', 'A', '_', '_', '_', 'S', '_', 'I', 'U', '_', // 4 '_', '_', '_', 'D', '_', 'R', 'E', '_', '_', 'N', '_', '_', ' ', '_', '_', '_', // 5 '_', '_', '_', 'Z', '_', 'L', '_', '_', '_', 'H', '_', '_', '\n', '_', '_', '_', // 6 '_', 'O', 'B', '_', 'T', '_', '_', '_', '\r', '_', '_', '_', '_', '_', '_', '_' // 7 }; static const unsigned char code_to_figs[128] = { //0 1 2 3 4 5 6 7 8 9 a b c d e f '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', // 0 '_', '_', '_', '_', '_', '_', '_', '\'', '_', '_', '_', '!', '_', ':', '(', '_', // 1 '_', '_', '_', '_', '_', '_', '_', '2', '_', '_', '_', '6', '_', '0', '1', '_', // 2 '_', '_', '_', '_', '_', '&', '_', '_', '_', '.', '/', '_', ';', '_', '_', '_', // 3 '_', '_', '_', '_', '_', '_', '_', '-', '_', '_', '_', '\07', '_', '8', '7', '_', // 4 '_', '_', '_', '$', '_', '4', '3', '_', '_', ',', '_', '_', ' ', '_', '_', '_', // 5 '_', '_', '_', '"', '_', ')', '_', '_', '_', '#', '_', '_', '\n', '_', '_', '_', // 6 '_', '9', '?', '_', '5', '_', '_', '_', '\r', '_', '_', '_', '_', '_', '_', '_' // 7 }; static const int code_ltrs = 0x5a; static const int code_figs = 0x36; static const int code_alpha = 0x0f; static const int code_beta = 0x33; static const int code_char32 = 0x6a; static const int code_rep = 0x66; static const int char_bell = 0x07; class CCIR476 { unsigned char m_ltrs_to_code[128]; unsigned char m_figs_to_code[128]; bool m_valid_codes[128]; public: CCIR476() { memset( m_ltrs_to_code, 0, 128 ); memset( m_figs_to_code, 0, 128 ); for( size_t i = 0; i < 128; ++i ) m_valid_codes[i] = false ; for (int code = 0; code < 128; code++) { // Valid codes have four bits set only. This leaves three bits for error detection. // TODO: If a code is invalid, we could take the closest value in terms of bits. if (check_bits(code)) { m_valid_codes[code] = true; unsigned char figv = code_to_figs[code]; unsigned char ltrv = code_to_ltrs[code]; if ( figv != '_') { m_figs_to_code[figv] = code; } if ( ltrv != '_') { m_ltrs_to_code[ltrv] = code; } } } } void char_to_code(std::string & str, int ch, bool & ex_shift) const { ch = toupper(ch); // avoid unnecessary shifts if (ex_shift && m_figs_to_code[ch] != '\0') { str.push_back( m_figs_to_code[ch] ); } else if (!ex_shift && m_ltrs_to_code[ch] != '\0') { str.push_back( m_ltrs_to_code[ch] ); } else if (m_figs_to_code[ch] != '\0') { ex_shift = true; str.push_back( code_figs ); str.push_back( m_figs_to_code[ch] ); } else if (m_ltrs_to_code[ch] != '\0') { ex_shift = false; str.push_back( code_ltrs ); str.push_back( m_ltrs_to_code[ch] ); } } int code_to_char(int code, bool shift) const { const unsigned char * target = (shift) ? code_to_figs : code_to_ltrs; if (target[code] != '_') { return target[code]; } // default: return negated code return -code; } int bytes_to_code(int *pos) { int code = 0; int i; for (i = 0; i < 7; i++) code |= ((pos[i] > 0) << i); return code; } int bytes_to_char(int *pos, int shift) { int code = bytes_to_code(pos); return code_to_char(code, shift); } // http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetNaive /// Counting set bits, Brian Kernighan's way static bool check_bits(int v) { int bc = 0; while (v != 0) { bc++; v &= v - 1; } //printf("check_bits %d %d %c\n", bc, (int)code_to_ltrs[v], code_to_ltrs[v] ); return bc == 4; } // Is there a valid character in the next 7 ints? bool valid_char_at(int *pos) { int count = 0; int i; for (i = 0; i < 7; i++) if (pos[i] > 0) count++; return (count == 4); } }; /// This is temporary, to manipulate a multi-line string. static const char * new_line = "\n"; // Coordinates samples: // 52-08.5N 003-18.0E // 51-03.93N 001-09.17E // 50-40.2N 001-03.7W class ccir_message : public std::string { static const size_t header_len = 10 ; static const size_t trunc_len = 5 ; // Header structure is: // ZCZCabcd message text NNNN // a : Origin of the station. // b : Message type. // cd : Message number from this station. char m_origin ; char m_subject ; int m_number ; public: const char * msg_type(void) const { switch(m_subject) { case 'A' : return _("Navigational warning"); case 'B' : return _("Meteorological warning"); case 'C' : return _("Ice report"); case 'D' : return _("Search & rescue information, pirate warnings"); case 'E' : return _("Meteorological forecast"); case 'F' : return _("Pilot service message"); case 'G' : return _("AIS message"); case 'H' : return _("LORAN message"); case 'I' : return _("Not used"); case 'J' : return _("SATNAV messages"); case 'K' : return _("Other electronic navaid messages"); case 'L' : return _("Navigational warnings"); case 'T' : return _("Test transmissions (UK only)"); case 'V' : return _("Notice to fishermen (U.S. only)"); case 'W' : return _("Environmental (U.S. only)"); case 'X' : return _("Special services - allocation by IMO NAVTEX Panel"); case 'Y' : return _("Special services - allocation by IMO NAVTEX Panel"); case 'Z' : return _("No message on hand"); default : return _("Invalid navtex subject"); } } private: /// Remove non-Ascii chars, replace new-line by special character etc.... void cleanup() { /// It would be possible to do the change in place, because the new string /// it shorter than the current one, but at the expense of clarity. bool wasDelim = false, wasSpace = false, chrSeen = false ; std::string newStr ; for( iterator it = begin(); it != end(); ++it ) { switch( *it ) { case '\n': case '\r': wasDelim = true ; break ; case ' ' : case '\t': wasSpace = true ; break ; default : if( chrSeen ) { if( wasDelim ) { newStr.append(new_line); } else if( wasSpace ) { newStr.push_back(' '); } } wasDelim = false ; wasSpace = false ; chrSeen = true ; newStr.push_back( *it ); } } swap( newStr ); } void init_members() { m_origin = '?'; m_subject = '?'; m_number = 0 ; } public: ccir_message() { init_members(); } ccir_message( const std::string & s, char origin, char subject, int number ) : std::string(s) , m_origin(origin) , m_subject(subject) , m_number(number) { cleanup(); } void reset_msg() { clear(); init_members(); } typedef std::pair<bool, ccir_message> detect_result ; detect_result detect_header() { size_t qlen = size(); if (qlen >= header_len) { const char * comp = & (*this)[ qlen - header_len ]; if( (comp[0] == 'Z') && (comp[1] == 'C') && (comp[2] == 'Z') && (comp[3] == 'C') && (comp[4] == ' ') && isalnum(comp[5]) && isalnum(comp[6]) && isdigit(comp[7]) && isdigit(comp[8]) && // (comp[9] == '\r') ) (strchr( "\n\r", comp[9] ) ) ) { /// This returns the garbage before the valid header. // Garbage because the trailer could not be read, but maybe header OK. ccir_message msg_cut( substr( 0, size() - header_len ), m_origin, m_subject, m_number ); m_origin = comp[5]; m_subject = comp[6]; m_number = ( comp[7] - '0' ) * 10 + ( comp[8] - '0' ); // Remove the beginning useless chars. /// TODO: Read broken headers such as "ZCZC EA0?" clear(); return detect_result( true, msg_cut ); } } return detect_result( false, ccir_message() ); ; } bool detect_end() { // Should be "\r\nNNNN\r\n" theoretically, but tolerates shorter strings. static const size_t slen = 4 ; static const char stop_valid[slen + 1] = "NNNN"; size_t qlen = size(); if (qlen < slen) { return false; } std::string comp = substr(qlen - slen, slen); bool end_seen = comp == stop_valid; if( end_seen ) { erase( qlen - slen, slen ); LOG_INFO("\n%s", c_str()); } return end_seen ; } void display( const std::string & alt_string ) { std::string::operator=( alt_string ); cleanup(); long long currFreq = wf->rfcarrier(); if( ! progdefaults.NVTX_AdifLog && ! progdefaults.NVTX_KmlLog ) { return ; } const NavtexRecord * ptrNavRec = NavtexCatalog::InstCatalog().FindStation(currFreq, m_origin, progdefaults.myLocator, *this ); if( ptrNavRec != NULL ) { LOG_INFO("Locator=%s Origin=%c freq=%d name=%s lon=%lf lat=%lf", progdefaults.myLocator.c_str(), m_origin, static_cast<int>(currFreq), ptrNavRec->name().c_str(), ptrNavRec->coordinates().longitude().angle(), ptrNavRec->coordinates().latitude().angle() ); } else { LOG_INFO("Locator=%s Origin=%c freq=%d Navtex station not found", progdefaults.myLocator.c_str(), m_origin, static_cast<int>(currFreq) ); } if( progdefaults.NVTX_AdifLog ) { /// For updating the logbook with received messages. QsoHelper qso(MODE_NAVTEX); if( ptrNavRec ) { qso.Push(QTH, ptrNavRec->country() ); qso.Push(CALL, ptrNavRec->callsign() ); qso.Push(COUNTRY, ptrNavRec->country() ); qso.Push(GRIDSQUARE, ptrNavRec->coordinates().locator() ); qso.Push(NAME, ptrNavRec->name() ); /// If the header is clean, the message type is removed from the string. // In this context, this field cannot be used. qso.Push(XCHG1, msg_type() ); qso.Push(SRX, strformat( "%d", m_number ) ); } else { qso.Push(NAME, std::string("Station_") + m_origin ); } // Sequence of Chars and line-breaks, ASCII CR (code 13) + ASCII LF (code 10) qso.Push(NOTES, strreplace( *this, new_line, ADIF_EOL ) ); } // Adds a placemark to the navtex KML file. if( progdefaults.NVTX_KmlLog ) { if( ptrNavRec ) { KmlServer::CustomDataT custData ; custData.Push( "Callsign", ptrNavRec->callsign() ); custData.Push( "Country", ptrNavRec->country() ); custData.Push( "Locator", ptrNavRec->coordinates().locator() ); custData.Push( "Message number", m_number ); custData.Push( "Frequency", currFreq ); custData.Push( "Mode", mode_info[MODE_NAVTEX].adif_name ); custData.Push( "Message", *this ); KmlServer::GetInstance()->Broadcast( "Navtex", 0, ptrNavRec->coordinates(), 0, ptrNavRec->name(), "navtex_station", substr( 0, 20 ) + "...", custData ); } // TODO: Parse the message to extract coordinates. } } // display }; // ccir_message static const int deviation_f = 85; static const double dflt_center_freq = 1000.0 ; class navtex ; /// Implements PIMPL idiom. class navtex_implementation { enum State { SYNC_SETUP, SYNC, READ_DATA }; static const char * state_to_str( State s ) { switch( s ) { case SYNC_SETUP: return "SYNC_SETUP"; case SYNC : return "SYNC"; case READ_DATA : return "READ_DATA"; default : return "Unknown" ; } } bool m_only_sitor_b ; int m_message_counter ; static const size_t m_tx_block_len = 1024 ; /// Between -1 and 1. double m_tx_buf[m_tx_block_len]; size_t m_tx_counter ; navtex * m_ptr_navtex ; pthread_mutex_t m_mutex_tx ; typedef std::list<std::string> TxMsgQueueT ; TxMsgQueueT m_tx_msg_queue ; double m_metric ; CCIR476 m_ccir476; typedef std::list<int> sync_chrs_type ; ccir_message m_curr_msg ; double m_message_time ; double m_early_accumulator ; double m_prompt_accumulator ; double m_late_accumulator ; double m_mark_f, m_space_f; double m_time_sec; double m_baud_rate ; int m_sample_rate ; int m_averaged_mark_state; int m_bit_duration ; fftfilt *m_mark_lowpass; fftfilt *m_space_lowpass; double m_mark_phase; double m_space_phase; double m_bit_sample_count; State m_state; int m_sample_count; double m_next_early_event; double m_next_prompt_event; double m_next_late_event; double m_average_early_signal; double m_average_prompt_signal; double m_average_late_signal; std::vector<int> m_bit_values; int m_bit_cursor; bool m_shift ; bool m_pulse_edge_event; int m_error_count; bool m_alpha_phase ; bool m_header_found ; char snrmsg[80]; // filter method related double m_center_frequency_f ; navtex_implementation( const navtex_implementation & ); navtex_implementation(); navtex_implementation & operator=( const navtex_implementation & ); public: navtex_implementation(int the_sample_rate, bool only_sitor_b, navtex * ptr_navtex ) { pthread_mutex_init( &m_mutex_tx, NULL ); m_ptr_navtex = ptr_navtex ; m_only_sitor_b = only_sitor_b ; m_message_counter = 1 ; m_metric = 0.0 ; m_time_sec = 0.0 ; m_state = SYNC_SETUP; m_message_time = 0.0 ; m_early_accumulator = 0; m_prompt_accumulator = 0; m_late_accumulator = 0; m_sample_rate = the_sample_rate; m_bit_duration = 0; m_shift = false; m_alpha_phase = false; m_header_found = false; m_center_frequency_f = dflt_center_freq; // this value must never be zero and bigger than 10. m_baud_rate = 100; double m_bit_duration_seconds = 1.0 / m_baud_rate; m_bit_sample_count = m_sample_rate * m_bit_duration_seconds; // A narrower spread between signals allows the modem to // center on the pulses better, but a wider spread makes // more robust under noisy conditions. 1/5 seems to work. m_next_early_event = 0; m_next_prompt_event = m_bit_sample_count / 5; m_next_late_event = m_bit_sample_count * 2 / 5; m_average_early_signal = 0; m_average_prompt_signal = 0; m_average_late_signal = 0; m_error_count = 0; m_sample_count = 0; // keep 1 second worth of bit values for decoding m_bit_values.resize(m_baud_rate); m_bit_cursor = 0; m_mark_lowpass = 0; m_space_lowpass = 0; set_filter_values(); configure_filters(); } ~navtex_implementation() { pthread_mutex_destroy( &m_mutex_tx ); } private: void set_filter_values() { m_mark_f = m_center_frequency_f + deviation_f; m_space_f = m_center_frequency_f - deviation_f; m_mark_phase = 0; m_space_phase = 0; } void configure_filters() { // do not allow filters to be changed during signal processing! guard_lock filter_guard(&navtex_filter_mutex); const int filtlen = 512; if (m_mark_lowpass) delete m_mark_lowpass; m_mark_lowpass = new fftfilt(m_baud_rate/m_sample_rate, filtlen); m_mark_lowpass->rtty_filter(m_baud_rate/m_sample_rate); if (m_space_lowpass) delete m_space_lowpass; m_space_lowpass = new fftfilt(m_baud_rate/m_sample_rate, filtlen); m_space_lowpass->rtty_filter(m_baud_rate/m_sample_rate); } void set_state(State s) { if (s != m_state) { m_state = s; set_label_from_state(); } } /// The parameter is appended at the message end. void flush_message(const std::string & extra_info) { if( m_header_found ) { m_header_found = false; display_message( m_curr_msg, m_curr_msg + extra_info ); } else { display_message( m_curr_msg, "[Lost header]:" + m_curr_msg + extra_info ); } m_curr_msg.reset_msg(); m_message_time = m_time_sec; } /// Checks that we have no waited too long, and if so, flushes the message with a specific terminator. void process_timeout() { /// No messaging in SitorB if ( m_only_sitor_b ) { return ; } bool timeOut = m_time_sec - m_message_time > 600 ; if ( ! timeOut ) return ; LOG_INFO("Timeout: time_sec=%lf, message_time=%lf", m_time_sec, m_message_time ); // TODO: Headerless messages could be dropped if shorter than X chars. flush_message(":<TIMEOUT>"); } void process_messages(int c) { m_curr_msg.push_back((char) c); /// No header nor trailer for plain SitorB. if ( m_only_sitor_b ) { m_header_found = true; m_message_time = m_time_sec; return; } ccir_message::detect_result msg_cut = m_curr_msg.detect_header(); if ( msg_cut.first ) { /// Maybe the message was already valid. if( m_header_found ) { display_message( msg_cut.second, msg_cut.second + ":[Lost trailer]" ); } else { /// Maybe only non-significant chars. if( ! msg_cut.second.empty() ) { display_message( msg_cut.second, "[Lost header]:" + msg_cut.second + ":[Lost trailer]" ); } } m_header_found = true; m_message_time = m_time_sec; } else { // valid message state if ( m_curr_msg.detect_end() ) { flush_message(""); } } } // The rep character is transmitted 5 characters (35 bits) ahead of // the alpha character. int fec_offset(int offset) { return offset - 35; } // Flip the sign of the smallest (least certain) bit in a character; // hopefully this will result in the right valid character. void flip_smallest_bit(int *pos) { int min_zero = INT_MIN, min_one = INT_MAX; int min_zero_pos = -1, min_one_pos = -1; int count_zero = 0, count_one = 1; int val, i; for (i = 0; i < 7; i++) { val = pos[i]; if (val < 0) { count_zero++; if (val > min_zero) { min_zero = val; min_zero_pos = i; } } else { count_one++; if (val < min_one) { min_one = val; min_one_pos = i; } } } // A valid character has 3 zeroes and 4 ones, if we have // 5 ones or 4 zeroes, flipping the smallest one would make // this character valid. if (count_zero == 4) pos[min_zero_pos] = -pos[min_zero_pos]; else if (count_one == 5) pos[min_one_pos] = -pos[min_one_pos]; } // Try to find a position in the bit stream with: // - the largest number of valid characters, and // - with rep (duplicate) characters in the right locations // This way the code can sync up with an incoming signal after // the initial alpha/rep synchronisation // // http://www.arachnoid.com/JNX/index.html // "NAUTICAL" becomes: // rep alpha rep alpha N alpha A alpha U N T A I U C T A I L C blank A blank L int find_alpha_characters(void) { int best_offset = 0; int best_score = 0; int offset, i; // With 7 bits per character, and interleaved rep & alpha // characters, the first alpha character with a corresponding // rep in the stream can be in any of 14 locations for (offset = 35; offset < (35 + 14); offset++) { int score = 0; int reps = 0; int limit = m_bit_values.size() - 7; // Search for the largest sequence of valid characters for (i = offset; i < limit; i += 7) { if (m_ccir476.valid_char_at(&m_bit_values[i])) { int ri = fec_offset(i); int code = m_ccir476.bytes_to_code(&m_bit_values[i]); int rep = m_ccir476.bytes_to_code(&m_bit_values[ri]); // This character is valid score++; // Does it match its rep? if (code == rep) { // This offset is wrong, rep // and alpha are spaced odd if (code == code_alpha || code == code_rep) { score = 0; continue; } reps++; } else if (code == code_alpha) { // Is there a matching rep to // this alpha? int ri = i - 7; int rep = m_ccir476.bytes_to_code(&m_bit_values[ri]); if (rep == code_rep) { reps++; } } } } // the most valid characters, with at least 3 FEC reps if (reps >= 3 && score + reps > best_score) { best_score = score + reps; best_offset = offset; } } // m_bit_values fits 14 characters; if there are at least // 9 good ones, tell the caller where they start if (best_score > 8) return best_offset; else return -1; } // Turns accumulator values (estimates of whether a bit is 1 or 0) // into navtex messages void handle_bit_value(int accumulator) { int buffersize = m_bit_values.size(); int i, offset = 0; // Store the received value in the bit stream for (i = 0; i < buffersize - 1; i++) { m_bit_values[i] = m_bit_values[i+1]; } m_bit_values[buffersize - 1] = accumulator; if (m_bit_cursor > 0) m_bit_cursor--; // Find the most likely location where the message starts if (m_state == SYNC) { offset = find_alpha_characters(); if (offset >= 0) { set_state(READ_DATA); m_bit_cursor = offset; m_alpha_phase = true; } else set_state(SYNC_SETUP); } // Process 7-bit characters as they come in, // skipping rep (duplicate) characters if (m_state == READ_DATA) { if (m_bit_cursor < buffersize - 7) { if (m_alpha_phase) { int ret = process_bytes(m_bit_cursor); m_error_count -= ret; if (m_error_count > 5) set_state(SYNC_SETUP); if (m_error_count < 0) m_error_count = 0; } m_alpha_phase = !m_alpha_phase; m_bit_cursor += 7; } } } // Turn a series of 7 bit confidence values into a character // // 1 on successful decode of the alpha character // 0 on unmodified FEC replacement // -1 on soft failure (FEC calculation) // -2 on hard failure int process_bytes(int m_bit_cursor) { int code = m_ccir476.bytes_to_code(&m_bit_values[m_bit_cursor]); int success = 0; if (m_ccir476.check_bits(code)) { LOG_DEBUG("valid code : %x (%c)", code, m_ccir476.code_to_char(code, m_shift)); success = 1; goto decode; } if (fec_offset(m_bit_cursor) < 0) return -1; // The alpha (primary) character received was not correct. // Try the rep (duplicate) copy of the character, and some // permutations to see if the correct character can be found. { int i, calc, avg[7]; // Rep is 5 characters before alpha. int reppos = fec_offset(m_bit_cursor); int rep = m_ccir476.bytes_to_code(&m_bit_values[reppos]); if (CCIR476::check_bits(rep)) { // Current code is probably code_alpha. // Skip decoding to avoid switching phase. if (rep == code_rep) return 0; LOG_DEBUG("FEC replacement: %x -> %x (%c)", code, rep, m_ccir476.code_to_char(rep, m_shift)); code = rep; goto decode; } // Neither alpha or rep are valid. Check whether // the average of the two is a valid character. for (i = 0; i < 7; i++) { int a = m_bit_values[m_bit_cursor + i]; int r = m_bit_values[reppos + i]; avg[i] = a + r; } calc = m_ccir476.bytes_to_code(avg); if (CCIR476::check_bits(calc)) { LOG_DEBUG("FEC calculation: %x & %x -> %x (%c)", code, rep, calc, m_ccir476.code_to_char(calc, m_shift)); code = calc; success = -1; goto decode; } // Flip the lowest confidence bit in alpha. flip_smallest_bit(&m_bit_values[m_bit_cursor]); calc = m_ccir476.bytes_to_code(&m_bit_values[m_bit_cursor]); if (CCIR476::check_bits(calc)) { LOG_DEBUG("FEC calculation: %x & %x -> %x (%c)", code, rep, calc, m_ccir476.code_to_char(calc, m_shift)); code = calc; success = -1; goto decode; } // Flip the lowest confidence bit in rep. flip_smallest_bit(&m_bit_values[reppos]); calc = m_ccir476.bytes_to_code(&m_bit_values[reppos]); if (CCIR476::check_bits(calc)) { LOG_DEBUG("FEC calculation: %x & %x -> %x (%c)", code, rep, calc, m_ccir476.code_to_char(calc, m_shift)); code = calc; success = -1; goto decode; } // Try flipping the bit with the lowest confidence // in the average of alpha & rep. flip_smallest_bit(avg); calc = m_ccir476.bytes_to_code(avg); if (CCIR476::check_bits(calc)) { LOG_DEBUG("FEC calculation: %x & %x -> %x (%c)", code, rep, calc, m_ccir476.code_to_char(calc, m_shift)); code = calc; success = -1; goto decode; } LOG_DEBUG("decode fail %x, %x", code, rep); return -2; } decode: process_char(code); return success; } bool process_char(int chr) { static int last_char = 0; switch (chr) { case code_rep: // This code should run in alpha phase, but // it just received two rep characters. Fix // the rep/alpha phase, so FEC works again. if (last_char == code_rep) { LOG_DEBUG("fixing rep/alpha sync"); m_alpha_phase = false; } break; case code_alpha: break; case code_beta: break; case code_char32: break; case code_ltrs: m_shift = false; break; case code_figs: m_shift = true; break; default: chr = m_ccir476.code_to_char(chr, m_shift); if (chr < 0) { LOG_INFO(_("Missed this code: %x"), abs(chr)); } else { filter_print(chr); process_messages(chr); } break; } // switch last_char = chr; return true; } void filter_print(int c) { if (c == char_bell) { /// TODO: It should be a beep, but French navtex displays a quote. put_rx_char('\''); } else if (c != -1 && c != '\r' && c != code_alpha && c != code_rep) { put_rx_char(c); } } void compute_metric(void) { static double sigpwr = 0.0 ; static double noisepwr = 0.0; double delta = m_baud_rate/8.0; double np = wf->powerDensity(m_center_frequency_f, delta) * 3000 / delta; double sp = wf->powerDensity(m_mark_f, delta) + wf->powerDensity(m_space_f, delta) + 1e-10; double snr; sigpwr = decayavg ( sigpwr, sp, sp > sigpwr ? 2 : 8); noisepwr = decayavg ( noisepwr, np, 16 ); snr = 10*log10(sigpwr / noisepwr); snprintf(snrmsg, sizeof(snrmsg), "s/n %3.0f dB", snr); put_Status2(snrmsg); m_metric = CLAMP((3000 / delta) * (sigpwr/noisepwr), 0.0, 100.0); m_ptr_navtex->display_metric(m_metric); } void process_afc() { if( progStatus.afconoff == false ) return ; static size_t cnt_upd = 0 ; static const size_t delay_upd = 50 ; ++cnt_upd ; /// AFC from time to time. if( ( cnt_upd % delay_upd ) != 0 ) { return ; } static int cnt_read_data = 0 ; /// This centers the carrier where the activity is the strongest. static const int bw[][2] = { { -deviation_f - 10, -deviation_f + 5 }, { deviation_f - 5, deviation_f + 10 } }; // find mid frequency of power spectra in mark/space frequency interval double max_carrier = wf->powerDensityMaximum( 2, bw ); /// Do not change the frequency too quickly if an image is received. double next_carr = 0.0 ; State lingering_state ; if( m_state == READ_DATA ) { /// Proportional to the number of lines between each AFC update. cnt_read_data = delay_upd / 20 ; lingering_state = READ_DATA ; } else { if( cnt_read_data ) { --cnt_read_data ; lingering_state = READ_DATA ; } else { lingering_state = m_state ; /// Maybe this is the phasing signal, so we recenter. double pwr_left = wf->powerDensity ( max_carrier - deviation_f, 30 ); double pwr_right = wf->powerDensity( max_carrier + deviation_f, 30 ); static const double ratio_left_right = 5.0 ; if( pwr_left > ratio_left_right * pwr_right ) { max_carrier -= deviation_f ; } else if ( ratio_left_right * pwr_left < pwr_right ) { max_carrier += deviation_f ; } } } switch( lingering_state ) { case SYNC_SETUP: next_carr = max_carrier ; break; case SYNC: next_carr = decayavg( m_center_frequency_f, max_carrier, 1 ); break; case READ_DATA: // It will stay stable for a couple of calls. if( max_carrier < m_center_frequency_f ) next_carr = std::max( max_carrier, m_center_frequency_f - 3.0 ); else if( max_carrier > m_center_frequency_f ) next_carr = std::min( max_carrier, m_center_frequency_f + 3.0 ); else next_carr = max_carrier ; break; default: LOG_ERROR("Should not happen: lingering_state=%d", (int)lingering_state ); break ; } LOG_DEBUG("m_center_frequency_f=%f max_carrier=%f next_carr=%f cnt_read_data=%d", (double)m_center_frequency_f, max_carrier, next_carr, cnt_read_data ); double delta = fabs( m_center_frequency_f - next_carr ); if( delta > 1.0 ) { // Hertz. m_ptr_navtex->set_freq(next_carr); } } // The signal is sampled at three points: early, prompt, and late. // The prompt event is where the signal is decoded, while early and // late are only used to adjust the time of the sampling to match // the incoming signal. // // The early event happens 1/5 bit period before the prompt event, // and the late event 1/5 bit period later. If the incoming signal // peaks early, it means the decoder is late. That is, if the early // signal is "too large", decoding should to happen earlier. // // Attempt to center the signal so the accumulator is at its // maximum deviation at the prompt event. If the bit is decoded // too early or too late, the code is more sensitive to noise, // and less likely to decode the signal correctly. void process_multicorrelator() { // Adjust the sampling period once every 8 bit periods. if (m_sample_count % (int)(m_bit_sample_count * 8)) return; // Calculate the slope between early and late signals // to align the logic sampling with the received signal double slope = m_average_late_signal - m_average_early_signal; if (m_average_prompt_signal * 1.05 < m_average_early_signal && m_average_prompt_signal * 1.05 < m_average_late_signal) { // At a signal minimum. Get out quickly. if (m_average_early_signal > m_average_late_signal) { // move prompt to where early is slope = m_next_early_event - m_next_prompt_event; slope = fmod(slope - m_bit_sample_count, m_bit_sample_count); m_average_late_signal = m_average_prompt_signal; m_average_prompt_signal = m_average_early_signal; } else { // move prompt to where late is slope = m_next_late_event - m_next_prompt_event; slope = fmod(slope + m_bit_sample_count, m_bit_sample_count); m_average_early_signal = m_average_prompt_signal; m_average_prompt_signal = m_average_late_signal; } } else slope /= 1024; if (slope) { m_next_early_event += slope; m_next_prompt_event += slope; m_next_late_event += slope; LOG_DEBUG("adjusting by %1.2f, early %1.1f, prompt %1.1f, late %1.1f", slope, m_average_early_signal, m_average_prompt_signal, m_average_late_signal); } } /* A NAVTEX message is built on SITOR collective B-mode and consists of: * a phasing signal of at least ten seconds * the four characters "ZCZC" that identify the end of phasing * a single space * four characters B1, B2, B3 and B4: * B1 is an alpha character identifying the station, * B2 is an alpha character used to identify the subject of the message. * B3 and B4 are two-digit numerics identifying individual messages * a carriage return and a line feed * the information * the four characters "NNNN" to identify the end of information * a carriage return and two line feeds * either * 5 or more seconds of phasing signal and another message starting with "ZCZC" or * an end of emission idle signal alpha for at least 2 seconds. */ public: void process_data(const double * data, int nb_samples) { cmplx z, zmark, zspace, *zp_mark, *zp_space; process_afc(); process_timeout(); // prevent user waterfall interaction from changing filters! guard_lock g( &navtex_filter_mutex ); for( int i =0; i < nb_samples; ++i ) { int n_out; m_time_sec = m_sample_count / m_sample_rate ; double dv = 32767 * data[i]; z = cmplx(dv, dv); zmark = mixer(m_mark_phase, m_mark_f, z); m_mark_lowpass->run(zmark, &zp_mark); zspace = mixer(m_space_phase, m_space_f, z); n_out = m_space_lowpass->run(zspace, &zp_space); if (n_out) process_fft_output(zp_mark, zp_space, n_out); } } private: cmplx mixer(double &phase, double f, cmplx in) { cmplx z = cmplx( cos(phase), sin(phase)) * in; phase -= TWOPI * f / m_sample_rate; if (phase < -TWOPI) phase += TWOPI; return z; } // noise average decays fast down, slow up double noise_decay(double avg, double value) { int divisor; if (value < avg) divisor = m_bit_sample_count / 4; else divisor = m_bit_sample_count * 48; return decayavg(avg, value, divisor); } // envelope average decays fast up, slow down double envelope_decay(double avg, double value) { int divisor; if (value > avg) divisor = m_bit_sample_count / 4; else divisor = m_bit_sample_count * 16; return decayavg(avg, value, divisor); } void process_fft_output(cmplx *zp_mark, cmplx *zp_space, int samples) { // envelope & noise levels for mark & space, respectively static double mark_env = 0, space_env = 0; static double mark_noise = 0, space_noise = 0; for (int i = 0; i < samples; i++) { double mark_abs = abs(zp_mark[i]); double space_abs = abs(zp_space[i]); process_multicorrelator(); // determine noise floor & envelope for mark & space mark_env = envelope_decay(mark_env, mark_abs); mark_noise = noise_decay(mark_noise, mark_abs); space_env = envelope_decay(space_env, space_abs); space_noise = noise_decay(space_noise, space_abs); double noise_floor = (space_noise + mark_noise) / 2; // clip mark & space to envelope & floor mark_abs = std::min(mark_abs, mark_env); mark_abs = std::max(mark_abs, noise_floor); space_abs = std::min(space_abs, space_env); space_abs = std::max(space_abs, noise_floor); // mark-space discriminator with automatic threshold // correction, see: // http://www.w7ay.net/site/Technical/ATC/ double logic_level = (mark_abs - noise_floor) * (mark_env - noise_floor) - (space_abs - noise_floor) * (space_env - noise_floor) - 0.5 * ( (mark_env - noise_floor) * (mark_env - noise_floor) - (space_env - noise_floor) * (space_env - noise_floor)); // Using the logarithm of the logic_level tells the // bit synchronization and character decoding which // samples were decoded well, and which poorly. // This helps fish signals out of the noise. int mark_state = log(1 + abs(logic_level)); if (logic_level < 0) mark_state = -mark_state; m_early_accumulator += mark_state; m_prompt_accumulator += mark_state; m_late_accumulator += mark_state; // An average of the magnitude of the accumulator // is taken at the sample point, as well as a quarter // bit before and after. This allows the code to see // the best time to sample the signal without relying // on (noisy) null crossings. if (m_sample_count >= m_next_early_event) { m_average_early_signal = decayavg( m_average_early_signal, fabs(m_early_accumulator), 64); m_next_early_event += m_bit_sample_count; m_early_accumulator = 0; } if (m_sample_count >= m_next_late_event) { m_average_late_signal = decayavg( m_average_late_signal, fabs(m_late_accumulator), 64); m_next_late_event += m_bit_sample_count; m_late_accumulator = 0; } // the end of a signal pulse // the accumulator should be at maximum deviation m_pulse_edge_event = m_sample_count >= m_next_prompt_event; if (m_pulse_edge_event) { m_average_prompt_signal = decayavg( m_average_prompt_signal, fabs(m_prompt_accumulator), 64); m_next_prompt_event += m_bit_sample_count; m_averaged_mark_state = m_prompt_accumulator; if (m_ptr_navtex->get_reverse()) m_averaged_mark_state = -m_averaged_mark_state; m_prompt_accumulator = 0; } switch (m_state) { case SYNC_SETUP: m_error_count = 0; m_shift = false; set_state(SYNC); break; case SYNC: case READ_DATA: if (m_pulse_edge_event) handle_bit_value(m_averaged_mark_state); } m_sample_count++; } compute_metric(); } /// This updates the window label according to the state. void set_label_from_state(void) const { put_status( state_to_str(m_state) ); } private: /// Each received message is pushed in this queue, so it can be read by XML/RPC. syncobj m_sync_rx ; std::queue< std::string > m_received_messages ; void display_message( ccir_message & ccir_msg, const std::string & alt_string ) { if( ccir_msg.size() >= (size_t)progdefaults.NVTX_MinSizLoggedMsg ) { try { ccir_msg.display(alt_string); put_received_message( alt_string ); } catch( const std::exception & exc ) { LOG_WARN("Caught %s", exc.what() ); } } else { LOG_INFO("Do not log short message:%s", ccir_msg.c_str() ); } } /// Called by the engine each time a message is saved. void put_received_message( const std::string &message ) { guard_lock g( m_sync_rx.mtxp() ); LOG_INFO("%s", message.c_str() ); m_received_messages.push( message ); m_sync_rx.signal(); } public: /// Returns a received message, by chronological order. std::string get_received_message( double max_seconds ) { guard_lock g( m_sync_rx.mtxp() ); LOG_DEBUG("Delay=%f", max_seconds ); if( m_received_messages.empty() ) { if( ! m_sync_rx.wait(max_seconds) ) return "Timeout"; } std::string message = m_received_messages.front(); m_received_messages.pop(); return message ; } // http://www.arachnoid.com/JNX/index.html // "NAUTICAL" becomes: // rep alpha rep alpha N alpha A alpha U N T A I U C T A I L C blank A blank L std::string create_fec( const std::string & str ) const { std::string res ; const size_t sz = str.size(); static const size_t offset = 2 ; for( size_t i = 0 ; i < offset ; ++i ) { res.push_back( code_rep ); res.push_back( code_alpha ); } for ( size_t i = 0; i < sz; ++i ) { res.push_back( str[i] ); res.push_back( i >= offset ? str[ i - offset ] : code_alpha ); } for( size_t i = 0 ; i < offset ; ++i ) { res.push_back( code_char32 ); res.push_back( str[ sz - offset + i ] ); } return res; } /// Note path std::string can contain null characters. TODO: Beware of the extra copy constructor. std::string encode( const std::string & str ) const { std::string res ; bool shift = false ; for ( size_t i = 0, sz = str.size(); i < sz; ++ i ) { m_ccir476.char_to_code(res, str[i], shift ); } return res; } void tx_flush() { if( m_tx_counter != 0 ) { m_ptr_navtex->ModulateXmtr( m_tx_buf, m_tx_counter ); m_tx_counter = 0 ; } } /// Input value must be between -1 and 1 void add_sample( double sam ) { m_tx_buf[ m_tx_counter++ ] = sam ; if( m_tx_counter == m_tx_block_len ) { tx_flush(); } } // REMI : Note change to send_sine void send_sine( double seconds, double freq ) { static double phase = 0; int nb_samples = seconds * m_ptr_navtex->get_samplerate(); double max_level = 0.9;//0.99 ; // Between -1.0 and 1.0 double ratio = 2.0 * M_PI * (double)freq / (double)m_ptr_navtex->get_samplerate() ; for (int i = 0; i < nb_samples ; ++i ) { add_sample( max_level * sin( phase += ratio));//i * ratio ) ); if (phase > 2.0 * M_PI) phase -= 2.0*M_PI; } } void send_phasing( int seconds ) { send_sine( seconds, m_center_frequency_f ); } void send_bit( bool bit ) { send_sine( 1.0 / (double)m_baud_rate, bit ? m_mark_f : m_space_f ); } void send_string( const std::string & msg ) { std::string encod = encode( msg ); std::string sevenbits = create_fec( encod ); for( size_t i = 0, sz = sevenbits.size(); i < sz; i++ ) { char tmp_stat[64]; snprintf( tmp_stat, sizeof(tmp_stat), "Transmission %d%%", (int)( 100.0 * ( i + 1.0 ) / sz ) ); put_status( tmp_stat ); char c = sevenbits[i]; for( size_t j = 0; j < 7 ; ++j, c >>= 1 ) { send_bit( c & 1 ); } } } void send_message( const std::string & msg, bool is_first, bool is_last ) { put_status( "Transmission" ); m_tx_counter = 0 ; if( m_only_sitor_b ) { send_string( msg ); } else { put_status( "Phasing" ); send_phasing( is_first ? 10.0 : 5.0 ); char preamble[64]; const char origin = 'Z' ; // Never seen this value. const char subject = 'I' ; // This code is not used. snprintf( preamble, sizeof(preamble), "ZCZC %c%c%02d\r\n", origin, subject, m_message_counter ); m_message_counter = ( m_message_counter + 1 ) % 100 ; /// The extra cr-nl before NNNN is not in the specification but clarify things. std::string full_msg = preamble + msg + "\r\nNNNN\r\n\n"; send_string( full_msg ); // 5 or more seconds of phasing signal and another message starting with "ZCZC" or // an end of emission idle signal alpha for at least 2 seconds. */ if( is_last ) { put_status( "Trailer" ); send_phasing(2.0); } } tx_flush(); put_status( "" ); } void append_message_to_send( const std::string & msg ) { guard_lock g( &m_mutex_tx ); m_tx_msg_queue.push_back( msg ); } void transmit_message_async( const std::string & msg ) { LOG_INFO("%s", msg.c_str() ); append_message_to_send( msg ); bool is_first = true ; for(;;) { guard_lock g( &m_mutex_tx ); TxMsgQueueT::iterator it = m_tx_msg_queue.begin(), en = m_tx_msg_queue.end(); if( it == en ) break ; TxMsgQueueT::iterator it_next = it ; ++it_next ; bool is_last = it_next == en ; send_message( *it, is_first, is_last ); is_first = false ; m_tx_msg_queue.erase(it); } } void process_tx() { std::string msg ; for(;;) { int c = get_tx_char(); if( c == GET_TX_CHAR_NODATA ) { break ; } msg.push_back( c ); } for( size_t i = 0 ; i < msg.size(); ++ i) { put_echo_char( msg[i] ); } transmit_message_async(msg); } void set_carrier( double freq ) { m_center_frequency_f = freq; set_filter_values(); } }; // navtex_implementation #ifdef NAVTEX_COMMAND_LINE /// For testing purpose, this file can be compiled and run separately as a command-line program. int main(int n, const char ** v ) { printf("%s\n", v[1] ); FILE * f = fl_fopen( v[1], "r" ); fseek( f, 0, SEEK_END ); long l = ftell( f ); printf("l=%ld\n", l); char * buf = new char[l]; fseek( f, 0, SEEK_SET ); size_t lr = fread( buf, 1, l, f ); if( lr - l ) { printf("Err reading\n"); exit(EXIT_FAILURE); }; navtex_implementation nv(11025) ; double * tmp = new double[l/2]; const short * shrt = (const short *)buf; for( int i = 0; i < l/2; i++ ) tmp[i] = ( (double)shrt[i] ) / 32767.0; nv.process_data( tmp, l / 2 ); return 0 ; } #endif // NAVTEX_COMMAND_LINE navtex::navtex (trx_mode md) { modem::cap |= CAP_AFC | CAP_REV; navtex::mode = md; modem::samplerate = 11025; modem::bandwidth = 2 * deviation_f ; modem::reverse = false ; bool only_sitor_b = false ; switch( md ) { case MODE_NAVTEX : only_sitor_b = false ; break; case MODE_SITORB : only_sitor_b = true ; break; default : LOG_ERROR("Unknown mode"); } m_impl = new navtex_implementation( modem::samplerate, only_sitor_b, this ); } navtex::~navtex() { if( m_impl ) { delete m_impl ; } } void navtex::rx_init() { put_MODEstatus(modem::mode); } void navtex::restart() { } int navtex::rx_process(const double *buf, int len) { m_impl->process_data( buf, len ); return 0; } void navtex::tx_init() { videoText(); // In trx/modem.cxx } int navtex::tx_process() { modem::tx_process(); m_impl->process_tx(); return -1; } void navtex::set_freq( double freq ) { modem::set_freq( freq ); m_impl->set_carrier( freq ); } /// This returns the next received message. std::string navtex::get_message(int max_seconds) { return m_impl->get_received_message(max_seconds); } std::string navtex::send_message(const std::string &msg) { m_impl->append_message_to_send(msg); start_tx(); // If this is not done. return ""; }
60,837
C++
.cxx
1,758
31.419795
153
0.621166
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,195
FeldModern8-14.cxx
w1hkj_fldigi/src/feld/FeldModern8-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld modern -8-14 font fntchr feldmodern8_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000 }, }, {'"', { 0x0000, 0xD800, 0xD800, 0xD800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000 }, }, {'$', { 0x0000, 0x2000, 0x2000, 0x7800, 0xF800, 0xA000, 0xF000, 0x7800, 0x2800, 0xF800, 0xF000, 0x2000, 0x2000, 0x0000 }, }, {'%', { 0x0000, 0x4000, 0xE400, 0xE400, 0x4C00, 0x1800, 0x3000, 0x6000, 0xC800, 0x9C00, 0x9C00, 0x8800, 0x0000, 0x0000 }, }, {'&', { 0x0000, 0x3000, 0x7800, 0x4800, 0x4800, 0x7000, 0xF400, 0x8C00, 0x8800, 0xFC00, 0x7400, 0x0000, 0x0000, 0x0000 }, }, { 39, { 0x0000, 0x4000, 0x4000, 0xC000, 0x8000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x0000, 0x2000, 0x6000, 0xC000, 0x8000, 0x8000, 0x8000, 0x8000, 0xC000, 0x6000, 0x2000, 0x0000, 0x0000 }, }, {')', { 0x0000, 0x0000, 0x8000, 0xC000, 0x6000, 0x2000, 0x2000, 0x2000, 0x2000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'*', { 0x0000, 0x0000, 0x0000, 0x1000, 0x1000, 0xFE00, 0x7C00, 0x3800, 0x6C00, 0x4400, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x4000, 0xC000, 0x8000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0800, 0x0800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'0', { 0x0000, 0x0000, 0x7800, 0xFC00, 0x8C00, 0x9C00, 0xB400, 0xE400, 0xC400, 0x8400, 0xFC00, 0x7800, 0x0000, 0x0000 }, }, {'1', { 0x0000, 0x0000, 0x2000, 0x6000, 0xE000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'2', { 0x0000, 0x0000, 0x7800, 0xFC00, 0x8400, 0x0C00, 0x1800, 0x3000, 0x6000, 0xC000, 0xFC00, 0xFC00, 0x0000, 0x0000 }, }, {'3', { 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0400, 0x0C00, 0x1800, 0x1C00, 0x0400, 0x8400, 0xFC00, 0x7800, 0x0000, 0x0000 }, }, {'4', { 0x0000, 0x0000, 0x3800, 0x7800, 0x4800, 0xC800, 0x8800, 0xFC00, 0xFC00, 0x0800, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {'5', { 0x0000, 0x0000, 0xFC00, 0xFC00, 0x8000, 0x8000, 0xF800, 0xFC00, 0x0400, 0x0400, 0xFC00, 0xF800, 0x0000, 0x0000 }, }, {'6', { 0x0000, 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0xF800, 0xFC00, 0x8400, 0x8400, 0xFC00, 0x7800, 0x0000, 0x0000 }, }, {'7', { 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0400, 0x0400, 0x0C00, 0x1800, 0x3000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'8', { 0x0000, 0x0000, 0x7800, 0xFC00, 0x8400, 0x8400, 0x7800, 0xFC00, 0x8400, 0x8400, 0xFC00, 0x7800, 0x0000, 0x0000 }, }, {'9', { 0x0000, 0x0000, 0x7800, 0xFC00, 0x8400, 0x8400, 0xFC00, 0x7C00, 0x0400, 0x0400, 0x7C00, 0x7800, 0x0000, 0x0000 }, }, {':', { 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000, 0x0000, 0x0000 }, }, {'<', { 0x0000, 0x0000, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0xC000, 0x6000, 0x3000, 0x1800, 0x0800, 0x0000, 0x0000 }, }, {'=', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x0000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x0800, 0x1800, 0x3000, 0x2000, 0x0000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'@', { 0x0000, 0x0000, 0x7C00, 0xFE00, 0x8200, 0x8200, 0xB200, 0xBE00, 0xBC00, 0x8000, 0xFC00, 0x7C00, 0x0000, 0x0000 }, }, {'A', { 0x0000, 0x0000, 0x3000, 0x7800, 0xCC00, 0x8400, 0x8400, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0x0000, 0x0000 }, }, {'B', { 0x0000, 0x0000, 0xF800, 0xFC00, 0x8400, 0x8400, 0xF800, 0xF800, 0x8400, 0x8400, 0xFC00, 0xF800, 0x0000, 0x0000 }, }, {'C', { 0x0000, 0x0000, 0x3800, 0x7C00, 0xC400, 0x8000, 0x8000, 0x8000, 0x8000, 0xC400, 0x7C00, 0x3800, 0x0000, 0x0000 }, }, {'D', { 0x0000, 0x0000, 0xF000, 0xF800, 0x8C00, 0x8400, 0x8400, 0x8400, 0x8400, 0x8C00, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'E', { 0x0000, 0x0000, 0xFC00, 0xFC00, 0x8000, 0x8000, 0xF000, 0xF000, 0x8000, 0x8000, 0xFC00, 0xFC00, 0x0000, 0x0000 }, }, {'F', { 0x0000, 0x0000, 0xFC00, 0xFC00, 0x8000, 0x8000, 0xF000, 0xF000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'G', { 0x0000, 0x0000, 0x3C00, 0x7C00, 0xC000, 0x8000, 0x8C00, 0x8C00, 0x8400, 0xC400, 0x7C00, 0x3800, 0x0000, 0x0000 }, }, {'H', { 0x0000, 0x0000, 0x8400, 0x8400, 0x8400, 0x8400, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0x8400, 0x0000, 0x0000 }, }, {'I', { 0x0000, 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'J', { 0x0000, 0x0000, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x8400, 0x8400, 0xFC00, 0x7800, 0x0000, 0x0000 }, }, {'K', { 0x0000, 0x0000, 0x8400, 0x8400, 0x8C00, 0x9800, 0xF000, 0xF000, 0x9800, 0x8C00, 0x8400, 0x8400, 0x0000, 0x0000 }, }, {'L', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xFC00, 0xFC00, 0x0000, 0x0000 }, }, {'M', { 0x0000, 0x0000, 0x8200, 0xC600, 0xEE00, 0xBA00, 0x9200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'N', { 0x0000, 0x0000, 0x8400, 0xC400, 0xE400, 0xB400, 0x9C00, 0x8C00, 0x8400, 0x8400, 0x8400, 0x8400, 0x0000, 0x0000 }, }, {'O', { 0x0000, 0x0000, 0x3000, 0x7800, 0xCC00, 0x8400, 0x8400, 0x8400, 0x8400, 0xCC00, 0x7800, 0x3000, 0x0000, 0x0000 }, }, {'P', { 0x0000, 0x0000, 0xF800, 0xFC00, 0x8400, 0x8400, 0xFC00, 0xF800, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'Q', { 0x0000, 0x0000, 0x7800, 0xFC00, 0x8400, 0x8400, 0x8400, 0x8400, 0x9400, 0x9400, 0xFC00, 0x7800, 0x0800, 0x0800 }, }, {'R', { 0x0000, 0x0000, 0xF800, 0xFC00, 0x8400, 0x8400, 0xFC00, 0xF800, 0x8800, 0x8C00, 0x8400, 0x8400, 0x0000, 0x0000 }, }, {'S', { 0x0000, 0x0000, 0x7800, 0xFC00, 0x8400, 0x8000, 0xF800, 0x7C00, 0x0400, 0x8400, 0xFC00, 0x7800, 0x0000, 0x0000 }, }, {'T', { 0x0000, 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'U', { 0x0000, 0x0000, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0xFC00, 0x7800, 0x0000, 0x0000 }, }, {'V', { 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0xC600, 0x4400, 0x6C00, 0x2800, 0x3800, 0x1000, 0x1000, 0x0000, 0x0000 }, }, {'W', { 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x9200, 0x9200, 0x9200, 0xFE00, 0x6C00, 0x0000, 0x0000 }, }, {'X', { 0x0000, 0x0000, 0x8200, 0x8200, 0xC600, 0x6C00, 0x3800, 0x3800, 0x6C00, 0xC600, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'Y', { 0x0000, 0x0000, 0x8200, 0x8200, 0xC600, 0x6C00, 0x3800, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000 }, }, {'Z', { 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0C00, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0xFC00, 0xFC00, 0x0000, 0x0000 }, }, {'[', { 0x0000, 0x0000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'\\', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {']', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'^', { 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0x7C00, 0x0400, 0x7C00, 0xFC00, 0x8400, 0xFC00, 0x7C00, 0x0000, 0x0000 }, }, {'b', { 0x0000, 0x0000, 0x8000, 0x8000, 0xB800, 0xFC00, 0xC400, 0x8400, 0x8400, 0x8400, 0xFC00, 0xF800, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0x7800, 0x0000, 0x0000 }, }, {'d', { 0x0000, 0x0000, 0x0400, 0x0400, 0x7400, 0xFC00, 0x8C00, 0x8400, 0x8400, 0x8400, 0xFC00, 0x7C00, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0xFC00, 0x8400, 0xFC00, 0xFC00, 0x8000, 0xF800, 0x7800, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0x0000, 0x3C00, 0x7C00, 0x4000, 0x4000, 0xF800, 0xF800, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x0000, 0x7C00, 0xFC00, 0x8400, 0x8400, 0x8C00, 0xFC00, 0x7400, 0x0400, 0x7C00, 0x7800, 0x0000 }, }, {'h', { 0x0000, 0x0000, 0x8000, 0x8000, 0xB800, 0xFC00, 0xC400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x0000, 0x0000 }, }, {'i', { 0x0000, 0x2000, 0x2000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'j', { 0x0000, 0x0800, 0x0800, 0x0000, 0x3800, 0x3800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0xF800, 0x7000 }, }, {'k', { 0x0000, 0x0000, 0x8000, 0x8800, 0x9800, 0xB000, 0xE000, 0xE000, 0xB000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'l', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0x0000, 0x0000, 0xEC00, 0xFE00, 0x9200, 0x9200, 0x8200, 0x8200, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0x0000, 0x0000, 0xB800, 0xFC00, 0xC400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0xFC00, 0x8400, 0x8400, 0x8400, 0x8400, 0xFC00, 0x7800, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xFC00, 0x8400, 0x8400, 0xC400, 0xFC00, 0xB800, 0x8000, 0x8000, 0x8000 }, }, {'q', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7C00, 0xFC00, 0x8400, 0x8400, 0x8C00, 0xFC00, 0x7400, 0x0400, 0x0400, 0x0400 }, }, {'r', { 0x0000, 0x0000, 0x0000, 0x0000, 0xB800, 0xFC00, 0xC400, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7C00, 0xFC00, 0x8000, 0xF800, 0x7C00, 0x0400, 0xFC00, 0xF800, 0x0000, 0x0000 }, }, {'t', { 0x0000, 0x0000, 0x4000, 0x4000, 0xF000, 0xF000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7800, 0x3800, 0x0000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8C00, 0xFC00, 0x7400, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0x8200, 0xC600, 0x6C00, 0x3800, 0x1000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0x9200, 0x9200, 0x9200, 0xFE00, 0x6C00, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8200, 0xC600, 0x6C00, 0x3800, 0x3800, 0x6C00, 0xC600, 0x8200, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8400, 0x8400, 0x8400, 0x8400, 0x8C00, 0xFC00, 0x7400, 0x0400, 0x7C00, 0x7800 }, }, {'z', { 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x1800, 0x3000, 0x6000, 0xC000, 0xFC00, 0xFC00, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x2000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x2000, 0x0000 }, }, {'|', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {'}', { 0x0000, 0x8000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0x8000, 0x0000 }, }, {'~', { 0x0000, 0x9800, 0xFC00, 0x6400, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,823
C++
.cxx
117
108.581197
125
0.677582
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,196
FeldModern-14.cxx
w1hkj_fldigi/src/feld/FeldModern-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld modern-14 font fntchr feldmodern_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000 }, }, {'"', { 0x0000, 0xD800, 0xD800, 0xD800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000 }, }, {'$', { 0x0000, 0x2000, 0x2000, 0x7800, 0xF800, 0xA000, 0xF000, 0x7800, 0x2800, 0xF800, 0xF000, 0x2000, 0x2000, 0x0000 }, }, {'%', { 0x0000, 0x4000, 0xE400, 0xE400, 0x4C00, 0x1800, 0x3000, 0x6000, 0xC800, 0x9C00, 0x9C00, 0x8800, 0x0000, 0x0000 }, }, {'&', { 0x0000, 0x3000, 0x7800, 0x4800, 0x4800, 0x7000, 0xF400, 0x8C00, 0x8800, 0xFC00, 0x7400, 0x0000, 0x0000, 0x0000 }, }, { 39, { 0x0000, 0x4000, 0x4000, 0xC000, 0x8000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x0000, 0x2000, 0x6000, 0xC000, 0x8000, 0x8000, 0x8000, 0x8000, 0xC000, 0x6000, 0x2000, 0x0000, 0x0000 }, }, {')', { 0x0000, 0x0000, 0x8000, 0xC000, 0x6000, 0x2000, 0x2000, 0x2000, 0x2000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'*', { 0x0000, 0x0000, 0x0000, 0x1000, 0x1000, 0xFE00, 0x7C00, 0x3800, 0x6C00, 0x4400, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0xC000, 0xC000, 0xC000, 0x4000, 0xC000, 0x8000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0800, 0x0800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'0', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x9800, 0xB800, 0xE800, 0xC800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'1', { 0x0000, 0x0000, 0x2000, 0x6000, 0xE000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'2', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'3', { 0x0000, 0x0000, 0xF800, 0xF800, 0x0800, 0x1800, 0x3000, 0x3800, 0x0800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'4', { 0x0000, 0x0000, 0x3000, 0x7000, 0x5000, 0xD000, 0x9000, 0xF800, 0xF800, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000 }, }, {'5', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xF000, 0xF800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'6', { 0x0000, 0x0000, 0x7000, 0xF000, 0x8000, 0x8000, 0xF000, 0xF800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'7', { 0x0000, 0x0000, 0xF800, 0xF800, 0x0800, 0x0800, 0x1800, 0x3000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'8', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0xD800, 0x7000, 0xD800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'9', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0800, 0x0800, 0x7800, 0x7000, 0x0000, 0x0000 }, }, {':', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000 }, }, {'<', { 0x0000, 0x0000, 0x0000, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0xC000, 0x6000, 0x3000, 0x1800, 0x0800, 0x0000 }, }, {'=', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x0800, 0x1800, 0x3000, 0x2000, 0x0000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'@', { 0x0000, 0x0000, 0x7800, 0xFC00, 0x8400, 0x8400, 0xB400, 0xBC00, 0xB800, 0x8000, 0xF800, 0x7800, 0x0000, 0x0000 }, }, {'A', { 0x0000, 0x0000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'B', { 0x0000, 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0xF000, 0xF000, 0x8800, 0x8800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'C', { 0x0000, 0x0000, 0x3000, 0x7800, 0xC800, 0x8000, 0x8000, 0x8000, 0x8000, 0xC800, 0x7800, 0x3000, 0x0000, 0x0000 }, }, {'D', { 0x0000, 0x0000, 0xE000, 0xF000, 0x9800, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0xF000, 0xE000, 0x0000, 0x0000 }, }, {'E', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'F', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'G', { 0x0000, 0x0000, 0x3800, 0x7800, 0xC000, 0x8000, 0x9800, 0x9800, 0x8800, 0xC800, 0x7800, 0x3000, 0x0000, 0x0000 }, }, {'H', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'I', { 0x0000, 0x0000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'J', { 0x0000, 0x0000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'K', { 0x0000, 0x0000, 0x8800, 0x8800, 0x9800, 0xB000, 0xE000, 0xE000, 0xB000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'L', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'M', { 0x0000, 0x0000, 0x8800, 0xD800, 0xF800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'N', { 0x0000, 0x0000, 0x8800, 0xC800, 0xC800, 0xE800, 0xA800, 0xB800, 0x9800, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'O', { 0x0000, 0x0000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x0000, 0x0000 }, }, {'P', { 0x0000, 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0xF800, 0xF000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'Q', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xF800, 0x7000, 0x1000, 0x1000 }, }, {'R', { 0x0000, 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0xF800, 0xF000, 0x9000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'S', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8000, 0xF000, 0x7800, 0x0800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'T', { 0x0000, 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'U', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'V', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0x5000, 0x7000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'W', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xA800, 0xF800, 0x5000, 0x0000, 0x0000 }, }, {'X', { 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'Y', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'Z', { 0x0000, 0x0000, 0xF800, 0xF800, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'[', { 0x0000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x0000, 0x0000, 0x0000 }, }, {'\\', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {']', { 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0x0000, 0x0000, 0x0000 }, }, {'^', { 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0x7800, 0x0800, 0x7800, 0xF800, 0x8800, 0xF800, 0x7800, 0x0000, 0x0000 }, }, {'b', { 0x0000, 0x0000, 0x8000, 0x8000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0xF000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF000, 0x7000, 0x0000, 0x0000 }, }, {'d', { 0x0000, 0x0000, 0x0800, 0x0800, 0x6800, 0xF800, 0x9800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0xF800, 0xF800, 0x8000, 0xF000, 0x7000, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0x0000, 0x3800, 0x7800, 0x4000, 0x4000, 0xF000, 0xF000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0xF800, 0x8800, 0x8800, 0x9800, 0xF800, 0x6800, 0x0800, 0x7800, 0x7000 }, }, {'h', { 0x0000, 0x0000, 0x8000, 0x8000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'i', { 0x0000, 0x4000, 0x4000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'j', { 0x0000, 0x1000, 0x1000, 0x0000, 0x3000, 0x3000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x9000, 0xF000, 0x6000 }, }, {'k', { 0x0000, 0x0000, 0x8000, 0x8000, 0x9000, 0xB000, 0xE000, 0xC000, 0xE000, 0xB000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'l', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0x0000, 0x0000, 0xD000, 0xF800, 0xA800, 0xA800, 0xA800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0x0000, 0x0000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0xC800, 0xF800, 0xB000, 0x8000, 0x8000, 0x8000 }, }, {'q', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0xF800, 0x8800, 0x8800, 0x9800, 0xF800, 0x6800, 0x0800, 0x0800, 0x0800 }, }, {'r', { 0x0000, 0x0000, 0x0000, 0x0000, 0xB000, 0xF800, 0xC800, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0xF800, 0x8000, 0xF000, 0x7800, 0x0800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'t', { 0x0000, 0x0000, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7000, 0x3000, 0x0000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0xF800, 0x6800, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xF800, 0x5000, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0xF800, 0x6800, 0x0800, 0x7800, 0x7000 }, }, {'z', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x1800, 0x3000, 0x6000, 0xC000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x2000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x2000, 0x0000 }, }, {'|', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {'}', { 0x0000, 0x8000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0x8000, 0x0000 }, }, {'~', { 0x0000, 0x9800, 0xFC00, 0x6400, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,819
C++
.cxx
117
108.547009
125
0.677638
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,197
FeldNarr-14.cxx
w1hkj_fldigi/src/feld/FeldNarr-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld narrow-14 font fntchr feldnarr_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0x0000 }, }, {'"', { 0x0000, 0xA000, 0xA000, 0xA000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000 }, }, {'$', { 0x0000, 0x2000, 0x7000, 0xF800, 0xA800, 0xA000, 0xF000, 0x7800, 0x2800, 0xA800, 0xF800, 0x7000, 0x2000, 0x0000 }, }, {'%', { 0x0000, 0xC800, 0xC800, 0xC800, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x9800, 0x9800, 0x9800, 0x0000 }, }, {'&', { 0x0000, 0x4000, 0xE000, 0xA000, 0xA000, 0x4000, 0x4000, 0xA000, 0xA000, 0x9000, 0x9000, 0xF800, 0x7800, 0x0000 }, }, { 39, { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x0000, 0x2000, 0x6000, 0xC000, 0xC000, 0x8000, 0x8000, 0xC000, 0xC000, 0x6000, 0x2000, 0x0000, 0x0000 }, }, {')', { 0x0000, 0x0000, 0x8000, 0xC000, 0x6000, 0x6000, 0x2000, 0x2000, 0x6000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'*', { 0x0000, 0x0000, 0x8800, 0x8800, 0x5000, 0x7000, 0xF800, 0xF800, 0x7000, 0x5000, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0800, 0x0800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'0', { 0x0000, 0x0000, 0x7000, 0xF800, 0x9800, 0x9800, 0xA800, 0xA800, 0xC800, 0xC800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'1', { 0x0000, 0x0000, 0x2000, 0x6000, 0xE000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'2', { 0x0000, 0x0000, 0x6000, 0xF000, 0x9000, 0x1000, 0x3000, 0x2000, 0x4000, 0xC000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'3', { 0x0000, 0x0000, 0xF000, 0xF800, 0x0800, 0x0800, 0x3800, 0x3800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'4', { 0x0000, 0x0000, 0x8000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF800, 0xF800, 0x1000, 0x1000, 0x1000, 0x0000 }, }, {'5', { 0x0000, 0x0000, 0x7800, 0x7800, 0x4000, 0x4000, 0x7000, 0x7800, 0x0800, 0x0800, 0x1800, 0xF000, 0xE000, 0x0000 }, }, {'6', { 0x0000, 0x2000, 0x6000, 0xC000, 0x8000, 0x8000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'7', { 0x0000, 0x0000, 0xF800, 0xF800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000 }, }, {'8', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xD800, 0x7000, 0x7000, 0xD800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'9', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0800, 0x0800, 0x1800, 0x7000, 0x6000, 0x0000, 0x0000 }, }, {':', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000 }, }, {'<', { 0x0000, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0xC000, 0x6000, 0x3000, 0x1800, 0x0800, 0x0000, 0x0000, 0x0000 }, }, {'=', { 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0x7000, 0xF800, 0x8800, 0x0800, 0x1800, 0x3000, 0x2000, 0x2000, 0x0000, 0x0000, 0x2000, 0x2000, 0x0000 }, }, {'@', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xB800, 0xB800, 0xB000, 0x8000, 0xC000, 0x7800, 0x3800, 0x0000, 0x0000 }, }, {'A', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'B', { 0x0000, 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x7000, 0x7000, 0x4800, 0x4800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'C', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8000, 0x8000, 0x8000, 0x8000, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'D', { 0x0000, 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'E', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'F', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'G', { 0x0000, 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0x9800, 0x9800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'H', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'I', { 0x0000, 0x0000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'J', { 0x0000, 0x0000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0x8800, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'K', { 0x0000, 0x0000, 0x8800, 0x8800, 0x9800, 0xB000, 0xE000, 0xE000, 0xB000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'L', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'M', { 0x0000, 0x0000, 0x8800, 0xD800, 0xF800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'N', { 0x0000, 0x0000, 0x8800, 0xC800, 0xC800, 0xE800, 0xA800, 0xB800, 0x9800, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'O', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'P', { 0x0000, 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x7800, 0x7000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'Q', { 0x0000, 0x0000, 0x7000, 0xF800, 0xD800, 0x8800, 0x8800, 0xA800, 0xA800, 0xB800, 0xF000, 0x7000, 0x1800, 0x0800 }, }, {'R', { 0x0000, 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0xF800, 0xF000, 0x9000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'S', { 0x0000, 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0xF000, 0x7800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'T', { 0x0000, 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'U', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'V', { 0x0000, 0x0000, 0x8800, 0x8800, 0x9800, 0x9000, 0xB000, 0xA000, 0xE000, 0xC000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'W', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xA800, 0xF800, 0x5000, 0x0000, 0x0000 }, }, {'X', { 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'Y', { 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0x5000, 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'Z', { 0x0000, 0x0000, 0xF800, 0xF800, 0x1800, 0x1000, 0x3000, 0x6000, 0x4000, 0xC000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'[', { 0x0000, 0x0000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'\\', { 0x0000, 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000 }, }, {']', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'^', { 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0x7800, 0x0800, 0x7800, 0xF800, 0x8800, 0xF800, 0x7800, 0x0000, 0x0000 }, }, {'b', { 0x0000, 0x0000, 0x8000, 0x8000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0xF000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF000, 0x7000, 0x0000, 0x0000 }, }, {'d', { 0x0000, 0x0000, 0x0800, 0x0800, 0x6800, 0xF800, 0x9800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0xF800, 0xF800, 0x8000, 0xF800, 0x7800, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0x0000, 0x3800, 0x7800, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0xF800, 0x8800, 0x8800, 0x9800, 0xF800, 0x6800, 0x0800, 0x7800, 0x7000 }, }, {'h', { 0x0000, 0x0000, 0x8000, 0x8000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'i', { 0x0000, 0x4000, 0x4000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'j', { 0x0000, 0x1000, 0x1000, 0x0000, 0x3000, 0x3000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x9000, 0xF000, 0x6000 }, }, {'k', { 0x0000, 0x0000, 0x8000, 0x8000, 0x9000, 0xB000, 0xE000, 0xE000, 0xA000, 0xB000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'l', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0x0000, 0x0000, 0xD000, 0xF800, 0xA800, 0xA800, 0xA800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0x0000, 0x0000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0xC800, 0xF800, 0xB000, 0x8000, 0x8000, 0x8000 }, }, {'q', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0xF800, 0x8800, 0x8800, 0x9800, 0xF800, 0x6800, 0x0800, 0x0800, 0x0800 }, }, {'r', { 0x0000, 0x0000, 0x0000, 0x0000, 0xD800, 0xF800, 0x6000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0xF800, 0x8000, 0xF000, 0x7800, 0x0800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'t', { 0x0000, 0x0000, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7000, 0x3000, 0x0000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0xF800, 0x6800, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xF800, 0x5000, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0xC800, 0x7800, 0x3000, 0x2000, 0x6000, 0xC000, 0xC000 }, }, {'z', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x1800, 0x3000, 0x6000, 0xC000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x2000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x2000, 0x0000 }, }, {'|', { 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000 }, }, {'}', { 0x0000, 0x8000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0x8000, 0x0000 }, }, {'~', { 0x0000, 0x6800, 0xF800, 0xB000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,817
C++
.cxx
117
108.529915
125
0.677587
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,198
FeldVert-14.cxx
w1hkj_fldigi/src/feld/FeldVert-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld vert-14 font fntchr feldvert_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x8000, 0x8000, 0x0000 }, }, {'"', { 0x0000, 0xA000, 0xA000, 0xA000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000 }, }, {'$', { 0x2000, 0x2000, 0x7800, 0xF800, 0xA000, 0xA000, 0xF000, 0x7800, 0x2800, 0x2800, 0xF800, 0xF000, 0x2000, 0x2000 }, }, {'%', { 0x0000, 0xC800, 0xC800, 0xC800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xD800, 0x9800, 0x9800, 0x0000 }, }, {'&', { 0x0000, 0x4000, 0xE000, 0xA000, 0xA000, 0xE000, 0x6000, 0x6800, 0xD800, 0x9000, 0x9000, 0xF800, 0x6800, 0x0000 }, }, { 39, { 0x0000, 0x4000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x2000, 0x6000, 0xC000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xC000, 0x6000, 0x2000, 0x0000 }, }, {')', { 0x0000, 0x8000, 0xC000, 0x6000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x6000, 0xC000, 0x8000, 0x0000 }, }, {'*', { 0x0000, 0x1000, 0x1000, 0xFE00, 0x7C00, 0x3800, 0x6C00, 0x4400, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x2000, 0xE000, 0xE000, 0xC000 }, }, {'-', { 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0800, 0x0800, 0x1800, 0x1800, 0x3000, 0x3000, 0x6000, 0x6000, 0xC000, 0xC000, 0x8000, 0x8000, 0x0000 }, }, {'0', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x9800, 0xB800, 0xE800, 0xC800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'1', { 0x0000, 0x2000, 0x6000, 0xE000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x7000, 0x7000, 0x0000 }, }, {'2', { 0x0000, 0x7000, 0xF800, 0x8800, 0x0800, 0x0800, 0x3800, 0x7000, 0xC000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000 }, }, {'3', { 0x0000, 0xF800, 0xF800, 0x0800, 0x0800, 0x1800, 0x3000, 0x3000, 0x1800, 0x0800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'4', { 0x0000, 0x8000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF800, 0xF800, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000 }, }, {'5', { 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xF000, 0xF800, 0x0800, 0x0800, 0x0800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'6', { 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0xF000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'7', { 0x0000, 0xF800, 0xF800, 0x0800, 0x0800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0x4000, 0x4000, 0x0000 }, }, {'8', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xD800, 0x7000, 0x7000, 0xD800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'9', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0800, 0x0800, 0x0800, 0x7800, 0x7000, 0x0000 }, }, {':', { 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000, 0x0000, 0x0000 }, }, {'<', { 0x0000, 0x1000, 0x3000, 0x6000, 0xC000, 0x8000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1000, 0x0000, 0x0000, 0x0000 }, }, {'=', { 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0x7000, 0xF800, 0x8800, 0x0800, 0x0800, 0x1800, 0x3000, 0x2000, 0x0000, 0x0000, 0x2000, 0x2000, 0x0000 }, }, {'@', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xA800, 0xA800, 0xB800, 0xB800, 0x8000, 0xC000, 0x7800, 0x3800, 0x0000 }, }, {'A', { 0x0000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'B', { 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0x9800, 0xF000, 0xF000, 0x9800, 0x8800, 0x8800, 0xF800, 0xF000, 0x0000 }, }, {'C', { 0x0000, 0x7000, 0xF800, 0xC800, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xC800, 0xF800, 0x7000, 0x0000 }, }, {'D', { 0x0000, 0xE000, 0xF000, 0x9800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0xF000, 0xE000, 0x0000 }, }, {'E', { 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000 }, }, {'F', { 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000 }, }, {'G', { 0x0000, 0x7000, 0xF800, 0xC800, 0x8000, 0x8000, 0x9800, 0x9800, 0x8800, 0x8800, 0xD800, 0xF800, 0x7000, 0x0000 }, }, {'H', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'I', { 0x0000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000 }, }, {'J', { 0x0000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0x8800, 0xD800, 0xF800, 0x7000, 0x0000 }, }, {'K', { 0x0000, 0x8800, 0x8800, 0x8800, 0x9800, 0xB000, 0xE000, 0xE000, 0xB000, 0x9800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'L', { 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000 }, }, {'M', { 0x0000, 0x8800, 0xD800, 0xF800, 0xA800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'N', { 0x0000, 0x8800, 0x8800, 0xC800, 0xC800, 0xE800, 0xA800, 0xB800, 0x9800, 0x9800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'O', { 0x0000, 0x7000, 0xF800, 0xD800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0xF800, 0x7000, 0x0000 }, }, {'P', { 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000 }, }, {'Q', { 0x0000, 0x7000, 0xF800, 0xD800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xB800, 0xF800, 0x7C00, 0x0C00 }, }, {'R', { 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF000, 0x9000, 0x9800, 0x8800, 0x8800, 0x0000 }, }, {'S', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8000, 0xC000, 0x6000, 0x3000, 0x1800, 0x0800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'T', { 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000 }, }, {'U', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0xF800, 0x7000, 0x0000 }, }, {'V', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0x9000, 0xB000, 0xA000, 0xE000, 0xC000, 0xC000, 0x8000, 0x0000 }, }, {'W', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xF800, 0xF800, 0x5000, 0x0000 }, }, {'X', { 0x0000, 0x8800, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'Y', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0x5000, 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000 }, }, {'Z', { 0x0000, 0xF800, 0xF800, 0x0800, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000 }, }, {'[', { 0x0000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x0000 }, }, {'\\', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0800, 0x0000 }, }, {']', { 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0x0000 }, }, {'^', { 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x4000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x0000, 0x7000, 0x7800, 0x0800, 0x0800, 0x7800, 0xF800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0000 }, }, {'b', { 0x0000, 0x8000, 0x8000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x0000, 0x7000, 0xF000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF000, 0x7000, 0x0000 }, }, {'d', { 0x0000, 0x0800, 0x0800, 0x6800, 0xF800, 0x9800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8000, 0x8000, 0xF000, 0x7000, 0x0000 }, }, {'f', { 0x0000, 0x3000, 0x7800, 0x4800, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x7800, 0xF800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'h', { 0x0000, 0x8000, 0x8000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'i', { 0x4000, 0x4000, 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000 }, }, {'j', { 0x1000, 0x1000, 0x0000, 0x0000, 0x3000, 0x3000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x9000, 0xF000, 0x6000 }, }, {'k', { 0x0000, 0x8000, 0x8000, 0x9000, 0x9000, 0xB000, 0xE000, 0xC000, 0xC000, 0xE000, 0xB000, 0x9000, 0x9000, 0x0000 }, }, {'l', { 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0x0000, 0xD000, 0xF800, 0xA800, 0xA800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0x0000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0x8800, 0xC800, 0xF800, 0xB000, 0x8000, 0x8000, 0x8000, 0x0000 }, }, {'q', { 0x0000, 0x0000, 0x7800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0xF800, 0x6800, 0x0800, 0x0800, 0x0000 }, }, {'r', { 0x0000, 0x0000, 0x0000, 0xD800, 0xF800, 0x6000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0xF000, 0x7800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000 }, }, {'t', { 0x0000, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7000, 0x3000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0xF800, 0x6800, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xF800, 0x5000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xC800, 0x6800, 0x3800, 0x3000, 0x6000, 0xC000, 0x8000 }, }, {'z', { 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0xF800, 0xF800, 0x0000 }, }, {'{', { 0x0000, 0x2000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x2000, 0x0000 }, }, {'|', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0800, 0x0000 }, }, {'}', { 0x0000, 0x8000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0x8000, 0x0000 }, }, {'~', { 0x0000, 0x9000, 0xF800, 0x6800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,815
C++
.cxx
117
108.512821
125
0.677536
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,199
Feld7x7-14.cxx
w1hkj_fldigi/src/feld/Feld7x7-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld 7x7-14 font fntchr feld7x7_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'"', { 0x0000, 0x0000, 0xA000, 0xA000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000, 0x0000 }, }, {'$', { 0x0000, 0x2000, 0x7800, 0x7800, 0xA000, 0xA000, 0x7000, 0x7000, 0x2800, 0x2800, 0xF000, 0xF000, 0x2000, 0x0000 }, }, {'%', { 0x0000, 0x0000, 0xC800, 0xC800, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x9800, 0x9800, 0x0000, 0x0000 }, }, {'&', { 0x0000, 0x0000, 0x4000, 0x4000, 0xE000, 0xE000, 0x6800, 0x6800, 0x9000, 0x9000, 0x7800, 0x7800, 0x0000, 0x0000 }, }, { 39, { 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x0000, 0x6000, 0x6000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {')', { 0x0000, 0x0000, 0xC000, 0xC000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'*', { 0x0000, 0x0000, 0xA800, 0xA800, 0x7000, 0x7000, 0xF800, 0xF800, 0x7000, 0x7000, 0xA800, 0xA800, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0xF800, 0xF800, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x8000, 0x8000, 0x0000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0000, 0x0800, 0x0800, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'0', { 0x0000, 0x0000, 0x7000, 0x7000, 0x9800, 0x9800, 0xA800, 0xA800, 0xC800, 0xC800, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'1', { 0x0000, 0x0000, 0x6000, 0x6000, 0xA000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'2', { 0x0000, 0x0000, 0xE000, 0xE000, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'3', { 0x0000, 0x0000, 0xF000, 0xF000, 0x0800, 0x0800, 0x3000, 0x3000, 0x0800, 0x0800, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'4', { 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF800, 0xF800, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000 }, }, {'5', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xF000, 0xF000, 0x0800, 0x0800, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'6', { 0x0000, 0x0000, 0x7000, 0x7000, 0x8000, 0x8000, 0xF000, 0xF000, 0x8800, 0x8800, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'7', { 0x0000, 0x0000, 0xF800, 0xF800, 0x0800, 0x0800, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x0000, 0x0000 }, }, {'8', { 0x0000, 0x0000, 0x7000, 0x7000, 0x8800, 0x8800, 0x7000, 0x7000, 0x8800, 0x8800, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'9', { 0x0000, 0x0000, 0x7000, 0x7000, 0x8800, 0x8800, 0x7800, 0x7800, 0x0800, 0x0800, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {':', { 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x8000, 0x8000, 0x0000 }, }, {'<', { 0x0000, 0x0000, 0x0800, 0x0800, 0x3000, 0x3000, 0xC000, 0xC000, 0x3000, 0x3000, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {'=', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x0000, 0x8000, 0x8000, 0x6000, 0x6000, 0x1800, 0x1800, 0x6000, 0x6000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0x0000, 0xE000, 0xE000, 0x1000, 0x1000, 0x2000, 0x2000, 0x0000, 0x0000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'@', { 0x0000, 0x0000, 0x7000, 0x7000, 0x8800, 0x8800, 0xB000, 0xB000, 0x8000, 0x8000, 0x7800, 0x7800, 0x0000, 0x0000 }, }, {'A', { 0x0000, 0x0000, 0x7000, 0x7000, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'B', { 0x0000, 0x0000, 0xF000, 0xF000, 0x4800, 0x4800, 0x7000, 0x7000, 0x4800, 0x4800, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'C', { 0x0000, 0x0000, 0x7800, 0x7800, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x7800, 0x7800, 0x0000, 0x0000 }, }, {'D', { 0x0000, 0x0000, 0xF000, 0xF000, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'E', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'F', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'G', { 0x0000, 0x0000, 0x7800, 0x7800, 0x8000, 0x8000, 0x9800, 0x9800, 0x8800, 0x8800, 0x7800, 0x7800, 0x0000, 0x0000 }, }, {'H', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'I', { 0x0000, 0x0000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'J', { 0x0000, 0x0000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0x8800, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'K', { 0x0000, 0x0000, 0x8800, 0x8800, 0x9000, 0x9000, 0xE000, 0xE000, 0x9000, 0x9000, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'L', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'M', { 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0xD800, 0xA800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'N', { 0x0000, 0x0000, 0x8800, 0x8800, 0xC800, 0xC800, 0xA800, 0xA800, 0x9800, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'O', { 0x0000, 0x0000, 0x7000, 0x7000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'P', { 0x0000, 0x0000, 0xF000, 0xF000, 0x8800, 0x8800, 0xF000, 0xF000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'Q', { 0x0000, 0x0000, 0x7000, 0x7000, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0x7000, 0x7000, 0x1000, 0x1000 }, }, {'R', { 0x0000, 0x0000, 0xF000, 0xF000, 0x8800, 0x8800, 0xF000, 0xF000, 0x9000, 0x9000, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'S', { 0x0000, 0x0000, 0x7800, 0x7800, 0x8000, 0x8000, 0x7000, 0x7000, 0x0800, 0x0800, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'T', { 0x0000, 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'U', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'V', { 0x0000, 0x0000, 0x8800, 0x8800, 0x9000, 0x9000, 0xA000, 0xA000, 0xC000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'W', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xA800, 0x5000, 0x5000, 0x0000, 0x0000 }, }, {'X', { 0x0000, 0x0000, 0x8800, 0x8800, 0x5000, 0x5000, 0x2000, 0x2000, 0x5000, 0x5000, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'Y', { 0x0000, 0x0000, 0x8800, 0x8800, 0x5000, 0x5000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'Z', { 0x0000, 0x0000, 0xF800, 0xF800, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'[', { 0x0000, 0x0000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'\\', { 0x0000, 0x0000, 0x8000, 0x8000, 0x4000, 0x4000, 0x2000, 0x2000, 0x1000, 0x1000, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {']', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'^', { 0x0000, 0x0000, 0x2000, 0x2000, 0x5000, 0x5000, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0x0000, 0xC000, 0xC000, 0x8000, 0x8000, 0x4000, 0x4000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x0000, 0x0000, 0xE000, 0xE000, 0x1000, 0x1000, 0xF000, 0xF000, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'b', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0xF000, 0xF000, 0x8800, 0x8800, 0x8800, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0x7000, 0x8000, 0x8000, 0x8000, 0x8000, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'d', { 0x0000, 0x0000, 0x0800, 0x0800, 0x7800, 0x7800, 0x8800, 0x8800, 0x8800, 0x8800, 0x7800, 0x7800, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0x7000, 0xF800, 0xF800, 0x8000, 0x8000, 0x7800, 0x7800, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0x0000, 0x3800, 0x3800, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x0000, 0x7800, 0x7800, 0x8800, 0x8800, 0x7800, 0x7800, 0x0800, 0x0800, 0x7000, 0x7000, 0x0000 }, }, {'h', { 0x0000, 0x0000, 0x8000, 0x8000, 0xF000, 0xF000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'i', { 0x4000, 0x4000, 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'j', { 0x1000, 0x1000, 0x0000, 0x0000, 0x3000, 0x3000, 0x1000, 0x1000, 0x1000, 0x1000, 0x9000, 0x9000, 0x6000, 0x6000 }, }, {'k', { 0x0000, 0x0000, 0x9000, 0x9000, 0xA000, 0xA000, 0xC000, 0xC000, 0xA000, 0xA000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'l', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0x0000, 0x0000, 0xD000, 0xD000, 0xA800, 0xA800, 0xA800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0x0000, 0x0000, 0xB000, 0xB000, 0xC800, 0xC800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0x7000, 0x8800, 0x8800, 0x8800, 0x8800, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF000, 0xF000, 0x8800, 0x8800, 0xC800, 0xC800, 0xB000, 0xB000, 0x8000, 0x8000 }, }, {'q', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0x7800, 0x8800, 0x8800, 0x9800, 0x9800, 0x6800, 0x6800, 0x0800, 0x0800 }, }, {'r', { 0x0000, 0x0000, 0x0000, 0x0000, 0xD800, 0xD800, 0x6000, 0x6000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0x7800, 0xC000, 0xC000, 0x3800, 0x3800, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'t', { 0x0000, 0x0000, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x3000, 0x3000, 0x0000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x5000, 0x5000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0x5000, 0x5000, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x7000, 0x7000, 0x7000, 0x7000, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x4800, 0x4800, 0x3000, 0x3000, 0x2000, 0x2000, 0x4000, 0x4000 }, }, {'z', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x1000, 0x1000, 0x6000, 0x6000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x0000, 0x6000, 0x6000, 0x4000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'|', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'}', { 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x6000, 0x6000, 0x4000, 0x4000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'~', { 0x0000, 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x5000, 0x5000, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,814
C++
.cxx
117
108.495726
125
0.677485
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,200
FeldLo8-14.cxx
w1hkj_fldigi/src/feld/FeldLo8-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld Lo8-14 font fntchr feldlo8_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000 }, }, {'"', { 0x0000, 0x0000, 0xA000, 0xA000, 0xA000, 0xA000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000 }, }, {'$', { 0x2000, 0x7800, 0xF800, 0xF800, 0xA000, 0xA000, 0xF000, 0x7800, 0x2800, 0x2800, 0xF800, 0xF800, 0xF000, 0x2000 }, }, {'%', { 0x0000, 0xC800, 0xC800, 0xC800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xD800, 0x9800, 0x9800, 0x0000 }, }, {'&', { 0x4000, 0xE000, 0xE000, 0xA000, 0x4000, 0x4000, 0xE000, 0xA000, 0xB000, 0xB000, 0xF800, 0x7800, 0x7800, 0x0000 }, }, { 39, { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x2000, 0x6000, 0xE000, 0xC000, 0x8000, 0x8000, 0x8000, 0x8000, 0xC000, 0xE000, 0x6000, 0x2000, 0x0000 }, }, {')', { 0x0000, 0x8000, 0xC000, 0xE000, 0x6000, 0x2000, 0x2000, 0x2000, 0x2000, 0x6000, 0xE000, 0xC000, 0x8000, 0x0000 }, }, {'*', { 0x0000, 0x0000, 0x1000, 0x1000, 0xFE00, 0x7C00, 0x3800, 0x6C00, 0x4400, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x2000, 0xE000, 0xE000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'-', { 0x0000, 0x0000, 0xF800, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0800, 0x0800, 0x1800, 0x1800, 0x3000, 0x3000, 0x6000, 0x6000, 0xC000, 0xC000, 0x8000, 0x8000, 0x0000 }, }, {'0', { 0x0000, 0x7800, 0xFC00, 0xFC00, 0x8C00, 0x8C00, 0xB400, 0xB400, 0xC400, 0xC400, 0xFC00, 0xFC00, 0x7800, 0x0000 }, }, {'1', { 0x0000, 0x2000, 0x6000, 0xE000, 0xE000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x7000, 0x7000, 0x7000, 0x0000 }, }, {'2', { 0x0000, 0xF800, 0xFC00, 0xFC00, 0x0400, 0x0400, 0x7C00, 0xF800, 0x8000, 0x8000, 0xFC00, 0xFC00, 0xFC00, 0x0000 }, }, {'3', { 0x0000, 0xF800, 0xFC00, 0xFC00, 0x0400, 0x0400, 0x3C00, 0x3C00, 0x0400, 0x0400, 0xFC00, 0xFC00, 0xF800, 0x0000 }, }, {'4', { 0x0000, 0x8000, 0x8800, 0x8800, 0x8800, 0x8800, 0xFC00, 0xFC00, 0xFC00, 0x0800, 0x0800, 0x0800, 0x0800, 0x0000 }, }, {'5', { 0x0000, 0xFC00, 0xFC00, 0xFC00, 0x8000, 0x8000, 0xF800, 0xFC00, 0x0400, 0x0400, 0xFC00, 0xFC00, 0xF800, 0x0000 }, }, {'6', { 0x0000, 0x7C00, 0xFC00, 0xFC00, 0x8000, 0x8000, 0xF800, 0xFC00, 0x8400, 0x8400, 0xFC00, 0xFC00, 0x7800, 0x0000 }, }, {'7', { 0x0000, 0xFC00, 0xFC00, 0xFC00, 0x0800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0x4000, 0x0000, 0x0000 }, }, {'8', { 0x0000, 0x7800, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x7800, 0x7800, 0x8400, 0x8400, 0xFC00, 0xFC00, 0x7800, 0x0000 }, }, {'9', { 0x0000, 0x7800, 0xFC00, 0xFC00, 0x8400, 0x8400, 0xFC00, 0x7C00, 0x0400, 0x0400, 0x7C00, 0x7C00, 0x7800, 0x0000 }, }, {':', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000 }, }, {'<', { 0x0000, 0x0800, 0x1800, 0x3800, 0x7000, 0xE000, 0xC000, 0xC000, 0xE000, 0x7000, 0x3800, 0x1800, 0x0800, 0x0000 }, }, {'=', { 0x0000, 0x0000, 0xF800, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x0000, 0x8000, 0xC000, 0xE000, 0x7000, 0x3800, 0x1800, 0x1800, 0x3800, 0x7000, 0xE000, 0xC000, 0x8000 }, }, {'?', { 0x0000, 0x7800, 0xFC00, 0xFC00, 0x8400, 0x0400, 0x0C00, 0x1800, 0x3000, 0x0000, 0x0000, 0x3000, 0x3000, 0x3000 }, }, {'@', { 0x0000, 0x7800, 0xFC00, 0xFC00, 0x8400, 0x8400, 0xBC00, 0xBC00, 0x8000, 0xC000, 0xFC00, 0x7C00, 0x3C00, 0x0000 }, }, {'A', { 0x0000, 0x7800, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0xFC00, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0x0000 }, }, {'B', { 0x0000, 0xF800, 0xFC00, 0xFC00, 0x8400, 0x8400, 0xF800, 0xF800, 0x8400, 0x8400, 0xFC00, 0xFC00, 0xF800, 0x0000 }, }, {'C', { 0x0000, 0x7C00, 0xFC00, 0xFC00, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xFC00, 0xFC00, 0x7C00, 0x0000 }, }, {'D', { 0x0000, 0xF800, 0xFC00, 0xFC00, 0x8C00, 0x8400, 0x8400, 0x8400, 0x8400, 0x8C00, 0xFC00, 0xFC00, 0xF800, 0x0000 }, }, {'E', { 0x0000, 0xFC00, 0xFC00, 0xFC00, 0x8000, 0x8000, 0xF000, 0xF000, 0x8000, 0x8000, 0xFC00, 0xFC00, 0xFC00, 0x0000 }, }, {'F', { 0x0000, 0xFC00, 0xFC00, 0xFC00, 0x8000, 0x8000, 0x8000, 0xF000, 0xF000, 0xF000, 0x8000, 0x8000, 0x8000, 0x0000 }, }, {'G', { 0x0000, 0x7C00, 0xFC00, 0xFC00, 0x8000, 0x8000, 0x9C00, 0x9C00, 0x8400, 0x8400, 0xFC00, 0xFC00, 0x7800, 0x0000 }, }, {'H', { 0x0000, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0xFC00, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0x8400, 0x0000 }, }, {'I', { 0x0000, 0xF800, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0xF800, 0x0000 }, }, {'J', { 0x0000, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x8400, 0x8400, 0xFC00, 0xFC00, 0x7800, 0x0000 }, }, {'K', { 0x0000, 0x8400, 0x8400, 0x8C00, 0x9C00, 0xB800, 0xF000, 0xF000, 0xB800, 0x9C00, 0x8C00, 0x8400, 0x8400, 0x0000 }, }, {'L', { 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xFC00, 0xFC00, 0xFC00, 0x0000 }, }, {'M', { 0x0000, 0x8200, 0xC600, 0xEE00, 0xFE00, 0xBA00, 0x9200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x0000 }, }, {'N', { 0x0000, 0x8400, 0xC400, 0xC400, 0xE400, 0xA400, 0xB400, 0x9400, 0x9C00, 0x8C00, 0x8C00, 0x8400, 0x8400, 0x0000 }, }, {'O', { 0x0000, 0x7800, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0xFC00, 0xFC00, 0x7800, 0x0000 }, }, {'P', { 0x0000, 0xF800, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0xFC00, 0xFC00, 0xF800, 0x8000, 0x8000, 0x8000, 0x0000 }, }, {'Q', { 0x0000, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0x8400, 0x9400, 0x9400, 0xFC00, 0xFE00, 0x7E00, 0x0600, 0x0000 }, }, {'R', { 0x0000, 0xF800, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0xFC00, 0xF800, 0xF800, 0x8C00, 0x8C00, 0x8C00, 0x0000 }, }, {'S', { 0x0000, 0x7C00, 0xFC00, 0xFC00, 0x8000, 0x8000, 0xF800, 0x7C00, 0x0400, 0x0400, 0xFC00, 0xFC00, 0xF800, 0x0000 }, }, {'T', { 0x0000, 0xFE00, 0xFE00, 0xFE00, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000 }, }, {'U', { 0x0000, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0xFC00, 0xFC00, 0x7800, 0x0000 }, }, {'V', { 0x0000, 0x8400, 0x8400, 0x8C00, 0x8800, 0x9800, 0x9000, 0xB000, 0xA000, 0xE000, 0xC000, 0xC000, 0x8000, 0x0000 }, }, {'W', { 0x0000, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x9200, 0x9200, 0x9200, 0x9200, 0xFE00, 0xFE00, 0x6C00, 0x0000 }, }, {'X', { 0x0000, 0x8200, 0x8200, 0xC600, 0xEE00, 0x7C00, 0x3800, 0x3800, 0x7C00, 0xEE00, 0xC600, 0x8200, 0x8200, 0x0000 }, }, {'Y', { 0x0000, 0x8200, 0x8200, 0xC600, 0xEE00, 0x7C00, 0x3800, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000 }, }, {'Z', { 0x0000, 0xFC00, 0xFC00, 0xFC00, 0x0C00, 0x0C00, 0x3800, 0x7000, 0xC000, 0xC000, 0xFC00, 0xFC00, 0xFC00, 0x0000 }, }, {'[', { 0x0000, 0xE000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0xE000, 0x0000 }, }, {'\\', { 0x0000, 0x8000, 0x8000, 0xC000, 0xC000, 0x6000, 0x6000, 0x3000, 0x3000, 0x1800, 0x1800, 0x0800, 0x0800, 0x0000 }, }, {']', { 0x0000, 0xE000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0xE000, 0x0000 }, }, {'^', { 0x0000, 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xE000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x7800, 0x7C00, 0x7C00, 0x0400, 0x7C00, 0xFC00, 0x8400, 0xFC00, 0xFC00, 0x7C00, 0x0000, 0x0000 }, }, {'b', { 0x8000, 0x8000, 0x8000, 0xF800, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0xFC00, 0xFC00, 0xF800, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x7800, 0xF800, 0xF800, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x7800, 0x0000, 0x0000 }, }, {'d', { 0x0400, 0x0400, 0x0400, 0x7C00, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0xFC00, 0xFC00, 0x7C00, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0x7800, 0xFC00, 0xFC00, 0x8400, 0xFC00, 0xFC00, 0x8000, 0xFC00, 0xFC00, 0x7C00, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0x3800, 0x7800, 0x7800, 0x4000, 0x4000, 0xF000, 0xF000, 0x4000, 0x4000, 0xF000, 0xF000, 0xF000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x0000, 0x7C00, 0xFC00, 0xFC00, 0x8400, 0x8400, 0xFC00, 0x7C00, 0x0400, 0xFC00, 0xFC00, 0x7800 }, }, {'h', { 0x8000, 0x8000, 0x8000, 0xF800, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x0000, 0x0000 }, }, {'i', { 0x2000, 0x2000, 0x0000, 0xE000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0xF000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'j', { 0x0800, 0x0800, 0x0000, 0x1800, 0x1800, 0x1800, 0x0800, 0x0800, 0x0800, 0x8800, 0xF800, 0xF800, 0x7000, 0x0000 }, }, {'k', { 0x8000, 0x8000, 0x8800, 0x9800, 0xB800, 0xF000, 0xE000, 0xE000, 0xB000, 0xB800, 0x9800, 0x8800, 0x0000, 0x0000 }, }, {'l', { 0xE000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0xEC00, 0xFE00, 0xFE00, 0x9200, 0x9200, 0x9200, 0x8200, 0x8200, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0xB800, 0xFC00, 0xFC00, 0xC400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x7800, 0xFC00, 0xFC00, 0x8400, 0x8400, 0x8400, 0x8400, 0xFC00, 0xFC00, 0x7800, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0x0000, 0xF800, 0xFC00, 0xFC00, 0x4400, 0x4400, 0x7C00, 0x7C00, 0x7800, 0x4000, 0x4000, 0x4000 }, }, {'q', { 0x0000, 0x0000, 0x0000, 0x7C00, 0xFC00, 0xFC00, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x7800, 0x0800, 0x0800 }, }, {'r', { 0x0000, 0x0000, 0xDC00, 0xFC00, 0xFC00, 0x6000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x7C00, 0xFC00, 0xFC00, 0x8000, 0xF800, 0x7C00, 0x0400, 0xFC00, 0xFC00, 0xF800, 0x0000, 0x0000 }, }, {'t', { 0x4000, 0x4000, 0xF000, 0xF000, 0xF000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7800, 0x7800, 0x3800, 0x0000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8400, 0x8C00, 0xFC00, 0xFC00, 0x7400, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0xC600, 0xEE00, 0x7C00, 0x3800, 0x1000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0x8200, 0x9200, 0x9200, 0x9200, 0xFE00, 0xFE00, 0x6C00, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x8200, 0xC600, 0xEE00, 0x7C00, 0x3800, 0x3800, 0x7C00, 0xEE00, 0xC600, 0x8200, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x8400, 0x8400, 0x8400, 0xC400, 0xE400, 0x7C00, 0x3C00, 0x0400, 0xFC00, 0xFC00, 0x7800, 0x0000 }, }, {'z', { 0x0000, 0x0000, 0xFC00, 0xFC00, 0xFC00, 0x1800, 0x3000, 0x6000, 0xC000, 0xFC00, 0xFC00, 0xFC00, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x2000, 0x6000, 0x6000, 0x4000, 0x4000, 0xC000, 0xC000, 0xC000, 0x4000, 0x6000, 0x6000, 0x2000, 0x0000 }, }, {'|', { 0x0000, 0x8000, 0x8000, 0xC000, 0xC000, 0x6000, 0x6000, 0x3000, 0x3000, 0x1800, 0x1800, 0x0800, 0x0800, 0x0000 }, }, {'}', { 0x0000, 0x8000, 0xC000, 0xC000, 0x4000, 0x4000, 0x6000, 0x6000, 0x6000, 0x4000, 0xC000, 0xC000, 0x8000, 0x0000 }, }, {'~', { 0x0000, 0x0000, 0xD800, 0xF800, 0x6C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,813
C++
.cxx
117
108.495726
125
0.677485
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,201
FeldStyl-14.cxx
w1hkj_fldigi/src/feld/FeldStyl-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld styl-14 font fntchr feldstyl_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x8000, 0x8000, 0x0000 }, }, {'"', { 0x0000, 0xA000, 0xA000, 0xA000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000, 0x0000 }, }, {'$', { 0x2000, 0x2000, 0x7800, 0xF800, 0xA000, 0xA000, 0xF000, 0x7800, 0x2800, 0x2800, 0xF800, 0xF000, 0x2000, 0x2000 }, }, {'%', { 0x0000, 0xC800, 0xC800, 0xC800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xD800, 0x9800, 0x9800, 0x0000 }, }, {'&', { 0x0000, 0x4000, 0xE000, 0xA000, 0xA000, 0xE000, 0x6000, 0x6800, 0xD800, 0x9000, 0x9000, 0xF800, 0x6800, 0x0000 }, }, { 39, { 0x0000, 0x4000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x2000, 0x6000, 0xC000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xC000, 0x6000, 0x2000, 0x0000 }, }, {')', { 0x0000, 0x8000, 0xC000, 0x6000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x6000, 0xC000, 0x8000, 0x0000 }, }, {'*', { 0x0000, 0x1000, 0x1000, 0xFE00, 0x7C00, 0x3800, 0x6C00, 0x4400, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x2000, 0xE000, 0xE000, 0xC000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0800, 0x0800, 0x1800, 0x1800, 0x3000, 0x3000, 0x6000, 0x6000, 0xC000, 0xC000, 0x8000, 0x8000, 0x0000 }, }, {'0', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x9800, 0xB800, 0xE800, 0xC800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'1', { 0x0000, 0x2000, 0x6000, 0xE000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x0000 }, }, {'2', { 0x0000, 0x7000, 0xF800, 0x8800, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000 }, }, {'3', { 0x0000, 0xF000, 0xF800, 0x0800, 0x0800, 0x1800, 0x3000, 0x3000, 0x1800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000 }, }, {'4', { 0x0000, 0x0000, 0x3000, 0x7000, 0x5000, 0xD000, 0x9000, 0x9000, 0xF800, 0xF800, 0x1000, 0x1000, 0x1000, 0x0000 }, }, {'5', { 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xF000, 0xF800, 0x0800, 0x0800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000 }, }, {'6', { 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0xF000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'7', { 0x0000, 0xF800, 0xF800, 0x0800, 0x0800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0x4000, 0x4000, 0x0000 }, }, {'8', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xD800, 0x7000, 0x7000, 0xD800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'9', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0800, 0x0800, 0x0800, 0x7800, 0x7000, 0x0000 }, }, {':', { 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000, 0x0000, 0x0000 }, }, {'<', { 0x0000, 0x0000, 0x1000, 0x3000, 0x6000, 0xC000, 0x8000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1000, 0x0000, 0x0000 }, }, {'=', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x0000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0x7000, 0xF800, 0x8800, 0x0800, 0x0800, 0x1800, 0x3000, 0x2000, 0x0000, 0x0000, 0x2000, 0x2000, 0x0000 }, }, {'@', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xA800, 0xA800, 0xB800, 0xB800, 0x8000, 0xC000, 0x7800, 0x3800, 0x0000 }, }, {'A', { 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'B', { 0x0000, 0xE000, 0xF000, 0x9000, 0x9000, 0x9000, 0xF000, 0xF800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF000, 0x0000 }, }, {'C', { 0x0000, 0x3800, 0x7800, 0xC000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xC000, 0x7800, 0x3800, 0x0000 }, }, {'D', { 0x0000, 0xE000, 0xF000, 0x9800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0xF000, 0xE000, 0x0000 }, }, {'E', { 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000 }, }, {'F', { 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000 }, }, {'G', { 0x0000, 0x3800, 0x7800, 0xC000, 0x8000, 0x8000, 0x9800, 0x9800, 0x8800, 0x8800, 0xC800, 0x7800, 0x3000, 0x0000 }, }, {'H', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'I', { 0x0000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000 }, }, {'J', { 0x0000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'K', { 0x0000, 0x8800, 0x8800, 0x8800, 0x9800, 0xB000, 0xE000, 0xE000, 0xB000, 0x9800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'L', { 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000 }, }, {'M', { 0x0000, 0x8800, 0xD800, 0xF800, 0xA800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'N', { 0x0000, 0x8800, 0x8800, 0xC800, 0xC800, 0xE800, 0xA800, 0xB800, 0x9800, 0x9800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'O', { 0x0000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x0000 }, }, {'P', { 0x0000, 0xE000, 0xF000, 0x9800, 0x8800, 0x8800, 0x9800, 0xF000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000 }, }, {'Q', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xB800, 0xF800, 0x7C00, 0x0C00 }, }, {'R', { 0x0000, 0xE000, 0xF000, 0x9800, 0x8800, 0x8800, 0x9800, 0xF000, 0xF000, 0x9000, 0x9800, 0x8800, 0x8800, 0x0000 }, }, {'S', { 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000 }, }, {'T', { 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000 }, }, {'U', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'V', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0x5000, 0x7000, 0x2000, 0x2000, 0x0000 }, }, {'W', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xF800, 0xF800, 0x5000, 0x0000 }, }, {'X', { 0x0000, 0x8800, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'Y', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000 }, }, {'Z', { 0x0000, 0xF800, 0xF800, 0x0800, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000 }, }, {'[', { 0x0000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x0000 }, }, {'\\', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0800, 0x0000 }, }, {']', { 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0x0000 }, }, {'^', { 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x4000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x0000, 0x7000, 0x7800, 0x0800, 0x0800, 0x7800, 0xF800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0000 }, }, {'b', { 0x0000, 0x8000, 0x8000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x0000, 0x7000, 0xF000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF000, 0x7000, 0x0000 }, }, {'d', { 0x0000, 0x0800, 0x0800, 0x6800, 0xF800, 0x9800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8000, 0x8000, 0xF800, 0x7800, 0x0000 }, }, {'f', { 0x0000, 0x3800, 0x7800, 0x4000, 0x4000, 0x4000, 0xF000, 0xF000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x0000, 0x7800, 0xF800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0800, 0x0800, 0xF800, 0xF000 }, }, {'h', { 0x0000, 0x8000, 0x8000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'i', { 0x4000, 0x4000, 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000 }, }, {'j', { 0x1000, 0x1000, 0x0000, 0x3000, 0x3000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0xF000, 0xE000, 0x0000 }, }, {'k', { 0x0000, 0x8000, 0x8000, 0x9000, 0x9000, 0xB000, 0xE000, 0xC000, 0xC000, 0xE000, 0xB000, 0x9000, 0x9000, 0x0000 }, }, {'l', { 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0x0000, 0xD000, 0xF800, 0xA800, 0xA800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0x0000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0x8800, 0xC800, 0xF800, 0xB000, 0x8000, 0x8000, 0x8000 }, }, {'q', { 0x0000, 0x0000, 0x0000, 0x7800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0xF800, 0x6800, 0x0800, 0x0800 }, }, {'r', { 0x0000, 0x0000, 0x0000, 0xB000, 0xF800, 0xC800, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0xF000, 0x7800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000 }, }, {'t', { 0x0000, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7000, 0x3000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0xF800, 0x6800, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0x5000, 0x7000, 0x2000, 0x2000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xF800, 0x5000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000 }, }, {'z', { 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0xF800, 0xF800, 0x0000 }, }, {'{', { 0x0000, 0x2000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x2000, 0x0000 }, }, {'|', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0800, 0x0000 }, }, {'}', { 0x0000, 0x8000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0x8000, 0x0000 }, }, {'~', { 0x0000, 0x9000, 0xF800, 0x6800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,815
C++
.cxx
117
108.512821
125
0.677536
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,202
FeldDx-14.cxx
w1hkj_fldigi/src/feld/FeldDx-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feldDx-14 font fntchr feldDx_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000 }, }, {'"', { 0x0000, 0x0000, 0xA000, 0xA000, 0xA000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000, 0x0000 }, }, {'$', { 0x0000, 0x2000, 0x7000, 0xF800, 0xA800, 0xA000, 0xF000, 0x7800, 0x2800, 0xA800, 0xF800, 0x7000, 0x2000, 0x0000 }, }, {'%', { 0x0000, 0xC800, 0xC800, 0xC800, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x9800, 0x9800, 0x9800, 0x0000 }, }, {'&', { 0x0000, 0x4000, 0xE000, 0xA000, 0xA000, 0x4000, 0x4000, 0xA000, 0xA000, 0x9000, 0x9000, 0xF800, 0x7800, 0x0000 }, }, { 39, { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x0000, 0x2000, 0x6000, 0xC000, 0xC000, 0x8000, 0x8000, 0xC000, 0xC000, 0x6000, 0x2000, 0x0000, 0x0000 }, }, {')', { 0x0000, 0x0000, 0x8000, 0xC000, 0x6000, 0x6000, 0x2000, 0x2000, 0x6000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'*', { 0x0000, 0x0000, 0x8800, 0x8800, 0x5000, 0x7000, 0xF800, 0xF800, 0x7000, 0x5000, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x2000, 0x2000, 0xE000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x0000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0800, 0x0800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'0', { 0x0000, 0x0000, 0x7000, 0xF800, 0x9800, 0x9800, 0xA800, 0xA800, 0xC800, 0xC800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'1', { 0x0000, 0x0000, 0x2000, 0x6000, 0xE000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'2', { 0x0000, 0x0000, 0x6000, 0xF000, 0x9000, 0x1000, 0x3000, 0x2000, 0x4000, 0xC000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'3', { 0x0000, 0x0000, 0xF000, 0xF800, 0x0800, 0x0800, 0x3800, 0x3800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'4', { 0x0000, 0x0000, 0x8000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF800, 0xF800, 0x1000, 0x1000, 0x1000, 0x0000 }, }, {'5', { 0x0000, 0x0000, 0x7800, 0x7800, 0x4000, 0x4000, 0x7000, 0x7800, 0x0800, 0x0800, 0x1800, 0xF000, 0xE000, 0x0000 }, }, {'6', { 0x0000, 0x2000, 0x6000, 0xC000, 0x8000, 0x8000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'7', { 0x0000, 0x0000, 0xF800, 0xF800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000 }, }, {'8', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xD800, 0x7000, 0x7000, 0xD800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'9', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0800, 0x0800, 0x1800, 0x7000, 0x6000, 0x0000 }, }, {':', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000, 0x0000 }, }, {'<', { 0x0000, 0x0000, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0xC000, 0x6000, 0x3000, 0x1800, 0x0800, 0x0000, 0x0000 }, }, {'=', { 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x0000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0x7000, 0xF800, 0x8800, 0x0800, 0x1800, 0x3000, 0x2000, 0x2000, 0x0000, 0x0000, 0x2000, 0x2000, 0x0000 }, }, {'@', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xB800, 0xB800, 0xB000, 0x8000, 0xC000, 0x7800, 0x3800, 0x0000, 0x0000 }, }, {'A', { 0x0000, 0x0000, 0x0C00, 0x3F00, 0xF3C0, 0xC0C0, 0xC0C0, 0xFFC0, 0xFFC0, 0xC0C0, 0xC0C0, 0xC0C0, 0x0000, 0x0000 }, }, {'B', { 0x0000, 0x0000, 0xFF80, 0xFFE0, 0x3060, 0x3060, 0x3F80, 0x3F80, 0x3060, 0x3060, 0xFFE0, 0xFF80, 0x0000, 0x0000 }, }, {'C', { 0x0000, 0x0000, 0x3F00, 0xFFC0, 0xF0C0, 0xC000, 0xC000, 0xC000, 0xC000, 0xF0C0, 0xFFC0, 0x3F00, 0x0000, 0x0000 }, }, {'D', { 0x0000, 0x0000, 0xFF00, 0xFFC0, 0x30C0, 0x30C0, 0x30C0, 0x30C0, 0x30C0, 0x30C0, 0xFFC0, 0xFF00, 0x0000, 0x0000 }, }, {'E', { 0x0000, 0x0000, 0xFFC0, 0xFFC0, 0xC000, 0xC000, 0xFFC0, 0xFFC0, 0xC000, 0xC000, 0xFFC0, 0xFFC0, 0x0000, 0x0000 }, }, {'F', { 0x0000, 0x0000, 0xFFC0, 0xFFC0, 0xC000, 0xC000, 0xFC00, 0xFC00, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'G', { 0x0000, 0x0000, 0x3FC0, 0xFFC0, 0xF000, 0xC000, 0xC3C0, 0xC3C0, 0xC0C0, 0xF0C0, 0xFFC0, 0x3F00, 0x0000, 0x0000 }, }, {'H', { 0x0000, 0x0000, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xFFC0, 0xFFC0, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0x0000, 0x0000 }, }, {'I', { 0x0000, 0x0000, 0xFC00, 0xFC00, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0xFC00, 0xFC00, 0x0000, 0x0000 }, }, {'J', { 0x0000, 0x0000, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0xC0C0, 0xC0C0, 0xFFC0, 0x3F00, 0x0000, 0x0000 }, }, {'K', { 0x0000, 0x0000, 0xC0C0, 0xC0C0, 0xC3C0, 0xCF00, 0xFC00, 0xFC00, 0xCF00, 0xC3C0, 0xC0C0, 0xC0C0, 0x0000, 0x0000 }, }, {'L', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xFFC0, 0xFFC0, 0x0000, 0x0000 }, }, {'M', { 0x0000, 0xC00C, 0xF03C, 0xFCFC, 0xCFCC, 0xC30C, 0xC00C, 0xC00C, 0xC00C, 0xC00C, 0xC00C, 0x000C, 0x0000, 0x0000 }, }, {'N', { 0x0000, 0x0000, 0xC0C0, 0xF0C0, 0xF0C0, 0xFCC0, 0xCCC0, 0xCFC0, 0xC3C0, 0xC3C0, 0xC0C0, 0xC0C0, 0x0000, 0x0000 }, }, {'O', { 0x0000, 0x0000, 0x3F00, 0xFFC0, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xFFC0, 0x3F00, 0x0000, 0x0000 }, }, {'P', { 0x0000, 0x0000, 0xFF00, 0xFFC0, 0x30C0, 0x30C0, 0x3FC0, 0x3F00, 0x3000, 0x3000, 0xFC00, 0xFC00, 0x0000, 0x0000 }, }, {'Q', { 0x0000, 0x0000, 0x3F00, 0xFFC0, 0xF3C0, 0xC0C0, 0xC0C0, 0xCCC0, 0xCCC0, 0xCFC0, 0xFF00, 0x3F00, 0x03C0, 0x00C0 }, }, {'R', { 0x0000, 0x0000, 0xFF80, 0xFFE0, 0xC060, 0xC060, 0xFFE0, 0xFF80, 0xC180, 0xC1E0, 0xC060, 0xC060, 0x0000, 0x0000 }, }, {'S', { 0x0000, 0x0000, 0x3FC0, 0xFFC0, 0xC000, 0xC000, 0xFF00, 0x3FC0, 0x00C0, 0x00C0, 0xFFC0, 0xFF00, 0x0000, 0x0000 }, }, {'T', { 0x0000, 0x0000, 0xFFC0, 0xFFC0, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000 }, }, {'U', { 0x0000, 0x0000, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xFFC0, 0x3F00, 0x0000, 0x0000 }, }, {'V', { 0x0000, 0x0000, 0xC0C0, 0xC0C0, 0xC3C0, 0xC300, 0xCF00, 0xCC00, 0xFC00, 0xF000, 0xF000, 0xC000, 0x0000, 0x0000 }, }, {'W', { 0x0000, 0x0000, 0xC30C, 0xC30C, 0xC30C, 0xC30C, 0xC30C, 0xC30C, 0xC30C, 0xCFCC, 0xFCFC, 0x3030, 0x0000, 0x0000 }, }, {'X', { 0x0000, 0x0000, 0xC0C0, 0xC0C0, 0xF3C0, 0x3F00, 0x0C00, 0x0C00, 0x3F00, 0xF3C0, 0xC0C0, 0xC0C0, 0x0000, 0x0000 }, }, {'Y', { 0x0000, 0x0000, 0xC0C0, 0xC0C0, 0xF3C0, 0x3300, 0x3F00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000 }, }, {'Z', { 0x0000, 0x0000, 0xFFC0, 0xFFC0, 0x03C0, 0x0300, 0x0F00, 0x3C00, 0x30C0, 0xF0C0, 0xFFC0, 0xFFC0, 0x0000, 0x0000 }, }, {'[', { 0x0000, 0x0000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'\\', { 0x0000, 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000 }, }, {']', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'^', { 0x0000, 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0x0000, 0xFE00, 0xFE00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x7000, 0xF800, 0xD800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'b', { 0x0000, 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x7000, 0x7000, 0x4800, 0x4800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x7000, 0xF800, 0xC800, 0x8000, 0x8000, 0x8000, 0x8000, 0xC800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'d', { 0x0000, 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x7800, 0xF800, 0xC000, 0x8000, 0x9800, 0x9800, 0x8800, 0xC800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'h', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'i', { 0x0000, 0x0000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'j', { 0x0000, 0x0000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0x8800, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'k', { 0x0000, 0x0000, 0x8800, 0x8800, 0x9800, 0xB000, 0xE000, 0xE000, 0xB000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'l', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0x8200, 0xC600, 0xEE00, 0xBA00, 0x9200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0x8800, 0xC800, 0xC800, 0xE800, 0xA800, 0xB800, 0x9800, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x7800, 0x7000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'q', { 0x0000, 0x0000, 0x7000, 0xF800, 0xD800, 0x8800, 0x8800, 0xA800, 0xA800, 0xB800, 0xF000, 0x7000, 0x1800, 0x0800 }, }, {'r', { 0x0000, 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0xF800, 0xF000, 0x9000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0xF000, 0x7800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'t', { 0x0000, 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x8800, 0x8800, 0x9800, 0x9000, 0xB000, 0xA000, 0xE000, 0xC000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x9200, 0x9200, 0x9200, 0x9200, 0x9200, 0x9200, 0x9200, 0xBA00, 0xEE00, 0x4400, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0x5000, 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'z', { 0x0000, 0x0000, 0xF800, 0xF800, 0x1800, 0x1000, 0x3000, 0x6000, 0x4800, 0xC800, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x0000, 0x2000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x2000 }, }, {'|', { 0x0000, 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000 }, }, {'}', { 0x0000, 0x0000, 0x8000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0x8000 }, }, {'~', { 0x0000, 0x0000, 0x2000, 0x7000, 0xD800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,810
C++
.cxx
117
108.470085
125
0.677488
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,203
feld.cxx
w1hkj_fldigi/src/feld/feld.cxx
// // feld.cxx -- FELDHELL modem // // Copyright (C) 2006-2010 // Dave Freese, W1HKJ // // This modem code owes much to the efforts of Joe Veldhuis, N8FQ // // Adapted from code contained in gmfsk source code distribution. // gmfsk Copyright (C) 2001, 2002, 2003 // Tomi Manninen (oh2bns@sral.fi) // Copyright (C) 2004 // Lawrence Glaister (ve7it@shaw.ca) // ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <stdlib.h> #include <stdio.h> #include <iostream> #include "feld.h" #include "fl_digi.h" #include "fontdef.h" #include "confdialog.h" #include "qrunner.h" #include "status.h" #include "debug.h" #include "threads.h" #include <FL/Fl.H> #include <FL/Fl_Value_Slider.H> LOG_FILE_SOURCE(debug::LOG_MODEM); pthread_mutex_t feld_mutex = PTHREAD_MUTEX_INITIALIZER; char feldmsg[80]; void feld::tx_init() { txcounter = 0.0; tx_state = PREAMBLE; preamble = 3; prevsymb = false; videoText(); return; } void feld::rx_init() { rxcounter = 0.0; peakhold = 0.0; for (int i = 0; i < 2 * MAX_RX_COLUMN_LEN; i++ ) col_data[i] = 0; col_pointer = 0; peakhold = 0.0; agc = 0.0; RxColumnLen = progdefaults.HellRcvHeight; switch (mode) { // Amplitude modulation modes case MODE_FELDHELL: rxpixrate = (RxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); break; case MODE_SLOWHELL: rxpixrate = (RxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); break; case MODE_HELLX5: rxpixrate = (RxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); break; case MODE_HELLX9: rxpixrate = (RxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); break; // Frequency modulation modes case MODE_FSKH245: rxpixrate = (RxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); break; case MODE_FSKH105: rxpixrate = (RxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); break; case MODE_HELL80: rxpixrate = (RxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); break; default : rxpixrate = (RxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); break; } return; } void feld::init() { modem::init(); initKeyWaveform(); set_scope_mode(Digiscope::BLANK); put_MODEstatus(mode); if (progdefaults.StartAtSweetSpot) set_freq(progdefaults.PSKsweetspot); else if (progStatus.carrier != 0) { set_freq(progStatus.carrier); #if !BENCHMARK_MODE progStatus.carrier = 0; #endif } else set_freq(wf->Carrier()); rx_init(); } static void set_HellBW(double val) { sldrHellBW->value(val); } void feld::restart() { RxColumnLen = progdefaults.HellRcvHeight; TxColumnLen = FELD_COLUMN_LEN; switch (mode) { // Amplitude modulation modes case MODE_FELDHELL: feldcolumnrate = 17.5; rxpixrate = (RxColumnLen * feldcolumnrate); txpixrate = (TxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); upsampleinc = (double)(txpixrate/samplerate); hell_bandwidth = txpixrate; filter_bandwidth = 5 * round(1.2 * hell_bandwidth / 5.0); progdefaults.HELL_BW_FH = filter_bandwidth; break; case MODE_SLOWHELL: feldcolumnrate = 2.1875; rxpixrate = (RxColumnLen * feldcolumnrate); txpixrate = (TxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); upsampleinc = (double)(txpixrate/samplerate); hell_bandwidth = txpixrate; filter_bandwidth = 5 * round(1.2 * hell_bandwidth / 5.0); progdefaults.HELL_BW_FH = filter_bandwidth; break; case MODE_HELLX5: feldcolumnrate = 87.5; rxpixrate = (RxColumnLen * feldcolumnrate); txpixrate = (TxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); upsampleinc = (double)(txpixrate/samplerate); hell_bandwidth = txpixrate; filter_bandwidth = 5 * round(1.2 * hell_bandwidth / 5.0); progdefaults.HELL_BW_X5 = filter_bandwidth; break; case MODE_HELLX9: feldcolumnrate = 157.5; rxpixrate = (RxColumnLen * feldcolumnrate); txpixrate = (TxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); upsampleinc = (double)(txpixrate/samplerate); hell_bandwidth = txpixrate; filter_bandwidth = 5 * round(1.2 * hell_bandwidth / 5.0); progdefaults.HELL_BW_X9 = filter_bandwidth; break; // Frequency modulation modes case MODE_FSKH245: feldcolumnrate = 17.5; rxpixrate = (RxColumnLen * feldcolumnrate); txpixrate = (TxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); upsampleinc = (double)(txpixrate/samplerate); hell_bandwidth = 122.5; phi2freq = samplerate / M_PI / (hell_bandwidth / 2.0); filter_bandwidth = 5 * round(4.0 * hell_bandwidth / 5.0); progdefaults.HELL_BW_FSKH245 = filter_bandwidth; cap |= CAP_REV; break; case MODE_FSKH105: feldcolumnrate = 17.5; rxpixrate = (RxColumnLen * feldcolumnrate); txpixrate = (TxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); upsampleinc = (double)(txpixrate/samplerate); hell_bandwidth = 55; phi2freq = samplerate / M_PI / (hell_bandwidth / 2.0); filter_bandwidth = 5 * round(4.0 * hell_bandwidth / 5.0); progdefaults.HELL_BW_FSKH105 = filter_bandwidth; cap |= CAP_REV; break; case MODE_HELL80: feldcolumnrate = 35; rxpixrate = (RxColumnLen * feldcolumnrate); txpixrate = (TxColumnLen * feldcolumnrate); downsampleinc = (double)(rxpixrate/samplerate); upsampleinc = (double)(txpixrate/samplerate); hell_bandwidth = 300; phi2freq = samplerate / M_PI / (hell_bandwidth / 2.0); filter_bandwidth = 5 * round(4.0 * hell_bandwidth / 5.0); progdefaults.HELL_BW_HELL80 = filter_bandwidth; cap |= CAP_REV; break; default : feldcolumnrate = 17.5; break; } set_bandwidth(hell_bandwidth); lpfilt->create_filter(0, 1.0 * filter_bandwidth / samplerate);//0.5 * filter_bandwidth / samplerate); average->setLength( 500 * samplerate / rxpixrate); rx_init(); wf->redraw_marker(); REQ(set_HellBW, filter_bandwidth); /* std::cout << "HellRcvHeight: " << progdefaults.HellRcvHeight << "\n" << "rx column length: " << RxColumnLen << "\n" << "tx column length: " << TxColumnLen << "\n" << "feldcolumrate: " << feldcolumnrate << "\n" << "rxpixrate: " << rxpixrate << "\n" << "txpixrate: " << txpixrate << "\n" << "downsampleinc: " << downsampleinc << "\n" << "upsampleinc: " << upsampleinc << "\n" << "hell_bandwidth: " << hell_bandwidth << "\n" << "filter bandwidth: " << filter_bandwidth << "\n" << "baud: " << 0.5 * txpixrate << "\n"; */ } feld::~feld() { if (hilbert) delete hilbert; if (lpfilt) delete lpfilt; if (average) delete average; } feld::feld(trx_mode m) { mode = m; samplerate = FeldSampleRate; cap |= CAP_BW; lpfilt = new fftfilt (0, 0.5, 1024); average = new Cmovavg (200); bbfilt = new Cmovavg(8); hilbert = new C_FIR_filter(); hilbert->init_hilbert (37, 1); rxphacc = 0.0; txphacc = 0.0; wf->redraw_marker(); REQ(&Raster::set_marquee, FHdisp, progdefaults.HellMarquee); col_data.alloc(2 * MAX_RX_COLUMN_LEN); restart(); } // rx section cmplx feld::mixer(cmplx in) { cmplx z; z = cmplx( cos(rxphacc), sin(rxphacc) ); z = z * in; rxphacc -= 2.0 * M_PI * frequency / samplerate; if (rxphacc < 0) rxphacc += TWOPI; return z; } void feld::FSKH_rx(cmplx z) { guard_lock raster_lock(&feld_mutex); double f; double vid; double avg; f = arg(conj(prev) * z) * phi2freq; prev = z; f = bbfilt->run(f); avg = average->run(abs(z)); rxcounter += downsampleinc; if (rxcounter < 1.0) return; rxcounter -= 1.0; if (avg > agc) agc = avg; else switch (progdefaults.hellagc) { case 3: agc *= (1.0 - 0.2 / RxColumnLen); break; case 2: agc *= (1.0 - 0.075 / RxColumnLen); break; case 1: default: agc *= (1.0 - 0.01 / RxColumnLen); } metric = CLAMP(1000*agc, 0.0, 100.0); display_metric(metric); vid = CLAMP(0.5*(f + 1), 0.0, 1.0); if (reverse) vid = 1.0 - vid; if (progdefaults.HellBlackboard) vid = 1.0 - vid; col_data[col_pointer + RxColumnLen] = (int)(vid * 255.0); col_pointer++; if (col_pointer == RxColumnLen) { if (metric > progStatus.sldrSquelchValue || progStatus.sqlonoff == false) { switch (progdefaults.HellRcvWidth) { case 4: REQ(put_rx_data, col_data, 2 * RxColumnLen); case 3: REQ(put_rx_data, col_data, 2 * RxColumnLen); case 2: REQ(put_rx_data, col_data, 2 * RxColumnLen); case 1: default: REQ(put_rx_data, col_data, 2 * RxColumnLen); } } col_pointer = 0; for (int i = 0; i < RxColumnLen; i++) col_data[i] = col_data[i + RxColumnLen]; } } void feld::rx(cmplx z) { guard_lock raster_lock(&feld_mutex); double x, avg; int ix; x = abs(z); if (x > peakval) peakval = x; avg = average->run(x); rxcounter += downsampleinc; if (rxcounter < 1.0) return; rxcounter -= 1.0; x = peakval; peakval = 0; if (x > peakhold) peakhold = x; else peakhold *= (1.0 - 0.02 / RxColumnLen); ix = CLAMP(255 * x / peakhold, 0, 255); if (avg > agc) agc = avg; else switch (progdefaults.hellagc) { case 3: agc *= (1.0 - 0.2 / RxColumnLen); break; case 2: agc *= (1.0 - 0.075 / RxColumnLen); break; case 1: default: agc *= (1.0 - 0.01 / RxColumnLen); } metric = CLAMP(1000*agc, 0.0, 100.0); display_metric(metric); if (!progdefaults.HellBlackboard) ix = 255 - ix; col_data[col_pointer + RxColumnLen] = ix; col_pointer++; if (col_pointer >= RxColumnLen) { if (metric > progStatus.sldrSquelchValue || progStatus.sqlonoff == false) { switch (progdefaults.HellRcvWidth) { case 4: REQ(put_rx_data, col_data, 2 * RxColumnLen); case 3: REQ(put_rx_data, col_data, 2 * RxColumnLen); case 2: REQ(put_rx_data, col_data, 2 * RxColumnLen); case 1: default: REQ(put_rx_data, col_data, 2 * RxColumnLen); } } col_pointer = 0; for (int i = 0; i < RxColumnLen; i++) col_data[i] = col_data[i + RxColumnLen]; } } int feld::rx_process(const double *buf, int len) { cmplx z, *zp; int i, n; if (progdefaults.HELL_BW != filter_bandwidth) { filter_bandwidth = progdefaults.HELL_BW; switch (mode) { case MODE_FELDHELL: progdefaults.HELL_BW_FH = filter_bandwidth; break; case MODE_SLOWHELL: progdefaults.HELL_BW_SH = filter_bandwidth; break; case MODE_HELLX5: progdefaults.HELL_BW_X5 = filter_bandwidth; break; case MODE_HELLX9: progdefaults.HELL_BW_X9 = filter_bandwidth; break; case MODE_FSKH245: progdefaults.HELL_BW_FSKH245 = filter_bandwidth; break; case MODE_FSKH105: progdefaults.HELL_BW_FSKH105 = filter_bandwidth; break; case MODE_HELL80: progdefaults.HELL_BW_HELL80 = filter_bandwidth; } lpfilt->create_filter(0, 0.5 * filter_bandwidth / samplerate); wf->redraw_marker(); } while (len-- > 0) { /* create analytic signal... */ z = cmplx( *buf, *buf ); buf++; /// hilbert transform need for complex frequency shift hilbert->run(z, z); z = mixer(z); n = lpfilt->run(z, &zp); switch (mode) { case MODE_FSKH245: case MODE_FSKH105: case MODE_HELL80: for (i = 0; i < n; i++) { FSKH_rx(zp[i]); } break; default: for (i = 0; i < n; i++) rx(zp[i]); break; } } return 0; } //===================================================================== // tx section // returns value = column bits with b0 ... b13 the transmit rows respecfully // 1 = on, 0 = off // if all bits are 0 // and no lesser bits are set then character is complete // then return -1; int feld::get_font_data(unsigned char c, int col) { int bits = 0; int mask; int bin; int ordbits = 0; fntchr *font = 0; if (col > 15 || c < ' ' || c > '~') return -1; mask = 1 << (15 - col); switch (progdefaults.feldfontnbr) { case 0: font = feld7x7_14; break; case 1: font = feld7x7n_14; break; case 2: font = feldDx_14; break; case 3: font = feldfat_14; break; case 4: font = feldhell_12; break; case 5: font = feldlittle_12; break; case 6: font = feldlo8_14; break; case 7: font = feldlow_14; break; case 8: font = feldmodern_14; break; case 9: font = feldmodern8_14; break; case 10: font = feldnarr_14; break; case 11: font = feldreal_14; break; case 12: font = feldstyl_14; break; case 13: font = feldvert_14; break; case 14: font = feldwide_14; break; default: font = feld7x7_14; } for (int i = 0; i < 14; i++) ordbits |= font[c-' '].byte[i]; for (int row = 0; row < 14; row ++) { bin = font[c - ' '].byte[13 - row] & mask; if ( bin != 0) bits |= 1 << row; } int testval = (1 << (15 - col)) - 1; if ( (bits == 0) && ((ordbits & testval) == 0) ) return -1; return bits; } double feld::nco(double freq) { double x = sin(txphacc); txphacc += 2.0 * M_PI * freq / samplerate; if (txphacc > TWOPI) txphacc -= TWOPI; return x; } void feld::send_symbol(int currsymb, int nextsymb) { int outlen = 0; double Amp = 1.0; double tone = get_txfreq_woffset(); if (hardkeying != progdefaults.HellPulseFast) { hardkeying = progdefaults.HellPulseFast; initKeyWaveform(); } if (mode == MODE_FSKH245 || mode == MODE_FSKH105 || mode == MODE_HELL80) tone += (reverse ? -1 : 1) * (currsymb ? -1 : 1) * bandwidth / 2.0; for (;;) { switch (mode) { case MODE_FSKH245 : case MODE_FSKH105 : case MODE_HELL80 : break; case MODE_HELLX5 : case MODE_HELLX9 : Amp = currsymb; break; case MODE_FELDHELL : case MODE_SLOWHELL : default : if (prevsymb == 0 && currsymb == 1) { Amp = OnShape[outlen]; } else if (currsymb == 1 && nextsymb == 0) { Amp = OffShape[outlen]; } else Amp = currsymb; break; } outbuf[outlen++] = Amp * nco(tone); if (outlen >= OUTBUFSIZE) { LOG_DEBUG("feld reset"); outlen = 0; break; } txcounter += upsampleinc; if (txcounter < 1.0) continue; txcounter -= 1.0; break; } prevsymb = currsymb; // write to soundcard & display ModulateXmtr(outbuf, outlen); rx_process(outbuf, outlen); } void feld::send_null_column() { for (int i = 0; i < 14; i++) send_symbol(0, 0); } void feld::tx_char(char c) { int column = 0; int bits, colbits; int currbit, nextbit; send_null_column(); if (c == ' ') { send_null_column(); send_null_column(); send_null_column(); } else { while ((bits = get_font_data(c, column)) != -1) { for (int col = 0; col < progdefaults.HellXmtWidth; col++) { colbits = bits; for (int i = 0; i < 14; i++) { currbit = colbits & 1; colbits = colbits >> 1; nextbit = colbits & 1; send_symbol(currbit, nextbit); } } column++; } } send_null_column(); return; } int feld::tx_process() { modem::tx_process(); int c; if (hardkeying != progdefaults.HellPulseFast) { hardkeying = progdefaults.HellPulseFast; initKeyWaveform(); } if (tx_state == PREAMBLE) { if (preamble-- > 0) { tx_char('.'); return 0; } tx_state = DATA; } if (tx_state == POSTAMBLE) { if (postamble-- > 0) { tx_char('.'); return 0; } tx_char(' '); tx_state = PREAMBLE; return -1; } c = get_tx_char(); if (c == GET_TX_CHAR_ETX || stopflag) { tx_state = POSTAMBLE; postamble = 3; return 0; } // if TX buffer empty // send idle character if (c == GET_TX_CHAR_NODATA) { if (progdefaults.HellXmtIdle == true) c = '.'; else { send_null_column(); send_null_column(); return 0; } } if (c == '\r' || c == '\n') c = ' '; tx_char(c); return 0; } void feld::initKeyWaveform() { for (int i = 0; i < MAXLEN; i++) { OnShape[i] = 1.0; OffShape[i] = 0.0; } for (int i = 0; i < 32; i++) { switch (hardkeying) { case 0: OnShape[i] = 0.5*(1.0 - cos(M_PI * i / 33)); // raised cosine with 4 msec rise break; case 1: if (i < 16) OnShape[i] = 0.5*(1.0 - cos(M_PI * i / 16)); // raised cosine with 2 msec rise break; case 2: if (i < 8) OnShape[i] = 0.5*(1.0 - cos(M_PI * i / 8)); // raised cosine with 1 msec rise case 3: default: // square shaped pulse break; } OffShape[31 - i] = OnShape[i]; } }
17,147
C++
.cxx
638
23.916928
102
0.648482
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,204
FeldHell-12.cxx
w1hkj_fldigi/src/feld/FeldHell-12.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feldhell-12 font fntchr feldhell_12[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0x0000 }, }, {'"', { 0x0000, 0xA000, 0xA000, 0xA000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000 }, }, {'$', { 0x0000, 0x2000, 0x7000, 0xF800, 0xA800, 0xA000, 0xF000, 0x7800, 0x2800, 0xA800, 0xF800, 0x7000, 0x2000, 0x0000 }, }, {'%', { 0x0000, 0xC800, 0xC800, 0xC800, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x9800, 0x9800, 0x9800, 0x0000 }, }, {'&', { 0x0000, 0x4000, 0xE000, 0xA000, 0xA000, 0x4000, 0x4000, 0xA000, 0xA000, 0x9000, 0x9000, 0xF800, 0x7800, 0x0000 }, }, { 39, { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x0000, 0x2000, 0x6000, 0xC000, 0xC000, 0x8000, 0x8000, 0xC000, 0xC000, 0x6000, 0x2000, 0x0000, 0x0000 }, }, {')', { 0x0000, 0x0000, 0x8000, 0xC000, 0x6000, 0x6000, 0x2000, 0x2000, 0x6000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'*', { 0x0000, 0x0000, 0x8800, 0x8800, 0x5000, 0x7000, 0xF800, 0xF800, 0x7000, 0x5000, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0800, 0x0800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'0', { 0x0000, 0x7000, 0xF800, 0x9800, 0x9800, 0xA800, 0xA800, 0xC800, 0xC800, 0xF800, 0x7000, 0x0000, 0x0000, 0x0000 }, }, {'1', { 0x0000, 0x2000, 0x6000, 0xE000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {'2', { 0x0000, 0x6000, 0xF000, 0x9000, 0x1000, 0x3000, 0x2000, 0x4000, 0xC000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000 }, }, {'3', { 0x0000, 0xF000, 0xF800, 0x0800, 0x0800, 0x3800, 0x3800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000, 0x0000, 0x0000 }, }, {'4', { 0x0000, 0x8000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF800, 0xF800, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000 }, }, {'5', { 0x0000, 0x7800, 0x7800, 0x4000, 0x4000, 0x7000, 0x7800, 0x0800, 0x0800, 0x1800, 0xF000, 0xE000, 0x0000, 0x0000 }, }, {'6', { 0x0000, 0x2000, 0x6000, 0xC000, 0x8000, 0x8000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'7', { 0x0000, 0xF800, 0xF800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'8', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xD800, 0x7000, 0x7000, 0xD800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'9', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0800, 0x0800, 0x1800, 0x7000, 0x6000, 0x0000, 0x0000 }, }, {':', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x0000, 0xC000, 0x0000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000 }, }, {'<', { 0x0000, 0x0000, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0xC000, 0x6000, 0x3000, 0x1800, 0x0800, 0x0000, 0x0000 }, }, {'=', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x0000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0x7000, 0xF800, 0x8800, 0x0800, 0x1800, 0x3000, 0x2000, 0x2000, 0x0000, 0x0000, 0x2000, 0x2000, 0x0000 }, }, {'@', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xB800, 0xB800, 0xB000, 0x8000, 0xC000, 0x7800, 0x3800, 0x0000, 0x0000 }, }, {'A', { 0x0000, 0x7000, 0xF800, 0xD800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000 }, }, {'B', { 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x7000, 0x7000, 0x4800, 0x4800, 0xF800, 0xF000, 0x0000, 0x0000, 0x0000 }, }, {'C', { 0x0000, 0x7000, 0xF800, 0xC800, 0x8000, 0x8000, 0x8000, 0x8000, 0xC800, 0xF800, 0x7000, 0x0000, 0x0000, 0x0000 }, }, {'D', { 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0xF800, 0xF000, 0x0000, 0x0000, 0x0000 }, }, {'E', { 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000 }, }, {'F', { 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000 }, }, {'G', { 0x0000, 0x7800, 0xF800, 0xC000, 0x8000, 0x9800, 0x9800, 0x8800, 0xC800, 0xF800, 0x7000, 0x0000, 0x0000, 0x0000 }, }, {'H', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000 }, }, {'I', { 0x0000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000, 0x0000 }, }, {'J', { 0x0000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0x8800, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000 }, }, {'K', { 0x0000, 0x8800, 0x8800, 0x9800, 0xB000, 0xE000, 0xE000, 0xB000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000 }, }, {'L', { 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000 }, }, {'M', { 0x0000, 0x8200, 0xC600, 0xEE00, 0xBA00, 0x9200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x0000, 0x0000, 0x0000 }, }, {'N', { 0x0000, 0x8800, 0xC800, 0xC800, 0xE800, 0xA800, 0xB800, 0x9800, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000 }, }, {'O', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000, 0x0000 }, }, {'P', { 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x7800, 0x7000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000, 0x0000 }, }, {'Q', { 0x0000, 0x7000, 0xF800, 0xD800, 0x8800, 0x8800, 0xA800, 0xA800, 0xB800, 0xF000, 0x7000, 0x1800, 0x0800, 0x0000 }, }, {'R', { 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0xF800, 0xF000, 0x9000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000 }, }, {'S', { 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0xF000, 0x7800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000, 0x0000, 0x0000 }, }, {'T', { 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {'U', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000, 0x0000 }, }, {'V', { 0x0000, 0x8800, 0x8800, 0x9800, 0x9000, 0xB000, 0xA000, 0xE000, 0xC000, 0xC000, 0x8000, 0x0000, 0x0000, 0x0000 }, }, {'W', { 0x0000, 0x9200, 0x9200, 0x9200, 0x9200, 0x9200, 0x9200, 0x9200, 0xBA00, 0xEE00, 0x4400, 0x0000, 0x0000, 0x0000 }, }, {'X', { 0x0000, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000 }, }, {'Y', { 0x0000, 0x8800, 0x8800, 0xD800, 0x5000, 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {'Z', { 0x0000, 0xF800, 0xF800, 0x1800, 0x1000, 0x3000, 0x6000, 0x4800, 0xC800, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000 }, }, {'[', { 0x0000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x0000, 0x0000, 0x0000 }, }, {'\\', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {']', { 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0x0000, 0x0000, 0x0000 }, }, {'^', { 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0xFE00, 0xFE00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000 }, }, {'b', { 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x7800, 0x7800, 0x4800, 0x4800, 0xF800, 0xF000, 0x0000, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x7000, 0xF800, 0xC800, 0x8000, 0x8000, 0x8000, 0x8000, 0xC800, 0xF800, 0x7000, 0x0000, 0x0000, 0x0000 }, }, {'d', { 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0xF800, 0xF000, 0x0000, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xF800, 0xF800, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000 }, }, {'g', { 0x0000, 0x7800, 0xF800, 0xC000, 0x8000, 0x9800, 0x9800, 0x8800, 0xC800, 0xF800, 0x7000, 0x0000, 0x0000, 0x0000 }, }, {'h', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000 }, }, {'i', { 0x0000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000, 0x0000 }, }, {'j', { 0x0000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000, 0x0000 }, }, {'k', { 0x0000, 0x8800, 0x9800, 0x9800, 0xB000, 0xE000, 0xE000, 0xB000, 0x9800, 0x9800, 0x8800, 0x0000, 0x0000, 0x0000 }, }, {'l', { 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000 }, }, {'m', { 0x0000, 0x8200, 0xC600, 0xEE00, 0xBA00, 0x9200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x0000, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x8800, 0xC800, 0xC800, 0xE800, 0xA800, 0xB800, 0x9800, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x7800, 0x7000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000, 0x0000 }, }, {'q', { 0x0000, 0x7000, 0xF800, 0xD800, 0x8800, 0x8800, 0xA800, 0xA800, 0xB800, 0xF000, 0x7000, 0x1800, 0x0800, 0x0000 }, }, {'r', { 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0xF800, 0xF000, 0x9000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0xF000, 0x7800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000, 0x0000, 0x0000 }, }, {'t', { 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {'u', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x8800, 0x8800, 0x9800, 0x9000, 0xB000, 0xA000, 0xE000, 0xC000, 0xC000, 0x8000, 0x0000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x9200, 0x9200, 0x9200, 0x9200, 0x9200, 0x9200, 0x9200, 0xBA00, 0xEE00, 0x4400, 0x0000, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x8800, 0x8800, 0xD800, 0x5000, 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {'z', { 0x0000, 0xF800, 0xF800, 0x1800, 0x1000, 0x3000, 0x6000, 0x4800, 0xC800, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x2000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x2000, 0x0000 }, }, {'|', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {'}', { 0x0000, 0x8000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0x8000, 0x0000 }, }, {'~', { 0x0000, 0x2000, 0x7000, 0xD800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,814
C++
.cxx
117
108.504274
125
0.67759
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,205
FeldWide-14.cxx
w1hkj_fldigi/src/feld/FeldWide-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld wide-14 font fntchr feldwide_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0x0000 }, }, {'"', { 0x0000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x4800, 0x4800, 0xFE00, 0xFE00, 0x4800, 0x4800, 0xFE00, 0xFE00, 0x4800, 0x4800, 0x0000, 0x0000, 0x0000 }, }, {'$', { 0x0000, 0x1000, 0x7C00, 0xFE00, 0x9200, 0x9000, 0xFC00, 0x7E00, 0x1200, 0x9200, 0xFE00, 0x7C00, 0x1000, 0x0000 }, }, {'%', { 0x0000, 0xC200, 0xC200, 0xC200, 0x0600, 0x0C00, 0x1800, 0x3000, 0x6000, 0xC000, 0x8600, 0x8600, 0x8600, 0x0000 }, }, {'&', { 0x0000, 0x1800, 0x3C00, 0x6400, 0x6000, 0x3000, 0x7A00, 0x5E00, 0xCC00, 0x8400, 0x8600, 0xFE00, 0x7C00, 0x0000 }, }, { 39, { 0x0000, 0xC000, 0xC000, 0xC000, 0xE000, 0x2000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x1800, 0x3800, 0x6000, 0xC000, 0xC000, 0x8000, 0x8000, 0xC000, 0xC000, 0x6000, 0x3800, 0x1800, 0x0000 }, }, {')', { 0x0000, 0xC000, 0xE000, 0x3000, 0x1800, 0x1800, 0x0800, 0x0800, 0x1800, 0x1800, 0x3000, 0xE000, 0xC000, 0x0000 }, }, {'*', { 0x0000, 0x1000, 0x1000, 0x1000, 0xFE00, 0xFE00, 0x3800, 0x3800, 0x6C00, 0xC600, 0x8200, 0x0000, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x1000, 0x1000, 0x1000, 0xFE00, 0xFE00, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0xE000, 0xC000, 0x0000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0800, 0x0800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'0', { 0x0000, 0x0000, 0x7E00, 0xFF00, 0x8D00, 0x8D00, 0x9900, 0x9900, 0xB100, 0xB100, 0xFF00, 0x7E00, 0x0000, 0x0000 }, }, {'1', { 0x0000, 0x0000, 0x3000, 0x7000, 0xD000, 0x9000, 0x1000, 0x1000, 0x1000, 0x1000, 0x7C00, 0x7C00, 0x0000, 0x0000 }, }, {'2', { 0x0000, 0x0000, 0x7C00, 0xFE00, 0x8200, 0x0200, 0x3E00, 0x7C00, 0xC000, 0xC000, 0xFE00, 0xFE00, 0x0000, 0x0000 }, }, {'3', { 0x0000, 0x0000, 0x7C00, 0xFE00, 0x8600, 0x0600, 0x1C00, 0x1C00, 0x0600, 0x8600, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'4', { 0x0000, 0x8000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xFE00, 0xFE00, 0x0800, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {'5', { 0x0000, 0x7E00, 0x7E00, 0x4000, 0x4000, 0x7C00, 0x7E00, 0x0200, 0x0200, 0x0600, 0xFC00, 0xF800, 0x0000, 0x0000 }, }, {'6', { 0x3C00, 0x7C00, 0xC000, 0x8000, 0x8000, 0xBC00, 0xFE00, 0xC200, 0x8200, 0x8200, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'7', { 0x0000, 0xFE00, 0xFE00, 0x0C00, 0x0C00, 0x1800, 0x1800, 0x3000, 0x3000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'8', { 0x7C00, 0xFE00, 0x8200, 0x8200, 0xC600, 0x7C00, 0x7C00, 0xC600, 0x8200, 0x8200, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'9', { 0x0000, 0x7C00, 0xFE00, 0x8200, 0x8200, 0xFE00, 0x7E00, 0x0200, 0x0200, 0x0600, 0x7C00, 0x7800, 0x0000, 0x0000 }, }, {':', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000, 0x0000 }, }, {'<', { 0x0000, 0x0000, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0xC000, 0x6000, 0x3000, 0x1800, 0x0800, 0x0000, 0x0000 }, }, {'=', { 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0x7C00, 0xFE00, 0x8200, 0x0200, 0x0E00, 0x1C00, 0x3000, 0x2000, 0x0000, 0x0000, 0x2000, 0x2000, 0x0000 }, }, {'@', { 0x0000, 0x7C00, 0xFE00, 0x8200, 0x8200, 0xBA00, 0xBE00, 0xBC00, 0x8000, 0xC000, 0x7C00, 0x3C00, 0x0000, 0x0000 }, }, {'A', { 0x0000, 0x0000, 0x3800, 0x7C00, 0xC600, 0x8200, 0x8200, 0xFE00, 0xFE00, 0x8200, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'B', { 0x0000, 0x0000, 0xFC00, 0xFE00, 0x4200, 0x4200, 0x7C00, 0x7C00, 0x4200, 0x4200, 0xFE00, 0xFC00, 0x0000, 0x0000 }, }, {'C', { 0x0000, 0x0000, 0x7C00, 0xFE00, 0x8200, 0x8000, 0x8000, 0x8000, 0x8000, 0x8200, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'D', { 0x0000, 0x0000, 0xF800, 0xFC00, 0x4600, 0x4200, 0x4200, 0x4200, 0x4200, 0x4600, 0xFC00, 0xF800, 0x0000, 0x0000 }, }, {'E', { 0x0000, 0x0000, 0xFE00, 0xFE00, 0x8000, 0x8000, 0xF800, 0xF800, 0x8000, 0x8000, 0xFE00, 0xFE00, 0x0000, 0x0000 }, }, {'F', { 0x0000, 0x0000, 0xFE00, 0xFE00, 0x8000, 0x8000, 0xF800, 0xF800, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'G', { 0x0000, 0x0000, 0x7E00, 0xFE00, 0x8000, 0x8000, 0x8E00, 0x8E00, 0x8200, 0x8200, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'H', { 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0x8200, 0xFE00, 0xFE00, 0x8200, 0x8200, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'I', { 0x0000, 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'J', { 0x0000, 0x0000, 0x0E00, 0x0E00, 0x0200, 0x0200, 0x0200, 0x0200, 0x8200, 0x8200, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'K', { 0x0000, 0x0000, 0x8600, 0x8600, 0x8C00, 0x9800, 0xF000, 0xF000, 0x9800, 0x8C00, 0x8600, 0x8600, 0x0000, 0x0000 }, }, {'L', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xFE00, 0xFE00, 0x0000, 0x0000 }, }, {'M', { 0x0000, 0x0000, 0x8200, 0xC600, 0xEE00, 0xBA00, 0x9200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'N', { 0x0000, 0x0000, 0x8200, 0xC200, 0xE200, 0xB200, 0x9A00, 0x8E00, 0x8600, 0x8200, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'O', { 0x0000, 0x0000, 0x7C00, 0xFE00, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'P', { 0x0000, 0x0000, 0xFC00, 0xFE00, 0x4200, 0x4200, 0x7E00, 0x7C00, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'Q', { 0x0000, 0x0000, 0x7C00, 0xFE00, 0x8200, 0x8200, 0x8200, 0x8200, 0x8A00, 0x8A00, 0xFE00, 0x7C00, 0x0400, 0x0400 }, }, {'R', { 0x0000, 0x0000, 0xFC00, 0xFE00, 0x8200, 0x8200, 0xFE00, 0xFC00, 0x8400, 0x8600, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'S', { 0x0000, 0x0000, 0x7E00, 0xFE00, 0x8000, 0x8000, 0xFC00, 0x7E00, 0x0200, 0x0200, 0xFE00, 0xFC00, 0x0000, 0x0000 }, }, {'T', { 0x0000, 0x0000, 0xFE00, 0xFE00, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000 }, }, {'U', { 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'V', { 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0x8600, 0x8C00, 0x9800, 0xB000, 0xE000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'W', { 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0x8200, 0x9200, 0x9200, 0x9200, 0x9200, 0xFE00, 0x6C00, 0x0000, 0x0000 }, }, {'X', { 0x0000, 0x0000, 0x8200, 0x8200, 0xC600, 0x6C00, 0x3800, 0x3800, 0x6C00, 0xC600, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'Y', { 0x0000, 0x0000, 0x8200, 0x8200, 0xC600, 0x6C00, 0x3800, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000 }, }, {'Z', { 0x0000, 0x0000, 0xFE00, 0xFE00, 0x0C00, 0x0C00, 0x1800, 0x3000, 0x6000, 0x6000, 0xFE00, 0xFE00, 0x0000, 0x0000 }, }, {'[', { 0x0000, 0x0000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'\\', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {']', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'^', { 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7C00, 0x7E00, 0x0200, 0x7E00, 0xFE00, 0x8200, 0xFE00, 0x7E00, 0x0000, 0x0000 }, }, {'b', { 0x0000, 0x0000, 0xC000, 0xC000, 0x5C00, 0x7E00, 0x6200, 0x4200, 0x4200, 0x4200, 0xFE00, 0xFC00, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7C00, 0xFC00, 0x8000, 0x8000, 0x8000, 0x8000, 0xFC00, 0x7C00, 0x0000, 0x0000 }, }, {'d', { 0x0000, 0x0000, 0x0600, 0x0600, 0x7400, 0xFC00, 0x8C00, 0x8400, 0x8400, 0x8400, 0xFE00, 0x7E00, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7C00, 0xFE00, 0x8200, 0xFE00, 0xFE00, 0x8000, 0xFC00, 0x7C00, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0x0000, 0x3C00, 0x7C00, 0x4000, 0x4000, 0xF000, 0xF000, 0x4000, 0x4000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x0000, 0x7E00, 0xFE00, 0x8200, 0x8200, 0x8600, 0xFE00, 0x7A00, 0x0200, 0x7E00, 0x7C00, 0x0000 }, }, {'h', { 0x0000, 0x0000, 0xC000, 0xC000, 0x5C00, 0x7E00, 0x6200, 0x4200, 0x4200, 0x4200, 0xC200, 0xC200, 0x0000, 0x0000 }, }, {'i', { 0x0000, 0x2000, 0x2000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'j', { 0x0000, 0x0800, 0x0800, 0x0000, 0x3800, 0x3800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0xF800, 0x7000 }, }, {'k', { 0x0000, 0x0000, 0x8000, 0x9800, 0x9800, 0xB000, 0xE000, 0xE000, 0xB000, 0x9800, 0x8C00, 0x8C00, 0x0000, 0x0000 }, }, {'l', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0x0000, 0x0000, 0xEC00, 0xFE00, 0x9200, 0x9200, 0x9200, 0x8200, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0x0000, 0x0000, 0xBC00, 0xFE00, 0xC200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7C00, 0xFE00, 0x8200, 0x8200, 0x8200, 0x8200, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0x0000, 0xFC00, 0xFE00, 0x4200, 0x4200, 0x6200, 0x7E00, 0x5C00, 0x4000, 0xE000, 0xE000, 0x0000 }, }, {'q', { 0x0000, 0x0000, 0x0000, 0x7E00, 0xFE00, 0x8800, 0x8800, 0x9800, 0xF800, 0x6800, 0x0800, 0x1E00, 0x1E00, 0x0000 }, }, {'r', { 0x0000, 0x0000, 0x0000, 0x0000, 0xDC00, 0xFE00, 0x6200, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7E00, 0xFE00, 0x8000, 0xFC00, 0x7E00, 0x0200, 0xFE00, 0xFC00, 0x0000, 0x0000 }, }, {'t', { 0x0000, 0x0000, 0x4000, 0x4000, 0xF000, 0xF000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7800, 0x3800, 0x0000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x8600, 0xFE00, 0x7A00, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0x8200, 0xC600, 0x6C00, 0x3800, 0x1000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8200, 0x8200, 0x9200, 0x9200, 0x9200, 0x9200, 0xFE00, 0x6C00, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8200, 0xC600, 0x6C00, 0x3800, 0x3800, 0x6C00, 0xC600, 0x8200, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8200, 0x8200, 0x8200, 0xC600, 0x6C00, 0x3800, 0x3000, 0x6000, 0xC000, 0xC000 }, }, {'z', { 0x0000, 0x0000, 0x0000, 0x0000, 0xFE00, 0xFE00, 0x0C00, 0x1800, 0x3000, 0x6000, 0xFE00, 0xFE00, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x2000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x2000, 0x0000 }, }, {'|', { 0x0000, 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000 }, }, {'}', { 0x0000, 0x8000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0x8000, 0x0000 }, }, {'~', { 0x0000, 0x0000, 0x0000, 0x2000, 0x7000, 0xD800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,815
C++
.cxx
117
108.512821
125
0.677536
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,206
feldfonts.cxx
w1hkj_fldigi/src/feld/feldfonts.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include "fontdef.h" #include "Feld7x7-14.cxx" #include "Feld7x7n-14.cxx" #include "FeldDx-14.cxx" #include "FeldFat-14.cxx" #include "FeldHell-12.cxx" #include "FeldLittle-12.cxx" #include "FeldLo8-14.cxx" #include "FeldLow-14.cxx" #include "FeldModern-14.cxx" #include "FeldModern8-14.cxx" #include "FeldNarr-14.cxx" #include "FeldReal-14.cxx" #include "FeldStyl-14.cxx" #include "FeldVert-14.cxx" #include "FeldWide-14.cxx" char szFeldFonts[] = "\ 7x7 14|\ 7x7n 14|\ Dx 14|\ fat 14|\ hell 12|\ little 12|\ lo8 14|\ low 14|\ modern 14|\ modern8 14|\ narr 14|\ real 14|\ style 14|\ vert 14|\ wide 14";
1,560
C++
.cxx
52
28.903846
79
0.642049
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,207
FeldFat-14.cxx
w1hkj_fldigi/src/feld/FeldFat-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld-fat font fntchr feldfat_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000 }, }, {'"', { 0x0000, 0x0000, 0xD800, 0xD800, 0xD800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x0000, 0x6C00, 0x6C00, 0xFE00, 0xFE00, 0x6C00, 0x6C00, 0xFE00, 0xFE00, 0x6C00, 0x6C00, 0x0000, 0x0000 }, }, {'$', { 0x0000, 0x1000, 0x7E00, 0xFE00, 0xD000, 0xD000, 0xFC00, 0x7E00, 0x1600, 0x1600, 0xFE00, 0xFC00, 0x1000, 0x0000 }, }, {'%', { 0x0000, 0xE600, 0xE600, 0xE600, 0x0600, 0x0E00, 0x1C00, 0x3800, 0x7000, 0xE000, 0xCE00, 0xCE00, 0xCE00, 0x0000 }, }, {'&', { 0x0000, 0x1800, 0x3E00, 0x6600, 0x6000, 0x3000, 0x7B00, 0x7F00, 0xCE00, 0xC600, 0xC700, 0xFF00, 0x7C00, 0x0000 }, }, { 39, { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x1800, 0x3800, 0x7000, 0xE000, 0xC000, 0xC000, 0xC000, 0xC000, 0xE000, 0x7000, 0x3800, 0x1800, 0x0000 }, }, {')', { 0x0000, 0xC000, 0xE000, 0x7000, 0x3800, 0x1800, 0x1800, 0x1800, 0x1800, 0x3800, 0x7000, 0xE000, 0xC000, 0x0000 }, }, {'*', { 0x0000, 0x0000, 0x1000, 0x1000, 0x1000, 0xFE00, 0xFE00, 0x3800, 0x3800, 0x6C00, 0xC600, 0x8200, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x0000, 0x0000, 0x1800, 0x1800, 0x1800, 0xFF00, 0xFF00, 0x1800, 0x1800, 0x1800, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xE000, 0xE000, 0x6000, 0x6000, 0xE000, 0xC000, 0x0000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xE000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0C00, 0x0C00, 0x1C00, 0x1800, 0x3800, 0x3000, 0x7000, 0x6000, 0xE000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'0', { 0x0000, 0x0000, 0x7C00, 0xFE00, 0xCE00, 0xCE00, 0xD600, 0xD600, 0xE600, 0xE600, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'1', { 0x0000, 0x0000, 0x3000, 0x7000, 0xF000, 0xF000, 0x3000, 0x3000, 0x3000, 0x3000, 0xFC00, 0xFC00, 0x0000, 0x0000 }, }, {'2', { 0x0000, 0x0000, 0x7C00, 0xFE00, 0xC600, 0x0600, 0x3E00, 0x7C00, 0xC000, 0xC000, 0xFE00, 0xFE00, 0x0000, 0x0000 }, }, {'3', { 0x0000, 0x0000, 0x7C00, 0xFE00, 0xC600, 0x0600, 0x1C00, 0x1C00, 0x0600, 0xC600, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'4', { 0x0000, 0x0000, 0x3C00, 0x7C00, 0xEC00, 0xCC00, 0xCC00, 0xFE00, 0xFE00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000 }, }, {'5', { 0x0000, 0x0000, 0xFE00, 0xFE00, 0xC000, 0xC000, 0xFC00, 0xFE00, 0x0600, 0x0600, 0xFE00, 0xFC00, 0x0000, 0x0000 }, }, {'6', { 0x0000, 0x0000, 0x7C00, 0xFC00, 0xC000, 0xC000, 0xFC00, 0xFE00, 0xC600, 0xC600, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'7', { 0x0000, 0x0000, 0xFE00, 0xFE00, 0x0C00, 0x0C00, 0x1800, 0x1800, 0x3000, 0x3000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'8', { 0x0000, 0x0000, 0x7C00, 0xFE00, 0xC600, 0xC600, 0x7C00, 0x7C00, 0xC600, 0xC600, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'9', { 0x0000, 0x0000, 0x7C00, 0xFE00, 0xC600, 0xC600, 0xFE00, 0x7E00, 0x0600, 0x0600, 0x7E00, 0x7C00, 0x0000, 0x0000 }, }, {':', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000, 0x0000 }, }, {'<', { 0x0000, 0x0000, 0x0C00, 0x1C00, 0x3800, 0x7000, 0xE000, 0xE000, 0x7000, 0x3800, 0x1C00, 0x0C00, 0x0000, 0x0000 }, }, {'=', { 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x0000, 0xC000, 0xE000, 0x7000, 0x3800, 0x1C00, 0x1C00, 0x3800, 0x7000, 0xE000, 0xC000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0x0000, 0x7800, 0xFC00, 0xCC00, 0x0C00, 0x3800, 0x7000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x0000 }, }, {'@', { 0x0000, 0x7C00, 0xFE00, 0xC600, 0xC600, 0xDE00, 0xDE00, 0xDC00, 0xC000, 0xC000, 0x7C00, 0x3C00, 0x0000, 0x0000 }, }, {'A', { 0x0000, 0x0000, 0x3800, 0x7C00, 0xEE00, 0xC600, 0xC600, 0xFE00, 0xFE00, 0xC600, 0xC600, 0xC600, 0x0000, 0x0000 }, }, {'B', { 0x0000, 0x0000, 0xFC00, 0xFE00, 0xC600, 0xC600, 0xFC00, 0xFC00, 0xC600, 0xC600, 0xFE00, 0xFC00, 0x0000, 0x0000 }, }, {'C', { 0x0000, 0x0000, 0x3C00, 0x7E00, 0xE600, 0xC000, 0xC000, 0xC000, 0xC000, 0xE600, 0x7E00, 0x3C00, 0x0000, 0x0000 }, }, {'D', { 0x0000, 0x0000, 0xF800, 0xFC00, 0xCE00, 0xC600, 0xC600, 0xC600, 0xC600, 0xCE00, 0xFC00, 0xF800, 0x0000, 0x0000 }, }, {'E', { 0x0000, 0x0000, 0xFE00, 0xFE00, 0xC000, 0xC000, 0xF800, 0xF800, 0xC000, 0xC000, 0xFE00, 0xFE00, 0x0000, 0x0000 }, }, {'F', { 0x0000, 0x0000, 0xFE00, 0xFE00, 0xC000, 0xC000, 0xF800, 0xF800, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'G', { 0x0000, 0x0000, 0x3E00, 0x7E00, 0xE000, 0xC000, 0xCE00, 0xCE00, 0xC600, 0xE600, 0x7E00, 0x3C00, 0x0000, 0x0000 }, }, {'H', { 0x0000, 0x0000, 0xC600, 0xC600, 0xC600, 0xC600, 0xFE00, 0xFE00, 0xC600, 0xC600, 0xC600, 0xC600, 0x0000, 0x0000 }, }, {'I', { 0x0000, 0x0000, 0xF000, 0xF000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'J', { 0x0000, 0x0000, 0x0E00, 0x0E00, 0x0600, 0x0600, 0x0600, 0x0600, 0xC600, 0xC600, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'K', { 0x0000, 0x0000, 0xC600, 0xC600, 0xCE00, 0xDC00, 0xF800, 0xF800, 0xDC00, 0xCE00, 0xC600, 0xC600, 0x0000, 0x0000 }, }, {'L', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xFE00, 0xFE00, 0x0000, 0x0000 }, }, {'M', { 0x0000, 0x0000, 0xC600, 0xEE00, 0xFE00, 0xFE00, 0xD600, 0xC600, 0xC600, 0xC600, 0xC600, 0xC600, 0x0000, 0x0000 }, }, {'N', { 0x0000, 0x0000, 0xC600, 0xE600, 0xF600, 0xFE00, 0xDE00, 0xCE00, 0xC600, 0xC600, 0xC600, 0xC600, 0x0000, 0x0000 }, }, {'O', { 0x0000, 0x0000, 0x3800, 0x7C00, 0xEE00, 0xC600, 0xC600, 0xC600, 0xC600, 0xEE00, 0x7C00, 0x3800, 0x0000, 0x0000 }, }, {'P', { 0x0000, 0x0000, 0xFC00, 0xFE00, 0xC600, 0xC600, 0xFE00, 0xFC00, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'Q', { 0x0000, 0x0000, 0x7C00, 0xFE00, 0xC600, 0xC600, 0xC600, 0xC600, 0xDE00, 0xDE00, 0xFE00, 0x7C00, 0x0C00, 0x0C00 }, }, {'R', { 0x0000, 0x0000, 0xFC00, 0xFE00, 0xC600, 0xC600, 0xFE00, 0xFC00, 0xCC00, 0xCE00, 0xC600, 0xC600, 0x0000, 0x0000 }, }, {'S', { 0x0000, 0x0000, 0x7E00, 0xFE00, 0xC000, 0xC000, 0xFC00, 0x7E00, 0x0600, 0x0600, 0xFE00, 0xFC00, 0x0000, 0x0000 }, }, {'T', { 0x0000, 0x0000, 0xFC00, 0xFC00, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000 }, }, {'U', { 0x0000, 0x0000, 0xC600, 0xC600, 0xC600, 0xC600, 0xC600, 0xC600, 0xC600, 0xC600, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'V', { 0x0000, 0x0000, 0xC600, 0xC600, 0xC600, 0xC600, 0x6C00, 0x6C00, 0x3800, 0x3800, 0x1000, 0x1000, 0x0000, 0x0000 }, }, {'W', { 0x0000, 0x0000, 0xC600, 0xC600, 0xC600, 0xC600, 0xD600, 0xD600, 0xD600, 0xFE00, 0xFE00, 0x6C00, 0x0000, 0x0000 }, }, {'X', { 0x0000, 0x0000, 0xC600, 0xC600, 0xEE00, 0x7C00, 0x3800, 0x3800, 0x7C00, 0xEE00, 0xC600, 0xC600, 0x0000, 0x0000 }, }, {'Y', { 0x0000, 0x0000, 0xCC00, 0xCC00, 0xCC00, 0xFC00, 0x7800, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000 }, }, {'Z', { 0x0000, 0x0000, 0xFE00, 0xFE00, 0x0E00, 0x0C00, 0x1800, 0x3000, 0x6000, 0xE000, 0xFE00, 0xFE00, 0x0000, 0x0000 }, }, {'[', { 0x0000, 0x0000, 0xF000, 0xF000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'\\', { 0x0000, 0x0000, 0xC000, 0xC000, 0xE000, 0x6000, 0x7000, 0x3000, 0x3800, 0x1800, 0x1C00, 0x0C00, 0x0C00, 0x0000 }, }, {']', { 0x0000, 0x0000, 0xF000, 0xF000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'^', { 0x0000, 0x0000, 0x2000, 0x2000, 0x7000, 0x7000, 0xF800, 0xD800, 0xD800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7C00, 0x7E00, 0x0600, 0x7E00, 0xFE00, 0xC600, 0xFE00, 0x7E00, 0x0000, 0x0000 }, }, {'b', { 0x0000, 0x0000, 0xC000, 0xC000, 0xDC00, 0xFE00, 0xE600, 0xC600, 0xC600, 0xC600, 0xFE00, 0xFC00, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7C00, 0xFC00, 0xC000, 0xC000, 0xC000, 0xC000, 0xFC00, 0x7C00, 0x0000, 0x0000 }, }, {'d', { 0x0000, 0x0000, 0x0600, 0x0600, 0x7600, 0xFE00, 0xCE00, 0xC600, 0xC600, 0xC600, 0xFE00, 0x7E00, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7C00, 0xFE00, 0xC600, 0xFE00, 0xFE00, 0xC000, 0xFC00, 0x7C00, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0x0000, 0x3C00, 0x7C00, 0x6000, 0x6000, 0xF800, 0xF800, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7E00, 0xFE00, 0xC600, 0xC600, 0xC600, 0xFE00, 0x7E00, 0x0600, 0x7E00, 0x7C00 }, }, {'h', { 0x0000, 0x0000, 0xC000, 0xC000, 0xDC00, 0xFE00, 0xEE00, 0xC600, 0xC600, 0xC600, 0xC600, 0xC600, 0x0000, 0x0000 }, }, {'i', { 0x0000, 0x6000, 0x6000, 0x0000, 0xE000, 0xE000, 0x6000, 0x6000, 0x6000, 0x6000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'j', { 0x1800, 0x1800, 0x0000, 0x3800, 0x3800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0xD800, 0xF800, 0x7000, 0x0000 }, }, {'k', { 0x0000, 0x0000, 0xC000, 0xCC00, 0xDC00, 0xF800, 0xF000, 0xF000, 0xF800, 0xDC00, 0xCC00, 0xCC00, 0x0000, 0x0000 }, }, {'l', { 0x0000, 0x0000, 0xE000, 0xE000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0x0000, 0x0000, 0xEC00, 0xFE00, 0xFE00, 0xD600, 0xD600, 0xC600, 0xC600, 0xC600, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0x0000, 0x0000, 0xDC00, 0xFE00, 0xEE00, 0xC600, 0xC600, 0xC600, 0xC600, 0xC600, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7C00, 0xFE00, 0xC600, 0xC600, 0xC600, 0xC600, 0xFE00, 0x7C00, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFE00, 0xC600, 0xC600, 0xE600, 0xFE00, 0xDC00, 0xC000, 0xC000, 0xC000 }, }, {'q', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7E00, 0xFE00, 0xC600, 0xC600, 0xCE00, 0xFE00, 0x7600, 0x0600, 0x0600, 0x0600 }, }, {'r', { 0x0000, 0x0000, 0x0000, 0x0000, 0xDC00, 0xFE00, 0xE600, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7E00, 0xFE00, 0xC000, 0xFC00, 0x7E00, 0x0600, 0xFE00, 0xFC00, 0x0000, 0x0000 }, }, {'t', { 0x0000, 0x0000, 0x6000, 0x6000, 0xF000, 0xF000, 0x6000, 0x6000, 0x6000, 0x6000, 0x7800, 0x3800, 0x0000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x0000, 0x0000, 0xC600, 0xC600, 0xC600, 0xC600, 0xC600, 0xCE00, 0xFE00, 0x7600, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x0000, 0x0000, 0xC600, 0xC600, 0xC600, 0xC600, 0xEE00, 0x7C00, 0x3800, 0x1000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x0000, 0x0000, 0xC600, 0xC600, 0xD600, 0xD600, 0xD600, 0xFE00, 0xFE00, 0x6C00, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x0000, 0x0000, 0xC600, 0xEE00, 0x7C00, 0x3800, 0x3800, 0x7C00, 0xEE00, 0xC600, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x0000, 0x0000, 0xC600, 0xC600, 0xC600, 0xEE00, 0x7C00, 0x3800, 0x3000, 0x7000, 0xE000, 0xC000 }, }, {'z', { 0x0000, 0x0000, 0x0000, 0x0000, 0xFE00, 0xFE00, 0x0C00, 0x1800, 0x3000, 0x6000, 0xFE00, 0xFE00, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x3000, 0x7000, 0x6000, 0x6000, 0x6000, 0xE000, 0xE000, 0x6000, 0x6000, 0x7000, 0x7000, 0x3000, 0x0000 }, }, {'|', { 0x0000, 0xC000, 0xC000, 0xE000, 0x6000, 0x7000, 0x3000, 0x3800, 0x1800, 0x1C00, 0x0C00, 0x0C00, 0x0000, 0x0000 }, }, {'}', { 0x0000, 0xC000, 0xE000, 0x6000, 0x6000, 0x6000, 0x7000, 0x7000, 0x6000, 0x6000, 0x6000, 0xE000, 0xC000, 0x0000 }, }, {'~', { 0x0000, 0x0000, 0x2000, 0x7000, 0xF800, 0xD800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,810
C++
.cxx
117
108.470085
125
0.677488
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,208
FeldLittle-12.cxx
w1hkj_fldigi/src/feld/FeldLittle-12.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld little - 12 font fntchr feldlittle_12[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0x0000 }, }, {'"', { 0x0000, 0xA000, 0xA000, 0xA000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000 }, }, {'$', { 0x0000, 0x2000, 0x7000, 0xF800, 0xA800, 0xA000, 0xF000, 0x7800, 0x2800, 0xA800, 0xF800, 0x7000, 0x2000, 0x0000 }, }, {'%', { 0x0000, 0xC800, 0xC800, 0xC800, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x9800, 0x9800, 0x9800, 0x0000 }, }, {'&', { 0x0000, 0x4000, 0xE000, 0xA000, 0xA000, 0x4000, 0x4000, 0xA000, 0xA000, 0x9000, 0x9000, 0xF800, 0x7800, 0x0000 }, }, { 39, { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x0000, 0x2000, 0x6000, 0xC000, 0xC000, 0x8000, 0x8000, 0xC000, 0xC000, 0x6000, 0x2000, 0x0000, 0x0000 }, }, {')', { 0x0000, 0x0000, 0x8000, 0xC000, 0x6000, 0x6000, 0x2000, 0x2000, 0x6000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'*', { 0x0000, 0x0000, 0x8800, 0x8800, 0x5000, 0x7000, 0xF800, 0xF800, 0x7000, 0x5000, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000, 0x0000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000 }, }, {'/', { 0x0000, 0x0800, 0x0800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'0', { 0x0000, 0x0000, 0x6000, 0xF000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF000, 0x6000, 0x0000, 0x0000 }, }, {'1', { 0x0000, 0x0000, 0x2000, 0x6000, 0xE000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'2', { 0x0000, 0x0000, 0x6000, 0xF000, 0x9000, 0x1000, 0x3000, 0x2000, 0x4000, 0xC000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'3', { 0x0000, 0x0000, 0xE000, 0xF000, 0x1000, 0x1000, 0x7000, 0x7000, 0x1000, 0x1000, 0xF000, 0xE000, 0x0000, 0x0000 }, }, {'4', { 0x0000, 0x0000, 0x8000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF000, 0xF000, 0x1000, 0x1000, 0x1000, 0x0000 }, }, {'5', { 0x0000, 0x0000, 0xF000, 0xF000, 0x8000, 0x8000, 0xE000, 0xF000, 0x1000, 0x1000, 0x3000, 0xE000, 0xC000, 0x0000 }, }, {'6', { 0x0000, 0x2000, 0x6000, 0xC000, 0x8000, 0x8000, 0xA000, 0xF000, 0xD000, 0x9000, 0x9000, 0xF000, 0x6000, 0x0000 }, }, {'7', { 0x0000, 0xF000, 0xF000, 0x1000, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x8000, 0x0000 }, }, {'8', { 0x0000, 0x6000, 0xF000, 0x9000, 0x9000, 0xF000, 0x6000, 0x6000, 0xF000, 0x9000, 0x9000, 0xF000, 0x6000, 0x0000 }, }, {'9', { 0x0000, 0x0000, 0x6000, 0xF000, 0x9000, 0x9000, 0xF000, 0x7000, 0x1000, 0x1000, 0x3000, 0x6000, 0x4000, 0x0000 }, }, {':', { 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000, 0x0000 }, }, {'<', { 0x0000, 0x0000, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0xC000, 0x6000, 0x3000, 0x1800, 0x0800, 0x0000, 0x0000 }, }, {'=', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x0000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0x6000, 0xF000, 0x9000, 0x1000, 0x1000, 0x3000, 0x2000, 0x2000, 0x0000, 0x0000, 0x2000, 0x2000, 0x0000 }, }, {'@', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xB800, 0xB800, 0xB000, 0x8000, 0xC000, 0x7800, 0x3800, 0x0000, 0x0000 }, }, {'A', { 0x0000, 0x0000, 0x6000, 0xF000, 0x9000, 0x9000, 0x9000, 0xF000, 0xF000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'B', { 0x0000, 0x0000, 0xE000, 0xF000, 0x9000, 0x9000, 0xE000, 0xE000, 0x9000, 0x9000, 0xF000, 0xE000, 0x0000, 0x0000 }, }, {'C', { 0x0000, 0x0000, 0x6000, 0xF000, 0x9000, 0x8000, 0x8000, 0x8000, 0x8000, 0x9000, 0xF000, 0x6000, 0x0000, 0x0000 }, }, {'D', { 0x0000, 0x0000, 0xE000, 0xF000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF000, 0xE000, 0x0000, 0x0000 }, }, {'E', { 0x0000, 0x0000, 0xF000, 0xF000, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'F', { 0x0000, 0x0000, 0xF000, 0xF000, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'G', { 0x0000, 0x0000, 0x7000, 0xF000, 0x8000, 0x8000, 0xB000, 0xB000, 0x9000, 0x9000, 0xF000, 0x6000, 0x0000, 0x0000 }, }, {'H', { 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF000, 0xF000, 0x9000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'I', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'J', { 0x0000, 0x0000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x9000, 0x9000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'K', { 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0xB000, 0xE000, 0xE000, 0xB000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'L', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'M', { 0x0000, 0x0000, 0x8800, 0xD800, 0xF800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'N', { 0x0000, 0x0000, 0x9000, 0xD000, 0xF000, 0xB000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'O', { 0x0000, 0x0000, 0x6000, 0xF000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF000, 0x6000, 0x0000, 0x0000 }, }, {'P', { 0x0000, 0x0000, 0xE000, 0xF000, 0x9000, 0x9000, 0xF000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'Q', { 0x0000, 0x0000, 0x6000, 0xF000, 0x9000, 0x9000, 0x9000, 0xD000, 0xF000, 0xB000, 0xF000, 0x7000, 0x0000, 0x0000 }, }, {'R', { 0x0000, 0x0000, 0xE000, 0xF000, 0x9000, 0x9000, 0xF000, 0xE000, 0xA000, 0xB000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'S', { 0x0000, 0x0000, 0x7000, 0xF000, 0x8000, 0x8000, 0xE000, 0x7000, 0x1000, 0x1000, 0xF000, 0xE000, 0x0000, 0x0000 }, }, {'T', { 0x0000, 0x0000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000 }, }, {'U', { 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF000, 0x6000, 0x0000, 0x0000 }, }, {'V', { 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x9000, 0xB000, 0xA000, 0xE000, 0xC000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'W', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xA800, 0xF800, 0x5000, 0x0000, 0x0000 }, }, {'X', { 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0xF000, 0x6000, 0x6000, 0xF000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'Y', { 0x0000, 0x0000, 0xA000, 0xA000, 0xA000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000 }, }, {'Z', { 0x0000, 0x0000, 0xF000, 0xF000, 0x1000, 0x1000, 0x3000, 0x6000, 0xC000, 0xC000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'[', { 0x0000, 0x0000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'\\', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {']', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'^', { 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x7000, 0x1000, 0x7000, 0xF000, 0x9000, 0xF000, 0x7000, 0x0000, 0x0000 }, }, {'b', { 0x0000, 0x0000, 0x8000, 0x8000, 0xE000, 0xF000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF000, 0xE000, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0x6000, 0x0000, 0x0000 }, }, {'d', { 0x0000, 0x0000, 0x1000, 0x1000, 0x7000, 0xF000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF000, 0x7000, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0xF000, 0x9000, 0xF000, 0xF000, 0x8000, 0xF000, 0x7000, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0x0000, 0x2000, 0x6000, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x0000, 0x7000, 0xF000, 0x9000, 0x9000, 0xB000, 0xF000, 0x5000, 0x1000, 0x7000, 0x6000, 0x0000 }, }, {'h', { 0x0000, 0x0000, 0x8000, 0x8000, 0xE000, 0xF000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'i', { 0x0000, 0x8000, 0x8000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'j', { 0x0000, 0x2000, 0x2000, 0x0000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xA000, 0xE000, 0x4000 }, }, {'k', { 0x0000, 0x0000, 0x8000, 0x8000, 0xA000, 0xA000, 0xE000, 0xC000, 0xC000, 0xE000, 0xA000, 0xA000, 0x0000, 0x0000 }, }, {'l', { 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0x0000, 0x0000, 0xD000, 0xF800, 0xA800, 0xA800, 0xA800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0x0000, 0x0000, 0xA000, 0xF000, 0xD000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0xF000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF000, 0x6000, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0x0000, 0x0000, 0xE000, 0xF000, 0x9000, 0x9000, 0x9000, 0xF000, 0xE000, 0x8000, 0x8000, 0x8000 }, }, {'q', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0xF000, 0x9000, 0x9000, 0x9000, 0xF000, 0x7000, 0x1000, 0x1000, 0x1000 }, }, {'r', { 0x0000, 0x0000, 0x0000, 0x0000, 0xB000, 0xF000, 0xC000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0xF000, 0x8000, 0xE000, 0x7000, 0x1000, 0xF000, 0xE000, 0x0000, 0x0000 }, }, {'t', { 0x0000, 0x0000, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x6000, 0x2000, 0x0000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF000, 0x7000, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x9000, 0xB000, 0xE000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xF800, 0x5000, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x0000, 0x0000, 0xA000, 0xA000, 0xE000, 0x4000, 0x4000, 0xE000, 0xA000, 0xA000, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0xD000, 0x7000, 0x2000, 0x2000, 0x6000, 0xC000, 0x8000 }, }, {'z', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF000, 0xF000, 0x3000, 0x2000, 0x6000, 0xC000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x2000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x2000, 0x0000 }, }, {'|', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {'}', { 0x0000, 0x8000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0x8000, 0x0000 }, }, {'~', { 0x0000, 0x0000, 0x0000, 0x2000, 0x7000, 0xD800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,821
C++
.cxx
117
108.564103
125
0.677531
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,209
FeldLow-14.cxx
w1hkj_fldigi/src/feld/FeldLow-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld low-14 font fntchr feldlow_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000 }, }, {'"', { 0x0000, 0xA000, 0xA000, 0xA000, 0xA000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000 }, }, {'$', { 0x2000, 0x7800, 0xF800, 0xF800, 0xA000, 0xA000, 0xF000, 0x7800, 0x2800, 0x2800, 0xF800, 0xF800, 0xF000, 0x2000 }, }, {'%', { 0x0000, 0xC800, 0xC800, 0xC800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xD800, 0x9800, 0x9800, 0x0000 }, }, {'&', { 0x4000, 0xE000, 0xE000, 0xA000, 0x4000, 0x4000, 0xE000, 0xA000, 0xB000, 0xB000, 0xF800, 0x7800, 0x7800, 0x0000 }, }, { 39, { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x2000, 0x6000, 0xE000, 0xC000, 0x8000, 0x8000, 0x8000, 0x8000, 0xC000, 0xE000, 0x6000, 0x2000, 0x0000 }, }, {')', { 0x0000, 0x8000, 0xC000, 0xE000, 0x6000, 0x2000, 0x2000, 0x2000, 0x2000, 0x6000, 0xE000, 0xC000, 0x8000, 0x0000 }, }, {'*', { 0x0000, 0x0000, 0x0000, 0x0000, 0x1000, 0x1000, 0xFE00, 0x7C00, 0x3800, 0x6C00, 0x4400, 0x0000, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x2000, 0xE000, 0xE000, 0xC000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0800, 0x0800, 0x1800, 0x1800, 0x3000, 0x3000, 0x6000, 0x6000, 0xC000, 0xC000, 0x8000, 0x8000, 0x0000 }, }, {'0', { 0x0000, 0x7000, 0xF800, 0xF800, 0x9800, 0x9800, 0xA800, 0xA800, 0xC800, 0xC800, 0xF800, 0xF800, 0x7000, 0x0000 }, }, {'1', { 0x0000, 0x2000, 0x6000, 0xE000, 0xE000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000 }, }, {'2', { 0x0000, 0xF000, 0xF800, 0xF800, 0x0800, 0x0800, 0x7800, 0xF000, 0x8000, 0x8000, 0xF800, 0xF800, 0xF800, 0x0000 }, }, {'3', { 0x0000, 0xF000, 0xF800, 0xF800, 0x0800, 0x0800, 0x3800, 0x3800, 0x0800, 0x0800, 0xF800, 0xF800, 0xF000, 0x0000 }, }, {'4', { 0x0000, 0x8000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF800, 0xF800, 0xF800, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000 }, }, {'5', { 0x0000, 0xF800, 0xF800, 0xF800, 0x8000, 0x8000, 0xF000, 0xF800, 0x0800, 0x0800, 0xF800, 0xF800, 0xF000, 0x0000 }, }, {'6', { 0x0000, 0x7800, 0xF800, 0xF800, 0x8000, 0x8000, 0xF000, 0xF800, 0x8800, 0x8800, 0xF800, 0xF800, 0x7000, 0x0000 }, }, {'7', { 0x0000, 0xF800, 0xF800, 0xF800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000 }, }, {'8', { 0x0000, 0x7000, 0xF800, 0xF800, 0x8800, 0x8800, 0x7000, 0x7000, 0x8800, 0x8800, 0xF800, 0xF800, 0x7000, 0x0000 }, }, {'9', { 0x0000, 0x7000, 0xF800, 0xF800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0800, 0x0800, 0x7800, 0x7800, 0x7000, 0x0000 }, }, {':', { 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x2000, 0xE000, 0xC000 }, }, {'<', { 0x0000, 0x0800, 0x1800, 0x3800, 0x7000, 0xE000, 0xC000, 0xC000, 0xE000, 0x7000, 0x3800, 0x1800, 0x0800, 0x0000 }, }, {'=', { 0x0000, 0xF800, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x8000, 0xC000, 0xE000, 0x7000, 0x3800, 0x1800, 0x1800, 0x3800, 0x7000, 0xE000, 0xC000, 0x8000, 0x0000 }, }, {'?', { 0x0000, 0x7000, 0xF800, 0xF800, 0x8800, 0x0800, 0x0800, 0x3800, 0x3000, 0x0000, 0x0000, 0x2000, 0x2000, 0x2000 }, }, {'@', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xB800, 0xB800, 0xB000, 0x8000, 0xC000, 0x7800, 0x3800, 0x0000, 0x0000 }, }, {'A', { 0x0000, 0x7000, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'B', { 0x0000, 0xF000, 0xF800, 0xF800, 0x8800, 0x8800, 0xF000, 0xF000, 0x8800, 0x8800, 0xF800, 0xF800, 0xF000, 0x0000 }, }, {'C', { 0x0000, 0x7800, 0xF800, 0xF800, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x7800, 0x0000 }, }, {'D', { 0x0000, 0xF000, 0xF800, 0xF800, 0x9800, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0xF800, 0xF800, 0xF000, 0x0000 }, }, {'E', { 0x0000, 0xF800, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0xF800, 0xF800, 0xF800, 0x0000 }, }, {'F', { 0x0000, 0xF800, 0xF800, 0xF800, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x0000 }, }, {'G', { 0x0000, 0x7800, 0xF800, 0xF800, 0x8000, 0x8000, 0x9800, 0x9800, 0x8800, 0x8800, 0xF800, 0xF800, 0x7000, 0x0000 }, }, {'H', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'I', { 0x0000, 0xE000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0xE000, 0x0000 }, }, {'J', { 0x0000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0x8800, 0xF800, 0xF800, 0x7000, 0x0000 }, }, {'K', { 0x0000, 0x8800, 0x8800, 0x9800, 0xB800, 0xF000, 0xE000, 0xE000, 0xF000, 0xB800, 0x9800, 0x8800, 0x8800, 0x0000 }, }, {'L', { 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0xF800, 0x0000 }, }, {'M', { 0x0000, 0x8800, 0xD800, 0xF800, 0xF800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000 }, }, {'N', { 0x0000, 0x8800, 0x8800, 0xC800, 0xC800, 0xE800, 0xE800, 0xB800, 0xB800, 0x9800, 0x9800, 0x8800, 0x8800, 0x0000 }, }, {'O', { 0x0000, 0x7000, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x7000, 0x0000 }, }, {'P', { 0x0000, 0xF000, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0xF000, 0x8000, 0x8000, 0x8000, 0x0000 }, }, {'Q', { 0x0000, 0x7000, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xF800, 0xFC00, 0x7C00, 0x0C00 }, }, {'R', { 0x0000, 0xF000, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF000, 0xF000, 0x9800, 0x9800, 0x9800, 0x0000 }, }, {'S', { 0x0000, 0x7800, 0xF800, 0xF800, 0x8000, 0x8000, 0xF000, 0x7800, 0x0800, 0x0800, 0xF800, 0xF800, 0xF000, 0x0000 }, }, {'T', { 0x0000, 0xF800, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000 }, }, {'U', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x7000, 0x0000 }, }, {'V', { 0x0000, 0x8800, 0x8800, 0x8800, 0x9800, 0x9800, 0xB000, 0xB000, 0xE000, 0xE000, 0xC000, 0xC000, 0x8000, 0x0000 }, }, {'W', { 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xA800, 0xF800, 0xF800, 0x5000, 0x0000 }, }, {'X', { 0x0000, 0x8800, 0x8800, 0xD800, 0xF800, 0x7000, 0x2000, 0x2000, 0x7000, 0xF800, 0xD800, 0x8800, 0x8800, 0x0000 }, }, {'Y', { 0x0000, 0x8800, 0x8800, 0x8800, 0xD800, 0xD800, 0x7000, 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000 }, }, {'Z', { 0x0000, 0xF800, 0xF800, 0xF800, 0x1800, 0x1000, 0x3000, 0x6000, 0x4000, 0xC000, 0xF800, 0xF800, 0xF800, 0x0000 }, }, {'[', { 0x0000, 0xE000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0xE000, 0x0000 }, }, {'\\', { 0x0000, 0x8000, 0x8000, 0xC000, 0xC000, 0x6000, 0x6000, 0x3000, 0x3000, 0x1800, 0x1800, 0x0800, 0x0800, 0x0000 }, }, {']', { 0x0000, 0xE000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0xE000, 0x0000 }, }, {'^', { 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0xF800, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0xC000, 0xC000, 0xC000, 0xE000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x7000, 0x7800, 0x7800, 0x0800, 0x7800, 0xF800, 0x8800, 0xF800, 0xF800, 0x7800, 0x0000, 0x0000 }, }, {'b', { 0x8000, 0x8000, 0x8000, 0xF000, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x7000, 0xF000, 0xF000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF000, 0xF000, 0x7000, 0x0000, 0x0000 }, }, {'d', { 0x0800, 0x0800, 0x0800, 0x7800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x7800, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0x7000, 0xF800, 0xF800, 0x8800, 0xF800, 0xF800, 0x8000, 0xF800, 0xF800, 0x7800, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0x3000, 0x7000, 0x7000, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0xE000, 0xE000, 0xE000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x7800, 0xF800, 0xF800, 0x8800, 0x8800, 0xF800, 0x7800, 0x0800, 0xF800, 0xF800, 0x7000, 0x0000 }, }, {'h', { 0x8000, 0x8000, 0x8000, 0xF000, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'i', { 0x4000, 0x4000, 0x0000, 0xC000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'j', { 0x1000, 0x1000, 0x0000, 0x3000, 0x3000, 0x3000, 0x1000, 0x1000, 0x1000, 0x9000, 0xF000, 0xF000, 0x6000, 0x0000 }, }, {'k', { 0x0000, 0x8000, 0x8000, 0x9000, 0x9000, 0xB000, 0xE000, 0xE000, 0xE000, 0xB000, 0xB000, 0x9000, 0x9000, 0x0000 }, }, {'l', { 0x0000, 0xE000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0xF800, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0xD000, 0xF800, 0xF800, 0xA800, 0xA800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0xB000, 0xF800, 0xF800, 0xC800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x7000, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0x0000, 0xF000, 0xF800, 0xF800, 0x4800, 0x4800, 0x7800, 0x7800, 0x7000, 0x4000, 0x4000, 0x4000 }, }, {'q', { 0x0000, 0x0000, 0x0000, 0x7800, 0xF800, 0xF800, 0x9000, 0x9000, 0x9000, 0xF000, 0xF000, 0x7000, 0x1000, 0x1000 }, }, {'r', { 0x0000, 0x0000, 0xD800, 0xF800, 0xF800, 0x6000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x7800, 0xF800, 0xF800, 0x8000, 0xF000, 0x7800, 0x0800, 0xF800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'t', { 0x0000, 0x4000, 0x4000, 0xE000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7000, 0x7000, 0x3000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x9800, 0xF800, 0xF800, 0x6800, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xD800, 0xF800, 0x7000, 0x2000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xA800, 0xF800, 0xF800, 0x5000, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x8800, 0xD800, 0xF800, 0x7000, 0x2000, 0x2000, 0x7000, 0xF800, 0xD800, 0x8800, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0xC800, 0xE800, 0x7800, 0x3800, 0x3000, 0x6000, 0xC000, 0xC000 }, }, {'z', { 0x0000, 0x0000, 0xF800, 0xF800, 0xF800, 0x1800, 0x3000, 0x6000, 0xC000, 0xF800, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x2000, 0x6000, 0x6000, 0x4000, 0x4000, 0xC000, 0xC000, 0xC000, 0x4000, 0x6000, 0x6000, 0x2000, 0x0000 }, }, {'|', { 0x0000, 0x8000, 0x8000, 0xC000, 0xC000, 0x6000, 0x6000, 0x3000, 0x3000, 0x1800, 0x1800, 0x0800, 0x0800, 0x0000 }, }, {'}', { 0x0000, 0x8000, 0xC000, 0xC000, 0x4000, 0x4000, 0x6000, 0x6000, 0x6000, 0x4000, 0xC000, 0xC000, 0x8000, 0x0000 }, }, {'~', { 0x0000, 0xD800, 0xF800, 0x6C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,813
C++
.cxx
117
108.495726
125
0.677485
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,210
Feld7x7n-14.cxx
w1hkj_fldigi/src/feld/Feld7x7n-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld 7x7n-14 font fntchr feld7x7n_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'"', { 0x0000, 0x0000, 0xA000, 0xA000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000, 0x0000 }, }, {'$', { 0x0000, 0x2000, 0x7800, 0x7800, 0xA000, 0xA000, 0x7000, 0x7000, 0x2800, 0x2800, 0xF000, 0xF000, 0x2000, 0x0000 }, }, {'%', { 0x0000, 0x0000, 0xC800, 0xC800, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x9800, 0x9800, 0x0000, 0x0000 }, }, {'&', { 0x0000, 0x0000, 0x4000, 0x4000, 0xE000, 0xE000, 0x6800, 0x6800, 0x9000, 0x9000, 0x7800, 0x7800, 0x0000, 0x0000 }, }, { 39, { 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x0000, 0x6000, 0x6000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {')', { 0x0000, 0x0000, 0xC000, 0xC000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'*', { 0x0000, 0x0000, 0xA800, 0xA800, 0x7000, 0x7000, 0xF800, 0xF800, 0x7000, 0x7000, 0xA800, 0xA800, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0xF800, 0xF800, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x8000, 0x8000, 0x0000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0000, 0x0800, 0x0800, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'0', { 0x0000, 0x0000, 0x6000, 0x6000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'1', { 0x0000, 0x0000, 0x6000, 0x6000, 0xA000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'2', { 0x0000, 0x0000, 0xE000, 0xE000, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'3', { 0x0000, 0x0000, 0xE000, 0xE000, 0x1000, 0x1000, 0x2000, 0x2000, 0x1000, 0x1000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'4', { 0x0000, 0x0000, 0x3000, 0x3000, 0x5000, 0x5000, 0x9000, 0x9000, 0xF000, 0xF000, 0x1000, 0x1000, 0x0000, 0x0000 }, }, {'5', { 0x0000, 0x0000, 0xF000, 0xF000, 0x8000, 0x8000, 0xE000, 0xE000, 0x1000, 0x1000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'6', { 0x0000, 0x0000, 0x7000, 0x7000, 0x8000, 0x8000, 0xE000, 0xE000, 0x9000, 0x9000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'7', { 0x0000, 0x0000, 0xF000, 0xF000, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000 }, }, {'8', { 0x0000, 0x0000, 0x6000, 0x6000, 0x9000, 0x9000, 0x6000, 0x6000, 0x9000, 0x9000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'9', { 0x0000, 0x0000, 0x6000, 0x6000, 0x9000, 0x9000, 0x7000, 0x7000, 0x1000, 0x1000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {':', { 0x0000, 0x0000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x0000, 0xC000, 0xC000, 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'<', { 0x0000, 0x0000, 0x0800, 0x0800, 0x3000, 0x3000, 0xC000, 0xC000, 0x3000, 0x3000, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {'=', { 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x0000, 0x8000, 0x8000, 0x6000, 0x6000, 0x1800, 0x1800, 0x6000, 0x6000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0x0000, 0xE000, 0xE000, 0x1000, 0x1000, 0x2000, 0x2000, 0x0000, 0x0000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'@', { 0x0000, 0x0000, 0x6000, 0x6000, 0x9000, 0x9000, 0xB000, 0xB000, 0x8000, 0x8000, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'A', { 0x0000, 0x0000, 0x6000, 0x6000, 0x9000, 0x9000, 0xF000, 0xF000, 0x9000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'B', { 0x0000, 0x0000, 0xE000, 0xE000, 0x9000, 0x9000, 0xE000, 0xE000, 0x9000, 0x9000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'C', { 0x0000, 0x0000, 0x7000, 0x7000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'D', { 0x0000, 0x0000, 0xE000, 0xE000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'E', { 0x0000, 0x0000, 0xF000, 0xF000, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'F', { 0x0000, 0x0000, 0xF000, 0xF000, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'G', { 0x0000, 0x0000, 0x7000, 0x7000, 0x8000, 0x8000, 0xB000, 0xB000, 0x9000, 0x9000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'H', { 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF000, 0xF000, 0x9000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'I', { 0x0000, 0x0000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'J', { 0x0000, 0x0000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x9000, 0x9000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'K', { 0x0000, 0x0000, 0x9000, 0x9000, 0xA000, 0xA000, 0xC000, 0xC000, 0xA000, 0xA000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'L', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'M', { 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0xD800, 0xA800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'N', { 0x0000, 0x0000, 0x9000, 0x9000, 0xD000, 0xD000, 0xB000, 0xB000, 0x9000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'O', { 0x0000, 0x0000, 0x6000, 0x6000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'P', { 0x0000, 0x0000, 0xE000, 0xE000, 0x9000, 0x9000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'Q', { 0x0000, 0x0000, 0x6000, 0x6000, 0x9000, 0x9000, 0x9000, 0x9000, 0xB000, 0xB000, 0x7000, 0x7000, 0x1000, 0x1000 }, }, {'R', { 0x0000, 0x0000, 0xE000, 0xE000, 0x9000, 0x9000, 0xE000, 0xE000, 0xA000, 0xA000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'S', { 0x0000, 0x0000, 0x7000, 0x7000, 0x8000, 0x8000, 0x6000, 0x6000, 0x1000, 0x1000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'T', { 0x0000, 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'U', { 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'V', { 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x9000, 0xA000, 0xA000, 0xC000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'W', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xA800, 0x5000, 0x5000, 0x0000, 0x0000 }, }, {'X', { 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x9000, 0x6000, 0x6000, 0x9000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'Y', { 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x6000, 0x6000, 0x2000, 0x2000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000 }, }, {'Z', { 0x0000, 0x0000, 0xF000, 0xF000, 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'[', { 0x0000, 0x0000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'\\', { 0x0000, 0x0000, 0x8000, 0x8000, 0x4000, 0x4000, 0x2000, 0x2000, 0x1000, 0x1000, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {']', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'^', { 0x0000, 0x0000, 0x2000, 0x2000, 0x5000, 0x5000, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0x0000, 0xC000, 0xC000, 0x8000, 0x8000, 0x4000, 0x4000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x1000, 0x1000, 0xF000, 0xF000, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'b', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x9000, 0x9000, 0x9000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0x7000, 0x8000, 0x8000, 0x8000, 0x8000, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'d', { 0x0000, 0x0000, 0x1000, 0x1000, 0x7000, 0x7000, 0x9000, 0x9000, 0x9000, 0x9000, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0xF000, 0xF000, 0x8000, 0x8000, 0x7000, 0x7000, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0x0000, 0x3000, 0x3000, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0x7000, 0x9000, 0x9000, 0x7000, 0x7000, 0x1000, 0x1000, 0x6000, 0x6000 }, }, {'h', { 0x0000, 0x0000, 0x8000, 0x8000, 0xE000, 0xE000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'i', { 0x4000, 0x4000, 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'j', { 0x1000, 0x1000, 0x0000, 0x0000, 0x3000, 0x3000, 0x1000, 0x1000, 0x1000, 0x1000, 0x9000, 0x9000, 0x6000, 0x6000 }, }, {'k', { 0x0000, 0x0000, 0x9000, 0x9000, 0xA000, 0xA000, 0xC000, 0xC000, 0xA000, 0xA000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'l', { 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0x0000, 0x0000, 0xD000, 0xD000, 0xA800, 0xA800, 0xA800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0x0000, 0x0000, 0xE000, 0xE000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x9000, 0x9000, 0x9000, 0x9000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0x0000, 0x0000, 0xE000, 0xE000, 0x9000, 0x9000, 0x9000, 0x9000, 0xE000, 0xE000, 0x8000, 0x8000 }, }, {'q', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0x7000, 0x9000, 0x9000, 0x9000, 0x9000, 0x7000, 0x7000, 0x1000, 0x1000 }, }, {'r', { 0x0000, 0x0000, 0x0000, 0x0000, 0xB000, 0xB000, 0xC000, 0xC000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0x7000, 0xC000, 0xC000, 0x3000, 0x3000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'t', { 0x0000, 0x0000, 0x4000, 0x4000, 0xE000, 0xE000, 0x4000, 0x4000, 0x4000, 0x4000, 0x3000, 0x3000, 0x0000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x0000, 0x0000, 0x9000, 0x9000, 0xA000, 0xA000, 0xC000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0x5000, 0x5000, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x0000, 0x0000, 0x9000, 0x9000, 0x6000, 0x6000, 0x6000, 0x6000, 0x9000, 0x9000, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x0000, 0x0000, 0x9000, 0x9000, 0x5000, 0x5000, 0x2000, 0x2000, 0x2000, 0x2000, 0x4000, 0x4000 }, }, {'z', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF000, 0xF000, 0x2000, 0x2000, 0x4000, 0x4000, 0xF000, 0xF000, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x0000, 0x6000, 0x6000, 0x4000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000, 0x6000, 0x6000, 0x0000, 0x0000 }, }, {'|', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'}', { 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0x4000, 0x6000, 0x6000, 0x4000, 0x4000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'~', { 0x0000, 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x5000, 0x5000, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,815
C++
.cxx
117
108.512821
125
0.677536
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,211
FeldReal-14.cxx
w1hkj_fldigi/src/feld/FeldReal-14.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // feld real-14 font fntchr feldreal_14[] = { {' ', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'!', { 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'"', { 0x0000, 0x9000, 0x9000, 0xD800, 0x4800, 0x4800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'#', { 0x0000, 0x0000, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0xF800, 0xF800, 0x5000, 0x5000, 0x0000, 0x0000 }, }, {'$', { 0x0000, 0x2000, 0x7800, 0xF800, 0xA000, 0xA000, 0xF000, 0x7800, 0x2800, 0x2800, 0xF800, 0xF000, 0x2000, 0x0000 }, }, {'%', { 0x0000, 0xC400, 0xC400, 0xC400, 0x0C00, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x8C00, 0x8C00, 0x8C00, 0x0000 }, }, {'&', { 0x0000, 0x4000, 0xE000, 0xA000, 0xA000, 0x4000, 0x4000, 0xA800, 0xA800, 0x9000, 0x9000, 0xF800, 0x7800, 0x0000 }, }, { 39, { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x4000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'(', { 0x0000, 0x2000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x2000, 0x0000 }, }, {')', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000 }, }, {'*', { 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x0000, 0x0000 }, }, {'+', { 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000 }, }, {',', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0x4000, 0xC000, 0x8000, 0x0000 }, }, {'-', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'.', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000 }, }, {'/', { 0x0000, 0x0800, 0x0800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'0', { 0x0000, 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'1', { 0x0000, 0x0000, 0x2000, 0x6000, 0xE000, 0xA000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'2', { 0x0000, 0x0000, 0x6000, 0xF000, 0x9000, 0x1000, 0x3000, 0x2000, 0x4000, 0xC000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'3', { 0x0000, 0x7000, 0x7000, 0x1000, 0x1000, 0x3000, 0x3800, 0x0800, 0x0800, 0x1800, 0x3000, 0xE000, 0xC000, 0x0000 }, }, {'4', { 0x0000, 0x8000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xF800, 0xF800, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000 }, }, {'5', { 0x0000, 0x3800, 0x3800, 0x2000, 0x2000, 0x3000, 0x3800, 0x0800, 0x0800, 0x1800, 0xF000, 0xE000, 0x0000, 0x0000 }, }, {'6', { 0x0000, 0x2000, 0x6000, 0xC000, 0x8000, 0x8000, 0xB000, 0xF800, 0xC800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'7', { 0x0000, 0xF800, 0xF800, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'8', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xD800, 0x7000, 0x7000, 0xD800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000 }, }, {'9', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0x8800, 0xE800, 0x6800, 0x0800, 0x1800, 0x3000, 0x6000, 0x4000, 0x0000 }, }, {':', { 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x0000 }, }, {';', { 0x0000, 0x0000, 0x0000, 0x0000, 0xC000, 0xC000, 0xC000, 0x0000, 0x0000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000 }, }, {'<', { 0x0000, 0x0000, 0x0800, 0x1800, 0x3000, 0x6000, 0xC000, 0xC000, 0x6000, 0x3000, 0x1800, 0x0800, 0x0000, 0x0000 }, }, {'=', { 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0xF800, 0xF800, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'>', { 0x0000, 0x0000, 0x8000, 0xC000, 0x6000, 0x3000, 0x1800, 0x1800, 0x3000, 0x6000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'?', { 0x0000, 0xF000, 0xF000, 0x1000, 0x1000, 0x3000, 0x2000, 0x2000, 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0x0000 }, }, {'@', { 0x0000, 0x7000, 0xF800, 0x8800, 0x8800, 0xB800, 0xB800, 0xB000, 0x8000, 0xC000, 0x7800, 0x3800, 0x0000, 0x0000 }, }, {'A', { 0x0000, 0x0000, 0x7000, 0xF800, 0xD800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'B', { 0x0000, 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x7000, 0x7000, 0x4800, 0x4800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'C', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'D', { 0x0000, 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'E', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'F', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'G', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0x9800, 0x9800, 0x8800, 0x8800, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'H', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'I', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'J', { 0x0000, 0x0000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0x8800, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'K', { 0x0000, 0x0000, 0x8800, 0x8800, 0x9800, 0x9000, 0xE000, 0xE000, 0xB000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'L', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'M', { 0x0000, 0x0000, 0x8800, 0xD800, 0xF800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'N', { 0x0000, 0x0000, 0x8800, 0xC800, 0xC800, 0xE800, 0xA800, 0xB800, 0x9800, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'O', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'P', { 0x0000, 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x7800, 0x7000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'Q', { 0x0000, 0x0000, 0xF000, 0xF000, 0x9000, 0x9000, 0x9000, 0x9000, 0xB000, 0xB000, 0xF800, 0xF800, 0x0800, 0x0800 }, }, {'R', { 0x0000, 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0xF800, 0xF000, 0x9000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'S', { 0x0000, 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0xF000, 0x7800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'T', { 0x0000, 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'U', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'V', { 0x0000, 0x0000, 0x8800, 0x8800, 0x9800, 0x9000, 0xB000, 0xA000, 0xE000, 0xC000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'W', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xA800, 0xF800, 0x5000, 0x0000, 0x0000 }, }, {'X', { 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'Y', { 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0x5000, 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'Z', { 0x0000, 0x0000, 0xF800, 0xF800, 0x1800, 0x1000, 0x3000, 0x6000, 0x4000, 0xC000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'[', { 0x0000, 0x0000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'\\', { 0x0000, 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000 }, }, {']', { 0x0000, 0x0000, 0xE000, 0xE000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'^', { 0x0000, 0x2000, 0x2000, 0x7000, 0x5000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'_', { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFE00, 0xFE00, 0x0000, 0x0000 }, }, {'`', { 0x0000, 0x4000, 0x4000, 0xC000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, }, {'a', { 0x0000, 0x0000, 0x7000, 0xF800, 0xD800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'b', { 0x0000, 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x7000, 0x7000, 0x4800, 0x4800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'c', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'d', { 0x0000, 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'e', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'f', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0xE000, 0xE000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'g', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8000, 0x8000, 0x9800, 0x9800, 0x8800, 0x8800, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'h', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'i', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000 }, }, {'j', { 0x0000, 0x0000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x8800, 0x8800, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'k', { 0x0000, 0x0000, 0x8800, 0x8800, 0x9800, 0x9000, 0xE000, 0xE000, 0xB000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'l', { 0x0000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'m', { 0x0000, 0x0000, 0x8800, 0xD800, 0xF800, 0xA800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'n', { 0x0000, 0x0000, 0x8800, 0xC800, 0xC800, 0xE800, 0xA800, 0xB800, 0x9800, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'o', { 0x0000, 0x0000, 0xF800, 0xF800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'p', { 0x0000, 0x0000, 0xF000, 0xF800, 0x4800, 0x4800, 0x7800, 0x7000, 0x4000, 0x4000, 0xE000, 0xE000, 0x0000, 0x0000 }, }, {'q', { 0x0000, 0x0000, 0xF000, 0xF000, 0x9000, 0x9000, 0x9000, 0x9000, 0xB000, 0xB000, 0xF800, 0xF800, 0x0800, 0x0800 }, }, {'r', { 0x0000, 0x0000, 0xF000, 0xF800, 0x8800, 0x8800, 0xF800, 0xF000, 0x9000, 0x9800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'s', { 0x0000, 0x0000, 0x7800, 0xF800, 0x8000, 0x8000, 0xF000, 0x7800, 0x0800, 0x0800, 0xF800, 0xF000, 0x0000, 0x0000 }, }, {'t', { 0x0000, 0x0000, 0xF800, 0xF800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'u', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xF800, 0x7000, 0x0000, 0x0000 }, }, {'v', { 0x0000, 0x0000, 0x8800, 0x8800, 0x9800, 0x9000, 0xB000, 0xA000, 0xE000, 0xC000, 0xC000, 0x8000, 0x0000, 0x0000 }, }, {'w', { 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x8800, 0xA800, 0xA800, 0xA800, 0xA800, 0xF800, 0x5000, 0x0000, 0x0000 }, }, {'x', { 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0x7000, 0x2000, 0x2000, 0x7000, 0xD800, 0x8800, 0x8800, 0x0000, 0x0000 }, }, {'y', { 0x0000, 0x0000, 0x8800, 0x8800, 0xD800, 0x5000, 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000 }, }, {'z', { 0x0000, 0x0000, 0xF800, 0xF800, 0x1800, 0x1000, 0x3000, 0x6000, 0x4000, 0xC000, 0xF800, 0xF800, 0x0000, 0x0000 }, }, {'{', { 0x0000, 0x2000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x2000, 0x0000 }, }, {'|', { 0x0000, 0x8000, 0x8000, 0xC000, 0x4000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0800, 0x0000, 0x0000 }, }, {'}', { 0x0000, 0x8000, 0xC000, 0x4000, 0x4000, 0x4000, 0x6000, 0x6000, 0x4000, 0x4000, 0x4000, 0xC000, 0x8000, 0x0000 }, }, {'~', { 0x0000, 0x2000, 0x7000, 0xD800, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, } };
12,815
C++
.cxx
117
108.512821
125
0.677536
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,212
rsid.cxx
w1hkj_fldigi/src/rsid/rsid.cxx
// ---------------------------------------------------------------------------- // // rsid.cxx // // Copyright (C) 2008-2012 // Dave Freese, W1HKJ // Copyright (C) 2009-2012 // Stelios Bounanos, M0GLD // Copyright (C) 2012 // John Douyere, VK2ETA // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <string> #include <cmath> #include <cstring> #include <float.h> #include <samplerate.h> #include "rsid.h" #include "filters.h" #include "misc.h" #include "trx.h" #include "fl_digi.h" #include "configuration.h" #include "confdialog.h" #include "qrunner.h" #include "notify.h" #include "debug.h" #include "main.h" #include "arq_io.h" #include "data_io.h" #include "audio_alert.h" LOG_FILE_SOURCE(debug::LOG_MODEM); #include "rsid_defs.cxx" #define RSWINDOW 1 const int cRsId::Squares[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15, 0, 2, 4, 6, 8,10,12,14, 9,11,13,15, 1, 3, 5, 7, 0, 3, 6, 5,12,15,10, 9, 1, 2, 7, 4,13,14,11, 8, 0, 4, 8,12, 9,13, 1, 5,11,15, 3, 7, 2, 6,10,14, 0, 5,10,15,13, 8, 7, 2, 3, 6, 9,12,14,11, 4, 1, 0, 6,12,10, 1, 7,13,11, 2, 4,14, 8, 3, 5,15, 9, 0, 7,14, 9, 5, 2,11,12,10,13, 4, 3,15, 8, 1, 6, 0, 8, 9, 1,11, 3, 2,10,15, 7, 6,14, 4,12,13, 5, 0, 9,11, 2,15, 6, 4,13, 7,14,12, 5, 8, 1, 3,10, 0,10,13, 7, 3, 9,14, 4, 6,12,11, 1, 5,15, 8, 2, 0,11,15, 4, 7,12, 8, 3,14, 5, 1,10, 9, 2, 6,13, 0,12, 1,13, 2,14, 3,15, 4, 8, 5, 9, 6,10, 7,11, 0,13, 3,14, 6,11, 5, 8,12, 1,15, 2,10, 7, 9, 4, 0,14, 5,11,10, 4,15, 1,13, 3, 8, 6, 7, 9, 2,12, 0,15, 7, 8,14, 1, 9, 6, 5,10, 2,13,11, 4,12, 3 }; const int cRsId::indices[] = { 2, 4, 8, 9, 11, 15, 7, 14, 5, 10, 13, 3 }; cRsId::cRsId() { int error; src_state = src_new(progdefaults.sample_converter, 1, &error); if (error) { LOG_ERROR("src_new error %d: %s", error, src_strerror(error)); abort(); } src_data.end_of_input = 0; reset(); rsfft = new g_fft<rs_fft_type>(RSID_ARRAY_SIZE); memset(fftwindow, 0, sizeof(fftwindow)); if (RSWINDOW) { for (int i = 0; i < RSID_ARRAY_SIZE; i++) // fftwindow[i] = blackman ( 1.0 * i / RSID_ARRAY_SIZE ); fftwindow[i] = hamming ( 1.0 * i / RSID_ARRAY_SIZE ); // fftwindow[i] = hanning ( 1.0 * i / RSID_ARRAY_SIZE ); // fftwindow[i] = 1.0; } pCodes1 = new unsigned char[rsid_ids_size1 * RSID_NSYMBOLS]; memset(pCodes1, 0, sizeof(pCodes1) * sizeof(unsigned char)); pCodes2 = new unsigned char[rsid_ids_size2 * RSID_NSYMBOLS]; memset(pCodes2, 0, sizeof(pCodes2) * sizeof(unsigned char)); // Initialization of assigned mode/submode IDs. unsigned char* c; for (int i = 0; i < rsid_ids_size1; i++) { c = pCodes1 + i * RSID_NSYMBOLS; Encode(rsid_ids_1[i].rs, c); } for (int i = 0; i < rsid_ids_size2; i++) { c = pCodes2 + i * RSID_NSYMBOLS; Encode(rsid_ids_2[i].rs, c); } #if 0 printf("pcode 1\n"); printf(",rs, name, mode,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14\n"); for (int i = 0; i < rsid_ids_size1; i++) { printf("%d,%d,%s,%d", i, rsid_ids_1[i].rs, rsid_ids_1[i].name, rsid_ids_1[i].mode); for (int j = 0; j < RSID_NSYMBOLS + 1; j++) printf(",%d", pCodes1[i*(RSID_NSYMBOLS + 1) + j]); printf("\n"); } printf("\npcode 2\n"); printf(", rs, name, mode,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14\n"); for (int i = 0; i < rsid_ids_size2; i++) { printf("%d,%d,%s,%d", i, rsid_ids_2[i].rs, rsid_ids_2[i].name, rsid_ids_2[i].mode); for (int j = 0; j < RSID_NSYMBOLS + 1; j++) printf(",%d", pCodes2[i*(RSID_NSYMBOLS+ 1) + j]); printf("\n"); } #endif nBinLow = 3; nBinHigh = RSID_FFT_SIZE - 32; // - RSID_NTIMES - 2 outbuf = 0; symlen = 0; reset(); } cRsId::~cRsId() { delete [] pCodes1; delete [] pCodes2; delete [] outbuf; delete rsfft; src_delete(src_state); } void cRsId::reset() { iPrevDistance = iPrevDistance2 = 99; bPrevTimeSliceValid = bPrevTimeSliceValid2 = false; found1 = found2 = false; rsid_secondary_time_out = 0; memset(aInputSamples, 0, (RSID_ARRAY_SIZE * 2) * sizeof(float)); memset(aFFTAmpl, 0, RSID_FFT_SIZE * sizeof(rs_fft_type)); memset(fft_buckets, 0, RSID_NTIMES * RSID_FFT_SIZE * sizeof(int)); for (int n = 0; n < RSID_ARRAY_SIZE; n++) aFFTcmplx[n] = cmplx(0,0); int error = src_reset(src_state); if (error) LOG_ERROR("src_reset error %d: %s", error, src_strerror(error)); src_data.src_ratio = 0.0; inptr = RSID_FFT_SIZE; hamming_resolution = progdefaults.RsID_label_type; } void cRsId::Encode(int code, unsigned char *rsid) { rsid[0] = code >> 8; rsid[1] = (code >> 4) & 0x0f; rsid[2] = code & 0x0f; for (int i = 3; i < RSID_NSYMBOLS; i++) rsid[i] = 0; for (int i = 0; i < 12; i++) { for (int j = RSID_NSYMBOLS - 1; j > 0; j--) rsid[j] = rsid[j - 1] ^ Squares[(rsid[j] << 4) + indices[i]]; rsid[0] = Squares[(rsid[0] << 4) + indices[i]]; } } void cRsId::CalculateBuckets(const rs_fft_type *pSpectrum, int iBegin, int iEnd) { rs_fft_type Amp = 0.0, AmpMax = 0.0; int iBucketMax = iBegin - 2; int j; for (int i = iBegin; i < iEnd; i += 2) { if (iBucketMax == i - 2) { AmpMax = pSpectrum[i]; iBucketMax = i; for (j = i + 2; j < i + RSID_NTIMES + 2; j += 2) { Amp = pSpectrum[j]; if (Amp > AmpMax) { AmpMax = Amp; iBucketMax = j; } } } else { j = i + RSID_NTIMES; Amp = pSpectrum[j]; if (Amp > AmpMax) { AmpMax = Amp; iBucketMax = j; } } fft_buckets[RSID_NTIMES - 1][i] = (iBucketMax - i) >> 1; } } void cRsId::receive(const float* buf, size_t len) { if (len == 0) return; int srclen = static_cast<int>(len); double src_ratio = RSID_SAMPLE_RATE / active_modem->get_samplerate(); if (rsid_secondary_time_out > 0) { rsid_secondary_time_out -= 1.0 * len / active_modem->get_samplerate(); if (rsid_secondary_time_out <= 0) { LOG_INFO("%s", "Secondary RsID timed out"); reset(); } } if (src_data.src_ratio != src_ratio) { src_data.src_ratio = src_ratio; src_set_ratio(src_state, src_data.src_ratio); } while (srclen > 0) { src_data.data_in = const_cast<float*>(buf); src_data.input_frames = srclen; src_data.data_out = &aInputSamples[inptr]; src_data.output_frames = RSID_ARRAY_SIZE * 2 - inptr; src_data.input_frames_used = 0; int error = src_process(src_state, &src_data); if (unlikely(error)) { LOG_ERROR("src_process error %d: %s", error, src_strerror(error)); return; } size_t gend = src_data.output_frames_gen; size_t used = src_data.input_frames_used; inptr += gend; buf += used; srclen -= used; while (inptr >= RSID_ARRAY_SIZE) { search(); memmove(&aInputSamples[0], &aInputSamples[RSID_FFT_SAMPLES], (RSID_BUFFER_SIZE - RSID_FFT_SAMPLES)*sizeof(float)); inptr -= RSID_FFT_SAMPLES; } } } void cRsId::search(void) { if (progdefaults.rsidWideSearch) { nBinLow = 3; nBinHigh = RSID_FFT_SIZE - 32; } else { float centerfreq = active_modem->get_freq(); float bpf = 1.0 * RSID_ARRAY_SIZE / RSID_SAMPLE_RATE; nBinLow = (int)((centerfreq - 100.0 * 2) * bpf); nBinHigh = (int)((centerfreq + 100.0 * 2) * bpf); } if (nBinLow < 3) nBinLow = 3; if (nBinHigh > RSID_FFT_SIZE - 32) nBinHigh = RSID_FFT_SIZE - 32; bool bReverse = !(wf->Reverse() ^ wf->USB()); if (bReverse) { nBinLow = RSID_FFT_SIZE - nBinHigh; nBinHigh = RSID_FFT_SIZE - nBinLow; } if (RSWINDOW) { for (int i = 0; i < RSID_ARRAY_SIZE; i++) aFFTcmplx[i] = cmplx(aInputSamples[i] * fftwindow[i], 0); } else { for (int i = 0; i < RSID_ARRAY_SIZE; i++) aFFTcmplx[i] = cmplx(aInputSamples[i], 0); } rsfft->ComplexFFT(aFFTcmplx); memset(aFFTAmpl, 0, sizeof(aFFTAmpl)); static const double pscale = 4.0 / (RSID_FFT_SIZE * RSID_FFT_SIZE); if (unlikely(bReverse)) { for (int i = 0; i < RSID_FFT_SIZE; i++) aFFTAmpl[RSID_FFT_SIZE - 1 - i] = norm(aFFTcmplx[i]) * pscale; } else { for (int i = 0; i < RSID_FFT_SIZE; i++) aFFTAmpl[i] = norm(aFFTcmplx[i]) * pscale; } int bucket_low = 3; int bucket_high = RSID_FFT_SIZE - 32; if (bReverse) { bucket_low = RSID_FFT_SIZE - bucket_high; bucket_high = RSID_FFT_SIZE - bucket_low; } memmove(fft_buckets, &(fft_buckets[1][0]), (RSID_NTIMES - 1) * RSID_FFT_SIZE * sizeof(int)); memset(&(fft_buckets[RSID_NTIMES - 1][0]), 0, RSID_FFT_SIZE * sizeof(int)); CalculateBuckets ( aFFTAmpl, bucket_low, bucket_high - RSID_NTIMES); CalculateBuckets ( aFFTAmpl, bucket_low + 1, bucket_high - RSID_NTIMES); int symbol_out_1 = -1; int bin_out_1 = -1; int symbol_out_2 = -1; int bin_out_2 = -1; if (rsid_secondary_time_out <= 0) { found1 = search_amp(bin_out_1, symbol_out_1, pCodes1); if (found1) { if (symbol_out_1 != RSID_ESCAPE) { if (bReverse) bin_out_1 = 1024 - bin_out_1 - 31; apply(bin_out_1, symbol_out_1, 0); reset(); return; } else { // 10 rsid_gap + 15 symbols + 2 for timing errors rsid_secondary_time_out = 27 * RSID_SYMLEN; return; } } else return; } found2 = search_amp(bin_out_2, symbol_out_2, pCodes2); if (found2) { if (symbol_out_2 != RSID_NONE2) { if (bReverse) bin_out_2 = 1024 - bin_out_2 - 31; apply(bin_out_2, symbol_out_2, 1); } reset(); } } void cRsId::setup_mode(int iSymbol) { switch (iSymbol) { case RSID_RTTY_ASCII_7: progdefaults.rtty_baud = 5; progdefaults.rtty_bits = 1; progdefaults.rtty_shift = 9; REQ(&set_rtty_tab_widgets); break; case RSID_RTTY_ASCII_8: progdefaults.rtty_baud = 5; progdefaults.rtty_bits = 2; progdefaults.rtty_shift = 9; REQ(&set_rtty_tab_widgets); break; case RSID_RTTY_45: progdefaults.rtty_baud = 1; progdefaults.rtty_bits = 0; progdefaults.rtty_shift = 3; REQ(&set_rtty_tab_widgets); break; case RSID_RTTY_50: progdefaults.rtty_baud = 2; progdefaults.rtty_bits = 0; progdefaults.rtty_shift = 3; REQ(&set_rtty_tab_widgets); break; case RSID_RTTY_75: progdefaults.rtty_baud = 4; progdefaults.rtty_bits = 0; progdefaults.rtty_shift = 9; REQ(&set_rtty_tab_widgets); break; // DominoEX / FEC case RSID_DOMINOEX_4: case RSID_DOMINOEX_5: case RSID_DOMINOEX_8: case RSID_DOMINOEX_11: case RSID_DOMINOEX_16: case RSID_DOMINOEX_22: progdefaults.DOMINOEX_FEC = false; REQ(&set_dominoex_tab_widgets); break; case RSID_DOMINOEX_4_FEC: case RSID_DOMINOEX_5_FEC: case RSID_DOMINOEX_8_FEC: case RSID_DOMINOEX_11_FEC: case RSID_DOMINOEX_16_FEC: case RSID_DOMINOEX_22_FEC: progdefaults.DOMINOEX_FEC = true; REQ(&set_dominoex_tab_widgets); break; // olivia parameters case RSID_OLIVIA_4_125: progdefaults.oliviatones = 1; progdefaults.oliviabw = 0; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_4_250: progdefaults.oliviatones = 1; progdefaults.oliviabw = 1; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_4_500: progdefaults.oliviatones = 1; progdefaults.oliviabw = 2; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_4_1000: progdefaults.oliviatones = 1; progdefaults.oliviabw = 3; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_4_2000: progdefaults.oliviatones = 1; progdefaults.oliviabw = 4; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_8_125: progdefaults.oliviatones = 2; progdefaults.oliviabw = 0; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_8_250: progdefaults.oliviatones = 2; progdefaults.oliviabw = 1; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_8_500: progdefaults.oliviatones = 2; progdefaults.oliviabw = 2; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_8_1000: progdefaults.oliviatones = 2; progdefaults.oliviabw = 3; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_8_2000: progdefaults.oliviatones = 2; progdefaults.oliviabw = 4; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_16_500: progdefaults.oliviatones = 3; progdefaults.oliviabw = 2; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_16_1000: progdefaults.oliviatones = 3; progdefaults.oliviabw = 3; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_16_2000: progdefaults.oliviatones = 3; progdefaults.oliviabw = 4; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_32_1000: progdefaults.oliviatones = 4; progdefaults.oliviabw = 3; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_32_2000: progdefaults.oliviatones = 4; progdefaults.oliviabw = 4; REQ(&set_olivia_tab_widgets); break; case RSID_OLIVIA_64_2000: progdefaults.oliviatones = 5; progdefaults.oliviabw = 4; REQ(&set_olivia_tab_widgets); break; // contestia parameters case RSID_CONTESTIA_4_125: progdefaults.contestiatones = 1; progdefaults.contestiabw = 0; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_4_250: progdefaults.contestiatones = 1; progdefaults.contestiabw = 1; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_4_500: progdefaults.contestiatones = 1; progdefaults.contestiabw = 2; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_4_1000: progdefaults.contestiatones = 1; progdefaults.contestiabw = 3; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_4_2000: progdefaults.contestiatones = 1; progdefaults.contestiabw = 4; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_8_125: progdefaults.contestiatones = 2; progdefaults.contestiabw = 0; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_8_250: progdefaults.contestiatones = 2; progdefaults.contestiabw = 1; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_8_500: progdefaults.contestiatones = 2; progdefaults.contestiabw = 2; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_8_1000: progdefaults.contestiatones = 2; progdefaults.contestiabw = 3; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_8_2000: progdefaults.contestiatones = 2; progdefaults.contestiabw = 4; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_16_500: progdefaults.contestiatones = 3; progdefaults.contestiabw = 2; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_16_1000: progdefaults.contestiatones = 3; progdefaults.contestiabw = 3; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_16_2000: progdefaults.contestiatones = 3; progdefaults.contestiabw = 4; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_32_1000: progdefaults.contestiatones = 4; progdefaults.contestiabw = 3; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_32_2000: progdefaults.contestiatones = 4; progdefaults.contestiabw = 4; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_64_500: progdefaults.contestiatones = 5; progdefaults.contestiabw = 2; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_64_1000: progdefaults.contestiatones = 5; progdefaults.contestiabw = 3; REQ(&set_contestia_tab_widgets); break; case RSID_CONTESTIA_64_2000: progdefaults.contestiatones = 5; progdefaults.contestiabw = 4; REQ(&set_contestia_tab_widgets); break; default: break; } // switch (iSymbol) } void cRsId::apply(int iBin, int iSymbol, int extended) { ENSURE_THREAD(TRX_TID); double rsidfreq = 0, currfreq = 0; int n, mbin = NUM_MODES; int tblsize; const RSIDs *p_rsid; if (extended) { tblsize = rsid_ids_size2; p_rsid = rsid_ids_2; } else { tblsize = rsid_ids_size1; p_rsid = rsid_ids_1; } currfreq = active_modem->get_freq(); rsidfreq = (iBin + RSID_NSYMBOLS - 0.5) * RSID_SAMPLE_RATE / 2048.0; for (n = 0; n < tblsize; n++) { if (p_rsid[n].rs == iSymbol) { mbin = p_rsid[n].mode; break; } } if (mbin == NUM_MODES) { char msg[50]; if (n < tblsize) // RSID known but unimplemented snprintf(msg, sizeof(msg), "RSID: %s unimplemented", p_rsid[n].name); else // RSID unknown; shouldn't happen snprintf(msg, sizeof(msg), "RSID: code %d unknown", iSymbol); put_status(msg, 4.0); LOG_VERBOSE("%s", msg); return; } if (progdefaults.rsid_rx_modes.test(mbin)) { char msg[50]; snprintf(msg, sizeof(msg), "RSID: %s @ %0.1f Hz", p_rsid[n].name, rsidfreq); LOG_VERBOSE("%s", msg); } else { char msg[50]; snprintf(msg, sizeof(msg), "Ignoring RSID: %s @ %0.1f Hz", p_rsid[n].name, rsidfreq); LOG_DEBUG("%s", msg); return; } if (progdefaults.ENABLE_RSID_MATCH) audio_alert->alert(progdefaults.RSID_MATCH); if (mailclient || mailserver) REQ(pskmail_notify_rsid, mbin); if (progdefaults.rsid_auto_disable) REQ(toggleRSID); if (iSymbol == RSID_EOT) { if (progdefaults.rsid_eot_squelch) { REQ(rsid_eot_squelch); if (!progdefaults.disable_rsid_warning_dialog_box) REQ(notify_rsid_eot, mbin, rsidfreq); } return; } if (!progdefaults.disable_rsid_warning_dialog_box) REQ(notify_rsid, mbin, rsidfreq); if (progdefaults.rsid_notify_only) { if (data_io_enabled == KISS_IO) { bcast_rsid_kiss_frame(rsidfreq, mbin, (int) active_modem->get_txfreq_woffset(), active_modem->get_mode(), RSID_KISS_NOTIFY); } return; } if (progdefaults.rsid_mark) // mark current modem & freq REQ(note_qrg, false, "\nBefore RSID: ", "\n\n", active_modem->get_mode(), 0LL, currfreq); if(active_modem) // Currently only effects Olivia, Contestia and MT63. active_modem->rx_flush(); setup_mode(iSymbol); if (progdefaults.rsid_squelch) REQ(init_modem_squelch, mbin, progdefaults.disable_rsid_freq_change ? currfreq : rsidfreq); else REQ(init_modem, mbin, progdefaults.disable_rsid_freq_change ? currfreq : rsidfreq); } inline int cRsId::HammingDistance(int iBucket, unsigned char *p2) { int dist = 0; for (int i = 0, j = 1; i < RSID_NSYMBOLS; i++, j += 2) { if (fft_buckets[j][iBucket] != p2[i]) { ++dist; if (dist > hamming_resolution) break; } } return dist; } bool cRsId::search_amp( int &bin_out, int &symbol_out, unsigned char *pcode) { int i, j; int iDistanceMin = 1000; // infinity int iDistance = 1000; int iBin = -1; int iSymbol = -1; int tblsize; const RSIDs *prsid; if (pcode == pCodes1) { tblsize = rsid_ids_size1; prsid = rsid_ids_1; } else { tblsize = rsid_ids_size2; prsid = rsid_ids_2; } unsigned char *pc = 0; for (i = 0; i < tblsize; i++) { pc = pcode + i * RSID_NSYMBOLS; for (j = nBinLow; j < nBinHigh - RSID_NTIMES; j++) { iDistance = HammingDistance(j, pc); if (iDistance < iDistanceMin) { iDistanceMin = iDistance; iSymbol = prsid[i].rs; iBin = j; if (iDistanceMin == 0) break; } } } if (iDistanceMin <= hamming_resolution) { symbol_out = iSymbol; bin_out = iBin; return true; } return false; } //============================================================================= // transmit rsid code for current mode //============================================================================= bool cRsId::assigned(trx_mode mode) { rmode = RSID_NONE; rmode2 = RSID_NONE2; switch (mode) { case MODE_EOT : rmode = RSID_EOT; std::cout << "send RSID_EOT" << std::endl; return true; case MODE_RTTY : if (progdefaults.rtty_baud == 5 && progdefaults.rtty_bits == 1 && progdefaults.rtty_shift == 9) rmode = RSID_RTTY_ASCII_7; else if (progdefaults.rtty_baud == 5 && progdefaults.rtty_bits == 1 && progdefaults.rtty_shift == 9) rmode = RSID_RTTY_ASCII_8; else if (progdefaults.rtty_baud == 1 && progdefaults.rtty_bits == 0 && progdefaults.rtty_shift == 3) rmode = RSID_RTTY_45; else if (progdefaults.rtty_baud == 2 && progdefaults.rtty_bits == 0 && progdefaults.rtty_shift == 3) rmode = RSID_RTTY_50; else if (progdefaults.rtty_baud == 4 && progdefaults.rtty_bits == 0 && progdefaults.rtty_shift == 9) rmode = RSID_RTTY_75; else return false; return true; break; case MODE_OLIVIA: case MODE_OLIVIA_4_250: case MODE_OLIVIA_8_250: case MODE_OLIVIA_4_500: case MODE_OLIVIA_8_500: case MODE_OLIVIA_16_500: case MODE_OLIVIA_8_1000: case MODE_OLIVIA_16_1000: case MODE_OLIVIA_32_1000: case MODE_OLIVIA_64_2000: if (progdefaults.oliviatones == 1 && progdefaults.oliviabw == 0) rmode = RSID_OLIVIA_4_125; else if (progdefaults.oliviatones == 1 && progdefaults.oliviabw == 1) rmode = RSID_OLIVIA_4_250; else if (progdefaults.oliviatones == 1 && progdefaults.oliviabw == 2) rmode = RSID_OLIVIA_4_500; else if (progdefaults.oliviatones == 1 && progdefaults.oliviabw == 3) rmode = RSID_OLIVIA_4_1000; else if (progdefaults.oliviatones == 1 && progdefaults.oliviabw == 4) rmode = RSID_OLIVIA_4_2000; else if (progdefaults.oliviatones == 2 && progdefaults.oliviabw == 0) rmode = RSID_OLIVIA_8_125; else if (progdefaults.oliviatones == 2 && progdefaults.oliviabw == 1) rmode = RSID_OLIVIA_8_250; else if (progdefaults.oliviatones == 2 && progdefaults.oliviabw == 2) rmode = RSID_OLIVIA_8_500; else if (progdefaults.oliviatones == 2 && progdefaults.oliviabw == 3) rmode = RSID_OLIVIA_8_1000; else if (progdefaults.oliviatones == 2 && progdefaults.oliviabw == 4) rmode = RSID_OLIVIA_8_2000; else if (progdefaults.oliviatones == 3 && progdefaults.oliviabw == 2) rmode = RSID_OLIVIA_16_500; else if (progdefaults.oliviatones == 3 && progdefaults.oliviabw == 3) rmode = RSID_OLIVIA_16_1000; else if (progdefaults.oliviatones == 3 && progdefaults.oliviabw == 4) rmode = RSID_OLIVIA_16_2000; else if (progdefaults.oliviatones == 4 && progdefaults.oliviabw == 3) rmode = RSID_OLIVIA_32_1000; else if (progdefaults.oliviatones == 4 && progdefaults.oliviabw == 4) rmode = RSID_OLIVIA_32_2000; else if (progdefaults.oliviatones == 5 && progdefaults.oliviabw == 4) rmode = RSID_OLIVIA_64_2000; else return false; return true; break; case MODE_CONTESTIA: case MODE_CONTESTIA_4_125: case MODE_CONTESTIA_4_250: case MODE_CONTESTIA_8_250: case MODE_CONTESTIA_4_500: case MODE_CONTESTIA_8_500: case MODE_CONTESTIA_16_500: case MODE_CONTESTIA_8_1000: case MODE_CONTESTIA_16_1000: case MODE_CONTESTIA_32_1000: case MODE_CONTESTIA_64_2000: if (progdefaults.contestiatones == 1 && progdefaults.contestiabw == 0) rmode = RSID_CONTESTIA_4_125; else if (progdefaults.contestiatones == 1 && progdefaults.contestiabw == 1) rmode = RSID_CONTESTIA_4_250; else if (progdefaults.contestiatones == 1 && progdefaults.contestiabw == 2) rmode = RSID_CONTESTIA_4_500; else if (progdefaults.contestiatones == 1 && progdefaults.contestiabw == 3) rmode = RSID_CONTESTIA_4_1000; else if (progdefaults.contestiatones == 1 && progdefaults.contestiabw == 4) rmode = RSID_CONTESTIA_4_2000; else if (progdefaults.contestiatones == 2 && progdefaults.contestiabw == 0) rmode = RSID_CONTESTIA_8_125; else if (progdefaults.contestiatones == 2 && progdefaults.contestiabw == 1) rmode = RSID_CONTESTIA_8_250; else if (progdefaults.contestiatones == 2 && progdefaults.contestiabw == 2) rmode = RSID_CONTESTIA_8_500; else if (progdefaults.contestiatones == 2 && progdefaults.contestiabw == 3) rmode = RSID_CONTESTIA_8_1000; else if (progdefaults.contestiatones == 2 && progdefaults.contestiabw == 4) rmode = RSID_CONTESTIA_8_2000; else if (progdefaults.contestiatones == 3 && progdefaults.contestiabw == 2) rmode = RSID_CONTESTIA_16_500; else if (progdefaults.contestiatones == 3 && progdefaults.contestiabw == 3) rmode = RSID_CONTESTIA_16_1000; else if (progdefaults.contestiatones == 3 && progdefaults.contestiabw == 4) rmode = RSID_CONTESTIA_16_2000; else if (progdefaults.contestiatones == 4 && progdefaults.contestiabw == 3) rmode = RSID_CONTESTIA_32_1000; else if (progdefaults.contestiatones == 4 && progdefaults.contestiabw == 4) rmode = RSID_CONTESTIA_32_2000; else if (progdefaults.contestiatones == 5 && progdefaults.contestiabw == 2) rmode = RSID_CONTESTIA_64_500; else if (progdefaults.contestiatones == 5 && progdefaults.contestiabw == 3) rmode = RSID_CONTESTIA_64_1000; else if (progdefaults.contestiatones == 5 && progdefaults.contestiabw == 4) rmode = RSID_CONTESTIA_64_2000; else return false; return true; break; case MODE_DOMINOEX4: if (progdefaults.DOMINOEX_FEC) rmode = RSID_DOMINOEX_4_FEC; break; case MODE_DOMINOEX5: if (progdefaults.DOMINOEX_FEC) rmode = RSID_DOMINOEX_5_FEC; break; case MODE_DOMINOEX8: if (progdefaults.DOMINOEX_FEC) rmode = RSID_DOMINOEX_8_FEC; break; case MODE_DOMINOEX11: if (progdefaults.DOMINOEX_FEC) rmode = RSID_DOMINOEX_11_FEC; break; case MODE_DOMINOEX16: if (progdefaults.DOMINOEX_FEC) rmode = RSID_DOMINOEX_16_FEC; break; case MODE_DOMINOEX22: if (progdefaults.DOMINOEX_FEC) rmode = RSID_DOMINOEX_22_FEC; break; case MODE_MT63_500S: rmode = RSID_MT63_500_ST; break; case MODE_MT63_500L: rmode = RSID_MT63_500_LG; break; case MODE_MT63_1000S: rmode = RSID_MT63_1000_ST; break; case MODE_MT63_1000L: rmode = RSID_MT63_1000_LG; break; case MODE_MT63_2000S: rmode = RSID_MT63_2000_ST; break; case MODE_MT63_2000L: rmode = RSID_MT63_2000_LG; break; } // if rmode is still unset, look it up // Try secondary table first if (rmode == RSID_NONE) { for (size_t i = 0; i < sizeof(rsid_ids_2)/sizeof(*rsid_ids_2); i++) { if (mode == rsid_ids_2[i].mode) { rmode = RSID_ESCAPE; rmode2 = rsid_ids_2[i].rs; break; } } if (rmode2 == RSID_NONE2) { for (size_t i = 0; i < sizeof(rsid_ids_1)/sizeof(*rsid_ids_1); i++) { if (mode == rsid_ids_1[i].mode) { rmode = rsid_ids_1[i].rs; break; } } } } if (rmode == RSID_NONE) { LOG_DEBUG("%s mode is not assigned an RSID", mode_info[mode].sname); return false; } return true; } void cRsId::send_eot() { unsigned char rsid[RSID_NSYMBOLS]; double sr; size_t len; int iTone; double freq, phaseincr; double fr; double phase; Encode(RSID_EOT, rsid); sr = active_modem->get_samplerate(); len = (size_t)floor(RSID_SYMLEN * sr); if (unlikely(len != symlen)) { symlen = len; delete [] outbuf; outbuf = new double[symlen]; } // transmit 5 symbol periods of silence at beginning of rsid memset(outbuf, 0, symlen * sizeof(*outbuf)); for (int i = 0; i < 5; i++) active_modem->ModulateXmtr(outbuf, symlen); // transmit sequence of 15 symbols (tones) fr = 1.0 * active_modem->get_txfreq_woffset() - (RSID_SAMPLE_RATE * 7 / 1024); phase = 0.0; for (int i = 0; i < 15; i++) { iTone = rsid[i]; if (active_modem->get_reverse()) iTone = 15 - iTone; freq = fr + iTone * RSID_SAMPLE_RATE / 1024; phaseincr = 2.0 * M_PI * freq / sr; for (size_t j = 0; j < symlen; j++) { phase += phaseincr; if (phase > 2.0 * M_PI) phase -= 2.0 * M_PI; outbuf[j] = sin(phase); } active_modem->ModulateXmtr(outbuf, symlen); } } void cRsId::send(bool preRSID) { trx_mode mode = active_modem->get_mode(); if (!progdefaults.rsid_tx_modes.test(mode)) { LOG_DEBUG("Mode %s excluded, not sending RSID", mode_info[mode].sname); return; } if (!progdefaults.rsid_post && !preRSID) return; if (!assigned(mode)) return; unsigned char rsid[RSID_NSYMBOLS]; double sr; size_t len; int iTone; double freq, phaseincr; double fr; double phase; Encode(rmode, rsid); sr = active_modem->get_samplerate(); len = (size_t)floor(RSID_SYMLEN * sr); if (unlikely(len != symlen)) { symlen = len; delete [] outbuf; outbuf = new double[symlen]; } // transmit 5 symbol periods of silence at beginning of rsid memset(outbuf, 0, symlen * sizeof(*outbuf)); for (int i = 0; i < 5; i++) active_modem->ModulateXmtr(outbuf, symlen); // transmit sequence of 15 symbols (tones) fr = 1.0 * active_modem->get_txfreq_woffset() - (RSID_SAMPLE_RATE * 7 / 1024); phase = 0.0; for (int i = 0; i < 15; i++) { iTone = rsid[i]; if (active_modem->get_reverse()) iTone = 15 - iTone; freq = fr + iTone * RSID_SAMPLE_RATE / 1024; phaseincr = 2.0 * M_PI * freq / sr; for (size_t j = 0; j < symlen; j++) { phase += phaseincr; if (phase > 2.0 * M_PI) phase -= 2.0 * M_PI; outbuf[j] = sin(phase); } active_modem->ModulateXmtr(outbuf, symlen); } if (rmode == RSID_ESCAPE && rmode2 != RSID_NONE2) { // transmit 10 symbol periods of silence between rsid sequences memset(outbuf, 0, symlen * sizeof(*outbuf)); for (int i = 0; i < 10; i++) active_modem->ModulateXmtr(outbuf, symlen); Encode(rmode2, rsid); sr = active_modem->get_samplerate(); len = (size_t)floor(RSID_SYMLEN * sr); if (unlikely(len != symlen)) { symlen = len; delete [] outbuf; outbuf = new double[symlen]; } // transmit sequence of 15 symbols (tones) fr = 1.0 * active_modem->get_txfreq_woffset() - (RSID_SAMPLE_RATE * 7 / 1024); phase = 0.0; for (int i = 0; i < 15; i++) { iTone = rsid[i]; if (active_modem->get_reverse()) iTone = 15 - iTone; freq = fr + iTone * RSID_SAMPLE_RATE / 1024; phaseincr = 2.0 * M_PI * freq / sr; for (size_t j = 0; j < symlen; j++) { phase += phaseincr; if (phase > 2.0 * M_PI) phase -= 2.0 * M_PI; outbuf[j] = sin(phase); } active_modem->ModulateXmtr(outbuf, symlen); } } // 5 symbol periods of silence at end of transmission // and between RsID and the data signal int nperiods = 5; memset(outbuf, 0, symlen * sizeof(*outbuf)); for (int i = 0; i < nperiods; i++) active_modem->ModulateXmtr(outbuf, symlen); }
29,919
C++
.cxx
971
28.042225
102
0.668147
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,213
rsid_defs.cxx
w1hkj_fldigi/src/rsid/rsid_defs.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // Syntax: ELEM_(rsid_code, rsid_tag, fldigi_mode) // fldigi_mode is NUM_MODES if mode is not available in fldigi, // otherwise one of the tags defined in globals.h. // rsid_tag is stringified and may be shown to the user. /* ELEM_(263, ESCAPE, NUM_MODES) \ */ #undef ELEM_ #define RSID_LIST \ \ /* ESCAPE used to transition to 2nd RSID set */ \ \ ELEM_(263, EOT, MODE_EOT) \ ELEM_(6, ESCAPE, NUM_MODES) \ \ ELEM_(1, BPSK31, MODE_PSK31) \ ELEM_(110, QPSK31, MODE_QPSK31) \ ELEM_(2, BPSK63, MODE_PSK63) \ ELEM_(3, QPSK63, MODE_QPSK63) \ ELEM_(4, BPSK125, MODE_PSK125) \ ELEM_(5, QPSK125, MODE_QPSK125) \ ELEM_(126, BPSK250, MODE_PSK250) \ ELEM_(127, QPSK250, MODE_QPSK250) \ ELEM_(173, BPSK500, MODE_PSK500) \ \ ELEM_(183, PSK125R, MODE_PSK125R) \ ELEM_(186, PSK250R, MODE_PSK250R) \ ELEM_(187, PSK500R, MODE_PSK500R) \ \ ELEM_(7, PSKFEC31, NUM_MODES) \ ELEM_(8, PSK10, NUM_MODES) \ \ ELEM_(9, MT63_500_LG, MODE_MT63_500L) \ ELEM_(10, MT63_500_ST, MODE_MT63_500S) \ ELEM_(11, MT63_500_VST, NUM_MODES) \ ELEM_(12, MT63_1000_LG, MODE_MT63_1000L) \ ELEM_(13, MT63_1000_ST, MODE_MT63_1000S) \ ELEM_(14, MT63_1000_VST, NUM_MODES) \ ELEM_(15, MT63_2000_LG, MODE_MT63_2000L) \ ELEM_(17, MT63_2000_ST, MODE_MT63_2000S) \ ELEM_(18, MT63_2000_VST, NUM_MODES) \ \ ELEM_(19, PSKAM10, NUM_MODES) \ ELEM_(20, PSKAM31, NUM_MODES) \ ELEM_(21, PSKAM50, NUM_MODES) \ \ ELEM_(22, PSK63F, MODE_PSK63F) \ ELEM_(23, PSK220F, NUM_MODES) \ \ ELEM_(24, CHIP64, NUM_MODES) \ ELEM_(25, CHIP128, NUM_MODES) \ \ ELEM_(26, CW, MODE_CW) \ \ ELEM_(27, CCW_OOK_12, NUM_MODES) \ ELEM_(28, CCW_OOK_24, NUM_MODES) \ ELEM_(29, CCW_OOK_48, NUM_MODES) \ ELEM_(30, CCW_FSK_12, NUM_MODES) \ ELEM_(31, CCW_FSK_24, NUM_MODES) \ ELEM_(33, CCW_FSK_48, NUM_MODES) \ \ ELEM_(34, PACTOR1_FEC, NUM_MODES) \ \ ELEM_(113, PACKET_110, NUM_MODES) \ ELEM_(35, PACKET_300, NUM_MODES) \ ELEM_(36, PACKET_1200, NUM_MODES) \ \ ELEM_(37, RTTY_ASCII_7, MODE_RTTY) \ ELEM_(38, RTTY_ASCII_8, MODE_RTTY) \ ELEM_(39, RTTY_45, MODE_RTTY) \ ELEM_(40, RTTY_50, MODE_RTTY) \ ELEM_(41, RTTY_75, MODE_RTTY) \ \ ELEM_(42, AMTOR_FEC, NUM_MODES) \ \ ELEM_(43, THROB_1, MODE_THROB1) \ ELEM_(44, THROB_2, MODE_THROB2) \ ELEM_(45, THROB_4, MODE_THROB4) \ ELEM_(46, THROBX_1, MODE_THROBX1) \ ELEM_(47, THROBX_2, MODE_THROBX2) \ ELEM_(146, THROBX_4, MODE_THROBX4) \ \ ELEM_(204, CONTESTIA_4_125, MODE_CONTESTIA_4_125) \ ELEM_(55, CONTESTIA_4_250, MODE_CONTESTIA_4_250) \ ELEM_(54, CONTESTIA_4_500, MODE_CONTESTIA_4_500) \ ELEM_(255, CONTESTIA_4_1000, MODE_CONTESTIA_4_1000) \ ELEM_(254, CONTESTIA_4_2000, MODE_CONTESTIA_4_2000) \ \ ELEM_(169, CONTESTIA_8_125, MODE_CONTESTIA_8_125) \ ELEM_(49, CONTESTIA_8_250, MODE_CONTESTIA_8_250) \ ELEM_(52, CONTESTIA_8_500, MODE_CONTESTIA_8_500) \ ELEM_(117, CONTESTIA_8_1000, MODE_CONTESTIA_8_1000) \ ELEM_(247, CONTESTIA_8_2000, MODE_CONTESTIA_8_2000) \ \ ELEM_(275, CONTESTIA_16_250, MODE_CONTESTIA_16_250) \ ELEM_(50, CONTESTIA_16_500, MODE_CONTESTIA_16_500) \ ELEM_(53, CONTESTIA_16_1000, MODE_CONTESTIA_16_1000) \ ELEM_(259, CONTESTIA_16_2000, MODE_CONTESTIA_16_2000) \ \ ELEM_(51, CONTESTIA_32_1000, MODE_CONTESTIA_32_1000) \ ELEM_(201, CONTESTIA_32_2000, MODE_CONTESTIA_32_2000) \ \ ELEM_(194, CONTESTIA_64_500, MODE_CONTESTIA_64_500) \ ELEM_(193, CONTESTIA_64_1000, MODE_CONTESTIA_64_1000) \ ELEM_(191, CONTESTIA_64_2000, MODE_CONTESTIA_64_2000) \ \ ELEM_(56, VOICE, NUM_MODES) \ \ ELEM_(60, MFSK8, MODE_MFSK8) \ ELEM_(57, MFSK16, MODE_MFSK16) \ ELEM_(147, MFSK32, MODE_MFSK32) \ \ ELEM_(148, MFSK11, MODE_MFSK11) \ ELEM_(152, MFSK22, MODE_MFSK22) \ \ ELEM_(61, RTTYM_8_250, NUM_MODES) \ ELEM_(62, RTTYM_16_500, NUM_MODES) \ ELEM_(63, RTTYM_32_1000, NUM_MODES) \ ELEM_(65, RTTYM_8_500, NUM_MODES) \ ELEM_(66, RTTYM_16_1000, NUM_MODES) \ ELEM_(67, RTTYM_4_500, NUM_MODES) \ ELEM_(68, RTTYM_4_250, NUM_MODES) \ ELEM_(119, RTTYM_8_1000, NUM_MODES) \ ELEM_(170, RTTYM_8_125, NUM_MODES) \ \ ELEM_(203, OLIVIA_4_125, MODE_OLIVIA_4_125) \ ELEM_(75, OLIVIA_4_250, MODE_OLIVIA_4_250) \ ELEM_(74, OLIVIA_4_500, MODE_OLIVIA_4_500) \ ELEM_(229, OLIVIA_4_1000, MODE_OLIVIA_4_1000) \ ELEM_(238, OLIVIA_4_2000, MODE_OLIVIA_4_2000) \ \ ELEM_(163, OLIVIA_8_125, MODE_OLIVIA_8_125) \ ELEM_(69, OLIVIA_8_250, MODE_OLIVIA_8_250) \ ELEM_(72, OLIVIA_8_500, MODE_OLIVIA_8_500) \ ELEM_(116, OLIVIA_8_1000, MODE_OLIVIA_8_1000) \ ELEM_(214, OLIVIA_8_2000, MODE_OLIVIA_8_2000) \ \ ELEM_(70, OLIVIA_16_500, MODE_OLIVIA_16_500) \ ELEM_(73, OLIVIA_16_1000, MODE_OLIVIA_16_1000) \ ELEM_(234, OLIVIA_16_2000, MODE_OLIVIA_16_2000) \ \ ELEM_(71, OLIVIA_32_1000, MODE_OLIVIA_32_1000) \ ELEM_(221, OLIVIA_32_2000, MODE_OLIVIA_32_2000) \ \ ELEM_(211, OLIVIA_64_2000, MODE_OLIVIA_64_2000) \ \ ELEM_(76, PAX, NUM_MODES) \ ELEM_(77, PAX2, NUM_MODES) \ ELEM_(78, DOMINOF, NUM_MODES) \ ELEM_(79, FAX, NUM_MODES) \ ELEM_(81, SSTV, NUM_MODES) \ \ ELEM_(84, DOMINOEX_4, MODE_DOMINOEX4) \ ELEM_(85, DOMINOEX_5, MODE_DOMINOEX5) \ ELEM_(86, DOMINOEX_8, MODE_DOMINOEX8) \ ELEM_(87, DOMINOEX_11, MODE_DOMINOEX11) \ ELEM_(88, DOMINOEX_16, MODE_DOMINOEX16) \ ELEM_(90, DOMINOEX_22, MODE_DOMINOEX22) \ ELEM_(92, DOMINOEX_4_FEC, MODE_DOMINOEX4) \ ELEM_(93, DOMINOEX_5_FEC, MODE_DOMINOEX5) \ ELEM_(97, DOMINOEX_8_FEC, MODE_DOMINOEX8) \ ELEM_(98, DOMINOEX_11_FEC, MODE_DOMINOEX11) \ ELEM_(99, DOMINOEX_16_FEC, MODE_DOMINOEX16) \ ELEM_(101, DOMINOEX_22_FEC, MODE_DOMINOEX22) \ \ ELEM_(104, FELD_HELL, MODE_FELDHELL) \ ELEM_(105, PSK_HELL, NUM_MODES) \ ELEM_(106, HELL_80, MODE_HELL80) \ ELEM_(107, FM_HELL_105, MODE_FSKH105) \ ELEM_(108, FM_HELL_245, MODE_FSKH245) \ \ ELEM_(114, MODE_141A, NUM_MODES) \ ELEM_(123, DTMF, NUM_MODES) \ ELEM_(125, ALE400, NUM_MODES) \ ELEM_(131, FDMDV, NUM_MODES) \ \ ELEM_(132, JT65_A, NUM_MODES) \ ELEM_(134, JT65_B, NUM_MODES) \ ELEM_(135, JT65_C, NUM_MODES) \ \ ELEM_(136, THOR_4, MODE_THOR4) \ ELEM_(137, THOR_8, MODE_THOR8) \ ELEM_(138, THOR_16, MODE_THOR16) \ ELEM_(139, THOR_5, MODE_THOR5) \ ELEM_(143, THOR_11, MODE_THOR11) \ ELEM_(145, THOR_22, MODE_THOR22) \ \ ELEM_(153, CALL_ID, NUM_MODES) \ \ ELEM_(155, PACKET_PSK1200, NUM_MODES) \ ELEM_(156, PACKET_PSK250, NUM_MODES) \ ELEM_(159, PACKET_PSK63, NUM_MODES) \ \ ELEM_(172, MODE_188_110A_8N1, NUM_MODES) \ \ /* NONE must be the last element */ \ ELEM_(0, NONE, NUM_MODES) #define ELEM_(code_, tag_, mode_) RSID_ ## tag_ = code_, enum { RSID_LIST }; #undef ELEM_ #define ELEM_(code_, tag_, mode_) { RSID_ ## tag_, mode_, #tag_ }, const RSIDs cRsId::rsid_ids_1[] = { RSID_LIST }; #undef ELEM_ const int cRsId::rsid_ids_size1 = sizeof(rsid_ids_1)/sizeof(*rsid_ids_1) - 1; //====================================================================== /* ELEM_(6, ESCAPE2, NUM_MODES) \ */ #define RSID_LIST2 \ ELEM2_(450, PSK63RX4, MODE_4X_PSK63R) \ ELEM2_(457, PSK63RX5, MODE_5X_PSK63R) \ ELEM2_(458, PSK63RX10, MODE_10X_PSK63R) \ ELEM2_(460, PSK63RX20, MODE_20X_PSK63R) \ ELEM2_(462, PSK63RX32, MODE_32X_PSK63R) \ \ ELEM2_(467, PSK125RX4, MODE_4X_PSK125R) \ ELEM2_(497, PSK125RX5, MODE_5X_PSK125R) \ ELEM2_(513, PSK125RX10, MODE_10X_PSK125R) \ ELEM2_(519, PSK125X12, MODE_12X_PSK125) \ ELEM2_(522, PSK125RX12, MODE_12X_PSK125R) \ ELEM2_(527, PSK125RX16, MODE_16X_PSK125R) \ \ ELEM2_(529, PSK250RX2, MODE_2X_PSK250R) \ ELEM2_(533, PSK250RX3, MODE_3X_PSK250R) \ ELEM2_(539, PSK250RX5, MODE_5X_PSK250R) \ ELEM2_(541, PSK250X6, MODE_6X_PSK250) \ ELEM2_(545, PSK250RX6, MODE_6X_PSK250R) \ ELEM2_(551, PSK250RX7, MODE_7X_PSK250R) \ \ ELEM2_(553, PSK500RX2, MODE_2X_PSK500R) \ ELEM2_(558, PSK500RX3, MODE_3X_PSK500R) \ ELEM2_(564, PSK500RX4, MODE_4X_PSK500R) \ ELEM2_(566, PSK500X2, MODE_2X_PSK500) \ ELEM2_(569, PSK500X4, MODE_4X_PSK500) \ \ ELEM2_(570, PSK1000, MODE_PSK1000) \ ELEM2_(580, PSK1000R, MODE_PSK1000R) \ ELEM2_(587, PSK1000X2, MODE_2X_PSK1000) \ ELEM2_(595, PSK1000RX2, MODE_2X_PSK1000R) \ ELEM2_(604, PSK800RX2, MODE_2X_PSK800R) \ ELEM2_(610, PSK800X2, MODE_2X_PSK800) \ \ ELEM2_(620, MFSK64, MODE_MFSK64) \ ELEM2_(625, MFSK128, MODE_MFSK128) \ \ ELEM2_(639, THOR25x4, MODE_THOR25x4) \ ELEM2_(649, THOR50x1, MODE_THOR50x1) \ ELEM2_(653, THOR50x2, MODE_THOR50x2) \ ELEM2_(658, THOR100, MODE_THOR100) \ \ ELEM2_(662, DOMINOEX_44, MODE_DOMINOEX44) \ ELEM2_(681, DOMINOEX_88, MODE_DOMINOEX88) \ \ ELEM2_(687, MFSK31, MODE_MFSK31) \ \ ELEM2_(691, DOMINOEX_MICRO, MODE_DOMINOEXMICRO) \ ELEM2_(693, THOR_MICRO, MODE_THORMICRO) \ \ ELEM2_(1026, MFSK64L, MODE_MFSK64L) \ ELEM2_(1029, MFSK128L, MODE_MFSK128L) \ \ ELEM2_(1066, PSK8P125, MODE_8PSK125) \ ELEM2_(1071, PSK8P250, MODE_8PSK250) \ ELEM2_(1076, PSK8P500, MODE_8PSK500) \ ELEM2_(1047, PSK8P1000, MODE_8PSK1000) \ \ ELEM2_(1037, PSK8P125F, MODE_8PSK125F) \ ELEM2_(1038, PSK8P250F, MODE_8PSK250F) \ ELEM2_(1043, PSK8P500F, MODE_8PSK500F) \ ELEM2_(1078, PSK8P1000F, MODE_8PSK1000F) \ ELEM2_(1058, PSK8P1200F, MODE_8PSK1200F) \ \ ELEM2_(1239, PSK8P125FL, MODE_8PSK125FL) \ ELEM2_(2052, PSK8P250FL, MODE_8PSK250FL) \ \ ELEM2_(2053, OFDM500F, MODE_OFDM_500F) \ ELEM2_(2094, OFDM7F0F, MODE_OFDM_750F) \ ELEM2_(2118, OFDM2000, MODE_OFDM_2000) \ ELEM2_(2110, OFDM2000F, MODE_OFDM_2000F) \ \ ELEM2_(1171, IFKP, MODE_IFKP) \ \ ELEM2_(0, NONE2, NUM_MODES) #define ELEM2_(code_, tag_, mode_) RSID_ ## tag_ = code_, enum { RSID_LIST2 }; #undef ELEM2_ #define ELEM2_(code_, tag_, mode_) { RSID_ ## tag_, mode_, #tag_ }, const RSIDs cRsId::rsid_ids_2[] = { RSID_LIST2 }; #undef ELEM2_ const int cRsId::rsid_ids_size2 = sizeof(rsid_ids_2)/sizeof(*rsid_ids_2) - 1;
17,293
C++
.cxx
307
39.713355
79
0.397443
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,214
combo.cxx
w1hkj_fldigi/src/combo/combo.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // // This is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This software is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <iostream> #include <string> #include <cstring> #include <cstdlib> #include <FL/Fl.H> #include <FL/fl_draw.H> #include <FL/Fl_Output.H> #include "config.h" #include "combo.h" void popbrwsr_cb (Fl_Widget *v, long d); Fl_PopBrowser::Fl_PopBrowser (int X, int Y, int W, int H, const char *label) : Fl_Window (X, Y, W, H, label) { hRow = H; wRow = W; clear_border(); box(FL_BORDER_BOX); align(FL_ALIGN_INSIDE); popbrwsr = new Fl_Select_Browser(0,0,wRow,hRow, ""); popbrwsr->callback ( (Fl_Callback*)popbrwsr_cb); popbrwsr->align(FL_ALIGN_INSIDE); parentCB = 0; end(); set_modal(); } Fl_PopBrowser::~Fl_PopBrowser () { delete popbrwsr; } int Fl_PopBrowser::handle(int event) { Fl_ComboBox *cbx = (Fl_ComboBox*)this->parent(); if (!Fl::event_inside( child(0) ) && event == FL_PUSH) { pophide(); return 1; } if (event == FL_KEYDOWN) { int kbd = Fl::event_key(); int key = Fl::event_text()[0]; if (kbd == FL_Down) { if (popbrwsr->value() < popbrwsr->size()) popbrwsr->select(popbrwsr->value() + 1); popbrwsr->bottomline(popbrwsr->value()); return 1; } if (kbd == FL_Up && popbrwsr->value() > 1) { popbrwsr->select(popbrwsr->value() - 1); return 1; } if (key == '\r' || kbd == FL_Enter) { // kbd test for OS X int n = popbrwsr->value() - 1; pophide(); cbx->index(n); cbx->do_callback(); return 1; } if (key == '\b' || kbd == FL_BackSpace) { // kbd test for OS X if (!keystrokes.empty()) keystrokes.erase(keystrokes.length() - 1, 1); return 1; } if (key == 0x1b || kbd == FL_Escape) { // kbd test for OS X pophide(); return 0; } if (key >= ' ' && key <= 0x7f) { keystrokes += key; for (int i = 0; i < cbx->listsize; i++) { if (strncasecmp(keystrokes.c_str(), cbx->datalist[i]->s, keystrokes.length()) == 0) { popbrwsr->select(i+1); popbrwsr->show(i+1); return 1; } } return 0; } } return Fl_Group::handle(event); } void Fl_PopBrowser::add(char *s, void *d) { popbrwsr->add(s,d); } void Fl_PopBrowser::clear() { popbrwsr->clear(); } void Fl_PopBrowser::sort() { return; } void Fl_PopBrowser::popshow (int x, int y) { int nRows = parentCB->numrows(); int fh = fl_height(); int height = nRows * fh + 4; if (popbrwsr->size() == 0) return; if (nRows > parentCB->lsize()) nRows = parentCB->lsize(); // locate first occurance of inp string value in the list // and display that if found int i = parentCB->index(); if (!(i >= 0 && i < parentCB->listsize)) { for (i = 0; i < parentCB->listsize; i++) if (parentCB->type_ == COMBOBOX) { if (!strcmp(parentCB->val->value(), parentCB->datalist[i]->s)) break; } else { if (!strcmp(parentCB->valbox->label(), parentCB->datalist[i]->s)) break; } if (i == parentCB->listsize) i = 0; } // resize and reposition the popup to insure that it is within the bounds // of the uppermost parent widget // preferred position is just below and at the same x position as the // parent widget Fl_Widget *gparent = parentCB; int hp = gparent->h(); while ((gparent = gparent->parent())) { hp = gparent->h(); parentWindow = gparent; } int nu = nRows, nl = nRows; int hu = nu * fh + 4, hl = nl * fh + 4; int yu = parentCB->y() - hu; int yl = y; while (nl > 1 && (yl + hl > hp)) { nl--; hl -= fh; } while (nu > 1 && yu < 0) { nu--; yu += fh; hu -= fh; } y = yl; height = hl; if (nl < nu) { y = yu; height = hu; } wRow = parentCB->w(); popbrwsr->size (wRow, height); resize (x, y, wRow, height); popbrwsr->redraw(); popbrwsr->topline (i); keystrokes.clear(); popbrwsr->show(); show(); for (const Fl_Widget* o = popbrwsr; o; o = o->parent()) ((Fl_Widget *)o)->set_visible(); if (parentWindow) { parentWindow->damage(FL_DAMAGE_ALL); parentWindow->redraw(); } Fl::grab(this); } void Fl_PopBrowser::pophide () { hide (); if (parentWindow) { parentWindow->damage(FL_DAMAGE_ALL); parentWindow->redraw(); } Fl::grab(0); Fl::focus(((Fl_ComboBox*)parent())->btn); } void Fl_PopBrowser::popbrwsr_cb_i (Fl_Widget *v, long d) { // update the return values Fl_Select_Browser *SB = (Fl_Select_Browser *)(v); Fl_PopBrowser *PB = (Fl_PopBrowser *)(SB->parent()); Fl_ComboBox *CB = (Fl_ComboBox *)(PB->parent()); int row = SB->value(); if (row == 0) return; SB->deselect(); CB->index(row - 1); PB->pophide(); CB->do_callback(); return; } void popbrwsr_cb (Fl_Widget *v, long d) { ((Fl_PopBrowser *)(v))->popbrwsr_cb_i (v, d); return; } void Fl_ComboBox::fl_popbrwsr(Fl_Widget *p) { int xpos = p->x(), ypos = p->h() + p->y(); // pass the calling widget to the popup browser so that the // correct callback function can be called when the user selects an item // from the browser list Brwsr->parentCB = (Fl_ComboBox *) p; Brwsr->clear_kbd(); Brwsr->popshow(xpos, ypos); return; } void btnComboBox_cb (Fl_Widget *v, void *d) { Fl_ComboBox *p = (Fl_ComboBox *)(v->parent()); p->fl_popbrwsr (p); return; } void val_callback(Fl_Widget *w, void *d) { Fl_Input *inp = (Fl_Input *)(w); Fl_ComboBox *cbx = (Fl_ComboBox *)(d); cbx->add(inp->value()); cbx->sort(); } Fl_ComboBox::Fl_ComboBox (int X,int Y,int W,int H, const char *lbl, int wtype) : Fl_Group (X, Y, W, H, lbl) { width = W; height = H; type_ = wtype; valbox = new Fl_Box (FL_DOWN_BOX, X, Y, W-H, H, ""); valbox->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT); valbox->color(FL_BACKGROUND2_COLOR); val = new Fl_Input (X, Y, W-H, H, ""); val->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT); val->callback((Fl_Callback *)val_callback, this); val->when(FL_WHEN_RELEASE); if (type_ == LISTBOX) { valbox->show(); val->hide(); } else { val->show(); valbox->hide(); } btn = new Fl_Button (X + W - H + 1, Y, H - 1, H, "@2>"); btn->callback ((Fl_Callback *)btnComboBox_cb, 0); Brwsr = 0; datalist = new datambr *[FL_COMBO_LIST_INCR]; maxsize = FL_COMBO_LIST_INCR; for (int i = 0; i < FL_COMBO_LIST_INCR; i++) datalist[i] = 0; listsize = 0; listtype = 0; Brwsr = new Fl_PopBrowser(X, Y, W, H, ""); Brwsr->align(FL_ALIGN_INSIDE); idx = 0; end(); numrows_ = 8; } Fl_ComboBox::~Fl_ComboBox() { delete Brwsr; for (int i = 0; i < listsize; i++) { if (datalist[i]) { if (datalist[i]->s) delete [] datalist[i]->s; delete datalist[i]; } } delete [] datalist; } int Fl_ComboBox::handle(int event) { if (event == FL_KEYDOWN) { int kbd = Fl::event_key(); if (kbd == FL_Down) { fl_popbrwsr (this); return 1; } } if (event == FL_MOUSEWHEEL) { int d = Fl::event_dy(); if (d) { if (d > 0) idx ++; else idx--; if (idx < 0) idx = 0; if (idx >= listsize) idx = listsize - 1; if (type_ == LISTBOX) { valbox->label(datalist[idx]->s); valbox->redraw_label(); } else { val->value( datalist[idx]->s); val->redraw(); } Fl_Group::do_callback(); return 1; } } return Fl_Group::handle(event); } void Fl_ComboBox::type (int t) { listtype = t; } void Fl_ComboBox::readonly(bool yes) { if (type_ == LISTBOX) return; val->readonly(yes); if (yes) val->selection_color(fl_rgb_color(173,216,230)); else val->selection_color(FL_SELECTION_COLOR); } // ComboBox value is contained in the val widget const char *Fl_ComboBox::value() { if (type_ == LISTBOX) return valbox->label(); else return val->value(); } void Fl_ComboBox::value( std::string s ) { while (s[0] == ' ') { s.erase(0,1); } if (s.empty()) { if (type_ == LISTBOX) { valbox->label(""); valbox->redraw_label(); } else { val->value(""); val->redraw(); } return; } int i; if ((listtype & FL_COMBO_UNIQUE_NOCASE) == FL_COMBO_UNIQUE_NOCASE) { for (i = 0; i < listsize; i++) { if (strcasecmp (s.c_str(), datalist[i]->s) == 0) break; } } else { for (i = 0; i < listsize; i++) { if (strcmp (s.c_str(), datalist[i]->s) == 0) break; } } if ( i < listsize) { idx = i; if (type_ == LISTBOX) { valbox->label(datalist[idx]->s); valbox->redraw_label(); } else { val->value(datalist[idx]->s); val->redraw(); } } else { if (type_ == LISTBOX) { valbox->label(""); valbox->redraw_label(); } else if (type_ != LISTBOX && !val->readonly()) { insert(s.c_str(), 0); for (i = 0; i < listsize; i++) { if (strcmp (s.c_str(), datalist[i]->s) == 0) { idx = i; val->value(datalist[idx]->s); break; } val->redraw(); } } else { val->value(""); val->redraw(); } } } void Fl_ComboBox::put_value(const char *s) { value(s); } void Fl_ComboBox::index(int i) { if (i >= 0 && i < listsize) { idx = i; if (type_ == LISTBOX) { valbox->label(datalist[idx]->s); valbox->redraw_label(); } else { val->value( datalist[idx]->s); val->redraw(); } } } int Fl_ComboBox::index() { return idx; } void * Fl_ComboBox::data() { return retdata; } void Fl_ComboBox::insert(const char *str, void *d) { datalist[listsize] = new datambr; datalist[listsize]->s = new char [strlen(str) + 1]; datalist[listsize]->s[0] = 0; strcpy (datalist[listsize]->s, str); datalist[listsize]->d = 0; Brwsr->add(datalist[listsize]->s,d); listsize++; if (listsize == maxsize) { int nusize = maxsize + FL_COMBO_LIST_INCR; datambr **temparray = new datambr *[nusize]; for (int i = 0; i < listsize; i++) temparray[i] = datalist[i]; delete [] datalist; datalist = temparray; maxsize = nusize; } } void Fl_ComboBox::add( const char *s, void * d) { std::string str = s; std::string sinsert; size_t p = str.find("|"); bool found = false; if (p != std::string::npos) { while (p != std::string::npos) { sinsert = str.substr(0, p); found = false; // test for in list if ((listtype & FL_COMBO_UNIQUE_NOCASE) == FL_COMBO_UNIQUE_NOCASE) { for (int i = 0; i < listsize; i++) { if (sinsert == datalist[i]->s) { found = true; break; } } } // not in list, so add this entry if (!found) insert(sinsert.c_str(), 0); str.erase(0, p+1); p = str.find("|"); } if (str.length()) insert(str.c_str(), 0); } else insert( s, d ); } void Fl_ComboBox::clear() { Brwsr->clear(); if (listsize == 0) return; for (int i = 0; i < listsize; i++) { delete [] datalist[i]->s; delete datalist[i]; } listsize = 0; } int DataCompare( const void *x1, const void *x2 ) { int cmp; datambr *X1, *X2; X1 = *(datambr **)(x1); X2 = *(datambr **)(x2); cmp = strcasecmp (X1->s, X2->s); if (cmp < 0) return -1; if (cmp > 0) return 1; return 0; } void Fl_ComboBox::sort() { Brwsr->clear (); qsort (&datalist[0], listsize, sizeof (datambr *), DataCompare); for (int i = 0; i < listsize; i++) Brwsr->add (datalist[i]->s, datalist[i]->d); } void Fl_ComboBox::textfont (int fnt) { if (type_ == LISTBOX) valbox->labelfont (fnt); else val->textfont (fnt); } void Fl_ComboBox::textsize (uchar n) { if (type_ == LISTBOX) valbox->labelsize(n); else val->textsize (n); } void Fl_ComboBox::textcolor( Fl_Color c) { if (type_ == LISTBOX) valbox->labelcolor (c); else val->textcolor (c); } void Fl_ComboBox::color(Fl_Color c) { _color = c; if (type_ == LISTBOX) { valbox->color(c); valbox->redraw(); } else { val->color(c); val->redraw(); } if (Brwsr) Brwsr->color(c); } int Fl_ComboBox::find_index(const char *str) { if((listsize < 1) || !str) return -1; for (int i = 0; i < listsize; i++) { if(datalist[i]->s) if(strncmp(datalist[i]->s, str, FILENAME_MAX) == 0) return i; } return -1; } void Fl_ComboBox::position(int n) { if (type_ != LISTBOX) val->position(n, n); }
12,449
C++
.cxx
524
21.223282
79
0.611477
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,215
pkt.cxx
w1hkj_fldigi/src/packet/pkt.cxx
// --------------------------------------------------------------------- // pkt.cxx -- 1200/300/2400 baud AX.25 // // // This file is a proposed part of fldigi. Adapted very liberally from // rtty.cxx, with many thanks to John Hansen, W2FS, who wrote // 'dcc.doc' and 'dcc2.doc', GNU Octave, GNU Radio Companion, and finally // Bartek Kania (bk.gnarf.org) whose 'aprs.c' expository coding style helped // shape this implementation. // // Copyright (C) 2010 // Dave Freese, W1HKJ // Chris Sylvain, KB3CS // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi; if not, write to the // // Free Software Foundation, Inc. // 51 Franklin Street, Fifth Floor // Boston, MA 02110-1301 USA. // // --------------------------------------------------------------------- #include <config.h> #include <iostream> #include "pkt.h" #include "fl_digi.h" #include "misc.h" #include "confdialog.h" #include "configuration.h" #include "status.h" #include "timeops.h" static char msg1[20]; static char msg2[20]; /*********************************************************************** * these are redefined as static members of the class * in the pkt1200.h file * increased number of elements in the PKTBITS to prepare for when * HF/VHF/DOUBLE selection is available * removed leading _ in names. Leading underscore is reserved in Linux * for the OS and library code. ***********************************************************************/ /* 1200 -> tones 1200 mark and 2200 Hz space (1700 Hz center) 300 -> tones 1600 space and 1800 Hz mark (1700 Hz center) 2400 -> tones 297.5 mark and 2102.5 Hz space (1200 Hz center) */ const double pkt::CENTER[] = {1700, 1700, 1200}; const double pkt::SHIFT[] = {1000, 200, 1805}; const int pkt::BAUD[] = {1200, 300, 2400}; const int pkt::BITS[] = {8, 8, 8}; PKT_MicE_field pkt::MicE_table[][12][5] = { { { Zero, Zero, South, P0, East }, { One, Zero, South, P0, East }, { Two, Zero, South, P0, East }, { Three, Zero, South, P0, East }, { Four, Zero, South, P0, East }, { Five, Zero, South, P0, East }, { Six, Zero, South, P0, East }, { Seven, Zero, South, P0, East }, { Eight, Zero, South, P0, East }, { Nine, Zero, South, P0, East }, { Invalid, Null, Null, Null, Null }, { Invalid, Null, Null, Null, Null } }, { // ['A'..'K'] + 'L' { Zero, One, Null, Null, Null }, // custom A/B/C msg codes { One, One, Null, Null, Null }, { Two, One, Null, Null, Null }, { Three, One, Null, Null, Null }, { Four, One, Null, Null, Null }, { Five, One, Null, Null, Null }, { Six, One, Null, Null, Null }, { Seven, One, Null, Null, Null }, { Eight, One, Null, Null, Null }, { Nine, One, Null, Null, Null }, { Space, One, Null, Null, Null }, { Space, Zero, South, P0, East } }, { // ['P'..'Z'] { Zero, One, North, P100, West }, // standard A/B/C msg codes { One, One, North, P100, West }, { Two, One, North, P100, West }, { Three, One, North, P100, West }, { Four, One, North, P100, West }, { Five, One, North, P100, West }, { Six, One, North, P100, West }, { Seven, One, North, P100, West }, { Eight, One, North, P100, West }, { Nine, One, North, P100, West }, { Space, One, North, P100, West }, { Invalid, Null, Null, Null, Null } } }; PKT_PHG_table pkt::PHG_table[] = { { "Omni", 4 }, { "NE", 2 }, { "E", 1 }, { "SE", 2 }, { "S", 1 }, { "SW", 2 }, { "W", 1 }, { "NW", 2 }, { "N", 1 } }; void pkt::tx_init() { int scale_factor = (pkt_baud > 1200 ? 2 : 1); // baud rate proportional // start each new transmission with MARK tone pretone = PKT_MarkBits * scale_factor; // number of flags to begin frame preamble = PKT_StartFlags * scale_factor; // number of flags to end frame postamble = PKT_EndFlags * scale_factor; if (!lo_tone) lo_tone = new NCO(); if (!hi_tone) hi_tone = new NCO(); lo_tone->init(pkt_ctrfreq-(pkt_shift/2), 0, PKT_SampleRate); hi_tone->init(pkt_ctrfreq+(pkt_shift/2), 0, PKT_SampleRate); tx_cbuf = &txbuf[0]; nr_ones = 0; currbit = nostuff = did_pkt_head = false; videoText(); } void pkt::rx_init() { rxstate = PKT_RX_STATE_STOP; scounter = 0; cbuf = &rxbuf[0]; // init rx buf ptr } void pkt::set_freq(double f) { // fixed transmit frequency modem if (abs(f - 1700) > 9) { if (!modem::freqlocked()) { modem::set_freq(pkt_ctrfreq); modem::freqlock = true; } modem::set_freq(f); nco_lo->init(f-(pkt_shift/2), 0, PKT_SampleRate); nco_hi->init(f+(pkt_shift/2), 0, PKT_SampleRate); nco_mid->init(f, 0, PKT_SampleRate); } else { if (modem::freqlocked()) modem::freqlock = false; modem::set_freq(pkt_ctrfreq); nco_lo->init(pkt_ctrfreq-(pkt_shift/2), 0, PKT_SampleRate); nco_hi->init(pkt_ctrfreq+(pkt_shift/2), 0, PKT_SampleRate); nco_mid->init(pkt_ctrfreq, 0, PKT_SampleRate); } } void pkt::init() { modem::init(); set_freq(pkt_ctrfreq); // use pkt default center freq. don't use PSKsweetspot. rx_init(); snprintf(msg1, sizeof(msg1), "%4i / %-4.0f", pkt_baud, pkt_shift); put_Status1(msg1); put_MODEstatus(mode); if (progdefaults.PKT_PreferXhairScope) set_scope_mode(Digiscope::XHAIRS); else set_scope_mode(Digiscope::RTTY); lo_signal_gain = pow(10, progdefaults.PKT_LOSIG_RXGAIN / 10); hi_signal_gain = pow(10, progdefaults.PKT_HISIG_RXGAIN / 10); lo_txgain = pow(10, progdefaults.PKT_LOSIG_TXGAIN / 10); hi_txgain = pow(10, progdefaults.PKT_HISIG_TXGAIN / 10); if (hi_txgain > 1.0 || lo_txgain > 1.0) { // renormalize output levels // [ modem output recording depends on gain =< 1.0 ] double inv; if (hi_txgain > lo_txgain) inv = 1.0 / hi_txgain; else inv = 1.0 / lo_txgain; lo_txgain *= inv; hi_txgain *= inv; } // leave 10% headroom lo_txgain *= 0.9; hi_txgain *= 0.9; #ifndef NDEBUG static bool do_once = true; /* from TAPR AX.25 v2.2 Specification: 2.2.8 Order of Bit Transmission With the exception of the FCS field, all fields of an AX.25 frame shall be sent with each octet's least-significant bit first. The FCS shall be sent most-significant bit first. */ // it seems they meant "byte first" in the last sentence above. sigh. /* useful tools for identifying CRCs SRP16 CRC16 http://home.netsurf.de/wolfgang.ehrhardt/crchash_en.html */ if (!do_once) return; #undef CRCDEBUG #ifdef CRCDEBUG // first two: http://ecee.colorado.edu/~newhallw/TechDepot/AX25CRC/CRC_for_AX25.pdf rxbuf[0] = 'A'; rxbuf[1] = 'B'; rxbuf[2] = 'C'; rxbuf[3] = 0x9f; rxbuf[4] = 0x2f; // FCS 0x9F2F (CRC16-X25) 0xF9F4 byte-wise reflected checkFCS(&rxbuf[3]); /* http://www.lammertbies.nl/comm/info/crc-calculation.html 8c4ccc2cac6cec1c9c7609 -> 0x1D0F (each msg byte is flipped) 3132333435363738399067 -> 0x0F2E */ rxbuf[0] = '1'; rxbuf[1] = '2'; rxbuf[2] = '3'; rxbuf[3] = '4'; rxbuf[4] = '5'; rxbuf[5] = '6'; rxbuf[6] = '7'; rxbuf[7] = '8'; rxbuf[8] = '9'; rxbuf[9] = 0x90; rxbuf[10] = 0x6e; // FCS 0x906E (CRC16-X25) 0x0976 bytewise reflected checkFCS(&rxbuf[9]); // http://www.aerospacesoftware.com/winhexcom.html rxbuf[0] = 0x11; rxbuf[1] = 0x22; rxbuf[2] = 0x33; rxbuf[3] = 0x44; rxbuf[4] = 0x55; rxbuf[5] = 0x66; rxbuf[6] = 0x77; rxbuf[7] = 0x88; rxbuf[8] = 0x99; rxbuf[9] = 0x14; rxbuf[10] = 0x99; // FCS 0x1499 (CRC16-X25) 0x2899 bytewise reflected checkFCS(&rxbuf[9]); // next two: http://www.lammertbies.nl/forum/viewtopic.php?t=607 rxbuf[0] = 0x10; // 7e 08 91 87 44 7e <- 0x4487 HDLC rxbuf[1] = 0x89; // == 7e 10 89 e1 22 7e rxbuf[2] = 0x83; rxbuf[3] = 0x1f; // CRC16-X25 0x831F reflected is 0xC1F8 checkFCS(&rxbuf[2]); rxbuf[2] = 0x1f; rxbuf[3] = 0x83; // set FCS (lo,hi) rxbuf[4] = 0x0f; rxbuf[5] = 0x47; // magic 0x0F47 checkFCS(&rxbuf[4]); rxbuf[0] = 0x10; // 7e 08 b1 85 65 7e <- 0x6585 HDLC rxbuf[1] = 0x8d; // == 7e 10 8d a1 a6 7e rxbuf[2] = 0xc5; rxbuf[3] = 0x3b; // CRC16-X25 0xC53B reflected Bwise is 0xA3DC checkFCS(&rxbuf[2]); rxbuf[2] = 0x3b; rxbuf[3] = 0xc5; // set FCS (lo,hi) rxbuf[4] = 0x0f; rxbuf[5] = 0x47; // magic 0x0F47 checkFCS(&rxbuf[4]); // http://cs.nju.edu.cn/yangxc/dcc_teach/fcs-calc.pdf /* rxbuf[0] = 0x72; rxbuf[1] = 0xd3; rxbuf[2] = 0x4f; rxbuf[3] = 0x3c; rxbuf[4] = 0x30; // FCS reflected Bwise is 0x3C30 */ rxbuf = { 0x72, 0xd3, 0x4f, 0x3c, 0x0c }; checkFCS(&rxbuf[3]); rxbuf[0] = 0x01; //DF test rxbuf[1] = 0x02; rxbuf[2] = 0x03; rxbuf[3] = 0x04; rxbuf[4] = 0x40; rxbuf[5] = 0x80; rxbuf[6] = 0x61; // (was) 0xb77b rxbuf[7] = 0xee; // 0x61EE is reflected Bw 0x8677 checkFCS(&rxbuf[6]); // http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=75742&start=0 // (looks like an anonymized AX.25 packet) rxbuf[0] = 0x80; rxbuf[1] = 0x80; rxbuf[2] = 0x80; rxbuf[3] = 0x80; rxbuf[4] = 0x80; rxbuf[5] = 0x80; rxbuf[6] = 0xf2; rxbuf[7] = 0x9e; // addr char 0x9e>>1 = 0x4f == 'O' rxbuf[8] = 0x9e; rxbuf[9] = 0x9e; rxbuf[10] = 0x9e; rxbuf[11] = 0x9e; rxbuf[12] = 0x9e; rxbuf[13] = 0x61; rxbuf[14] = 0x03; // ax.25 flag rxbuf[15] = 0xf0; // ax.25 flag rxbuf[16] = 0x0b; rxbuf[17] = 0x58; // FCS is 0x0B58 (hi,lo) msb->lsb 0xd01a Bwise refl. checkFCS(&rxbuf[16]); rxbuf[16] = 0x58; rxbuf[17] = 0x0b; // set FCS (lo,hi) msb->lsb rxbuf[18] = 0x0f; rxbuf[19] = 0x47; // magic value 0x0F47 revflipped is 0xF0E2 // bitflip(0x0F47) = 0xE2F0 // ~(0xE2F0) = 0x1D0F // CRC-CCITT magic value is 0x1D0F checkFCS(&rxbuf[18]); #endif // CRCDEBUG if (debug::level == debug::DEBUG_LEVEL) { // same anonymized packet from above plus some trash before 1st flag rxbuf[0] = 0x66; rxbuf[1] = 0x77; rxbuf[2] = 0x7e; rxbuf[3] = 0x7e; rxbuf[4] = 0x80; rxbuf[5] = 0x80; rxbuf[6] = 0x80; rxbuf[7] = 0x80; rxbuf[8] = 0x80; rxbuf[9] = 0x80; rxbuf[10] = 0xf2; rxbuf[11] = 0x9e; rxbuf[12] = 0x9e; rxbuf[13] = 0x9e; rxbuf[14] = 0x9e; rxbuf[15] = 0x9e; rxbuf[16] = 0x9e; rxbuf[17] = 0x61; rxbuf[18] = 0x03; rxbuf[19] = 0xf0; rxbuf[20] = 0x58; rxbuf[21] = 0x0b; rxbuf[22] = 0x7e; rxbuf[23] = 0x00; unsigned char *cp, b; for (cp = &rxbuf[0]; *cp ; cp++) { for (b = 0; b < 8; b++) if (*cp & (1 << b)) rx(true); else rx(false); } // "Sun May 24 14:56:03 2009" http://bk.gnarf.org/radio/aprs-20090524-1.txt rxbuf[0] = 0x7e; rxbuf[1] = 0x82; rxbuf[2] = 0xa0; rxbuf[3] = 0xaa; rxbuf[4] = 0x64; rxbuf[5] = 0x6a; rxbuf[6] = 0x9c; rxbuf[7] = 0xe0; rxbuf[8] = 0xa6; rxbuf[9] = 0x9a; rxbuf[10] = 0x6e; rxbuf[11] = 0x8e; rxbuf[12] = 0xb2; rxbuf[13] = 0xa8; rxbuf[14] = 0x60; rxbuf[15] = 0xae; rxbuf[16] = 0x92; rxbuf[17] = 0x88; rxbuf[18] = 0x8a; rxbuf[19] = 0x66; rxbuf[20] = 0x40; rxbuf[21] = 0x65; rxbuf[22] = 0x03; rxbuf[23] = 0xf0; rxbuf[24] = 0x3d; rxbuf[25] = 0x35; rxbuf[26] = 0x35; rxbuf[27] = 0x34; rxbuf[28] = 0x39; rxbuf[29] = 0x2e; rxbuf[30] = 0x32; rxbuf[31] = 0x36; rxbuf[32] = 0x4e; rxbuf[33] = 0x2f; rxbuf[34] = 0x30; rxbuf[35] = 0x31; rxbuf[36] = 0x33; rxbuf[37] = 0x30; rxbuf[38] = 0x37; rxbuf[39] = 0x2e; rxbuf[40] = 0x30; rxbuf[41] = 0x33; rxbuf[42] = 0x45; rxbuf[43] = 0x2f; rxbuf[44] = 0x2a; rxbuf[45] = 0x2a; rxbuf[46] = 0x4b; rxbuf[47] = 0x45; rxbuf[48] = 0x56; rxbuf[49] = 0x4c; rxbuf[50] = 0x41; rxbuf[51] = 0x4e; rxbuf[52] = 0x47; rxbuf[53] = 0x45; rxbuf[54] = 0x20; rxbuf[55] = 0x48; rxbuf[56] = 0x45; rxbuf[57] = 0x4c; rxbuf[58] = 0x49; rxbuf[59] = 0x50; rxbuf[60] = 0x4f; rxbuf[61] = 0x52; rxbuf[62] = 0x54; rxbuf[63] = 0x2a; rxbuf[64] = 0x2a; rxbuf[65] = 0x20; rxbuf[66] = 0x7b; rxbuf[67] = 0x55; rxbuf[68] = 0x49; rxbuf[69] = 0x56; rxbuf[70] = 0x33; rxbuf[71] = 0x32; rxbuf[72] = 0x4e; rxbuf[73] = 0x7d; rxbuf[74] = 0x0d; rxbuf[75] = 0xe8; rxbuf[76] = 0x03; checkFCS(&rxbuf[75]); do_put_rx_char(&rxbuf[75]); } #undef NCODEBUG #ifdef NCODEBUG NCO *osc = new NCO(); osc->init(1200, 0, PKT_SampleRate); for(int i = 0; i < 30; i++) { cmplx z = osc->cmplx_sample(); fprintf(stderr," %f %f\n", z.re, z.im); } osc->init(2200, 0, PKT_SampleRate); for(int i = 0; i < 30; i++) { cmplx z = osc->cmplx_sample(); fprintf(stderr," %f %f\n", z.re, z.im); } delete osc; #endif // NCODEBUG do_once = false; #endif // NDEBUG } pkt::~pkt() { if (nco_lo) delete nco_lo; if (nco_hi) delete nco_hi; if (nco_mid) delete nco_mid; if (idle_signal_buf) delete idle_signal_buf; if (lo_signal_buf) delete lo_signal_buf; if (hi_signal_buf) delete hi_signal_buf; if (mid_signal_buf) delete mid_signal_buf; if (signal_buf) delete signal_buf; if (pipe) delete [] pipe; if (dsppipe) delete [] dsppipe; if (lo_tone) delete lo_tone; if (hi_tone) delete hi_tone; } void pkt::set_pkt_modem_params(int i) { pkt_baud = BAUD[i]; pkt_shift = SHIFT[i]; pkt_nbits = BITS[i]; pkt_ctrfreq = CENTER[i]; /************************************************************** SYMBOLLEN is the number of samples in one data bit (aka one symbol) at the current baud rate **************************************************************/ symbollen = (int) floor((double)PKT_SampleRate / pkt_baud + 0.5); pkt_startlen = 4 * symbollen; pkt_detectlen = PKT_DetectLen * symbollen; pkt_syncdisplen = PKT_SyncDispLen * symbollen; pkt_idlelen = PKT_IdleLen * symbollen; pkt_startlen = 2 * pkt_idlelen; fragmentsize = symbollen; // modem::fragmentsize -> see modem.h // http://users.encs.concordia.ca/~n_goswam/advsg00/advsgtxt/c10digtx_b1_r00.htm // BW = Baud + Shift * K .. K ::= 1.2 pkt_BW = pkt_baud + pkt_shift * 1.2; } void pkt::restart() { if (select_val != progdefaults.PKT_BAUD_SELECT) { select_val = progdefaults.PKT_BAUD_SELECT; set_pkt_modem_params(select_val); } snprintf(msg1, sizeof(msg1), "%4i / %-4.0f", pkt_baud, pkt_shift); put_Status1(msg1); put_MODEstatus(mode); if (!nco_lo) nco_lo = new NCO(); if (!nco_hi) nco_hi = new NCO(); if (!nco_mid) nco_mid = new NCO(); nco_lo->init(pkt_ctrfreq-(pkt_shift/2), 0, PKT_SampleRate); nco_hi->init(pkt_ctrfreq+(pkt_shift/2), 0, PKT_SampleRate); nco_mid->init(pkt_ctrfreq, 0, PKT_SampleRate); set_freq(pkt_ctrfreq); set_bandwidth(pkt_shift); // waterfall tuning box wf->redraw_marker(); if (!idle_signal_buf) idle_signal_buf = new double [PKT_IdleLen*PKT_MaxSymbolLen]; idle_signal_pwr = idle_signal_buf_ptr = 0; for (int i = 0; i < pkt_idlelen; i++) idle_signal_buf[i] = 0; if (!lo_signal_buf) lo_signal_buf = new cmplx [PKT_MaxSymbolLen]; if (!hi_signal_buf) hi_signal_buf = new cmplx [PKT_MaxSymbolLen]; if (!mid_signal_buf) mid_signal_buf = new cmplx [PKT_MaxSymbolLen]; if (!signal_buf) signal_buf = new double [PKT_DetectLen*PKT_MaxSymbolLen]; signal_pwr = signal_buf_ptr = 0; signal_gain = 1.0; // 5.0 for(int i = 0; i < pkt_detectlen; i++) signal_buf[i] = 0; lo_signal_energy = hi_signal_energy = mid_signal_energy = cmplx(0, 0); yt_avg = correlate_buf_ptr = 0; for(int i = 0; i < symbollen; i++) lo_signal_buf[i] = hi_signal_buf[i] = mid_signal_buf[i] = cmplx(0, 0); if (!pipe) pipe = new double [PKT_SyncDispLen*PKT_MaxSymbolLen]; if (!dsppipe) dsppipe = new double [PKT_SyncDispLen*PKT_MaxSymbolLen]; QIptr = pipeptr = 0; // 1024 = 2 * SCBLOCKSIZE ( == MAX_ZLEN ) for (int i = 0; i < MAX_ZLEN; i++) QI[i] = cmplx(0,0); metric = 0.0; signal_power = noise_power = power_ratio = snr_avg = 1; clear_zdata = true; } pkt::pkt(trx_mode md) { cap |= CAP_REV; cap &= ~CAP_AFC; // modem::cap mode = md; // modem::mode samplerate = PKT_SampleRate; // modem::samplerate nco_lo = nco_hi = nco_mid = (NCO *)0; idle_signal_buf = (double *)0; lo_signal_buf = hi_signal_buf = mid_signal_buf = (cmplx *)0; signal_buf = (double *)0; pipe = dsppipe = (double *)0; select_val = -1; // force modem param init restart(); lo_tone = hi_tone = (NCO *)0; tx_char_count = MAXOCTETS-3; // leave room for FCS and end-flag // init_MicE_table(); // init_PHG_table(); } void pkt::update_syncscope() { int j, len = pkt_syncdisplen; for (int i = 0; i < len; i++) { j = pipeptr - i; if (j < 0) j += len; dsppipe[i] = pipe[j]; } set_scope(dsppipe, len, false); } void pkt::clear_syncscope() { set_scope(0, 0, false); } /* cmplx pkt::mixer(cmplx in) { cmplx z; z.re = cos(phaseacc); z.im = sin(phaseacc); z = z * in; phaseacc -= TWOPI * frequency / samplerate; if (phaseacc > M_PI) phaseacc -= TWOPI; else if (phaseacc < M_PI) phaseacc += TWOPI; return z; } */ unsigned char pkt::bitreverse(unsigned char in, int n) { unsigned char out = 0; for (int i = 0; i < n; i++) out = (out << 1) | ((in >> i) & 1); return out; } unsigned int pkt::computeFCS(unsigned char *head, unsigned char *tail) { unsigned char *c, b, tc; // CRC AX.25 Generator mask // == bitflip(poly(x**16 + x**12 + x**5 + 1)) // == bitflip(0x1021) == bitflip(0001000000100001) // == 1000010000001000 == 0x8408 // http://www.ross.net/crc/download/crc_v3.txt unsigned int fcsv = 0xFFFF; // as in Ross except: shift right instead of left and reflected mask // (mirror image because AX.25 is lsb->msb order) for(c = head; c < tail; c++) { fcsv ^= *c; for(b = 0; b < 8; b++) { if (fcsv & 0x0001) fcsv = (fcsv >> 1) ^ 0x8408; else fcsv >>= 1; fcsv &= 0xFFFF; } } fcsv ^= 0xFFFF; // fcsv is now (lo,hi) tc = (fcsv & 0xFF00) >> 8; fcsv = ((fcsv & 0x00FF) << 8) | tc; // fcsv is now (hi,lo) return fcsv; } // compare AX.25 Frame CheckSum (FCS) value to computed value bool pkt::checkFCS(unsigned char *cp) { // HDLC frame must be at least one byte plus FCS // AX.25 frame must be at least MINOCTETS plus FCS if (cp < &rxbuf[MINOCTETS-1]) return false; /* http://www.tapr.org/pub_ax25.html transmitted AX.25 FCS is big endian (high byte first) and bit-wise reversed for each byte versus the rest of the frame. because we traverse each byte from lsb->msb while receiving or transmitting -- and -- the FCS is transmitted msb->lsb per specification, therefore: >> the FCS must be in the buffer big endian >> with a byte-wise bit-reversed ("reflected") order. ... really. */ /* with more investigating I learn: AX.25 FCS is big endian and bit-wise lsb->msb like all the rest of the octets. so therefore: the FCS goes in the buffer big endian order. ... just that and no more. */ unsigned int fcsv_rcvd = (unsigned int)(cp[0] << 8) | cp[1]; unsigned int fcsv = computeFCS(&rxbuf[1], cp); // begin after leading flag LOG_DEBUG("FCS computed %04X %s received %04X", fcsv, (fcsv_rcvd == fcsv ? "==" : "<>"), fcsv_rcvd); if (fcsv_rcvd == fcsv) return true; return false; } inline void put_rx_const(const char s[]) { unsigned char *p = (unsigned char *) &s[0]; for( ; *p; p++) put_rx_char(*p); } inline void put_rx_hex(unsigned char c) { char v[3]; snprintf(&v[0], 3, "%02x", c); put_rx_char(v[0]); put_rx_char(v[1]); } void pkt::expand_Cmp(unsigned char *cpI) { // APRS Spec 1.0.1 Chapter 9 - Compressed Position Report format unsigned char *cp, tc, cc; unsigned char Cmpbuf[96], *bp = &Cmpbuf[0]; unsigned char *tbp = bp; double Lat, Lon, td; bool sign; cp = cpI+1; // skip past Symbol Table ID char // Latitude as base91 number tc = *cp++ - 33; Lat = tc * 91 * 91 * 91; // fourth digit ==> x * 91^3 tc = *cp++ - 33; Lat += tc * 91 * 91; // third digit ==> x * 91^2 tc = *cp++ - 33; Lat += tc * 91; // second digit ==> x * 91^1 tc = *cp++ - 33; Lat += tc; // units digit ==> x * 91^0 Lat = 90.0 - Lat / 380926.0; // - ==> S, + ==> N // Longitude as base91 number tc = *cp++ - 33; Lon = tc * 91 * 91 * 91; // 4th digit tc = *cp++ - 33; Lon += tc * 91 * 91; // 3rd digit tc = *cp++ - 33; Lon += tc * 91; // 2nd digit tc = *cp++ - 33; Lon += tc; // units digit Lon = -180.0 + Lon / 190463.0; // - ==> W, + ==> E if (Lat < 0) { sign = 1; // has sign (is negative) Lat *= -1; } else sign = 0; td = Lat - floor(Lat); cc = snprintf((char *)bp, 3, "%2.f", (Lat - td)); // DD bp += cc; cc = snprintf((char *)bp, 6, "%05.2f", td*60); // MM.MM bp += cc; if (sign) *bp++ = 'S'; else *bp++ = 'N'; *bp++ = ' '; if (Lon < 0) { sign = 1; Lon *= -1; } else sign = 0; td = Lon - floor(Lon); cc = snprintf((char *)bp, 4, "%03.f", (Lon - td)); // DDD bp += cc; cc = snprintf((char *)bp, 6, "%5.2f", td*60); // MM.MM bp += cc; if (sign) *bp++ = 'W'; else *bp++ = 'E'; cp += 1; // skip past Symbol Code char if (*cp != ' ') { // still more if ((*(cp + 2) & 0x18) == 0x10) { // NMEA source = GGA sentence // compressed Altitude uses chars in the same range // as CSE/SPD but the Compression Type ID takes precedence // when it indicates the NMEA source is a GGA sentence. // so check on this one first and CSE/SPD last. double Altitude; tc = *cp++ - 33; // 2nd digit Altitude = tc * 91; tc = *cp++ - 33; Altitude += tc; // this compressed posit field is not very useful as spec'ed, // since it cannot produce a possible negative altitude! // the NMEA GGA sentence is perfectly capable of providing // a negative altitude value. Mic-E gets this right. // Since the example given in the APRS 1.0.1 Spec uses a value // in excess of 10000, this field should be re-spec'ed as a // value in meters relative to 10km below mean sea level (just // as done in Mic-E). Altitude = pow(1.002, Altitude); if (progdefaults.PKT_unitsSI) cc = snprintf((char *)bp, 11, " %-.1fm", Altitude*0.3048); else // units per Spec cc = snprintf((char *)bp, 12, " %-.1fft", Altitude); bp += cc; } else if (*cp == '{') { // pre-calculated radio range double Range; cp += 1; // skip past ID char tc = *cp++ - 33; // range Range = pow(1.08, (double)tc) * 2; if (progdefaults.PKT_unitsSI) cc = snprintf((char *)bp, 24, " Est. Range = %-.1fkm", Range*1.609); else // units per Spec cc = snprintf((char *)bp, 24, " Est. Range = %-.1fmi", Range); bp += cc; } else if (*cp >= '!' && *cp <= 'z') { // compressed CSE/SPD int Speed; tc = *cp++ - 33; // course cc = snprintf((char *)bp, 8, " %03ddeg", tc*4); bp += cc; tc = *cp++ - 33; // speed Speed = (int)floor(pow(1.08, (double)tc) - 1); // 1.08^tc - 1 kts if (progdefaults.PKT_unitsSI) cc = snprintf((char *)bp, 8, " %03dkph", (int)floor(Speed*1.852+0.5)); else if (progdefaults.PKT_unitsEnglish) cc = snprintf((char *)bp, 8, " %03dmph", (int)floor(Speed*1.151+0.5)); else // units per Spec cc = snprintf((char *)bp, 8, " %03dkts", Speed); bp += cc; } } if (progdefaults.PKT_RXTimestamp) put_rx_const(" "); put_rx_const(" [Cmp] "); for(; tbp < bp; tbp++) put_rx_char(*tbp); put_rx_char('\r'); if (debug::level >= debug::VERBOSE_LEVEL) { cp = cpI+12; // skip to Compression Type ID char if (*(cp - 2) != ' ') { // Cmp Type ID is valid tbp = bp = &Cmpbuf[0]; tc = *cp - 33; // T cc = snprintf((char *)bp, 4, "%02x:", tc); bp += cc; strcpy((char *)bp, " GPS Fix = "); bp += 11; if ((tc & 0x20) == 0x20) { strcpy((char *)bp, "old"); bp += 3; } else { strcpy((char *)bp, "current"); bp += 7; } strcpy((char *)bp, ", NMEA Source = "); bp += 16; switch (tc & 0x18) { case 0x00: strcpy((char *)bp, "other"); bp += 5; break; case 0x08: strcpy((char *)bp, "GLL"); bp += 3; break; case 0x10: strcpy((char *)bp, "GGA"); bp += 3; break; case 0x18: strcpy((char *)bp, "RMC"); bp += 3; break; default: strcpy((char *)bp, "\?\?"); bp += 2; break; } strcpy((char *)bp, ", Cmp Origin = "); bp += 15; switch (tc & 0x07) { case 0x00: strcpy((char *)bp, "Compressed"); bp += 10; break; case 0x01: strcpy((char *)bp, "TNC BText"); bp += 9; break; case 0x02: strcpy((char *)bp, "Software (DOS/Mac/Win/+SA)"); bp += 26; break; case 0x03: strcpy((char *)bp, "[tbd]"); bp += 5; break; case 0x04: strcpy((char *)bp, "KPC3"); bp += 4; break; case 0x05: strcpy((char *)bp, "Pico"); bp += 4; break; case 0x06: strcpy((char *)bp, "Other tracker [tbd]"); bp += 19; break; case 0x07: strcpy((char *)bp, "Digipeater conversion"); bp += 21; break; default: strcpy((char *)bp, "\?\?"); bp += 2; break; } if (progdefaults.PKT_RXTimestamp) put_rx_const(" "); put_rx_const(" [CmpType] "); for(; tbp < bp; tbp++) put_rx_char(*tbp); put_rx_char('\r'); } } } void pkt::expand_PHG(unsigned char *cpI) { // APRS Spec 1.0.1 Chapter 6 - Time and Position format // APRS Spec 1.0.1 Chapter 7 - PHG Extension format bool hasPHG = false; unsigned char *cp, tc, cc; unsigned char PHGbuf[64], *bp = &PHGbuf[0]; unsigned char *tbp = bp; switch (*cpI) { case '!': case '=': // simplest posits cp = cpI+1; // skip past posit ID char if (*cp != '/') { // posit not compressed cp += 19; // skip past posit data } else { // posit is compressed cp += 1; // skip past compressed posit ID char cp += 12; // skip past compressed posit data } if (strncmp((const char *)cp, "PHG", 3) == 0) { // strings match unsigned char ndigits; int power, height; double gain, range; cp += 3; // skip past Data Extension ID chars // get span of chars in cp which are only digits ndigits = strspn((const char *)cp, "0123456789"); switch (ndigits) { //case 1: H might be larger than '9'. code below will work. // must also check that P.GD are all '0'-'9' //break; case 4: // APRS Spec 1.0.1 Chapter 7 page 28 case 5: // PHGR proposed for APRS Spec 1.2 hasPHG = true; tc = *cp++ - '0'; // P power = tc * tc; // tc^2 cc = snprintf((char *)bp, 5, "%dW,", power); bp += cc; tc = *cp++ - '0'; // H *bp++ = ' '; if (tc < 30) { // constrain Height to signed 32bit value height = 10 * (1 << tc); // 10 * 2^tc if (progdefaults.PKT_unitsSI) cc = snprintf((char *)bp, 11, "%dm", (int)floor(height*0.3048+0.5)); else // units per Spec cc = snprintf((char *)bp, 12, "%dft", height); bp += cc; } else { height = 0; strcpy((char *)bp, "-\?\?-"); bp += 4; } strcpy((char *)bp, " HAAT,"); bp += 6; tc = *cp++; // G gain = pow(10, ((double)(tc - '0') / 10)); cc = snprintf((char *)bp, 6, " %cdB,", tc); bp += cc; tc = *cp++ - '0'; // D *bp++ = ' '; if (tc < 9) { strcpy((char *)bp, PHG_table[tc].s); bp += PHG_table[tc].l; } else { strcpy((char *)bp, "-\?\?-"); bp += 4; } *bp++ = ','; range = sqrt(2 * height * sqrt(((double)power / 10) * (gain / 2))); if (progdefaults.PKT_unitsSI) cc = snprintf((char *)bp, 24, " Est. Range = %-.1fkm", range*1.609); else // units per Spec cc = snprintf((char *)bp, 24, " Est. Range = %-.1fmi", range); bp += cc; if (ndigits == 5 && *(cp + 1) == '/') { // PHGR: http://www.aprs.org/aprs12/probes.txt // '1'-'9' and 'A'-'Z' are actually permissible. // does anyone send 10 ('A') or more beacons per hour? strcpy((char *)bp, ", "); bp += 2; tc = *cp++; // R cc = snprintf((char *)bp, 14, "%c beacons/hr", tc); bp += cc; } break; default: // switch(ndigits) break; } } break; default: // switch(*cpI) break; } if (hasPHG) { if (progdefaults.PKT_RXTimestamp) put_rx_const(" "); put_rx_const(" [PHG] "); for(; tbp < bp; tbp++) put_rx_char(*tbp); put_rx_char('\r'); } } void pkt::expand_MicE(unsigned char *cpI, unsigned char *cpE) { // APRS Spec 1.0.1 Chapter 10 - Mic-E Data format bool isMicE = true; bool msgstd = false, msgcustom = false; // decoding starts at first AX.25 dest addr unsigned char *cp = &rxbuf[1], tc, cc; unsigned char MicEbuf[64], *bp = &MicEbuf[0]; unsigned char *tbp = bp; unsigned int msgABC = 0; PKT_MicE_field Lat = North, LonOffset = Zero, Lon = West; for (int i = 0; i < 3; i++) { // remember: AX.25 dest addr chars are shifted left by one tc = *cp++ >> 1; switch (tc & 0xF0) { case 0x30: // MicE_table[0] cc = tc - '0'; if (cc < 10) { *bp++ = MicE_table[0][cc][0]; } else isMicE = false; break; case 0x40: // MicE_table[1] cc = tc - 'A'; if (cc < 12) { bool t = MicE_table[1][cc][1]-'0'; if (t) { msgABC |= t << (2-i); msgcustom = true; } else msgABC &= ~(1 << (2-i)); *bp++ = MicE_table[1][cc][0]; } else isMicE = false; break; case 0x50: // MicE_table[2] cc = tc - 'P'; if (cc < 11) { msgABC |= (MicE_table[2][cc][1]-'0') << (2-i); msgstd = true; *bp++ = MicE_table[2][cc][0]; } else isMicE = false; break; default: // Invalid isMicE = false; break; } } for (int i = 3; i < 6; i++) { // remember: AX.25 dest addr chars are shifted left by one tc = *cp++ >> 1; switch (i) { case 3: switch (tc & 0xF0) { case 0x30: // MicE_table[0] cc = tc - '0'; if (cc < 10) { Lat = MicE_table[0][cc][2]; *bp++ = MicE_table[0][cc][0]; } else isMicE = false; break; case 0x40: // MicE_table[1] cc = tc - 'A'; if (cc == 11) { Lat = MicE_table[1][cc][2]; *bp++ = MicE_table[1][cc][0]; } else isMicE = false; break; case 0x50: // MicE_table[2] cc = tc - 'P'; if (cc < 11) { Lat = MicE_table[2][cc][2]; *bp++ = MicE_table[2][cc][0]; } else isMicE = false; break; default: // Invalid isMicE = false; break; } break; case 4: switch (tc & 0xF0) { case 0x30: // MicE_table[0] cc = tc - '0'; if (cc < 10) { LonOffset = MicE_table[0][cc][3]; *bp++ = MicE_table[0][cc][0]; } else isMicE = false; break; case 0x40: // MicE_table[1] cc = tc - 'A'; if (cc == 11) { LonOffset = MicE_table[1][cc][3]; *bp++ = MicE_table[1][cc][0]; } else isMicE = false; break; case 0x50: // MicE_table[2] cc = tc - 'P'; if (cc < 11) { LonOffset = MicE_table[2][cc][3]; *bp++ = MicE_table[2][cc][0]; } else isMicE = false; break; default: // Invalid isMicE = false; break; } break; case 5: switch (tc & 0xF0) { case 0x30: // MicE_table[0] cc = tc - '0'; if (cc < 10) { Lon = MicE_table[0][cc][4]; *bp++ = MicE_table[0][cc][0]; } else isMicE = false; break; case 0x40: // MicE_table[1] cc = tc - 'A'; if (cc == 11) { Lon = MicE_table[1][cc][4]; *bp++ = MicE_table[1][cc][0]; } else isMicE = false; break; case 0x50: // MicE_table[2] cc = tc - 'P'; if (cc < 11) { Lon = MicE_table[2][cc][4]; *bp++ = MicE_table[2][cc][0]; } else isMicE = false; break; default: // Invalid isMicE = false; break; } break; default: // Invalid isMicE = false; break; } } if (isMicE) { int Speed = 0, Course = 0; if (progdefaults.PKT_RXTimestamp) put_rx_const(" "); put_rx_const(" [Mic-E] "); if (msgstd && msgcustom) put_rx_const("Unknown? "); else if (msgcustom) { put_rx_const("Custom-"); put_rx_char((7 - msgABC)+'0'); put_rx_const(". "); } else { switch (msgABC) { // APRS Spec 1.0.1 Chapter 10 page 45 case 0: put_rx_const("Emergency"); break; case 1: put_rx_const("Priority"); break; case 2: put_rx_const("Special"); break; case 3: put_rx_const("Committed"); break; case 4: put_rx_const("Returning"); break; case 5: put_rx_const("In Service"); break; case 6: put_rx_const("En Route"); break; case 7: put_rx_const("Off Duty"); break; default: put_rx_const("-\?\?-"); break; } if (msgABC) put_rx_char('.'); else put_rx_char('!'); // Emergency! put_rx_char(' '); } for (; tbp < bp; tbp++) { put_rx_char(*tbp); if (tbp == (bp - 3)) put_rx_char('.'); } if (Lat == North) put_rx_char('N'); else if (Lat == South) put_rx_char('S'); else put_rx_char('\?'); put_rx_char(' '); cp = cpI+1; // one past the Data Type ID char // decode Lon degrees - APRS Spec 1.0.1 Chapter 10 page 48 tc = *cp++ - 28; if (LonOffset == P100) tc += 100; if (tc > 179 && tc < 190) tc -= 80; else if (tc > 189 && tc < 200) tc -= 190; cc = snprintf((char *)bp, 4, "%03d", tc); bp += cc; // decode Lon minutes tc = *cp++ - 28; if (tc > 59) tc -= 60; cc = snprintf((char *)bp, 3, "%02d", tc); bp += cc; // decode Lon hundredths of a minute tc = *cp++ - 28; cc = snprintf((char *)bp, 3, "%02d", tc); bp += cc; for (; tbp < bp; tbp++) { put_rx_char(*tbp); if (tbp == (bp - 3)) put_rx_char('.'); } if (Lon == East) put_rx_char('E'); else if (Lon == West) put_rx_char('W'); else put_rx_char('\?'); // decode Speed and Course - APRS Spec 1.0.1 Chapter 10 page 52 tc = *cp++ - 28; // speed: hundreds and tens if (tc > 79) tc -= 80; Speed = tc * 10; tc = *cp++ - 28; // speed: units and course: hundreds Course = (tc % 10); // remainder from dividing by 10 tc -= Course; tc /= 10; // tc is now quotient from dividing by 10 Speed += tc; if (Course > 3) Course -= 4; Course *= 100; tc = *cp++ - 28; // course: tens and units Course += tc; if (progdefaults.PKT_unitsSI) cc = snprintf((char *)bp, 8, " %03dkph", (int)floor(Speed*1.852+0.5)); else if (progdefaults.PKT_unitsEnglish) cc = snprintf((char *)bp, 8, " %03dmph", (int)floor(Speed*1.151+0.5)); else // units per Spec cc = snprintf((char *)bp, 8, " %03dkts", Speed); bp += cc; cc = snprintf((char *)bp, 8, " %03ddeg", Course); bp += cc; for (; tbp < bp; tbp++) { put_rx_char(*tbp); } cp += 2; // skip past Symbol and Symbol Table ID chars if (cp <= cpE) { // still more if (*cp == '>') { cp += 1; put_rx_const(" TH-D7"); } else if (*cp == ']' && *cpE == '=') { cp += 1; cpE -= 1; put_rx_const(" TM-D710"); } else if (*cp == ']') { cp += 1; put_rx_const(" TM-D700"); } else if (*cp == '\'' && *(cpE - 1) == '|' && *cpE == '3') { cp += 1; cpE -= 2; put_rx_const(" TT3"); } else if (*cp == '\'' && *(cpE - 1) == '|' && *cpE == '4') { cp += 1; cpE -= 2; put_rx_const(" TT4"); } else if (*cp == '`' && *(cpE - 1) == '_' && *cpE == ' ') { cp += 1; cpE -= 2; put_rx_const(" VX-8"); } else if (*cp == '`' && *(cpE - 1) == '_' && *cpE == '#') { cp += 1; cpE -= 2; put_rx_const(" VX-8D/G"); // VX-8G for certain. guessing. } else if (*cp == '`' && *(cpE - 1) == '_' && *cpE == '\"') { cp += 1; cpE -= 2; put_rx_const(" FTM-350"); } else if ((*cp == '\'' || *cp == '`') && *(cp + 4) == '}') { cp += 1; // tracker? rig? ID codes are somewhat ad hoc. put_rx_const(" MFR\?"); } if (cp < cpE) { if (*(cp + 3) == '}') { // station altitude as base91 number int Altitude = 0; tc = *cp++ - 33; // third digit ==> x * 91^2 Altitude = tc * 91 * 91; tc = *cp++ - 33; // second digit ==> x * 91^1 ==> x * 91 Altitude += tc * 91; tc = *cp++ - 33; // unit digit ==> x * 91^0 ==> x * 1 Altitude += tc; Altitude -= 10000; // remove offset from datum *bp++ = ' '; if (Altitude >= 0) *bp++ = '+'; if (progdefaults.PKT_unitsEnglish) cc = snprintf((char *)bp, 12, "%dft", (int)floor(Altitude*3.281+0.5)); else // units per Spec cc = snprintf((char *)bp, 11, "%dm", Altitude); bp += cc; for (; tbp < bp; tbp++) { put_rx_char(*tbp); } cp += 1; // skip past '}' } } if (cp < cpE) put_rx_char(' '); for (; cp <= cpE; cp++) put_rx_char(*cp); } put_rx_char('\r'); } } void pkt::do_put_rx_char(unsigned char *cp) { int i, j; unsigned char c; bool isMicE = false; unsigned char *cpInfo; for (i = 8; i < 14; i++) { // src callsign is second in AX.25 frame c = rxbuf[i] >> 1; if (c != ' ') put_rx_char(c); // skip past padding (if any) } // bit 7 = command/response bit // bits 6,5 = 1 // bits 4-1 = src SSID // bit 0 = last callsign flag c = (rxbuf[14] & 0x7f) >> 1; if (c > 0x30) { put_rx_char('-'); if (c < 0x3a) put_rx_char(c); else { put_rx_char('1'); put_rx_char(c-0x0a); } } put_rx_char('>'); for (i = 1; i < 7; i++) { // dest callsign is first in AX.25 frame c = rxbuf[i] >> 1; if (c != ' ') put_rx_char(c); } c = (rxbuf[7] & 0x7f) >> 1; if (c > 0x30) { put_rx_char('-'); if (c < 0x3a) put_rx_char(c); else { put_rx_char('1'); put_rx_char(c-0x0a); } } j=8; if ((rxbuf[14] & 0x01) != 1) { // check last callsign flag do { put_rx_char(','); j += 7; for (i = j; i < (j+6); i++) { c = rxbuf[i] >> 1; if (c != ' ') put_rx_char(c); } c = (rxbuf[j+6] & 0x7f) >> 1; if (c > 0x30) { put_rx_char('-'); if (c < 0x3a) put_rx_char(c); else { put_rx_char('1'); put_rx_char(c-0x0a); } } } while ((rxbuf[j+6] & 0x01) != 1); if (rxbuf[j+6] & 0x80) // packet gets no more hops put_rx_char('*'); } if (debug::level < debug::VERBOSE_LEVEL) { // skip past CTRL and PID to INFO bytes when I_FRAME // puts buffer pointer in FCS when U_FRAME and S_FRAME // (save CTRL byte for possible MicE decoding) j += 7; c = rxbuf[j]; j += 2; } else { // show more frame info when .ge. VERBOSE debug level j += 7; put_rx_char(';'); c = rxbuf[j]; // CTRL present in all frames if ((c & 0x01) == 0) { // I_FRAME unsigned char p = rxbuf[j+1]; // PID present only in I_FRAME if (debug::level == debug::DEBUG_LEVEL) { put_rx_hex(c); put_rx_char(' '); put_rx_hex(p); put_rx_char(';'); } put_rx_const("I/"); put_rx_hex( (c & 0xE0) >> 5 ); // AX.25 v2.2 para 2.3.2.1 if (c & 0x10) put_rx_char('*'); // P/F bit else put_rx_char('.'); put_rx_hex( (c & 0x0E) >> 1 ); put_rx_char('/'); switch (p) { // AX.25 v2.2 para 2.2.4 case 0x01: put_rx_const("X.25PLP"); break; case 0x06: put_rx_const("C-TCPIP"); break; case 0x07: put_rx_const("U-TCPIP"); break; case 0x08: put_rx_const("FRAG"); break; case 0xC3: put_rx_const("TEXNET"); break; case 0xC4: put_rx_const("LQP"); break; case 0xCA: put_rx_const("ATALK"); break; case 0xCB: put_rx_const("ATALK-ARP"); break; case 0xCC: put_rx_const("ARPA-IP"); break; case 0xCD: put_rx_const("ARPA-AR"); break; case 0xCE: put_rx_const("FLEXNET"); break; case 0xCF: put_rx_const("NET/ROM"); break; case 0xF0: put_rx_const("NO-L3"); break; case 0xFF: put_rx_const("L3ESC="); put_rx_hex(rxbuf[++j]); break; default: if ((p & 0x30) == 0x10) put_rx_const("L3V1"); else if ((p & 0x30) == 0x20) put_rx_const("L3V2"); else put_rx_const("L3-RSVD"); put_rx_char('='); put_rx_hex(p); break; } } else if ((c & 0x03) == 0x01) { // S_FRAME if (debug::level == debug::DEBUG_LEVEL) { put_rx_hex(c); put_rx_char(';'); } put_rx_const("S/"); put_rx_hex( (c & 0xE0) >> 5 ); if (c & 0x10) put_rx_char('*'); else put_rx_char('.'); put_rx_char('/'); switch (c & 0x0C) { // AX.25 v2.2 para 2.3.4.2 case 0x00: put_rx_const("RR"); break; case 0x04: put_rx_const("RNR"); break; case 0x08: put_rx_const("REJ"); break; case 0x0C: default: put_rx_const("UNK"); break; } } else if ((c & 0x03) == 0x03) { // U_FRAME if (debug::level == debug::DEBUG_LEVEL) { put_rx_hex(c); put_rx_char(';'); } put_rx_char('U'); if (c & 0x10) put_rx_char('*'); else put_rx_char('.'); switch (c & 0xEC) { // AX.25 v2.2 para 2.3.4.3 case 0x00: put_rx_const("UI"); break; case 0x0E: put_rx_const("DM"); break; case 0x1E: put_rx_const("SABM"); break; case 0x20: put_rx_const("DISC"); break; case 0x30: put_rx_const("UA"); break; case 0x81: put_rx_const("FRMR"); break; default: put_rx_const("UNK"); break; } } j+=2; } put_rx_char(':'); // ptr to first info field char cpInfo = &rxbuf[j]; if ((c & 0x03) == 0x03 && (c & 0xEC) == 0x00 && (*cpInfo == '\'' || *cpInfo == '`' || *cpInfo == 0x1C || *cpInfo == 0x1D) && (cp - cpInfo) > 7) { /* Mic-E must have at least 8 info chars + Data Type ID char cp - (cpInfo - 1) > 8 ==> cp - cpInfo > 7 */ // this is very probably a Mic-E encoded packet isMicE = true; } // offset between last info char (not FCS) and bufhead i = (cp - &rxbuf[0]); // (cp - &rxbuf[1]) + 1 ==> (cp - &rxbuf[0]) while (j < i) put_rx_char(rxbuf[j++]); if (*(cp-1) != '\r') put_rx_char('\r'); // <cr> only for packets not ending with <cr> // cp points to FCS, so (cp-X) is last info field char if ((progdefaults.PKT_expandMicE || debug::level >= debug::VERBOSE_LEVEL) && isMicE) expand_MicE(cpInfo, (*(cp-1) == '\r' ? cp-2 : cp-1)); // need to deal with posits having timestamps ('/' and '@' leading char) if (*cpInfo == '!' || *cpInfo == '=') { if ((progdefaults.PKT_expandCmp || debug::level >= debug::VERBOSE_LEVEL) && (*(cpInfo + 1) == '/' || *(cpInfo + 1) == '\\')) // compressed posit expand_Cmp(cpInfo+1); if (progdefaults.PKT_expandPHG || debug::level >= debug::VERBOSE_LEVEL) // look for PHG data expand_PHG(cpInfo); } if (*(cp-1) == '\r') put_rx_char('\r'); // for packets ending with <cr>: show it on-screen } void pkt::rx(bool bit) { static unsigned char c = 0, bcounter = 0; c >>= 1; ++bcounter; if (bit == false) { c &= ~(1 << (pkt_nbits-1)); // bits are sent lsb first if (seq_ones == 6) { // flag byte found bcounter = 0; if (cbuf >= &rxbuf[MINOCTETS]) { // flag at end of frame *cbuf = PKT_Flag; // == 0x7e if (debug::level == debug::DEBUG_LEVEL) fprintf(stderr,"7e\n"); // monitor Metric and Squelch Level if ( !progStatus.sqlonoff || metric >= progStatus.sldrSquelchValue ) { // lazy eval /* // check FCS at end of frame // if FCS is OK - packet is in rxbuffer, // put_rx_char() for each byte in rxbuffer */ if (checkFCS((cbuf - 2)) == true) { if (progdefaults.PKT_RXTimestamp) { unsigned char ts[16], *tc = &ts[0]; time_t t = time(NULL); struct tm stm; (void)gmtime_r(&t, &stm); snprintf((char *)ts, sizeof(ts), "[%02d:%02d:%02d] ", stm.tm_hour, stm.tm_min, stm.tm_sec); while (*tc) put_rx_char(*tc++); } do_put_rx_char((cbuf - 2)); } } cbuf = &rxbuf[0]; // reset after first end frame flag } else { // packet too short if cbuf < &rxbuf[MINOCTETS] // put only one beginning flag into buffer rxbuf[0] = PKT_Flag; cbuf = &rxbuf[1]; if (debug::level == debug::DEBUG_LEVEL) fprintf(stderr,"7e "); } } else if (seq_ones == 5) { // need bit un-stuffing c <<= 1; // shift c back to skip stuffed bit --bcounter; } seq_ones = 0; } else { c |= (1 << (pkt_nbits-1)); // bits are sent lsb first ++seq_ones; //if (seq_ones > 6) { // something is wrong //} } if (bcounter == pkt_nbits) { bcounter = 0; if (cbuf < &rxbuf[MAXOCTETS]) { *cbuf++ = c; if (debug::level == debug::DEBUG_LEVEL) fprintf(stderr,"%02x ",c); } else // else complain: cbuf is at MAXOCTETS LOG_WARN("Long input packet, %d octets!",(int)(cbuf - &rxbuf[0])); } /* // when flag found: keep collecting flags (0x7e) until !(0x7e) found // (first non-0x7e begins DATA) // keep collecting bits in DATA, 8 at-a-time, until 0x7e found // while collecting bits, perform bit-unstuffing so we place in // databuffer exactly 8 bits at-a-time // (at times more than 8 bits in to 8 bits out) // first trailing 0x7e ends DATA and begins STOP */ } void pkt::Metric() { double snr = 0; double pr = signal_power / noise_power; power_ratio = decayavg(power_ratio, pr, pr-power_ratio > 0 ? 2 : 8); snr = 10*log10( power_ratio ); snprintf(msg2, sizeof(msg2), "s/n %3.0f dB", snr-snr_avg); put_Status2(msg2); metric = CLAMP(power_ratio, 0.0, 100.0); display_metric(metric); if (metric < 5.0) snr_avg = decayavg(snr_avg, snr, 8); } void pkt::idle_signal_power(double sample) { // average of signal energy over PKT_IdleLen duration sample *= sample; idle_signal_pwr += sample; idle_signal_pwr -= idle_signal_buf[idle_signal_buf_ptr]; idle_signal_buf[idle_signal_buf_ptr] = sample; ++idle_signal_buf_ptr %= pkt_idlelen; // circular buffer } #ifndef NDEBUG double pkt::corr_power(cmplx z) #else inline double pkt::corr_power(cmplx z) #endif { // scaled magnitude double power = norm(z); power /= 2 * symbollen; return power; } void pkt::correlate(double sample) { cmplx yl, yh, yt; yl = nco_lo->cmplx_sample(); yl *= sample; lo_signal_energy += yl; lo_signal_energy -= lo_signal_buf[correlate_buf_ptr]; lo_signal_buf[correlate_buf_ptr] = yl; lo_signal_corr = lo_signal_gain * corr_power(lo_signal_energy); yh = nco_hi->cmplx_sample(); yh *= sample; hi_signal_energy += yh; hi_signal_energy -= hi_signal_buf[correlate_buf_ptr]; hi_signal_buf[correlate_buf_ptr] = yh; hi_signal_corr = hi_signal_gain * corr_power(hi_signal_energy); yt = nco_mid->cmplx_sample(); yt *= sample; mid_signal_energy += yt; mid_signal_energy -= mid_signal_buf[correlate_buf_ptr]; mid_signal_buf[correlate_buf_ptr] = yt; //mid_signal_corr = corr_power(mid_signal_energy); ++correlate_buf_ptr %= symbollen; // SymbolLen correlation window yt = mid_signal_energy; if (abs(lo_signal_corr - hi_signal_corr) < 0.2) { // mid-symbol or noise pipe[pipeptr] = 0.0; QI[QIptr] = cmplx(yt.imag(), yt.real()); } else if (lo_signal_corr > hi_signal_corr) { pipe[pipeptr] = 0.5; QI[QIptr] = cmplx (0.125 * yt.imag(), yt.real()); } else { pipe[pipeptr] = -0.5; QI[QIptr] = cmplx( yt.real(), 0.125 * yt.imag()); } ++pipeptr %= pkt_syncdisplen; yt_avg = decayavg(yt_avg, abs(yt), symbollen/2); if (yt_avg > 0) QI[QIptr] = QI[QIptr] / yt_avg; ++QIptr %= MAX_ZLEN; } void pkt::detect_signal() { double sig_corr = lo_signal_corr + hi_signal_corr;// - mid_signal_corr; signal_pwr += sig_corr; signal_pwr -= signal_buf[signal_buf_ptr]; signal_buf[signal_buf_ptr] = sig_corr; ++signal_buf_ptr %= pkt_detectlen; // circular buffer signal_power = signal_pwr / pkt_detectlen * signal_gain; noise_power = idle_signal_pwr / pkt_idlelen; // allow lazy eval if (signal_power > PKT_MinSignalPwr && signal_power > noise_power) { // lo+hi freq signals are present detect_drop = pkt_detectlen; // reset signal drop counter if (rxstate == PKT_RX_STATE_DROP) { rxstate = PKT_RX_STATE_START; // init STATE_START signal_gain = 1.0; // 5.0 scounter = pkt_detectlen; //(was) 9 * symbollen;//11 instead of 9? lo_sync = 100.0; hi_sync = -100.0; } } else if (--detect_drop < 1 && rxstate == PKT_RX_STATE_DATA) { // lazy eval // give up on signals - gone,gone. rxstate = PKT_RX_STATE_STOP; scounter = 0; // (scounter is signed int) if (debug::level == debug::DEBUG_LEVEL) fprintf(stderr,"\n"); } } void pkt::do_sync() { double power_delta = lo_signal_corr - hi_signal_corr; lo_sync_ptr--; hi_sync_ptr--; if (lo_sync > power_delta && power_delta < 0) { lo_sync_ptr = 0; lo_sync = power_delta; } if (hi_sync < power_delta && power_delta > 0) { hi_sync_ptr = 0; hi_sync = power_delta; } if (--scounter < 1) { int offset; if (fabs(hi_sync) > fabs(lo_sync)) offset = -hi_sync_ptr; else offset = -lo_sync_ptr; offset %= symbollen; // clamp offset to +/- one symbol mid_symbol = symbollen - offset; prev_symbol = pll_symbol = hi_signal_corr < lo_signal_corr; rxstate = PKT_RX_STATE_DATA; seq_ones = 0; // reset once on transition to STATE_DATA cbuf = &rxbuf[0]; // and reset packet buffer ptr } } void pkt::rx_data() { bool tbit = hi_signal_corr < lo_signal_corr; // detect current symbol mid_symbol -= 1; int imid_symbol = (int) floor(mid_symbol+0.5); // hard-decision symbol decoding. done at mid-symbol (imid_symbol < 1). // // might do instead a soft-decision by cumulative voting // of more than one mid-symbol sample? symbollen-2 samples max? // if (imid_symbol < 1) { // counting down to middle of next symbol bool bit = prev_symbol == tbit; // detect symbol change prev_symbol = pll_symbol = tbit; mid_symbol += symbollen; // advance to middle of next symbol // remember to check value of reverse here to determine symbol rx(reverse ? !bit : bit); } else if (tbit != pll_symbol) { // update PLL if (mid_symbol < ((double)symbollen/2)) mid_symbol += PKT_PLLAdjVal; else mid_symbol -= PKT_PLLAdjVal; pll_symbol = tbit; } } int pkt::rx_process(const double *buf, int len) { double x_n; if (select_val != progdefaults.PKT_BAUD_SELECT) { // need to re-init modem restart(); } Metric(); while (len-- > 0) { x_n = *buf++; switch (rxstate) { case PKT_RX_STATE_STOP: default: rxstate = PKT_RX_STATE_IDLE; // fallthrough with next sample (x_(n+1)) case PKT_RX_STATE_IDLE: idle_signal_power( x_n ); if (--scounter < 1) { rxstate = PKT_RX_STATE_DROP; scounter = pkt_idlelen; signal_gain = 1.0; signal_pwr = signal_buf_ptr = 0; for(int i = 0; i < pkt_detectlen; i++) signal_buf[i] = 0; lo_signal_energy = hi_signal_energy = mid_signal_energy = cmplx(0, 0); yt_avg = correlate_buf_ptr = 0; for(int i = 0; i < symbollen; i++) lo_signal_buf[i] = hi_signal_buf[i] = mid_signal_buf[i] = cmplx(0, 0); } break; case PKT_RX_STATE_DROP: idle_signal_power( x_n ); correlate( x_n ); detect_signal(); break; case PKT_RX_STATE_START: correlate( x_n ); do_sync(); break; case PKT_RX_STATE_DATA: correlate( x_n ); rx_data(); detect_signal(); break; } } // while(len) if (metric < progStatus.sldrSquelchValue && progStatus.sqlonoff) { if (clear_zdata) { for (int i = 0; i < MAX_ZLEN; i++) QI[i] = cmplx(0,0); QIptr = 0; set_zdata(QI, MAX_ZLEN); clear_zdata = false; clear_syncscope(); } } else { clear_zdata = true; update_syncscope(); set_zdata(QI, MAX_ZLEN); } return 0; } //===================================================================== // PKT1200 transmit //===================================================================== void pkt::send_symbol(bool bit) { if (reverse) bit = !bit; for (int i = 0; i < symbollen; i++) { if (bit) outbuf[i] = hi_tone->sample() * hi_txgain; // modem::outbuf[] else outbuf[i] = lo_tone->sample() * lo_txgain; // modem::outbuf[] } // adjust nco phase accumulator to pick up where the other nco left off if (bit) lo_tone->setphaseacc(hi_tone->getphaseacc()); else hi_tone->setphaseacc(lo_tone->getphaseacc()); ModulateXmtr(outbuf, symbollen); // ignore retv? } /* void pkt::send_stop() { double freq; bool invert = reverse; if (invert) freq = get_txfreq_woffset() - pkt_shift / 2.0; else freq = get_txfreq_woffset() + pkt_shift / 2.0; // stoplen = 0; // stoplen ::= (int) ((1.0 * 12000 / 1200) + 0.5) = 10 for (int i = 0; i < stoplen; i++) { outbuf[i] = nco(freq); if (invert) FSKbuf[i] = 0.0 * FSKnco(); else FSKbuf[i] = FSKnco(); } if (progdefaults.PseudoFSK) ModulateStereo(outbuf, FSKbuf, stoplen); else ModulateXmtr(outbuf, stoplen); } */ void pkt::send_char(unsigned char c) { // if nostuff == 1 then { do _no_ bit stuffing } // else { keep track of no-transition (one bits) and stuff as needed } for (int i = 0; i < pkt_nbits; i++) { if ((c & 0x01) == 0) { currbit = !currbit; // transition on zero bits send_symbol(currbit); nr_ones = 0; } else { send_symbol(currbit); if (++nr_ones == 5 && !nostuff) { currbit = !currbit; // stuff zero bit send_symbol(currbit); nr_ones = 0; } } c >>= 1; // lsb to msb bit order } } string upcase(string s) { // this function is also defined in arq::upcase // how to make a fldigi::upcase and use it here and in flarq? // maybe add it to misc/strutil.cxx ? for (size_t i = 0; i < s.length(); i++) s[i] = toupper(s[i]); return s; } void pkt::send_msg(unsigned char c) { // form TX pane incoming chars into a valid UI AX.25 packet // in KISS mode, we do not create a packet header. if (!did_pkt_head) { int i, j; // the following is split into two because putting it all together // as "upcase(progdefaults.myCall).c_str()" would compile but not // work correctly. Callsign decoded as "******-9" (wrong!). string ts = upcase(progdefaults.myCall); const char *src = ts.c_str(), // MYCALL dest2[] = "WIDE2 "; // digi char dest[7]; snprintf(dest, 7, "APL%1d%02d", FLDIGI_VERSION_MAJOR, FLDIGI_VERSION_MINOR); // dest[] = "APL321" for (i = 7, j = 0; i < 13; i++, j++) { // put src callsign in frame if (src[j] == 0) break; txbuf[i] = src[j] << 1; } while (j++ < 6) { txbuf[i++] = ' ' << 1; // padding } txbuf[13] = '9' << 1; // src + SSID ==> MYCALL-9 for (i = 0, j = 0; i < 6; i++, j++ ) { // put dest callsign in frame txbuf[i] = dest[j] << 1; } txbuf[6] = '1' << 1; // dest[] + SSID ==> APL321-1 if (pkt_baud >= 1200) { for (i = 14, j = 0; i < 20; i++, j++) { // put digi callsign in frame txbuf[i] = dest2[j] << 1; } txbuf[20] = '1' << 1; // dest2[] + SSID ==> WIDE1-1 txbuf[20] |= 0x01; // add last callsign flag tx_cbuf = &txbuf[21]; } else { // use no digi when baud < 1200. limited bandwidth! txbuf[6] |= 0x01; // add last callsign flag tx_cbuf = &txbuf[14]; } *tx_cbuf++ = 0x03; // add CTRL val for U_FRAME type UI *tx_cbuf++ = 0xf0; unsigned char *tc = &txbuf[0]; while (tc < tx_cbuf) { send_char(*tc++); tx_char_count--; // must count header chars in pkt length } did_pkt_head = true; } send_char(c); *tx_cbuf++ = c; } int pkt::tx_process() { if (pretone > 0) { while (pretone-- > 0) { send_symbol(0); // Mark (low) tone } } if (preamble > 0) { nostuff = 1; // turn off bit stuffing here while (preamble-- > 0) { send_char(PKT_Flag); } nostuff = 0; // send_char() is 8-bit clean tx_char_count--; // count only last flag char } static int c = 0; if (tx_char_count > 0) c = get_tx_char(); // TX buffer empty // if (c == 0x03 || stopflag) { if (c == GET_TX_CHAR_ETX || stopflag || tx_char_count == 0) { if (!stopflag) { // compute FCS and add it to the frame via *tx_cbuf unsigned int fcs = computeFCS(&txbuf[0], tx_cbuf); // (B == Byte, b == bit) unsigned char tc = (fcs & 0xFF00) >> 8; // msB *tx_cbuf++ = tc; send_char(tc); tc = (unsigned char)(fcs & 0x00FF); // lsB *tx_cbuf++ = tc; send_char(tc); nostuff = 1; // turn off bit stuffing while (postamble-- > 0) { send_char(PKT_Flag); } nostuff = 0; stopflag = true; return 0; } stopflag = false; tx_char_count = MAXOCTETS-3; // leave room for FCS and end-flag tx_cbuf = &txbuf[0]; currbit = 0; did_pkt_head = false; cwid(); return -1; } if (tx_char_count-- > 0) send_msg((unsigned char)c); else { // else complain: maybe auto-segment? LOG_WARN("Long output packet, %d octets!",(int)(tx_cbuf - &txbuf[0])); return -1; } return 0; }
54,691
C++
.cxx
1,925
25.736104
84
0.600577
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,216
fmt_dialog.cxx
w1hkj_fldigi/src/fmt/fmt_dialog.cxx
// ---------------------------------------------------------------------------- // fmt_dialog.cxx -- fmt modem // // Copyright (C) 2020 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <iostream> #include <FL/Fl_Box.H> #include "configuration.h" #include "confdialog.h" #include "gettext.h" #include "fmt_dialog.h" #include "fmt.h" #include "fl_digi.h" #include "modem.h" #include "status.h" plot_xy *fmt_plot = (plot_xy *)0; Fl_Group *ref_group = (Fl_Group *)0; Fl_Light_Button *btn_ref_enable = (Fl_Light_Button *)0; Fl_Button *btn_ref_up = (Fl_Button *)0; Fl_Counter *cnt_ref_freq = (Fl_Counter *)0; Fl_Button *btn_ref_dn = (Fl_Button *)0; Fl_Button *btn_ref_reset = (Fl_Button *)0; Fl_Button *btn_ref_clear = (Fl_Button *)0; Fl_Output *fmt_ref_val = (Fl_Output *)0; Fl_Output *fmt_ref_db = (Fl_Output *)0; Fl_Box *ref_color = (Fl_Box *)0; Fl_Group *unk_group = (Fl_Group *)0; Fl_Light_Button *btn_unk_enable = (Fl_Light_Button *)0; Fl_Button *btn_unk_up = (Fl_Button *)0; Fl_Counter *cnt_unk_freq = (Fl_Counter *)0; Fl_Button *btn_unk_dn = (Fl_Button *)0; Fl_Button *btn_unk_reset = (Fl_Button *)0; Fl_Button *btn_unk_clear = (Fl_Button *)0; Fl_Output *fmt_unk_val = (Fl_Output *)0; Fl_Output *fmt_unk_db = (Fl_Output *)0; Fl_Box *unk_color = (Fl_Box *)0; Fl_Light_Button *btn_fmt_record = (Fl_Light_Button *)0; Fl_Box *box_fmt_recording = (Fl_Box *)0; Fl_ListBox *fmt_rec_interval = (Fl_ListBox *)0; Fl_ListBox *fmt_scale = (Fl_ListBox *)0; Fl_ListBox *fmt_cntr_minutes = (Fl_ListBox *)0; static const char *legend_p100 = "-.010|-.008|-.006|-.004|-.002|0|.002|.004|.006|.008|.010"; static const char *legend_p50 = "-0.05|-0.04|-0.03|-0.02|-0.01|0|0.01|0.02|0.03|0.04|0.05"; static const char *legend_p10 = "-.10|-.08|-.06|-.04|-.02|0|.02|.04|.06|.08|.10"; static const char *legend_p25 = "-0.25|-0.2|-0.15|-0.10|-0.05|0|0.05|0.10|0.15|0.20|0.25"; static const char *legend_p5 = "-0.5|-0.4|-0.3|-0.2|-0.1|0|0.1|0.2|0.3|0.4|0.5"; static const char *legend_1p = "-1.0|-0.8|-0.6|-0.4|-0.2|0|0.2|0.4|0.6|0.8|1.0"; static const char *legend_2p = "-2.0|-1.5|-1.0|-0.5|0|0.5|1.0|1.5|2.0"; static const char *legend_4p = "-4.0|-3.5|-3.0|-2.5|-2.0|-1.5|-1.0|-0.5|0|0.5|1.0|1.5|2.0|2.5|3.0|3.5|4.0"; static const char *legend_5p = "5.0|-4.0|-3.0|-2.0|-1.0|0|1.0|2.0|3.0|4.0|5.0"; static const char *legend_10p = "-10.0|-8.0|-6.0|-4.0|-2.0|0|2.0|4.0|6.0|8.0|10.0"; static const char *legend_5 = " |4|3|2|1| |"; static const char *legend_15 = " |14|13|12|11|10|9|8|7|6|5|4|3|2|1| |"; static const char *legend_30 = " |28|26|24|22|20|18|16|14|12|10|8|6|4|2| |"; static const char *legend_60 = " |55|50|45|40|35|30|25|20|15|10|5| |"; static const char *legend_120 = " |110|100|90|80|70|60|50|40|30|20|10| |"; static int seconds[5] = {300, 900, 1800, 3600, 7200}; void cb_unk_up(void *) { double f = cnt_unk_freq->value () + 10; if (f > 3000) f = 3000; cnt_unk_freq->value (f); cnt_unk_freq->callback (); } void cb_unk_dn(void *) { double f = cnt_unk_freq->value () - 10; if (f < 100) f = 100; cnt_unk_freq->value (f); cnt_unk_freq->callback (); } void cb_ref_up(void *) { double f = cnt_ref_freq->value () + 10; if (f > 3000) f = 3000; cnt_ref_freq->value (f); cnt_ref_freq->callback (); } void cb_ref_dn(void *) { double f = cnt_ref_freq->value () - 10; if (f < 100) f = 100; cnt_ref_freq->value (f); cnt_ref_freq->callback (); } void cb_btn_fmt_record(void *) { write_recs = btn_fmt_record->value(); } void cb_btn_unk_enable(void *) { set_unk_freq(NULL); record_unk = btn_unk_enable->value(); } void cb_btn_ref_enable(void *) { set_ref_freq(NULL); record_ref = btn_ref_enable->value(); } void fmt_rec_interval_cb(void *) { progStatus.FMT_rec_interval = fmt_rec_interval->index(); } void fmt_set_x_scale() { int minutes = 0; int markers = 0; const char *legend = NULL; switch (progStatus.FMT_minutes) { case 4: minutes = 120; markers = 12; legend = legend_120; break; case 3: minutes = 60; markers = 12; legend = legend_60; break; case 2: minutes = 30; markers = 15; legend = legend_30; break; case 1: minutes = 15; markers = 15; legend = legend_15; break; case 0: default: minutes = 5; markers = 5; legend = legend_5; } fmt_plot->x_scale (MAX_DATA_PTS - 60 * minutes, MAX_DATA_PTS, markers); fmt_plot->set_x_legend (legend); fmt_plot->thick_lines(progdefaults.FMT_thick_lines); fmt_plot->plot_over_axis(progdefaults.FMT_plot_over_axis); fmt_plot->redraw(); } void fmt_set_y_scale() { switch (progStatus.FMT_trk_scale) { case 0 : fmt_plot->y_scale(-0.01, 0.01, 10); fmt_plot->set_y_legend(legend_p100); break; case 1 : fmt_plot->y_scale(-0.05, .05, 10); fmt_plot->set_y_legend(legend_p50); break; case 2 : fmt_plot->y_scale(-0.10, 0.10, 10); fmt_plot->set_y_legend(legend_p10); break; case 3 : fmt_plot->y_scale(-0.25, .25, 10); fmt_plot->set_y_legend(legend_p25); break; case 4 : fmt_plot->y_scale(-0.5, .5, 10); fmt_plot->set_y_legend(legend_p5); break; case 5 : fmt_plot->y_scale(-1.0, 1.0, 10); fmt_plot->set_y_legend(legend_1p); break; case 6 : fmt_plot->y_scale(-2.0, 2.0, 8); fmt_plot->set_y_legend(legend_2p); break; case 7 : fmt_plot->y_scale(-4.0, 4.0, 16); fmt_plot->set_y_legend(legend_4p); break; case 8 : fmt_plot->y_scale(-5.0, 5.0, 10); fmt_plot->set_y_legend(legend_5p); break; case 9 : fmt_plot->y_scale(-10.0, 10.0, 10); fmt_plot->set_y_legend(legend_10p); break; default: fmt_plot->y_scale(-1.0, 1.0, 10); fmt_plot->set_y_legend(legend_1p); break; } fmt_plot->redraw(); } void fmt_scale_cb(void *) { progStatus.FMT_trk_scale = fmt_scale->index(); fmt_set_y_scale(); } void fmt_cntr_minutes_cb(void *) { progStatus.FMT_minutes = fmt_cntr_minutes->index(); fmt_set_x_scale(); } Fl_Group* fmt_panel(int X, int Y, int W, int H) { Fl_Group* grp = new Fl_Group(X, Y, W, H); int grp_height = 24; fmt_plot = new plot_xy ( grp->x() + 2, grp->y() + 2, grp->w() - 4, grp->h() - 4- 2 * grp_height, ""); fmt_plot->reverse_x(progdefaults.FMT_reverse); fmt_plot->bk_color (progdefaults.FMT_background); fmt_plot->line_color_1 (progdefaults.FMT_unk_color); fmt_plot->line_color_2 (progdefaults.FMT_ref_color); fmt_plot->axis_color (progdefaults.FMT_axis_color); fmt_plot->legend_color (progdefaults.FMT_legend_color); fmt_set_x_scale (); fmt_set_y_scale (); fmt_plot->show_1(false); fmt_plot->show_2(false); ref_group = new Fl_Group( fmt_plot->x(), fmt_plot->y() + fmt_plot->h(), fmt_plot->w(), 24); ref_group->box(FL_ENGRAVED_BOX); btn_unk_enable = new Fl_Light_Button( ref_group->x() + 2, ref_group->y() + 2, 50, 20, "Unk'"); btn_unk_enable->selection_color(progdefaults.default_btn_color); btn_unk_enable->callback((Fl_Callback *)cb_btn_unk_enable); unk_color = new Fl_Box( btn_unk_enable->x() + btn_unk_enable->w() + 2, btn_unk_enable->y() + 4, 12, 12, ""); unk_color->box(FL_DOWN_BOX); unk_color->color(progdefaults.FMT_unk_color); btn_unk_dn = new Fl_Button( unk_color->x() + unk_color->w() + 2, btn_unk_enable->y(), 20, 20, "@|<"); btn_unk_dn->callback((Fl_Callback*)cb_unk_dn); cnt_unk_freq = new Fl_Counter( btn_unk_dn->x() + btn_unk_dn->w(), btn_unk_dn->y(), 120, 20, ""); cnt_unk_freq->minimum(100); cnt_unk_freq->maximum(4000); cnt_unk_freq->step(0.1); cnt_unk_freq->lstep(1.0); cnt_unk_freq->value(progStatus.FMT_unk_freq); cnt_unk_freq->callback((Fl_Callback*)set_unk_freq); btn_unk_up = new Fl_Button( cnt_unk_freq->x() + cnt_unk_freq->w(), cnt_unk_freq->y(), 20, 20, "@>|"); btn_unk_up->callback((Fl_Callback*)cb_unk_up); btn_unk_reset = new Fl_Button( btn_unk_up->x() + btn_unk_up->w() + 2, btn_unk_up->y(), 50, 20, "Reset"); btn_unk_reset->callback((Fl_Callback*)cb_unk_reset); btn_unk_reset->tooltip("Reset unknown frequency"); fmt_unk_val = new Fl_Output( btn_unk_reset->x() + btn_unk_reset->w() + 4, btn_unk_enable->y(), 110, 20, ""); fmt_unk_val->value(0); fmt_unk_db = new Fl_Output( fmt_unk_val->x() + fmt_unk_val->w() + 6, btn_unk_enable->y(), 50, 20, ""); fmt_unk_db->value(""); fmt_unk_db->tooltip("amplitude in dBvp"); btn_unk_clear = new Fl_Button( fmt_unk_db->x() + fmt_unk_db->w() + 6, fmt_unk_val->y(), 60, 20, "Clear"); btn_unk_clear->callback((Fl_Callback*)cb_unk_clear); btn_unk_clear->tooltip("Clear unknown plot"); Fl_Group *dmy1 = new Fl_Group( btn_unk_clear->x() + btn_unk_clear->w(), btn_unk_clear->y(), 1, btn_unk_clear->h()); dmy1->box(FL_FLAT_BOX); dmy1->end(); btn_fmt_record = new Fl_Light_Button( ref_group->x() + ref_group->w() - 84, dmy1->y(), 80, 20, "Record"); btn_fmt_record->callback((Fl_Callback *)cb_btn_fmt_record); box_fmt_recording = new Fl_Box( btn_fmt_record->x() - 20, btn_fmt_record->y() + 4, 12, 12, ""); box_fmt_recording->box(FL_DOWN_BOX); box_fmt_recording->color(FL_WHITE); fmt_rec_interval = new Fl_ListBox( box_fmt_recording->x() - 110, btn_fmt_record->y(), 85, 20, "Interval"); fmt_rec_interval->align(FL_ALIGN_LEFT); fmt_rec_interval->add("0.10 sec"); fmt_rec_interval->add("0.25 sec"); fmt_rec_interval->add("0.50 sec"); fmt_rec_interval->add("1.0 sec"); fmt_rec_interval->add("2.0 sec"); fmt_rec_interval->add("5.0 sec"); fmt_rec_interval->add("10.0 sec"); fmt_rec_interval->color(FL_WHITE); fmt_rec_interval->index(progStatus.FMT_rec_interval); fmt_rec_interval->callback((Fl_Callback *)fmt_rec_interval_cb); fmt_rec_interval->tooltip(_("Record update every NN seconds")); ref_group->end(); ref_group->resizable(dmy1); unk_group = new Fl_Group( ref_group->x(), ref_group->y() + ref_group->h(), ref_group->w(), grp_height); unk_group->box(FL_ENGRAVED_BOX); btn_ref_enable = new Fl_Light_Button( unk_group->x() + 2, unk_group->y() + 2, 50, 20, "Ref'"); btn_ref_enable->selection_color(progdefaults.default_btn_color); btn_ref_enable->callback((Fl_Callback *)cb_btn_ref_enable); ref_color = new Fl_Box( btn_ref_enable->x() + btn_ref_enable->w() + 2, btn_ref_enable->y() + 4, 12, 12, ""); ref_color->box(FL_DOWN_BOX); ref_color->color(progdefaults.FMT_ref_color); btn_ref_dn = new Fl_Button( unk_color->x() + unk_color->w() + 2, btn_ref_enable->y(), 20, 20, "@|<"); btn_ref_dn->callback((Fl_Callback*)cb_ref_dn); cnt_ref_freq = new Fl_Counter( cnt_unk_freq->x(), btn_ref_dn->y(), 120, 20, ""); cnt_ref_freq->minimum(100); cnt_ref_freq->maximum(4000); cnt_ref_freq->step(0.1); cnt_ref_freq->lstep(1.0); cnt_ref_freq->value(progStatus.FMT_ref_freq); cnt_ref_freq->callback((Fl_Callback*)set_ref_freq); btn_ref_up = new Fl_Button( btn_unk_up->x(), cnt_ref_freq->y(), 20, 20, "@>|"); btn_ref_up->callback((Fl_Callback*)cb_ref_up); btn_ref_reset = new Fl_Button( btn_ref_up->x() + btn_ref_up->w() + 2, btn_ref_up->y(), 50, 20, "Reset"); btn_ref_reset->callback((Fl_Callback*)cb_ref_reset); btn_ref_reset->tooltip("Reset unknown tracking frequency"); fmt_ref_val = new Fl_Output( btn_ref_reset->x() + btn_ref_reset->w() + 2, btn_ref_reset->y(), 110, 20, ""); fmt_ref_val->value(""); fmt_ref_db = new Fl_Output( fmt_unk_db->x(), fmt_ref_val->y(), 50, 20, ""); fmt_ref_db->value(""); fmt_ref_db->tooltip("amplitude in dBvp"); btn_ref_clear = new Fl_Button( btn_unk_clear->x(), fmt_ref_val->y(), 60, 20, "Clear"); btn_ref_clear->callback((Fl_Callback*)cb_ref_clear); btn_ref_clear->tooltip("Clear reference plot"); Fl_Group *dmy2 = new Fl_Group( btn_ref_clear->x() + btn_ref_clear->w(), btn_ref_clear->y(), 1, btn_ref_clear->h()); dmy2->box(FL_FLAT_BOX); dmy2->end(); fmt_scale = new Fl_ListBox( unk_group->x() + unk_group->w() - 84, dmy2->y(), 80, 20, "Scale"); fmt_scale->align(FL_ALIGN_LEFT); fmt_scale->add("+/- .01"); fmt_scale->add("+/- .05"); fmt_scale->add("+/- .10"); fmt_scale->add("+/- .25"); fmt_scale->add("+/- .5"); fmt_scale->add("+/- 1"); fmt_scale->add("+/- 2"); fmt_scale->add("+/- 4"); fmt_scale->add("+/- 5"); fmt_scale->add("-/- 10"); fmt_scale->color(FL_WHITE); fmt_scale->index(progStatus.FMT_trk_scale); fmt_scale->callback((Fl_Callback *)fmt_scale_cb); fmt_scale->tooltip(_("Vertical scale of tracks")); fmt_cntr_minutes = new Fl_ListBox( fmt_scale->x() - 130, fmt_scale->y(), 85, 20, "T-scale"); fmt_cntr_minutes->align(FL_ALIGN_LEFT); fmt_cntr_minutes->add("5 min"); fmt_cntr_minutes->add("15 min"); fmt_cntr_minutes->add("30 min"); fmt_cntr_minutes->add("60 min"); fmt_cntr_minutes->add("120 min"); fmt_cntr_minutes->color(FL_WHITE); fmt_cntr_minutes->index(progStatus.FMT_minutes); fmt_cntr_minutes->callback((Fl_Callback *)fmt_cntr_minutes_cb); fmt_cntr_minutes->tooltip(_("Time scale span in minutes")); unk_group->end(); unk_group->resizable(dmy2); grp->end(); grp->resizable (fmt_plot); return grp; } void put_unk_value (const char *msg) { fmt_unk_val->value (msg); } void put_ref_value (const char *msg) { fmt_ref_val->value (msg); } void put_unk_amp (const char *msg) { fmt_unk_db->value (msg); } void put_ref_amp (const char *msg) { fmt_ref_db->value (msg); } void set_ref_freq (void *) { progStatus.FMT_ref_freq = cnt_ref_freq->value(); wf->draw_fmt_marker(); active_modem->reset_reference(); } void set_unk_freq (void *) { progStatus.FMT_unk_freq = cnt_unk_freq->value(); wf->draw_fmt_marker(); active_modem->reset_unknown(); } void set_unk_freq_value(double f) { cnt_unk_freq->value(f); progStatus.FMT_unk_freq = f; wf->draw_fmt_marker(); active_modem->reset_unknown(); } void set_ref_freq_value(double f) { cnt_ref_freq->value(f); progStatus.FMT_ref_freq = f; wf->draw_fmt_marker(); active_modem->reset_reference(); } void cb_unk_reset (void *) { active_modem->reset_unknown(); } void cb_unk_clear (void *) { fmt_modem->clear_unk_pipe(); fmt_plot->data_1(NULL, 0); fmt_plot->redraw(); } void cb_ref_reset (void *) { active_modem->reset_reference(); } void cb_ref_clear (void *) { fmt_modem->clear_ref_pipe(); fmt_plot->data_2(NULL, 0); fmt_plot->redraw(); } void set_fmt_scope() { guard_lock datalock (&scope_mutex); int num_pts = seconds[progStatus.FMT_minutes]; fmt_plot->data_1 (&fmt_modem->unk_pipe[MAX_DATA_PTS - num_pts], num_pts); fmt_plot->data_2 (&fmt_modem->ref_pipe[MAX_DATA_PTS - num_pts], num_pts); fmt_plot->redraw(); } void clear_ref_scope() { fmt_plot->data_2 (&fmt_modem->ref_pipe[MAX_DATA_PTS], MAX_DATA_PTS); fmt_plot->redraw(); Fl::flush(); } void clear_unk_scope() { fmt_plot->data_1 (&fmt_modem->ref_pipe[MAX_DATA_PTS], MAX_DATA_PTS); fmt_plot->redraw(); Fl::flush(); }
15,608
C++
.cxx
474
30.270042
79
0.627848
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,217
fmt.cxx
w1hkj_fldigi/src/fmt/fmt.cxx
// ---------------------------------------------------------------------------- // fmt.cxx -- fmt modem // // Copyright (C) 2020 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <string> #include <cstdio> #include <ctime> #include <iostream> #include <fstream> #include <cstdarg> #include <unistd.h> #include <string.h> #include "configuration.h" #include "confdialog.h" #include "fmt.h" #include "fmt_dialog.h" #include "modem.h" #include "misc.h" #include "filters.h" #include "fftfilt.h" #include "digiscope.h" #include "waterfall.h" #include "main.h" #include "fl_digi.h" #include "timeops.h" #include "debug.h" #include "qrunner.h" #include "status.h" // RnA discriminator #define fmt_DFT_LEN 51200 #define fmt_LPF_LEN 512 #define fmt_BPF_LEN 512 static int srs[] = {8000, 11025, 12000, 16000, 22050, 24000, 44100, 48000}; //static int dftlen[] = {1024, 1536, 1536, 2048, 2560, 2560, 5120, 6144}; // ~8 DFTs per second //static int dftlen[] = {2048, 2560, 3072, 4096, 5632, 6144, 11264, 12288}; // ~4 DFTs per second //static int dftlen[] = {4096, 5632, 6144, 8192, 11264, 12288, 22528, 24576}; // ~2 DFTs per second static int dftlen[] = {8192, 11264, 12288, 16384, 22528, 24576, 45056, 49152}; // ~1 DFTs per second //static int dftblocks[] = {16, 22, 24, 32, 44, 48, 88, 96}; // # 512 sample blocks for 1 DFT / second static char msg1[80]; static char msg1a[80]; static char msg2[80]; static char msg2a[80]; static double fmt_ref_frequency = 0; static double fmt_ref_base_freq = 0; static double fmt_ref_amp = 0; static double fmt_unk_frequency = 0; static double fmt_unk_base_freq = 0; static double fmt_unk_amp = 0; static std::string fmt_filename; static std::string fmt_wav_filename; static std::string fmt_wav_pathfname; static char file_datetime_name[200]; pthread_mutex_t scope_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t data_mutex = PTHREAD_MUTEX_INITIALIZER; //====================================================================== // FMT Thread loop //====================================================================== static pthread_t FMT_thread; static int rec_interval[] = { 10, 25, 50, 100, 200, 500, 1000 }; bool record_unk = false; bool record_ref = false; bool write_recs = false; static bool FMT_exit = false; static bool FMT_enabled = false; static bool is_recording = false; static char s_clk_time[40]; static int csvrow = 0; static bool fmt_start = true; static bool record_ok = false; static time_t fmt_time = 0; static time_t last_epoch = 0; static time_t curr_epoch = 0; static struct tm fmt_tm; static struct timeval fmt_tv; static double ufreq = 0, uamp = 0; static double rfreq = 0, ramp = 0; // formatting std::strings used by csv export method static std::string csv_string; static std::string buffered_csv_string; // uncomment next line to enable debugging data file //#define DEBUG_CSV #ifdef DEBUG_CSV static std::string debug_csv_string; #endif static char comma_format[] = "\ \"T %02d:%02d:%02d.%02d\",\ \"%6.2f\",\ \"%13.3f\",\ \"%13.4f\",\ \"%0.4f\",\ \"%6.4f\",\ \"%s\",\ \"%6.2f\",,\ \"%13.4f\",\ \"%0.4f\",\ \"%s\",\ \"%6.2f\"\ ,,\"=L%d-F%d-D%d\"\n"; static char tab_format[] = "\ \"T %02d:%02d:%02d.%02d\"\t\ \"%6.2f\"\t\ \"%13.3f\"\t\ \"%13.4f\"\t\ \"%0.4f\"\t\ \"%6.4f\"\t\ \"%s\"\t\ \"%6.2f\"\t\t\ \"%13.4f\"\t\ \"%0.4f\"\t\ \"%s\"\t\ \"%6.2f\"\ \t\t\"=L%d-F%d-D%d\"\n"; static char usb_ref_equation[] = "=C%d + (D%d + E%d + F%d)"; static char lsb_ref_equation[] = "=C%d - (D%d + E%d + F%d)"; static char usb_unk_equation[] = "=C%d + (D%d + J%d + K%d)"; static char lsb_unk_equation[] = "=C%d - (D%d + J%d + K%d)"; static char ref_equation[50]; static char unk_equation[50]; void set_button ( void *d ) { Fl_Button *b = (Fl_Button *)d; b->value(1); } void clear_button ( void *d ) { Fl_Button *b = (Fl_Button *)d; b->value(0); } std::string txtout; void set_output (void *) { txt_fmt_wav_filename->value(txtout.c_str()); } void start_fmt_wav_record() { time_t wav_time = time(NULL); struct tm File_Start_Date; gmtime_r(&wav_time, &File_Start_Date); static char temp[200]; strftime(temp, sizeof(temp), "fmt_%Y.%m.%d.%H.%M.%S", &File_Start_Date); fmt_wav_pathfname.assign(FMTDir). append(temp). append(".").append((progdefaults.myCall.empty() ? "nil" : progdefaults.myCall)). append(".wav"); if(!RXscard->startCapture(fmt_wav_pathfname, SF_FORMAT_WAV | SF_FORMAT_PCM_16)) { Fl::awake( clear_button, btn_fmt_record_wav); txtout.clear(); Fl::awake (set_output); is_recording = false; return; } is_recording = true; txtout = temp; Fl::awake (set_output); } void cb_fmt_record_wav(bool b) { if (!b) { RXscard->stopCapture(); txtout.clear(); Fl::awake (set_output); is_recording = false; return; } if (!is_recording) start_fmt_wav_record(); } static void show(void *) { btn_fmt_record_wav->value(1); txt_fmt_wav_filename->value(fmt_wav_pathfname.c_str()); } static void noshow(void *) { btn_fmt_record_wav->value(0); txt_fmt_wav_filename->value(""); } static std::ofstream csv_file; static void fmt_create_file() { struct tm File_Start_Date; gmtime_r(&curr_epoch, &File_Start_Date); std::string call = progdefaults.myCall.empty() ? "nil" : progdefaults.myCall; strftime((char*)file_datetime_name, sizeof(file_datetime_name), "%Y.%m.%d.%H.%M.%S", &File_Start_Date); fmt_filename.assign(FMTDir). append("fmt_"). append(file_datetime_name). append(".").append(call). append(".csv"); csv_file.open(fmt_filename.c_str()); if (!csv_file.is_open()) { LOG_ERROR("fl_fopen: %s", fmt_filename.c_str()); return; } // A , B , C , D , E , F , G , H ,I, J , K , L , M ,N, O , P, Q , R // Clock,Elapsed,Xcvr VFO,Freq Corr,Ref WF Freq,Ref Corr,Ref Est Freq,Ref dBVpk, ,Unk WF Freq,Unk Corr,Unk Est Freq,Unk dBVpk, ,Unk Compensated , // , , , , , , , , , , , , , , ,Average:,=average(O:O) // , , , , , , , , , , , , , , ,Std Dev:,=stdev(O:O) csv_string.assign("\ \"Clock\",\"Elapsed\",\"Xcvr VFO\",\"Freq Corr\",\ \"Ref WF Freq\",\"Ref Corr\",\"Ref Est Freq\",\"Ref dBVpk\",,\ \"Unk WF Freq\",\"Unk Corr\",\"Unk Est Freq\",\"Unk dBVpk\",,\ \"Unk Compensated\","); csv_string.append(call).append(",").append(file_datetime_name).append("\n"); csv_string.append("\ ,,,,,,,,,,,,,,,\"Average:\",\"=average(O:O)\"\n"), csv_string.append("\ ,,,,,,,,,,,,,,,\"Std Dev:\",\"=stdev(O:O)\"\n"); if (progdefaults.FMT_use_tabs) { for (size_t n = 0; n < csv_string.length(); n++) if (csv_string[n] == ',') csv_string[n] = '\t'; } csvrow = 4; if (progdefaults.fmt_sync_wav_file && !is_recording) { fmt_wav_pathfname.assign(FMTDir). append(file_datetime_name). append(".").append(call). append(".wav"); if(!RXscard->startCapture(fmt_wav_pathfname, SF_FORMAT_WAV | SF_FORMAT_PCM_16)) { Fl::awake (noshow); is_recording = false; } else { Fl::awake (show); is_recording = true; } } #ifdef DEBUG_CSV debug_csv_string = csv_string; #endif put_status (file_datetime_name); } void fmt_reset_record() { Fl::awake (clear_button, btn_fmt_record); if (progdefaults.fmt_sync_wav_file) { Fl::awake ( clear_button, btn_fmt_record_wav); cb_fmt_record_wav(false); } txtout.clear(); Fl::awake (set_output); } void fmt_show_recording(void *on) { if (on == (void *)1) { box_fmt_recording->color(FL_DARK_RED); } else { box_fmt_recording->color(FL_WHITE); } box_fmt_recording->redraw(); } int fmt_auto_record = false; int start_auto_record = 0; int autorecord_time = 0; void start_auto_tracking(void *) { LOG_INFO("%s", "start auto record in 10 secs"); btn_unk_enable->value(1); btn_unk_enable->redraw(); btn_ref_enable->value(1); btn_ref_enable->redraw(); } void start_auto_recording(void *) { LOG_INFO("%s", "start auto record now"); btn_fmt_record->value(1); btn_fmt_record->redraw(); fmt_create_file(); return; } void stop_auto_recording(void *) { LOG_INFO("%s", "stop auto record"); btn_unk_enable->value(0); btn_unk_enable->redraw(); btn_ref_enable->value(0); btn_ref_enable->redraw(); btn_fmt_record->value(0); btn_fmt_record->redraw(); write_recs = false; } static char sz_temp[512]; #ifdef DEBUG_CSV // debugging void write_debug_string() { std::string debug_filename; debug_filename.assign(FMTDir).append("debug.csv"); rotate_log(debug_filename); FILE *csv_debug = fopen(debug_filename.c_str(), "w"); fprintf(csv_debug, "%s", debug_csv_string.c_str()); fclose(csv_debug); debug_csv_string.clear(); } #endif void fmt_write_file() { fmt_start = true; static int ticks = 0; static int hrs = 0, mins = 0, secs = 0; static bool reset_ticks = false; if (gettimeofday (&fmt_tv, NULL)) { return; } fmt_time = time(NULL); last_epoch = fmt_time + 1; while (fmt_time < last_epoch) { MilliSleep(1); fmt_time = time(NULL); } gmtime_r(&fmt_time, &fmt_tm); last_epoch = fmt_time; hrs = fmt_tm.tm_hour; mins = fmt_tm.tm_min; secs = fmt_tm.tm_sec; ticks = 0; for (;;) { if (FMT_exit || active_modem->get_mode() != MODE_FMT) break; curr_epoch = time(NULL); if (curr_epoch != last_epoch) { last_epoch = curr_epoch; if (++secs >= 60) { secs = 0; if (++mins >= 60) { mins = 0; if (++hrs >= 24) hrs = 0; } } if (fmt_auto_record == 2 && secs == start_auto_record) { Fl::awake(start_auto_recording); fmt_auto_record = 3; autorecord_time = -1; } if ((++autorecord_time >= cnt_fmt_auto_record_time->value()) && fmt_auto_record == 3) { Fl::awake(stop_auto_recording); fmt_auto_record = 0; } if (reset_ticks) { ticks = 0; reset_ticks = false; } else { if (ticks % 100 < 50) ticks = ticks - ticks % 100; else ticks = ticks - ticks % 100 + 100; } snprintf(s_clk_time, sizeof(s_clk_time), "%02d:%02d:%02d", hrs, mins, secs); put_Status1 (s_clk_time); record_ok = true; } if (btn_fmt_autorecord->value()) { if (fmt_auto_record == 1) { Fl::awake(start_auto_tracking); start_auto_record = secs + 10; if (start_auto_record > 60) start_auto_record -= 60; fmt_auto_record = 2; } } else fmt_auto_record = 0; if (!record_unk && !record_ref && !btn_fmt_autorecord->value()) { if (csv_file.is_open()) { buffered_csv_string.assign(csv_string); csv_file << buffered_csv_string; csv_file.flush(); csv_file.close(); #ifdef DEBUG_CSV debug_csv_string.append(csv_string); write_debug_string(); #endif csv_string.clear(); } Fl::awake (fmt_show_recording, (void *)0); fmt_reset_record(); put_Status1 (""); put_status (""); MilliSleep(50); break; } if (write_recs && !csv_file.is_open()) { fmt_create_file(); record_ok = false; reset_ticks = true; Fl::awake (fmt_show_recording, (void *)1); } else if (!write_recs && csv_file.is_open()) { Fl::awake (fmt_show_recording, (void *)0); buffered_csv_string.assign(csv_string); csv_file << buffered_csv_string; csv_file.flush(); csv_file.close(); #ifdef DEBUG_CSV debug_csv_string.append(csv_string); write_debug_string(); #endif csv_string.clear(); put_Status1 (""); put_status (""); fmt_reset_record(); } if (ticks % rec_interval[progStatus.FMT_rec_interval] == 0) { if (record_ok && (record_unk || record_ref) && write_recs && csv_file.is_open()) { { guard_lock datalock (&data_mutex); ufreq = fmt_unk_base_freq; uamp = fmt_unk_amp; rfreq = fmt_ref_base_freq; ramp = fmt_ref_amp; } if (record_unk) { uamp = 20.0 * log10( (uamp == 0 ? 1e-6 : uamp) ); } else { ufreq = 0; uamp = -160; } if (record_ref) { ramp = 20.0 * log10( (ramp == 0 ? 1e-6 : ramp) ); } else { rfreq = 0; ramp = -160; } if (wf->USB()) { snprintf(ref_equation, sizeof(ref_equation), usb_ref_equation, csvrow, csvrow, csvrow, csvrow); snprintf(unk_equation, sizeof(unk_equation), usb_unk_equation, csvrow, csvrow, csvrow, csvrow); } else { snprintf(ref_equation, sizeof(ref_equation), lsb_ref_equation, csvrow, csvrow, csvrow, csvrow); snprintf(unk_equation, sizeof(unk_equation), lsb_unk_equation, csvrow, csvrow, csvrow, csvrow); } snprintf(sz_temp, sizeof(sz_temp), (progdefaults.FMT_use_tabs ? tab_format : comma_format), hrs, mins, secs, ticks % 100, ticks * 0.01, 1.0 * qsoFreqDisp->value(), progdefaults.FMT_freq_corr, (record_ref ? progStatus.FMT_ref_freq : 0), rfreq, (record_ref ? ref_equation : "0"), ramp, (record_unk ? progStatus.FMT_unk_freq : 0), ufreq, (record_unk ? unk_equation : "0"), uamp, csvrow, csvrow, csvrow); csv_string.append(sz_temp); csvrow++; buffered_csv_string.assign(csv_string); csv_file << buffered_csv_string; csv_file.flush(); #ifdef DEBUG_CSV debug_csv_string.append(csv_string); #endif csv_string.clear(); } } ticks++; MilliSleep(10); } } void *FMT_loop(void *args) { SET_THREAD_ID(FMT_TID); while(1) { MilliSleep(50); if (FMT_exit) break; record_unk = btn_unk_enable->value(); record_ref = btn_ref_enable->value(); if (record_unk || record_ref || btn_fmt_autorecord->value()) { fmt_write_file(); } } // exit the FMT thread SET_THREAD_CANCEL(); return NULL; } //====================================================================== // //====================================================================== void FMT_thread_init(void) { FMT_exit = false; if (pthread_create(&FMT_thread, NULL, FMT_loop, NULL) < 0) { LOG_ERROR("%s", "pthread_create failed"); return; } LOG_INFO("%s", "FMT thread started"); FMT_enabled = true; } //====================================================================== // //====================================================================== void FMT_thread_close(void) { if (!FMT_enabled) return; FMT_exit = true; pthread_join(FMT_thread, NULL); FMT_enabled = false; FMT_thread = 0; LOG_INFO("%s", "FMT thread closed"); } void fmt::tx_init() { } void fmt::rx_init() { put_MODEstatus(mode); } void fmt::init() { modem::init(); rx_init(); } fmt::~fmt() { delete unk_ffilt; delete unk_afilt; delete ref_ffilt; delete ref_afilt; delete [] unk_pipe; delete [] ref_pipe; // RnA delete [] fftbuff; delete [] unkbuff; delete [] refbuff; delete [] BLACKMAN; delete unk_bpfilter; delete ref_bpfilter; cb_fmt_record_wav(false); } bool clear_unknown_pipe = false; void fmt::clear_unk_pipe() { clear_unknown_pipe = true; } bool clear_reference_pipe = false; void fmt::clear_ref_pipe() { clear_reference_pipe = true; } double fmt::blackman(double omega) { return (0.42 - 0.50 * cos(twoPI * omega) + 0.08 * cos(4 * M_PI * omega)); } void fmt::restart() { if (progdefaults.FMT_sr < 0) progdefaults.FMT_sr = 0; if (progdefaults.FMT_sr > 7) progdefaults.FMT_sr = 7; sr = progdefaults.FMT_sr; samplerate = srs[sr]; Ts = 1.0 / samplerate; set_samplerate(samplerate); unk_ffilt->setLength (movavg_len = 0); unk_afilt->setLength (movavg_len); ref_ffilt->setLength (movavg_len); ref_afilt->setLength (movavg_len); unk_freq = progStatus.FMT_unk_freq; unk_ffilt->reset(); unk_afilt->reset(); unk_count = 0; dspcnt = DSP_CNT; for (int i = 0; i < MAX_DATA_PTS; i++) { unk_pipe[i].x = i + 1; unk_pipe[i].y = 100; } ref_ffilt->reset(); ref_afilt->reset(); ref_freq = progStatus.FMT_ref_freq; ref_count = 0; { guard_lock datalock (&scope_mutex); for (int i = 0; i < MAX_DATA_PTS; i++) { ref_pipe[i].x = i + 1; ref_pipe[i].y = 100; } } double tau = 1.0 / (dftlen[sr] - 1); for (int i = 0; i < dftlen[sr]; i++) { BLACKMAN[i] = blackman( i * tau ); } for (int i = 0; i < fmt_DFT_LEN; i++) { fftbuff[i] = 0; unkbuff[i] = 0; refbuff[i] = 0; } reset_bpf(); // delta conversion coefficients, only change with change in sample rate dmK = tan(M_PI / (2.0 * dftlen[sr])); srK = srs[sr] / M_PI; } fmt::fmt() { mode = MODE_FMT; if (progdefaults.FMT_sr < 1) progdefaults.FMT_sr = 1; if (progdefaults.FMT_sr > 6) progdefaults.FMT_sr = 6; samplerate = srs[progdefaults.FMT_sr]; unk_pipe = new PLOT_XY[MAX_DATA_PTS]; ref_pipe = new PLOT_XY[MAX_DATA_PTS]; movavg_len = progdefaults.FMT_movavg_len; unk_ffilt = new Cmovavg(movavg_len); unk_afilt = new Cmovavg(movavg_len); ref_ffilt = new Cmovavg(movavg_len); ref_afilt = new Cmovavg(movavg_len); cap &= ~CAP_TX; // RnA BLACKMAN = new double[fmt_DFT_LEN]; fftbuff = new double[fmt_DFT_LEN]; unkbuff = new double[fmt_DFT_LEN]; refbuff = new double[fmt_DFT_LEN]; unk_bpfilter = new C_FIR_filter(); ref_bpfilter = new C_FIR_filter(); twoPI = 2.0 * M_PI; restart(); FMT_thread_init(); } void fmt::reset_unknown() { unk_count = 0; } void fmt::reset_reference() { ref_count = 0; } // --------------------------------------------------------------------- // DFT estimator using T&R algorithm // --------------------------------------------------------------------- void fmt::reset_bpf() { int fillen = fmt_BPF_LEN; double fhi = 0; double flo = 0; bpf_width = progdefaults.FMT_bpf_width; fhi = 1.0 * (unk_freq + bpf_width / 2) / samplerate; flo = 1.0 * (unk_freq - bpf_width / 2) / samplerate; unk_bpfilter->init_bandpass (fillen, 1, flo, fhi); fhi = 1.0 * (ref_freq + bpf_width / 2) / samplerate; flo = 1.0 * (ref_freq - bpf_width / 2) / samplerate; ref_bpfilter->init_bandpass (fillen, 1, flo, fhi); set_bandwidth(20); } double fmt::absdft (double *buff, double fm, double incr) { double rval = 0; double ival = 0; double omega = fm * Ts + incr / dftlen[sr]; for( int i = 0; i < dftlen[sr]; i++) { rval += buff[i] * cos(twoPI * i * omega); ival += buff[i] * sin(twoPI * i * omega); } return 2.0 * sqrt(rval * rval + ival * ival) / dftlen[sr]; } double fmt::evaluate_dft(double &freq){ for (int n = 0; n < 2; n++) { am = absdft (fftbuff, freq, -0.5); bm = absdft (fftbuff, freq, 0.5 ); if (am + bm == 0) break; dm = (bm - am) / (bm + am); delta = srK * atan(dm * dmK); if (abs(delta) > progdefaults.FMT_HL_level) { if (progdefaults.FMT_HL_on) { LOG_ERROR("HDL: %f", delta); delta = (delta < 0 ? -1 : 1) * progdefaults.FMT_HL_level; } else if (progdefaults.FMT_dft_cull_on) { LOG_ERROR("CUL: %f", delta); delta = 0; } } freq += delta; } return 2.39883 * absdft(fftbuff, freq, 0); } int fmt::rx_process_dft() { double amp; if (unk_count == 0 || ((fabs(dft_unk_base) > progdefaults.FMT_freq_err) && record_unk) ) { unk_freq = progStatus.FMT_unk_freq; unk_count = 1; LOG_VERBOSE("FMT unknown freq reset to track @ %f Hz", progStatus.FMT_unk_freq); } if (ref_count == 0 || ((fabs(dft_ref_base) > progdefaults.FMT_freq_err) && record_ref) ) { ref_freq = progStatus.FMT_ref_freq; ref_count = 1; LOG_VERBOSE("FMT reference freq reset to track @ %f Hz", progStatus.FMT_ref_freq); } // unknown tracking for (int i = 0; i < dftlen[sr]; i++) fftbuff[i] = BLACKMAN[i] * unkbuff[i]; amp = evaluate_dft(unk_freq); if (progdefaults.FMT_movavg_len > 0) { dft_unk_base = unk_ffilt->run (unk_freq - progStatus.FMT_unk_freq); dft_unk_amp = unk_afilt->run (amp); } else { dft_unk_base = unk_freq - progStatus.FMT_unk_freq; dft_unk_amp = amp; } // reference tracking for (int i = 0; i < dftlen[sr]; i++) fftbuff[i] = BLACKMAN[i] * refbuff[i]; amp = evaluate_dft(ref_freq); if (progdefaults.FMT_movavg_len > 0) { dft_ref_base = ref_ffilt->run (ref_freq - progStatus.FMT_ref_freq); dft_ref_amp = ref_afilt->run (amp); } else { dft_ref_base = ref_freq - progStatus.FMT_ref_freq; dft_ref_amp = amp; } return 0; } static int smpl_counter = 0; static int blk_counter = 0; int fmt::rx_process(const double *buf, int len) { if (sr != progdefaults.FMT_sr) { restart(); ref_count = 0; unk_count = 0; } if (movavg_len != progdefaults.FMT_movavg_len) { movavg_len = progdefaults.FMT_movavg_len; unk_ffilt->setLength (movavg_len * samplerate / len); unk_afilt->setLength (movavg_len * samplerate / len); ref_ffilt->setLength (movavg_len * samplerate / len); ref_afilt->setLength (movavg_len * samplerate / len); } if (clear_unknown_pipe) { guard_lock datalock (&scope_mutex); for (int i = 0; i < MAX_DATA_PTS; i++) { unk_pipe[i].x = i + 1; unk_pipe[i].y = 100; } clear_unknown_pipe = false; REQ (clear_unk_scope); } if (clear_reference_pipe) { guard_lock datalock (&scope_mutex); for (int i = 0; i < MAX_DATA_PTS; i++) { ref_pipe[i].x = i + 1; ref_pipe[i].y = 100; } clear_reference_pipe = false; REQ (clear_ref_scope); } double out, in; for (int i = 0; i < fmt_DFT_LEN - len; i++) { unkbuff[i] = unkbuff[i + len]; refbuff[i] = refbuff[i + len]; } for (int i = 0; i < len; i++) { in = buf[i]; if (progdefaults.FMT_unk_bpf_on) { unk_bpfilter->Irun(in, out); unkbuff[fmt_DFT_LEN - len + i] = out; } else unkbuff[fmt_DFT_LEN - len + i] = in; if (progdefaults.FMT_ref_bpf_on) { ref_bpfilter->Irun(in, out); refbuff[fmt_DFT_LEN - len + i] = out; } else refbuff[fmt_DFT_LEN - len + i] = in; } if ((blk_counter += len) >= dftlen[sr] / (progdefaults.FMT_dft_rate + 1)) { if (bpf_width != progdefaults.FMT_bpf_width || unk_count == 0 || ref_count == 0) reset_bpf(); rx_process_dft (); unk_base_freq = dft_unk_base; unk_amp = dft_unk_amp; ref_base_freq = dft_ref_base; ref_amp = dft_ref_amp; blk_counter = 0; } if (++smpl_counter >= (samplerate / len) / 20.0) { // 0.05 second guard_lock datalock (&data_mutex); fmt_unk_frequency = unk_freq; fmt_unk_base_freq = unk_base_freq; fmt_unk_amp = unk_amp; fmt_ref_frequency = ref_freq; fmt_ref_base_freq = ref_base_freq; fmt_ref_amp = ref_amp; smpl_counter = 0; } dspcnt -= (1.0 * len / samplerate); if (dspcnt <= 0) { { guard_lock datalock(&scope_mutex); for (int i = 1; i < MAX_DATA_PTS; i++) { unk_pipe[i-1].y = unk_pipe[i].y; ref_pipe[i-1].y = ref_pipe[i].y; } if (btn_unk_enable->value()) { unk_pipe[MAX_DATA_PTS -1].y = 1.0 * unk_base_freq + progdefaults.FMT_freq_corr; snprintf(msg1, sizeof(msg1), "%13.3f", wf->rfcarrier() + (unk_freq + progdefaults.FMT_freq_corr) * (wf->USB() ? 1 : -1)); REQ (put_unk_value, msg1); snprintf(msg1a, sizeof(msg1a), "%6.1f", 20.0 * log10( (fmt_unk_amp == 0 ? 1e-6 : fmt_unk_amp) ) ); REQ (put_unk_amp, msg1a); fmt_plot->show_1(true); } else { unk_pipe[MAX_DATA_PTS -1].y = 0.0; REQ (put_unk_value, ""); REQ (put_unk_amp, ""); fmt_plot->show_1(false); } if (btn_ref_enable->value()) { ref_pipe[MAX_DATA_PTS -1].y = 1.0 * ref_base_freq + progdefaults.FMT_freq_corr; snprintf(msg2, sizeof(msg2), "%13.3f", wf->rfcarrier() + (ref_freq + progdefaults.FMT_freq_corr) * (wf->USB() ? 1 : -1)); REQ (put_ref_value, msg2); snprintf(msg2a, sizeof(msg2a), "%6.1f", 20.0 * log10( (fmt_ref_amp == 0 ? 1e-6 : fmt_ref_amp) ) ); REQ (put_ref_amp, msg2a); fmt_plot->show_2(true); } else { ref_pipe[MAX_DATA_PTS -1].y = 0.0; REQ (put_ref_value, ""); REQ (put_ref_amp, ""); fmt_plot->show_2(false); } } REQ (set_fmt_scope); dspcnt = DSP_CNT; } return 0; } //===================================================================== // fmt transmit //===================================================================== int fmt::tx_process() { return -1; }
24,493
C++
.cxx
850
26.188235
169
0.608211
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,218
fileselect.cxx
w1hkj_fldigi/src/fileselector/fileselect.cxx
// ---------------------------------------------------------------------------- // // fileselect.cxx -- file selector front end // // Copyright (C) 2008-2009 // Stelios Bounanos, M0GLD // Dave Freese, 2015 // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <string> #include <cstdlib> #include <libgen.h> #include <FL/fl_ask.H> #include <FL/Fl_Native_File_Chooser.H> #include "config.h" #include "fileselect.h" #include "debug.h" #include "qrunner.h" /** \class Fl_Native_File_Chooser This class lets an FLTK application easily and consistently access the operating system's native file chooser. Some operating systems have very complex and specific file choosers that many users want access to specifically, instead of FLTK's default file chooser(s). In cases where there is no native file browser, FLTK's own file browser is used instead. To use this widget correctly, use the following include in your code: \code #include <FL/Fl_Native_File_Chooser.H> \endcode Do not include the other Fl_Native_File_Choser_XXX.H files in your code; those are platform specific files that will be included automatically depending on your build platform. The following example shows how to pick a single file: \code // Create and post the local native file chooser #include <FL/Fl_Native_File_Chooser.H> [..] Fl_Native_File_Chooser fnfc; fnfc.title("Pick a file"); fnfc.type(Fl_Native_File_Chooser::BROWSE_FILE); fnfc.filter("Text\t*.txt\n" "C Files\t*.{cxx,h,c}"); fnfc.directory("/var/tmp"); // default directory to use // Show native chooser switch ( fnfc.show() ) { case -1: printf("ERROR: %s\n", fnfc.errmsg()); break; // ERROR case 1: printf("CANCEL\n"); break; // CANCEL default: printf("PICKED: %s\n", fnfc.filename()); break; // FILE CHOSEN } \endcode <B>Platform Specific Caveats</B> - Under X windows, it's best if you call Fl_File_Icon::load_system_icons() at the start of main(), to enable the nicer looking file browser widgets. Use the static public attributes of class Fl_File_Chooser to localize the browser. - Some operating systems support certain OS specific options; see Fl_Native_File_Chooser::options() for a list. \image html Fl_Native_File_Chooser.png "The Fl_Native_File_Chooser on different platforms." \image latex Fl_Native_File_Chooser.png "The Fl_Native_File_Chooser on different platforms" width=14cm enum Type { BROWSE_FILE = 0, ///< browse files (lets user choose one file) BROWSE_DIRECTORY, ///< browse directories (lets user choose one directory) BROWSE_MULTI_FILE, ///< browse files (lets user choose multiple files) BROWSE_MULTI_DIRECTORY, ///< browse directories (lets user choose multiple directories) BROWSE_SAVE_FILE, ///< browse to save a file BROWSE_SAVE_DIRECTORY ///< browse to save a directory }; enum Option { NO_OPTIONS = 0x0000, ///< no options enabled SAVEAS_CONFIRM = 0x0001, ///< Show native 'Save As' overwrite confirm dialog (if supported) NEW_FOLDER = 0x0002, ///< Show 'New Folder' icon (if supported) PREVIEW = 0x0004 ///< enable preview mode }; IMPORTANT NOTICE: The filter type must be terminated with a '\n' on OS X or the application crashes with a Bus timeout */ bool trx_inhibit = false; namespace FSEL { void create(void) {}; void destroy(void) {}; std::string filename, stitle, sfilter, sdef, sdirectory; char dirbuf[FL_PATH_MAX + 1] = ""; char msg[400]; // use this function for testing on garbage OS, aka Windows /* void pfile (const char *dir, const char *fname, const char *filt) { char fn[FL_PATH_MAX+1]; #ifdef __WIN32__ fl_filename_expand(fn, sizeof(fn) -1, "$USERPROFILE/"); #else fl_filename_expand(fn, sizeof(fn) -1, "$HOME/"); #endif strcat(fn, "pfile.txt"); FILE *f = fl_fopen(fn, "a"); fprintf(f,"\ dir: %s\n\ file: %s\n\ filter: %s\n", dir, fname, filt); fclose(f); } */ void dosfname(std::string &s) { for (size_t i = 0; i < s.length(); i++) if (s[i] == '/') s[i] = '\\'; } const char* select(const char* title, const char* filter, const char* def, int* fsel) { if (strlen(dirbuf) == 0) { #ifdef __WIN32__ fl_filename_expand(dirbuf, sizeof(dirbuf) -1, "$USERPROFILE/"); #else fl_filename_expand(dirbuf, sizeof(dirbuf) -1, "$HOME/"); #endif } size_t p = 0; Fl_Native_File_Chooser native; stitle.clear(); sfilter.clear(); sdef.clear(); sdirectory.clear(); if (title) stitle.assign(title); if (filter) sfilter.assign(filter); if (def) { sdef.assign(def); if (!sdef.empty()) { p = sdef.length() - 1; if ((sdef[p] == '/') || (sdef[p] == '\\')) sdef.append("fname"); } sdirectory.assign(sdef); p = sdirectory.rfind(fl_filename_name(sdef.c_str())); sdirectory.erase(p); } if (sdirectory.empty()) { sdirectory.assign(dirbuf); } if (sdef.empty()) { sdef.assign(sdirectory); sdef.append("temp"); } if (!sfilter.empty()) { if (sfilter[sfilter.length()-1] != '\n') sfilter += '\n'; native.filter(sfilter.c_str()); } native.title(stitle.c_str()); #if __WIN32__ dosfname(sdef); dosfname(sdirectory); #endif if (!sdef.empty()) native.preset_file(sdef.c_str()); if (!sdirectory.empty()) native.directory(sdirectory.c_str()); native.type(Fl_Native_File_Chooser::BROWSE_FILE); native.options(Fl_Native_File_Chooser::PREVIEW); // pfile(sdirectory.c_str(), sdef.c_str(), sfilter.c_str()); filename.clear(); trx_inhibit = true; switch ( native.show() ) { case -1: // ERROR LOG_ERROR("ERROR: %s\n", native.errmsg()); // Error fall through case 1: // CANCEL filename = ""; break; default: if ( native.filename() ) { filename = native.filename(); } else { filename = ""; } break; } trx_inhibit = false; if (fsel) *fsel = native.filter_value(); return filename.c_str(); } const char* saveas(const char* title, const char* filter, const char* def, int* fsel) { if (strlen(dirbuf) == 0) { #ifdef __WIN32__ fl_filename_expand(dirbuf, sizeof(dirbuf) -1, "$USERPROFILE/"); #else fl_filename_expand(dirbuf, sizeof(dirbuf) -1, "$HOME/"); #endif } size_t p = 0; Fl_Native_File_Chooser native; stitle.clear(); sfilter.clear(); sdef.clear(); sdirectory.clear(); if (title) stitle.assign(title); if (filter) sfilter.assign(filter); if (def) { sdef.assign(def); if (!sdef.empty()) { p = sdef.length() - 1; if ((sdef[p] == '/') || (sdef[p] == '\\')) sdef.append("fname"); } sdirectory.assign(sdef); p = sdirectory.rfind(fl_filename_name(sdef.c_str())); sdirectory.erase(p); } if (sdirectory.empty()) { sdirectory.assign(dirbuf); } if (sdef.empty()) { sdef.assign(sdirectory); sdef.append("temp"); } if (!sfilter.empty()) { if (sfilter[sfilter.length()-1] != '\n') sfilter += '\n'; native.filter(sfilter.c_str()); } native.title(stitle.c_str()); #if __WIN32__ dosfname(sdef); dosfname(sdirectory); #endif if (!sdef.empty()) native.preset_file(sdef.c_str()); if (!sdirectory.empty()) native.directory(sdirectory.c_str()); native.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); native.options(Fl_Native_File_Chooser::NEW_FOLDER | Fl_Native_File_Chooser::SAVEAS_CONFIRM); // pfile(sdirectory.c_str(), sdef.c_str(), sfilter.c_str()); filename.clear(); trx_inhibit = true; switch ( native.show() ) { case -1: // ERROR LOG_ERROR("ERROR: %s\n", native.errmsg()); break; case 1: // CANCEL filename = ""; break; default: if ( native.filename() ) { filename = native.filename(); } else { filename = ""; } break; } trx_inhibit = false; if (fsel) *fsel = native.filter_value(); return filename.c_str(); } const char* dir_select(const char* title, const char* filter, const char* def) { Fl_Native_File_Chooser native; stitle.clear(); sfilter.clear(); sdef.clear(); if (title) stitle.assign(title); if (filter) sfilter.assign(filter); if (def) sdef.assign(def); if (!sfilter.empty() && sfilter[sfilter.length()-1] != '\n') sfilter += '\n'; if (!stitle.empty()) native.title(stitle.c_str()); native.type(Fl_Native_File_Chooser::BROWSE_DIRECTORY); if (!sfilter.empty()) native.filter(sfilter.c_str()); native.options(Fl_Native_File_Chooser::NO_OPTIONS); #if __WIN32__ dosfname(sdef); #endif if (!sdef.empty()) { native.directory(sdef.c_str()); sdirectory = sdef; } else sdirectory.clear(); filename.clear(); trx_inhibit = true; switch ( native.show() ) { case -1: // ERROR LOG_ERROR("ERROR: %s\n", native.errmsg()); break; case 1: // CANCEL filename = ""; break; default: if ( native.filename() ) { filename = native.filename(); } else { filename = ""; } break; } trx_inhibit = false; return filename.c_str(); } } // FSEL
9,509
C++
.cxx
303
28.742574
104
0.667869
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,220
spectrum.cxx
w1hkj_fldigi/src/fft-monitor/spectrum.cxx
// ---------------------------------------------------------------------------- // spectrum Spectrum display Widget based on Digiscope widget // // Copyright (C) 2006-2017 // Dave Freese, W1HKJ // Copyright (C) 2008 // Stelios Bounanos, M0GLD // // This file is part of fldigi. Adapted from code contained in gmfsk source code // distribution. // gmfsk Copyright (C) 2001, 2002, 2003 // Tomi Manninen (oh2bns@sral.fi) // Copyright (C) 2004 // Lawrence Glaister (ve7it@shaw.ca) // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <iostream> #include <cmath> #include <cstring> #include <FL/Fl.H> #include <FL/fl_draw.H> #include "spectrum.h" #include "modem.h" #include "trx.h" #include "fl_digi.h" #include "qrunner.h" #include "configuration.h" spectrum::spectrum (int x, int y, int w, int h) : Digiscope (x, y, w, h) { _paused = false; _freq = 0; _db = 0; _db_diff = 0; _f_diff = 0; _gofreq = 0; mode(spectrum::SCOPE); } spectrum::~spectrum() { } void spectrum::handle_shift_leftclick(int x1) { _gofreq = progdefaults.fftviewer_fcenter - progdefaults.fftviewer_frng / 2 + (1.0 * x1 / w()) * progdefaults.fftviewer_frng; } void spectrum::handle_leftclick( int x1, int y1) { if (Fl::event_state() & FL_SHIFT) { handle_shift_leftclick(x1); return; } if (Fl::event_key('1') || Fl::event_key(FL_KP + '1')) { _y_user1 = 1.0 * y1 / h(); _x_user1 = 1.0 * x1 / w(); } else if (Fl::event_key('2') || Fl::event_key(FL_KP + '2')) { _y_user2 = 1.0 * y1 / h(); _x_user2 = 1.0 * x1 / w(); } else if (Fl::event_key('c') || Fl::event_key('3') || Fl::event_key(FL_KP + '3')) { _y_user1 = _y_user2 = -1; _x_user1 = _x_user2 = -1; } else { _freq = progdefaults.fftviewer_fcenter - progdefaults.fftviewer_frng / 2 + (1.0 * x1 / w()) * progdefaults.fftviewer_frng; _db = progdefaults.fftviewer_maxdb - (1.0 * y1 / h()) * progdefaults.fftviewer_range; return; } if ((_y_user1 != -1) && (_y_user2 != -1)) _db_diff = (_y_user1 - _y_user2) * progdefaults.fftviewer_range; else _db_diff = 0; if ((_x_user1 != -1) && (_x_user2 != -1)) _f_diff = (_x_user2 - _x_user1) * progdefaults.fftviewer_frng; else _db_diff = 0; } void spectrum::handle_rightclick( int x, int y) { _paused = !_paused; } int spectrum::handle(int event) { if (event == FL_ENTER) { fl_cursor(FL_CURSOR_CROSS); redraw(); return 1; } if (event == FL_LEAVE) { fl_cursor(FL_CURSOR_ARROW); redraw(); return 1; } if (!Fl::event_inside(this)) return 0; switch (event) { case FL_PUSH : break; case FL_RELEASE : if (!Fl::event_inside(this)) break; switch (Fl::event_button()) { case FL_LEFT_MOUSE: handle_leftclick(Fl::event_x() - x(), Fl::event_y() - y()); break; case FL_RIGHT_MOUSE : handle_rightclick(Fl::event_x() - x(), Fl::event_y() - y()); break; default : break; } default : break; } return 1; }
3,594
C++
.cxx
128
25.835938
87
0.621919
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,221
spectrum_viewer.cxx
w1hkj_fldigi/src/fft-monitor/spectrum_viewer.cxx
// ---------------------------------------------------------------------------- // spectrum_viewer.cxx -- spectrum dialog // // Copyright (C) 2017 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <FL/Fl_Double_Window.H> #include <FL/Fl_Group.H> #include <FL/Fl_Counter.H> #include <FL/Fl_Button.H> #include <FL/Fl_Menu_Bar.H> #include <FL/Fl_Output.H> #include <FL/Fl_Box.H> #include <iostream> #include "configuration.h" #include "status.h" #include "spectrum.h" #include "spectrum_viewer.h" #include "fft-monitor.h" #include "gettext.h" #include "modem.h" #include "trx.h" Fl_Double_Window *spectrum_viewer = (Fl_Double_Window *)0; spectrum *fftscope = (spectrum *)0; Fl_Group *fftmon_mnuFrame = (Fl_Group *)0; Fl_Group *group1 = (Fl_Group *)0; Fl_Group *group2 = (Fl_Group *)0; Fl_Counter *fftviewer_scans = (Fl_Counter *)0; Fl_Counter *fftviewer_range = (Fl_Counter *)0; Fl_Counter *fftviewer_maxdb = (Fl_Counter *)0; Fl_Counter *fftviewer_fcenter = (Fl_Counter *)0; Fl_Counter *fftviewer_frng = (Fl_Counter *)0; Fl_Button *fftviewer_reset = (Fl_Button *)0; Fl_Button *fftviewer_goto = (Fl_Button *)0; Fl_Group *g1 = (Fl_Group *)0; Fl_Group *g3 = (Fl_Group *)0; Fl_Group *g2 = (Fl_Group *)0; Fl_Menu_Bar *fftmon_mnu_bar = (Fl_Menu_Bar *)0; Fl_Output *values = (Fl_Output *)0; Fl_Output *db_diffs = (Fl_Output *)0; Fl_Output *f_diffs = (Fl_Output *)0; Fl_Button *pause_button = (Fl_Button *)0; Fl_Box *annunciator = (Fl_Box *)0; fftmon *fft_modem = (fftmon *)0; void cb_fftviewer_scans(Fl_Counter *w, void *d) { progdefaults.fftviewer_scans = w->value(); fft_modem->restart(); } void cb_fftviewer_range(Fl_Counter *w, void *d) { progdefaults.fftviewer_range = w->value(); } void cb_fftviewer_maxdb(Fl_Counter *w, void *d) { progdefaults.fftviewer_maxdb = w->value(); } void check_frng(int fr) { int fc = progdefaults.fftviewer_fcenter; if (fc - fr/2 < 0) fr = 2*fc; if (fc + fr/2 > 4000) fr = 2*(4000 - fc); progdefaults.fftviewer_frng = fr; fftviewer_frng->value(fr); fftviewer_frng->redraw(); } void cb_fftviewer_fcenter(Fl_Counter *w, void *d) { progdefaults.fftviewer_fcenter = w->value(); int fr = progdefaults.fftviewer_frng; check_frng(fr); } void cb_fftviewer_frng(Fl_Counter *w, void *d) { progdefaults.fftviewer_frng = w->value(); int fr = progdefaults.fftviewer_frng; check_frng(fr); } void cb_fftviewer_reset(Fl_Button *b, void *d) { progdefaults.fftviewer_fcenter = 2000; progdefaults.fftviewer_frng = 4000; fftviewer_fcenter->value(2000); fftviewer_frng->value(4000); fftviewer_fcenter->redraw(); fftviewer_frng->redraw(); if (progdefaults.wf_spectrum_dbvals) { progdefaults.fftviewer_range = progdefaults.wfAmpSpan; progdefaults.fftviewer_maxdb = progdefaults.wfRefLevel; fftviewer_maxdb->value(progdefaults.fftviewer_maxdb); fftviewer_maxdb->redraw(); fftviewer_range->value(progdefaults.fftviewer_range); fftviewer_range->redraw(); } } void cb_pause_button(Fl_Button *b, void *d) { fftscope->paused( !fftscope->paused() ); } void cb_fftviewer_goto(Fl_Button *b, void *d) { progdefaults.fftviewer_fcenter = active_modem->get_freq(); int fr = progdefaults.fftviewer_frng; if (progdefaults.wf_spectrum_modem_scale) fr = progdefaults.wf_spectrum_scale_factor * active_modem->get_bandwidth(); check_frng(fr); fftviewer_fcenter->value(progdefaults.fftviewer_fcenter); fftviewer_fcenter->redraw(); if (progdefaults.wf_spectrum_dbvals) { progdefaults.fftviewer_range = progdefaults.wfAmpSpan; progdefaults.fftviewer_maxdb = progdefaults.wfRefLevel; fftviewer_maxdb->value(progdefaults.fftviewer_maxdb); fftviewer_maxdb->redraw(); fftviewer_range->value(progdefaults.fftviewer_range); fftviewer_range->redraw(); } } void cb_spectrum_viewer(Fl_Double_Window *w, void *) { progStatus.svX = spectrum_viewer->x(); progStatus.svY = spectrum_viewer->y(); progStatus.svW = spectrum_viewer->w(); progStatus.svH = spectrum_viewer->h(); spectrum_viewer->hide(); return; } void cb_mnu_fftmon_close(Fl_Menu_*, void*) { cb_spectrum_viewer(0,0); } extern bool b_write_fftfile; void cb_mnu_fftmon_csv(Fl_Menu_*, void*) { if (!b_write_fftfile) b_write_fftfile = true; } void cb_mnu_x_graticule(Fl_Menu_*, void*) { progStatus.x_graticule = true; progStatus.y_graticule = false; progStatus.xy_graticule = false; fftscope->x_graticule(true); fftscope->y_graticule(false); } void cb_mnu_y_graticule(Fl_Menu_*, void*) { progStatus.y_graticule = true; progStatus.x_graticule = false; progStatus.xy_graticule = false; fftscope->x_graticule(false); fftscope->y_graticule(true); } void cb_mnu_xy_graticules(Fl_Menu_*, void*) { progStatus.xy_graticule = true; progStatus.x_graticule = false; progStatus.y_graticule = false; fftscope->x_graticule(true); fftscope->y_graticule(true); } Fl_Menu_Item fftmon_menu[] = { {_("&Dialog"), 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0}, {_("&Graticule"), 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0}, { _("X graticule"), 0, (Fl_Callback*)cb_mnu_x_graticule, 0, FL_MENU_RADIO, FL_NORMAL_LABEL, 0, 14, 0}, { _("Y graticule"), 0, (Fl_Callback*)cb_mnu_y_graticule, 0, FL_MENU_RADIO, FL_NORMAL_LABEL, 0, 14, 0}, { _("X/Y graticules"), 0, (Fl_Callback*)cb_mnu_xy_graticules, 0, FL_MENU_RADIO, FL_NORMAL_LABEL, 0, 14, 0}, { 0 }, {_("&Save to CSV"), 0, (Fl_Callback*)cb_mnu_fftmon_csv, 0, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0}, {_("&Close"), 0, (Fl_Callback*)cb_mnu_fftmon_close, 0, 0, FL_NORMAL_LABEL, 0, 14, 0}, { 0 }, { 0 } }; #define VALWIDTH 120 #define DIFFSWIDTH 80 #define PAUSEWIDTH 60 #define ANNUNWIDTH 140 #define WIDTHS (VALWIDTH + 2*DIFFSWIDTH + PAUSEWIDTH + ANNUNWIDTH) #define STATUS_COLOR 0xfdf5e600 void create_spectrum_viewer() { if (spectrum_viewer) return; spectrum_viewer = new Fl_Double_Window(0, 0, 550, 400, "Spectrum Scope"); spectrum_viewer->xclass(PACKAGE_NAME); fftmon_mnuFrame = new Fl_Group(0,0, spectrum_viewer->w(), 20); fftmon_mnu_bar = new Fl_Menu_Bar(0, 0, fftmon_mnuFrame->w() - WIDTHS, 20); fftmon_mnu_bar->menu(fftmon_menu); pause_button = new Fl_Button( fftmon_mnu_bar->x() + fftmon_mnu_bar->w(), 0, PAUSEWIDTH, 20, "Running"); pause_button->callback((Fl_Callback*)cb_pause_button); annunciator = new Fl_Box( pause_button->x() + pause_button->w(), 0, ANNUNWIDTH, 20, ""); annunciator->box(FL_DOWN_BOX); annunciator->color(STATUS_COLOR); values = new Fl_Output( annunciator->x() + annunciator->w(), 0, VALWIDTH, 20, ""); values->value(""); values->color(STATUS_COLOR); db_diffs = new Fl_Output( values->x() + values->w(), 0, DIFFSWIDTH, 20, ""); db_diffs->value(""); db_diffs->color(STATUS_COLOR); f_diffs = new Fl_Output( db_diffs->x() + db_diffs->w(), 0, DIFFSWIDTH, 20, ""); f_diffs->value(""); f_diffs->color(STATUS_COLOR); fftmon_mnuFrame->resizable(fftmon_mnu_bar); fftmon_mnuFrame->end(); group1 = new Fl_Group(0, 20, 550, 330); fftscope = new spectrum (group1->x(), group1->y(), group1->w(), group1->h()); group1->resizable(fftscope); group1->end(); group1->show(); group2 = new Fl_Group(0, 350, 550, 50); g1 = new Fl_Group(0, 350, 548, 50, ""); fftviewer_scans = new Fl_Counter(5, 360, 100, 22, "# scans"); fftviewer_scans->minimum(1); fftviewer_scans->maximum(500); fftviewer_scans->step(1); fftviewer_scans->lstep(10.0); fftviewer_scans->value(50); fftviewer_scans->callback((Fl_Callback*)cb_fftviewer_scans); fftviewer_scans->value(progdefaults.fftviewer_scans); fftviewer_scans->tooltip(_("each display point an average of past N fft values")); fftviewer_range = new Fl_Counter( 5 + fftviewer_scans->x() + fftviewer_scans->w(), 360, 80, 22, "dB Range"); fftviewer_range->type(1); fftviewer_range->minimum(20); fftviewer_range->maximum(120); fftviewer_range->step(10); fftviewer_range->value(60); fftviewer_range->callback((Fl_Callback*)cb_fftviewer_range); fftviewer_range->value(progdefaults.fftviewer_range); fftviewer_range->tooltip(_("range of dB scale")); fftviewer_maxdb = new Fl_Counter( 5 + fftviewer_range->x() + fftviewer_range->w(), 360, 80, 22, "upper dB"); fftviewer_maxdb->type(1); fftviewer_maxdb->minimum(-60); fftviewer_maxdb->maximum(0); fftviewer_maxdb->step(10); fftviewer_maxdb->value(0); fftviewer_maxdb->callback((Fl_Callback*)cb_fftviewer_maxdb); fftviewer_maxdb->value(progdefaults.fftviewer_maxdb); fftviewer_maxdb->tooltip(_("offset Db scale")); int xp = 5 + fftviewer_maxdb->x() + fftviewer_maxdb->w(); g2 = new Fl_Group( xp, 352, g1->w() - 2 - xp, 46, ""); g2->box(FL_ENGRAVED_FRAME); fftviewer_fcenter = new Fl_Counter( 5 + g2->x(), 358, 100, 22, "F-center"); fftviewer_fcenter->minimum(0); fftviewer_fcenter->maximum(3950); fftviewer_fcenter->step(1); fftviewer_fcenter->lstep(10); fftviewer_fcenter->value(0); fftviewer_fcenter->callback((Fl_Callback*)cb_fftviewer_fcenter); fftviewer_fcenter->value(progdefaults.fftviewer_fcenter); fftviewer_fcenter->tooltip(_("center frequency")); fftviewer_frng = new Fl_Counter( 5 + fftviewer_fcenter->x() + fftviewer_fcenter->w(), 358, 110, 22, "F-range"); fftviewer_frng->minimum(100); fftviewer_frng->maximum(4000); fftviewer_frng->step(20); fftviewer_frng->lstep(100); fftviewer_frng->value(4000); fftviewer_frng->callback((Fl_Callback*)cb_fftviewer_frng); fftviewer_frng->value(progdefaults.fftviewer_frng); fftviewer_frng->tooltip(_("frequency range")); fftviewer_reset = new Fl_Button( 5 + fftviewer_frng->x() + fftviewer_frng->w(), 354, 38, 20, "Reset"); fftviewer_reset->callback((Fl_Callback*)cb_fftviewer_reset); fftviewer_reset->tooltip(_("Center = 2000, Range = 4000")); fftviewer_goto = new Fl_Button( 5 + fftviewer_frng->x() + fftviewer_frng->w(), 376, 38, 20, "Goto"); fftviewer_goto->callback((Fl_Callback*)cb_fftviewer_goto); fftviewer_goto->tooltip(_("Center - wf track\nRange = 10 * mode-bw")); g2->end(); g1->end(); g3 = new Fl_Group(spectrum_viewer->w() - 2, 350, 2, 50, ""); g3->end(); group2->end(); group2->resizable(g3); spectrum_viewer->resizable(group1); spectrum_viewer->size_range(550, 400); spectrum_viewer->end(); spectrum_viewer->callback((Fl_Callback *)cb_spectrum_viewer); if (progStatus.x_graticule) { fftmon_menu[2].setonly(); fftscope->x_graticule(true); fftscope->y_graticule(false); } else if (progStatus.y_graticule) { fftmon_menu[3].setonly(); fftscope->x_graticule(false); fftscope->y_graticule(true); } else { fftmon_menu[4].setonly(); fftscope->x_graticule(true); fftscope->y_graticule(true); } } //====================================================================== void open_spectrum_viewer() { if (!spectrum_viewer) create_spectrum_viewer(); if (!fft_modem) { progdefaults.fftviewer_fcenter = active_modem->get_freq(); fft_modem = new fftmon(); active_modem->set_freq(progdefaults.fftviewer_fcenter); } else progdefaults.fftviewer_fcenter = active_modem->get_freq(); int fr = progdefaults.fftviewer_frng; if (progdefaults.wf_spectrum_modem_scale) fr = progdefaults.wf_spectrum_scale_factor * active_modem->get_bandwidth(); check_frng(fr); fftviewer_fcenter->value(progdefaults.fftviewer_fcenter); fftviewer_fcenter->redraw(); if (progdefaults.wf_spectrum_dbvals) { progdefaults.fftviewer_range = progdefaults.wfAmpSpan; progdefaults.fftviewer_maxdb = progdefaults.wfRefLevel; fftviewer_maxdb->value(progdefaults.fftviewer_maxdb); fftviewer_maxdb->redraw(); fftviewer_range->value(progdefaults.fftviewer_range); fftviewer_range->redraw(); } spectrum_viewer->show(); spectrum_viewer->redraw(); spectrum_viewer->resize(progStatus.svX, progStatus.svY, progStatus.svW, progStatus.svH); } void close_spectrum_viewer() { if (spectrum_viewer) { spectrum_viewer->hide(); delete spectrum_viewer; spectrum_viewer = 0; } if (fft_modem) { delete fft_modem; fft_modem = 0; } } void recenter_spectrum_viewer() { if (!spectrum_viewer) return; if (!spectrum_viewer->visible()) return; if (!progdefaults.wf_spectrum_center) return; if (!fft_modem) return; progdefaults.fftviewer_fcenter = active_modem->get_freq(); int fr = progdefaults.fftviewer_frng; if (progdefaults.wf_spectrum_modem_scale) fr = progdefaults.wf_spectrum_scale_factor * active_modem->get_bandwidth(); check_frng(fr); fftviewer_fcenter->value(progdefaults.fftviewer_fcenter); fftviewer_fcenter->redraw(); if (progdefaults.wf_spectrum_dbvals) { progdefaults.fftviewer_range = progdefaults.wfAmpSpan; progdefaults.fftviewer_maxdb = progdefaults.wfRefLevel; fftviewer_maxdb->value(progdefaults.fftviewer_maxdb); fftviewer_maxdb->redraw(); fftviewer_range->value(progdefaults.fftviewer_range); fftviewer_range->redraw(); } spectrum_viewer->redraw(); }
13,667
C++
.cxx
388
32.703608
111
0.695958
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,222
fft-monitor.cxx
w1hkj_fldigi/src/fft-monitor/fft-monitor.cxx
// ---------------------------------------------------------------------------- // fftmon.cxx -- fftmon modem // // Copyright (C) 2017 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <string> #include <cstdio> #include <ctime> #include <cstring> #include <FL/Fl_Counter.H> #include "fl_digi.h" #include "modem.h" #include "misc.h" #include "filters.h" #include "fftfilt.h" #include "waterfall.h" #include "main.h" #include "fft-monitor.h" #include "timeops.h" #include "debug.h" #include "digiscope.h" #include "trx.h" #include "spectrum_viewer.h" #include "threads.h" #include "configuration.h" //extern Digiscope *fftscope; //extern spectrum *fftscope; #include "confdialog.h" extern Fl_Counter *fftviewer_scans; extern Fl_Counter *fftviewer_fcenter; extern Fl_Counter *fftviewer_frng; extern Fl_Button *pause_button; extern Fl_Box *annunciator; pthread_mutex_t fftmon_mutex = PTHREAD_MUTEX_INITIALIZER; bool b_write_fftfile = false; static std::string fftmonFilename; void toggle_scans(void *me) { fftmon *mon = (fftmon *)(me); if (mon->scans_stable) fftviewer_scans->color(FL_GREEN); else fftviewer_scans->color(FL_BACKGROUND_COLOR); fftviewer_scans->redraw(); } void fftmon::init() { } fftmon::~fftmon() { delete [] fftbuff; delete [] dftbuff; delete [] buffer; delete [] cmplxbuf; delete scanfft; } void fftmon::restart() { fftmon_sr = active_modem->get_samplerate(); for (int i = 0; i < fftmonFFT_LEN; i++) { bshape[i] = blackman(1.0 * i / fftmonFFT_LEN); fftbuff[i] = dftbuff[i] = 0; cmplxbuf[i] = std::complex<double>(0, 0); } for (int i = 0; i < fftmonFFT_LEN / 2; i++) buffer[i] = 0; for (int i = 0; i < LENdiv2; i++) fftfilt[i]->setLength(progdefaults.fftviewer_scans); scans_stable = false; numscans = 0; Fl::awake(toggle_scans, this); } fftmon::fftmon() { fftbuff = new double[fftmonFFT_LEN]; dftbuff = new double[fftmonFFT_LEN]; cmplxbuf = new cmplx[fftmonFFT_LEN]; buffer = new double[fftmonFFT_LEN / 2]; for (int i = 0; i < LENdiv2; i++) { fftfilt[i] = new Cmovavg(1000); fftfilt[i]->setLength(progdefaults.fftviewer_scans); } for (int i = 0; i < fftmonFFT_LEN; i++) { bshape[i] = blackman(1.0 * i / fftmonFFT_LEN); fftbuff[i] = dftbuff[i] = 0; cmplxbuf[i] = std::complex<double>(0, 0); } for (int i = 0; i < fftmonFFT_LEN / 2; i++) buffer[i] = 0; scanfft = new g_fft<double>(fftmonFFT_LEN); fftmonFilename = TempDir; fftmonFilename.append("rx_spectrum.csv"); cap &= ~CAP_TX; // rx only modem restart(); } //======================================================================= // //======================================================================= // static double scopebuff[LENdiv2]; static double filebuff[LENdiv2]; double goto_freq() { int fc = fftscope->gofreq(); int fr = progdefaults.fftviewer_frng; int rem = 0; if (fc < 100) fc = 100; if (fr < 200) fr = 200; if (fc + fr/2 > 4000) fr = (4000 - fc)/2; if (fc < fr/2) fr = fc * 2; rem = fr % 20; fr /= 20; if (rem >= 10) fr = fr + 1; fr *= 20; if (fr > 4000) fr = 4000; progdefaults.fftviewer_frng = fr; progdefaults.fftviewer_fcenter = fc; fftviewer_fcenter->value(fc); fftviewer_fcenter->redraw(); fftviewer_frng->value(fr); fftviewer_frng->redraw(); fftscope->gofreq(0); return fc; } void write_to_fftscope(void *) { // clear scope views fftscope->clear_axis(); double f0 = progdefaults.fftviewer_fcenter - progdefaults.fftviewer_frng / 2; double f1 = progdefaults.fftviewer_fcenter + progdefaults.fftviewer_frng / 2; double sr = active_modem->get_samplerate(); if (fftscope->gofreq()) f0 = goto_freq(); int n0 = LENdiv2 * (8000.0 / sr) * (f0 / 4000.0); int n1 = LENdiv2 * (8000.0 / sr) * (f1 / 4000.0); // vertical graticule, every 10 dB int N = progdefaults.fftviewer_range / 10; for (int i = 1; i < N; i++) fftscope->xaxis(i, 1.0 * i / N); // horizontal graticule int incr = 500; if (progdefaults.fftviewer_frng <= 2000) incr = 200; if (progdefaults.fftviewer_frng <= 1000) incr = 100; if (progdefaults.fftviewer_frng <= 500 ) incr = 50; if (progdefaults.fftviewer_frng <= 250) incr = 25; annunciator->label( (incr == 500) ? "10 db/div, 500 Hz/div" : (incr == 200) ? "10 db/div, 200 Hz/div" : (incr == 100) ? "10 db/div, 100 Hz/div" : (incr == 50) ? "10 db/div, 50 Hz/div" : "10 db/div, 25 Hz/div"); annunciator->redraw_label(); int xp = f0; int xpd = xp % incr; double xpos = 1.0 * (incr - xpd) / progdefaults.fftviewer_frng; double fincr = 1.0 * incr / progdefaults.fftviewer_frng; int n = 1; while (xpos < 1.0) { fftscope->yaxis(n, xpos); xpos += fincr; n++; } if (fftscope->paused()) pause_button->label("Paused"); else pause_button->label("Running"); pause_button->redraw_label(); static char msg[100]; snprintf(msg, sizeof(msg), " %.0f Hz, %.1f dB", fftscope->freq(), fftscope->db()); values->value(msg); if (fftscope->db_diff()) { snprintf(msg, sizeof(msg), "%.0f dB", fftscope->db_diff()); db_diffs->value(msg); snprintf(msg, sizeof(msg), "%.0f Hz", fabs(fftscope->f_diff())); f_diffs->value(msg); } else { db_diffs->value(""); f_diffs->value(""); } fftscope->data(&scopebuff[n0], n1 - n0, false); fftscope->redraw(); } // add mutex lock void write_to_fftfile(void *) { guard_lock gl_filebuff(&fftmon_mutex); b_write_fftfile = false; double sr = active_modem->get_samplerate(); FILE *out = fl_fopen(fftmonFilename.c_str(), "w"); if (unlikely(!out)) { LOG_PERROR("fl_fopen"); return; } fprintf(out, "Frequency,Magnitude\n"); for (int i = 0; i < LENdiv2; i++) fprintf(out, "%0.1f, %f\n", i * sr / fftmonFFT_LEN, filebuff[i]); fclose(out); } void fftmon::update_fftscope() { if (!fftscope) return; if (b_write_fftfile) Fl::awake(write_to_fftfile); if ( !fftscope->paused() ) { guard_lock gl_filebuff(&fftmon_mutex); double val = 0; for (int i = 0; i < LENdiv2; i++) { val = fftbuff[i] / LENdiv2; if (val < 1e-6) val = 1e-6; if (val > 1) val = 1.0; filebuff[i] = val; buffer[i] = 20 * log10f(val); } } for (int i = 0; i < LENdiv2; i++) scopebuff[i] = 1.0 + (buffer[i] - progdefaults.fftviewer_maxdb)/progdefaults.fftviewer_range; Fl::awake(write_to_fftscope); } static std::complex<double> fftmon_temp[fftmonFFT_LEN]; int fftmon::rx_process(const double *buf, int len) { if (len > fftmonFFT_LEN) return 0; // if audio playback if (fftmon_sr != active_modem->get_samplerate()) restart(); for (int i = 0; i < fftmonFFT_LEN - len; i++) dftbuff[i] = dftbuff[i + len]; for (int i = 0; i < len; i++) { dftbuff[fftmonFFT_LEN - len + i] = buf[i]; } double val; for (int i = 0; i < fftmonFFT_LEN; i++) { val = dftbuff[i] * bshape[i]; fftmon_temp[i] = std::complex<double>(val, 0);//val); } scanfft->ComplexFFT(fftmon_temp); for (int i = 0; i < fftmonFFT_LEN/2; i++) fftbuff[i] = fftfilt[i]->run(abs(fftmon_temp[i])); update_fftscope(); if (!scans_stable) { if (numscans++ >= progdefaults.fftviewer_scans) { scans_stable = true; Fl::awake(toggle_scans, this); } } return 0; } int fftmon::cmplx_process(const cmplx *buf, int len) { if (len > fftmonFFT_LEN) return 0; // if audio playback if (fftmon_sr != active_modem->get_samplerate()) restart(); for (int i = 0; i < fftmonFFT_LEN - len; i++) cmplxbuf[i] = cmplxbuf[i + len]; for (int i = 0; i < len; i++) { cmplxbuf[fftmonFFT_LEN - len + i] = buf[i]; } for (int i = 0; i < fftmonFFT_LEN; i++) { fftmon_temp[i] = bshape[i] * cmplxbuf[i]; } scanfft->ComplexFFT(fftmon_temp); for (int i = 0; i < fftmonFFT_LEN/2; i++) fftbuff[i] = fftfilt[i]->run(abs(fftmon_temp[i])); update_fftscope(); if (!scans_stable) { if (numscans++ >= progdefaults.fftviewer_scans) { scans_stable = true; Fl::awake(toggle_scans, this); } } return 0; }
8,562
C++
.cxx
286
27.734266
95
0.643685
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,223
socket.cxx
w1hkj_fldigi/src/network/socket.cxx
// ---------------------------------------------------------------------------- // socket.cxx // // Copyright (C) 2008-2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <sys/types.h> #include <FL/Fl.H> #ifndef __MINGW32__ # include <sys/socket.h> # include <netdb.h> # if defined(__OpenBSD__) && defined(nitems) # undef nitems # endif # include <arpa/inet.h> # include <netinet/in.h> # include <sys/time.h> # include <sys/select.h> #else # include "compat.h" #define socklen_t int #endif #define DEFAULT_BUFFER_SIZE 1024 #include <unistd.h> #include <fcntl.h> #include <string> #include <sstream> #include <fstream> #include <cerrno> #include <cstring> #include <cstdlib> #include <cmath> #include <cstdio> #include <errno.h> #include "debug.h" #ifdef BUILD_FLARQ # include "flarq.h" #else # include "main.h" #endif #include "socket.h" #include "estrings.h" #if HAVE_GETADDRINFO && !defined(AI_NUMERICSERV) # define AI_NUMERICSERV 0 #endif static int dummy_value = 0; // // utility functions // #if HAVE_GETADDRINFO static void copy_addrinfo(struct addrinfo** info, const struct addrinfo* src) { struct addrinfo* p = *info; for (const struct addrinfo* rp = src; rp; rp = rp->ai_next) { if (p) { p->ai_next = new struct addrinfo; p = p->ai_next; } else { p = new struct addrinfo; if (!*info) *info = p; } p->ai_flags = rp->ai_flags; p->ai_family = rp->ai_family; p->ai_socktype = rp->ai_socktype; p->ai_protocol = rp->ai_protocol; p->ai_addrlen = rp->ai_addrlen; if (rp->ai_addr) { p->ai_addr = reinterpret_cast<struct sockaddr*>(new struct sockaddr_storage); memcpy(p->ai_addr, rp->ai_addr, rp->ai_addrlen); } else p->ai_addr = NULL; if (rp->ai_canonname) p->ai_canonname = strdup(rp->ai_canonname); else p->ai_canonname = NULL; p->ai_next = NULL; } } static void free_addrinfo(struct addrinfo* ai) { for (struct addrinfo *next, *p = ai; p; p = next) { next = p->ai_next; delete reinterpret_cast<struct sockaddr_storage*>(p->ai_addr); free(p->ai_canonname); delete p; } } #else static void copy_charpp(char*** dst, const char* const* src) { if (src == NULL) { *dst = NULL; return; } size_t n = 0; for (const char* const* s = src; *s; s++) n++; *dst = new char*[n+1]; for (size_t i = 0; i < n; i++) (*dst)[i] = strdup(src[i]); (*dst)[n] = NULL; } static void copy_hostent(struct hostent* dst, const struct hostent* src) { if (src->h_name) dst->h_name = strdup(src->h_name); else dst->h_name = NULL; copy_charpp(&dst->h_aliases, src->h_aliases); dst->h_length = src->h_length; if (src->h_addr_list) { size_t n = 0; for (const char* const* p = src->h_addr_list; *p; p++) n++; dst->h_addr_list = new char*[n+1]; for (size_t i = 0; i < n; i++) { dst->h_addr_list[i] = new char[src->h_length]; memcpy(dst->h_addr_list[i], src->h_addr_list[i], src->h_length); } dst->h_addr_list[n] = NULL; } else dst->h_addr_list = NULL; } static void copy_servent(struct servent* dst, const struct servent* src) { if (src->s_name) dst->s_name = strdup(src->s_name); else dst->s_name = NULL; copy_charpp(&dst->s_aliases, src->s_aliases); dst->s_port = src->s_port; if (src->s_proto) dst->s_proto = strdup(src->s_proto); else dst->s_proto = NULL; } static void free_charpp(char** pp) { if (!pp) return; for (char** p = pp; *p; p++) free(*p); delete [] pp; } static void free_hostent(struct hostent* hp) { free(const_cast<char*>(hp->h_name)); free_charpp(hp->h_aliases); if (hp->h_addr_list) { for (char** p = hp->h_addr_list; *p; p++) delete [] *p; delete [] hp->h_addr_list; } } static void free_servent(struct servent* sp) { free(const_cast<char*>(sp->s_name)); free_charpp(sp->s_aliases); free(sp->s_proto); } #endif // HAVE_GETADDRINFO // // Address class // Address::Address(const char* host, int port, const char* proto_name) : node(host), copied(false) { #if HAVE_GETADDRINFO info = NULL; #else memset(&host_entry, 0, sizeof(host_entry)); memset(&service_entry, 0, sizeof(service_entry)); #endif if (node.empty() && (port == 0)) return; std::ostringstream s; s << port; service = s.str(); try { lookup(proto_name); } catch (...) { throw; } } Address::Address(const char* host, const char* port_name, const char* proto_name) : node(host), service(port_name), copied(false) { #if HAVE_GETADDRINFO info = NULL; #else memset(&host_entry, 0, sizeof(host_entry)); memset(&service_entry, 0, sizeof(service_entry)); #endif try { lookup(proto_name); } catch (...) { throw; } } Address::Address(const Address &addr) { #if HAVE_GETADDRINFO info = NULL; #else memset(&host_entry, 0, sizeof(host_entry)); memset(&service_entry, 0, sizeof(service_entry)); #endif *this = addr; } Address::~Address() { #if HAVE_GETADDRINFO if (info) { if (!copied) freeaddrinfo(info); else free_addrinfo(info); } #else free_hostent(&host_entry); free_servent(&service_entry); #endif } Address& Address::operator=(const Address& rhs) { if (this == &rhs) return *this; node = rhs.node; service = rhs.service; #if HAVE_GETADDRINFO if (info) { if (!copied) freeaddrinfo(info); else free_addrinfo(info); } copy_addrinfo(&info, rhs.info); #else free_hostent(&host_entry); free_servent(&service_entry); copy_hostent(&host_entry, &rhs.host_entry); copy_servent(&service_entry, &rhs.service_entry); addr.ai_protocol = rhs.addr.ai_protocol; addr.ai_socktype = rhs.addr.ai_socktype; #endif copied = true; return *this; } void Address::lookup(const char* proto_name) { int proto; if (!strcasecmp(proto_name, "tcp")) proto = IPPROTO_TCP; else if (!strcasecmp(proto_name, "udp")) proto = IPPROTO_UDP; else throw SocketException("Bad protocol name"); #if HAVE_GETADDRINFO struct addrinfo hints; memset(&hints, 0, sizeof(hints)); # ifdef AI_ADDRCONFIG hints.ai_flags = AI_ADDRCONFIG; # endif hints.ai_family = AF_UNSPEC; hints.ai_socktype = (proto == IPPROTO_TCP ? SOCK_STREAM : SOCK_DGRAM); if (service.find_first_not_of("0123456789") == std::string::npos) hints.ai_flags |= AI_NUMERICSERV; int r = getaddrinfo(node.empty() ? NULL : node.c_str(), service.c_str(), &hints, &info); if (r != 0) { throw SocketException(gai_strerror(r)); } #else // use gethostbyname etc. memset(&host_entry, 0, sizeof(host_entry)); memset(&service_entry, 0, sizeof(service_entry)); if (node.empty()) node = "0.0.0.0"; struct hostent* hp; if ((hp = gethostbyname(node.c_str())) == NULL) throw SocketException(hstrerror(HOST_NOT_FOUND)); copy_hostent(&host_entry, hp); int port; struct servent* sp; if ((sp = getservbyname(service.c_str(), NULL)) == NULL) { // if a service name string could not be looked up by name, it must be numeric if (service.find_first_not_of("0123456789") != std::string::npos) throw SocketException("Unknown service name"); port = htons(atoi(service.c_str())); sp = getservbyport(port, NULL); } if (!sp) service_entry.s_port = port; else copy_servent(&service_entry, sp); memset(&addr, 0, sizeof(addr)); addr.ai_protocol = proto; addr.ai_socktype = (proto == IPPROTO_TCP ? SOCK_STREAM : SOCK_DGRAM); #endif } /// /// Returns the number of addresses available for /// the node and service /// size_t Address::size(void) const { size_t n = 0; #if HAVE_GETADDRINFO if (!info) return 0; for (struct addrinfo* p = info; p; p = p->ai_next) n++; #else if (!host_entry.h_addr_list) return 0; for (char** p = host_entry.h_addr_list; *p; p++) n++; #endif return n; } /// /// Returns an address from the list of those available /// for the node and service /// const addr_info_t* Address::get(size_t n) const { #if HAVE_GETADDRINFO if (!info) return NULL; struct addrinfo* p = info; for (size_t i = 0; i < n; i++) p = p->ai_next; LOG_VERBOSE("Found address %s", get_str(p).c_str()); return p; #else if (!host_entry.h_addr_list) return NULL; memset(&saddr, 0, sizeof(saddr)); #ifdef __WIN32__ saddr.sin_family = AF_INET; saddr.sin_addr = *(struct in_addr*)host_entry.h_addr_list[n]; saddr.sin_port = service_entry.s_port; addr.ai_family = saddr.sin_family; #else saddr.sin6_family = AF_INET6; saddr.sin6_addr = *(struct in6_addr*)host_entry.h_addr_list[n]; saddr.sin6_port = service_entry.s_port; addr.ai_family = saddr.sin6_family; #endif addr.ai_addrlen = sizeof(saddr); addr.ai_addr = (struct sockaddr*)&saddr; LOG_VERBOSE("Found address %s", get_str(&addr).c_str()); return &addr; #endif } /// /// Returns the string representation of an address /// std::string Address::get_str(const addr_info_t* addr) { if (!addr) return ""; #if HAVE_GETADDRINFO char host[NI_MAXHOST], port[NI_MAXSERV]; memset(host, 0, sizeof(host)); if (getnameinfo(addr->ai_addr, sizeof(struct sockaddr_storage), host, sizeof(host), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV) == 0) return std::string("[").append(host).append("]:").append(port); else return ""; #else char* host, port[8]; #ifdef __WIN32__ host = inet_ntoa(((struct sockaddr_in*)addr->ai_addr)->sin_addr); snprintf(port, sizeof(port), "%u", htons(((struct sockaddr_in*)addr->ai_addr)->sin_port)); #else host = inet_ntoa(((struct sockaddr_in6*)addr->ai_addr)->sin6_addr); snprintf(port, sizeof(port), "%u", htons(((struct sockaddr_in6*)addr->ai_addr)->sin6_port)); #endif return std::string("[").append(host).append("]:").append(port); #endif } // // Socket class // #ifdef __MINGW32__ void windows_init(void) { static WSADATA wsaData; static int wsa_init_ = 0; if (wsa_init_) return; wsa_init_ = 1; if (WSAStartup(MAKEWORD(WSA_MAJOR, WSA_MINOR), &wsaData)) { fprintf(stderr, "unable to initialize winsock: error %d", WSAGetLastError()); exit(EXIT_FAILURE); } atexit((void(*)(void)) WSACleanup); } #endif /// Constructs a Socket object and associates the address addr with it. /// This address will be used by subsequent calls to the bind() or connect() /// methods /// /// @param addr An Address object /// Socket::Socket(const Address &addr) { #ifdef __MINGW32__ windows_init(); #endif buffer = new char[S_BUFSIZ]; memset(&timeout, 0, sizeof(timeout)); anum = 0; nonblocking = false; autoclose = true; saddr_size = sizeof(saddr); use_kiss_dual_port = &dummy_value; open(addr); } /// Constructs a Socket object from a file descriptor /// /// @param fd A file descriptor /// Socket::Socket(int fd) : sockfd(fd) { #ifdef __MINGW32__ windows_init(); #endif buffer = new char[S_BUFSIZ]; anum = 0; memset(&timeout, 0, sizeof(timeout)); if (sockfd == -1) return; #ifndef __MINGW32__ int r = fcntl(sockfd, F_GETFL); if (r == -1) throw SocketException(errno, "fcntl"); nonblocking = r & O_NONBLOCK; #else // no way to retrieve nonblocking status on woe32(?!) set_nonblocking(false); #endif autoclose = true; } /// /// Constructs a Socket object by copying another instance /// Socket::Socket(const Socket& s) : sockfd(s.sockfd), address(s.address), anum(s.anum), nonblocking(s.nonblocking), autoclose(true) { #ifdef __MINGW32__ windows_init(); #endif buffer = new char[S_BUFSIZ]; ainfo = address.get(anum); memcpy(&timeout, &s.timeout, sizeof(timeout)); s.set_autoclose(false); } Socket::~Socket() { if(buffer) delete [] buffer; if (autoclose) close(); } Socket& Socket::operator=(const Socket& rhs) { if (this == &rhs) return *this; sockfd = rhs.sockfd; address = rhs.address; anum = rhs.anum; ainfo = address.get(anum); memcpy(&timeout, &rhs.timeout, sizeof(timeout)); nonblocking = rhs.nonblocking; autoclose = rhs.autoclose; rhs.set_autoclose(false); return *this; } void Socket::dual_port(int * dual_port) { if(dual_port) use_kiss_dual_port = dual_port; else use_kiss_dual_port = &dummy_value; } void Socket::set_dual_port_number(unsigned int port) { dual_port_number = port; } void Socket::set_dual_port_number(std::string port) { if(!port.empty()) { dual_port_number = (unsigned int) atoi(port.c_str()); } else { use_kiss_dual_port = &dummy_value; } } /// /// Associates the Socket with an address /// /// This address will be used by subsequent calls to the bind() or connect /// methods. /// /// @params addr An address object /// void Socket::open(const Address& addr) { address = addr; size_t n = address.size(); const addr_info_t* info = (addr_info_t *)0; ainfo = info; for (anum = 0; anum < n; anum++) { info = address.get(anum); LOG_VERBOSE("\n\ Address %s\n\ Family %s\n\ Sock type %s\n\ Protocol %s", address.get_str(info).c_str(), (info->ai_family == AF_INET6 ? "AF_INET6" :\ (info->ai_family == AF_INET ? "AF_INET" : "unknown")), (info->ai_socktype == SOCK_STREAM ? "stream" : "dgram"), (info->ai_protocol == IPPROTO_TCP ? "tcp" : (info->ai_protocol == IPPROTO_UDP ? "udp" : "unknown protocol"))); if (info->ai_family == AF_INET) ainfo = info; } if (ainfo == (addr_info_t *)0) { LOG_ERROR("Cannot find IPv4 address"); sockfd = -1; throw SocketException("Cannot find IPv4 address"); } LOG_VERBOSE("Trying %s", address.get_str(ainfo).c_str()); if ((sockfd = socket(ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol)) == -1) { throw SocketException(errno, "Open socket"); } LOG_VERBOSE("Socket address: %d", sockfd); set_close_on_exec(true); } /// /// Shuts down the socket /// void Socket::close(void) { LOG_VERBOSE("sockfd %d", sockfd); #ifdef __MINGW32__ ::closesocket(sockfd); #else ::close(sockfd); #endif connected_flag = false; } /// /// Waits for the socket file descriptor to become ready for I/O /// /// @params dir Specifies the I/O direction. 0 is input, 1 is output. /// /// @return True if the file descriptor became ready within the timeout /// period, false otherwise. @see Socket::set_timeout bool Socket::wait(int dir) { fd_set fdset; FD_ZERO(&fdset); FD_SET((unsigned)sockfd, &fdset); struct timeval t = { timeout.tv_sec, timeout.tv_usec }; int r; if (dir == 0) r = select(sockfd + 1, &fdset, NULL, NULL, &t); else if (dir == 1) r = select(sockfd + 1, NULL, &fdset, NULL, &t); else throw SocketException(EINVAL, "Socket::wait"); if (r == -1) throw SocketException(errno, "select"); return r; } /// /// Binds the socket to the address associated with the object /// @see Socket::open /// void Socket::bind(void) { int r = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (const char*)&r, sizeof(r)) == -1) #ifndef NDEBUG perror("setsockopt SO_REUSEADDR"); #else ; #endif if (::bind(sockfd, ainfo->ai_addr, ainfo->ai_addrlen) == -1) { if(errno != EADDRINUSE) // EADDRINUSE == 48 throw SocketException(errno, "bind"); } } /// /// Binds the socket to the address associated with the object /// @see Socket::open /// void Socket::bindUDP(void) { #ifdef HAVE_GETADDRINFO struct addrinfo hints; struct addrinfo *res = NULL; struct addrinfo *ai_p = NULL; #ifdef __WIN32__ struct sockaddr_in *addr_in = NULL; struct sockaddr addr; #else struct sockaddr_in6 *addr_in = NULL; struct sockaddr_in6 addr; #endif int r = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (const char*)&r, sizeof(r)) == -1) throw SocketException(r, "setsockopt SO_REUSEADDR"); memset(&hints, 0, sizeof(hints)); # ifdef AI_ADDRCONFIG hints.ai_flags = AI_ADDRCONFIG; # endif #ifdef __WIN32__ hints.ai_family = AF_INET; #else hints.ai_family = AF_INET6; #endif hints.ai_socktype = SOCK_DGRAM; //hints.ai_protocol = ainfo->ai_protocol; hints.ai_flags |= AI_NUMERICSERV; std::string port_io = address.get_service(); std::string addrStr = address.get_node(); if ((r = getaddrinfo(NULL, port_io.c_str(), &hints, &res)) < 0) throw SocketException(r, "getaddrinfo"); memset(&addr, 0, sizeof(addr)); #ifdef __WIN32__ addr_in = (sockaddr_in *) &addr; #else addr_in = (sockaddr_in6 *) &addr; #endif for(ai_p = res; ai_p != NULL; ai_p = ai_p->ai_next) { #ifdef __WIN32__ if (ai_p->ai_family == AF_INET) { #else if (ai_p->ai_family == AF_INET6) { #endif memcpy(addr_in, ai_p->ai_addr, sizeof(addr)); break; } } #ifdef __WIN32__ addr_in->sin_addr.s_addr = INADDR_ANY; #else addr_in->sin6_addr = in6addr_any; #endif if (::bind(sockfd, (const struct sockaddr *)&addr, sizeof(struct sockaddr)) == -1) { freeaddrinfo(res); throw SocketException(errno, "bind"); } freeaddrinfo(res); #else int r = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (const char*)&r, sizeof(r)) == -1) #ifndef NDEBUG perror("setsockopt SO_REUSEADDR"); #else ; #endif #ifdef __WIN32__ struct sockaddr_in *addr; #else struct sockaddr_in6 *addr; #endif struct sockaddr_storage store_addr; memset(&store_addr, 0, sizeof(store_addr)); #ifdef __WIN32__ memcpy(&store_addr, ainfo->ai_addr, sizeof(struct sockaddr_in)); addr = (struct sockaddr_in *) &store_addr; addr->sin_addr.s_addr = INADDR_ANY; #else memcpy(&store_addr, ainfo->ai_addr, sizeof(struct sockaddr_in6)); addr = (struct sockaddr_in6 *) &store_addr; addr->sin6_addr.s6_addr = in6addr_any; #endif if (::bind(sockfd, (const struct sockaddr *)addr, sizeof(struct sockaddr)) == -1) throw SocketException(errno, "bind"); #endif } /// /// Calls listen(2) on the socket file desriptor /// /// The socket must already have been bound to an address via a call to the bind /// method. /// /// @params backlog The maximum number of pending connections (default SOMAXCONN) /// void Socket::listen(int backlog) { if (::listen(sockfd, backlog) == -1) throw SocketException(errno, "listen"); } /// /// Accepts a connection /// /// The socket must already have been bound to an address via a call to the bind /// method. /// /// @return A Socket instance for the accepted connection /// Socket Socket::accept(void) { connected_flag = false; Socket s; listen(); // wait for fd to become readable if (nonblocking && ((timeout.tv_sec > 0) || (timeout.tv_usec > 0))) if (!wait(0)) throw SocketException(ETIMEDOUT, "select"); int r; if ((r = ::accept(sockfd, NULL, 0)) == -1) throw SocketException(errno, "accept"); set_close_on_exec(true, r); connected_flag = true; s = Socket(r); s.connected_flag = true; return s; } /// /// Accepts a single connection and then closes the listening socket /// @see Socket::accept /// /// @return A Socket instance for the accepted connection /// Socket Socket::accept1(void) { bind(); Socket s = accept(); close(); s.set_close_on_exec(true); return s; } /// /// Accepts a connection /// /// The socket must already have been bound to an address via a call to the bind /// method. /// /// @return A Socket instance pointer for the accepted connection /// Socket * Socket::accept2(void) { connected_flag = false; Socket * s = 0; listen(); // wait for fd to become readable if (nonblocking && ((timeout.tv_sec > 0) || (timeout.tv_usec > 0))) if (!wait(0)) throw SocketException(ETIMEDOUT, "select"); int r; if ((r = ::accept(sockfd, NULL, 0)) == -1) return (Socket *)0; set_close_on_exec(true, r); connected_flag = true; s = new Socket(r); if(s) s->connected_flag = true; return s; } /// /// Connects the socket to the address that is associated with the object /// int Socket::connect(void) { connected_flag = false; int res = ::connect(sockfd, ainfo->ai_addr, ainfo->ai_addrlen); if (res == -1) { if (errno == 0 || errno == EISCONN) { LOG_VERBOSE("Connected to sockfd %d: %s : %s", sockfd, address.get_str(ainfo).c_str(), strerror(errno) ); connected_flag = true; return errno; } if (errno == EWOULDBLOCK || errno == EINPROGRESS || errno == EALREADY) { LOG_VERBOSE("Connect attempt to %s : %d, %s", address.get_str(ainfo).c_str(), errno, strerror(errno)); return errno; } LOG_ERROR("Connect to %s failed: %d, %s", address.get_str(ainfo).c_str(), errno, strerror(errno)); throw SocketException(errno, "connect"); } LOG_VERBOSE(" Connected to sockfd %d: %s", sockfd, address.get_str(ainfo).c_str()); connected_flag = true; return EISCONN; } /// /// Connects the socket to the address that is associated with the object /// Return connect state (T/F) /// bool Socket::connect1(void) { connected_flag = false; LOG_VERBOSE("Connecting to %s", address.get_str(ainfo).c_str()); if (::connect(sockfd, ainfo->ai_addr, ainfo->ai_addrlen) == -1) { return false; } connected_flag = true; return true; } /// /// Return T/F connected state. /// bool Socket::is_connected(void) { return connected_flag; } /// Set socket to allow for broadcasting. /// void Socket::broadcast(bool flag) { int option = 0; if(flag) option = 1; setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST,(char *) &option, sizeof(option)); } /// /// Connects the socket to an address /// /// @param addr The address to connect to /// int Socket::connect(const Address& addr) { close(); open(addr); return connect(); } /// /// Sends a buffer /// /// @param buf /// @param len /// /// @return The amount of data that was sent. This may be less than len /// if the socket is non-blocking. /// size_t Socket::send(const void* buf, size_t len) { // if we have a nonblocking socket and a nonzero timeout, // wait for fd to become writeable if (nonblocking && ((timeout.tv_sec > 0) || (timeout.tv_usec > 0))) if (!wait(1)) { LOG_ERROR("Select failed on %d", sockfd); return 0; } size_t nToWrite = len; int r = 0; const char *sp = (const char *)buf; while ( nToWrite > 0) { #if defined(__WIN32__) r = ::send(sockfd, sp, nToWrite, 0); if (r > 0) { sp += r; nToWrite -= r; } else { if (r == 0) { shutdown(sockfd, SHUT_WR); throw SocketException(errno, "send"); } else if (r < 0) { switch(errno) { case EAGAIN: break; case ENOTCONN: case EBADF: default: throw SocketException(errno, "send"); } r = 0; } } #else r = ::write(sockfd, sp, nToWrite); if (r > 0) { sp += r; nToWrite -= r; } else { if (r == 0) { shutdown(sockfd, SHUT_WR); throw SocketException(errno, "send"); } else if (r == -1) { switch(errno) { case EAGAIN: case ENOTCONN: case EBADF: break; default: throw SocketException(errno, "send"); } r = 0; } } #endif } return r; } /// /// Sends a string /// /// @param buf /// /// @return The amount of data that was sent. This may be less than len /// if the socket is non-blocking. /// size_t Socket::send(const std::string& buf) { size_t ret; try { ret = send(buf.data(), buf.length()); } catch (...) { throw; } return ret; } /// /// Receives data into a buffer /// /// @arg buf /// @arg len The maximum number of bytes to write to buf. /// /// @return The amount of data that was received. This may be less than len /// if the socket is non-blocking. size_t Socket::recv(void* buf, size_t len) { // if we have a nonblocking socket and a nonzero timeout, // wait for fd to become writeable if (nonblocking && ((timeout.tv_sec > 0) || (timeout.tv_usec > 0))) if (!wait(0)) { return 0; } ssize_t r = 0; try { r = ::recv(sockfd, (char*)buf, len, 0); } catch (SocketException &e) { throw e; } if (r < 0) r = 0; return r; } /// /// Receives all available data and appends it to a string. /// /// @arg buf /// /// @return The amount of data that was received. /// size_t Socket::recv(std::string& buf) { ssize_t r = 0; // if we have a nonblocking socket and a nonzero timeout, // wait for fd to become writeable if (nonblocking && ((timeout.tv_sec > 0) || (timeout.tv_usec > 0))) { if (!wait(0)) { buf.clear(); return 0; } } int tout = 2; try { buf.clear(); while (tout > 0) { memset(buffer, 0, S_BUFSIZ); r = ::recv(sockfd, buffer, S_BUFSIZ, 0); if (r > 0) buf.append(buffer); MilliSleep(50); tout--; } } catch (SocketException &e) { throw e; } return buf.length(); } /// /// Sends a buffer (UDP) /// /// @param buf /// @param len /// /// @return The amount of data that was sent. This may be less than len /// if the socket is non-blocking. /// size_t Socket::sendTo(const void* buf, size_t len) { struct sockaddr * useAddr = (struct sockaddr *)0; size_t addr_size = 0; if(use_kiss_dual_port && *use_kiss_dual_port) { memset(&saddr_dp, 0, sizeof(saddr_dp)); memcpy(&saddr_dp, ainfo->ai_addr, ainfo->ai_addrlen); set_port((struct sockaddr *) &saddr_dp, dual_port_number); useAddr = (struct sockaddr * ) &saddr_dp; addr_size = ainfo->ai_addrlen; } else { useAddr = (struct sockaddr *) ainfo->ai_addr; addr_size = ainfo->ai_addrlen; } #ifndef NDEBUG { unsigned long host_addr = get_address4((struct sockaddr *)useAddr); unsigned int host_port = get_port((struct sockaddr *) useAddr); LOG_VERBOSE("HAP:%lX:%d count=%d buf=%s", host_addr, host_port, (int)len, (char*)buf); } #endif // if we have a nonblocking socket and a nonzero timeout, // wait for fd to become writeable if (nonblocking && ((timeout.tv_sec > 0) || (timeout.tv_usec > 0))) if (!wait(1)) return 0; size_t nToWrite = len; int r = 0; const char *sp = (const char *)buf; while ( nToWrite > 0) { try { r = ::sendto(sockfd, sp, nToWrite, 0, useAddr, addr_size); } catch (...) { throw; } if (r > 0) { sp += r; nToWrite -= r; } else { if (r == 0) { shutdown(sockfd, SHUT_WR); throw SocketException(errno, "send"); } else if (r == -1) { if (errno != EAGAIN && errno != 0) { LOG_VERBOSE("errno = %d (%s) r %d buff %s", errno, strerror(errno), r, sp); } r = 0; } } } return r; } /// /// Sends a string /// /// @param buf /// /// @return The amount of data that was sent. This may be less than len /// if the socket is non-blocking. /// size_t Socket::sendTo(const std::string& buf) { try { return sendTo(buf.data(), buf.length()); } catch (...) { throw; } } // // Get the port number from a sockaddr pointer // void Socket::set_port(struct sockaddr *sa, unsigned int port) { #ifdef __WIN32__ if (sa->sa_family == AF_INET) { struct sockaddr_in *saddr_in = (sockaddr_in *) sa; saddr_in->sin_port = htons(port); } #else if (sa->sa_family == AF_INET6) { struct sockaddr_in6 *saddr_in = (sockaddr_in6 *) sa; saddr_in->sin6_port = htons(port); } #endif } // // Get the port number from a sockaddr pointer // unsigned int Socket::get_port(struct sockaddr *sa) { unsigned short int port_number = 0; #ifdef __WIN32__ if (sa->sa_family == AF_INET) { struct sockaddr_in *saddr_in = (sockaddr_in *) sa; port_number = (unsigned short int) saddr_in->sin_port; } #else if (sa->sa_family == AF_INET6) { struct sockaddr_in6 *saddr_in = (sockaddr_in6 *) sa; port_number = (unsigned short int) saddr_in->sin6_port; } #endif return (unsigned int) ntohs(port_number); } // // Get the IP Address number from a sockaddr pointer // unsigned long Socket::get_address4(struct sockaddr *sa) { #ifdef __WIN32__ unsigned long IPAddr = 0; if (sa->sa_family == AF_INET) { struct sockaddr_in *saddr_in = (sockaddr_in *) sa; IPAddr = saddr_in->sin_addr.s_addr; } return (unsigned long) ntohl(IPAddr); #else return 0L; #endif } unsigned long Socket::get_to_address(void) { return (unsigned long) ntohl(inet_addr(address.get_node().c_str())); }; /// /// Receives data into a buffer (UDP) /// /// @arg buf /// @arg len The maximum number of bytes to write to buf. /// /// @return The amount of data that was received. This may be less than len /// if the socket is non-blocking. size_t Socket::recvFrom(void* buf, size_t len) { // if we have a nonblocking socket and a nonzero timeout, // wait for fd to become writeable if (nonblocking && (timeout.tv_sec > 0 || timeout.tv_usec > 0)) if (!wait(0)) return 0; struct sockaddr_storage temp_saddr; unsigned int temp_saddr_size; temp_saddr_size = sizeof(temp_saddr); memset(&temp_saddr, 0, temp_saddr_size); int r = 0; try { r = ::recvfrom(sockfd, (char *)buf, len, 0, (struct sockaddr *)&temp_saddr, (socklen_t *)&temp_saddr_size); if (r == 0) shutdown(sockfd, SHUT_RD); else if (r < 0) { if((errno == EAGAIN) || (errno == 0)) { if (errno) LOG_VERBOSE("ErrorNo: %d (%s)", errno, strerror(errno)); memset(buf, 0, len); return 0; } else { LOG_VERBOSE("ErrorNo: %d (%s)", errno, strerror(errno)); throw SocketException(errno, "recv"); } } } catch (...) { throw; } if(r > 0) { // To prevent loop back and except only from address x unsigned long srvr_addr = 0x7F000001L; unsigned long srvr_to_addr = get_to_address(); unsigned int srvr_dp_port = get_dual_port_number(); unsigned int srvr_port = get_local_port(); unsigned int local_port = get_local_port(); unsigned long host_addr = get_address4((struct sockaddr *)&temp_saddr); unsigned int host_port = get_port((struct sockaddr *)&temp_saddr); if(use_dual_port()) { srvr_port = srvr_dp_port; } if((srvr_port == host_port) && (srvr_to_addr == host_addr)) { if((srvr_addr == host_addr) && (local_port == host_port)) { LOG_VERBOSE("Loopback Warning: %X:%u", (unsigned int)host_addr, host_port); memset(buf, 0, len); return 0; } } } return r; } #ifdef USE_ME_ONCE_I_WORK /// /// Return the local Ip Address /// /// #ifdef __WIN32__ sockaddr_in * Socket::localIPAddress(void) #else sockaddr_in6 * Socket::localIPAddress(void) #endif { char buf[512]; #ifdef __WIN32__ static struct sockaddr_in localaddr; #else static struct sockaddr_in6 localaddr; #endif struct msghdr hmsg; struct cmsghdr *cmsg; struct in_pktinfo *pkt = 0; unsigned char *cdat = 0; memset(&hmsg, 0, sizeof(hmsg)); memset(&cmsg, 0, sizeof(cmsg)); hmsg.msg_name = &localaddr; hmsg.msg_namelen = sizeof(localaddr); hmsg.msg_control = buf; hmsg.msg_controllen = sizeof(buf); size_t st = ::recvmsg(sockfd, &hmsg, 0); if(CMSG_FIRSTHDR(&hmsg)) { cmsg = CMSG_FIRSTHDR(&hmsg); for (; cmsg != NULL; cmsg = CMSG_NXTHDR(&hmsg, cmsg)) { if (cmsg->cmsg_level != IPPROTO_IP || cmsg->cmsg_type != IP_PKTINFO) { continue; } cdat = CMSG_DATA(cmsg); pkt = (struct in_pktinfo *) cdat; } } } #endif /// /// Receives all available data and appends it to a string. /// /// @arg buf /// /// @return The amount of data that was received. /// size_t Socket::recvFrom(std::string& buf) { size_t n = 0; ssize_t r; try { while ((r = recvFrom(buffer, S_BUFSIZ)) > 0) { buf.reserve(buf.length() + r); buf.append(buffer, r); n += r; } } catch (...) { throw; } return n; } /// /// Signal to unblock sockets /// /// void Socket::shut_down(void) { ::shutdown(sockfd, SHUT_RDWR); } /// /// Retrieves the socket's receive or send buffer size /// /// @param dir Specifies the I/O direction. 0 is input, 1 is output. /// int Socket::get_bufsize(int dir) { int len; if (::get_bufsize(sockfd, dir, &len) == -1) throw SocketException(errno, "get_bufsize"); return len; } /// /// Sets the socket's receive or send buffer size /// /// @param dir Specifies the I/O direction. 0 is input, 1 is output. /// @param len Specifies the new buffer size /// void Socket::set_bufsize(int dir, int len) { if (::set_bufsize(sockfd, dir, len) == -1) throw SocketException(errno, "set_bufsize"); } /// /// Sets the socket's blocking mode /// /// @param v If true, the socket is set to non-blocking /// void Socket::set_nonblocking(bool v) { if (set_nonblock(sockfd, v) == -1) throw SocketException(errno, "set_nonblock"); nonblocking = v; } /// /// Enables the use of Nagle's algorithm for the socket /// /// @param v If true, Nagle's algorithm is disabled. /// void Socket::set_nodelay(bool v) { if (::set_nodelay(sockfd, v) == -1) throw SocketException(errno, "set_nodelay"); } /// /// Sets the timeout associated with non-blocking operations /// /// @param t /// void Socket::set_timeout(const struct timeval& t) { timeout.tv_sec = t.tv_sec; timeout.tv_usec = t.tv_usec; } void Socket::set_timeout(double t) { timeout.tv_sec = (time_t)floor(t); timeout.tv_usec = (suseconds_t)((t - timeout.tv_sec) * 1e6); } /// /// Sets the socket's autoclose mode. /// /// If autoclose is disabled, the socket file descriptor will not be closed when /// the Socket object is destructed. /// /// @param v If true, the socket will be closed by the destructor /// void Socket::set_autoclose(bool v) const { autoclose = v; } /// /// Sets the socket's close-on-exec flag /// void Socket::set_close_on_exec(bool v, int fd) { if (fd == -1) fd = sockfd; if (set_cloexec(fd, v) == -1) throw SocketException(errno, "set_cloexec"); } /// /// Returns the Socket's file descriptor. /// /// The descriptor should only be used for reading and writing. /// /// @return the socket file descriptor /// int Socket::fd(void) { return sockfd; }
33,609
C++
.cxx
1,356
22.652655
109
0.664878
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,224
xmlrpc.cxx
w1hkj_fldigi/src/network/xmlrpc.cxx
// ---------------------------------------------------------------------------- // xmlrpc.cxx // // Copyright (C) 2008-2010 // Stelios Bounanos, M0GLD // Copyright (C) 2008-2010 // Dave Freese, W1HKJ // Copyright (C) 2013 // Remi Chateauneu, F4ECW // // See EOF for a list of method names. Run "fldigi --xmlrpc-list" // to see a list of method names, signatures and descriptions. // // // This file is part of fldigi. // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include "xmlrpc.h" #include <iostream> #include <iomanip> #include <string> #include <vector> #include <list> #include <map> #include <exception> #include <cstdlib> #include <signal.h> #include "threads.h" struct XmlRpcImpl; #include "globals.h" #include "configuration.h" #ifdef HAVE_VALUES_H # include <values.h> #endif #include "modem.h" #include "trx.h" #include "fl_digi.h" #include "configuration.h" #include "main.h" #include "waterfall.h" #include "macros.h" #include "qrunner.h" #include "wefax.h" #include "wefax-pic.h" #include "navtex.h" #include "ascii.h" #if USE_HAMLIB #include "hamlib.h" #endif #include "rigio.h" #include "debug.h" #include "re.h" #include "pskrep.h" // required for flrig support #include "fl_digi.h" #include "rigsupport.h" #include "confdialog.h" #include "arq_io.h" #include "status.h" LOG_FILE_SOURCE(debug::LOG_RPC_SERVER); using namespace XmlRpc; /// Not defined the usual way on Mingw #ifndef DBL_MAX #define DBL_MAX 1.7976931348623157e+308 #endif namespace xmlrpc_c { struct method { const char * _signature ; const char * _help ; virtual std::string help(void) const { return _help;} const char * signature() const { return _signature; } virtual ~method() {} }; typedef method * methodPtr ; typedef XmlRpcValue value ; typedef XmlRpcValue value_string ; typedef XmlRpcValue value_bytestring ; typedef XmlRpcValue value_struct ; typedef XmlRpcValue value_nil ; typedef XmlRpcValue value_array ; typedef XmlRpcValue value_double ; typedef XmlRpcValue value_int ; typedef XmlRpcValue value_boolean ; struct fault : public std::runtime_error { typedef enum { CODE_INTERNAL } Codes; fault( const char * msg, Codes cd = CODE_INTERNAL ) : std::runtime_error(msg) {} }; struct paramList { const XmlRpcValue & _params ; paramList( const XmlRpcValue & prm ) : _params(prm) {} int getInt(int i, int mini = INT_MIN, int maxi = INT_MAX ) const { int tmp = _params[i]; if( tmp < mini ) tmp = mini ; else if(tmp > maxi) tmp = maxi ; return tmp ; } std::string getString(int i) const { return _params[i]; } std::vector<unsigned char> getBytestring(int i) const { return _params[i]; } double getDouble(int i, double mini = -DBL_MAX, double maxi = DBL_MAX) const { double tmp = _params[i]; if( tmp < mini ) tmp = mini ; else if(tmp > maxi) tmp = maxi ; return tmp ; } bool getBoolean(int i) const { return _params[i]; } const std::vector<value> & getArray(int i) const { return _params[i]; } void verifyEnd(size_t sz) const { const std::vector<value> & tmpRef = _params ; if( sz != tmpRef.size() ) throw std::runtime_error("Bad size"); } }; } template< class RPC_METHOD > struct Method : public RPC_METHOD, public XmlRpcServerMethod { Method( const char * n ) : XmlRpcServerMethod( n ) {} void execute (XmlRpcValue &params, XmlRpcValue &result) { xmlrpc_c::paramList params2(params) ; RPC_METHOD::execute( params2, &result ); } }; typedef XmlRpcServerMethod * (*RpcFactory)( const char * ); template<class RPC_METHOD> struct RpcBuilder { static XmlRpcServerMethod * factory( const char * name ) { return new Method< RPC_METHOD >( name ); } }; struct XmlRpcImpl : public XmlRpcServer { void fl_open(const char * port) { bindAndListen( atoi( port ) ); enableIntrospection(true); } void run() { double milli_secs = -1.0 ; // Tell our server to wait indefinately for messages work(milli_secs); } /// BEWARE IT IS CALLED FROM ANOTHER THREAD. void close() { exit(); shutdown(); } }; struct rpc_method { RpcFactory m_fact ; ~rpc_method() { delete method ; } xmlrpc_c::method * method ; const char* name; }; typedef std::list<rpc_method> methods_t; static methods_t* methods = 0; pthread_t* server_thread; pthread_mutex_t* server_mutex; XML_RPC_Server* XML_RPC_Server::inst = 0; XML_RPC_Server::XML_RPC_Server() { server_impl = new XmlRpcImpl; add_methods(); for( methods_t::iterator it = methods->begin(), en = methods->end(); it != en; ++it ) { XmlRpcServerMethod * mth = dynamic_cast< XmlRpcServerMethod * >( it->method ); server_impl->addMethod( mth ); } server_thread = new pthread_t; server_mutex = new pthread_mutex_t; pthread_mutex_init(server_mutex, NULL); // run = true; } XML_RPC_Server::~XML_RPC_Server() { // run = false; // the xmlrpc server is closed and deleted when // XML_RPC_Server::stop(); // is called from main // delete methods; } void XML_RPC_Server::start(const char* node, const char* service) { if (inst) return; inst = new XML_RPC_Server; try { inst->server_impl->fl_open(service); if (pthread_create(server_thread, NULL, thread_func, NULL) != 0) throw std::runtime_error(strerror(errno)); } catch (const std::exception& e) { LOG_ERROR("Could not start XML-RPC server (%s)", e.what()); delete server_thread; server_thread = 0; delete inst; inst = 0; return; } } /// BEWARE IT IS CALLED FROM ANOTHER THREAD. void XML_RPC_Server::stop(void) { // FIXME: uncomment when we have an xmlrpc server that can be interrupted // if (!inst) // return; inst->server_impl->close(); delete inst; inst = 0; } void* XML_RPC_Server::thread_func(void*) { SET_THREAD_ID(XMLRPC_TID); save_signals(); inst->server_impl->run(); restore_signals(); SET_THREAD_CANCEL(); return NULL; } std::ostream& XML_RPC_Server::list_methods(std::ostream& out) { add_methods(); std::ios_base::fmtflags f = out.flags(std::ios::left); for (methods_t::const_iterator i = methods->begin(); i != methods->end(); ++i) out << std::setw(32) << i->name << std::setw(8) << i->method->signature() << i->method->help() << '\n'; return out << std::setiosflags(f); } // ============================================================================= // Methods that change the server state must call XMLRPC_LOCK // guard_lock (include/threads.h) ensures that mutex are always unlocked. #define XMLRPC_LOCK SET_THREAD_ID(XMLRPC_TID); guard_lock autolock_(server_mutex) // ============================================================================= // generic helper functions static void set_button(Fl_Button* button, bool value) { button->value(value); button->do_callback(); } static void set_valuator(Fl_Valuator* valuator, double value) { valuator->value(value); valuator->do_callback(); } static void set_text(Fl_Input* textw, std::string& value) { textw->value(value.c_str()); textw->do_callback(); } static void set_text2(Fl_Input2* textw, std::string& value) { textw->value(value.c_str()); textw->do_callback(); } static void set_combo_contents(Fl_ComboBox* box, const std::vector<std::string>* items) { box->clear(); if (items->empty()) { box->add(""); box->index(0); box->deactivate(); return; } for (std::vector<std::string>::const_iterator i = items->begin(); i != items->end(); ++i) { box->add(i->c_str()); } box->index(0); box->activate(); } static void set_combo_value(Fl_ComboBox* box, const std::string& s) { box->value(s.c_str()); box->do_callback(); } static void get_combo_contents(Fl_ComboBox* box, std::vector<xmlrpc_c::value>* items) { int n = box->lsize(), p = box->index(); items->reserve(n); for (int i = 0; i < n; i++) { box->index(i); items->push_back(xmlrpc_c::value_string(box->value())); } box->index(p); } // ============================================================================= // XML-RPC interface definition // ============================================================================= class Fldigi_list : public xmlrpc_c::method { public: Fldigi_list() { _signature = "A:n"; _help = "Returns the list of methods."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { std::vector<xmlrpc_c::value> help; for (methods_t::const_iterator i = methods->begin(); i != methods->end(); ++i) { std::map<std::string, xmlrpc_c::value> item; item["name"] = xmlrpc_c::value_string(i->name); item["signature"] = xmlrpc_c::value_string(i->method->signature()); item["help"] = xmlrpc_c::value_string(i->method->help()); help.push_back(xmlrpc_c::value_struct(item)); } *retval = xmlrpc_c::value_array(help); } }; class Fldigi_name : public xmlrpc_c::method { public: Fldigi_name() { _signature = "s:n"; _help = "Returns the program name."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { *retval = xmlrpc_c::value_string(PACKAGE_TARNAME); } }; class Fldigi_version_struct : public xmlrpc_c::method { public: Fldigi_version_struct() { _signature = "S:n"; _help = "Returns the program version as a struct."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { std::map<std::string, xmlrpc_c::value> vstruct; vstruct["major"] = xmlrpc_c::value_int(FLDIGI_VERSION_MAJOR); vstruct["minor"] = xmlrpc_c::value_int(FLDIGI_VERSION_MINOR); vstruct["patch"] = xmlrpc_c::value_string(FLDIGI_VERSION_PATCH); *retval = xmlrpc_c::value_struct(vstruct); } }; class Fldigi_version_string : public xmlrpc_c::method { public: Fldigi_version_string() { _signature = "s:n"; _help = "Returns the program version as a string."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] fldigi.version_string: %s", XmlRpc::client_id.c_str(), PACKAGE_VERSION); *retval = xmlrpc_c::value_string(PACKAGE_VERSION); } }; class Fldigi_name_version : public xmlrpc_c::method { public: Fldigi_name_version() { _signature = "s:n"; _help = "Returns the program name and version."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] fldigi.name_version: %s", XmlRpc::client_id.c_str(), PACKAGE_STRING); *retval = xmlrpc_c::value_string(PACKAGE_STRING); } }; class Fldigi_config_dir : public xmlrpc_c::method { public: Fldigi_config_dir() { _signature = "s:n"; _help = "Returns the name of the configuration directory."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] fldigi.config_dir %s", XmlRpc::client_id.c_str(), HomeDir.c_str()); *retval = xmlrpc_c::value_string(HomeDir); } }; class Fldigi_terminate : public xmlrpc_c::method { public: Fldigi_terminate() { _signature = "n:i"; _help = "Terminates fldigi. ``i'' is bitmask specifying data to save: 0=options; 1=log; 2=macros."; } enum { TERM_SAVE_OPTIONS = 1 << 0, TERM_SAVE_LOG = 1 << 1, TERM_SAVE_MACROS = 1 << 2 }; static void terminate(int how) { if (how & TERM_SAVE_OPTIONS) progdefaults.saveDefaults(); progdefaults.changed = false; progdefaults.confirmExit = false; extern bool oktoclear; if (how & TERM_SAVE_LOG && !oktoclear) qsoSave->do_callback(); oktoclear = true; progdefaults.NagMe = false; if (how & TERM_SAVE_MACROS && macros.changed) macros.saveMacroFile(); macros.changed = false; fl_digi_main->do_callback(); } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] fldigi.terminate: %d", XmlRpc::client_id.c_str(), int(params.getInt(0))); REQ(terminate, params.getInt(0)); *retval = xmlrpc_c::value_nil(); } }; // ============================================================================= class Modem_get_name : public xmlrpc_c::method { public: Modem_get_name() { _signature = "s:n"; _help = "Returns the name of the current modem."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { const char* cur = mode_info[active_modem->get_mode()].sname; LOG_INFO("[%s] modem.get_name: %s", XmlRpc::client_id.c_str(), cur); *retval = xmlrpc_c::value_string(cur); } }; class Modem_get_mode : public xmlrpc_c::method { public: Modem_get_mode() { _signature = "s:n"; _help = "Returns the ADIF mode for the current modem."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { std::string adif_mode = mode_info[active_modem->get_mode()].export_mode; std::string adif_submode = mode_info[active_modem->get_mode()].export_submode; LOG_INFO("[%s] modem.get_mode: %s", XmlRpc::client_id.c_str(), adif_mode.c_str()); *retval = xmlrpc_c::value_string(adif_mode); } }; class Modem_get_submode : public xmlrpc_c::method { public: Modem_get_submode() { _signature = "s:n"; _help = "Returns the ADIF submode for the current modem."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { std::string adif_submode = mode_info[active_modem->get_mode()].export_submode; LOG_INFO("[%s] modem.get_mode: %s", XmlRpc::client_id.c_str(), adif_submode.c_str()); *retval = xmlrpc_c::value_string(adif_submode); } }; class Modem_get_names : public xmlrpc_c::method { public: Modem_get_names() { _signature = "A:n"; _help = "Returns all modem names."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { std::vector<xmlrpc_c::value> names; names.reserve(NUM_MODES); std::string snames; for (size_t i = 0; i < NUM_MODES; i++) { names.push_back(xmlrpc_c::value_string(mode_info[i].sname)); snames.append("\n").append(mode_info[i].sname); } LOG_INFO("[%s] modem.get_names: %s", XmlRpc::client_id.c_str(), snames.c_str()); *retval = xmlrpc_c::value_array(names); } }; class Modem_get_id : public xmlrpc_c::method { public: Modem_get_id() { _signature = "i:n"; _help = "Returns the ID of the current modem."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { int md = active_modem->get_mode(); LOG_INFO("[%s] modem.get_id %d", XmlRpc::client_id.c_str(), md); *retval = xmlrpc_c::value_int(md); } }; class Modem_get_max_id : public xmlrpc_c::method { public: Modem_get_max_id() { _signature = "i:n"; _help = "Returns the maximum modem ID number."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] modem.get_max_id: %d", XmlRpc::client_id.c_str(), NUM_MODES -1); *retval = xmlrpc_c::value_int(NUM_MODES - 1); } }; class Modem_set_by_name : public xmlrpc_c::method { public: Modem_set_by_name() { _signature = "s:s"; _help = "Sets the current modem. Returns old name."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; const char* cur = mode_info[active_modem->get_mode()].sname; std::string s = params.getString(0); LOG_INFO("[%s] modem.set_by_name: %s", XmlRpc::client_id.c_str(), s.c_str()); for (size_t i = 0; i < NUM_MODES; i++) { if (s == mode_info[i].sname) { REQ_SYNC(init_modem_sync, i, 0); *retval = xmlrpc_c::value_string(cur); return; } } *retval = "No such modem"; return; } }; class Modem_set_by_id : public xmlrpc_c::method { public: Modem_set_by_id() { _signature = "i:i"; _help = "Sets the current modem. Returns old ID."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; int cur = active_modem->get_mode(); int i = params.getInt(0, 0, NUM_MODES-1); REQ_SYNC(init_modem_sync, i, 0); *retval = xmlrpc_c::value_int(cur); } }; // ============================================================================= class Modem_set_carrier : public xmlrpc_c::method { public: Modem_set_carrier() { _signature = "i:i"; _help = "Sets modem carrier. Returns old carrier."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; int cur = active_modem->get_freq(); LOG_INFO("[%s] modem.set_carrier: %d", XmlRpc::client_id.c_str(), int(params.getInt(0,1))); active_modem->set_freq(params.getInt(0, 1)); *retval = xmlrpc_c::value_int(cur); } }; class Modem_inc_carrier : public xmlrpc_c::method { public: Modem_inc_carrier() { _signature = "i:i"; _help = "Increments the modem carrier frequency. Returns the new carrier."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; int cur = active_modem->get_freq(); LOG_INFO("[%s] modem.inc_carrier: %d", XmlRpc::client_id.c_str(), int(params.getInt(0))); active_modem->set_freq(cur + params.getInt(0)); *retval = xmlrpc_c::value_int(active_modem->get_freq()); } }; class Modem_get_carrier : public xmlrpc_c::method { public: Modem_get_carrier() { _signature = "i:n"; _help = "Returns the modem carrier frequency."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] modem.get_carrier: %d", XmlRpc::client_id.c_str(), int(active_modem->get_freq())); *retval = xmlrpc_c::value_int(active_modem->get_freq()); } }; // ============================================================================= class Modem_get_afc_sr : public xmlrpc_c::method { public: Modem_get_afc_sr() { _signature = "i:n"; _help = "Returns the modem AFC search range."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { if (!(active_modem->get_cap() & modem::CAP_AFC_SR)) { LOG_ERROR("[%s] modem.get_afc_sr: %s", XmlRpc::client_id.c_str(), "Operation not supported by modem"); *retval = "Operation not supported by modem"; } else { LOG_INFO("[%s] modem.get_afc_sr: %d", XmlRpc::client_id.c_str(), int(cntSearchRange->value())); *retval = xmlrpc_c::value_int((int)cntSearchRange->value()); } } }; class Modem_set_afc_sr : public xmlrpc_c::method { public: Modem_set_afc_sr() { _signature = "i:i"; _help = "Sets the modem AFC search range. Returns the old value."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; if (!(active_modem->get_cap() & modem::CAP_AFC_SR)) { LOG_DEBUG("[%s] modem.set_afc_sr %s", XmlRpc::client_id.c_str(), "Operation not supported by modem"); *retval = "Operation not supported by modem"; return; } int v = (int)(cntSearchRange->value()); LOG_INFO("[%s] modem.set_afc_sr: %d", XmlRpc::client_id.c_str(), v); REQ(set_valuator, cntSearchRange, params.getInt(0, (int)cntSearchRange->minimum(), (int)cntSearchRange->maximum())); *retval = xmlrpc_c::value_int(v); } }; class Modem_inc_afc_sr : public xmlrpc_c::method { public: Modem_inc_afc_sr() { _signature = "i:i"; _help = "Increments the modem AFC search range. Returns the new value."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; if (!(active_modem->get_cap() & modem::CAP_AFC_SR)) { LOG_DEBUG("[%s] modem.inc_afc_sr: %s", XmlRpc::client_id.c_str(), "Operation not supported by modem"); *retval = "Operation not supported by modem"; return; } int v = (int)(cntSearchRange->value() + params.getInt(0)); LOG_INFO("[%s] modem.inc_afc_sr: %d", XmlRpc::client_id.c_str(), v); REQ(set_valuator, cntSearchRange, v); *retval = xmlrpc_c::value_int(v); } }; // ============================================================================= static Fl_Valuator* get_bw_val(void) { if (!(active_modem->get_cap() & modem::CAP_BW)) return 0; trx_mode m = active_modem->get_mode(); if (m >= MODE_HELL_FIRST && m <= MODE_HELL_LAST) return sldrHellBW; else if (m == MODE_CW) return sldrCWbandwidth; return 0; } class Modem_get_bw : public xmlrpc_c::method { public: Modem_get_bw() { _signature = "i:n"; _help = "Returns the modem bandwidth."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { Fl_Valuator* val = get_bw_val(); LOG_INFO("[%s] modem.get_bw: %d", XmlRpc::client_id.c_str(), int(get_bw_val()->value())); if (val) *retval = xmlrpc_c::value_int((int)get_bw_val()->value()); else *retval = xmlrpc_c::value_int(0); } }; class Modem_set_bw : public xmlrpc_c::method { public: Modem_set_bw() { _signature = "i:i"; _help = "Sets the modem bandwidth. Returns the old value."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; Fl_Valuator* val = get_bw_val(); if (val) { int v = (int)(val->value()); LOG_INFO("[%s] modem.set_bw: %d", XmlRpc::client_id.c_str(), v); REQ(set_valuator, val, params.getInt(0, (int)val->minimum(), (int)val->maximum())); *retval = xmlrpc_c::value_int(v); } else *retval = xmlrpc_c::value_int(0); } }; class Modem_inc_bw : public xmlrpc_c::method { public: Modem_inc_bw() { _signature = "i:i"; _help = "Increments the modem bandwidth. Returns the new value."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; Fl_Valuator* val = get_bw_val(); if (val) { int v = (int)(val->value() + params.getInt(0)); LOG_INFO("[%s] modem.inc_bw: %d", XmlRpc::client_id.c_str(), v); REQ(set_valuator, val, v); *retval = xmlrpc_c::value_int(v); } else *retval = xmlrpc_c::value_int(0); } }; // ============================================================================= class Modem_get_quality : public xmlrpc_c::method { public: Modem_get_quality() { _signature = "d:n"; _help = "Returns the modem signal quality in the range [0:100]."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] modem.get_quality: %f", XmlRpc::client_id.c_str(), pgrsSquelch->value()); *retval = xmlrpc_c::value_double(pgrsSquelch->value()); } }; class Modem_search_up : public xmlrpc_c::method { public: Modem_search_up() { _signature = "n:n"; _help = "Searches upward in frequency."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "modem.search_up"); REQ(&modem::searchUp, active_modem); *retval = xmlrpc_c::value_nil(); } }; class Modem_search_down : public xmlrpc_c::method { public: Modem_search_down() { _signature = "n:n"; _help = "Searches downward in frequency."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "modem.search_down"); REQ(&modem::searchDown, active_modem); *retval = xmlrpc_c::value_nil(); } }; class Modem_olivia_set_bandwidth : public xmlrpc_c::method { public: Modem_olivia_set_bandwidth() { _signature = "n:i"; _help = "Sets the Olivia bandwidth."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { int bw; switch (bw = params.getInt(0)) { case 125: case 250: case 500: case 1000: case 2000: { XMLRPC_LOCK; LOG_INFO("[%s] modem.olivia_set_bandwidth: %d", XmlRpc::client_id.c_str(), bw); REQ_SYNC(set_olivia_bw, bw); *retval = xmlrpc_c::value_nil(); } break; default: LOG_INFO("[%s] modem.olivia_set_bandiwidth: %s", XmlRpc::client_id.c_str(), "Invalid bandwidth"); *retval = "Invalid Olivia bandwidth"; } } }; class Modem_olivia_get_bandwidth : public xmlrpc_c::method { public: Modem_olivia_get_bandwidth() { _signature = "i:n"; _help = "Returns the Olivia bandwidth."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { int bw, v = i_listbox_olivia_bandwidth->index() + 1; if (v == 0) bw = 125; else if (v == 1) bw = 250; else if (v == 2) bw = 500; else if (v == 3) bw = 1000; else bw = 2000; LOG_INFO("[%s] modem.olivia_get_bandwidth: %d", XmlRpc::client_id.c_str(), bw); *retval = xmlrpc_c::value_int(bw); } }; class Modem_olivia_set_tones : public xmlrpc_c::method { public: Modem_olivia_set_tones() { _signature = "n:i"; _help = "Sets the Olivia tones."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { int tones = params.getInt(0, 2, 256); if (powerof2(tones)) { XMLRPC_LOCK; LOG_INFO("[%s] modem.olivia_set_tones: %d", XmlRpc::client_id.c_str(), tones); REQ_SYNC(set_olivia_tones, tones); *retval = xmlrpc_c::value_nil(); } else { LOG_INFO("[%s] modem.olivia_set_tones: %s", XmlRpc::client_id.c_str(), "Invalid olivia tones"); *retval = "Invalid Olivia tones"; } } }; class Modem_olivia_get_tones : public xmlrpc_c::method { public: Modem_olivia_get_tones() { _signature = "i:n"; _help = "Returns the Olivia tones."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] modem.olivia_get_tones: %d", XmlRpc::client_id.c_str(), int(1 << (i_listbox_olivia_tones->index() + 1))); *retval = xmlrpc_c::value_int(1 << (i_listbox_olivia_tones->index() + 1)); } }; // ============================================================================= class Main_get_status1 : public xmlrpc_c::method { public: Main_get_status1() { _signature = "s:n"; _help = "Returns the contents of the first status field (typically s/n)."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] main.get_status1: %s", XmlRpc::client_id.c_str(), Status1->label()); *retval = xmlrpc_c::value_string(Status1->label()); } }; class Main_get_status2 : public xmlrpc_c::method { public: Main_get_status2() { _signature = "s:n"; _help = "Returns the contents of the second status field."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] main.get_status2: %s", XmlRpc::client_id.c_str(), Status2->label()); *retval = xmlrpc_c::value_string(Status2->label()); } }; class Main_get_sb : public xmlrpc_c::method { public: Main_get_sb() { _signature = "s:n"; _help = "[DEPRECATED; use main.get_wf_sideband and/or rig.get_mode]"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] main.get_sb (DEPRECATED): %s", XmlRpc::client_id.c_str(), wf->USB() ? "USB" : "LSB"); *retval = xmlrpc_c::value_string(wf->USB() ? "USB" : "LSB"); } }; class Main_set_sb : public xmlrpc_c::method { public: Main_set_sb() { _signature = "n:s"; _help = "[DEPRECATED; use main.set_wf_sideband and/or rig.set_mode]"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; std::string s = params.getString(0); if (s != "LSB" && s != "USB") { *retval = "Invalid argument"; return; } LOG_INFO("[%s] main.set_sb (DEPRECATED): %s", XmlRpc::client_id.c_str(), s.c_str()); REQ(static_cast<void (waterfall::*)(bool)>(&waterfall::USB), wf, s == "USB"); *retval = xmlrpc_c::value_nil(); } }; class Main_get_wf_sideband : public xmlrpc_c::method { public: Main_get_wf_sideband() { _signature = "s:n"; _help = "Returns the current waterfall sideband."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] main.get_wf_sideband: %s", XmlRpc::client_id.c_str(), wf->USB() ? "USB" : "LSB"); *retval = xmlrpc_c::value_string(wf->USB() ? "USB" : "LSB"); } }; class Main_set_wf_sideband : public xmlrpc_c::method { public: Main_set_wf_sideband() { _signature = "n:s"; _help = "Sets the waterfall sideband to USB or LSB."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; std::string s = params.getString(0); if (s != "USB" && s != "LSB") *retval = "Invalid argument"; else REQ(static_cast<void (waterfall::*)(bool)>(&waterfall::USB), wf, s == "USB"); LOG_INFO("[%s] main.set_wf_sideband %s", XmlRpc::client_id.c_str(), s.c_str()); *retval = xmlrpc_c::value_nil(); } }; void xmlrpc_set_qsy(long long rfc) { unsigned long int freq = static_cast<unsigned long int>(rfc); wf->rfcarrier(freq); wf->movetocenter(); show_frequency(freq); } class Main_set_freq : public xmlrpc_c::method { public: Main_set_freq() { _signature = "d:d"; _help = "Sets the RF carrier frequency. Returns the old value."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; double rfc = wf->rfcarrier(); LOG_INFO("[%s] main.set_freq: %f", XmlRpc::client_id.c_str(), rfc); qsy((long long int)params.getDouble(0, 0.0)); *retval = xmlrpc_c::value_double(rfc); } }; class Main_inc_freq : public xmlrpc_c::method { public: Main_inc_freq() { _signature = "d:d"; _help = "Increments the RF carrier frequency. Returns the new value."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; double rfc = wf->rfcarrier() + params.getDouble(0); qsy((long long int)rfc); LOG_INFO("[%s] main.inc_freq: %f", XmlRpc::client_id.c_str(), rfc); *retval = xmlrpc_c::value_double(rfc); } }; // ============================================================================= class Main_get_afc : public xmlrpc_c::method { public: Main_get_afc() { _signature = "b:n"; _help = "Returns the AFC state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] main.get_afc: %s", XmlRpc::client_id.c_str(), (btnAFC->value() ? "ON" : "OFF")); *retval = xmlrpc_c::value_boolean(btnAFC->value()); } }; class Main_set_afc : public xmlrpc_c::method { public: Main_set_afc() { _signature = "b:b"; _help = "Sets the AFC state. Returns the old state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = btnAFC->value(); LOG_INFO("[%s] main.set_afc: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); REQ(set_button, btnAFC, params.getBoolean(0)); *retval = xmlrpc_c::value_boolean(v); } }; class Main_toggle_afc : public xmlrpc_c::method { public: Main_toggle_afc() { _signature = "b:n"; _help = "Toggles the AFC state. Returns the new state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = !btnAFC->value(); LOG_INFO("[%s] main.toggle_afc: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); REQ(set_button, btnAFC, v); *retval = xmlrpc_c::value_boolean(v); } }; // ============================================================================= class Main_get_sql : public xmlrpc_c::method { public: Main_get_sql() { _signature = "b:n"; _help = "Returns the squelch state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] main.get_sql: %s", XmlRpc::client_id.c_str(), (btnSQL->value() ? "ON" : "OFF")); *retval = xmlrpc_c::value_boolean(btnSQL->value()); } }; class Main_set_sql : public xmlrpc_c::method { public: Main_set_sql() { _signature = "b:b"; _help = "Sets the squelch state. Returns the old state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = btnSQL->value(); LOG_INFO("[%s] main.set_sql: %s", XmlRpc::client_id.c_str(), (btnSQL->value() ? "ON" : "OFF")); REQ(set_button, btnSQL, params.getBoolean(0)); *retval = xmlrpc_c::value_boolean(v); } }; class Main_toggle_sql : public xmlrpc_c::method { public: Main_toggle_sql() { _signature = "b:n"; _help = "Toggles the squelch state. Returns the new state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = !btnSQL->value(); LOG_INFO("[%s] main.toggle_sql: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); REQ(set_button, btnSQL, v); *retval = xmlrpc_c::value_boolean(v); } }; // ============================================================================= class Main_get_sql_level : public xmlrpc_c::method { public: Main_get_sql_level() { _signature = "d:n"; _help = "Returns the squelch level."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] main.get_sql_level: %f", XmlRpc::client_id.c_str(), sldrSquelch->value()); *retval = xmlrpc_c::value_double(sldrSquelch->value()); } }; class Main_set_sql_level : public xmlrpc_c::method { public: Main_set_sql_level() { _signature = "d:d"; _help = "Sets the squelch level. Returns the old level."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; double v = sldrSquelch->value(); LOG_INFO("[%s] main.set_sql_level: %f", XmlRpc::client_id.c_str(), v); REQ(set_valuator, sldrSquelch, params.getDouble(0, sldrSquelch->maximum(), sldrSquelch->minimum())); *retval = xmlrpc_c::value_double(v); } }; class Main_inc_sql_level : public xmlrpc_c::method { public: Main_inc_sql_level() { _signature = "d:d"; _help = "Increments the squelch level. Returns the new level."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; double v = sldrSquelch->value(); LOG_INFO("[%s] main.inc_sql_level: %f", XmlRpc::client_id.c_str(), v); REQ(set_valuator, sldrSquelch, v + params.getDouble(0)); // FIXME: check range *retval = xmlrpc_c::value_double(sldrSquelch->value()); } }; // ============================================================================= class Main_get_rev : public xmlrpc_c::method { public: Main_get_rev() { _signature = "b:n"; _help = "Returns the Reverse Sideband state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] main.get_rev: %s", XmlRpc::client_id.c_str(), (wf->btnRev->value() ? "ON" : "OFF")); *retval = xmlrpc_c::value_boolean(wf->btnRev->value()); } }; class Main_set_rev : public xmlrpc_c::method { public: Main_set_rev() { _signature = "b:b"; _help = "Sets the Reverse Sideband state. Returns the old state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = wf->btnRev->value(); LOG_INFO("[%s] main.set_rev: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); REQ(set_button, wf->btnRev, params.getBoolean(0)); *retval = xmlrpc_c::value_boolean(v); } }; class Main_toggle_rev : public xmlrpc_c::method { public: Main_toggle_rev() { _signature = "b:n"; _help = "Toggles the Reverse Sideband state. Returns the new state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = !wf->btnRev->value(); LOG_INFO("[%s] main.toggle_rev: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); REQ(set_button, wf->btnRev, v); *retval = xmlrpc_c::value_boolean(v); } }; // ============================================================================= class Main_get_lock : public xmlrpc_c::method { public: Main_get_lock() { _signature = "b:n"; _help = "Returns the Transmit Lock state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] main.get_lock: %s", XmlRpc::client_id.c_str(), (wf->xmtlock->value() ? "ON" : "OFF")); *retval = xmlrpc_c::value_boolean(wf->xmtlock->value()); } }; class Main_set_lock : public xmlrpc_c::method { public: Main_set_lock() { _signature = "b:b"; _help = "Sets the Transmit Lock state. Returns the old state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = wf->xmtlock->value(); LOG_INFO("[%s] main.set_lock: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); REQ(set_button, wf->xmtlock, params.getBoolean(0)); *retval = xmlrpc_c::value_boolean(v); } }; class Main_toggle_lock : public xmlrpc_c::method { public: Main_toggle_lock() { _signature = "b:n"; _help = "Toggles the Transmit Lock state. Returns the new state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = !wf->xmtlock->value(); LOG_INFO("[%s] main.toggle_lock: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); REQ(set_button, wf->xmtlock, v); *retval = xmlrpc_c::value_boolean(v); } }; // ============================================================================= class Main_get_txid : public xmlrpc_c::method { public: Main_get_txid() { _signature = "b:n"; _help = "Returns the TXID state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] main.get_txid: %s", XmlRpc::client_id.c_str(), (btnTxRSID->value() ? "ON" : "OFF")); *retval = xmlrpc_c::value_boolean(btnTxRSID->value()); } }; class Main_set_txid : public xmlrpc_c::method { public: Main_set_txid() { _signature = "b:b"; _help = "Sets the TXID state. Returns the old state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = btnTxRSID->value(); LOG_INFO("[%s] main.set_txid: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); REQ(set_button, btnTxRSID, params.getBoolean(0)); *retval = xmlrpc_c::value_boolean(v); } }; class Main_toggle_txid : public xmlrpc_c::method { public: Main_toggle_txid() { _signature = "b:n"; _help = "Toggles the TXID state. Returns the new state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = !btnTxRSID->value(); LOG_INFO("[%s] main.toggle_txid: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); REQ(set_button, btnTxRSID, v); *retval = xmlrpc_c::value_boolean(v); } }; class Main_get_rsid : public xmlrpc_c::method { public: Main_get_rsid() { _signature = "b:n"; _help = "Returns the RSID state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] main.get_rsid: %s", XmlRpc::client_id.c_str(), (btnRSID->value() ? "ON" : "OFF")); *retval = xmlrpc_c::value_boolean(btnRSID->value()); } }; class Main_set_rsid : public xmlrpc_c::method { public: Main_set_rsid() { _signature = "b:b"; _help = "Sets the RSID state. Returns the old state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = btnRSID->value(); LOG_INFO("[%s] main.set_rsid: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); REQ(set_button, btnRSID, params.getBoolean(0)); *retval = xmlrpc_c::value_boolean(v); } }; class Main_toggle_rsid : public xmlrpc_c::method { public: Main_toggle_rsid() { _signature = "b:n"; _help = "Toggles the RSID state. Returns the new state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = !btnRSID->value(); LOG_INFO("[%s] main.toggle_rsid: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); REQ(set_button, btnRSID, v); *retval = xmlrpc_c::value_boolean(v); } }; // ============================================================================= class Main_get_trx_status : public xmlrpc_c::method { public: Main_get_trx_status() { _signature = "s:n"; _help = "Returns transmit/tune/receive status."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { std::string st; if (btnTune->value()) st = "tune"; else if (wf->xmtrcv->value()) st = "tx"; else st = "rx"; LOG_INFO("[%s] main.get_trx_status: %s", XmlRpc::client_id.c_str(), st.c_str()); *retval = xmlrpc_c::value_string(st.c_str()); } }; class Main_tx : public xmlrpc_c::method { public: Main_tx() { _signature = "n:n"; _help = "Transmits."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; if (!wf->xmtrcv->value()) { LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "main.tx"); REQ(set_button, wf->xmtrcv, true); } *retval = xmlrpc_c::value_nil(); } }; class Main_tune : public xmlrpc_c::method { public: Main_tune() { _signature = "n:n"; _help = "Tunes."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; if (!btnTune->value()) { LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "main.tune"); REQ(set_button, btnTune, !btnTune->value()); } *retval = xmlrpc_c::value_nil(); } }; class Main_rx : public xmlrpc_c::method { public: Main_rx() { _signature = "n:n"; _help = "Receives."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; if (wf->xmtrcv->value()) { LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "main.rx"); REQ(set_button, wf->xmtrcv, false); } *retval = xmlrpc_c::value_nil(); } }; class Main_abort : public xmlrpc_c::method { public: Main_abort() { _signature = "n:n"; _help = "Aborts a transmit or tune."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; if (trx_state == STATE_TX || trx_state == STATE_TUNE) { REQ(abort_tx); REQ(AbortARQ); } LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "main.abort"); *retval = xmlrpc_c::value_nil(); } }; class Main_rx_tx : public xmlrpc_c::method { public: Main_rx_tx() { _signature = "n:n"; _help = "Sets normal Rx/Tx switching."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; if (trx_state == STATE_TX || trx_state == STATE_TUNE) { REQ(abort_tx); REQ(AbortARQ); } LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "main.rx_tx"); REQ(set_rx_tx); *retval = xmlrpc_c::value_nil(); } }; class Main_rx_only : public xmlrpc_c::method { public: Main_rx_only() { _signature = "n:n"; _help = "Disables Tx."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; if (trx_state == STATE_TX || trx_state == STATE_TUNE) { REQ(abort_tx); REQ(AbortARQ); } LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "main.rx_only"); REQ(set_rx_only); *retval = xmlrpc_c::value_nil(); } }; //---------------------------------------------------------------------- // flmsg i/o //---------------------------------------------------------------------- bool flmsg_is_online = false; void flmsg_defeat(void *) { flmsg_is_online = false; } static void reset_flmsg() { flmsg_is_online = true; Fl::remove_timeout(flmsg_defeat); Fl::add_timeout(5.0, flmsg_defeat); } class flmsg_online : public xmlrpc_c::method { public: flmsg_online() { _signature = "n:n"; _help = "flmsg online indication"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; reset_flmsg(); LOG_INFO("[%s] main.flmsg_online: %s", XmlRpc::client_id.c_str(), "true"); } }; class flmsg_get_data : public xmlrpc_c::method { public: flmsg_get_data() { _signature = "6:n"; _help = "Returns all RX data received since last query."; } static void get_rx(char **text, int *size) { // the get* methods may throw but this function is not allowed to do so *text = get_rx_data(); *size = strlen(*text); } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; char *text; int size; REQ_SYNC(get_rx, &text, &size); std::vector<unsigned char> bytes; if (size) { bytes.resize(size, 0); memcpy(&bytes[0], text, size); } reset_flmsg(); LOG_INFO("[%s] flmsg_get_data: %s", XmlRpc::client_id.c_str(), text); *retval = xmlrpc_c::value_bytestring(bytes); } }; std::string flmsg_data; class flmsg_available : public xmlrpc_c::method { public: flmsg_available() { _signature = "n:n"; _help = "flmsg data available"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; int data_ready = (int)flmsg_data.size(); reset_flmsg(); LOG_INFO("[%s] main.flmsg_available: %d", XmlRpc::client_id.c_str(), data_ready); *retval = xmlrpc_c::value_int(data_ready); } }; class flmsg_transfer : public xmlrpc_c::method { public: flmsg_transfer() { _signature = "n:n"; _help = "data transfer to flmsg"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; std::string tempstr = flmsg_data; reset_flmsg(); LOG_INFO("[%s] main.flmsg_transfer:\n%s", XmlRpc::client_id.c_str(), tempstr.c_str()); *retval = xmlrpc_c::value_string(tempstr); flmsg_data.clear(); } }; class flmsg_squelch : public xmlrpc_c::method { public: flmsg_squelch() { _signature = "b:n"; _help = "Returns the squelch state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { reset_flmsg(); LOG_INFO("[%s] main.flmsg_squelch: %s", XmlRpc::client_id.c_str(), (active_modem->get_metric() > progStatus.sldrSquelchValue ? "ACTIVE" : "NOT ACTIVE")); *retval = xmlrpc_c::value_boolean(active_modem->get_metric() > progStatus.sldrSquelchValue); } }; //---------------------------------------------------------------------- // BACKWARD COMPATABILITY //---------------------------------------------------------------------- class Main_flmsg_online : public xmlrpc_c::method { public: Main_flmsg_online() { _signature = "n:n"; _help = "flmsg online indication"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; reset_flmsg(); LOG_INFO("[%s] main.flmsg_online: %s", XmlRpc::client_id.c_str(), "true"); } }; class Main_flmsg_available : public xmlrpc_c::method { public: Main_flmsg_available() { _signature = "n:n"; _help = "flmsg data available"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; int data_ready = (int)flmsg_data.size(); reset_flmsg(); LOG_INFO("[%s] main.flmsg_available: %d", XmlRpc::client_id.c_str(), data_ready); *retval = xmlrpc_c::value_int(data_ready); } }; class Main_flmsg_transfer : public xmlrpc_c::method { public: Main_flmsg_transfer() { _signature = "n:n"; _help = "data transfer to flmsg"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; std::string tempstr = flmsg_data; reset_flmsg(); LOG_INFO("[%s] main.flmsg_transfer:\n%s", XmlRpc::client_id.c_str(), tempstr.c_str()); *retval = xmlrpc_c::value_string(tempstr); flmsg_data.clear(); } }; class Main_flmsg_squelch : public xmlrpc_c::method { public: Main_flmsg_squelch() { _signature = "b:n"; _help = "Returns the squelch state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { reset_flmsg(); LOG_INFO("[%s] main.flmsg_squelch: %s", XmlRpc::client_id.c_str(), (active_modem->get_metric() > progStatus.sldrSquelchValue ? "ACTIVE" : "NOT ACTIVE")); *retval = xmlrpc_c::value_boolean(active_modem->get_metric() > progStatus.sldrSquelchValue); } }; //---------------------------------------------------------------------- class Main_run_macro : public xmlrpc_c::method { public: Main_run_macro() { _signature = "n:i"; _help = "Runs a macro."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] main.run_macro: %d", XmlRpc::client_id.c_str(), int(params.getInt(0,0,MAXMACROS-1))); REQ(&Main_run_macro::run_macro, params.getInt(0, 0, MAXMACROS-1)); *retval = xmlrpc_c::value_nil(); } static void run_macro(int i) { macros.execute(i); } }; class Main_get_max_macro_id : public xmlrpc_c::method { public: Main_get_max_macro_id() { _signature = "i:n"; _help = "Returns the maximum macro ID number."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] main.get_max_macro_id: %d", XmlRpc::client_id.c_str(), MAXMACROS - 1); *retval = xmlrpc_c::value_int(MAXMACROS - 1); } }; class Main_rsid : public xmlrpc_c::method { public: Main_rsid() { _signature = "n:n"; _help = "[DEPRECATED; use main.{get,set,toggle}_rsid]"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; if (!(wf->xmtrcv->value() || btnTune->value() || btnRSID->value())) { LOG_INFO("[%s] main.rsid: %s", XmlRpc::client_id.c_str(), "ENABLE"); REQ(set_button, btnRSID, true); } *retval = xmlrpc_c::value_nil(); } }; // ============================================================================= // classes added to support flrig // // dhf 6/23/09 class Main_get_trx_state : public xmlrpc_c::method { public: Main_get_trx_state() { _signature = "s:n"; _help = "Returns T/R state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { std::string st; if (trx_state == STATE_TX || trx_state == STATE_TUNE) st = "TX"; else if (trx_state == STATE_RX) st = "RX"; else st = "OTHER"; LOG_INFO("[%s] main.get_trx_state: %s", XmlRpc::client_id.c_str(), st.c_str()); *retval = xmlrpc_c::value_string(st.c_str()); } }; pthread_mutex_t tx_queue_mutex = PTHREAD_MUTEX_INITIALIZER; static std::string xmlchars; bool xmltest_char_available; static size_t pxmlchar = 0; static char xml_status_msg[50]; int xmltest_char() { guard_lock xmlchr_lock(&tx_queue_mutex); if (xmlchars.empty() || !xmltest_char_available) return -3; if (pxmlchar >= xmlchars.length() ) { xmlchars.clear(); pxmlchar = 0; xmltest_char_available = false; return -3; } snprintf(xml_status_msg, sizeof(xml_status_msg), "%d%% sent", static_cast<int>(100*pxmlchar/xmlchars.length())); put_status(xml_status_msg, 1.0); return xmlchars[pxmlchar++] & 0xFF; } void reset_xmlchars() { xmlchars.clear(); pxmlchar = 0; xmltest_char_available = false; } int number_of_samples( std::string s) { active_modem->XMLRPC_CPS_TEST = true; xmlchars = s; pxmlchar = 0; xmltest_char_available = true; active_modem->set_stopflag(false); trx_transmit(); MilliSleep(10); while(trx_state != STATE_RX) { MilliSleep(10); Fl::awake(); } xmltest_char_available = false; active_modem->XMLRPC_CPS_TEST = false; return active_modem->tx_sample_count; } class Main_get_char_rates : public xmlrpc_c::method { public: Main_get_char_rates() { _signature = "s:n"; _help = "Returns table of char rates."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { trx_mode id = active_modem->get_mode(); if ( id == MODE_SSB || id == MODE_WWV || id == MODE_ANALYSIS || id == MODE_WEFAX_576 || id == MODE_WEFAX_288 ) { *retval = xmlrpc_c::value_string("0:1:0"); return; } XMLRPC_LOCK; REQ(stopMacroTimer); int s0 = 0;//number_of_samples(""); int s1 = 0; std::string xmlbuf; static char result[100]; static std::string line; int chsamples = 0; int i = 0; for (int m = 0; m < 32; m++) { line.clear(); for (int n = 0; n < 8; n++) { i = m*8+n; if ( (id >= MODE_PSK31 && id <= MODE_PSK1000R) || (id >= MODE_4X_PSK63R && id <= MODE_2X_PSK1000R) || id == MODE_CW || id == MODE_RTTY ) { s1 = number_of_samples(std::string(1,i)); chsamples = active_modem->char_samples; } else { s0 = number_of_samples(std::string(1, i)); int j; for(j = 2; j < 32; j++) { s1 = number_of_samples(std::string(j, i)); if(s1 > s0) break; } chsamples = (s1 - s0) / (j-1); } snprintf(result, sizeof(result), n == 7 ? " %.8f\n" : n == 0 ? "%.8f," : " %.8f,", 1.0 * chsamples / active_modem->get_samplerate()); line.append(result); } xmlbuf.append(line); } LOG_INFO("[%s] main.get_char_rates:\n%s", XmlRpc::client_id.c_str(), xmlbuf.c_str()); *retval = xmlrpc_c::value_string(xmlbuf); } }; class Main_get_char_timing : public xmlrpc_c::method { public: Main_get_char_timing() { _signature = "n:i"; _help = "Input: value of character. Returns transmit duration for specified character (samples:sample rate)."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { trx_mode id = active_modem->get_mode(); if ( id == MODE_SSB || id == MODE_WWV || id == MODE_ANALYSIS || id == MODE_WEFAX_576 || id == MODE_WEFAX_288 ) { *retval = xmlrpc_c::value_string("0:1:0"); return; } XMLRPC_LOCK; REQ(stopMacroTimer); std::vector<unsigned char> bytes = params.getBytestring(0); bytes.push_back(0); std::string totest = (const char*)&bytes[0]; if (totest.empty() || !active_modem) { *retval = xmlrpc_c::value_string("0:1:0"); return; } static std::string xmlbuf; char result[64]; int character = 0; int count = sscanf(totest.c_str(), "%d", &character); if(count != 1) { *retval = xmlrpc_c::value_string("0:1:0"); return; } unsigned int s0 = 0, chsamples = 0, over_head = 0; int factor = 4; unsigned int min_char = 2; bool psk_8_flag = false; bool fast_flag = false; if((id >= MODE_8PSK_FIRST) && (id <= MODE_8PSK_LAST)) psk_8_flag = true; if (((id >= MODE_4X_PSK63R) && (id <= MODE_2X_PSK1000R)) || ((id >= MODE_PSK31) && (id <= MODE_PSK1000R)) || (id == MODE_CW) || (id == MODE_RTTY)) { if(psk_8_flag) fast_flag = false; else fast_flag = true; } if(((id >= MODE_THOR_FIRST) && (id <= MODE_THOR_LAST)) || ((id >= MODE_OLIVIA_FIRST) && (id <= MODE_OLIVIA_LAST))) { fast_flag = false; psk_8_flag = false; } if(fast_flag) { s0 = number_of_samples(std::string(1,character)); chsamples = active_modem->char_samples; over_head = active_modem->ovhd_samples; } else if(psk_8_flag) { // This doens't seem to work with the MFSK modes int n = 16; over_head = number_of_samples(""); chsamples = number_of_samples(std::string(n, character)) - over_head; chsamples /= n; } else { // This works for all of the remaining modes. unsigned int s1 = 0, s2 = 0; unsigned int temp = 0, no_of_chars = 1, k = 0; s0 = s1 = s2 = number_of_samples(std::string(no_of_chars, character)); for(int i = no_of_chars + 1; i < 32; i++) { s2 = number_of_samples(std::string(i, character)); if(s2 > s1 && temp++ > min_char) { break; } s0 = s2; no_of_chars++; } k = no_of_chars * factor; s1 = number_of_samples(std::string(k, character)); chsamples = (s1 - s0) / (k - no_of_chars); over_head = s1 - (chsamples * k); } snprintf(result, sizeof(result), "%5u:%6u:%6u", chsamples, active_modem->get_samplerate(), over_head); xmlbuf.assign(result); LOG_INFO("[%s] main.get_char_timing:\n%s", XmlRpc::client_id.c_str(), xmlbuf.c_str()); *retval = xmlrpc_c::value_string(xmlbuf); } }; class Main_get_tx_timing : public xmlrpc_c::method { public: Main_get_tx_timing() { _signature = "n:s"; _help = "Returns transmit duration for test string (samples:sample rate:secs)."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { trx_mode id = active_modem->get_mode(); if ( id == MODE_SSB || id == MODE_WWV || id == MODE_ANALYSIS || id == MODE_WEFAX_576 || id == MODE_WEFAX_288 || id == MODE_SITORB || id == MODE_NAVTEX ) { *retval = xmlrpc_c::value_string("0:1:0.0"); return; } XMLRPC_LOCK; std::vector<unsigned char> bytes = params.getBytestring(0); bytes.push_back(0); std::string totest = (const char*)&bytes[0]; if (totest.empty() || !active_modem) { *retval = xmlrpc_c::value_string("0:1:0.0"); return; } int chsamples = number_of_samples(totest);// - start_stop_samples; std::string xmlbuf; char buf[64]; memset(buf, 0, sizeof(buf)); snprintf(buf, sizeof(buf) - 1, "%u : %u : %.9f", \ chsamples, active_modem->tx_sample_rate, 1.0 * chsamples / active_modem->tx_sample_rate); xmlbuf.assign(buf); LOG_INFO("[%s] main.get_tx_timing:\n%s", XmlRpc::client_id.c_str(), xmlbuf.c_str()); *retval = xmlrpc_c::value_string(xmlbuf); } }; class Rig_set_name : public xmlrpc_c::method { public: Rig_set_name() { _signature = "n:s"; _help = "Sets the rig name for xmlrpc rig"; } static void set_rig_name(const std::string& name) { windowTitle = name; if (main_window_title.find(windowTitle) == std::string::npos) setTitle(); } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] main.set_name: %s", XmlRpc::client_id.c_str(), std::string(params.getString(0)).c_str()); REQ(set_rig_name, params.getString(0)); *retval = xmlrpc_c::value_nil(); } }; class Rig_get_name : public xmlrpc_c::method { public: Rig_get_name() { _signature = "s:n"; _help = "Returns the rig name previously set via rig.set_name"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] rig.get_name: %s", XmlRpc::client_id.c_str(), windowTitle.c_str()); *retval = xmlrpc_c::value_string(windowTitle); } }; class Rig_set_frequency : public xmlrpc_c::method { public: Rig_set_frequency() { _signature = "d:d"; _help = "Sets the RF carrier frequency. Returns the old value."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; double rfc = wf->rfcarrier(); unsigned long int f = (long int)(params.getDouble(0,0.0)); LOG_INFO("[%s] rig.set_frequency %lu", XmlRpc::client_id.c_str(), f); qsy(f); *retval = xmlrpc_c::value_double(rfc); } }; class Rig_get_freq : public xmlrpc_c::method { public: Rig_get_freq() { _signature = "d:n"; _help = "Returns the RF carrier frequency."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { double rfc = wf->rfcarrier(); LOG_INFO("[%s] rig.get_frequency %f", XmlRpc::client_id.c_str(), rfc); *retval = xmlrpc_c::value_double(rfc); } }; class Rig_set_smeter : public xmlrpc_c::method { public: Rig_set_smeter() { _signature = "n:i"; _help = "Sets the smeter returns null."; } static void set_smeter(int rfc) { if (smeter && pwrmeter && progStatus.meters) { smeter->value(rfc); pwrmeter->hide(); smeter->show(); } } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] rig.set_smeter: %d", XmlRpc::client_id.c_str(), int(params.getInt(0))); REQ(set_smeter, params.getInt(0)); *retval = xmlrpc_c::value_nil(); } }; class Rig_set_pwrmeter : public xmlrpc_c::method { public: Rig_set_pwrmeter() { _signature = "n:i"; _help = "Sets the power meter returns null."; } static void set_pwrmeter(int rfc) { if (pwrmeter && smeter && progStatus.meters) { pwrmeter->value(rfc); smeter->hide(); pwrmeter->show(); } } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] rig.set_pwrmeter: %d", XmlRpc::client_id.c_str(), int(params.getInt(0))); REQ(set_pwrmeter, params.getInt(0)); *retval = xmlrpc_c::value_nil(); } }; class Rig_set_modes : public xmlrpc_c::method { public: Rig_set_modes() { _signature = "n:A"; _help = "Sets the list of available rig modes"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; std::vector<xmlrpc_c::value> v = params.getArray(0); std::vector<std::string> modes; std::string smodes; modes.reserve(v.size()); // copy for (std::vector<xmlrpc_c::value>::const_iterator i = v.begin(); i != v.end(); ++i) { modes.push_back(static_cast<std::string>(xmlrpc_c::value_string(*i))); smodes.append("\n").append(static_cast<std::string>(xmlrpc_c::value_string(*i))); } LOG_INFO("[%s] rig.set_modes:%s", XmlRpc::client_id.c_str(), smodes.c_str()); REQ_SYNC(set_combo_contents, qso_opMODE, &modes); *retval = xmlrpc_c::value_nil(); } }; class Rig_set_mode : public xmlrpc_c::method { public: Rig_set_mode() { _signature = "n:s"; _help = "Selects a mode previously added by rig.set_modes"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] rig_set_mode: %s", XmlRpc::client_id.c_str(), std::string(params.getString(0)).c_str()); REQ(set_combo_value, qso_opMODE, params.getString(0)); *retval = xmlrpc_c::value_nil(); } }; class Rig_get_modes : public xmlrpc_c::method { public: Rig_get_modes() { _signature = "A:n"; _help = "Returns the list of available rig modes"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; std::vector<xmlrpc_c::value> modes; REQ_SYNC(get_combo_contents, qso_opMODE, &modes); std::string smodes; for (size_t n = 0; n < modes.size(); n++) smodes.append("\n").append(std::string(modes[n])); LOG_INFO("[%s] rig.get_modes:%s", XmlRpc::client_id.c_str(), smodes.c_str()); *retval = xmlrpc_c::value_array(modes); } }; class Rig_get_mode : public xmlrpc_c::method { public: Rig_get_mode() { _signature = "s:n"; _help = "Returns the name of the current transceiver mode"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] rig.get_mode: %s", XmlRpc::client_id.c_str(), qso_opMODE->value()); *retval = xmlrpc_c::value_string(qso_opMODE->value()); } }; class Rig_set_bandwidths : public xmlrpc_c::method { public: Rig_set_bandwidths() { _signature = "n:A"; _help = "Sets the list of available rig bandwidths"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; std::vector<xmlrpc_c::value> v = params.getArray(0); std::vector<std::string> bws; std::string s_bws; bws.reserve(v.size()); for (std::vector<xmlrpc_c::value>::const_iterator i = v.begin(); i != v.end(); ++i) { bws.push_back(static_cast<std::string>(xmlrpc_c::value_string(*i))); s_bws.append("\n").append(static_cast<std::string>(xmlrpc_c::value_string(*i))); } LOG_INFO("[%s] rig.set_bandwidths:%s", XmlRpc::client_id.c_str(), s_bws.c_str()); REQ_SYNC(set_combo_contents, qso_opBW, &bws); *retval = xmlrpc_c::value_nil(); } }; class Rig_set_bandwidth : public xmlrpc_c::method { public: Rig_set_bandwidth() { _signature = "n:s"; _help = "Selects a bandwidth previously added by rig.set_bandwidths"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] rig.set_bandwidth: %s", XmlRpc::client_id.c_str(), std::string(params.getString(0)).c_str()); REQ(set_combo_value, qso_opBW, params.getString(0)); *retval = xmlrpc_c::value_nil(); } }; class Rig_get_bandwidths : public xmlrpc_c::method { public: Rig_get_bandwidths() { _signature = "A:n"; _help = "Returns the list of available rig bandwidths"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; std::vector<xmlrpc_c::value> bws; REQ_SYNC(get_combo_contents, qso_opBW, &bws); std::string sbws; for (size_t n = 0; n < bws.size(); n++) sbws.append("\n").append(std::string(bws[n])); LOG_INFO("[%s] rig.get_modes:%s", XmlRpc::client_id.c_str(), sbws.c_str()); *retval = xmlrpc_c::value_array(bws); } }; class Rig_get_bandwidth : public xmlrpc_c::method { public: Rig_get_bandwidth() { _signature = "s:n"; _help = "Returns the name of the current transceiver bandwidth"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] rig.get_bandwidth: %s", XmlRpc::client_id.c_str(), std::string(qso_opBW->value()).c_str()); *retval = xmlrpc_c::value_string(qso_opBW->value()); } }; class Rig_get_notch : public xmlrpc_c::method { public: Rig_get_notch() { _signature = "s:n"; _help = "Reports a notch filter frequency based on WF action"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] rig.get_notch: %d", XmlRpc::client_id.c_str(), notch_frequency); *retval = xmlrpc_c::value_int(notch_frequency); } }; class Rig_set_notch : public xmlrpc_c::method { public: Rig_set_notch() { _signature = "n:i"; _help = "Sets the notch filter position on WF"; } static void set_notch(int freq) { notch_frequency = freq; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; int notch = notch_frequency; REQ(set_notch, params.getInt(0)); LOG_INFO("[%s] rig.set_notch: %d", XmlRpc::client_id.c_str(), notch); *retval = xmlrpc_c::value_int(notch); } }; class Rig_enable_qsy : public xmlrpc_c::method { public: Rig_enable_qsy() { _signature = "n:i"; _help = "Enable/disable (1/0) QSY for xmlrpc transceiver control"; } static void enable_qsy(int on) { if (!wf) return; wf->setQSY(on); } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; REQ(enable_qsy, params.getInt(0)); *retval = xmlrpc_c::value_int(params.getInt(0)); } }; // ============================================================================= class Main_set_rig_name : public Rig_set_name { public: Main_set_rig_name() { _help = "[DEPRECATED; use rig.set_name]"; } }; class Main_set_rig_frequency : public Rig_set_frequency { public: Main_set_rig_frequency() { _help = "[DEPRECATED; use rig.set_frequency]"; } }; class Main_set_rig_modes : public Rig_set_modes { public: Main_set_rig_modes() { _help = "[DEPRECATED; use rig.set_modes"; } }; class Main_set_rig_mode : public Rig_set_mode { public: Main_set_rig_mode() { _help = "[DEPRECATED; use rig.set_mode"; } }; class Main_get_freq : public Rig_get_freq { public: Main_get_freq() {_help = "[DEPRECATED; use rig.get_frequency"; } }; class Main_get_rig_modes : public Rig_get_modes { public: Main_get_rig_modes() { _help = "[DEPRECATED; use rig.get_modes]"; } }; class Main_get_rig_mode : public Rig_get_mode { public: Main_get_rig_mode() { _help = "[DEPRECATED; use rig.get_mode]"; } }; class Main_set_rig_bandwidths : public Rig_set_bandwidths { public: Main_set_rig_bandwidths() { _help = "[DEPRECATED; use rig.set_bandwidths]"; } }; class Main_set_rig_bandwidth : public Rig_set_bandwidth { public: Main_set_rig_bandwidth() { _help = "[DEPRECATED; use rig.set_bandwidth]"; } }; class Main_get_rig_bandwidths : public Rig_set_bandwidths { public: Main_get_rig_bandwidths() { _help = "[DEPRECATED; use rig.get_bandwidths]"; } }; class Main_get_rig_bandwidth : public Rig_get_bandwidth { public: Main_get_rig_bandwidth() { _help = "[DEPRECATED; use rig.get_bandwidth]"; } }; // ============================================================================= class Log_get_freq : public xmlrpc_c::method { public: Log_get_freq() { _signature = "s:n"; _help = "Returns the Frequency field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_freq: %s", XmlRpc::client_id.c_str(), inpFreq->value()); *retval = xmlrpc_c::value_string(inpFreq->value()); } }; class Log_get_time_on : public xmlrpc_c::method { public: Log_get_time_on() { _signature = "s:n"; _help = "Returns the Time-On field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_time_on: %s", XmlRpc::client_id.c_str(), inpTimeOn->value()); *retval = xmlrpc_c::value_string(inpTimeOn->value()); } }; class Log_get_date_on : public xmlrpc_c::method { public: Log_get_date_on() { _signature = "s:n"; _help = "Returns the date associated with time_on field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_date_on: %s", XmlRpc::client_id.c_str(), sDate_on.c_str()); *retval = xmlrpc_c::value_string(sDate_on); } }; class Log_get_time_off : public xmlrpc_c::method { public: Log_get_time_off() { _signature = "s:n"; _help = "Returns the Time-Off field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_time_off: %s", XmlRpc::client_id.c_str(), inpTimeOff->value()); *retval = xmlrpc_c::value_string(inpTimeOff->value()); } }; class Log_get_date_off : public xmlrpc_c::method { public: Log_get_date_off() { _signature = "s:n"; _help = "Returns the date associated with time_off field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_date_on: %s", XmlRpc::client_id.c_str(), sDate_off.c_str()); *retval = xmlrpc_c::value_string(sDate_off); } }; class Log_get_call : public xmlrpc_c::method { public: Log_get_call() { _signature = "s:n"; _help = "Returns the Call field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_call: %s", XmlRpc::client_id.c_str(), inpCall->value()); *retval = xmlrpc_c::value_string(inpCall->value()); } }; class Log_set_call : public xmlrpc_c::method { public: Log_set_call() { _signature = "n:s"; _help = "Sets the Call field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] log.set_call: %s", XmlRpc::client_id.c_str(), std::string(params.getString(0)).c_str()); REQ(set_text, inpCall, params.getString(0)); *retval = xmlrpc_c::value_nil(); } }; class Log_get_name : public xmlrpc_c::method { public: Log_get_name() { _signature = "s:n"; _help = "Returns the Name field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_Name: %s", XmlRpc::client_id.c_str(), inpName->value()); *retval = xmlrpc_c::value_string(inpName->value()); } }; class Log_set_name : public xmlrpc_c::method { public: Log_set_name() { _signature = "n:s"; _help = "Sets the Name field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] log.set_name: %s", XmlRpc::client_id.c_str(), std::string(params.getString(0)).c_str()); REQ(set_text, inpName, params.getString(0)); *retval = xmlrpc_c::value_nil(); } }; class Log_set_qth : public xmlrpc_c::method { public: Log_set_qth() { _signature = "n:s"; _help = "Sets the QTH field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] log.set_qth: %s", XmlRpc::client_id.c_str(), std::string(params.getString(0)).c_str()); REQ(set_text, inpQth, params.getString(0)); *retval = xmlrpc_c::value_nil(); } }; class Log_set_locator : public xmlrpc_c::method { public: Log_set_locator() { _signature = "n:s"; _help = "Sets the Locator field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] log.set_locator: %s", XmlRpc::client_id.c_str(), std::string(params.getString(0)).c_str()); REQ(set_text, inpLoc, params.getString(0)); *retval = xmlrpc_c::value_nil(); } }; class Log_get_rst_in : public xmlrpc_c::method { public: Log_get_rst_in() { _signature = "s:n"; _help = "Returns the RST(r) field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_rst_in: %s", XmlRpc::client_id.c_str(), inpRstIn->value()); *retval = xmlrpc_c::value_string(inpRstIn->value()); } }; class Log_set_rst_in : public xmlrpc_c::method { public: Log_set_rst_in() { _signature = "n:s"; _help = "Sets the RST(r) field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] log.set_rst_in: %s", XmlRpc::client_id.c_str(), std::string(params.getString(0)).c_str()); REQ(set_text2, inpRstIn, params.getString(0)); *retval = xmlrpc_c::value_nil(); } }; class Log_get_rst_out : public xmlrpc_c::method { public: Log_get_rst_out() { _signature = "s:n"; _help = "Returns the RST(s) field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_rst_out: %s", XmlRpc::client_id.c_str(), inpRstOut->value()); *retval = xmlrpc_c::value_string(inpRstOut->value()); } }; class Log_set_rst_out : public xmlrpc_c::method { public: Log_set_rst_out() { _signature = "n:s"; _help = "Sets the RST(s) field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] log.set_rst_out: %s", XmlRpc::client_id.c_str(), std::string(params.getString(0)).c_str()); REQ(set_text2, inpRstOut, params.getString(0)); *retval = xmlrpc_c::value_nil(); } }; class Log_get_serial_number : public xmlrpc_c::method { public: Log_get_serial_number() { _signature = "s:n"; _help = "Returns the serial number field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_serial_number: %s", XmlRpc::client_id.c_str(), inpSerNo->value()); *retval = xmlrpc_c::value_string(inpSerNo->value()); } }; class Log_set_serial_number : public xmlrpc_c::method { public: Log_set_serial_number() { _signature = "n:s"; _help = "Sets the serial number field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] log.set_serial_number: %s", XmlRpc::client_id.c_str(), std::string(params.getString(0)).c_str()); REQ(set_text, inpSerNo, params.getString(0)); *retval = xmlrpc_c::value_nil(); } }; class Log_get_serial_number_sent : public xmlrpc_c::method { public: Log_get_serial_number_sent() { _signature = "s:n"; _help = "Returns the serial number (sent) field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_serial_number_sent: %s", XmlRpc::client_id.c_str(), outSerNo->value()); *retval = xmlrpc_c::value_string(outSerNo->value()); } }; class Log_get_exchange : public xmlrpc_c::method { public: Log_get_exchange() { _signature = "s:n"; _help = "Returns the contest exchange field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_exchange: %s", XmlRpc::client_id.c_str(), inpXchgIn->value()); *retval = xmlrpc_c::value_string(inpXchgIn->value()); } }; class Log_set_exchange : public xmlrpc_c::method { public: Log_set_exchange() { _signature = "n:s"; _help = "Sets the contest exchange field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] log.set_exchange: %s", XmlRpc::client_id.c_str(), std::string(params.getString(0)).c_str()); REQ(set_text, inpXchgIn, params.getString(0)); *retval = xmlrpc_c::value_nil(); } }; class Log_get_state : public xmlrpc_c::method { public: Log_get_state() { _signature = "s:n"; _help = "Returns the State field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_state: %s", XmlRpc::client_id.c_str(), inpState->value()); *retval = xmlrpc_c::value_string(inpState->value()); } }; class Log_get_province : public xmlrpc_c::method { public: Log_get_province() { _signature = "s:n"; _help = "Returns the Province field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_province: %s", XmlRpc::client_id.c_str(), inpVEprov->value()); *retval = xmlrpc_c::value_string(inpVEprov->value()); } }; class Log_get_country : public xmlrpc_c::method { public: Log_get_country() { _signature = "s:n"; _help = "Returns the Country field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_country: %s", XmlRpc::client_id.c_str(), cboCountry->value()); *retval = xmlrpc_c::value_string(cboCountry->value()); } }; class Log_get_qth : public xmlrpc_c::method { public: Log_get_qth() { _signature = "s:n"; _help = "Returns the QTH field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_qth: %s", XmlRpc::client_id.c_str(), inpQTH->value()); *retval = xmlrpc_c::value_string(inpQth->value()); } }; class Log_get_band : public xmlrpc_c::method { public: Log_get_band() { _signature = "s:n"; _help = "Returns the current band name."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_band: %s", XmlRpc::client_id.c_str(), band_name(band(wf->rfcarrier()))); *retval = xmlrpc_c::value_string(band_name(band(wf->rfcarrier()))); } }; class Log_get_sb : public Main_get_wf_sideband { public: Log_get_sb() { _help = "[DEPRECATED; use main.get_wf_sideband]"; } }; class Log_get_notes : public xmlrpc_c::method { public: Log_get_notes() { _signature = "s:n"; _help = "Returns the Notes field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_notes: %s", XmlRpc::client_id.c_str(), inpNotes->value()); *retval = xmlrpc_c::value_string(inpNotes->value()); } }; class Log_get_locator : public xmlrpc_c::method { public: Log_get_locator() { _signature = "s:n"; _help = "Returns the Locator field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_locator: %s", XmlRpc::client_id.c_str(), inpLoc->value()); *retval = xmlrpc_c::value_string(inpLoc->value()); } }; class Log_get_az : public xmlrpc_c::method { public: Log_get_az() { _signature = "s:n"; _help = "Returns the AZ field contents."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] log.get_az: %s", XmlRpc::client_id.c_str(), inpAZ->value()); *retval = xmlrpc_c::value_string(inpAZ->value()); } }; class Logbook_last_record: public xmlrpc_c::method{ public: Logbook_last_record() { _signature = "s:n"; _help = "Returns the ADIF record of the last logbook record."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { std::string adif_str = last_adif_record(); LOG_INFO("[%s] logbook.last_record: %s", XmlRpc::client_id.c_str(), last_adif_record().c_str()); *retval = xmlrpc_c::value_string(adif_str); } }; class Logbook_all_records: public xmlrpc_c::method{ public: Logbook_all_records() { _signature = "s:n"; _help = "Returns the entire ADIF logbook currently opened."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { std::string adif_str = all_adif_records(); LOG_INFO("[%s] logbook.all_adif_records export size %lu", XmlRpc::client_id.c_str(), adif_str.length()); *retval = xmlrpc_c::value_string(adif_str); } }; class Log_clear : public xmlrpc_c::method { public: Log_clear() { _signature = "n:n"; _help = "Clears the contents of the log fields."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "log.clear"); REQ(clearQSO); *retval = xmlrpc_c::value_nil(); } }; // ============================================================================= class Io_in_use : public xmlrpc_c::method { public: Io_in_use() { _signature = "s:n"; _help = "Returns the IO port in use (ARQ/KISS)."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { std::string s; if(data_io_enabled == KISS_IO) s = "KISS"; else if(data_io_enabled == ARQ_IO) s = "ARQ"; else s = ""; LOG_INFO("[%s] Io.in_use: %s", XmlRpc::client_id.c_str(), s.c_str()); *retval = xmlrpc_c::value_string(s.c_str()); } }; class Io_enable_kiss : public xmlrpc_c::method { public: Io_enable_kiss() { _signature = "n:n"; _help = "Switch to KISS I/O"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "Io.enable_kiss"); REQ(enable_kiss); *retval = xmlrpc_c::value_nil(); } }; class Io_enable_arq : public xmlrpc_c::method { public: Io_enable_arq() { _signature = "n:n"; _help = "Switch to ARQ I/O"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "Io.enable_arq"); REQ(enable_arq); *retval = xmlrpc_c::value_nil(); } }; // ============================================================================= class Text_get_rx_length : public xmlrpc_c::method { public: Text_get_rx_length() { _signature = "i:n"; _help = "Returns the number of characters in the RX widget."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] Text.get_rx_length: %d", XmlRpc::client_id.c_str(), (int)(ReceiveText->buffer()->length())); *retval = xmlrpc_c::value_int(ReceiveText->buffer()->length()); } }; class Text_get_rx : public xmlrpc_c::method { public: Text_get_rx() { _signature = "6:ii"; _help = "Returns a range of characters (start, length) from the RX text widget."; } static void get_rx_text_range(const xmlrpc_c::paramList* params, xmlrpc_c::fault** err, char** text, int* size) { // the get* methods may throw but this function is not allowed to do so try { params->verifyEnd(2); Fl_Text_Buffer_mod* tbuf = ReceiveText->buffer(); int len = tbuf->length(); int start = params->getInt(0, 0, len - 1); int n = params->getInt(1, -1, len - start); if (n == -1) n = len; // we can request more text than is available *text = tbuf->text_range(start, start + n); *size = n; } catch (const xmlrpc_c::fault& f) { *err = new xmlrpc_c::fault(f); } catch (const std::exception& e) { *err = new xmlrpc_c::fault(e.what(), xmlrpc_c::fault::CODE_INTERNAL); } } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; xmlrpc_c::fault* err = NULL; char* text; int size; REQ_SYNC(get_rx_text_range, &params, &err, &text, &size); if (unlikely(err)) { xmlrpc_c::fault f(*err); delete err; throw f; } std::vector<unsigned char> bytes; if (size) { bytes.resize(size, 0); memcpy(&bytes[0], text, size); } *retval = xmlrpc_c::value_bytestring(bytes); LOG_INFO("[%s] Text.get_rx: %s", XmlRpc::client_id.c_str(), text); free(text); } }; class Text_clear_rx : public xmlrpc_c::method { public: Text_clear_rx() { _signature = "n:n"; _help = "Clears the RX text widget."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; REQ(&FTextBase::clear, ReceiveText); LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "Text.clear_rx"); *retval = xmlrpc_c::value_nil(); } }; class Text_add_tx_queu : public xmlrpc_c::method { public: Text_add_tx_queu() { _signature = "n:s"; _help = "Adds a string to the TX transmit queu."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; guard_lock xmlchr_lock(&tx_queue_mutex); std::string txt2send = params.getString(0); if (xmlchars.empty()) { xmlchars = txt2send; xmltest_char_available = true; pxmlchar = 0; } else { xmlchars.append(txt2send); } LOG_INFO("[%s] Text.add_tx_queue: %s", XmlRpc::client_id.c_str(), txt2send.c_str()); *retval = xmlrpc_c::value_nil(); } }; class Text_add_tx : public xmlrpc_c::method { public: Text_add_tx() { _signature = "n:s"; _help = "Adds a string to the TX text widget."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; LOG_INFO("[%s] Text.add_tx: %s", XmlRpc::client_id.c_str(), std::string(params.getString(0)).c_str()); REQ_SYNC(&FTextTX::add_text, TransmitText, params.getString(0)); *retval = xmlrpc_c::value_nil(); } }; class Text_add_tx_bytes : public xmlrpc_c::method { public: Text_add_tx_bytes() { _signature = "n:6"; _help = "Adds a byte string to the TX text widget."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; std::vector<unsigned char> bytes = params.getBytestring(0); bytes.push_back(0); LOG_INFO("[%s] Text.add_tx_bytes: %s", XmlRpc::client_id.c_str(), std::string((const char*)&bytes[0]).c_str()); REQ_SYNC(&FTextTX::add_text, TransmitText, std::string((const char*)&bytes[0])); *retval = xmlrpc_c::value_nil(); } }; class Text_clear_tx : public xmlrpc_c::method { public: Text_clear_tx() { _signature = "n:n"; _help = "Clears the TX text widget."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; REQ(&FTextBase::clear, TransmitText); LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "Text.clear_tx"); *retval = xmlrpc_c::value_nil(); } }; // ============================================================================= class RXTX_get_data : public xmlrpc_c::method { public: RXTX_get_data() { _signature = "6:n"; _help = "Returns all RXTX combined data since last query."; } static void get_rxtx(char **text, int *size) { // the get* methods may throw but this function is not allowed to do so *text = get_rxtx_data(); *size = strlen(*text); } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; char *text; int size; REQ_SYNC(get_rxtx, &text, &size); std::vector<unsigned char> bytes; if (size) { bytes.resize(size, 0); memcpy(&bytes[0], text, size); } LOG_INFO("[%s] RXTX.get_data: %s", XmlRpc::client_id.c_str(), text); *retval = xmlrpc_c::value_bytestring(bytes); } }; // ============================================================================= class RX_get_data : public xmlrpc_c::method { public: RX_get_data() { _signature = "6:n"; _help = "Returns all RX data received since last query."; } static void get_rx(char **text, int *size) { // the get* methods may throw but this function is not allowed to do so *text = get_rx_data(); *size = strlen(*text); } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; char *text; int size; REQ_SYNC(get_rx, &text, &size); std::vector<unsigned char> bytes; if (size) { bytes.resize(size, 0); memcpy(&bytes[0], text, size); } LOG_INFO("[%s] RX.get_data: %s", XmlRpc::client_id.c_str(), text); *retval = xmlrpc_c::value_bytestring(bytes); } }; // ============================================================================= class TX_get_data : public xmlrpc_c::method { public: TX_get_data() { _signature = "6:n"; _help = "Returns all TX data transmitted since last query."; } static void get_tx(char **text, int *size) { // the get* methods may throw but this function is not allowed to do so *text = get_tx_data(); *size = strlen(*text); } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; char *text; int size; REQ_SYNC(get_tx, &text, &size); std::vector<unsigned char> bytes; if (size) { bytes.resize(size, 0); memcpy(&bytes[0], text, size); } LOG_INFO("[%s] TX.get_data: %s", XmlRpc::client_id.c_str(), text); *retval = xmlrpc_c::value_bytestring(bytes); } }; // ============================================================================= class Spot_get_auto : public xmlrpc_c::method { public: Spot_get_auto() { _signature = "b:n"; _help = "Returns the autospotter state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { LOG_INFO("[%s] Spot.get_auto: %s", XmlRpc::client_id.c_str(), (btnAutoSpot->value() ? "ON" : "OFF")); *retval = xmlrpc_c::value_boolean(btnAutoSpot->value()); } }; class Spot_set_auto : public xmlrpc_c::method { public: Spot_set_auto() { _signature = "b:b"; _help = "Sets the autospotter state. Returns the old state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = btnAutoSpot->value(); REQ(set_button, (Fl_Button *) btnAutoSpot, params.getBoolean(0)); LOG_INFO("[%s] Spot.set_auto: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); *retval = xmlrpc_c::value_boolean(v); } }; class Spot_toggle_auto : public xmlrpc_c::method { public: Spot_toggle_auto() { _signature = "b:n"; _help = "Toggles the autospotter state. Returns the new state."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { XMLRPC_LOCK; bool v = !btnAutoSpot->value(); LOG_INFO("[%s] Spot.toggle_auto: %s", XmlRpc::client_id.c_str(), (v ? "ON" : "OFF")); REQ(set_button, (Fl_Button *) btnAutoSpot, v); *retval = xmlrpc_c::value_boolean(v); } }; class Spot_pskrep_get_count : public xmlrpc_c::method { public: Spot_pskrep_get_count() { _signature = "i:n"; _help = "Returns the number of callsigns spotted in the current session."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) { int cnt = static_cast<int>(pskrep_count()); LOG_INFO("[%s] Spot.pskrep_get_count: %d", XmlRpc::client_id.c_str(), cnt); *retval = xmlrpc_c::value_int(cnt); } }; // ============================================================================= // Returns the current wefax modem pointer. static wefax * get_wefax(void) { if( ( active_modem->get_mode() >= MODE_WEFAX_FIRST ) && ( active_modem->get_mode() <= MODE_WEFAX_LAST ) ) { wefax * ptr = dynamic_cast<wefax *>( active_modem ); if( ptr == NULL ) throw std::runtime_error("Inconsistent wefax object"); return ptr ; } throw std::runtime_error("Not in wefax mode"); return (wefax *)0; } struct Wefax_state_string : public xmlrpc_c::method { Wefax_state_string() { _signature = "s:n"; _help = "Returns Wefax engine state (tx and rx) for information."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) try { std::string wfs = get_wefax()->state_string(); LOG_INFO("[%s] wefax.state_string: %s", XmlRpc::client_id.c_str(), wfs.c_str()); *retval = xmlrpc_c::value_string( wfs.c_str() ); } catch( const std::exception & e ) { LOG_ERROR("[%s] wefax.state_string: %s", XmlRpc::client_id.c_str(), e.what()); *retval = xmlrpc_c::value_string( e.what()); } }; struct Wefax_skip_apt : public xmlrpc_c::method { Wefax_skip_apt() { _signature = "s:n"; _help = "Skip APT during Wefax reception"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) try { get_wefax()->skip_apt(); LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "wefax.skip_apt"); *retval = xmlrpc_c::value_string( "" ); } catch( const std::exception & e ) { LOG_ERROR("[%s] wefax.skip_apt: %s", XmlRpc::client_id.c_str(), e.what()); *retval = xmlrpc_c::value_string( e.what() ); } }; /// TODO: Refresh the screen with the new value. struct Wefax_skip_phasing : public xmlrpc_c::method { Wefax_skip_phasing() { _signature = "s:n"; _help = "Skip phasing during Wefax reception"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) try { get_wefax()->skip_phasing(true); LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "wefax.skip_phasing"); *retval = xmlrpc_c::value_string( "" ); } catch( const std::exception & e ) { LOG_ERROR("[%s] wefax.skip_phasing: %s", XmlRpc::client_id.c_str(), e.what()); *retval = xmlrpc_c::value_string( e.what() ); } }; // TODO: The image should be reloaded just like cancelling from the GUI. struct Wefax_set_tx_abort_flag : public xmlrpc_c::method { Wefax_set_tx_abort_flag() { _signature = "s:n"; _help = "Cancels Wefax image transmission"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) try { get_wefax()->set_tx_abort_flag(); LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "wefax.set_tx_abort_flag"); *retval = xmlrpc_c::value_string( "" ); } catch( const std::exception & e ) { LOG_ERROR("[%s] wefax.set_tx_abort_flag: %s", XmlRpc::client_id.c_str(), e.what()); *retval = xmlrpc_c::value_string( e.what() ); } }; struct Wefax_end_reception : public xmlrpc_c::method { Wefax_end_reception() { _signature = "s:n"; _help = "End Wefax image reception"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) try { get_wefax()->end_reception(); LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "wefax.end_reception"); *retval = xmlrpc_c::value_string( "" ); } catch( const std::exception & e ) { LOG_ERROR("[%s] wefax.end_reception: %s", XmlRpc::client_id.c_str(), e.what()); *retval = xmlrpc_c::value_string( e.what() ); } }; struct Wefax_start_manual_reception : public xmlrpc_c::method { Wefax_start_manual_reception() { _signature = "s:n"; _help = "Starts fax image reception in manual mode"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) try { get_wefax()->set_rx_manual_mode(true); get_wefax()->skip_apt(); get_wefax()->skip_phasing(true); LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "wefax.start_manual_reception"); *retval = xmlrpc_c::value_string( "" ); } catch( const std::exception & e ) { LOG_ERROR("[%s] wefax.start_manual_reception: %s", XmlRpc::client_id.c_str(), e.what()); *retval = xmlrpc_c::value_string( e.what() ); } }; struct Wefax_set_adif_log : public xmlrpc_c::method { Wefax_set_adif_log() { _signature = "s:b"; _help = "Set/reset logging to received/transmit images to ADIF log file"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) try { progdefaults.WEFAX_AdifLog = params.getBoolean(0); LOG_INFO("[%s] %s", XmlRpc::client_id.c_str(), "wefax.set_adif_log"); *retval = xmlrpc_c::value_string( "" ); } catch( const std::exception & e ) { LOG_ERROR("[%s] wefax.set_adif_log: %s", XmlRpc::client_id.c_str(), e.what()); *retval = xmlrpc_c::value_string( e.what() ); } }; struct Wefax_set_max_lines : public xmlrpc_c::method { Wefax_set_max_lines() { _signature = "s:i"; _help = "Set maximum lines for fax image reception"; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) try { progdefaults.WEFAX_MaxRows = params.getInt(0); /// This updates the GUI. LOG_INFO("[%s] wefax.set_max_lines: %d", XmlRpc::client_id.c_str(), progdefaults.WEFAX_MaxRows); *retval = xmlrpc_c::value_string( "" ); } catch( const std::exception & e ) { LOG_ERROR("[%s] wefax.set_max_lines: %s", XmlRpc::client_id.c_str(), e.what()); *retval = xmlrpc_c::value_string( e.what() ); } }; struct Wefax_get_received_file : public xmlrpc_c::method { Wefax_get_received_file() { _signature = "s:i"; _help = "Waits for next received fax file, returns its name with a delay. Empty string if timeout."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) try { std::string filename = get_wefax()->get_received_file( params.getInt(0)); LOG_INFO("[%s] wefax.get_received_file: %s", XmlRpc::client_id.c_str(), filename.c_str()); *retval = xmlrpc_c::value_string( filename ); } catch( const std::exception & e ) { LOG_ERROR("[%s] wefax.get_received_file: %s", XmlRpc::client_id.c_str(), e.what()); *retval = xmlrpc_c::value_string( e.what() ); } }; struct Wefax_send_file : public xmlrpc_c::method { Wefax_send_file() { _signature = "s:si"; _help = "Send file. returns an empty string if OK otherwise an error message."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) try { std::string status = get_wefax()->send_file( params.getString(0), params.getInt(1) ); LOG_INFO("[%s] wefax.send_file: %s", XmlRpc::client_id.c_str(), status.c_str()); *retval = xmlrpc_c::value_string( status ); } catch( const std::exception & e ) { LOG_ERROR("[%s] wefax.send_file: %s", XmlRpc::client_id.c_str(), e.what()); *retval = xmlrpc_c::value_string( e.what() ); } }; // ============================================================================= // Returns the current navtex modem pointer. static navtex * get_navtex(void) { if( ( active_modem->get_mode() != MODE_NAVTEX ) && ( active_modem->get_mode() != MODE_SITORB ) ) { navtex * ptr = dynamic_cast<navtex *>( active_modem ); if( ptr == NULL ) throw std::runtime_error("Inconsistent navtex object"); return ptr ; } throw std::runtime_error("Not in navtex or sitorB mode"); return (navtex *)0; } struct Navtex_get_message : public xmlrpc_c::method { Navtex_get_message() { _signature = "s:i"; _help = "Returns next Navtex/SitorB message with a max delay in seconds.. Empty string if timeout."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) try { LOG_INFO("[%s] navtex.get_message: %s", XmlRpc::client_id.c_str(), std::string( get_navtex()->get_message( params.getInt(0))).c_str()); *retval = xmlrpc_c::value_string( get_navtex()->get_message( params.getInt(0)) ); } catch( const std::exception & e ) { LOG_ERROR("[%s] navtex.get_message: %s", XmlRpc::client_id.c_str(), e.what()); *retval = xmlrpc_c::value_string( e.what()); } }; struct Navtex_send_message : public xmlrpc_c::method { Navtex_send_message() { _signature = "s:s"; _help = "Send a Navtex/SitorB message. Returns an empty string if OK otherwise an error message."; } void execute(const xmlrpc_c::paramList& params, xmlrpc_c::value* retval) try { std::string status = get_navtex()->send_message( params.getString(0) ); LOG_INFO("[%s] navtex.send_message: %s", XmlRpc::client_id.c_str(), status.c_str()); *retval = xmlrpc_c::value_string( status ); } catch( const std::exception & e ) { LOG_ERROR("[%s] navtex.send_message: %s", XmlRpc::client_id.c_str(), e.what()); *retval = xmlrpc_c::value_string( e.what() ); } }; // ============================================================================= // End XML-RPC interface // method list: ELEM_(class_name, "method_name") #undef ELEM_ #define METHOD_LIST \ ELEM_(Fldigi_list, "fldigi.list") \ ELEM_(Fldigi_name, "fldigi.name") \ ELEM_(Fldigi_version_struct, "fldigi.version_struct") \ ELEM_(Fldigi_version_string, "fldigi.version") \ ELEM_(Fldigi_name_version, "fldigi.name_version") \ ELEM_(Fldigi_config_dir, "fldigi.config_dir") \ ELEM_(Fldigi_terminate, "fldigi.terminate") \ \ ELEM_(Modem_get_mode, "modem.get_mode") \ ELEM_(Modem_get_submode, "modem.get_submode") \ ELEM_(Modem_get_name, "modem.get_name") \ ELEM_(Modem_get_names, "modem.get_names") \ ELEM_(Modem_get_id, "modem.get_id") \ ELEM_(Modem_get_max_id, "modem.get_max_id") \ ELEM_(Modem_set_by_name, "modem.set_by_name") \ ELEM_(Modem_set_by_id, "modem.set_by_id") \ \ ELEM_(Modem_set_carrier, "modem.set_carrier") \ ELEM_(Modem_inc_carrier, "modem.inc_carrier") \ ELEM_(Modem_get_carrier, "modem.get_carrier") \ \ ELEM_(Modem_get_afc_sr, "modem.get_afc_search_range") \ ELEM_(Modem_set_afc_sr, "modem.set_afc_search_range") \ ELEM_(Modem_inc_afc_sr, "modem.inc_afc_search_range") \ \ ELEM_(Modem_get_bw, "modem.get_bandwidth") \ ELEM_(Modem_set_bw, "modem.set_bandwidth") \ ELEM_(Modem_inc_bw, "modem.inc_bandwidth") \ \ ELEM_(Modem_get_quality, "modem.get_quality") \ ELEM_(Modem_search_up, "modem.search_up") \ ELEM_(Modem_search_down, "modem.search_down") \ \ ELEM_(Modem_olivia_set_bandwidth, "modem.olivia.set_bandwidth") \ ELEM_(Modem_olivia_get_bandwidth, "modem.olivia.get_bandwidth") \ ELEM_(Modem_olivia_set_tones, "modem.olivia.set_tones") \ ELEM_(Modem_olivia_get_tones, "modem.olivia.get_tones") \ \ ELEM_(Main_get_status1, "main.get_status1") \ ELEM_(Main_get_status2, "main.get_status2") \ \ ELEM_(Main_get_sb, "main.get_sideband") \ ELEM_(Main_set_sb, "main.set_sideband") \ ELEM_(Main_get_wf_sideband, "main.get_wf_sideband") \ ELEM_(Main_set_wf_sideband, "main.set_wf_sideband") \ ELEM_(Main_get_freq, "main.get_frequency") \ ELEM_(Main_set_freq, "main.set_frequency") \ ELEM_(Main_inc_freq, "main.inc_frequency") \ \ ELEM_(Main_get_afc, "main.get_afc") \ ELEM_(Main_set_afc, "main.set_afc") \ ELEM_(Main_toggle_afc, "main.toggle_afc") \ \ ELEM_(Main_get_sql, "main.get_squelch") \ ELEM_(Main_set_sql, "main.set_squelch") \ ELEM_(Main_toggle_sql, "main.toggle_squelch") \ \ ELEM_(Main_get_sql_level, "main.get_squelch_level") \ ELEM_(Main_set_sql_level, "main.set_squelch_level") \ ELEM_(Main_inc_sql_level, "main.inc_squelch_level") \ \ ELEM_(Main_get_rev, "main.get_reverse") \ ELEM_(Main_set_rev, "main.set_reverse") \ ELEM_(Main_toggle_rev, "main.toggle_reverse") \ \ ELEM_(Main_get_lock, "main.get_lock") \ ELEM_(Main_set_lock, "main.set_lock") \ ELEM_(Main_toggle_lock, "main.toggle_lock") \ \ ELEM_(Main_get_txid, "main.get_txid") \ ELEM_(Main_set_txid, "main.set_txid") \ ELEM_(Main_toggle_txid, "main.toggle_txid") \ \ ELEM_(Main_get_rsid, "main.get_rsid") \ ELEM_(Main_set_rsid, "main.set_rsid") \ ELEM_(Main_toggle_rsid, "main.toggle_rsid") \ \ ELEM_(Main_get_trx_status, "main.get_trx_status") \ ELEM_(Main_tx, "main.tx") \ ELEM_(Main_tune, "main.tune") \ ELEM_(Main_rsid, "main.rsid") \ ELEM_(Main_rx, "main.rx") \ ELEM_(Main_rx_tx, "main.rx_tx") \ ELEM_(Main_rx_only, "main.rx_only") \ ELEM_(Main_abort, "main.abort") \ \ ELEM_(Main_get_trx_state, "main.get_trx_state") \ ELEM_(Main_get_tx_timing, "main.get_tx_timing") \ ELEM_(Main_get_char_rates, "main.get_char_rates") \ ELEM_(Main_get_char_timing, "main.get_char_timing") \ ELEM_(Main_set_rig_name, "main.set_rig_name") \ ELEM_(Main_set_rig_frequency, "main.set_rig_frequency") \ ELEM_(Main_set_rig_modes, "main.set_rig_modes") \ ELEM_(Main_set_rig_mode, "main.set_rig_mode") \ ELEM_(Main_get_rig_modes, "main.get_rig_modes") \ ELEM_(Main_get_rig_mode, "main.get_rig_mode") \ ELEM_(Main_set_rig_bandwidths, "main.set_rig_bandwidths") \ ELEM_(Main_set_rig_bandwidth, "main.set_rig_bandwidth") \ ELEM_(Main_get_rig_bandwidth, "main.get_rig_bandwidth") \ ELEM_(Main_get_rig_bandwidths, "main.get_rig_bandwidths") \ \ ELEM_(Main_run_macro, "main.run_macro") \ ELEM_(Main_get_max_macro_id, "main.get_max_macro_id") \ \ ELEM_(Rig_set_name, "rig.set_name") \ ELEM_(Rig_get_name, "rig.get_name") \ ELEM_(Rig_set_frequency, "rig.set_frequency") \ ELEM_(Rig_set_smeter, "rig.set_smeter") \ ELEM_(Rig_set_pwrmeter, "rig.set_pwrmeter") \ ELEM_(Rig_set_modes, "rig.set_modes") \ ELEM_(Rig_set_mode, "rig.set_mode") \ ELEM_(Rig_get_modes, "rig.get_modes") \ ELEM_(Rig_get_mode, "rig.get_mode") \ ELEM_(Rig_set_bandwidths, "rig.set_bandwidths") \ ELEM_(Rig_set_bandwidth, "rig.set_bandwidth") \ ELEM_(Rig_get_freq, "rig.get_frequency") \ ELEM_(Rig_get_bandwidth, "rig.get_bandwidth") \ ELEM_(Rig_get_bandwidths, "rig.get_bandwidths") \ ELEM_(Rig_get_notch, "rig.get_notch") \ ELEM_(Rig_set_notch, "rig.set_notch") \ ELEM_(Rig_enable_qsy, "rig.enable_qsy") \ \ ELEM_(Log_get_freq, "log.get_frequency") \ ELEM_(Log_get_time_on, "log.get_time_on") \ ELEM_(Log_get_time_off, "log.get_time_off") \ ELEM_(Log_get_date_on, "log.get_date_on") \ ELEM_(Log_get_date_off, "log.get_date_off") \ ELEM_(Log_get_call, "log.get_call") \ ELEM_(Log_get_name, "log.get_name") \ ELEM_(Log_get_rst_in, "log.get_rst_in") \ ELEM_(Log_get_rst_out, "log.get_rst_out") \ ELEM_(Log_set_rst_in, "log.set_rst_in") \ ELEM_(Log_set_rst_out, "log.set_rst_out") \ ELEM_(Log_get_serial_number, "log.get_serial_number") \ ELEM_(Log_set_serial_number, "log.set_serial_number") \ ELEM_(Log_get_serial_number_sent, "log.get_serial_number_sent") \ ELEM_(Log_get_exchange, "log.get_exchange") \ ELEM_(Log_set_exchange, "log.set_exchange") \ ELEM_(Log_get_state, "log.get_state") \ ELEM_(Log_get_province, "log.get_province") \ ELEM_(Log_get_country, "log.get_country") \ ELEM_(Log_get_qth, "log.get_qth") \ ELEM_(Log_get_band, "log.get_band") \ ELEM_(Log_get_sb, "log.get_sideband") \ ELEM_(Log_get_notes, "log.get_notes") \ ELEM_(Log_get_locator, "log.get_locator") \ ELEM_(Log_get_az, "log.get_az") \ \ ELEM_(Log_clear, "log.clear") \ ELEM_(Log_set_call, "log.set_call") \ ELEM_(Log_set_name, "log.set_name") \ ELEM_(Log_set_qth, "log.set_qth") \ ELEM_(Log_set_locator, "log.set_locator") \ ELEM_(Log_set_rst_in, "log.set_rst_in") \ ELEM_(Log_set_rst_out, "log.set_rst_out") \ \ ELEM_(Logbook_last_record, "logbook.last_record") \ ELEM_(Logbook_all_records, "logbook.all_records") \ \ ELEM_(Main_flmsg_online, "main.flmsg_online") \ ELEM_(Main_flmsg_available, "main.flmsg_available") \ ELEM_(Main_flmsg_transfer, "main.flmsg_transfer") \ ELEM_(Main_flmsg_squelch, "main.flmsg_squelch") \ \ ELEM_(flmsg_online, "flmsg.online") \ ELEM_(flmsg_available, "flmsg.available") \ ELEM_(flmsg_transfer, "flmsg.transfer") \ ELEM_(flmsg_squelch, "flmsg.squelch") \ ELEM_(flmsg_get_data, "flmsg.get_data") \ \ ELEM_(Io_in_use, "io.in_use") \ ELEM_(Io_enable_kiss, "io.enable_kiss") \ ELEM_(Io_enable_arq, "io.enable_arq") \ \ ELEM_(Text_get_rx_length, "text.get_rx_length") \ ELEM_(Text_get_rx, "text.get_rx") \ ELEM_(Text_clear_rx, "text.clear_rx") \ ELEM_(Text_add_tx, "text.add_tx") \ ELEM_(Text_add_tx_queu, "text.add_tx_queu") \ ELEM_(Text_add_tx_bytes, "text.add_tx_bytes") \ ELEM_(Text_clear_tx, "text.clear_tx") \ \ ELEM_(RXTX_get_data, "rxtx.get_data") \ ELEM_(RX_get_data, "rx.get_data") \ ELEM_(TX_get_data, "tx.get_data") \ \ ELEM_(Spot_get_auto, "spot.get_auto") \ ELEM_(Spot_set_auto, "spot.set_auto") \ ELEM_(Spot_toggle_auto, "spot.toggle_auto") \ ELEM_(Spot_pskrep_get_count, "spot.pskrep.get_count") \ \ ELEM_(Wefax_state_string, "wefax.state_string") \ ELEM_(Wefax_skip_apt, "wefax.skip_apt") \ ELEM_(Wefax_skip_phasing, "wefax.skip_phasing") \ ELEM_(Wefax_set_tx_abort_flag, "wefax.set_tx_abort_flag") \ ELEM_(Wefax_end_reception, "wefax.end_reception") \ ELEM_(Wefax_start_manual_reception, "wefax.start_manual_reception") \ ELEM_(Wefax_set_adif_log, "wefax.set_adif_log") \ ELEM_(Wefax_set_max_lines, "wefax.set_max_lines") \ ELEM_(Wefax_get_received_file, "wefax.get_received_file") \ ELEM_(Wefax_send_file, "wefax.send_file") \ \ ELEM_(Navtex_get_message, "navtex.get_message") \ ELEM_(Navtex_send_message, "navtex.send_message") \ struct rm_pred { re_t filter; bool allow; rm_pred(const char* re, bool allow_) : filter(re, REG_EXTENDED | REG_NOSUB), allow(allow_) { } bool operator()(const methods_t::value_type& v) { return filter.match(v.name) ^ allow && !strstr(v.name, "fldigi."); } }; void XML_RPC_Server::add_methods(void) { if (methods) return; #undef ELEM_ #define ELEM_(class_, name_) { RpcBuilder<class_>::factory, NULL, name_ }, rpc_method m[] = { METHOD_LIST }; methods = new methods_t(m, m + sizeof(m)/sizeof(*m)); if (!progdefaults.xmlrpc_deny.empty()) methods->remove_if(rm_pred(progdefaults.xmlrpc_deny.c_str(), false)); else if (!progdefaults.xmlrpc_allow.empty()) methods->remove_if(rm_pred(progdefaults.xmlrpc_allow.c_str(), true)); methods_t::iterator it = methods->begin(); methods_t::iterator en = methods->end(); for( ; it != en; ++it ) { XmlRpcServerMethod * mth = it->m_fact( it->name ); it->method = dynamic_cast< xmlrpc_c::method * >( mth ); } }
112,768
C++
.cxx
4,026
25.595132
118
0.616494
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,225
network.cxx
w1hkj_fldigi/src/network/network.cxx
// ---------------------------------------------------------------------------- // network.cxx // // Copyright (C) 2008...2019 // David Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <unistd.h> #include <sys/time.h> #include <cmath> #include <string> #include <sstream> #include <errno.h> #include <pthread.h> #include <time.h> #include <FL/Fl.H> #include <FL/Fl_Window.H> #include "socket.h" #include "timeops.h" #include "gettext.h" #include "debug.h" #include "main.h" #include "network.h" #include "socket.h" #include "fl_digi.h" //---------------------------------------------------------------------- // //---------------------------------------------------------------------- static void my_debug( void *ctx, int level, const char *file, int line, const char *str ) { ((void) level); fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); fflush( (FILE *) ctx ); } std::string stripped(std::string s) { while (s[0] == ' ') s.erase(0,1); while (s[s.length()-1] == ' ') s.erase(s.length() - 1); return s; } void Url::parse(std::string url) { _https = false; _host.clear(); _port.clear(); _request.clear(); _url = url; if (_url.find("https://") == 0) { _https = true; _url.erase(0,8); _port = "443"; } else if (url.find("http://") == 0) { _url.erase(0,7); _port = "80"; } size_t p = _url.find(":"); if (p != std::string::npos) { _port = _url.substr(p+1); _url.erase(p); } p = _url.find("/"); if (p != std::string::npos) { _host = _url.substr(0, p); _request = _url.substr(p); } else { _host = _url; } _host = stripped(_host); _url = stripped(url); _request = stripped(_request); if (debug_file) { debug_file << "parser:" << std::endl; debug_file << "url: " << url << std::endl; debug_file << "host: " << _host << std::endl; debug_file << "port: " << _port << std::endl; debug_file << "req: " << _request << std::endl; } } int Url::http_get(std::string &response) { std::ostringstream REQUEST; size_t len, rcvd; bool ret = true; const char service[] = "http"; REQUEST << "GET " << _request << " HTTP/1.1\r\n" << "User-Agent: fldigi " << FLDIGI_VERSION << "\r\n\ Host: " << _host << "\r\n\ Connection: close\r\n\r\n"; len = REQUEST.str().length(); if (debug_file) { debug_file << "Url::http_get(...)" << std::endl; debug_file << "Host: " << _host << std::endl; debug_file << "Service: " << service << std::endl; debug_file << "Request: " << REQUEST.str() << std::endl; } try { Address addr(_host.c_str(), service); Socket s(addr); // Socket s(Address(_host.c_str(), service)); s.connect(); s.set_nonblocking(); s.set_timeout(_timeout); if (s.send(REQUEST.str()) != len) { if (debug_file) debug_file << "send timed out: " << REQUEST.str() << std::endl; response = "Send timed out"; ret = false; goto recv_exit; } if (debug_file) debug_file << "sent: " << len << " bytes." << std::endl; int wait = 1; // allow up to 5 seconds to receive response while ((rcvd = s.recv(response)) == 0) { wait++; if (wait > 5) { if (debug_file) debug_file << "s.recv(...) failed after " << wait << " attempts" << std::endl; return false; } MilliSleep(100); } if (debug_file) debug_file << "s.recv(...) response required " << wait << " request" << (wait > 1 ? "s" : "") << std::endl; } catch (const SocketException& e) { response = e.what(); if (response.empty()) response = "UNKNOWN ERROR"; if (debug_file) { debug_file << "Caught socket exception: " << errno << ": " << response << std::endl; } ret = false; } if (debug_file) { debug_file << "s.recv(...) " << rcvd << " bytes." << std::endl; debug_file << "Response: " << response << std::endl; } recv_exit: return ret; } int Url::https_get(std::string &response) { int ret = 1, len; _err = MBEDTLS_EXIT_SUCCESS; std::ostringstream REQUEST; mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; mbedtls_ssl_context ssl; mbedtls_ssl_config conf; mbedtls_x509_crt cacert; #if defined(MBEDTLS_DEBUG_C) mbedtls_debug_set_threshold( 1 ); #endif /* * 0. Initialize the RNG and the session data */ mbedtls_net_init( &server_fd ); mbedtls_ssl_init( &ssl ); mbedtls_ssl_config_init( &conf ); mbedtls_x509_crt_init( &cacert ); mbedtls_ctr_drbg_init( &ctr_drbg ); if (debug_file) { debug_file << "\n . Seeding the random number generator..."; debug_file.flush(); } mbedtls_entropy_init( &entropy ); if ( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, (const unsigned char *)_pers.c_str(), _pers.length() ) ) != 0 ) { snprintf(err_string, sizeof(err_string), " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); _err = ret; goto exit; } if (debug_file) { debug_file << " ok\n"; } /* * 0. Initialize certificates */ if (debug_file) { debug_file << " . Loading the CA root certificate ..."; debug_file.flush(); } ca_crt_rsa[ca_crt_rsa_size - 1] = 0; ret = mbedtls_x509_crt_parse(&cacert, (uint8_t *)ca_crt_rsa, ca_crt_rsa_size); if( ret < 0 ) { snprintf(err_string, sizeof(err_string), " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); _err = ret; goto exit; } if (debug_file) { debug_file << " ok (" << ret << " skipped)\n"; } /* * 1. Start the connection */ if (debug_file) { debug_file << " . Connecting to tcp/" << _host << ":" << _port << "..."; debug_file.flush(); } if( ( ret = mbedtls_net_connect( &server_fd, _host.c_str(), _port.c_str(), MBEDTLS_NET_PROTO_TCP ) ) != 0 ) { snprintf(err_string, sizeof(err_string), " failed\n ! mbedtls_net_connect returned %d\n\n", ret ); _err = ret; goto exit; } if (debug_file) { debug_file << " ok\n"; } /* * 2. Setup stuff */ if (debug_file) { debug_file << " . Setting up the SSL/TLS structure..."; debug_file.flush(); } if( ( ret = mbedtls_ssl_config_defaults( &conf, MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) { snprintf(err_string, sizeof(err_string), " failed\n ! mbedtls_ssl_config_defaults returned %d\n\n", ret ); _err = ret; goto exit; } if (debug_file) { debug_file << " ok\n"; } /* * 3. More stuff */ /* OPTIONAL is not optimal for security, * but makes interop easier in this simplified example */ mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL ); mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL ); mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) { snprintf(err_string, sizeof(err_string), " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret ); _err = ret; goto exit; } if( ( ret = mbedtls_ssl_set_hostname( &ssl, _host.c_str() ) ) != 0 ) { snprintf(err_string, sizeof(err_string), " failed\n ! mbedtls_ssl_set_hostname returned %d\n\n", ret ); _err = ret; goto exit; } mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); /* * 4. Handshake */ if (debug_file) { debug_file << " . Performing the SSL/TLS handshake..."; debug_file.flush(); } while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) { if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) { snprintf(err_string, sizeof(err_string), " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret ); _err = ret; goto exit; } } if (debug_file) { debug_file << " ok\n"; } /* * 5. Verify the server certificate */ if (debug_file) { debug_file << " . Verifying peer X.509 certificate..."; } /* In real life, we probably want to bail out when ret != 0 */ if( ( flags = mbedtls_ssl_get_verify_result( &ssl ) ) != 0 ) { char vrfy_buf[512]; if (debug_file) { debug_file << " failed\n"; } mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags ); if (debug_file) { debug_file << vrfy_buf << std::endl; } } else if (debug_file) { debug_file << " ok\n"; } /* * 6. Write the GET request */ if (debug_file) { debug_file << " > Write to server:"; debug_file.flush(); } REQUEST << "GET " << _request << " HTTP/1.1\r\n"; REQUEST << "User-Agent: fldigi-" << FLDIGI_VERSION << "\r\n" << "Host: " << _host << ":" << _port << "\r\n" << "Content-Type: application/json; charset=utf-8\r\n" << "Connection: Keep-Alive\r\n\r\n"; len = REQUEST.str().length(); while( ( ret = mbedtls_ssl_write( &ssl, (const unsigned char *)REQUEST.str().c_str(), len ) ) <= 0 ) { if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) { snprintf(err_string, sizeof(err_string), " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); _err = ret; goto exit; } } len = ret; if (debug_file) { debug_file << len << " bytes written\n\"" << REQUEST.str() << "\""; debug_file.flush(); } /* * 7. Read the HTTP response */ if (debug_file) { debug_file << "\n < Read from server:"; debug_file.flush(); } do { len = sizeof( buf ) - 1; memset( buf, 0, sizeof( buf ) ); ret = mbedtls_ssl_read( &ssl, (unsigned char *)buf, len ); if( ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE ) { continue; } if( ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY ) { break; } if( ret < 0 ) { if (debug_file) { debug_file << "failed\n ! mbedtls_ssl_read returned " << ret << std::endl; } break; } if( ret == 0 ) { if (debug_file) { debug_file << "\n\nEOF\n\n"; } break; } len = ret; if (debug_file) { debug_file << len << " bytes read\n\n" << (char *) buf << std::endl; } _data.append(buf); break; } while( 1 ); mbedtls_ssl_close_notify( &ssl ); response = _data; _err = MBEDTLS_EXIT_SUCCESS; exit: #ifdef MBEDTLS_ERROR_C if( _err != MBEDTLS_EXIT_SUCCESS ) { char error_buf[100]; mbedtls_strerror( _err, error_buf, 100 ); snprintf(err_string, sizeof(err_string), "Last error was: %d - %s\n\n", _err, error_buf ); } #endif mbedtls_net_free( &server_fd ); mbedtls_x509_crt_free( &cacert ); mbedtls_ssl_free( &ssl ); mbedtls_ssl_config_free( &conf ); mbedtls_ctr_drbg_free( &ctr_drbg ); mbedtls_entropy_free( &entropy ); return( _err ); } int Url::get(std::string url, std::string &response) { if (url.empty()) return -1; parse(url); int ret = 0; if (_https) ret = https_get(response); else ret = http_get(response); return ret; } int Url::_rotate_log = 0; void Url::debug() { std::string fname = DebugDir; fname.append("network_debug.txt"); if (!_rotate_log) { rotate_log(fname); _rotate_log = 1; } debug_file.open(fname.c_str(), std::ios::app); } bool get_http(const std::string& url, std::string& reply, double timeout) { Url target_url; target_url.timeout(timeout); return target_url.get(url, reply); }
11,767
C++
.cxx
431
24.649652
110
0.601951
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,226
weather.cxx
w1hkj_fldigi/src/network/weather.cxx
// ---------------------------------------------------------------------------- // weather.cxx -- a part of fldigi // // Copyright (C) 2012 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #ifdef __MINGW32__ # include "compat.h" #endif #include <sys/time.h> #include "signal.h" #include <string> #include <iostream> #include <cstring> #include <cmath> #include <cctype> #include "threads.h" #include "misc.h" #include "configuration.h" #include "main.h" #include "confdialog.h" #include "fl_digi.h" #include "trx.h" #include "xmlreader.h" #include "qrunner.h" #include "debug.h" #include "network.h" #include "weather.h" #include "metar.h" void getwx(std::string& wx, std::string wxsta) { std::string metar; if (wxsta.empty()) metar = progdefaults.wx_sta; else metar = wxsta; for (size_t n = 0; n < metar.length(); n++) metar[n] = toupper(metar[n]); Metar local_wx; local_wx.params( progdefaults.wx_inches, progdefaults.wx_mbars, progdefaults.wx_fahrenheit, progdefaults.wx_celsius, progdefaults.wx_mph, progdefaults.wx_kph, progdefaults.wx_condx, progdefaults.wx_station_name); local_wx.debug(true); if (local_wx.get(metar) == 0) { if (progdefaults.wx_full) { wx = local_wx.full(); return; } wx = local_wx.parsed(); } else wx.clear(); return; } void get_METAR_station() { cb_mnuVisitURL(0, (void*)std::string("http://www.rap.ucar.edu/weather/surface/stations.txt").c_str()); }
2,181
C++
.cxx
74
27.648649
103
0.669378
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,228
metar.cxx
w1hkj_fldigi/src/network/metar.cxx
// ---------------------------------------------------------------------------- // metar.cxx // // Copyright (C) 2019 // David Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include "metar.h" /*====================================================================== * * WEATHER The weather group * iiddppooxx * ii is intensity group * ii Description * - light * moderate * + heavy * VC in the vicinity * * dd is the descriptor group * dd Description * MI shallow * PR partial * BC patches * DR low drifting * BL blowing * SH shower * TS thunderstorm * FZ freezing * * pp is the precipitation group * pp Description * DZ drizzle * RA rain * SN snow * SG snow grains * IC ice crystals * PE ice pellets * GR hail * GS small hail/snow pellets * UP unknown * * oo is the obscuration group * oo Description * BR mist * FG fog * FU smoke * VA volcanic ash * DU dust * SA sand * HZ haze * PY spray * * xx is the misc group * xx Description * PO dust whirls * SQ squalls * FC funnel cloud/tornado/waterspout * SS duststorm * * CLOUDS * The cloud levels * ccchhhtt * ccc is the coverage * CLR or SKC = clear * FEW = 1/8 coverage * SCT = 2,3,4/8 coverage * BKN = 5,6,7/8 coverage * OVC = overcast * VV = vertical visibility for obscuration * hhh is the height of base in 30m or 100ft increments. ie 30 = 3000 feet * tt is an optional type * CU = cumulus * CB = cumulonumbus * TCU = towering cumulus * CI = cirrus */ struct wxpairs {const char *grp; const char *name;}; static wxpairs precip[] = { {"DZ", "drizzle"}, {"RA", "rain"}, {"SN", "snow"}, {"SG", "snow grains"}, {"IC", "ice crystals"}, {"PE", "ice pellets"}, {"GR", "hail"}, {"GS", "small hail / show pellets"}, {"UP", "unknown"}, {NULL, NULL} }; static wxpairs intensity[] = { {"-", "light"}, {"+", "heavy"}, {"VC", "in the vicinity"}, {NULL, NULL} }; static wxpairs descriptor[] = { {"MI", "shallow "}, {"PR", "partial"}, {"BC", "patches"}, {"DR", "low drifting"}, {"BL", "blowing"}, {"SH", "shower"}, {"TS", "thunderstorm"}, {"FZ", "freezing"}, {NULL, NULL} }; static wxpairs obscure[] = { {"BR", "mist"}, {"FG", "fog"}, {"FU", "smoke"}, {"VA", "volcanic ash"}, {"DU", "dust"}, {"SA", "sand"}, {"HZ", "haze"}, {"PY", "spray"}, {NULL, NULL} }; static wxpairs misc[] = { {"PO", "dust whirls"}, {"SQ", "squalls"}, {"FC", "funnel cloud/tornado/waterspout"}, {"SS", "duststorm"}, {NULL, NULL} }; static wxpairs clouds[] = { {"CLR", "clear skies"}, {"SKC", "clear skies"}, {"FEW", "few clouds"}, {"SCT", "scattered clouds"}, {"BKN", "broken cloud cover"}, {"OVC", "overcast"}, {NULL, NULL} }; static wxpairs cloud_type[] = { {"CU", "cumulus"}, {"CB", "cumulonumbus"}, {"TCU", "towering cumulus"}, {"CI", "cirrus"}, {NULL, NULL} }; void Metar::parse() { size_t p, p1, p2, p3; p = _metar_text.find(_metar_station); if (p == std::string::npos) { _wx_text_full.assign(_metar_station).append(" not found in url response!"); _wx_text_full.append("\n").append(_metar_text).append("\n"); return; } const char *cl = "Content-Length:"; int content_length; p1 = _metar_text.find(cl); if (p1 != std::string::npos) { content_length = atol(&_metar_text[p1 + strlen(cl)]); _metar_text.erase(0, _metar_text.length() - content_length); } else { p2 = _metar_text.find("("); if (p2 != std::string::npos) { p3 = _metar_text.rfind("\n", p2); if (p3 != std::string::npos) _metar_text.erase(0,p3 + 1); } else while ( (p2 = _metar_text.find("\r\n")) != std::string::npos) _metar_text.erase(0, p2 + 2); } p1 = _metar_text.find("\n"); _station_name = _metar_text.substr(0, p1); if ((p2 = _station_name.find("(")) != std::string::npos) _station_name.erase(p2 - 1); p3 = _metar_text.find("ob:"); if (p3 == std::string::npos) { _wx_text_full.assign(_metar_station).append(" observations not available"); _wx_text_parsed.assign(_wx_text_full); return; } _wx_text_full.assign(_metar_text.substr(0, p3)); p = _metar_text.find(_metar_station, p3 + 1); _metar_text.erase(0, p + 1 + _metar_station.length()); p = _metar_text.find("\n"); if (p != std::string::npos) _metar_text.erase(p); // parse field contents bool parsed = false; _conditions.clear(); while(_metar_text.length()) { // each ob: field is separated by a space or end of file parsed = false; p = _metar_text.find(" "); if (p != std::string::npos) { _field = _metar_text.substr(0, p); _metar_text.erase(0, p+1); } else { _field = _metar_text; _metar_text.clear(); } if (_field == "RMK") break; // parse for general weather // iiddppooxx if (_field == "AUTO") ; else if ((p = _field.rfind("KT")) != std::string::npos) { if (p == _field.length() - 2) { // wind dir / speed int knots; _winds.clear(); if (sscanf(_field.substr(3,2).c_str(), "%d", &knots) == 1) { _winds.append(_field.substr(0,3)).append(" at "); char ctemp[10]; if (_mph) { snprintf(ctemp, sizeof(ctemp), "%d mph ", (int)ceil(knots * 600.0 / 528.0 )); _winds.append(ctemp); } if (_kph) { snprintf(ctemp, sizeof(ctemp), "%d km/h ", (int)ceil(knots * 600.0 * 1.6094 / 528.0)); _winds.append(ctemp); } } } } else if ((p = _field.rfind("MPS")) != std::string::npos) { if (p == _field.length() - 3) { // wind dir / speed in meters / second int mps; _winds.clear(); if (sscanf(_field.substr(3,2).c_str(), "%d", &mps) == 1) { _winds.append(_field.substr(0,3)).append(" at "); char ctemp[10]; if (_mph) { snprintf(ctemp, sizeof(ctemp), "%d mph ", (int)ceil(mps * 2.2369)); _winds.append(ctemp); } if (_kph) { snprintf(ctemp, sizeof(ctemp), "%d km/h ", (int)ceil(mps * 3.6)); _winds.append(ctemp); } } } } else if ((p = _field.find("/") ) != std::string::npos) { // temperature / dewpoint std::string cent = _field.substr(0, p); if (cent[0] == 'M') cent[0] = '-'; int tempC, tempF; _temp.clear(); if (sscanf(cent.c_str(), "%d", &tempC) == 1) { tempF = (int)(tempC * 1.8 + 32); char ctemp[10]; if (_fahrenheit) { snprintf(ctemp, sizeof(ctemp), "%d F ", tempF); _temp.append(ctemp); } if (_celsius) { snprintf(ctemp, sizeof(ctemp), "%d C", tempC); _temp.append(ctemp); } } } else if ((_field[0] == 'A' && _field.length() == 5) || _field[0] == 'Q') { float inches; _baro.clear(); if (sscanf(_field.substr(1).c_str(), "%f", &inches) == 1) { if (_field[0] == 'A') inches /= 100.0; else inches /= 33.87; char ctemp[20]; if (_inches) { snprintf(ctemp, sizeof(ctemp), "%.2f in. Hg ", inches); _baro.append(ctemp); } if (_mbars) { snprintf(ctemp, sizeof(ctemp), "%.0f mbar", floor(inches * 33.87)); _baro.append(ctemp); } } } if (!parsed) { for (wxpairs *pp = precip; pp->grp != NULL; pp++) { if (_field.find(pp->grp) != std::string::npos) { // found a precip group wxpairs *ii, *dd, *oo, *xx; for (ii = intensity; ii->grp != NULL; ii++) if (_field.find(ii->grp) != std::string::npos) break; for (dd = descriptor; dd->grp != NULL; dd++) if (_field.find(dd->grp) != std::string::npos) break; for (oo = obscure; oo->grp != NULL; oo++) if (_field.find(oo->grp) != std::string::npos) break; for (xx = misc; xx->grp != NULL; xx++) if (_field.find(xx->grp) != std::string::npos) break; if (ii->grp != NULL) _conditions.append(ii->name).append(" "); if (dd->grp != NULL) _conditions.append(dd->name).append(" "); _conditions.append(pp->name); if (oo->grp != NULL) _conditions.append(", ").append(oo->name); if (xx->grp != NULL) _conditions.append(", ").append(xx->name); parsed = true; } } } if (!parsed) { wxpairs *oo; for (oo = obscure; oo->grp != NULL; oo++) if (_field.find(oo->grp) != std::string::npos) break; if (oo->grp != NULL) { _conditions.append(" ").append(oo->name); parsed = true; } } if (!parsed) { // parse for cloud cover // use only the first occurance of sky cover report; it is lowest altitude // cloud cover is reported multiple times for sounding stations for (wxpairs *cc = clouds; cc->grp != NULL; cc++) { if (_field.find(cc->grp) != std::string::npos) { if (_conditions.find(cc->name) != std::string::npos) break; if (_conditions.empty()) _conditions.append(cc->name); else _conditions.append(", ").append(cc->name); wxpairs *ct; for (ct = cloud_type; ct->grp != NULL; ct++) { if (_field.find(ct->grp) != std::string::npos) { if (ct->grp != NULL) _conditions.append(" ").append(ct->name); break; } } parsed = true; break; } } } } _wx_text_parsed.clear(); if (_name && !_station_name.empty()) { _wx_text_parsed.append("Loc: ").append(_station_name).append("\n"); } if (_condx && !_conditions.empty()) { _wx_text_parsed.append("Cond: ").append(_conditions).append("\n"); } if ((_mph || _kph) && !_winds.empty()){ _wx_text_parsed.append("Wind: ").append(_winds).append("\n"); } if ((_fahrenheit || _celsius) && !_temp.empty() ) { _wx_text_parsed.append("Temp: ").append(_temp).append("\n"); } if ((_inches || _mbars) && !_baro.empty()) { _wx_text_parsed.append("Baro: ").append(_baro).append("\n"); } return; } int Metar::get() { std::string metar_url = "https://tgftp.nws.noaa.gov/data/observations/metar/decoded/"; metar_url.append(_metar_station).append(".TXT"); int ret = url.get(metar_url, _metar_text); if (ret == 0) parse(); return ret; }
10,350
C++
.cxx
356
25.980337
92
0.583634
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,229
wefax_map.cxx
w1hkj_fldigi/src/wefax/wefax_map.cxx
// ---------------------------------------------------------------------------- // wefax_map.cxx rgb wefax_map viewer // // Copyright (C) 2006-2017 // Dave Freese, W1HKJ // Copyright (C) 2008-2009 // Stelios Bounanos, M0GLD // Copyright (C) 2010 // Remi Chateauneu, F4ECW // // This file is part of fldigi. // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 4 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #ifdef __MINGW32__ # include "compat.h" #endif #include <string> #include <sstream> #include <cmath> #include <cstdlib> #include <cstdio> #include <cstring> #include <algorithm> #include <time.h> #include <sys/stat.h> #include <sys/types.h> #include <FL/Fl.H> #include <FL/Fl_Box.H> #include <FL/fl_draw.H> #include <zlib.h> #include <png.h> #include "fl_digi.h" #include "trx.h" #include "wefax_map.h" #include "debug.h" #include "timeops.h" wefax_map::wefax_map (int X, int Y, int W, int H, int bg_col) : Fl_Widget (X, Y, W, H) { box(FL_FLAT_BOX); width = W; height = H; bufsize = W * H * depth; numcol = 0; slantdir = 0; vidbuf = new unsigned char[bufsize]; background = bg_col ; memset( vidbuf, background, bufsize ); zoom = 0 ; binary = false ; binary_threshold = 128 ; } wefax_map::~wefax_map() { if (vidbuf) delete [] vidbuf; } void wefax_map::video(unsigned char const *data, int len ) { if (len > bufsize) return; memcpy( vidbuf, data, len ); redraw(); } unsigned char wefax_map::pixel(int pos) { if (pos < 0 || pos >= bufsize) return 0; return vidbuf[pos]; } void wefax_map::clear() { memset(vidbuf, background, bufsize); redraw(); } void wefax_map::resize_zoom(int x, int y, int w, int h) { if( zoom < 0 ) { int stride = -zoom + 1 ; Fl_Widget::resize(x,y,w/stride,h/stride); } else if( zoom > 0 ) { int stride = zoom + 1 ; Fl_Widget::resize(x,y,w*stride,h*stride); } else { Fl_Widget::resize(x,y,w,h); } } void wefax_map::resize(int x, int y, int w, int h) { width = w; height = h; delete [] vidbuf; bufsize = depth * w * h; vidbuf = new unsigned char[bufsize]; memset( vidbuf, background, bufsize ); resize_zoom(x,y,w,h); } /// No data destruction. Used when the received image grows more than expected. /// Beware that this is not protected by a mutex. void wefax_map::resize_height(int new_height, bool clear_img) { int new_bufsize = width * new_height * depth; /// If the allocation fails, std::bad_alloc is thrown. unsigned char * new_vidbuf = new unsigned char[new_bufsize]; if( clear_img ) { /// Sets to zero the complete image. memset( new_vidbuf, background, new_bufsize ); } else { if( new_height <= height ) { memcpy( new_vidbuf, vidbuf, new_bufsize ); } else { memcpy( new_vidbuf, vidbuf, bufsize ); memset( new_vidbuf + bufsize, background, new_bufsize - bufsize ); } } delete [] vidbuf ; vidbuf = new_vidbuf ; bufsize = new_bufsize ; height = new_height; resize_zoom( x(), y(), width, height ); redraw(); } void wefax_map::stretch(double the_ratio) { /// We do not change the width but the height int new_height = height * the_ratio + 0.5 ; int new_bufsize = width * new_height * depth; /// If the allocation fails, std::bad_alloc is thrown. unsigned char * new_vidbuf = new unsigned char[new_bufsize]; /// No interpolation, it takes the nearest pixel. for( int ix_out = 0 ; ix_out < new_bufsize ; ix_out += depth ) { int ix_in = 0.5 + ( double )ix_out * the_ratio ; switch( ix_in % depth ) { case 1 : --ix_in ; break ; case 2 : ++ix_in ; break ; default: ; } if( ix_in >= bufsize ) { /// Grey value as a filler to indicate the end. For debugging. memset( new_vidbuf + ix_out, 128, new_bufsize - ix_out ); break ; } for( int i = 0; i < depth ; ++i ) { new_vidbuf[ ix_out + i ] = vidbuf[ ix_in + i ]; } }; delete [] vidbuf ; vidbuf = new_vidbuf ; bufsize = new_bufsize ; height = new_height; resize_zoom( x(), y(), width, height ); redraw(); } /// Change the horizontal center of the image by shifting the pixels. void wefax_map::shift_horizontal_center(int horizontal_shift) { /// This is a number of pixels. horizontal_shift *= depth ; if( horizontal_shift < -bufsize ) { horizontal_shift = -bufsize ; } if( horizontal_shift > 0 ) { /// Here we lose a couple of pixels at the end of the buffer /// if there is not a line enough. It should not be a lot. memmove( vidbuf + horizontal_shift, vidbuf, bufsize - horizontal_shift ); memset( vidbuf, background, horizontal_shift ); } else { /// Here, it is not necessary to reduce the buffer size. memmove( vidbuf, vidbuf - horizontal_shift, bufsize + horizontal_shift ); memset( vidbuf + bufsize + horizontal_shift, background, -horizontal_shift ); } redraw(); } void wefax_map::set_zoom( int the_zoom ) { zoom = the_zoom ; /// The size of the displayed bitmap is changed. resize_zoom( x(), y(), width, height ); } // in data user data passed to function // in x_screen,y_screen,wid_screen position and width of scan line in image // out buf buffer for generated image data. // Must copy wid_screen pixels from scanline y_screen, starting at pixel x_screen to this buffer. void wefax_map::draw_cb( void *data, int x_screen, int y_screen, int wid_screen, uchar * __restrict__ buf) { const wefax_map * __restrict__ ptr_pic = ( const wefax_map * ) data ; const int img_width = ptr_pic->width ; const unsigned char * __restrict__ in_ptr = ptr_pic->vidbuf ; /// One pixel out of (zoom+1) if( ptr_pic->zoom < 0 ) { const int stride = -ptr_pic->zoom + 1 ; const int in_offset = ( img_width * y_screen + x_screen ) * stride ; int dpth_in_offset = depth * in_offset ; if(ptr_pic->binary) { for( int ix_w = 0, max_w = wid_screen * depth; ix_w < max_w ; ix_w += depth ) { buf[ ix_w ] = ptr_pic->pix2bin(in_ptr[ dpth_in_offset ]); buf[ ix_w + 1 ] = ptr_pic->pix2bin(in_ptr[ dpth_in_offset + 1 ]); buf[ ix_w + 2 ] = ptr_pic->pix2bin(in_ptr[ dpth_in_offset + 2 ]); dpth_in_offset += depth * stride ; } } else { for( int ix_w = 0, max_w = wid_screen * depth; ix_w < max_w ; ix_w += depth ) { buf[ ix_w ] = in_ptr[ dpth_in_offset ]; buf[ ix_w + 1 ] = in_ptr[ dpth_in_offset + 1 ]; buf[ ix_w + 2 ] = in_ptr[ dpth_in_offset + 2 ]; dpth_in_offset += depth * stride ; } } return ; } /// Reads each input pixel (-zoom+1) times. if( ptr_pic->zoom > 0 ) { const int stride = ptr_pic->zoom + 1 ; const int in_offset = img_width * ( y_screen / stride ) + x_screen / stride ; #ifndef NDEBUG if( y_screen / stride >= ptr_pic->h() ) { LOG_ERROR( "Overflow2 y_screen=%d h=%d y_screen*stride=%d height=%d stride=%d\n", y_screen, ptr_pic->h(), (y_screen/stride), ptr_pic->height, stride ); return ; } #endif if(ptr_pic->binary) { for( int ix_w = 0, max_w = wid_screen * depth, dpth_in_offset = depth * in_offset ; ix_w < max_w ; ) { unsigned char in_dpth_in_offset_0 = ptr_pic->pix2bin(in_ptr[ dpth_in_offset ]); unsigned char in_dpth_in_offset_1 = ptr_pic->pix2bin(in_ptr[ dpth_in_offset + 1 ]); unsigned char in_dpth_in_offset_2 = ptr_pic->pix2bin(in_ptr[ dpth_in_offset + 2 ]); // Stride is less than 4 or 5. for( int j= 0; j < stride; j++, ix_w += depth ) { buf[ ix_w ] = in_dpth_in_offset_0; buf[ ix_w + 1 ] = in_dpth_in_offset_1; buf[ ix_w + 2 ] = in_dpth_in_offset_2; } dpth_in_offset += depth ; } } else { for( int ix_w = 0, max_w = wid_screen * depth, dpth_in_offset = depth * in_offset ; ix_w < max_w ; ) { unsigned char in_dpth_in_offset_0 = in_ptr[ dpth_in_offset ]; unsigned char in_dpth_in_offset_1 = in_ptr[ dpth_in_offset + 1 ]; unsigned char in_dpth_in_offset_2 = in_ptr[ dpth_in_offset + 2 ]; // Stride is less than 4 or 5. for( int j= 0; j < stride; j++, ix_w += depth ) { buf[ ix_w ] = in_dpth_in_offset_0; buf[ ix_w + 1 ] = in_dpth_in_offset_1; buf[ ix_w + 2 ] = in_dpth_in_offset_2; } dpth_in_offset += depth ; } } return ; } // zoom == 0, stride=1 const int in_offset = img_width * y_screen + x_screen ; if(ptr_pic->binary) { int dpth_in_offset = depth * in_offset ; for( int ix_w = 0, max_w = wid_screen * depth; ix_w < max_w ; ix_w += depth ) { buf[ ix_w ] = ptr_pic->pix2bin(in_ptr[ dpth_in_offset ]); buf[ ix_w + 1 ] = ptr_pic->pix2bin(in_ptr[ dpth_in_offset + 1 ]); buf[ ix_w + 2 ] = ptr_pic->pix2bin(in_ptr[ dpth_in_offset + 2 ]); dpth_in_offset += depth ; } } else { abort(); // This should never be called, see optimization in wefax_map::draw(). } } // wefax_map::draw_cb void wefax_map::draw() { if( ( zoom == 0 ) && ( binary == false ) ) { /// No scaling, this is faster. fl_draw_image( vidbuf, x(), y(), w(), h() ); } else { fl_draw_image( draw_cb, this, x(), y(), w(), h() ); // redraw(); } } void wefax_map::slant_undo() { int row, col; unsigned char temp[width * depth]; if (height == 0 || width == 0 || slantdir == 0) return; if (slantdir == -1) { // undo from left for (row = 0; row < height; row++) { col = numcol * row / (height - 1); if (col > 0) { memmove( temp, &vidbuf[(row * width + width - col) * depth], (width - col) * depth ); memmove( &vidbuf[(row * width + col)*depth], &vidbuf[row * width *depth], (width - col) * depth ); memmove( &vidbuf[row * width * depth], temp, col * depth ); } } } else if (slantdir == 1) { // undo from right for (row = 0; row < height; row++) { col = numcol * row / (height - 1); if (col > 0) { memmove( temp, &vidbuf[row * width * depth], col * depth ); memmove( &vidbuf[row * width * depth], &vidbuf[(row * width + col) * depth], (width - col) * depth ); memmove( &vidbuf[(row * width + width - col) * depth], temp, col *depth ); } } } slantdir = 0; redraw(); } void wefax_map::slant_corr(int x, int y) { int row, col; unsigned char temp[width * depth]; if (height == 0 || width == 0) return; if (x > width / 2) { // unwrap from right numcol = (width - x) * height / y; if (numcol > width / 2) numcol = width / 2; for (row = 0; row < height; row++) { col = numcol * row / (height - 1); if (col > 0) { memmove( temp, &vidbuf[(row * width + width - col) * depth], (width - col) * depth ); memmove( &vidbuf[(row * width + col)*depth], &vidbuf[row * width *depth], (width - col) * depth ); memmove( &vidbuf[row * width * depth], temp, col * depth ); } } slantdir = 1; } else { // unwrap from left numcol = x * height / y; if (numcol > width / 2) numcol = width / 2; for (row = 0; row < height; row++) { col = numcol * row / (height - 1); if (col > 0) { memmove( temp, &vidbuf[row * width * depth], col * depth ); memmove( &vidbuf[row * width * depth], &vidbuf[(row * width + col) * depth], (width - col) * depth ); memmove( &vidbuf[(row * width + width - col) * depth], temp, col *depth ); } } slantdir = -1; } redraw(); } int wefax_map::handle(int event) { if (Fl::event_inside( this )) { if (event == FL_RELEASE) { int xpos = Fl::event_x() - x(); int ypos = Fl::event_y() - y(); int evb = Fl::event_button(); if (evb == 1) slant_corr(xpos, ypos); else if (evb == 3) slant_undo(); LOG_DEBUG("#2 %d, %d", xpos, ypos); return 1; } return 1; } return 0; } static FILE* open_file(const char* name, const char* suffix) { FILE* fp; std::string fname = name; if (fname[fname.length() - 1] == '/') { // if the name ends in a slash we will generate // a timestamped name in the following format: char stamp[50]; time_t time_sec = time(0); struct tm ztime; (void)gmtime_r(&time_sec, &ztime); size_t sz; if ((sz = strftime(stamp, sizeof(stamp), "pic_%Y-%m-%d_%H%M%Sz", &ztime)) > 0) { fname.append(stamp); fname.append(suffix); mkdir(name, 0777); fp = fopen(fname.c_str(), "wb"); } else fp = NULL; } else { if (fname.find(suffix) == std::string::npos) fname.append(suffix); fp = fopen(fname.c_str(), "wb"); } return fp; } static inline unsigned char avg_pix( const unsigned char * vidbuf ) { return ( vidbuf[ 0 ] + vidbuf[ 1 ] + vidbuf[ 2 ] ) / wefax_map::depth ; } int wefax_map::save_png(const char* filename, const char *extra_comments) { FILE* fp; if ((fp = open_file(filename, ".png")) == NULL) return -1; // set up the png structures png_structp png; png_infop info; if ((png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)) == NULL) { fclose(fp); return -1; } /* png_set_compression_level() shall set the compression level to "level". * The valid values for "level" range from [0,9], corresponding directly * to compression levels for zlib. The value 0 implies no compression * and 9 implies maximal compression. Note: Tests have shown that zlib * compression levels 3-6 usually perform as well as level 9 for PNG images, * and do considerably fewer calculations. */ png_set_compression_level(png, Z_BEST_COMPRESSION); if ((info = png_create_info_struct(png)) == NULL) { png_destroy_write_struct(&png, NULL); fclose(fp); return -1; } if (setjmp(png_jmpbuf(png))) { png_destroy_write_struct(&png, &info); fclose(fp); return -1; } // use an stdio stream png_init_io(png, fp); // set png header int color_type = PNG_COLOR_TYPE_RGB ; /// Color images must take eight bits per pixel. const int bit_depth = 8;//( monochrome && binary ) ? 1 : 8 ; png_set_IHDR(png, info, width, height, bit_depth, color_type, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); // write text comments struct tm tm; time_t t = time(NULL); gmtime_r(&t, &tm); char z[20 + 1]; strftime(z, sizeof(z), "%Y-%m-%dT%H:%M:%SZ", &tm); z[sizeof(z) - 1] = '\0'; std::ostringstream comment; comment << "Program: " PACKAGE_STRING << '\n' << "Received: " << z << '\n' << "Modem: " << mode_info[active_modem->get_mode()].name << '\n' << "Frequency: " << inpFreq->value() << '\n'; if( extra_comments ) { comment << extra_comments ; } if (inpCall->size()) comment << "Log call: " << inpCall->value() << '\n'; // set text png_text text; text.key = strdup("Comment"); text.text = strdup(comment.str().c_str()); text.compression = PNG_TEXT_COMPRESSION_NONE; png_set_text(png, info, &text, 1); // write header png_write_info(png, info); // Extra check for debugging. if( height * width * depth != bufsize ) { LOG_ERROR("Buffer inconsistency h=%d w=%d b=%d", height, width, bufsize ); } // write image /* if(monochrome) { unsigned char tmp_row[width]; png_bytep row; for (int i = 0; i < height; i++) { int row_offset = i * width * depth ; if( binary ) { unsigned char accumPix = 0 ; int j_offset = 0 ; for(int j = 0 ; j < width; ++j ) { int col_offset = row_offset + j * depth ; unsigned char tmpChr = avg_pix( vidbuf + col_offset ); tmpChr = pix2bin(tmpChr) ? 1 : 0 ; j_offset = j & 0x07 ; tmpChr = tmpChr << ( 7 - j_offset ); accumPix |= tmpChr ; if( j_offset == 7 ) { tmp_row[ j >> 3 ] = accumPix ; accumPix = 0 ; } } if( j_offset != 7 ) { tmp_row[ width >> 3 ] = accumPix ; } } else { for(int j = 0 ; j < width; ++j ) { int col_offset = row_offset + j * depth ; tmp_row[j] = avg_pix( vidbuf + col_offset ); } } row = tmp_row; png_write_rows(png, &row, 1); } } else */ { png_bytep row; for (int i = 0; i < height; i++) { row = &vidbuf[i * width * depth]; png_write_rows(png, &row, 1); } } png_write_end(png, info); // clean up free(text.key); free(text.text); png_destroy_write_struct(&png, &info); fclose(fp); return 0; } bool wefax_map::restore( int row, int margin ) { if( ( row <= noise_height_margin ) || ( row >= height ) ) return true; unsigned char * line_ante = vidbuf + (row - noise_height_margin) * width * depth; // Copy the new calculated value (at previous call) to all channels. // TODO: Do that when switching off noise removal, otherwise a couple of colored pixels are left. for( int col = margin ; col < width - margin; ++col ) { int offset = col * depth ; line_ante[ offset ] = line_ante[ offset + 2 ] = line_ante[ offset + 1 ]; } return false ; } void wefax_map::erosion( int row ) { static const size_t margin_one = 1 ; if( restore( row, margin_one ) ) return ; const unsigned char * line_prev = vidbuf + (row - noise_height_margin + 1) * width * depth; unsigned char * line_curr = vidbuf + (row - noise_height_margin + 2) * width * depth; const unsigned char * line_next = vidbuf + (row - noise_height_margin + 3) * width * depth; for( size_t col = margin_one ; col < width - margin_one; ++col ) { unsigned char new_pix = 255 ; new_pix = std::min( new_pix, line_prev[ depth * ( col - 1 ) ] ); new_pix = std::min( new_pix, line_prev[ depth * ( col ) ] ); new_pix = std::min( new_pix, line_prev[ depth * ( col + 1 ) ] ); new_pix = std::min( new_pix, line_curr[ depth * ( col - 1 ) ] ); new_pix = std::min( new_pix, line_curr[ depth * ( col ) ] ); new_pix = std::min( new_pix, line_curr[ depth * ( col + 1 ) ] ); new_pix = std::min( new_pix, line_next[ depth * ( col - 1 ) ] ); new_pix = std::min( new_pix, line_next[ depth * ( col ) ] ); new_pix = std::min( new_pix, line_next[ depth * ( col + 1 ) ] ); /// Use this channel as a buffer. Beware that if we change the slant, // this component might not be restored // because the line position changed. Not a big problem. // We might forbid slanting when de-noising. line_curr[ col * depth + 1 ] = new_pix; } } void wefax_map::remove_noise( int row, int half_len, int noise_margin ) { if( restore( row, half_len ) ) return ; const unsigned char * line_prev = vidbuf + (row - noise_height_margin + 1) * width * depth; unsigned char * line_curr = vidbuf + (row - noise_height_margin + 2) * width * depth; const unsigned char * line_next = vidbuf + (row - noise_height_margin + 3) * width * depth; const int nb_neighbours = ( 2 * ( 2 * half_len + 1 ) ); int medians[nb_neighbours]; /// Takes into account the first component only. for( int col = half_len ; col < width - half_len; ++col ) { int curr_pix = line_curr[ col * depth ]; assert( ( curr_pix >= 0 ) && ( curr_pix <= 255 ) ); int pix_min = 255, pix_max = 0; for( int subcol = col - half_len, tmp, nghb_i = 0 ; subcol <= col + half_len ; ++subcol ) { int offset = subcol * depth ; tmp = line_prev[ offset ]; if( tmp < pix_min ) pix_min = tmp ; else if( tmp > pix_max ) pix_max = tmp ; medians[nghb_i++] = tmp; tmp = line_next[ offset ]; if( tmp < pix_min ) pix_min = tmp ; else if( tmp > pix_max ) pix_max = tmp ; medians[nghb_i++] = tmp; } // Maybe the pixel is between min and max. int thres_min = pix_min - noise_margin; if(thres_min < 0) thres_min = 0; assert(thres_min <= pix_min); int thres_max = pix_max + noise_margin; if(thres_max > 255 ) thres_max = 255; if(thres_max < pix_max) abort(); if( ( curr_pix >= thres_min ) && ( curr_pix <= thres_max ) ) continue ; assert( ( pix_max >= 0 ) && ( pix_max <= 255 ) ); std::sort( medians, medians + nb_neighbours ); int new_pix = medians[ nb_neighbours / 2 ]; assert( new_pix >= 0 ); /// Use this channel as a buffer. Beware that if we change the slant, // this component might not be restored // because the line position changed. Not a big problem. // We might forbid slanting when de-noising. line_curr[ col * depth + 1 ] = new_pix; } } int wefax_picbox::handle(int event) { if (!Fl::event_inside(this)) return 0; switch (event) { case FL_DND_ENTER: case FL_DND_LEAVE: case FL_DND_DRAG: case FL_DND_RELEASE: return 1; case FL_PASTE: break; default: return Fl_Box::handle(event); } // handle FL_PASTE std::string text = Fl::event_text(); // from dnd event "file:///home/dave/Photos/dave.jpeg" std::string::size_type p; if ((p = text.find("file://")) != std::string::npos) text.erase(0, p + strlen("file://")); if ((p = text.find('\r')) != std::string::npos) text.erase(p); if ((p = text.find('\n')) != std::string::npos) text.erase(p); struct stat st; if (stat(text.c_str(), &st) == -1 || !S_ISREG(st.st_mode)) return 0; extern void load_image(const char*); load_image(text.c_str()); return 1; }
21,323
C++
.cxx
672
28.657738
117
0.612154
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,230
wefax.cxx
w1hkj_fldigi/src/wefax/wefax.cxx
// --------------------------------------------------------------------- // wefax.cxx -- Weather Fax modem // // Copyright (C) 2019 // Remi Chateauneu, F4ECW // David Freese, W1HKJ // // This file is part of fldigi. Adapted from code contained in HAMFAX source code // distribution. // Hamfax Copyright (C) Christof Schmitt // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // --------------------------------------------------------------------- #include <config.h> #include <unistd.h> #include <cstdlib> #include <sstream> #include <iostream> #include <fstream> #include <iomanip> #include <cstring> #include <valarray> #include <cmath> #include <cstddef> #include <queue> #include <map> #include <libgen.h> #include "debug.h" #include "gettext.h" #include "wefax.h" #include "modem.h" #include "main.h" #include "misc.h" #include "timeops.h" #include "fl_digi.h" #include "configuration.h" #include "status.h" #include "filters.h" #include "strutil.h" #include "wefax-pic.h" #include "ascii.h" #include "qrunner.h" // --------------------------------------------------------------------- // // --------------------------------------------------------------------- #define PUT_STATUS(A) \ { \ std::stringstream strm_status ; \ strm_status << A ; \ LOG_DEBUG("%s", strm_status.str().c_str()); \ } // put_status(strm_status.str().c_str()); // --------------------------------------------------------------------- // Core of the code taken from Hamfax. // --------------------------------------------------------------------- /// No reasonable FIR filter should have more coefficients than that. #define MAX_FILT_SIZE 256 struct fir_coeffs { const char * _name ; int _size ; const double _coefs[MAX_FILT_SIZE]; }; // Narrow, middle and wide fir low pass filter from ACfax static const fir_coeffs input_filters[] = { { _("Narrow"), 65, { 0.000495, 0.000684, 0.000885, 0.00109, 0.00128, 0.00141, 0.00142, 0.00124, 0.000793, 2.94e-05, -0.00108, -0.00251, -0.0042, -0.00602, -0.00778, -0.00925, -0.0101, -0.0102, -0.00909, -0.00664, -0.00267, 0.00289, 0.01, 0.0185, 0.0281, 0.0383, 0.0488, 0.059, 0.0682, 0.0761, 0.0821, 0.0858, 0.0871, 0.0858, 0.0821, 0.0761, 0.0682, 0.059, 0.0488, 0.0383, 0.0281, 0.0185, 0.01, 0.00289, -0.00267, -0.00664, -0.00909, -0.0102, -0.0101, -0.00925, -0.00778, -0.00602, -0.0042, -0.00251, -0.00108, 2.94e-05, 0.000793, 0.00124, 0.00142, 0.00141, 0.00128, 0.00109, 0.000885, 0.000684, 0.000495 } }, { _("Medium"), 65, { -0.000795, -0.000779, -0.000698, -0.000517, -0.000195, 0.000303, 0.000982, 0.0018, 0.00267, 0.00343, 0.00389, 0.00383, 0.00306, 0.00144, -0.00102, -0.0042, -0.0078, -0.0114, -0.0143, -0.0159, -0.0156, -0.0127, -0.00695, 0.00188, 0.0136, 0.0277, 0.0434, 0.0596, 0.0752, 0.0889, 0.0997, 0.106, 0.109, 0.106, 0.0997, 0.0889, 0.0752, 0.0596, 0.0434, 0.0277, 0.0136, 0.00188, -0.00695, -0.0127, -0.0156, -0.0159, -0.0143, -0.0114, -0.0078, -0.0042, -0.00102, 0.00144, 0.00306, 0.00383, 0.00389, 0.00343, 0.00267, 0.0018, 0.000982, 0.000303, -0.000195, -0.000517, -0.000698, -0.000779, -0.000795 } }, { _("Wide"), 65, { 0.000716, 0.000844, 0.000845, 0.000668, 0.000259, -0.000402, -0.00126, -0.00216, -0.00284, -0.003, -0.00234, -0.00073, 0.00175, 0.0047, 0.00747, 0.00922, 0.00911, 0.00655, 0.00143, -0.00575, -0.0138, -0.0209, -0.025, -0.0241, -0.0167, -0.00203, 0.0193, 0.0457, 0.0743, 0.102, 0.125, 0.14, 0.145, 0.14, 0.125, 0.102, 0.0743, 0.0457, 0.0193, -0.00203, -0.0167, -0.0241, -0.025, -0.0209, -0.0138, -0.00575, 0.00143, 0.00655, 0.00911, 0.00922, 0.00747, 0.0047, 0.00175, -0.00073, -0.00234, -0.003, -0.00284, -0.00216, -0.00126, -0.000402, 0.000259, 0.000668, 0.000845, 0.000844, 0.000716 } } }; static const size_t nb_filters = sizeof(input_filters)/sizeof(input_filters[0]); ; /// This contains all possible reception filters. class fir_filter_pair_set : public std::vector< C_FIR_filter > { /// This, because C_FIR_filter cannot be copied. fir_filter_pair_set(const fir_filter_pair_set &); fir_filter_pair_set & operator = (const fir_filter_pair_set &); public: static const char ** filters_list(void) { /// There will be a small memory leak when leaving. No problem at all. static const char ** stt_filters = NULL ; if (stt_filters == NULL) { stt_filters = new const char * [nb_filters + 1]; for(size_t ix_filt = 0 ; ix_filt < nb_filters ; ++ix_filt) { stt_filters[ix_filt] = input_filters[ix_filt]._name ; } stt_filters[nb_filters] = NULL ; } return stt_filters ; } fir_filter_pair_set() { /// Beware that C_FIR_filter cannot be copied with its content. resize(nb_filters); for(size_t ix_filt = 0 ; ix_filt < nb_filters ; ++ix_filt) { // Same filter for real and imaginary. const fir_coeffs * ptr_filt = input_filters + ix_filt ; // init() should take const double pointers. operator[](ix_filt).init(ptr_filt->_size, 1, const_cast< double * >(ptr_filt->_coefs), const_cast< double * >(ptr_filt->_coefs)); } } }; // fir_filter_pair_set /// Speed-up of trigonometric calculations. template <class T> class lookup_table { T * m_table; size_t m_table_size; size_t m_next; size_t m_increment; /// No default constructor because it would invalidate the buffer pointer. lookup_table(); lookup_table(const lookup_table &); lookup_table & operator = (const lookup_table &); public: lookup_table(const size_t N) : m_table_size(N), m_next(0), m_increment(0) { assert(N != 0); /// If no more memory, an exception will be thrown. m_table = new T[m_table_size]; } ~lookup_table(void) { delete[] m_table; } T& operator[](size_t i) { return m_table[i]; } void set_increment(size_t i) { m_increment = i; } T next_value(void) { m_next+=m_increment; if (m_next>=m_table_size) { m_next%=m_table_size; } return m_table[m_next]; } size_t size(void) const { return m_table_size; } void reset(void) { m_next = 0; } }; // lookup_table typedef enum { RXAPTSTART, RXAPTSTOP, RXPHASING, RXIMAGE, TXAPTSTART, TXPHASING, ENDPHASING, TXIMAGE, TXAPTSTOP, TXBLACK, IDLE } fax_state; static const char * state_to_str(fax_state a_state) { switch(a_state) { case RXAPTSTART : return _("APT reception start"); case RXAPTSTOP : return _("APT reception stop"); case RXPHASING : return _("Phasing reception"); case RXIMAGE : return _("Receiving"); case TXAPTSTART : return _("APT transmission start"); case TXAPTSTOP : return _("APT stop"); case TXPHASING : return _("Phasing transmission"); case ENDPHASING : return _("End phasing"); case TXIMAGE : return _("Sending image"); case TXBLACK : return _("Sending black"); case IDLE : return _("Idle"); } return "UNKNOWN"; }; /// TODO: This should be hidden to this class. static const int bytes_per_pixel = 3; #define IOC_576 576 #define IOC_288 288 /// Index of correlation to image width. static int ioc_to_width(int ioc) { return ioc * M_PI ; }; /// Used by bandwidth. Standard shift is 800 Hz, so deviation is 400 Hz. /// Deutsche Wetterdienst (DWD) shift is 850 Hz. static int fm_deviation = -1 ; #define GARBAGE_STR "garbage" class fax_implementation { wefax * m_ptr_wefax ; // Points to the modem of which this is the implementation. fax_state m_rx_state ; // RXPHASING, RXIMAGE etc... bool rx_state_changed; int m_sample_rate; // Set at startup: 8000, 11025 etc... int m_current_value; // Latest received pixel value. bool m_apt_high; int m_apt_trans; // APT low-high transitions int m_apt_count; // samples counted for m_apt_trans int m_apt_start_freq; // Standard APT frequency. Set at startup. int m_apt_stop_freq; // Standard APT frequency. bool m_phase_high; // When state=RXPHASING int m_curr_phase_len; // Counts the len of the image band used for phasing int m_curr_phase_high; // Counts the len of the white part of the phasing image band. int m_curr_phase_low; // Counts the len of the black part of the phasing image band. int m_phase_lines; int m_num_phase_lines; int m_phasing_calls_nb;// Number of calls to decode_phasing for the current image. double m_lpm_img; // Lines per minute. double m_lpm_sum_rx; // Sum of the latest LPM values, when RXPHASING. int m_default_lpm; // 120 for WEFAX_576, 60 for WEFAX_288. int m_img_width; // Calculated with IOC=576 or 288. int m_img_sample; // Current received samples number when in RXIMAGE. int m_last_col; // Current col based on samples number, decides to set a pixel when changes. int m_pixel_val; // Accumulates received samples, then averaged to set a pixel. int m_pix_samples_nb; // Number of samples read for the next pixel, and current column. About 4 if 11025 Hz. bool m_img_color; // Whether this is a color image or not. fax_state m_tx_state; // Modem state when transmitting. int m_tx_phasing_lin; // Nb of phasing lines sent when transmitting an image. int m_start_duration; // Number of seconds for sending ATP start. int m_stop_duration; // Number of seconds for sending APT stop. int m_img_tx_cols; // Number of columns when transmitting. int m_img_tx_rows; // Number of rows when transmitting. int m_carrier; // Normalised fax carrier frequency. Should be identical to modem::get_freq(). int m_fax_pix_num; // Index of current pixel in received image. const unsigned char * m_xmt_pic_buf ; // Bytes to send. Number of pixels by three. bool m_manual_mode ; // Tells whether everything is read, or apt+phasing detection. /// The number of samples sent for one line. The LPM is given by the GUI. Typically 5512. double m_smpl_per_lin ;// Recalculated each time m_lpm_img is updated. double deviation_ratio; // At the moment, never found an example where it should be negated. static const bool m_phase_inverted = false; /// This is always the same filter for all objects. static fir_filter_pair_set m_rx_filters ; /// These are used for transmission. lookup_table<double> m_dbl_sine; lookup_table<double> m_dbl_cosine; lookup_table<double> m_dbl_arc_sine; /// Stores a result based on the previous received sample. double m_i_fir_old; double m_q_fir_old; cmplx currz; cmplx prevz; void decode(const int* buf, int nb_samples); /// Used for transmission. lookup_table<short> m_short_sine; /// This evaluates the average and standard deviation of the current image, // using the histogram. class statistics { static const size_t m_sz = 256 ; int m_hist[m_sz]; mutable double m_avg ; mutable double m_dev ; public: void add_bw(int pix_val) { pix_val = pix_val < 0 ? 0 : pix_val > 255 ? 255 : pix_val ; m_hist[ pix_val ]++; } void calc() const { m_avg = 0.0; int sum = 0 ; int sum_vals = 0 ; for(size_t i = 0; i < m_sz; ++ i) { int weight = m_hist[i]; sum_vals += i * weight ; sum += weight ; } if (sum == 0) { m_avg = 0.0 ; m_dev = 0.0 ; return ; } m_avg = sum_vals / sum ; double sum_dlt_pwr2 = 0.0 ; for(size_t i = 0; i < m_sz; ++ i) { int weight = m_hist[i]; double val = i - m_avg ; sum_dlt_pwr2 += val * val * weight ; } m_dev = sqrt(sum_dlt_pwr2 / sum); } double average() const { return m_avg; } double stddev() const { return m_dev; }; void reset() { std::fill(m_hist, m_hist + m_sz, 0); } }; statistics m_statistics ; fax_implementation(); /// Needed when starting image reception, after phasing. void reset_counters(void) { m_last_col = 0 ; m_fax_pix_num = 0 ; m_img_sample = 0; m_pix_samples_nb = 0; } // These counters used for phasing. void reset_phasing_counters() { m_lpm_sum_rx = 0; m_phasing_calls_nb = 0 ; m_phase_high = m_current_value >= 128 ? true : false; m_curr_phase_len = m_curr_phase_high = m_curr_phase_low = 0; m_phase_lines = m_num_phase_lines = 0; } /// Called at init time or when the carrier changes. void reset_increments(void) { /// This might happen at startup. Not a problem. if (m_sample_rate == 0) { return; } m_dbl_sine.set_increment(m_dbl_sine.size()*m_carrier/m_sample_rate); m_dbl_cosine.set_increment(m_dbl_cosine.size()*m_carrier/m_sample_rate); m_dbl_sine.reset(); m_dbl_cosine.reset(); m_short_sine.reset(); } public: fax_implementation(int fax_mode, wefax * ptr_wefax); void init_rx(int the_smpl_rate); void skip_apt_rx(void); void skip_phasing_to_image_save(const std::string & comment); void skip_phasing_to_image(bool auto_center); void skip_phasing_rx(bool auto_center); void end_rx(void); void rx_new_samples(const double* audio_ptr, int audio_sz); void init_tx(int the_smpl_rate); void modulate(const double* buffer, int n); void tx_params_set( int the_lpm, const unsigned char * xmtpic_buffer, bool is_color, int img_w, int img_h); bool trx_do_next(void); void tx_apt_stop(void); double carrier(void) const { return m_carrier ; } /// The trigo tables have an increment which depends on the carrier frequency. void set_carrier(double freq) { m_carrier = freq ; reset_increments(); } int fax_width(void) const { return m_img_width ; } /// When set, starts receiving faxes without interruption other than manual. void manual_mode_set(bool manual_flag) { m_manual_mode = manual_flag ; } /// Called by the GUI. bool manual_mode_get(void) const { return m_manual_mode ; } int lpm_to_samples(int the_lpm) const { return m_sample_rate * 60.0 / the_lpm ; } /// Called by the GUI. void lpm_set(int the_lpm) { m_lpm_img = the_lpm ; m_smpl_per_lin = lpm_to_samples(m_lpm_img); } /// This generates a filename based on the frequency, current time, internal state etc... std::string generate_filename(const char *extra_msg) const ; const char * state_rx_str(void) const { return state_to_str(m_rx_state); } /// Returns a string telling the state. Informational purpose. std::string state_string(void) const { std::stringstream result ; result << "tx:" << state_to_str(m_tx_state) << " " << "rx:" << state_to_str(m_rx_state); return result.str(); }; private: /// Centered around the frequency. double power_usb_noise(void) const { static double avg_pwr = 0.0 ; double pwr = wf->powerDensity(m_carrier, 2 * fm_deviation) + 1e-10; return decayavg(avg_pwr, pwr, 25);//10); } /// This evaluates the power signal when APT start frequency. This frequency pattern /// can be observed on the waterfall. double power_usb_apt_start(void) const { static double avg_pwr = 0.0 ; /// Value approximated by watching the waterfall. double pwr = wf->powerDensity(m_apt_start_freq, 10); return decayavg(avg_pwr, pwr, 10); } /// Estimates the signal power when the phasing signal is received. double power_usb_phasing(void) const { static double avg_pwr = 0.0 ; /// Rough estimate based on waterfall observation. static const int bandwidth_phasing = 1 ; double pwr = wf->powerDensity(m_carrier - fm_deviation, bandwidth_phasing); return decayavg(avg_pwr, pwr, 10); } /// There is some power at m_carrier + fm_deviation but this is neglictible. double power_usb_image(void) const { static double avg_pwr = 0.0 ; /// This value is obtained by watching the waterfall. static const int bandwidth_image = 100 ; double pwr = wf->powerDensity(m_carrier + fm_deviation, bandwidth_image); return decayavg(avg_pwr, pwr, 10); } /// Hambourg Radio sends a constant freq which looks like an image. /// We eliminate it by comparing with a black signal. /// If this is a real image, bith powers will be close. /// If not, the image is very important, but not the black. /// TODO: Consider removing this, because it is not used. double power_usb_black(void) const { static double avg_pwr = 0.0 ; /// This value is obtained by watching the waterfall. static const int bandwidth_black = 20 ; double pwr = wf->powerDensity(m_carrier - fm_deviation, bandwidth_black); return decayavg(avg_pwr, pwr, 10); } /// Evaluates the signal power for APT stop frequency. double power_usb_apt_stop(void) const { static double avg_pwr = 0.0 ; /// This value is obtained by watching the waterfall. double pwr = wf->powerDensity(m_apt_stop_freq, 10); return decayavg(avg_pwr, pwr, 10); } /// This evaluates the signal/noise ratio for some specific bandwidths. class fax_signal { const fax_implementation * _ptr_fax ; int _cnt ; /// The value can be reused a couple of times. double _apt_start ; double _phasing ; double _image ; double _black ; double _apt_stop ; fax_state _state ; /// Deduction made based on signal power. const char * _text; const char * _stop_code; /// Finer tests can be added. These are all rule-of-thumb values based /// on observation of real signals. /// TODO: Adds a learning mode using the Hamfax detector to train the signal-based one. void set_state(void) { _state = IDLE ; _text = _("No signal detected"); _stop_code = "" ; if ((_apt_start > 20.0) && (_phasing < 10.0) && (_image < 10.0) && (_apt_stop < 10.0)) { _state = RXAPTSTART ; _text = _("Strong APT start signal: Skip to phasing."); } if ( /// The image signal may be weak if the others signals are even weaker. ( (_apt_start < 1.0) && (_phasing < 1.0) && (_image > 10.0) && (_apt_stop < 1.0)) || ( (_apt_start < 1.0) && (_phasing < 0.5) && (_image > 8.0) && (_apt_stop < 0.5)) || ( (_apt_start < 3.0) && (_phasing < 1.0) && (_image > 15.0) && (_apt_stop < 1.0))) { _state = RXIMAGE ; _text = _("Strong image signal when getting APT start: Starting phasing."); } if ((_apt_start < 10.0) && (_phasing > 20.0) && (_image < 10.0) && (_apt_stop < 10.0)) { _state = RXPHASING ; _text = _("Strong phasing signal when getting APT start: Starting phasing."); } /// TODO: Beware that quite often, it cuts image in the middle. // Maybe the levels should be amended. if ((_apt_start < 2.0) & (_phasing < 2.0) && (_image < 2.0) && (_apt_stop > 20.0)) { _state = RXAPTSTOP ; _text = _("Strong APT stop signal: Stopping reception."); _stop_code = "stop"; } /// Consecutive lines in a wefax image have a strong statistical correlation. fax_state state_corr = _ptr_fax->correlation_state(&_stop_code); if ((_state == RXIMAGE) || (_state == IDLE)) { if (state_corr == RXAPTSTOP) { _state = RXAPTSTOP ; _text = _("No significant line-to-line correlation: Reception should stop."); } } if ((_state == IDLE) || (_state == RXAPTSTART) || (_state == RXPHASING)) { if (state_corr == RXIMAGE) { _state = RXIMAGE ; _text = _("Significant line-to-line correlation: Reception should start."); } } } void recalc(void) { /// Adds a small value to avoid division by zero. double noise = _ptr_fax->power_usb_noise() + 1e-10 ; /// Multiplications are faster than divisions. double inv_noise = 1.0 / noise ; _apt_start = _ptr_fax->power_usb_apt_start() * inv_noise ; _phasing = _ptr_fax->power_usb_phasing() * inv_noise ; _image = _ptr_fax->power_usb_image() * inv_noise ; _black = _ptr_fax->power_usb_black() * inv_noise ; _apt_stop = _ptr_fax->power_usb_apt_stop() * inv_noise ; set_state(); } public: /// This recomputes, if needed, the various signal power ratios. void refresh(void) { /// Values reevaluated every X input samples. Must be smaller /// than the typical audio input frames (512 samples). static const int validity = 1000 ; /// Calculated at least the first time. if ((_cnt % validity) == 0) { recalc(); } /// Does not matter if wrapped beyond 2**31. ++_cnt ; } fax_signal(const fax_implementation * ptr_fax) : _ptr_fax(ptr_fax) , _cnt(0) , _text(NULL) {} fax_state signal_state(void) const { return _state ; } const char * signal_text(void) const { return _text; }; const char * signal_stop_code(void) const { return _stop_code; } double image_noise_ratio(void) const { return _image ; } /// For debugging only. friend std::ostream & operator<<(std::ostream & refO, const fax_signal & ref_sig) { refO << " start=" << std::setw(10) << ref_sig._apt_start << " phasing=" << std::setw(10) << ref_sig._phasing << " image=" << std::setw(10) << ref_sig._image << " black=" << std::setw(10) << ref_sig._black << " stop=" << std::setw(10) << ref_sig._apt_stop << " pwr_state=" << state_to_str(ref_sig._state); return refO ; } std::string to_string(void) const { std::stringstream tmp_strm ; tmp_strm << *this ; return tmp_strm.str(); } }; /// We tolerate a small difference between the frequencies. bool is_near_freq(int f1, int f2, int margin) const { int delta = f1 - f2 ; if (delta < 0) { delta = -delta ; } if (delta < margin) { return true ; } else { return false ; } } void save_automatic( const char * extra_msg, const std::string & comment); void decode_apt(int x, const fax_signal & the_signal); void decode_phasing(int x, const fax_signal & the_signal); bool decode_image(int x); private: /// Each received file has its name pushed in this queue. syncobj m_sync_rx ; std::queue< std::string > m_received_files ; public: /// Called by the engine each time a file is saved. void put_received_file(const std::string &filnam) { guard_lock g(m_sync_rx.mtxp()); LOG_INFO("%s", filnam.c_str()); m_received_files.push(filnam); m_sync_rx.signal(); } /// Returns a received file name, by chronological order. std::string get_received_file(int max_seconds) { guard_lock g(m_sync_rx.mtxp()); LOG_VERBOSE(_("delay = %d"), max_seconds); if (m_received_files.empty()) { if (! m_sync_rx.wait(max_seconds)) return std::string(); } std::string filnam = m_received_files.front(); m_received_files.pop(); return filnam ; } private: /// No unicity if the same filename is sent by several clients at the same time. /// This does not really matter because the error codes should be the same. syncobj m_sync_tx_fil ; std::string m_tx_fil ; // Filename being transmitted. syncobj m_sync_tx_msg ; typedef std::map< std::string, std::string > sent_files_type ; sent_files_type m_sent_files ; public: /// If the delay is exceeded, returns with an error message. std::string send_file(const std::string & filnam, double max_seconds) { LOG_VERBOSE("%s rf_carried = %d carrier = %d", filnam.c_str(), static_cast<int>(wf->rfcarrier()), m_carrier); bool is_acquired = transmit_lock_acquire(filnam, max_seconds); if (! is_acquired) return "Timeout sending " + filnam ; REQ(wefax_pic::send_image, filnam); guard_lock g(m_sync_tx_fil.mtxp()); sent_files_type::iterator itFi ; while(true) { itFi = m_sent_files.find(filnam); if (itFi != m_sent_files.end()) { break ; } LOG_VERBOSE("Locking"); guard_lock g(m_sync_tx_msg.mtxp()); LOG_VERBOSE("Waiting %f",max_seconds); if (! m_sync_tx_msg.wait(max_seconds)) { LOG_VERBOSE("Timeout %f", max_seconds); return "Timeout"; } } std::string err_msg = itFi->second ; LOG_VERBOSE("err_msg = %s", err_msg.c_str()); m_sent_files.erase(itFi); return err_msg ; } /// Called when loading a file from the GUI, or indirectly from XML-RPC. bool transmit_lock_acquire(const std::string & filnam, double delay = wefax::max_delay) { LOG_VERBOSE("Sending %s delay = %f tid = %d", filnam.c_str(), delay, (int)GET_THREAD_ID()); guard_lock g(m_sync_tx_fil.mtxp()); LOG_VERBOSE("Locked"); if (! m_tx_fil.empty()) { if (! m_sync_tx_fil.wait(delay)) return false ; } m_tx_fil = filnam ; LOG_VERBOSE("Sent %s", filnam.c_str()); return true ; } /// Allows to send another file. Called by XML-RPC and the GUI. void transmit_lock_release(const std::string & err_msg) { LOG_VERBOSE("err_msg = %s tid = %d", err_msg.c_str(), (int)GET_THREAD_ID()); guard_lock g(m_sync_tx_msg.mtxp()); LOG_VERBOSE("%s %s", m_tx_fil.c_str(), err_msg.c_str()); if (m_tx_fil.empty()) { LOG_WARN(_("%s: File name should not be empty"), err_msg.c_str()); } else { m_sent_files[ m_tx_fil ] = err_msg ; m_tx_fil.clear(); } LOG_VERBOSE("Signaling"); m_sync_tx_msg.signal(); } /// Maybe we could reset this buffer when we change the state so that we could /// use the current LPM width. struct corr_buffer_t : public std::vector<unsigned char> { unsigned char at_mod(size_t i) const { return operator[](i % size()); } unsigned char & at_mod(size_t i) { return operator[](i % size()); } }; mutable corr_buffer_t m_correlation_buffer ; mutable double m_curr_corr_avg ; // Average line-to-line correlation for the spec'd # sampled lines. mutable double m_imag_corr_max ; // Max line-to-line correlation for the current image. mutable double m_imag_corr_min ; // Min line-to-line correlation for the current image. mutable int m_corr_calls_nb; /// Evaluates the correlation between two lines separated by line_offset pixels. double correlation_from_index(size_t line_length, size_t line_offset) const { /// This is a ring buffer. size_t line_length_plus_img_sample = line_length + m_img_sample ; int avg_pred = 0, avg_curr = 0 ; for(size_t i = m_img_sample ; i < line_length_plus_img_sample ; ++i) { int pix_pred = m_correlation_buffer.at_mod(i ); int pix_curr = m_correlation_buffer.at_mod(i + line_offset); avg_pred += pix_pred; avg_curr += pix_curr ; } avg_pred /= line_length; avg_curr /= line_length; /// Use integers because it is faster. Samples are chars, so no overflow possible. int numerator = 0, denom_pred = 0, denom_curr = 0 ; for(size_t i = m_img_sample ; i < line_length_plus_img_sample ; ++i) { int pix_pred = m_correlation_buffer.at_mod(i ); int pix_curr = m_correlation_buffer.at_mod(i + line_offset); int delta_pred = pix_pred - avg_pred ; int delta_curr = pix_curr - avg_curr ; numerator += delta_pred * delta_curr ; denom_pred += delta_pred * delta_pred ; denom_curr += delta_curr * delta_curr ; } double denominator = sqrt((double)denom_pred * (double)denom_curr); if (denominator == 0.0) { return 0.0 ; } else { return fabs(numerator / denominator); } } size_t correlation_shift(size_t corr_smpl_lin) const { static bool is_init = false ; static const size_t max_space_echo = 100 ; /// Specific to the antenna and the reception, so no need to clean it up. static size_t shift_histogram[max_space_echo]; static size_t nb_calls = 0 ; if (! is_init) { for(size_t i = 0; i < max_space_echo; ++i) shift_histogram[i] = 0 ; is_init = true ; } double tmpCorrPrev = correlation_from_index(corr_smpl_lin, 0); size_t local_max = 0 ; bool is_growing = false ; /// We could even start the loop later because we are not interested by small shifts. for(size_t i = 1 ; i < max_space_echo; i++) { double tmpCorr = correlation_from_index(corr_smpl_lin, i); bool is_growing_next = tmpCorr > tmpCorrPrev ; if (is_growing && (! is_growing_next )) { local_max = i - 1 ; break ; } is_growing = is_growing_next ; tmpCorrPrev = tmpCorr ; } if (local_max != 0) { ++shift_histogram[local_max]; } ++nb_calls ; size_t best_shift_idx = 0 ; size_t biggest_shift = shift_histogram[best_shift_idx]; if ((nb_calls > 100) && ((nb_calls % 10) == 0)) { for(size_t i = 0; i < max_space_echo; ++i) { size_t new_hist = shift_histogram[i]; if (new_hist > biggest_shift) { biggest_shift = new_hist ; best_shift_idx = i ; } } LOG_VERBOSE("Shift: i = %d hist = %d", (int)best_shift_idx, (int)biggest_shift); } return best_shift_idx ; } static const int min_white_level = 128 ; /// Absolute value of statistical correlation between the current line and the previous one. /// Called once per maximum sample line. void correlation_calc(void) const { ++m_corr_calls_nb; /// We should in fact take the smallest one, 60. size_t corr_smpl_lin = lpm_to_samples(m_default_lpm); double current_corr = correlation_from_index(corr_smpl_lin, corr_smpl_lin); /// This never happened, but who knows (Inaccuracy etc...)? if (current_corr > 1.0) { LOG_WARN("Inconsistent correlation:%lf", current_corr); current_corr = 1.0; } int crows = progdefaults.wefax_correlation_rows; if (m_corr_calls_nb < crows) { m_curr_corr_avg = current_corr ; /// The max value of the correlation must be significative (Does not take peak values). m_imag_corr_max = 0.0; m_imag_corr_min = 0.0; } else { /// Equivalent to decayavg with weight= (min_corr_lin +1)/min_corr_lin m_curr_corr_avg = (m_curr_corr_avg * crows + current_corr) / (crows + 1); m_imag_corr_max = std::max(m_curr_corr_avg, m_imag_corr_max); m_imag_corr_min = std::min(m_curr_corr_avg, m_imag_corr_min); } /// Debugging purpose only. if ((m_corr_calls_nb % 10) == 0) { LOG_DEBUG( "current_corr = %lf m_curr_corr_avg = %lf m_imag_corr_max = %f m_corr_calls_nb = %d state = %s m_lpm_img = %f", current_corr, m_curr_corr_avg, m_imag_corr_max, m_corr_calls_nb, state_rx_str(), m_lpm_img); } double metric = m_curr_corr_avg * 100.0 ; m_ptr_wefax->display_metric(metric); return; /* static bool first = true; if ((m_corr_calls_nb % 10) == 0) { if (first) { ofstream csv("stats.csv"); csv << "current_corr,curr_corr_avg,imag_corr_max,corr_calls_nb,state,lpm_img,metric" << std::endl; first = false; } ofstream csv("stats.csv", ios::app); csv << current_corr << "," << m_curr_corr_avg << "," << m_imag_corr_max << "," << m_corr_calls_nb << "," << state_rx_str() << "," << m_lpm_img << "," << metric << std::endl; csv.close(); } */ } /// This is called quite often. It estimates, based on the mobile /// average of statistical correlation between consecutive lines, whether this is a wefax /// signal or not. fax_state correlation_state(const char ** stop_code) const { static fax_state stable_state = IDLE ; switch(stable_state) { case RXAPTSTART : *stop_code = "stable_start" ; break; case RXAPTSTOP : *stop_code = "stable_stop" ; break; case RXPHASING : *stop_code = "stable_phasing"; break; case RXIMAGE : *stop_code = "stable_image" ; break; case IDLE : *stop_code = "stable_idle" ; break; default : *stop_code = "unexpected" ; break; } /// If the mobile average is not computed on enough lines, returns IDLE /// which means "Do not know" in this context. if (m_corr_calls_nb >= progdefaults.wefax_correlation_rows) { int crr_row = m_img_sample / m_smpl_per_lin ; /// Sometimes, we detected a Stop just after the header, and we create an image /// of 300 lines. This is a rule of thumb. The bad consequence is that the image /// would be a bit too high. This an approximate row number. /// On the other hand, if we read very few lines, we assume this is just noise. double low_corr = progdefaults.wefax_correlation; /// If high threshold, we cut images in two. /// If low threshold, we go on reading an image after its end if apt stop is not seen, /// and might read the beginning of the next image. if (m_curr_corr_avg < low_corr) { LOG_DEBUG("Setting to stop m_curr_corr_avg = %f low_corr = %f", m_curr_corr_avg, low_corr); *stop_code = "nocorr"; stable_state = RXAPTSTOP ; /// TODO: Beware, this is sometimes triggered with cyclic parasites. } else if (m_curr_corr_avg > 3 * low_corr / 2) { stable_state = RXIMAGE ; } else if ((m_imag_corr_max < 0.10) && (crr_row > 200)) { // If the correlation was always very low for many lines, // this means that we started to read a wrong image, so // there might be a wrong tuning or the DWD constant frequency. // So we trash the image. // TODO: It is done too many times: SOMETIMES THE MESSAGE IS REPEATED HUNDREDTH. // crr8row continues to grow although it makes no sense. LOG_INFO("Flushing dummy image m_imag_corr_max = %f crr_row = %d 200 lines.", m_imag_corr_max, crr_row); static const char * garbage_200 = GARBAGE_STR ".200"; *stop_code = garbage_200; reset_afc(); stable_state = RXAPTSTOP ; } else if ((m_imag_corr_max < 0.20) && (crr_row > 500)) { // If the max line-to-line correlation still low for a bigger image. LOG_INFO("Flushing dummy image m_imag_corr_max = %f crr_row = %d 500 lines.", m_imag_corr_max, crr_row); static const char * garbage_500 = GARBAGE_STR ".500"; *stop_code = garbage_500; reset_afc(); stable_state = RXAPTSTOP ; } else { stable_state = IDLE ; } } /// Message for first detection. if ((stable_state == IDLE) && (m_corr_calls_nb == progdefaults.wefax_correlation_rows)) { static double last_corr_avg = 0.0 ; if (m_curr_corr_avg != last_corr_avg) { LOG_INFO("Correlation average %lf m_imag_corr_max = %f: Detected %s", m_curr_corr_avg, m_imag_corr_max, state_to_str(stable_state)); last_corr_avg = m_curr_corr_avg ; } } return stable_state; } /// We compute about the same when plotting a pixel. void correlation_update(int the_sample) { size_t corr_smpl_lin = lpm_to_samples(m_default_lpm); size_t corr_buff_sz = 2 * corr_smpl_lin ; static size_t cnt_upd = 0 ; if (m_correlation_buffer.size() != corr_buff_sz) { m_correlation_buffer.resize(corr_buff_sz, 0); m_curr_corr_avg = 0.0 ; } if ((cnt_upd % corr_smpl_lin) == 0) { correlation_calc(); } ++cnt_upd ; m_correlation_buffer.at_mod(m_img_sample) = the_sample ; } // correlation_update /// Clean trick so that we can reset internal variables of process_afc(). void reset_afc() const { process_afc(true); } /// Called once for each row of input data. void process_afc(bool reset_afc = false) const { static int prev_row = -1 ; static int total_img_rows = 0 ; /// Audio frequency. static int stable_carrier = 0 ; static const int max_median_freqs = 20 ; static double median_freqs[ max_median_freqs ]; static int nb_median_freqs = 0 ; /// Rig frequency. static long long stable_rfcarrier = 0 ; /// TODO: Maybe we could restrict the range of frequencies. if (reset_afc) { /// Displays the message only once. if (prev_row != -1) { LOG_DEBUG("Resetting AFC total_img_rows = %d",total_img_rows); } prev_row = -1 ; total_img_rows = 0 ; stable_carrier = 0; stable_rfcarrier = 0 ; nb_median_freqs = 0 ; return; } if (progStatus.afconoff == false) return ; /// The LPM might have changed, but this is very improbable. /// We do not know the LPM so we assume the default. double smpl_per_lin = lpm_to_samples(m_default_lpm); int crr_row = m_img_sample / smpl_per_lin ; if (crr_row == prev_row) return ; long long curr_rfcarr = wf->rfcarrier() ; /// If the freq changed, reset the number of good lines read. if ((m_carrier != stable_carrier) || (curr_rfcarr != stable_rfcarrier)) { /// Displays the messages once only. if (total_img_rows != 0) { LOG_VERBOSE("Setting m_carrier = %d curr_rfcarr = %d total_img_rows = %d", m_carrier, static_cast<int>(curr_rfcarr), total_img_rows); } total_img_rows = 0 ; stable_carrier = m_carrier ; stable_rfcarrier = curr_rfcarr ; } /// If we could read a big portion of an image, then no adjustment. if (m_rx_state == RXIMAGE) { /// Maybe this is a new image so last_img_rows is from the previous image. if (prev_row < crr_row) { total_img_rows += crr_row - prev_row ; } else { LOG_DEBUG("prev_crr_row = %d crr_row = %d total_img_rows = %d", prev_row, crr_row, total_img_rows); } } else { LOG_DEBUG("State = %s crr_row = %d", state_rx_str(), crr_row); } prev_row = crr_row ; /// If we could succesfully read this number of lines, it must be the right frequency. static const int threshold_rows = 200 ; /// Consider than not only we could read many lines, but also other criterias such /// as correlation, or if we could read apt start/stop. Otherwise, it may stabilize a useless frequency. if ((total_img_rows >= threshold_rows) && (m_curr_corr_avg > 0.10)) { if (total_img_rows == threshold_rows) { LOG_VERBOSE("Stable total_img_rows = %d m_curr_corr_avg = %f", total_img_rows, m_curr_corr_avg); } //If the reception is always poor for a long time restart AFC. stable_carrier = progdefaults.WEFAX_Center; m_ptr_wefax->set_freq(stable_carrier); return ; } /// This centers the carrier where the activity is the strongest. static const int bw_dual[][2] = { { -fm_deviation - 50, -fm_deviation + 50 }, { fm_deviation - 50, fm_deviation + 50 } }; double max_carrier_dual = wf->powerDensityMaximum(2, bw_dual); static const int bw_right[][2] = { { fm_deviation - 50, fm_deviation + 50 } }; double max_carrier_right = wf->powerDensityMaximum(1, bw_right); // This might have to be adjusted because DWD has all the energy on the right // band, but Northwood has some on the left. double max_carrier = 0.0 ; /// Maybe there is not enough room on the left. if (max_carrier_dual < 0.0) { LOG_DEBUG("Invalid AFC: Dual band = %f, right band = %f. Take right", max_carrier_dual, max_carrier_right); max_carrier = max_carrier_right - fm_deviation; } else /// Both mask detect approximately the same frequency: This is the consistent case. if (fabs(max_carrier_dual - max_carrier_right) < 20) { max_carrier = max_carrier_right - fm_deviation; } else if (max_carrier_dual < max_carrier_right) { LOG_DEBUG("Inconsistent AFC: Dual band = %f, right band = %f. Take right", max_carrier_dual, max_carrier_right); max_carrier = max_carrier_right - fm_deviation; } else /// Single-band mask close to the left frequency of the dual-freq mask if (fabs(fabs(max_carrier_dual - max_carrier_right) - 2 * fm_deviation) < 20) { LOG_DEBUG("Dual band = %f instead of right band = %f. Take dual", max_carrier_dual, max_carrier_right); max_carrier = max_carrier_dual ; } else { LOG_DEBUG("Inconsistent AFC: Dual band = %f, right band = %f. Take dual.", max_carrier_dual, max_carrier_right); max_carrier = max_carrier_dual ; } /// The max power is unreachable, there might be another reason. Stay where we are. static bool prevWasRight = true ; /// TODO: We might find the next solution, maybe by giving to powerDensityMaximum a smaller range. if ((max_carrier <= fm_deviation) || (max_carrier >= IMAGE_WIDTH - fm_deviation)) { /// Display this message once only. if (prevWasRight) { LOG_VERBOSE("Invalid max_carrier = %f", max_carrier); } prevWasRight = false ; return ; } else { prevWasRight = true ; } // TODO: If the correlation is below a given threshold, it might be useless to add it. median_freqs[ nb_median_freqs % max_median_freqs ] = max_carrier ; ++nb_median_freqs; if (nb_median_freqs >= max_median_freqs) { std::sort(median_freqs, median_freqs + max_median_freqs); max_carrier = median_freqs[ max_median_freqs / 2 ]; } /// Do not change the frequency too quickly if an image is received. /// Reject large excursions in carrier if (fabs(m_carrier - max_carrier) > 10) return; stable_carrier += 0.10*(max_carrier - stable_carrier); if (stable_carrier < (progdefaults.WEFAX_Center - 25)) stable_carrier = progdefaults.WEFAX_Center; if (stable_carrier > (progdefaults.WEFAX_Center + 25)) stable_carrier = progdefaults.WEFAX_Center; m_ptr_wefax->set_freq(stable_carrier); LOG_DEBUG("m_carrier = %f max_carrier = %f next_carr = %d", (double)m_carrier, max_carrier, stable_carrier); } }; // class fax_implementation /// Narrow, middle etc... input filters. Constructed at program startup. Readonly. fir_filter_pair_set fax_implementation::m_rx_filters ; fax_implementation::fax_implementation(int fax_mode, wefax * ptr_wefax ) : m_ptr_wefax(ptr_wefax) , m_dbl_sine(8192),m_dbl_cosine(8192),m_dbl_arc_sine(256) , m_short_sine(8192) { m_apt_stop_freq = 450 ; m_img_color = false ; m_tx_phasing_lin = 20 ; m_carrier = progdefaults.WEFAX_Center ; m_start_duration = 5 ; m_stop_duration = 5 ; m_manual_mode = false ; m_rx_state = IDLE ; m_tx_state = IDLE ; m_sample_rate = 0 ; reset_counters(); int index_of_correlation ; /// http://en.wikipedia.org/wiki/Radiofax switch(fax_mode) { default: case MODE_WEFAX_576: m_apt_start_freq = 300 ; index_of_correlation = IOC_576 ; m_default_lpm = 120 ; break; case MODE_WEFAX_288: m_apt_start_freq = 675 ; index_of_correlation = IOC_288 ; m_default_lpm = 60 ; break; } m_img_width = ioc_to_width(index_of_correlation); for(size_t i = 0; i<m_dbl_sine.size(); i++) { m_dbl_sine[i] = std::sin(2.0*M_PI*i/m_dbl_sine.size());// * 32768.0; } for(size_t i = 0; i<m_dbl_cosine.size(); i++) { m_dbl_cosine[i] = std::cos(2.0*M_PI*i/m_dbl_cosine.size()); // * 32768.0; } for(size_t i = 0; i<m_dbl_arc_sine.size(); i++) { m_dbl_arc_sine[i] = std::asin(2.0*i/m_dbl_arc_sine.size()-1.0)/2.0/M_PI; } for(size_t i = 0; i<m_short_sine.size(); i++) { m_short_sine[i] = static_cast<short>(32767*std::sin(2.0*M_PI*i/m_short_sine.size())); } }; void fax_implementation::init_rx(int the_smpl_rat) { m_sample_rate = the_smpl_rat; m_rx_state = RXAPTSTART; rx_state_changed = true; m_apt_count = m_apt_trans = 0; m_apt_high = false; /// Centers the carriers on the GUI and reinits the trigonometric tables. m_ptr_wefax->set_freq(progdefaults.WEFAX_Center); reset_increments(); m_i_fir_old = m_q_fir_old = 0; m_corr_calls_nb = 0; deviation_ratio = (m_sample_rate / progdefaults.WEFAX_Shift) / TWOPI; } /// Values are between zero and 255 void fax_implementation::decode(const int* buf, int nb_samples) { if (nb_samples == 0) { LOG_WARN(_("Empty buffer.")); end_rx(); } fax_signal my_signal(this); process_afc(); for(int i = 0; i<nb_samples; i++) { int crr_val = buf[i]; my_signal.refresh(); m_current_value = crr_val; correlation_update(crr_val); if (m_manual_mode) { m_rx_state = RXIMAGE; rx_state_changed = true; bool is_max_lines_reached = decode_image(crr_val); if (is_max_lines_reached) { skip_apt_rx(); skip_phasing_rx(false); LOG_DEBUG(_("Max lines reached in manual mode: Resuming reception.")); if (m_manual_mode == false) { LOG_ERROR(_("Inconsistent manual mode.")); } } } else { decode_apt(crr_val,my_signal); if (m_rx_state == RXPHASING || m_rx_state == RXIMAGE) { decode_phasing(crr_val, my_signal); } if ((m_rx_state == RXIMAGE) && m_lpm_img > 0) { /// If the maximum number of lines is reached, we stop the reception. decode_image(crr_val); } } m_img_sample++; } if (rx_state_changed) { std::string str_state; switch(m_rx_state) { case RXAPTSTART : str_state = "APT start"; break; case RXAPTSTOP : str_state = "APT stop"; break; case RXPHASING : str_state = "Rx Phasing"; break; case RXIMAGE : str_state = "Rx Image"; break; default : case IDLE : str_state = "Idle"; break; } put_Status2(str_state.c_str()); rx_state_changed = false; } } // The number of transitions between black and white is counted. After 1/2 // second, the frequency is calculated. If it matches the APT start frequency, // the state skips to the detection of phasing lines, if it matches the apt // stop frequency two times, the reception is ended. void fax_implementation::decode_apt(int x, const fax_signal & the_signal) { if ((m_img_sample % 10000) == 0) { PUT_STATUS(state_rx_str() << " apt_count = " << m_apt_count); } /// Maybe the thresholds 229 and 25 should be changed if the image is not contrasted enough. // if (x>229 && !m_apt_high) { if (x>215 && !m_apt_high) { m_apt_high = true; ++m_apt_trans; // } else if (x<25 && m_apt_high) { } else if (x<40 && m_apt_high) { m_apt_high = false; } ++m_apt_count ; /// This makes one line if LPM = 120: // samples_per_line = m_sample_rate * 60.0 / the_lpm ; if (m_apt_count >= m_sample_rate/2) { static int curr_freq = 0 ; static int cr_1_freq = 0 ; static int cr_2_freq = 0 ; static int cr_3_freq = 0 ; // For APT start, we have several lines with freq=300 nearly exactly. // For APT stop, one or two lines maximum with freq=452, and this is not accurate. // On top of that, sometimes lines randomly have 300 or 452 black-white transitions, // especially if the signal is very noisy. This is why we check the transitions // frequency of two consecutive lines. cr_3_freq = cr_2_freq; cr_2_freq = cr_1_freq; cr_1_freq = curr_freq; curr_freq = m_sample_rate*m_apt_trans/m_apt_count; /// This writes the S/R level on the status bar. double tmp_snr = the_signal.image_noise_ratio(); char snr_buffer[64]; snprintf(snr_buffer, sizeof(snr_buffer), "s/n %3.0f dB", 20.0 * log10(tmp_snr)); put_Status1(snr_buffer); LOG_DEBUG("m_apt_count = %d m_apt_trans = %d curr_freq = %d cr_1_freq = %d cr_2_freq = %d", m_apt_count, m_apt_trans, curr_freq, cr_1_freq, cr_2_freq); m_apt_count = m_apt_trans = 0; if (m_rx_state == RXAPTSTART) { if (is_near_freq(curr_freq,m_apt_start_freq, 8) && is_near_freq(cr_1_freq,m_apt_start_freq, 8)) { LOG_VERBOSE(_("Skipping APT freq = %d State = %s"), curr_freq, state_rx_str()); skip_apt_rx(); PUT_STATUS(state_rx_str() << ", " << _("frequency") << ": " << curr_freq << " Hz. " << _("Skipping.")); return ; } if (is_near_freq(curr_freq,m_apt_stop_freq, 2) && is_near_freq(cr_1_freq,m_apt_stop_freq, 2)) { LOG_VERBOSE(_("Spurious APT stop frequency = %d Hz as waiting for APT start. SNR = %f State = %s"), curr_freq, tmp_snr, state_rx_str()); return ; } PUT_STATUS(state_rx_str() << ", " << _("frequency") << ": " << curr_freq << " Hz."); } /// If APT start in the middle of an image, maybe the preceding APT Stop was not caught. if (m_rx_state == RXIMAGE) { /// TODO: We could enhance accuracy by taking into account the number of read lines. int crr_row = m_img_sample / m_smpl_per_lin ; const char * msg_start = NULL ; if (is_near_freq(curr_freq,m_apt_start_freq, 4) && is_near_freq(cr_1_freq,m_apt_start_freq, 4) && is_near_freq(cr_2_freq,m_apt_start_freq, 4)) { msg_start = "apt"; } else if (is_near_freq(curr_freq,m_apt_start_freq, 5) && is_near_freq(cr_1_freq,m_apt_start_freq, 5) && is_near_freq(cr_2_freq,m_apt_start_freq, 5) && is_near_freq(cr_3_freq,m_apt_start_freq, 5)) { msg_start = "apt2"; } if (msg_start != NULL) { std::string comment = strformat( "APT start: freq = %d cr_1 = %d cr_2 = %d cr_3 = %d crr_row = %d State = %s msg = %s", curr_freq, cr_1_freq, cr_2_freq, cr_3_freq, crr_row, state_rx_str(), msg_start); LOG_VERBOSE("%s",comment.c_str()); PUT_STATUS(state_rx_str() << ", " << _("frequency") << ": " << curr_freq << " Hz. " << _("Skipping.")); save_automatic(msg_start,comment); skip_apt_rx(); return ; } } /// TODO: Check that the correlation is not too high because there are false stops. const char * msg_stop = NULL ; if (is_near_freq(curr_freq,m_apt_stop_freq, 6) && is_near_freq(cr_1_freq,m_apt_stop_freq, 6)) { msg_stop = "ok" ; } else if (is_near_freq(curr_freq,m_apt_stop_freq, 7) && is_near_freq(cr_1_freq,m_apt_stop_freq, 7) && is_near_freq(cr_2_freq,m_apt_stop_freq, 7)) { msg_stop = "ok2" ; } if (msg_stop != NULL) { std::string comment = strformat( "APT Stop: curr_freq = %d m_img_sample = %d State = %s_ msg = %s", curr_freq, m_img_sample, state_rx_str(), msg_stop); LOG_VERBOSE("%s",comment.c_str()); PUT_STATUS(state_rx_str() << " " << _("Apt stop frequency") << ": " << curr_freq << " Hz. " << _("Stopping.")); save_automatic(msg_stop,comment); return ; } switch(the_signal.signal_state()) { case RXAPTSTART : switch(m_rx_state) { case RXAPTSTART : skip_apt_rx(); LOG_VERBOSE("Start, start: %s", the_signal.signal_text()); break ; default : LOG_DEBUG("Start, %s: %s", state_rx_str(), the_signal.signal_text()); break ; } break ; case RXPHASING : switch(m_rx_state) { case RXAPTSTART : skip_apt_rx(); LOG_VERBOSE("Phasing, start: %s", the_signal.signal_text()); break ; default : LOG_DEBUG("Phasing, %s: %s", state_rx_str(), the_signal.signal_text()); break ; } break ; case RXIMAGE : switch(m_rx_state) { case RXAPTSTART : skip_apt_rx(); /// The phasing step will start receiving the image later. First we try /// to phase the image correctly. LOG_VERBOSE("Image, start: %s", the_signal.signal_text()); break ; default : LOG_DEBUG("Image, %s: %s", state_rx_str(), the_signal.signal_text()); break ; } break ; case RXAPTSTOP : switch(m_rx_state) { case RXIMAGE : LOG_VERBOSE("Stop, image: %s", the_signal.signal_text()); save_automatic(the_signal.signal_stop_code(), the_signal.signal_text()); break; default : LOG_DEBUG("Stop, %s: %s", state_rx_str(), the_signal.signal_text()); break ; } break ; default : LOG_DEBUG("%s, %s: %s", state_to_str(the_signal.signal_state()), state_rx_str(), the_signal.signal_text()); break ; } } } /// This generates a file name with the reception time and the frequency. std::string fax_implementation::generate_filename(const char *extra_msg) const { time_t tmp_time = time(NULL); struct tm tmp_tm ; localtime_r(&tmp_time, &tmp_tm); char buf_fil_nam[256] ; long long tmp_fl = wf->rfcarrier() ; snprintf(buf_fil_nam, sizeof(buf_fil_nam), "wefax_%04d%02d%02d_%02d%02d%02d_%d_%s.png", 1900 + tmp_tm.tm_year, 1 + tmp_tm.tm_mon, tmp_tm.tm_mday, tmp_tm.tm_hour, tmp_tm.tm_min, tmp_tm.tm_sec, static_cast<int>(tmp_fl), extra_msg); return buf_fil_nam ; } /// This saves an image and adds the right comments. void fax_implementation::save_automatic( const char * extra_msg, const std::string & comment) { std::string new_filnam ; std::stringstream extra_comments ; /// These criteria used by rules-of-thumb to eliminate blank images. m_statistics.calc(); double avg = m_statistics.average(); double stddev = m_statistics.stddev(); int current_row = m_img_sample / m_smpl_per_lin ; /* Sometimes the AFC leaves the right frequency (Because no signal) and it produces * images which are plain wrong (Pure periodic parasites). We might find * a criteria to suppress them but maybe it's better to enhance AFC. */ /// Minimum pixel numbers for a valid image. static const int max_fax_pix_num = 150000 ; if (m_fax_pix_num < max_fax_pix_num) { /// Maybe we should reset AFC ? LOG_VERBOSE(_("Do not save small image (%d bytes). Manual = %d"), m_fax_pix_num, m_manual_mode); goto cleanup_rx ; } /// If correlation was always low. if (0 == strncmp(extra_msg, GARBAGE_STR, strlen(GARBAGE_STR))) { LOG_VERBOSE(_("Do not save garbage file")); goto cleanup_rx ; } static const double min_max_correlation = 0.20 ; if (m_imag_corr_max < min_max_correlation) { LOG_VERBOSE(_("Do not save image with correlation < less than %f"), min_max_correlation); goto cleanup_rx ; } /// Intermediate blank images, low standard deviation and correlation. if (((avg > 220) && (m_imag_corr_max < 0.30) && (stddev < 30)) || ((avg > 240) && (m_imag_corr_max < 0.35) && (stddev < 30)) || ((avg > 230) && (m_imag_corr_max < 0.25) && (stddev < 35)) || ((avg > 220) && (stddev < 20))) { LOG_VERBOSE(_("Do not save non-significant image, avg = %f, m_imag_corr_max = %f stddev = %f"), avg, m_imag_corr_max, stddev); goto cleanup_rx ; } /// Dark images coming from local parasites. if ((avg < 100) && (m_imag_corr_max < 0.30)) { LOG_VERBOSE(_("Do not save dark parasite image, avg = %f, m_imag_corr_max = %f"), avg, m_imag_corr_max); goto cleanup_rx ; } /// Same: Dark images due to parasites. if ((avg < 80) && (m_imag_corr_max < 0.35)) { LOG_VERBOSE(_("Do not save dark parasite image (II), avg = %f, m_imag_corr_max = %f"), avg, m_imag_corr_max); goto cleanup_rx ; } if ((avg > 235) && (m_imag_corr_max < 0.65) && (stddev < 40) && (current_row < 100)) { LOG_VERBOSE(_("Do not save small white image, avg = %f, m_imag_corr_max = %f stddev = %f current_row = %d"), avg, m_imag_corr_max, stddev, current_row); goto cleanup_rx ; } /// Small image cut between APT start and phasing. if ((avg < 130) && (m_imag_corr_max < 0.70) && (stddev < 100) && (current_row < 100)) { LOG_VERBOSE(_("Do not save small white image, avg = %f, m_imag_corr_max = %f stddev = %f current_row = %d"), avg, m_imag_corr_max, stddev, current_row); goto cleanup_rx ; } new_filnam = generate_filename(extra_msg); LOG_VERBOSE("Saving %d bytes in %s. m_imag_corr_max = %f", m_fax_pix_num, new_filnam.c_str(), m_imag_corr_max); extra_comments << "ControlMode:" << (m_manual_mode ? "Manual" : "APT control") << "\n" ; extra_comments << "LPM:" << m_lpm_img << "\n" ; extra_comments << "Carrier:" << m_carrier << "\n" ; extra_comments << "Inversion:" << (m_phase_inverted ? "Inverted" : "Normal") << "\n" ; extra_comments << "Color:" << (m_img_color ? "Color" : "BW") << "\n" ; extra_comments << "SampleRate:" << m_sample_rate << "\n" ; extra_comments << "Maximum line-to-line correlation:" << m_imag_corr_max << "\n" ; extra_comments << "Minimum line-to-line correlation:" << m_imag_corr_min << "\n" ; extra_comments << "Average:" << avg << "\n" ; extra_comments << "Row number:" << current_row << "\n" ; extra_comments << "Standard deviation:" << stddev << "\n" ; extra_comments << "Comment:" << comment << "\n" ; extra_comments << "PID:" << getpid() << "\n" ; wefax_pic::save_image(new_filnam, extra_comments.str()); cleanup_rx: /// This clears the current image. end_rx(); }; // Phasing lines consist of 2.5% white at the beginning, 95% black and again // 2.5% white at the end (or inverted). In normal phasing lines we try to // count the length between the white-black transitions. If the line has // a reasonable amount of black (4.8%--5.2%) and the length fits in the // range of 60--360 lpm (plus some tolerance) it is considered a valid // phasing line. Then the start of a line and the lpm is calculated. void fax_implementation::decode_phasing(int x, const fax_signal & the_signal) { static const bool filter_phasing = true ; if (filter_phasing) { // The input is filtered over X columns because the blacks bands are very wide. static const size_t phasing_width = 16 ; static size_t phasing_count = 0 ; static int phasing_history[ phasing_width ]; /// Mobile average filters out parasites. phasing_history[ phasing_count % phasing_width ] = x ; ++phasing_count ; if (phasing_count >= phasing_width) { x = 0 ; for(size_t i = 0; i < phasing_width; ++i) x += phasing_history[ i ]; x /= phasing_width ; } } /// Number of samples per line. m_curr_phase_len++; ++m_phasing_calls_nb ; /// Number of white / black pixels. if (x > 188) m_curr_phase_high++; else if (x < 68) m_curr_phase_low++; /* If the high level is too high (229) we miss some phasing lines. * but if it is too low (200) the center is not at the right place. * We should instead use an histogram and determine what is the highest level in the image. */ // if ((!m_phase_inverted && x>229 && !m_phase_high) || if ((!m_phase_inverted && x > 200 && !m_phase_high) || (m_phase_inverted && x < 25 && m_phase_high)) { m_phase_high = m_phase_inverted ? false : true; } else if ((!m_phase_inverted && x < 25 && m_phase_high) || (m_phase_inverted && x > 200 && !m_phase_high)) { m_phase_high = m_phase_inverted ? true : false; /// In the phasing line, there is a white segment of 5% of the total length, // so it is approximated with 0.048->0.052. if (m_curr_phase_high >= (m_phase_inverted ? 0.94 : 0.04) * m_curr_phase_len && m_curr_phase_low >= (m_phase_inverted ? 0.04 : 0.94) * m_curr_phase_len && m_curr_phase_len >= 0.4 * m_sample_rate) { double tmp_lpm = 60.0 * m_sample_rate / m_curr_phase_len; m_lpm_sum_rx += tmp_lpm; ++m_phase_lines; PUT_STATUS(state_rx_str() << ". " << _("Decoding phasing line") << ", lpm = " << tmp_lpm << " " << _("count") << "=" << m_phase_lines); m_num_phase_lines = 0; // This option was selected just once, in the middle of an image, // with many vertical lines. if (m_phase_lines >= 4 /* Was 4 */) { /// The precision cannot really increase because there cannot // be more than a couple of loops. This is used for guessing // whether the LPM is around 120 or 60. lpm_set(m_lpm_sum_rx / m_phase_lines); std::string comment = strformat( "m_phase_lines = %d, m_num_phase_lines = %d, LPM = %f State = %s, \ m_img_sample = %d, m_last_col = %d, m_lpm_img = %f, m_smpl_per_lin = %f", m_phase_lines, m_num_phase_lines, m_lpm_img, state_rx_str(), m_img_sample, m_last_col, m_lpm_img, m_smpl_per_lin); LOG_VERBOSE("%s", comment.c_str()); skip_phasing_to_image_save(comment); /// reset_counters sets these to zero, so restore right values. // But skip_phasing_to_image normalizes the LPM if not accurate. /// Half of the band of the phasing line. m_img_sample = static_cast<int>(1.025 * m_smpl_per_lin); double tmp_pos = std::fmod(m_img_sample,m_smpl_per_lin) / m_smpl_per_lin; m_last_col = static_cast<int>(tmp_pos*m_img_width); /// Now the image will start at the right column offset. m_fax_pix_num = m_last_col * bytes_per_pixel ; LOG_VERBOSE("Center set: m_last_col = %d m_img_width = %d m_smpl_per_lin = %f", m_last_col, m_img_width, m_smpl_per_lin); } m_curr_phase_len = 0; } else if (m_rx_state == RXPHASING && m_phase_lines > 0 && ++m_num_phase_lines >= 5) { /// TODO: Compare with m_tx_phasing_lin which indicates the number of phasing /// lines sent when transmitting an image. std::string comment = strformat( "Missed last phasing line m_phase_lines = %d m_num_phase_lines = %d LPM = %f State = %s", m_phase_lines, m_num_phase_lines, m_lpm_img, state_rx_str()); LOG_VERBOSE("%s", comment.c_str()); /// Phasing header is finished but could not get the center. skip_phasing_to_image(true); } else if (m_curr_phase_len > 5*m_sample_rate) { m_curr_phase_len = m_curr_phase_high = m_curr_phase_low = 0; PUT_STATUS(state_rx_str() << ". " << _("Decoding phasing line, resetting.")); } else { /// Here, if no phasing is detected. Must be very fast. } PUT_STATUS(state_rx_str() << ". " << _("Decoding phasing line, reset.")); m_curr_phase_len = m_curr_phase_high = m_curr_phase_low = 0; } else if (m_rx_state == RXPHASING) { /// We do not know the LPM so we assume the default. /// TODO: We could take the one given by the GUI. Apparently; problem for Japanese faxes when lpm = 60: // http://forums.radioreference.com/digital-signals-decoding/228802-problems-decoding-wefax.html double smpl_per_lin = lpm_to_samples(m_default_lpm); int smpl_per_lin_int = smpl_per_lin ; int nb_tested_phasing_lines = m_phasing_calls_nb / smpl_per_lin ; /// If this is too big, we lose the beginning of the fax. // If this is too small, we start recording when we should not (But why not starting early ?) // Value was: 30 static const int max_tested_phasing_lines = 20 ; if ( (m_phase_lines == 0) && (m_num_phase_lines == 0) && (nb_tested_phasing_lines >= max_tested_phasing_lines) && ((m_phasing_calls_nb % smpl_per_lin_int) == 0)) { switch(the_signal.signal_state()) { case RXIMAGE : LOG_VERBOSE(_("Starting reception when phasing:%s"), the_signal.signal_text()); skip_phasing_to_image(true); break ; /// If RXPHASING, we stay in phasing mode. case RXAPTSTOP : /// Do not display the same message over and over. LOG_DEBUG(_("Strong APT stop when phasing:%s"), the_signal.signal_text()); end_rx(); skip_apt_rx(); default : break ; } } } } bool fax_implementation::decode_image(int x) { double current_row_dbl = m_img_sample / m_smpl_per_lin ; int current_row = current_row_dbl ; int curr_col = m_img_width * (current_row_dbl - current_row) ; if (curr_col == m_last_col) { m_pixel_val+=x; m_pix_samples_nb++; } else { if (m_pix_samples_nb>0) { m_pixel_val /= m_pix_samples_nb; REQ(wefax_pic::update_rx_pic_bw, m_pixel_val, m_fax_pix_num); m_statistics.add_bw(m_pixel_val); m_fax_pix_num += bytes_per_pixel ; } m_last_col = curr_col; m_pixel_val = x; m_pix_samples_nb = 1; } /// Prints the status from time to time. if ((m_img_sample % 10000) == 0) { PUT_STATUS(state_rx_str() << ". " << _("Image reception") << ", " << _("sample") << "=" << m_img_sample); } /// Hard-limit to the number of rows. if (current_row >= progdefaults.WEFAX_MaxRows) { std::string comment = strformat(_("Maximum number of rows %d reached:%d. m_last_col = %d Manual = %d"), progdefaults.WEFAX_MaxRows, current_row, m_last_col, m_manual_mode); LOG_VERBOSE("%s", comment.c_str()); /// The reception might be very poor, so reset AFC. reset_afc(); save_automatic("max",comment); return true ; } else { return false ; } } /// Called automatically or by the GUI, when clicking "Skip APT" void fax_implementation::skip_apt_rx(void) { LOG_VERBOSE("state = %s",state_rx_str()); REQ(wefax_pic::skip_rx_apt); if (m_rx_state!= RXAPTSTART) { LOG_ERROR(_("Should be in APT state. State = %s. Manual = %d"), state_rx_str(), m_manual_mode); } lpm_set(0); m_rx_state = RXPHASING; rx_state_changed = true; reset_phasing_counters(); m_img_sample = 0; /// Used for correlation between consecutive lines. m_imag_corr_max = 0.0 ; // Used for finally deciding whether it is worth saving the image. m_imag_corr_min = 1.0 ; // Used for finally deciding whether it is worth saving the image. m_statistics.reset(); } void fax_implementation::skip_phasing_to_image_save(const std::string & comment) { switch(m_rx_state) { /// Maybe we were still reading an image when the phasing band was detected. case RXIMAGE : LOG_VERBOSE("Detected phasing when in image state."); save_automatic("phasing",comment); skip_apt_rx(); break ; default: LOG_ERROR(_("Should be in phasing or image state. State = %s"), state_rx_str()); case RXPHASING: break ; } /// Because we might find a phasing band when reading an image. reset_phasing_counters(); /// Auto-centering by default. Beware that if an image is saved and /// if we lose samples, the alignment is lost. skip_phasing_to_image(false); } /// Called by the user when skipping phasing, /// or automatically when phasing is detected. void fax_implementation::skip_phasing_to_image(bool auto_center) { m_ptr_wefax->qso_rec_init(); REQ(wefax_pic::skip_rx_phasing, auto_center); m_rx_state = RXIMAGE; rx_state_changed = true; // For monochrome, LPM = 60, 90, 100, 120, 180, 240. For colour, LPM = 120, 240 // /// So we round to the nearest integer to avoid slanting. // int lpm_integer = wefax_pic::normalize_lpm(m_lpm_img); // if (m_lpm_img != lpm_integer) { // /// If we could not find a valid LPM, then set the default one for this mode (576/288). // lpm_integer = wefax_pic::normalize_lpm(m_default_lpm); // LOG_VERBOSE(_("LPM rounded from %f to %d. Manual = %d State = %s"), // m_lpm_img, lpm_integer, m_manual_mode, state_rx_str()); // } // /// From now on, m_lpm_img will never change and has a normalized value. // REQ(wefax_pic::update_rx_lpm, lpm_integer); // PUT_STATUS(state_rx_str() << ". " << _("Decoding phasing line LPM = ") << lpm_integer); // lpm_set(lpm_integer); lpm_set(m_default_lpm); } /// Called by the user when clicking button. Never called automatically. void fax_implementation::skip_phasing_rx(bool auto_center) { if (m_rx_state!= RXPHASING) { LOG_ERROR(_("Should be in phasing state. State = %s"), state_rx_str()); } skip_phasing_to_image(auto_center); /// We force these two values because these could not be detected automatically. // if (m_lpm_img != m_default_lpm) { // lpm_set(m_default_lpm); // LOG_VERBOSE(_("Forcing m_lpm_img = %f. Manual = %d"), m_lpm_img, m_manual_mode); // } m_img_sample = 0; /// The image start may not be what the phasing would have told. } // Here we want to remove the last detected phasing line and the following // non phasing line from the beginning of the image and one second of apt stop // from the end void fax_implementation::end_rx(void) { /// Synchronized otherwise there might be a crash if something tries to access the data. REQ(wefax_pic::abort_rx_viewer); m_rx_state = RXAPTSTART; rx_state_changed = true; reset_counters(); } #define CLIP 0.001 /// Receives data from the soundcard. void fax_implementation::rx_new_samples(const double* audio_ptr, int audio_sz) { int demod[audio_sz]; int ix = 0; /// The reception filter may have been changed by the GUI. if (progdefaults.wefax_filter > 2 || progdefaults.wefax_filter < 0) progdefaults.wefax_filter = 0; C_FIR_filter & ref_fir_filt_pair = m_rx_filters[ progdefaults.wefax_filter]; for (int i = 0; i < audio_sz; i++) { if (!ref_fir_filt_pair.run( cmplx (audio_ptr[i] * m_dbl_cosine.next_value(), audio_ptr[i] * m_dbl_sine.next_value()), currz)) continue; if (abs(currz) <= CLIP && abs(prevz) <= CLIP) demod[i] = 255; // white else { ix = round (255 * (0.5 - deviation_ratio * arg (conj (prevz) * currz))); demod[i] = std::min (std::max (0, ix), 255); } prevz = currz; } decode(demod, audio_sz); } // Init transmission. Called once only. void fax_implementation::init_tx(int the_smpl_rat) { m_sample_rate = the_smpl_rat; set_carrier(progdefaults.WEFAX_Center); /// These reset increments of trigo tables. m_ptr_wefax->set_freq(progdefaults.WEFAX_Center); m_tx_state = TXAPTSTART; } /// Elements of buffer are between 0.0 and 1.0 void fax_implementation::modulate(const double* buffer, int number) { double *stack = new double[number]; double tmp_freq = 0; for(int i = 0; i < number; i++) { tmp_freq = m_carrier + 2.0 * (buffer[i] - 0.5) * fm_deviation ; m_dbl_sine.set_increment(m_dbl_sine.size() * tmp_freq / m_sample_rate); stack[i] = m_dbl_sine.next_value(); } m_ptr_wefax->ModulateXmtr(stack, number); delete [] stack; } /// START 5 seconds /// SYNC 20 lines => 10 seconds if LPM = 120 /// IMAGE /// STOP 5 seconds /// BLACK 10 seconds bool fax_implementation::trx_do_next(void) { LOG_DEBUG("m_lpm_img = %f", m_lpm_img); /// The number of samples sent for one line. The LPM is given by the GUI. const int smpl_per_lin = m_smpl_per_lin; static const int block_len = 256;//1024; double *buf = new double[block_len]; bool end_of_loop = false ; bool tx_completed = true ; int curr_sample_idx = 0 , nb_samples_to_send = 0 ; double phase_pos; const char * curr_status_msg = 0; for (int num_bytes_to_write = 0; ; ++num_bytes_to_write) { if ((num_bytes_to_write % block_len == 0) && (num_bytes_to_write > 0)) { modulate(buf, num_bytes_to_write); curr_status_msg = state_to_str(m_tx_state); if (m_ptr_wefax->is_tx_finished(curr_sample_idx, nb_samples_to_send, curr_status_msg)) { end_of_loop = true ; tx_completed = false; continue ; } num_bytes_to_write = 0 ; } if (end_of_loop) { break ; } if (m_tx_state == TXAPTSTART) { nb_samples_to_send = m_sample_rate * m_start_duration ; if (curr_sample_idx < nb_samples_to_send) { buf[num_bytes_to_write] = 0.5 - (m_carrier - m_apt_start_freq) / (2.0 * fm_deviation); curr_sample_idx++; } else { m_tx_state = TXPHASING; curr_sample_idx = 0; } } if (m_tx_state == TXPHASING) { nb_samples_to_send = smpl_per_lin * m_tx_phasing_lin ; if (curr_sample_idx < nb_samples_to_send) { phase_pos = (double)(curr_sample_idx % smpl_per_lin) / (double)smpl_per_lin; buf[num_bytes_to_write] = (phase_pos < 0.025 || phase_pos >= 0.975) ? (m_phase_inverted ? 0.0 : 1.0) : (m_phase_inverted ? 1.0 : 0.0); curr_sample_idx++; } else { m_tx_state = ENDPHASING; curr_sample_idx = 0; } } if (m_tx_state == ENDPHASING) { nb_samples_to_send = smpl_per_lin ; if (curr_sample_idx < nb_samples_to_send) { buf[num_bytes_to_write] = m_phase_inverted ? 0.0 : 1.0; curr_sample_idx++; } else { m_tx_state = TXIMAGE; curr_sample_idx = 0; } } if (m_tx_state == TXIMAGE) { /// The image must be stretched so that its width matches the fax width, /// which cannot change because because it depends on the LPM. /// Accordingly the height is stretched. /// For LPM = 120 and sample rate = 11025 Hz, smpl_per_lin = 5512. double ratio_img_to_fax = 1.0 * m_img_width / m_img_tx_cols ; double ratio_pow = 1.0 * smpl_per_lin / m_img_tx_cols; nb_samples_to_send = m_img_tx_cols * m_img_tx_rows * ratio_pow; if (curr_sample_idx < nb_samples_to_send) { int tmp_col = (double)(curr_sample_idx % smpl_per_lin) * (double)m_img_tx_cols / smpl_per_lin; int tmp_row = (double)(curr_sample_idx / smpl_per_lin);// * (double)m_img_tx_cols / m_img_width; if (tmp_row >= m_img_tx_rows) { LOG_ERROR("Inconsistent tmp_row = %d m_img_tx_rows = %d " "curr_sample_idx = %d smpl_per_lin = %d " "ratio_img_to_fax = %f nb_samples_to_send = %d", tmp_row, m_img_tx_rows, curr_sample_idx, smpl_per_lin, ratio_img_to_fax, nb_samples_to_send); exit(EXIT_FAILURE); } /* if ((curr_sample_idx % smpl_per_lin) == 0) { printf("\ idx: %d, row: %d, spl: %d, Nsmpls: %d, %d x %d x %f, miw: %d\n", curr_sample_idx, tmp_row, smpl_per_lin, nb_samples_to_send, m_img_tx_cols, m_img_tx_rows, ratio_pow, m_img_width); } */ int byte_offset = bytes_per_pixel * (tmp_row * m_img_tx_cols + tmp_col); unsigned char temp_pix = m_xmt_pic_buf[ byte_offset ]; curr_sample_idx++; REQ(wefax_pic::set_tx_pic, temp_pix, tmp_col, tmp_row, m_img_color); buf[num_bytes_to_write] = (double)temp_pix / 256.0 ; } else { m_tx_state = TXAPTSTOP; curr_sample_idx = 0; } } if (m_tx_state == TXAPTSTOP) { nb_samples_to_send = m_sample_rate * m_stop_duration ; if (curr_sample_idx < nb_samples_to_send) { buf[num_bytes_to_write] = 0.5 - (m_carrier - m_apt_stop_freq) / (2.0 * fm_deviation); curr_sample_idx++; } else { m_tx_state = TXBLACK; curr_sample_idx = 0; continue; } } if (m_tx_state == TXBLACK) { nb_samples_to_send = m_sample_rate * 10; // 10 seconds of black if (curr_sample_idx < nb_samples_to_send) { buf[num_bytes_to_write] = 0; curr_sample_idx++; } else { m_tx_state = IDLE; end_of_loop = true ; continue ; } } } // loop delete [] buf; return tx_completed ; } void fax_implementation::tx_params_set( int the_lpm, const unsigned char * xmtpic_buffer, bool is_color, int img_w, int img_h) { LOG_DEBUG("img_w = %d img_h = %d the_lpm = %d is_color = %d", img_w, img_h, the_lpm, (int)is_color); m_img_tx_rows = img_h; m_img_tx_cols = img_w; m_img_color = is_color ; lpm_set(the_lpm); m_xmt_pic_buf = xmtpic_buffer ; PUT_STATUS(_("Sending wefax_map.") << _(" rows = ") << m_img_tx_rows << _(" cols = ") << m_img_tx_cols); } void fax_implementation::tx_apt_stop(void) { m_tx_state = TXAPTSTOP; } // --------------------------------------------------------------------- // // --------------------------------------------------------------------- /// Called by trx_trx_transmit_loop void wefax::tx_init() { videoText(); // In trx/modem.cxx m_impl->init_tx(modem::samplerate) ; } /// This updates the window label according to the state. void wefax::update_rx_label(void) const { std::string tmp_label(_("Reception ")); tmp_label += mode_info[modem::mode].name ; if (m_impl->manual_mode_get()) { tmp_label += _(" - Manual") ; } else { tmp_label += _(" - APT control") ; } REQ(wefax_pic::set_rx_label, tmp_label); } void wefax::rx_init() { put_MODEstatus(modem::mode); m_impl->init_rx(modem::samplerate) ; REQ(wefax_pic::resize_rx_viewer, m_impl->fax_width()); } void wefax::init() { modem::init(); /// TODO: Maybe remove, probably not necessary because called by trx_trx_loop rx_init(); /// TODO: Display scope. set_scope_mode(Digiscope::SCOPE); } void wefax::shutdown() { } wefax::~wefax() { modem::stopflag = true; /// Maybe we are receiving an image, this must be stopped. end_reception(); /// Maybe we are sending an image. REQ(wefax_pic::abort_tx_viewer); activate_wefax_image_item(false); delete m_impl ; /// Not really useful, just to help debugging. m_impl = 0 ; } wefax::wefax(trx_mode wefax_mode) : modem() { /// Beware that it is already set by modem::modem modem::cap |= CAP_AFC | CAP_REV | CAP_IMG ; LOG_DEBUG("wefax_mode = %d", (int)wefax_mode); wefax::mode = wefax_mode; modem::samplerate = 11025; m_impl = new fax_implementation(wefax_mode, this); /// Now this object is usable by wefax_pic. wefax_pic::setwefax_map_link(this); int tmpShift = progdefaults.WEFAX_Shift ; if ( (progdefaults.WEFAX_Shift < 100) || (progdefaults.WEFAX_Shift > 1000)) { static const int standard_shift = 800; LOG_WARN("Invalid weather fax shift: %d. setting standard value: %d", progdefaults.WEFAX_Shift, standard_shift); tmpShift = standard_shift ; } fm_deviation = tmpShift / 2 ; modem::bandwidth = fm_deviation * 2 ; m_abortxmt = false; modem::stopflag = false; // There is only one instance of the reception and transmission // windows, therefore only static methods. wefax_pic::create_both(false); /// This updates the window label. set_rx_manual_mode(false); activate_wefax_image_item(true); init(); } //---------------------------------------------------------------------- // receive processing //---------------------------------------------------------------------- /// This must return the current time in seconds with high precision. #if defined(__WIN32__) || defined(__APPLE__) #include <ctime> /// This is much less accurate. static double current_time(void) { clock_t clks = clock(); return clks * 1.0 / CLOCKS_PER_SEC; } #else #if defined(HAVE_CLOCK_GETTIME) #include <sys/time.h> static double current_time(void) { // DJV/AB3NR // Replace call to deprecated ftime() function with call to // clock_gettime(2). clock_gettime(2) is POSIX.1 compliant. // Replace ifdef __linux__ with autoconf generated guard. // (Note __linux__ fails for *BSD, which all have better functions // than the fallback Windows routine. Note, clock(2) on Unix systems // returns CPU time used so far. It's not a "clock" in any generally // accepted sense of the word. // // Check system call return codes and abort on failure. // DJV/AB3NR struct timespec ts; double curtime; // Do not know if CLOCK_MONOTONIC or CLOCK_REALTIME is appropriate. DJV if (clock_gettime(CLOCK_REALTIME, &ts) != 0) { LOG_PERROR("clock_gettime"); abort(); } curtime = ts.tv_nsec*1e-09 + (double)ts.tv_sec; return curtime; } #else #include <ctime> // This is much less accurate. // Add compile time warning DJV/AB3NR #warning imprecise clock() call in function current_time in wefax.cxx static double current_time(void) { clock_t clks = clock(); return clks * 1.0 / CLOCKS_PER_SEC; } #endif // HAVE_CLOCK_GETTIME #endif //__WIN32__ /// Callback continuously called by fldigi modem class. int wefax::rx_process(const double *buf, int len) { if (len == 0 || len > 512) return 0 ; static const int avg_buf_size = 256 ; static int idx = 0 ; static double buf_tim[avg_buf_size]; static int buf_len[avg_buf_size]; int idx_mod = idx % avg_buf_size ; /// Here we estimate the average number of pixels per second. buf_tim[idx_mod] = current_time(); buf_len[idx_mod] = len ; ++idx ; /// Wait some seconds otherwise not significant. if (idx >= avg_buf_size) { if (idx == avg_buf_size) { LOG_VERBOSE(_("Starting samples loss control avg_buf_size = %d"), avg_buf_size); } int idx_mod_first = idx % avg_buf_size ; double total_tim = buf_tim[idx_mod] - buf_tim[idx_mod_first]; int total_len = 0 ; for(int ix = 0 ; ix < avg_buf_size ; ++ix) { total_len += buf_len[ix] ; } /// Estimate the real sample rate. double estim_smpl_rate = (double)total_len / total_tim ; /// If too far from what it should be, it means that pixels were lost. if (estim_smpl_rate < 0.95 * modem::samplerate) { int expected_samples = (int)(modem::samplerate * total_tim + 0.5); int missing_samples = expected_samples - total_len ; LOG_VERBOSE(_("Lost %d samples idx = %d estim_smpl_rate = %f total_tim = %f total_len = %d. Auto-center."), missing_samples, idx, estim_smpl_rate, total_tim, total_len); // REQ(wefax_pic::update_auto_center, true); if (missing_samples <= 0) { /// This should practically never happen. LOG_WARN(_("Cannot compensate")); } else { /// Adjust the number of received pixels, /// so the lost frames are signaled once only. buf_len[idx_mod] += missing_samples ; } } } /// Back to normal processing. m_impl->rx_new_samples(buf, len); return 0; } //---------------------------------------------------------------------- // transmit processing //---------------------------------------------------------------------- /// This is called by wefax-pix.cxx before entering transmission loop. void wefax::set_tx_parameters( int the_lpm, const unsigned char * xmtpic_buffer, bool is_color, int img_w, int img_h) { m_impl->tx_params_set( the_lpm, xmtpic_buffer, is_color, img_w, img_h); } /// Callback continuously called by fldigi modem class. int wefax::tx_process() { modem::tx_process(); bool tx_was_completed = m_impl->trx_do_next(); std::string status ; if (!tx_was_completed) { status = _("Transmission cancelled"); LOG_VERBOSE("Sending cancelled"); m_qso_rec.putField(NOTES, status.c_str()); } REQ_FLUSH(GET_THREAD_ID()); wefax_pic::restart_tx_viewer(); transmit_lock_release(status); m_abortxmt = false; m_impl->tx_apt_stop(); return -1; } void wefax::skip_apt(void) { m_impl->skip_apt_rx(); } /// auto_center indicates whether we try to find the margin of the image /// automatically. This is the fact when skipping to image reception /// is triggered manually or based on the signal power. void wefax::skip_phasing(bool auto_center) { m_impl->skip_phasing_rx(auto_center); } void wefax::end_reception(void) { m_impl->end_rx(); } // Continuous reception or APT control. void wefax::set_rx_manual_mode(bool manual_flag) { m_impl->manual_mode_set(manual_flag); wefax_pic::set_manual(manual_flag); update_rx_label(); } void wefax::set_lpm(int the_lpm) { return m_impl->lpm_set(the_lpm); } /// Transmission time in seconds. Factor 3 if b/w image. int wefax::tx_time(int nb_bytes) const { return (double)nb_bytes / modem::samplerate ; } /// This prints a message about the progress of image sending, /// then tells whether the user has requested the end. bool wefax::is_tx_finished(int ix_sample, int nb_sample, const char * msg) const { static char wefaxmsg[256]; double fraction_done = nb_sample ? 100.0 * (double)ix_sample / nb_sample : 0.0 ; int tm_left = tx_time(nb_sample - ix_sample); snprintf( wefaxmsg, sizeof(wefaxmsg), "%s : %04.1f%%, %dm %ds remaining", msg, fraction_done, tm_left / 60, tm_left % 60); put_status(wefaxmsg); bool is_finished = modem::stopflag || m_abortxmt ; if (is_finished) { LOG_VERBOSE("Transmit finished"); } return is_finished ; } /// This returns the names of the possible reception filters. const char ** wefax::rx_filters(void) { return fir_filter_pair_set::filters_list(); } /// Allows to choose the reception filter. //void wefax::set_rx_filter(int idx_filter) //{ // m_impl->set_filter_rx(idx_filter); //} std::string wefax::suggested_filename(void) const { return m_impl->generate_filename("gui"); }; /// This creates a QSO record to be written to an adif file. void wefax::qso_rec_init(void) { /// This is always initialised because the flag progdefaults.WEFAX_AdifLog /// may be set in the middle of an image reception. /// Ideally we should find out the name of the fax station. m_qso_rec.putField(CALL, "Wefax"); m_qso_rec.putField(NAME, "Weather fax"); m_qso_rec.putField(TX_PWR, "0"); m_qso_rec.setDateTime(true); m_qso_rec.setFrequency(wf->rfcarrier() + m_impl->carrier()); m_qso_rec.putField(ADIF_MODE, mode_info[get_mode()].adif_name); } /// Called once a QSO rec has been filled with information. Saved to adif file. void wefax::qso_rec_save(void) { if (progdefaults.WEFAX_AdifLog == false) { return ; } m_qso_rec.setDateTime(false); qsodb.qsoNewRec (&m_qso_rec); qsodb.isdirty(0); loadBrowser(true); adifFile.writeLog (logbook_filename.c_str(), &qsodb); // dxcc_entity_cache_add(&rec); LOG_VERBOSE(_("Updating log book %s"), logbook_filename.c_str()); } /// Called when changing the carrier in the GUI, and by class modem with 1000Hz, when initializing. void wefax::set_freq(double freq) { modem::set_freq(freq); /// This must recompute the increments of the trigonometric tables. m_impl->set_carrier(freq); } // String telling the tx and rx internal state. std::string wefax::state_string(void) const { return m_impl->state_string(); } /// Called when a file is saved, so XML-RPC calls can get the filename. void wefax::put_received_file(const std::string &filnam) { m_impl->put_received_file(filnam); } /// Returns a received file name, by chronological order. std::string wefax::get_received_file(int max_seconds) { return m_impl->get_received_file(max_seconds); } std::string wefax::send_file(const std::string & filnam, double max_seconds) { return m_impl->send_file(filnam, max_seconds); } /// Transmitting files is done in exclusive mode. bool wefax::transmit_lock_acquire(const std::string & filnam, double max_seconds) { return m_impl->transmit_lock_acquire(filnam, max_seconds); } /// Called after a file is sent. void wefax::transmit_lock_release(const std::string & err_msg) { m_impl->transmit_lock_release(err_msg); }
84,207
C++
.cxx
2,253
34.339547
112
0.646858
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,231
wefax-pic.cxx
w1hkj_fldigi/src/wefax/wefax-pic.cxx
// ---------------------------------------------------------------------------- // wefax-pic.cxx -- wefax support functions // // Copyright (C) 2010 // Remi Chateauneu, F4ECW // // This file is part of fldigi. Adapted from code contained in HAMFAX source code // distribution. // Hamfax Copyright (C) Christof Schmitt // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <libgen.h> #include <string> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <time.h> #include <unistd.h> #include <FL/Fl_Widget.H> #include <FL/Fl_Button.H> #include <FL/Fl_Light_Button.H> #include <FL/Fl_Spinner.H> #include <FL/Fl_Output.H> #include <FL/Fl_Int_Input.H> #include <FL/Fl_Counter.H> #include <FL/Fl_Scroll.H> #include <FL/Fl_Counter.H> #include <FL/Fl_Select_Browser.H> #include <FL/Fl_Choice.H> #include <FL/Fl_Chart.H> #include <FL/Fl_Shared_Image.H> #include <FL/Enumerations.H> #include "wefax-pic.h" #include "debug.h" #include "configuration.h" #include "wefax.h" #include "trx.h" #include "fl_digi.h" #include "main.h" #include "fileselect.h" #include "wefax_map.h" #include "gettext.h" //Fl_Double_Window *wefax_pic_rx_win = (Fl_Double_Window *)0; Fl_Group *wefax_pic_rx_win = (Fl_Group *)0; Fl_Scroll *wefax_pic_rx_scroll = (Fl_Scroll *)0 ; static wefax_map *wefax_pic_rx_wefax_map = (wefax_map *)0; static Fl_Button *wefax_btn_rx_save = (Fl_Button *)0; static Fl_Button *wefax_btn_rx_abort = (Fl_Button *)0; static Fl_Button *wefax_btn_rx_pause = (Fl_Button *)0; static Fl_Button *wefax_btn_rx_resume = (Fl_Button *)0; static Fl_Choice *wefax_choice_rx_zoom = (Fl_Choice *)0; //static Fl_Browser *wefax_browse_rx_events = (Fl_Browser *)0; static Fl_Button *wefax_btn_rx_skip_apt = (Fl_Button *)0; static Fl_Button *wefax_btn_rx_skip_phasing = (Fl_Button *)0; Fl_Light_Button *wefax_round_rx_noise_removal = (Fl_Light_Button *)0; Fl_Light_Button *wefax_round_rx_binary = (Fl_Light_Button *)0; static Fl_Spinner *wefax_spinner_rx_binary = (Fl_Spinner *)0; Fl_Light_Button *wefax_round_rx_non_stop = (Fl_Light_Button *)0; static Fl_Output *wefax_out_rx_row_num = (Fl_Output *)0; //static Fl_Output *wefax_out_rx_width = (Fl_Output *)0; static Fl_Counter *wefax_cnt_rx_ratio = (Fl_Counter *)0; static Fl_Counter *wefax_rx_center = (Fl_Counter *)0; static Fl_Light_Button *wefax_autocenter = (Fl_Light_Button *)0; Fl_Double_Window *wefax_pic_tx_win = (Fl_Double_Window *)0; static Fl_Scroll *wefax_pic_tx_scroll = (Fl_Scroll *)0 ; static wefax_map *wefax_pic_tx_wefax_map = (wefax_map *)0; static wefax_picbox *wefax_pic_tx_box = (wefax_picbox *)0; static Fl_Choice *wefax_choice_tx_zoom = (Fl_Choice *)0; static Fl_Choice *wefax_choice_tx_lpm = (Fl_Choice *)0; static Fl_Button *wefax_btn_tx_send_color = (Fl_Button *)0; static Fl_Button *wefax_btn_tx_send_grey = (Fl_Button *)0; static Fl_Output *wefax_out_tx_row_num = (Fl_Output *)0; static Fl_Output *wefax_out_tx_col_num = (Fl_Output *)0; static Fl_Button *wefax_btn_tx_send_abort = (Fl_Button *)0; static Fl_Button *wefax_btn_tx_load = (Fl_Button *)0; static Fl_Button *wefax_btn_tx_clear = (Fl_Button *)0; static Fl_Button *wefax_btn_tx_close = (Fl_Button *)0; static void wefax_cb_pic_rx_center( Fl_Widget *, void *); /// The image to send. static Fl_Shared_Image *wefax_shared_tx_img = (Fl_Shared_Image *)0; /// This contains the original content of the image to send, /// converted into three bytes per pixel. static unsigned char *wefax_xmtimg = (unsigned char *)0; /// This indicates whether an image to send is loaded in the GUI. /// It allows to acquire twice when re-loading an image without sending. static bool wefax_image_loaded_in_gui = false ; /// Used for shifting the received image left and right. static int center_val_prev = 0 ; /// Global pointer to the current wefax modem. static wefax *wefax_serviceme = 0; /// TODO: This should be hidden in the class wefax_map. It is in wefax too. static const int bytes_per_pix = 3 ; /// Initial size of the reception image. A typical fax has about 1300 lines. static const int curr_pix_h_default = 1300 ; /// Always reset before loading a new image. static int curr_pix_height = curr_pix_h_default ; /// The antepenultimate line of the rx image is filtered to remove noise. static int rx_last_filtered_row = 0 ; static bool noise_removal = false ; /// Alters the slanting of the image based on LPM adjustments. static double rx_slant_ratio = 0.0 ; /// This transforms the user slant ratio (Small number around 0.0) /// into a ratio used to stretch the image (Very very small mantissa added to 1.0). static double slant_factor_default(void) { return 100.0 / ( rx_slant_ratio + 100.0 ); } static double slant_factor_with_ratio( double ratio_percent ) { return ( ratio_percent + 100.0 ) / ( rx_slant_ratio + 100.0 ); } /// When set by the user, no new pixel is added or printed. /// However, when the printing resumes, the position is not altered. static bool reception_paused = false ; /// Sets the label of the received or sent image. static void set_win_label( Fl_Window * wefax_pic, const std::string & lab) { char* label = strdup(lab.c_str()); wefax_pic->copy_label(label); free(label); wefax_pic->redraw(); } /// Called when clearing the image to send. static void clear_image(void) { ENSURE_THREAD(FLMAIN_TID); if (wefax_xmtimg) { delete [] wefax_xmtimg; wefax_xmtimg = NULL ; } if (wefax_shared_tx_img) { wefax_shared_tx_img->release(); wefax_shared_tx_img = 0; } set_win_label(wefax_pic_tx_win,""); } /// Clears the loaded image. It allows XML-RPC clients to send an image. static void wefax_cb_pic_tx_clear( Fl_Widget *, void *) { ENSURE_THREAD(FLMAIN_TID); wefax_image_loaded_in_gui = false ; clear_image(); wefax_pic_tx_wefax_map->clear(); wefax_pic_tx_wefax_map->resize(0,0,0,0); wefax_pic::restart_tx_viewer(); /// Now the lock can be acquired by XML-RPC. wefax_serviceme->transmit_lock_release( "Cleared" ); } /// According to config flags, shows or hides the transmission window, and resizes both windows if needed. static void wefax_pic_show_tx() { ENSURE_THREAD(FLMAIN_TID); wefax_pic_tx_win->show(); } static void wefax_cb_pic_tx_close( Fl_Widget *, void *) { ENSURE_THREAD(FLMAIN_TID); wefax_pic_tx_win->hide(); } /// Usual LPM values. static const struct { int m_value ; const char * m_label ; } all_lpm_values[] = { { 240, "240" }, { 120, "120" }, { 90, "90" }, { 60, "60" } }; static const int nb_lpm_values = sizeof(all_lpm_values) / sizeof(all_lpm_values[0]); /// Returns the LPM value choosed on the TX or RX window. static int get_choice_lpm_value( Fl_Choice * the_choice_lpm ) { int idx_lpm = the_choice_lpm->value(); if( ( idx_lpm < 0 ) || ( idx_lpm >= nb_lpm_values ) ) { LOG_WARN( "Invalid LPM index=%d", idx_lpm ); idx_lpm = 0 ; } return all_lpm_values[ idx_lpm ].m_value ; } /// Lpm=120 is by far the most common value, therefore used by default if nothing else works. /// wefax.cxx will always try 120 for wefax576 or 60 for wefax288. static const int lpm_default_idx = 1 ; static const char * title_choice_lpm = "LPM" ; /// Fills a FLTK widget with LPM vpossible values. Used for transmission and reception. static Fl_Choice * make_lpm_choice( int width_offset, int y_btn, int width_btn, int hei_tx_btn ) { Fl_Choice * choice_lpm = new Fl_Choice(width_offset, y_btn, width_btn, hei_tx_btn, title_choice_lpm ); for( int ix_lpm = 0 ; ix_lpm < nb_lpm_values ; ++ix_lpm ) { choice_lpm->add( all_lpm_values[ ix_lpm ].m_label ); }; choice_lpm->value(lpm_default_idx); choice_lpm->tooltip(_("Set the LPM value")); return choice_lpm ; } /// Sometimes the LPM can be calculated to 122.0 when it should be 120.0. int wefax_pic::normalize_lpm( double the_lpm ) { for( int ix_lpm = 0 ; ix_lpm < nb_lpm_values ; ++ix_lpm ) { int curr_lpm = all_lpm_values[ ix_lpm ].m_value ; if( std::fabs( the_lpm - curr_lpm ) < 3.0 ) { return curr_lpm ; } }; int dflt_lpm = all_lpm_values[ lpm_default_idx ].m_value ; LOG_VERBOSE("Out of bounds LPM=%f. Setting to default:%d", the_lpm, dflt_lpm ); return dflt_lpm ; } /// Called for each new color component. int wefax_pic::update_rx_pic_col(unsigned char data, int pix_pos ) { /// Each time the received image becomes too high, we increase its height. static const int curr_pix_incr_height = 100 ; /// Three ints per pixel. It is safer to recalculate the /// row index to avoid any buffer overflow, because the given /// row is invalid if the image was horizontally moved. int row_number = 1 + ( pix_pos / ( wefax_pic_rx_wefax_map->pix_width() * bytes_per_pix ) ); /// Maybe we must increase the image height. if( curr_pix_height <= row_number ) { curr_pix_height = row_number + curr_pix_incr_height ; wefax_pic_rx_wefax_map->resize_height( curr_pix_height, false ); int y_pos = wefax_pic_rx_wefax_map->h() - wefax_pic_rx_scroll->h() ; if( y_pos < 0 ) { y_pos = 0 ; } else { // Small margin at the bottom, so we can immediately see new lines. y_pos += 20 ; } wefax_pic_rx_wefax_map->position( wefax_pic_rx_wefax_map->x(), -y_pos ); wefax_pic_rx_scroll->redraw(); } wefax_pic_rx_wefax_map->pixel(data, pix_pos); return row_number ; } /// This estimates the colum of where the horizontal center of the image is, /// or rather, the beginning of the left margin. The estimation is done on /// a range of rows. It looks for a vertical band of X pixels, where the image /// derivative is the lowest. It works well with faxes because they always have /// a wide blank margin. //static int rowcount = 2; static int estimate_rx_image_center( int row_end , int numrows ) { if (row_end < numrows) return 0; /// This works as well with color images. int img_wid = wefax_pic_rx_wefax_map->pix_width() * bytes_per_pix ; unsigned const char * img_start = wefax_pic_rx_wefax_map->buffer(); /// The width of the image band on which we compute the minima /// of the absolute value of the video signal. /// Equal to the WEFAX start phasing width. #define AVG_WID 180 const unsigned char *pch = img_start; int avgs[img_wid]; memset(avgs, 0, img_wid * sizeof(*avgs)); int img_avg[img_wid]; memset(img_avg, 0, img_wid * sizeof(*img_avg)); // averages over numrows for (int col = 0; col < img_wid; col++) { int avgval = 0; Fl::awake(); for (int row = row_end - numrows; row < row_end; ++row) { avgval += (int)(pch[row * img_wid + col]); } avgs[col] = avgval / numrows; } int min_idx = -1; int min_val = 255; for (int col = 0; col < img_wid; col++) { for (int n = 0; n < AVG_WID; n++) img_avg[col] += avgs[(col + n) % img_wid]; img_avg[col] /= AVG_WID; if (img_avg[col] < min_val) { min_val = img_avg[col]; min_idx = col; } } if (min_idx > img_wid / 2) min_idx -= img_wid; min_idx += AVG_WID / 2; min_idx /= bytes_per_pix; // if (!rowcount) { // ofstream csvfile("img.csv"); // for (int col = 0; col < img_wid; ++col) // csvfile << avgs[col] << "," << img_avg[col] << std::endl; // csvfile.close(); // } else // --rowcount; if (min_val > 40) return 0; return min_idx; } /// Called for each bw pixel. void wefax_pic::update_rx_pic_bw(unsigned char data, int pix_pos ) { /// No pixel is added nor printed until this flag is reset to false. if( reception_paused ) { return ; }; /// The image must be horizontally shifted. pix_pos += center_val_prev * bytes_per_pix ; if( pix_pos < 0 ) { pix_pos = 0 ; } /// Maybe there is a slant. pix_pos = ( double )pix_pos * slant_factor_default() + 0.5 ; /// Must be a multiple of the number of bytes per pixel. pix_pos = ( pix_pos / bytes_per_pix ) * bytes_per_pix ; static int prev_row = 0; int row_number = 0; for (int n = 0; n < bytes_per_pix; n++) row_number = update_rx_pic_col(data, pix_pos + n); if (prev_row != row_number) { char row_num_buffer[20]; snprintf( row_num_buffer, sizeof(row_num_buffer), "%d", row_number ); wefax_out_rx_row_num->value( row_num_buffer ); prev_row = row_number; } if( noise_removal ) { if( ( row_number > wefax_map::noise_height_margin - 2 ) && ( row_number != rx_last_filtered_row ) ) { wefax_pic_rx_wefax_map->remove_noise( row_number, progdefaults.WEFAX_NoiseMargin, progdefaults.WEFAX_NoiseThreshold ); rx_last_filtered_row = row_number ; } } /// Recenter every X-th row static int last_row = 0; if ((row_number != last_row) && (row_number < progdefaults.wefax_align_stop) && (row_number > progdefaults.wefax_auto_after) && (row_number % progdefaults.wefax_align_rows == 0)) { last_row = row_number; int new_center = estimate_rx_image_center( row_number, progdefaults.wefax_align_rows ); if (progdefaults.wefax_autocenter) { if ( abs(new_center) > 3) { // 2 x depth of image wefax_rx_center->value(wefax_rx_center->value() - new_center); wefax_cb_pic_rx_center(NULL, NULL); } } } } static void wefax_cb_pic_rx_pause( Fl_Widget *, void *) { wefax_btn_rx_pause->hide(); wefax_btn_rx_resume->show(); reception_paused = true ; wefax_serviceme->update_rx_label(); } static void wefax_cb_pic_rx_resume( Fl_Widget *, void *) { wefax_btn_rx_pause->show(); wefax_btn_rx_resume->hide(); reception_paused = false ; wefax_serviceme->update_rx_label(); } static void wefax_cb_pic_rx_abort( Fl_Widget *, void *) { ENSURE_THREAD(FLMAIN_TID); if (wefax_serviceme != active_modem) return; /// This will call wefax_pic::abort_rx_viewer wefax_serviceme->end_reception(); wefax_round_rx_non_stop->value(false); wefax_serviceme->set_rx_manual_mode(false); wefax_round_rx_non_stop->redraw(); wefax_btn_rx_pause->show(); wefax_btn_rx_resume->hide(); } void wefax_pic::set_manual( bool manual ) { wefax_round_rx_non_stop->value(manual); } static void wefax_cb_pic_rx_manual( Fl_Widget *, void *) { if (wefax_serviceme != active_modem) return; if( wefax_round_rx_non_stop->value() ) { wefax_serviceme->set_rx_manual_mode(true); wefax_serviceme->skip_apt(); wefax_serviceme->skip_phasing(true); } else { wefax_serviceme->set_rx_manual_mode(false); } } static void wefax_cb_pic_rx_center( Fl_Widget *, void *) { if (wefax_serviceme != active_modem) return; ENSURE_THREAD(FLMAIN_TID); int center_new_val = wefax_rx_center->value(); int center_delta = center_new_val - center_val_prev ; center_val_prev = center_new_val ; wefax_pic_rx_wefax_map->shift_horizontal_center( center_delta ); } static void cb_wefax_autocenter( Fl_Widget *, void *) { if (wefax_serviceme != active_modem) return; progdefaults.wefax_autocenter = wefax_autocenter->value(); return; } /// This gets the directory where images are accessed by default. static std::string default_dir_get( const std::string & config_dir ) { std::string tmp_dir = config_dir.empty() ? PicsDir : config_dir ; /// Valid dir names must end with a slash. if( ! tmp_dir.empty() ) { char termin = tmp_dir[ tmp_dir.size() - 1 ]; if( ( termin != '/' ) && ( termin != '\\' ) ) tmp_dir += '/'; } return tmp_dir ; } /// This sets the directory where images are accessed by default. /// Receives a file name, not a directory name. static void default_dir_set( std::string & config_dir, const std::string & fil_name ) { char * fil_nam_copy = strdup( fil_name.c_str() ); /// dirname() is a POSIX function. const char * dir_nam = dirname( fil_nam_copy ); config_dir = dir_nam + std::string("/"); LOG_VERBOSE("Setting default dir to %s", dir_nam ); free( fil_nam_copy ); } /// Adds the file name to log to the adif file. static void qso_notes( const char * direction, const std::string & file_name ) { if( progdefaults.WEFAX_AdifLog == false ) { return ; } const std::string tmp_notes = direction + file_name ; wefax_serviceme->qso_rec().putField( NOTES, tmp_notes.c_str() ); } static void wefax_cb_pic_rx_save( Fl_Widget *, void *) { ENSURE_THREAD(FLMAIN_TID); const char ffilter[] = "Portable Network Graphics\t*.png\n"; std::string dfname = default_dir_get( progdefaults.wefax_save_dir ); dfname.append( wefax_serviceme->suggested_filename() ); const char *file_name = FSEL::saveas(_("Save image as:"), ffilter, dfname.c_str(), NULL); /// Beware that no extra comments are saved here. if (!file_name) return; if (!*file_name) return; wefax_pic_rx_wefax_map->save_png(file_name); qso_notes( "RX:", file_name ); wefax_serviceme->qso_rec_save(); /// Next time, image will be saved at the same place. default_dir_set( progdefaults.wefax_save_dir, file_name ); } /// Beware, might be called by another thread. Called by the GUI /// or when APT start is detected. void wefax_pic::skip_rx_apt(void) { ENSURE_THREAD(FLMAIN_TID); wefax_btn_rx_abort->hide(); wefax_btn_rx_skip_apt->hide(); wefax_btn_rx_skip_phasing->show(); } /// Called when the user clicks "Skip APT" static void wefax_cb_pic_rx_skip_apt( Fl_Widget *, void *) { if (wefax_serviceme != active_modem) return; ENSURE_THREAD(FLMAIN_TID); wefax_serviceme->skip_apt(); } /// Called when clicking "Skip phasing" or by wefax.cxx /// when end of phasing is detected. Beware, might be called by another thread. void wefax_pic::skip_rx_phasing(bool auto_center) { ENSURE_THREAD(FLMAIN_TID); /// Theoretically, this widget should already be hidden, but sometimes /// it seems that a call to skip_apt is lost... ? wefax_btn_rx_abort->show(); wefax_btn_rx_skip_apt->hide(); wefax_btn_rx_skip_phasing->hide(); wefax_round_rx_noise_removal->show(); wefax_round_rx_binary->show(); wefax_spinner_rx_binary->show(); wefax_out_rx_row_num->show(); wefax_cnt_rx_ratio->show(); } /// Called when clicking "Skip phasing". static void wefax_cb_pic_rx_skip_phasing( Fl_Widget *w, void *) { if (wefax_serviceme != active_modem) return; wefax_serviceme->skip_phasing(true); } static void wefax_cb_pic_rx_noise_removal( Fl_Widget *, void *) { if (wefax_serviceme != active_modem) return; ENSURE_THREAD(FLMAIN_TID); char rndVal = wefax_round_rx_noise_removal->value(); noise_removal = rndVal ? true : false; } static void wefax_cb_pic_rx_binary( Fl_Widget *, void *) { if (wefax_serviceme != active_modem) return; ENSURE_THREAD(FLMAIN_TID); char rndVal = wefax_round_rx_binary->value(); if( rndVal ) { wefax_pic_rx_wefax_map->set_binary( true ); wefax_spinner_rx_binary->activate(); } else { wefax_pic_rx_wefax_map->set_binary( false ); wefax_spinner_rx_binary->deactivate(); } } static void wefax_cb_pic_rx_bin_threshold( Fl_Widget *, void *) { if (wefax_serviceme != active_modem) return; ENSURE_THREAD(FLMAIN_TID); int rndVal = wefax_spinner_rx_binary->value(); wefax_pic_rx_wefax_map->set_binary_threshold( rndVal ); } static void wefax_cb_pic_ratio( Fl_Widget *, void * ) { if (wefax_serviceme != active_modem) return; ENSURE_THREAD(FLMAIN_TID); double ratio_percent = wefax_cnt_rx_ratio->value(); double current_ratio = slant_factor_with_ratio( ratio_percent ); wefax_pic_rx_wefax_map->stretch( current_ratio ); rx_slant_ratio = ratio_percent ; /// And we update the configuration structure. progdefaults.wefax_slant = rx_slant_ratio ; /// Will prompt for saving configuration when exiting. progdefaults.changed = true; } /// Possible zooms. The value is processed by class wefax_map. static const struct { int m_value ; const char * m_label ; } all_zooms[] = { { -3, "25%" }, { -2, "33%" }, { -1, "50%" }, { 0, "100%" } }; //, // { 1, "200%" }, // { 2, "300%" }, // { 3, "400%" }, //}; // Index in all_zooms. static const int idx_default_zoom = 2 ; static int zoom_nb = sizeof(all_zooms) / sizeof(all_zooms[0]); static void wefax_cb_pic_zoom( Fl_Widget * wefax_choice_zoom, void * ) { if (wefax_serviceme != active_modem) return; ENSURE_THREAD(FLMAIN_TID); int idx_zoom = dynamic_cast<Fl_Choice *>(wefax_choice_zoom)->value(); if( ( idx_zoom < 0 ) || ( idx_zoom >= zoom_nb ) ) { LOG_WARN( "Invalid zoom index=%d", idx_zoom ); idx_zoom = idx_default_zoom ; } /// Not very elegant but OK if two possibilities only. if( wefax_choice_zoom == wefax_choice_rx_zoom ) { wefax_pic_rx_wefax_map->set_zoom( all_zooms[ idx_zoom ].m_value ); wefax_pic_rx_win->redraw(); } else if( wefax_choice_zoom == wefax_choice_tx_zoom ) { wefax_pic_tx_wefax_map->set_zoom( all_zooms[ idx_zoom ].m_value ); wefax_pic_tx_win->redraw(); } else { LOG_ERROR("Inconsistent possibility"); } } static Fl_Choice * wefax_create_zoom(int fax_grp_x, int fax_grp_y, int wid_btn_curr, int H_BUTTON) { ENSURE_THREAD(FLMAIN_TID); static const char * title_zoom = "Zoom" ; Fl_Choice * wefax_choice_zoom = new Fl_Choice(fax_grp_x, fax_grp_y, wid_btn_curr, H_BUTTON, _(title_zoom)); wefax_choice_zoom->callback(wefax_cb_pic_zoom, 0); for( int ix_zoom = 0; ix_zoom < zoom_nb ; ++ix_zoom ) { wefax_choice_zoom->add( all_zooms[ ix_zoom ].m_label ); }; wefax_choice_zoom->value(idx_default_zoom); wefax_choice_zoom->tooltip(_("Window zoom")); wefax_choice_zoom->align(FL_ALIGN_LEFT); return wefax_choice_zoom ; } void wefax_pic::abort_rx_viewer(void) { if (wefax_serviceme != active_modem) return; ENSURE_THREAD(FLMAIN_TID); put_status(""); /// Maybe the image is too high, we make it shorter. wefax_pic_rx_wefax_map->resize_height( curr_pix_h_default, true ); /// Now returns to the top of the image, and refresh the scrolling. wefax_pic_rx_wefax_map->position( wefax_pic_rx_wefax_map->x(), 0 ); wefax_pic_rx_scroll->redraw(); curr_pix_height = curr_pix_h_default ; rx_last_filtered_row = 0; center_val_prev = 0 ; wefax_rx_center->value(0.0); wefax_btn_rx_abort->hide(); wefax_btn_rx_skip_apt->show(); wefax_btn_rx_skip_phasing->hide(); // Back to the first line before reading next image. wefax_pic_rx_scroll->scroll_to( 0, 0 ); } /// The resizing is different from the base class. class wefax_map_scroll : public wefax_map { public: /// Background color is gray. wefax_map_scroll(int X, int Y, int W, int H) : wefax_map (X, Y, W, H, 255) {}; virtual ~wefax_map_scroll() {}; /// wefax_map::resize destroys the image, we do not want that when displaying. virtual void resize(int x, int y, int w, int h) { Fl_Widget::resize( x, y, w, h ); } /// This must not process slant this way, so inhibits wefax_map::handle. virtual int handle(int event) { return 0 ; } }; static void wefax_load_image(const char * fil_name); static const int extra_win_wid = 800 ; Fl_Group *create_wefax_rx_viewer(int pos_x, int pos_y,int win_wid, int hei_win) { rx_slant_ratio = progdefaults.wefax_slant ; wefax_pic_rx_win = new Fl_Group(pos_x, pos_y, win_wid, hei_win); wefax_pic_rx_win->color( fl_rgb_color( progdefaults.RxColor.R, progdefaults.RxColor.G, progdefaults.RxColor.B), progdefaults.RxTxSelectcolor); wefax_pic_rx_win->align(FL_ALIGN_CLIP); /// A bit wider so that it does not scroll at the beginning. int H_MARGIN = 1; int W_MARGIN = 1; int H_BUTTON = 22; Fl_Font font = fl_font(); int fsize = fl_size(); fl_font(FL_HELVETICA, 12); int wid_img = win_wid - 2 * W_MARGIN; int hei_scroll = hei_win - (H_BUTTON + 3 * H_MARGIN); wefax_pic_rx_win->begin(); wefax_pic_rx_scroll = new Fl_Scroll( pos_x + W_MARGIN, pos_y, wid_img, hei_scroll ); wefax_pic_rx_scroll->type(Fl_Scroll::HORIZONTAL | Fl_Scroll::VERTICAL | Fl_Scroll::ALWAYS_ON); wefax_pic_rx_scroll->color( fl_rgb_color( 255, 255, 255), progdefaults.RxTxSelectcolor); wefax_pic_rx_scroll->box(FL_ENGRAVED_FRAME); wefax_pic_rx_scroll->begin(); /// It will be resized immediately. wefax_pic_rx_wefax_map = new wefax_map_scroll( wefax_pic_rx_scroll->x(), wefax_pic_rx_scroll->y(), wid_img, curr_pix_height); wefax_pic_rx_wefax_map->align(FL_ALIGN_TOP); wefax_pic_rx_wefax_map->set_zoom( all_zooms[ idx_default_zoom ].m_value ); wefax_pic_rx_scroll->end(); /// Sets the group at a big size, we will resize the width at the end. Fl_Group * tmpGroup = new Fl_Group( W_MARGIN, pos_y + hei_scroll, wid_img, H_BUTTON + 2 * H_MARGIN); tmpGroup->begin(); tmpGroup->box( FL_DOWN_BOX); tmpGroup->color(fl_rgb_color(144, 175, 200)); wefax_btn_rx_save = new Fl_Button( tmpGroup->x() + W_MARGIN, tmpGroup->y() + H_MARGIN, 35, H_BUTTON, _("Save")); wefax_btn_rx_save->callback(wefax_cb_pic_rx_save, 0); wefax_btn_rx_save->tooltip(_("Save current image in a file.")); /// Clear, Skipt APT and Skip phasing are at the same place wefax_btn_rx_abort = new Fl_Button( wefax_btn_rx_save->x() + wefax_btn_rx_save->w() + W_MARGIN, wefax_btn_rx_save->y(), 45, H_BUTTON, _("Clear")); wefax_btn_rx_abort->callback(wefax_cb_pic_rx_abort, 0); wefax_btn_rx_abort->tooltip(_("End and clear current image reception.")); wefax_btn_rx_skip_apt = new Fl_Button( wefax_btn_rx_abort->x(), wefax_btn_rx_abort->y(), wefax_btn_rx_abort->w(), wefax_btn_rx_abort->h(), _("APT")); wefax_btn_rx_skip_apt->callback(wefax_cb_pic_rx_skip_apt, 0); wefax_btn_rx_skip_apt->tooltip(_("Skip Automatic Picture Transmission step")); wefax_btn_rx_skip_phasing = new Fl_Button( wefax_btn_rx_abort->x(), wefax_btn_rx_abort->y(), wefax_btn_rx_abort->w(), wefax_btn_rx_abort->h(), _("Phase")); wefax_btn_rx_skip_phasing->callback(wefax_cb_pic_rx_skip_phasing, 0); wefax_btn_rx_skip_phasing->tooltip(_("Skip phasing step")); wefax_btn_rx_pause = new Fl_Button( wefax_btn_rx_skip_phasing->x() + wefax_btn_rx_skip_phasing->w() + W_MARGIN, wefax_btn_rx_skip_phasing->y(), 45, H_BUTTON, _("Pause")); wefax_btn_rx_pause->callback(wefax_cb_pic_rx_pause, 0); wefax_btn_rx_pause->tooltip(_("Pause reception.")); wefax_btn_rx_resume = new Fl_Button( wefax_btn_rx_skip_phasing->x(), wefax_btn_rx_skip_phasing->y(), wefax_btn_rx_skip_phasing->w(), wefax_btn_rx_skip_phasing->h(), _("Resume")); wefax_btn_rx_resume->callback(wefax_cb_pic_rx_resume, 0); wefax_btn_rx_resume->tooltip(_("Resume reception.")); wefax_btn_rx_resume->hide(); wefax_round_rx_non_stop = new Fl_Light_Button( wefax_btn_rx_resume->x() + wefax_btn_rx_resume->w() + W_MARGIN, wefax_btn_rx_resume->y(), 50, H_BUTTON, _("Cont'")); wefax_round_rx_non_stop->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); wefax_round_rx_non_stop->selection_color(progdefaults.default_btn_color); wefax_round_rx_non_stop->callback(wefax_cb_pic_rx_manual, 0); wefax_round_rx_non_stop->tooltip(_("Continuous reception mode")); int zw = fl_width(_("Mag")) + 5; wefax_choice_rx_zoom = new Fl_Choice( wefax_round_rx_non_stop->x() + wefax_round_rx_non_stop->w() + W_MARGIN + zw, wefax_round_rx_non_stop->y(), 60, H_BUTTON, _("Mag") ); wefax_choice_rx_zoom->callback(wefax_cb_pic_zoom, 0); for( int ix_zoom = 0; ix_zoom < zoom_nb ; ++ix_zoom ) wefax_choice_rx_zoom->add( all_zooms[ ix_zoom ].m_label ); wefax_choice_rx_zoom->value(idx_default_zoom); wefax_choice_rx_zoom->tooltip(_("Image magnification")); wefax_choice_rx_zoom->align(FL_ALIGN_LEFT); zw = fl_width(_("Row")) + 5; wefax_out_rx_row_num = new Fl_Output( wefax_choice_rx_zoom->x() + wefax_choice_rx_zoom->w() + zw + W_MARGIN, wefax_choice_rx_zoom->y(), 50, H_BUTTON, _("Row")); wefax_out_rx_row_num->align(FL_ALIGN_LEFT); wefax_out_rx_row_num->tooltip(_("Fax line number being read. Image is saved when reaching max lines.")); zw = fl_width(_("Tilt")) + 5; wefax_cnt_rx_ratio = new Fl_Counter( wefax_out_rx_row_num->x() + wefax_out_rx_row_num->w() + zw, wefax_out_rx_row_num->y(), 120, H_BUTTON, _("Tilt")); wefax_cnt_rx_ratio->align(FL_ALIGN_LEFT); wefax_cnt_rx_ratio->step(.0001); wefax_cnt_rx_ratio->lstep(.001); wefax_cnt_rx_ratio->precision( 4 ); wefax_cnt_rx_ratio->callback(wefax_cb_pic_ratio, 0); wefax_cnt_rx_ratio->value(rx_slant_ratio); wefax_cnt_rx_ratio->tooltip(_("Adjust image slant to correct soundcard clock error.")); zw = fl_width(_("Align")) + 5; wefax_rx_center = new Fl_Counter( wefax_cnt_rx_ratio->x() + wefax_cnt_rx_ratio->w() + zw, wefax_cnt_rx_ratio->y(), 130, H_BUTTON, _("Align")); wefax_rx_center->align(FL_ALIGN_LEFT); /// The range is set when the image size in pixels is known. wefax_rx_center->step(1.0); wefax_rx_center->lstep(10.0); wefax_rx_center->callback(wefax_cb_pic_rx_center, 0); wefax_rx_center->tooltip(_("Align image horizontally.")); center_val_prev = 0 ; wefax_autocenter = new Fl_Light_Button( wefax_rx_center->x() + wefax_rx_center->w() + W_MARGIN, wefax_rx_center->y(), 45, H_BUTTON, "Auto"); wefax_autocenter->selection_color(progdefaults.default_btn_color); wefax_autocenter->callback(cb_wefax_autocenter, 0); wefax_autocenter->tooltip(_("Enable automatic image centering")); wefax_autocenter->value(progdefaults.wefax_autocenter); wefax_round_rx_noise_removal = new Fl_Light_Button( wefax_autocenter->x() + wefax_autocenter->w() + W_MARGIN, wefax_autocenter->y(), 50, H_BUTTON, _("Noise")); wefax_round_rx_noise_removal->callback(wefax_cb_pic_rx_noise_removal, 0); wefax_round_rx_noise_removal->tooltip(_("Removes noise when ticked")); wefax_round_rx_noise_removal->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); wefax_round_rx_noise_removal->selection_color(progdefaults.default_btn_color); wefax_round_rx_binary = new Fl_Light_Button( wefax_round_rx_noise_removal->x() + wefax_round_rx_noise_removal->w() + W_MARGIN, wefax_round_rx_noise_removal->y(), 35, H_BUTTON, _("Bin")); wefax_round_rx_binary->callback(wefax_cb_pic_rx_binary, 0); wefax_round_rx_binary->tooltip(_("Binary image when ticked")); wefax_round_rx_binary->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); wefax_round_rx_binary->selection_color(progdefaults.default_btn_color); wefax_round_rx_binary->value(0); wefax_spinner_rx_binary = new Fl_Spinner( wefax_round_rx_binary->x() + wefax_round_rx_binary->w() + W_MARGIN, wefax_round_rx_binary->y(), 50, H_BUTTON ); wefax_spinner_rx_binary->callback(wefax_cb_pic_rx_bin_threshold, 0); wefax_spinner_rx_binary->tooltip(_("Set binarization level")); wefax_spinner_rx_binary->format("%d"); wefax_spinner_rx_binary->type(FL_INT_INPUT); wefax_spinner_rx_binary->range(0.0, 255.0); wefax_spinner_rx_binary->step(1.0); wefax_spinner_rx_binary->value(wefax_pic_rx_wefax_map->get_binary_threshold()); Fl_Box *filler = new Fl_Box( wefax_spinner_rx_binary->x() + wefax_spinner_rx_binary->w(), wefax_spinner_rx_binary->y(), 2, H_BUTTON ); filler->box(FL_NO_BOX); tmpGroup->end(); tmpGroup->resizable(filler);//wefax_browse_rx_events); tmpGroup->init_sizes(); wefax_pic_rx_win->end(); wefax_pic_rx_win->resizable( wefax_pic_rx_scroll ); wefax_pic_rx_win->init_sizes(); wefax_pic_rx_win->redraw(); fl_font(font, fsize); return wefax_pic_rx_win; } void wefax_pic::resize_rx_viewer(int wid_img) { // return; ENSURE_THREAD(FLMAIN_TID); abort_rx_viewer(); wefax_pic_rx_wefax_map->wefax_map::resize( wefax_pic_rx_wefax_map->x(), wefax_pic_rx_wefax_map->y(), wid_img, curr_pix_h_default ); wefax_pic_rx_win->redraw(); } void wefax_pic::set_rx_label(const std::string & win_label) { std::string tmp_label( win_label ); if( reception_paused ) { tmp_label += " paused" ; } } void wefax_pic::save_image(const std::string & fil_name, const std::string & extra_comments ) { std::string dfname = default_dir_get( progdefaults.wefax_save_dir ) + fil_name ; std::stringstream local_comments; local_comments << extra_comments ; local_comments << "Slant:" << rx_slant_ratio << "\n" ; local_comments << "Auto-Center:" << ( progdefaults.wefax_autocenter ? "On" : "Off" ) << "\n" ; wefax_pic_rx_wefax_map->save_png( dfname.c_str(), local_comments.str().c_str()); // add_to_files_list( dfname ); qso_notes( "RX:", fil_name ); wefax_serviceme->qso_rec_save(); } /// Protected by an exclusive mutex. static std::string wefax_load_image_after_acquire(const char * fil_name) { if (wefax_serviceme != active_modem) return "Not in WEFAX mode"; ENSURE_THREAD(FLMAIN_TID); wefax_serviceme->qso_rec_init(); qso_notes( "TX:", fil_name ); clear_image(); wefax_shared_tx_img = Fl_Shared_Image::get(fil_name); if (!wefax_shared_tx_img) { std::string err_msg("Cannot call Fl_Shared_Image::get on file:" + std::string(fil_name) ); LOG_ERROR("%s",err_msg.c_str()); return err_msg; } if (wefax_shared_tx_img->count() > 1) { // we only handle rgb images std::string err_msg("Handle only RGB images: " + std::string(fil_name) ); LOG_ERROR("%s",err_msg.c_str()); clear_image(); return err_msg; } unsigned char * img_data = (unsigned char *)wefax_shared_tx_img->data()[0]; int img_wid = wefax_shared_tx_img->w(); int img_hei = wefax_shared_tx_img->h(); int img_depth = wefax_shared_tx_img->d(); wefax_xmtimg = new unsigned char [img_wid * img_hei * bytes_per_pix]; if (img_depth == bytes_per_pix) memcpy(wefax_xmtimg, img_data, img_wid*img_hei*bytes_per_pix); else if (img_depth == 4) { int i, j, k; for (i = 0; i < img_wid*img_hei; i++) { j = i*bytes_per_pix; k = i*4; wefax_xmtimg[j] = img_data[k]; wefax_xmtimg[j+1] = img_data[k+1]; wefax_xmtimg[j+2] = img_data[k+2]; } } else if (img_depth == 1) { int i, j; for (i = 0; i < img_wid*img_hei; i++) { j = i * bytes_per_pix; wefax_xmtimg[j] = wefax_xmtimg[j+1] = wefax_xmtimg[j+2] = img_data[i]; } } else { std::stringstream err_strm ; err_strm << "Inconsistent img_depth=" << img_depth << " for " << fil_name ; std::string err_msg = err_strm.str(); LOG_ERROR("%s",err_msg.c_str()); return err_msg ; }; wefax_pic::tx_viewer_resize(img_wid, img_hei); set_win_label(wefax_pic_tx_win, fil_name); wefax_pic_tx_box->label(0); // load the wefax_map widget with the rgb image wefax_pic_tx_wefax_map->show(); wefax_pic_tx_wefax_map->clear(); wefax_pic_tx_wefax_map->video(wefax_xmtimg, img_wid * img_hei * bytes_per_pix); int tim_color = wefax_serviceme->tx_time( img_wid * img_hei * bytes_per_pix ); static char wefax_txclr_tooltip[24]; snprintf( wefax_txclr_tooltip, sizeof(wefax_txclr_tooltip), _("Time needed: %dm %ds (Color)"), tim_color/60, tim_color % 60 ); wefax_btn_tx_send_color->tooltip(wefax_txclr_tooltip); if( false ) { // No color transmission now because no information this format. wefax_btn_tx_send_color->activate(); } int tim_grey = wefax_serviceme->tx_time( img_wid * img_hei ); static char wefax_txgry_tooltip[24]; snprintf( wefax_txgry_tooltip, sizeof(wefax_txgry_tooltip), _("Time needed: %dm %ds (B/W)"), tim_grey/60, tim_grey % 60 ); wefax_btn_tx_send_grey->tooltip(wefax_txgry_tooltip); wefax_btn_tx_send_grey->activate(); wefax_choice_tx_zoom->activate(); wefax_btn_tx_clear->activate(); return std::string(); } static void wefax_load_image(const char * fil_name) { if (wefax_serviceme != active_modem) return; if( !wefax_image_loaded_in_gui ) { /// So we do not re-acquire the exclusive access to wefax transmission. wefax_serviceme->transmit_lock_acquire(fil_name); wefax_image_loaded_in_gui = true ; } wefax_load_image_after_acquire(fil_name); } void wefax_pic::set_tx_pic(unsigned char data, int col, int row, bool is_color ) { if (wefax_serviceme != active_modem) return; ENSURE_THREAD(FLMAIN_TID); if( ( col >= wefax_shared_tx_img->w() ) || ( row >= wefax_shared_tx_img->h() ) ) { LOG_ERROR("invalid col=%d row=%d w=%d h=%d", col, row, wefax_shared_tx_img->w(), wefax_shared_tx_img->h() ); exit(EXIT_FAILURE); } int offset = row * wefax_shared_tx_img->w() + col ; if (is_color) { wefax_pic_tx_wefax_map->pixel( data, offset ); } else { int tripleOffset = bytes_per_pix * offset ; wefax_pic_tx_wefax_map->pixel( data, tripleOffset ); wefax_pic_tx_wefax_map->pixel( data, tripleOffset + 1 ); wefax_pic_tx_wefax_map->pixel( data, tripleOffset + 2 ); } static int previous_row = -1 ; if( row != previous_row ) { previous_row = row ; char num_buffer[20]; snprintf( num_buffer, sizeof(num_buffer), "%d", row ); wefax_out_tx_row_num->value( num_buffer ); snprintf( num_buffer, sizeof(num_buffer), "%d", wefax_shared_tx_img->w() ); wefax_out_tx_col_num->value( num_buffer ); } } static void wefax_cb_pic_tx_load(Fl_Widget *, void *) { const char *fil_name = FSEL::select(_("Load image file"), "Portable Network Graphics\t*.png\n" "Independent JPEG Group\t*.{jpg,jif,jpeg,jpe}\n" "Graphics Interchange Format\t*.gif", default_dir_get( progdefaults.wefax_load_dir ).c_str() ); if (!fil_name) return; if (!*fil_name) return; /// Next time, image will be saved at the same place. default_dir_set( progdefaults.wefax_load_dir, fil_name ); wefax_load_image(fil_name); } /// Called whether color or b/w image. static void wefax_pic_tx_send_common( bool is_color ) { ENSURE_THREAD(FLMAIN_TID); if (wefax_serviceme != active_modem) return; int img_w = wefax_shared_tx_img->w(); int img_h = wefax_shared_tx_img->h(); wefax_choice_tx_lpm->hide(); wefax_btn_tx_send_color->hide(); wefax_btn_tx_send_grey->hide(); wefax_btn_tx_load->hide(); wefax_choice_tx_zoom->hide(); wefax_btn_tx_clear->hide(); wefax_btn_tx_close->hide(); wefax_out_tx_row_num->show(); wefax_out_tx_col_num->show(); wefax_btn_tx_send_abort->show(); wefax_pic_tx_wefax_map->clear(); wefax_out_tx_row_num->value( "Init" ); wefax_out_tx_col_num->value( "" ); wefax_serviceme->set_tx_parameters( get_choice_lpm_value( wefax_choice_tx_lpm ), wefax_xmtimg, is_color, img_w, img_h ); start_tx(); } static void wefax_cb_pic_tx_send_color( Fl_Widget * , void *) { wefax_pic_tx_send_common(true); } static void wefax_cb_pic_tx_send_grey( Fl_Widget *, void *) { wefax_pic_tx_send_common(false); } static void wefax_cb_pic_tx_send_abort( Fl_Widget *, void *) { if (wefax_serviceme != active_modem) return; /// Maybe we are not sending an image. if( wefax_shared_tx_img ) { wefax_serviceme->set_tx_abort_flag(); // reload the wefax_map widget with the rgb image wefax_pic_tx_wefax_map->video(wefax_xmtimg, wefax_shared_tx_img->w() * wefax_shared_tx_img->h() * bytes_per_pix); } } void wefax_pic::restart_tx_viewer(void) { ENSURE_THREAD(FLMAIN_TID); wefax_out_tx_row_num->hide(); wefax_out_tx_col_num->hide(); wefax_btn_tx_send_abort->hide(); wefax_btn_tx_load->show(); wefax_btn_tx_close->show(); if( wefax_image_loaded_in_gui ) { // If the image was loaded from the GUI. wefax_choice_tx_lpm->show(); wefax_btn_tx_send_color->show(); wefax_btn_tx_send_grey->show(); wefax_choice_tx_zoom->show(); wefax_btn_tx_clear->show(); } else { /// If the image was loaded and sent from XML-RPC, or no image present. wefax_choice_tx_lpm->deactivate(); wefax_btn_tx_send_color->deactivate(); wefax_btn_tx_send_grey->deactivate(); wefax_choice_tx_zoom->deactivate(); wefax_btn_tx_clear->deactivate(); } } //void wefax_pic::create_wefax_tx_viewer(int pos_x, int pos_y,int win_wid, int hei_win) void create_wefax_tx_viewer(int pos_x, int pos_y,int win_wid, int hei_win) { ENSURE_THREAD(FLMAIN_TID); int wid_btn_margin = 5 ; Fl_Double_Window * tmpWin = new Fl_Double_Window(win_wid, hei_win, _("Send image")); wefax_pic_tx_win = tmpWin; wefax_pic_tx_win->color( fl_rgb_color( progdefaults.TxColor.R, progdefaults.TxColor.G, progdefaults.TxColor.B), progdefaults.RxTxSelectcolor); wefax_pic_tx_win->begin(); wefax_pic_tx_scroll = new Fl_Scroll( 1, 1, win_wid-2, hei_win - 23 ); wefax_pic_tx_scroll->type(Fl_Scroll::HORIZONTAL | Fl_Scroll::VERTICAL); wefax_pic_tx_scroll->color( fl_rgb_color( 255, 255, 255), progdefaults.RxTxSelectcolor); wefax_pic_tx_scroll->box(FL_ENGRAVED_FRAME); wefax_pic_tx_scroll->begin(); /// It will be resized immediately when an image is loaded. wefax_pic_tx_wefax_map = new wefax_map_scroll( 0,0,0,0); wefax_pic_tx_wefax_map->align(FL_ALIGN_TOP); wefax_pic_tx_wefax_map->set_zoom( all_zooms[ idx_default_zoom ].m_value ); wefax_pic_tx_scroll->end(); wefax_pic_tx_win->resizable( wefax_pic_tx_scroll ); wefax_pic_tx_box = new wefax_picbox( wefax_pic_tx_scroll->x(), wefax_pic_tx_scroll->y(), wefax_pic_tx_scroll->w(), wefax_pic_tx_scroll->h(), _("Loads an image file\nSupported types: PNG, JPEG, BMP")); wefax_pic_tx_box->labelfont(FL_HELVETICA_ITALIC); static const int last_margin = 21 ; static const int y_btn = hei_win - last_margin ; static const int hei_tx_btn = 20 ; Fl_Group * tmpGroup = new Fl_Group( 0, y_btn, extra_win_wid, last_margin ); tmpGroup->begin(); int width_btn = 30; int width_offset = 30; width_btn = 50 ; wefax_choice_tx_lpm = make_lpm_choice( width_offset, y_btn, width_btn, hei_tx_btn ); width_offset += width_btn + wid_btn_margin ; width_btn = 55 ; wefax_btn_tx_send_color = new Fl_Button(width_offset, y_btn, width_btn, hei_tx_btn, "Tx Color"); wefax_btn_tx_send_color->callback(wefax_cb_pic_tx_send_color, 0); wefax_btn_tx_send_color->tooltip(_("Starts transmit in color mode")); width_offset += width_btn + wid_btn_margin ; width_btn = 45 ; wefax_btn_tx_send_grey = new Fl_Button(width_offset, y_btn, width_btn, hei_tx_btn, "Tx B/W"); wefax_btn_tx_send_grey->callback( wefax_cb_pic_tx_send_grey, 0); wefax_btn_tx_send_grey->tooltip(_("Starts transmit in gray level mode")); width_offset += width_btn + wid_btn_margin ; width_btn = 55 ; wefax_btn_tx_load = new Fl_Button(width_offset, y_btn, width_btn, hei_tx_btn, _("Load...")); wefax_btn_tx_load->callback(wefax_cb_pic_tx_load, 0); wefax_btn_tx_load->tooltip(_("Load image to send")); width_offset += width_btn + wid_btn_margin + 40 ; width_btn = 58 ; wefax_choice_tx_zoom = wefax_create_zoom( width_offset, y_btn, width_btn, hei_tx_btn ); width_offset += width_btn + wid_btn_margin ; width_btn = 45 ; wefax_btn_tx_clear = new Fl_Button(width_offset, y_btn, width_btn, hei_tx_btn, _("Clear")); wefax_btn_tx_clear->callback(wefax_cb_pic_tx_clear, 0); wefax_btn_tx_clear->tooltip(_("Clear image to transmit")); width_offset += width_btn + wid_btn_margin ; width_btn = 45 ; wefax_btn_tx_close = new Fl_Button(width_offset, y_btn, width_btn, hei_tx_btn, _("Close")); wefax_btn_tx_close->callback(wefax_cb_pic_tx_close, 0); wefax_btn_tx_close->tooltip(_("Close transmit window")); wefax_out_tx_row_num = new Fl_Output(20, y_btn, 50, hei_tx_btn ); wefax_out_tx_row_num->align(FL_ALIGN_LEFT); wefax_out_tx_row_num->tooltip(_("Fax line number being sent.")); wefax_out_tx_col_num = new Fl_Output(80, y_btn, 50, hei_tx_btn, "x" ); wefax_out_tx_col_num->align(FL_ALIGN_LEFT); wefax_out_tx_col_num->tooltip(_("Fax column number.")); wefax_btn_tx_send_abort = new Fl_Button(180, y_btn, 100, hei_tx_btn, _("Abort Transmit") ); wefax_btn_tx_send_abort->callback(wefax_cb_pic_tx_send_abort, 0); wefax_btn_tx_send_abort->tooltip(_("Abort transmission")); wefax_out_tx_row_num->hide(); wefax_out_tx_col_num->hide(); wefax_btn_tx_send_abort->hide(); wefax_btn_tx_send_color->deactivate(); wefax_btn_tx_send_grey->deactivate(); wefax_choice_tx_zoom->deactivate(); wefax_btn_tx_clear->deactivate(); tmpGroup->end(); wefax_pic_tx_win->end(); wefax_pic_rx_win->init_sizes(); wefax_pic_rx_win->redraw(); } void wefax_pic::abort_tx_viewer(void) { wefax_cb_pic_tx_send_abort(NULL,NULL); wefax_cb_pic_tx_close(NULL,NULL); } void wefax_pic::tx_viewer_resize(int the_width, int the_height) { ENSURE_THREAD(FLMAIN_TID); LOG_DEBUG("the_width=%d the_height=%d", the_width, the_height ); int win_width = the_width < 288 ? 290 : the_width + 4; int win_height = the_height < 180 ? 180 : the_height + 30; int pic_x = (win_width - the_width) / 2; int pic_y = (win_height - 30 - the_height)/2; /// This because it is a wefax_map_scroll object. wefax_pic_tx_wefax_map->wefax_map::resize(pic_x, pic_y, the_width, the_height); wefax_pic_tx_wefax_map->clear(); wefax_pic_tx_box->size(win_width, win_height); } /// TODO: This crashes but should be called. void wefax_pic::delete_tx_viewer() { ENSURE_THREAD(FLMAIN_TID); wefax_pic_tx_win->hide(); wefax_serviceme = 0; /// First delete the Fl_Widget. delete wefax_pic_tx_win; wefax_pic_tx_win = 0; delete [] wefax_xmtimg; wefax_xmtimg = 0; } /// TODO: This crashes. void wefax_pic::delete_rx_viewer() { ENSURE_THREAD(FLMAIN_TID); wefax_pic_rx_win->hide(); wefax_serviceme = 0; /// These objects are deleted with the main window. wefax_pic_tx_win = 0; wefax_pic_rx_win = 0; } void wefax_pic::setwefax_map_link(wefax *me) { wefax_serviceme = me; } /// Called by the main menu bar to open explicitely a wefax transmission window. void wefax_pic::cb_mnu_pic_viewer_tx(Fl_Menu_ *, void * ) { if ( ! wefax_pic_tx_win) { LOG_ERROR("wefax_tx_win should be created"); return ; } progdefaults.WEFAX_HideTx = ! progdefaults.WEFAX_HideTx ; wefax_pic_show_tx(); } /// Called from XML-RPC thread. void wefax_pic::send_image( const std::string & fil_nam ) { LOG_VERBOSE("Sending %s", fil_nam.c_str() ); /// Here, transmit_lock_acquire is called by the XML-RPC client. std::string err_msg = wefax_load_image_after_acquire( fil_nam.c_str() ); if( ! err_msg.empty() ) { if (wefax_serviceme == active_modem) { /// Allows another XML-RPC client or the GUI to send an image. wefax_serviceme->transmit_lock_release( err_msg ); } return ; } wefax_cb_pic_tx_send_grey( NULL, NULL ); LOG_VERBOSE("Sent %s", fil_nam.c_str() ); } /// This function is called at two places: // - When creating the main window. // - When initializing the fax modem. void wefax_pic::create_both(bool called_from_fl_digi) { return; if( wefax_pic_rx_win ) return ; ENSURE_THREAD(FLMAIN_TID); // Fl_Window *temp = new Fl_Window(0,0,400,400); // wefax_pic_rx_wefax_map = new wefax_map_scroll(0, 0, 400, 200); // wefax_pic_rx_wefax_map->align(FL_ALIGN_TOP); // wefax_pic_rx_wefax_map->set_zoom( all_zooms[ idx_default_zoom ].m_value ); // temp->end(); }
46,640
C++
.cxx
1,235
35.59919
115
0.684723
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,232
debug_dialog.cxx
w1hkj_fldigi/src/debug/debug_dialog.cxx
// generated by Fast Light User Interface Designer (fluid) version 1.0305 #include "debug_dialog.h" Fl_Choice *mnu_debug_level=(Fl_Choice *)0; static void cb_mnu_debug_level(Fl_Choice*, void*) { mnu_debug_level_cb(); } Fl_Button *btn_clear_debug=(Fl_Button *)0; static void cb_btn_clear_debug(Fl_Button*, void*) { clear_debug(); } static void cb_source_code(Fl_Check_Button*, void*) { btn_debug_source_cb(0); } static void cb_source_code1(Fl_Check_Button*, void*) { btn_debug_source_cb(1); } static void cb_source_code2(Fl_Check_Button*, void*) { btn_debug_source_cb(2); } static void cb_source_code3(Fl_Check_Button*, void*) { btn_debug_source_cb(3); } static void cb_source_code4(Fl_Check_Button*, void*) { btn_debug_source_cb(4); } static void cb_source_code5(Fl_Check_Button*, void*) { btn_debug_source_cb(5); } static void cb_source_code6(Fl_Check_Button*, void*) { btn_debug_source_cb(6); } static void cb_source_code7(Fl_Check_Button*, void*) { btn_debug_source_cb(7); } static void cb_source_code8(Fl_Check_Button*, void*) { btn_debug_source_cb(8); } static void cb_source_code9(Fl_Check_Button*, void*) { btn_debug_source_cb(9); } static void cb_source_codea(Fl_Check_Button*, void*) { btn_debug_source_cb(10); } static void cb_source_codeb(Fl_Check_Button*, void*) { btn_debug_source_cb(11); } static void cb_source_codec(Fl_Check_Button*, void*) { btn_debug_source_cb(12); } static void cb_source_coded(Fl_Check_Button*, void*) { btn_debug_source_cb(13); } Fl_Check_Button *source_code[15]={(Fl_Check_Button *)0}; static void cb_source_codee(Fl_Check_Button*, void*) { btn_debug_source_cb(14); } Fl_Browser *btext=(Fl_Browser *)0; Fl_Double_Window* debug_dialog() { Fl_Double_Window* w; { Fl_Double_Window* o = new Fl_Double_Window(570, 240, "Event Log"); w = o; if (w) {/* empty */} { Fl_Group* o = new Fl_Group(0, 0, 570, 60); o->box(FL_ENGRAVED_BOX); { Fl_Group* o = new Fl_Group(0, 0, 140, 60); { Fl_Group* o = new Fl_Group(0, 0, 130, 60); { Fl_Choice* o = mnu_debug_level = new Fl_Choice(6, 5, 120, 22); mnu_debug_level->down_box(FL_BORDER_BOX); mnu_debug_level->callback((Fl_Callback*)cb_mnu_debug_level); mnu_debug_level->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); o->add("Quiet|Error|Warning|Info|Verbose|Debug"); o->value(3); } // Fl_Choice* mnu_debug_level { btn_clear_debug = new Fl_Button(5, 34, 60, 21, "clear"); btn_clear_debug->callback((Fl_Callback*)cb_btn_clear_debug); } // Fl_Button* btn_clear_debug o->end(); } // Fl_Group* o { Fl_Group* o = new Fl_Group(130, 0, 10, 60); o->end(); Fl_Group::current()->resizable(o); } // Fl_Group* o o->end(); Fl_Group::current()->resizable(o); } // Fl_Group* o { source_code[0] = new Fl_Check_Button(145, 5, 70, 15, "ARQ"); source_code[0]->tooltip("ARQ server"); source_code[0]->down_box(FL_DOWN_BOX); source_code[0]->callback((Fl_Callback*)cb_source_code); } // Fl_Check_Button* source_code[0] { source_code[1] = new Fl_Check_Button(145, 22, 70, 15, "Audio"); source_code[1]->tooltip("Audio: OSS, PortAudio, PulseAudio"); source_code[1]->down_box(FL_DOWN_BOX); source_code[1]->callback((Fl_Callback*)cb_source_code1); } // Fl_Check_Button* source_code[1] { source_code[2] = new Fl_Check_Button(145, 40, 70, 15, "Modem"); source_code[2]->tooltip("All Modem code"); source_code[2]->down_box(FL_DOWN_BOX); source_code[2]->callback((Fl_Callback*)cb_source_code2); } // Fl_Check_Button* source_code[2] { source_code[3] = new Fl_Check_Button(228, 5, 70, 15, "Rig i/o"); source_code[3]->tooltip("Rigcat, Hamlib, serial port i/o"); source_code[3]->down_box(FL_DOWN_BOX); source_code[3]->callback((Fl_Callback*)cb_source_code3); } // Fl_Check_Button* source_code[3] { source_code[4] = new Fl_Check_Button(228, 22, 70, 15, "Server"); source_code[4]->tooltip("XMLRPC server"); source_code[4]->down_box(FL_DOWN_BOX); source_code[4]->callback((Fl_Callback*)cb_source_code4); } // Fl_Check_Button* source_code[4] { source_code[5] = new Fl_Check_Button(228, 40, 70, 15, "Client"); source_code[5]->tooltip("XMLRPC client (flrig i/o)"); source_code[5]->down_box(FL_DOWN_BOX); source_code[5]->callback((Fl_Callback*)cb_source_code5); } // Fl_Check_Button* source_code[5] { source_code[6] = new Fl_Check_Button(311, 5, 70, 15, "Spotter"); source_code[6]->tooltip("Spotter client"); source_code[6]->down_box(FL_DOWN_BOX); source_code[6]->callback((Fl_Callback*)cb_source_code6); } // Fl_Check_Button* source_code[6] { source_code[7] = new Fl_Check_Button(311, 22, 70, 15, "Data"); source_code[7]->tooltip("Data sources i/o"); source_code[7]->down_box(FL_DOWN_BOX); source_code[7]->callback((Fl_Callback*)cb_source_code7); } // Fl_Check_Button* source_code[7] { source_code[8] = new Fl_Check_Button(311, 40, 70, 15, "Synop"); source_code[8]->tooltip("Synop code"); source_code[8]->down_box(FL_DOWN_BOX); source_code[8]->callback((Fl_Callback*)cb_source_code8); } // Fl_Check_Button* source_code[8] { source_code[9] = new Fl_Check_Button(394, 5, 70, 15, "KML"); source_code[9]->tooltip("KML code"); source_code[9]->down_box(FL_DOWN_BOX); source_code[9]->callback((Fl_Callback*)cb_source_code9); } // Fl_Check_Button* source_code[9] { source_code[10] = new Fl_Check_Button(394, 22, 70, 15, "KISS"); source_code[10]->tooltip("KISS code"); source_code[10]->down_box(FL_DOWN_BOX); source_code[10]->callback((Fl_Callback*)cb_source_codea); } // Fl_Check_Button* source_code[10] { source_code[11] = new Fl_Check_Button(394, 40, 70, 15, "MacLog"); source_code[11]->tooltip("Mac Logger i/o"); source_code[11]->down_box(FL_DOWN_BOX); source_code[11]->callback((Fl_Callback*)cb_source_codeb); } // Fl_Check_Button* source_code[11] { source_code[12] = new Fl_Check_Button(477, 5, 70, 15, "FD Log"); source_code[12]->tooltip("FD log i/o"); source_code[12]->down_box(FL_DOWN_BOX); source_code[12]->callback((Fl_Callback*)cb_source_codec); } // Fl_Check_Button* source_code[12] { source_code[13] = new Fl_Check_Button(477, 22, 70, 15, "N3FJP log"); source_code[13]->tooltip("N3FJP log i/o"); source_code[13]->down_box(FL_DOWN_BOX); source_code[13]->callback((Fl_Callback*)cb_source_coded); } // Fl_Check_Button* source_code[13] { source_code[14] = new Fl_Check_Button(477, 40, 70, 15, "Other"); source_code[14]->tooltip("All other code"); source_code[14]->down_box(FL_DOWN_BOX); source_code[14]->callback((Fl_Callback*)cb_source_codee); } // Fl_Check_Button* source_code[14] o->end(); } // Fl_Group* o { btext = new Fl_Browser(0, 60, 570, 180); Fl_Group::current()->resizable(btext); } // Fl_Browser* btext o->size_range(570, 240); o->end(); } // Fl_Double_Window* o return w; }
7,368
C++
.cxx
169
37.550296
76
0.613991
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,233
debug.cxx
w1hkj_fldigi/src/debug/debug.cxx
// ---------------------------------------------------------------------------- // debug.cxx // // Copyright (C) 2008-2010 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #ifdef __MINGW32__ # include "compat.h" #endif #include <sstream> #include <fstream> #include <cstdio> #include <cstring> #include <cstdarg> #include <string> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <time.h> #include <FL/Fl.H> #include <FL/Fl_Double_Window.H> #include <FL/Fl_Slider.H> #include <FL/Fl_Menu_Item.H> #include <FL/Fl_Menu_Button.H> #include <FL/Fl_Button.H> #include <FL/Fl_Browser.H> #include "debug.h" #include "debug_dialog.h" #include "status.h" #include "timeops.h" #include "icons.h" #include "gettext.h" #include "threads.h" #ifndef FLARQ_VERSION # include "status.h" # include "fl_digi.h" #endif static pthread_mutex_t debug_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t debug_hd_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t rotate_mutex = PTHREAD_MUTEX_INITIALIZER; extern Fl_Double_Window *fl_digi_main; extern void update_main_title(); #define MAX_LINES 65536 static FILE* wfile = 0; static FILE* rfile = 0; static int rfd; static bool tty; static Fl_Double_Window* window; static std::string linebuf; debug* debug::inst = 0; debug::level_e debug::level = debug::INFO_LEVEL; static const char* prefix[] = { _("Quiet"), _("Error"), _("Warning"), _("Info"), _("Verbose"), _("Debug") }; unsigned int debug::mask = 0; #include <iostream> void fcopy(std::string from, std::string to) { char buffer[65536]; FILE *fp_from, *fp_to; size_t n; if ((fp_from = fopen(from.c_str(), "rb")) != NULL) { if ((fp_to = fopen(to.c_str(), "wb")) != NULL) { while(1) { if (feof(fp_from)) break; // memset(buffer, 0, sizeof(buffer)); if ((n = fread(buffer, 1, sizeof(buffer), fp_from)) > 0) n = fwrite(buffer, 1, n, fp_to); else break; } fflush(fp_to); fclose(fp_to); } fclose(fp_from); } } void rotate_log(std::string filename) { guard_lock rlock(&rotate_mutex); std::string oldfn, newfn; const char *ext[] = {".1", ".2", ".3", ".4", ".5"}; for (int i = 4; i > 0; i--) { newfn.assign(filename).append(ext[i]); oldfn.assign(filename).append(ext[i - 1]); fcopy(oldfn, newfn); } newfn.assign(filename).append(ext[0]); fcopy(filename, newfn); } void debug::start(const char* filename) { if (debug::inst) return; rotate_log(filename); inst = new debug(filename); window = debug_dialog(); } void debug::stop(void) { if (window) { window->hide(); delete window; window = 0; //std::cout << "debug window deleted" << std::endl; } // if (inst) { // delete inst; // inst = 0; //std::cout << "instance deleted" << std::endl; // } //std::cout << "debug stopped" << std::endl; } static char fmt[2048]; static char dtext[32768]; void debug::log(level_e level, const char* func, const char* srcf, int line, const char* format, ...) { guard_lock debug_lock(&debug_mutex); if (!debug::inst) return; // always annotate with date/time & line number struct tm tm; time_t t_temp; struct timeval tv; gettimeofday(&tv, NULL); t_temp=(time_t)tv.tv_sec; // gmtime_r(&t_temp, &tm); localtime_r(&t_temp, &tm); static int _zmsec = 0; static int _zsec = 0; static int _zmin = 0; static int _zhr = 0; _zmsec = tv.tv_usec / 1000; _zsec = tm.tm_sec; _zmin = tm.tm_min; _zhr = tm.tm_hour; snprintf(fmt, sizeof(fmt), "%c: [%02d:%02d:%02d.%03d] %s : %d : %s\n %s\n", *prefix[level], _zhr, _zmin, _zsec, _zmsec, srcf, line, func, format); va_list args; va_start(args, format); intptr_t nt = vsnprintf(dtext, sizeof(dtext), fmt, args); va_end(args); fprintf(wfile, "%s", dtext); if (tty) { if (level <= DEBUG_LEVEL && level > QUIET_LEVEL) { fprintf(stderr, "%s", dtext); } } #ifdef __MINGW32__ fflush(wfile); #endif linebuf.append(dtext); Fl::awake(sync_text, (void*)nt); } void debug::hex_dump(const char* func, const char * data, int length) { guard_lock debug_lock(&debug_hd_mutex); char cbuff[32]; char hbuff[64]; char tbuff[32]; int index = 0; int data_index = 0; int count = length; unsigned int c = 0; int hi = 0; int step = 16; if(!func) func = "Unassigned"; if(!data || length < 0) return; while(count > 0) { memset(cbuff, 0, sizeof(cbuff)); memset(hbuff, 0, sizeof(hbuff)); memset(tbuff, 0, sizeof(tbuff)); hi = 0; for(index = 0; index < step; index++) { if(data_index < length) { c = ((unsigned int) data[data_index]) & 0xFF; if(c >= ' ' && c <= 0xff) { cbuff[index] = c; } else { cbuff[index] = '.'; } snprintf(tbuff, sizeof(tbuff) - 1, "%02X", c); hbuff[hi++] = tbuff[0]; hbuff[hi++] = tbuff[1]; hbuff[hi++] = ' '; } else { break; } data_index++; } if (debug::inst) LOG_DEBUG("%s: %s %s", func, cbuff, hbuff); count -= step; } } void debug::elog(const char* func, const char* srcf, int line, const char* text) { if (debug::inst) log(ERROR_LEVEL, func, srcf, line, "%s: %s", text, strerror(errno)); } void debug::show(void) { btext->bottomline(btext->size()); window->show(); } void debug::sync_text(void* arg) { guard_lock debug_lock(&debug_mutex); if (!window) return; size_t p1 = 0, p2 = linebuf.find("\n"); while (p2 != std::string::npos) { btext->add(linebuf.substr(p1, p2 - p1).c_str()); p1 = p2 + 1; p2 = linebuf.find("\n", p1); } btext->redraw(); btext->bottomline(btext->size()); linebuf.clear(); return; } debug::debug(const char* filename) { if ((wfile = fl_fopen(filename, "w")) == NULL) throw strerror(errno); setvbuf(wfile, (char*)NULL, _IOLBF, 0); set_cloexec(fileno(wfile), 1); if ((rfile = fl_fopen(filename, "r")) == NULL) throw strerror(errno); rfd = fileno(rfile); set_cloexec(rfd, 1); #ifndef __MINGW32__ int f; if ((f = fcntl(rfd, F_GETFL)) == -1) throw strerror(errno); if (fcntl(rfd, F_SETFL, f | O_NONBLOCK) == -1) throw strerror(errno); #endif tty = isatty(fileno(stderr)); linebuf.clear(); } debug::~debug() { if (wfile) fclose(wfile); if (rfile) fclose(rfile); // if (window) { // window->hide(); // delete window; // window = 0; // } // if (inst) { // delete inst; // inst = 0; // } } void mnu_debug_level_cb() { debug::level = (debug::level_e)(mnu_debug_level->value()); } void btn_debug_source_cb(int n) { int mask = 1 << n; if (source_code[n]->value()) debug::mask |= mask; else debug::mask &= ~mask; } void clear_debug() { guard_lock debug_lock(&debug_mutex); btext->clear(); linebuf.clear(); } void set_debug_mask(int mask) { debug::mask = mask; for (int n = 0; n < 15; n++) { source_code[n]->value( (mask & (1 << n)) ? 1 : 0); source_code[n]->redraw(); } mnu_debug_level->value(progStatus.debug_level); debug::level = debug::level_e(progStatus.debug_level); }
7,613
C++
.cxx
301
23.182724
101
0.640325
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,234
create_default_script.cxx
w1hkj_fldigi/src/config_script/create_default_script.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2015 // Robert Stiles // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <cstdlib> #include <cstdarg> #include <string> #include <fstream> #include <algorithm> #include <map> #include <unistd.h> #include <iostream> #include <fstream> #include <sstream> #include <cstring> #include <ctime> #include <vector> #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <errno.h> #include <time.h> #include <pthread.h> #include <libgen.h> #include <ctype.h> #include <sys/time.h> #include <string.h> #include "config.h" #include <sys/types.h> #ifdef __WOE32__ # ifdef __CYGWIN__ # include <w32api/windows.h> # else # include <windows.h> # endif #endif #include <cstdlib> #include <cstdarg> #include <string> #include <fstream> #include <algorithm> #include <map> #ifndef __WOE32__ #include <sys/wait.h> #endif #include "gettext.h" #include "fl_digi.h" #include <FL/Fl.H> #include <FL/fl_ask.H> #include <FL/Fl_Pixmap.H> #include <FL/Fl_Image.H> //#include <FL/Fl_Tile.H> #include <FL/x.H> #include <FL/Fl_Help_Dialog.H> #include <FL/Fl_Progress.H> #include <FL/Fl_Tooltip.H> #include <FL/Fl_Tabs.H> #include <FL/Fl_Multiline_Input.H> #include <FL/Fl_Menu_Bar.H> #include <FL/Fl_Pack.H> #include <FL/filename.H> #include <FL/fl_ask.H> #include "waterfall.h" #include "raster.h" #include "progress.h" #include "Panel.h" #include "main.h" #include "threads.h" #include "trx.h" #if USE_HAMLIB #include "hamlib.h" #endif #include "timeops.h" #include "rigio.h" #include "nullmodem.h" #include "psk.h" #include "cw.h" #include "mfsk.h" #include "wefax.h" #include "wefax-pic.h" #include "navtex.h" #include "mt63.h" #include "view_rtty.h" #include "olivia.h" #include "contestia.h" #include "thor.h" #include "dominoex.h" #include "feld.h" #include "throb.h" //#include "pkt.h" #include "wwv.h" #include "analysis.h" #include "ssb.h" #include "smeter.h" #include "pwrmeter.h" #include "ascii.h" #include "globals.h" #include "misc.h" #include "FTextRXTX.h" #include "confdialog.h" #include "configuration.h" #include "status.h" #include "macros.h" #include "macroedit.h" #include "logger.h" #include "lookupcall.h" #include "font_browser.h" #include "icons.h" #include "pixmaps.h" #include "rigsupport.h" #include "qrunner.h" #include "Viewer.h" #include "soundconf.h" #include "htmlstrings.h" # include "xmlrpc.h" #if BENCHMARK_MODE # include "benchmark.h" #endif #include "debug.h" #include "re.h" #include "network.h" #include "spot.h" #include "dxcc.h" #include "locator.h" #include "notify.h" #include "logbook.h" #include "rx_extract.h" #include "speak.h" #include "flmisc.h" #include "arq_io.h" #include "data_io.h" #include "kmlserver.h" #include "notifydialog.h" #include "macroedit.h" #include "rx_extract.h" #include "wefax-pic.h" #include "charsetdistiller.h" #include "charsetlist.h" #include "outputencoder.h" #include "record_loader.h" #include "record_browse.h" #include "fileselect.h" #include "waterfall.h" #include "util.h" #include "script_parsing.h" #include "run_script.h" void cb_create_default_script(void); static int create_default_script(char *file_name); static int add_command(FILE *fd, char *cmd, int param, int indent_level); static int add_command(FILE *fd, char *cmd, char * param, int indent_level); static int add_command(FILE *fd, char *cmd, int indent_level); static int add_command(FILE *fd, char *cmd, bool param, int indent_level); static int add_command(FILE *fd, char *cmd, double param, int indent_level); static int add_string(FILE *fd, char *cmd, int indent_level); static void write_macro_list(FILE *fd); extern pthread_mutex_t mutex_script_io; /** ******************************************************** * \brief Menu callback. Create default script based on the * current settings. * \param none * \return void ***********************************************************/ void cb_create_default_script(void) { pthread_mutex_lock(&mutex_script_io); static bool first_time = true; static char script_filename[FL_PATH_MAX + 1]; std::string new_path = ""; if(first_time) { memset(script_filename, 0, sizeof(script_filename)); strncpy(script_filename, ScriptsDir.c_str(), FL_PATH_MAX); int len = strnlen(script_filename, FL_PATH_MAX); if(len > 0) { len--; if(script_filename[len] == PATH_CHAR_SEPERATOR); else strncat(script_filename, PATH_SEPERATOR, FL_PATH_MAX); } else { return; } strncat(script_filename, "default_script.txt", FL_PATH_MAX); first_time = false; } const char *p = FSEL::saveas((char *)_("Script Files"), (char *)_("*.txt"), \ script_filename); if(p) { memset(script_filename, 0, sizeof(script_filename)); strncpy(script_filename, p, FL_PATH_MAX); Fl::lock(); create_default_script(script_filename); Fl::unlock(); } pthread_mutex_unlock(&mutex_script_io); } /** ******************************************************** * \brief Create default script based on current settings. * \param file_name Pointer to the file name and path. * \return 0 OK, other Error ***********************************************************/ static int create_default_script(char *file_name) { FILE *fd = (FILE *)0; static char buffer[FL_PATH_MAX]; std::string temp = ""; if(!file_name) { LOG_INFO(_("Invalid File Name Pointer (NULL) in function %s:%d"), __FILE__, __LINE__); return -1; } fd = fl_fopen(file_name, "w"); if(!fd) { LOG_INFO(_("Unable to create file %s (Error No=%d) func %s:%d"), file_name, errno, __FILE__, __LINE__); return -1; } memset(buffer, 0, sizeof(buffer)); // Tag the text file as a FLDIGI script file fprintf(fd, _("%s\n# Fldigi Generated Config Script\n"), SCRIPT_FILE_TAG); time_t thetime = time(0); fprintf(fd, _("# Created: %s\n"), ctime(&thetime)); // FLDIGI Main Window if(add_command(fd, (char *)CMD_FLDIGI, 0)) return fclose(fd); if(add_command(fd, (char *)CMD_FLDIGI_FREQ, (double) qsoFreqDisp->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_FLDIGI_MODE, (char *) qso_opMODE->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_FLDIGI_WFHZ, (int) wf->Carrier(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_FLDIGI_RXID, (bool) btnRSID->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_FLDIGI_TXID, (bool) btnTxRSID->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_FLDIGI_SPOT, (bool) btnAutoSpot->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_FLDIGI_REV, (bool) wf->btnRev->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_FLDIGI_AFC, (bool) btnAFC->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_FLDIGI_LOCK, (bool) wf->xmtlock->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_FLDIGI_SQL, (bool) btnSQL->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_FLDIGI_KPSQL, (bool) btnPSQL->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_FLDIGI_MODEM, (char *) active_modem->get_mode_name(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); // OPERATOR if(add_command(fd, (char *)CMD_OPERATOR, 0)) return fclose(fd); if(add_command(fd, (char *)CMD_CALLSIGN, (char *) inpMyCallsign->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_QTH, (char *) inpMyName->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_NAME, (char *) inpMyQth->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_LOCATOR, (char *) inpMyLocator->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_ANTENNA, (char *) inpMyAntenna->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); // AUDIO DEVICE if(add_command(fd, (char *)CMD_AUDIO_DEVICE, 0)) return fclose(fd); #if USE_OSS // OSS if(add_command(fd, (char *)CMD_OSS_AUDIO, (bool) btnAudioIO[0]->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_OSS_AUDIO_DEV_PATH, (char *) menuOSSDev->value(), 1)) return fclose(fd); #endif // USE_OSS #if USE_PORTAUDIO // PORT AUDIO if(add_command(fd, (char *)CMD_PORT_AUDIO, (bool) btnAudioIO[1]->value(), 1)) return fclose(fd); if(menuPortInDev->value() > -1) { memset(buffer, 0, sizeof(buffer)); // Invalid warning issued (clang-600.0.56 [3.5] MacOSX) if index is replaced with reinterpret_cast<intptr_t>(x) in snprintf() routine. int index = reinterpret_cast<intptr_t>(menuPortInDev->mvalue()->user_data()); snprintf(buffer, sizeof(buffer)-1, "%s:%d,\"%s\"", CMD_PORTA_CAP, index, menuPortInDev->text()); if(add_string(fd, (char *)buffer, 1)) return fclose(fd); } if(menuPortOutDev->value() > -1) { memset(buffer, 0, sizeof(buffer)); // Invalid warning issued (clang-600.0.56 [3.5] MacOSX) if index is replaced with reinterpret_cast<intptr_t>(x) in snprintf() routine. int index = reinterpret_cast<intptr_t>(menuPortOutDev->mvalue()->user_data()); snprintf(buffer, sizeof(buffer)-1, "%s:%d,\"%s\"", CMD_PORTA_PLAY, index, menuPortOutDev->text()); if(add_string(fd, (char *)buffer, 1)) return fclose(fd); } #endif // USE_PORTAUDIO #if USE_PULSEAUDIO // PULSE AUDIO if(add_command(fd, (char *)CMD_PULSEA, (bool) btnAudioIO[2]->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_PULSEA_SERVER, (char *) inpPulseServer->value(), 1)) return fclose(fd); #endif // USE_PULSEAUDIO if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); // AUDIO SETTINGS if(add_command(fd, (char *)CMD_AUDIO_SETTINGS, 0)) return fclose(fd); if(add_command(fd, (char *)CMD_CAPTURE_SAMPLE_RATE, (char *) menuInSampleRate->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_PLAYBACK_SAMPLE_RATE, (char *) menuOutSampleRate->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_AUDIO_CONVERTER, (char *) menuSampleConverter->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RX_PPM, (int) cntRxRateCorr->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_TX_PPM, (int) cntTxRateCorr->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_TX_OFFSET, (int) cntTxOffset->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); // AUDIO RIGHT CHANNEL if(add_command(fd, (char *)CMD_AUDIO_RT_CHANNEL, 0)) return fclose(fd); if(add_command(fd, (char *)CMD_AUDIO_L_R, (bool) chkAudioStereoOut->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_AUDIO_REV_L_R, (bool) chkReverseAudio->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_PTT_RIGHT_CHAN, (bool) btnPTTrightchannel2->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_CW_QSK_RT_CHAN, (bool) btnQSK2->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_PSEUDO_FSK_RT_CHAN, (bool) chkPseudoFSK2->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); // AUDIO WAVE if(add_command(fd, (char *)CMD_AUDIO_WAVE, 0)) return fclose(fd); if(add_command(fd, (char *)CMD_WAVE_SR, (char *) listbox_wav_samplerate->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); // RIG HRDWR PTT if(add_command(fd, (char *)CMD_HRDWR_PTT, 0)) return fclose(fd); if(add_command(fd, (char *)CMD_HPPT_PTT_RT, (bool) btnPTTrightchannel->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HPTT_SP2, (bool) btnTTYptt->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HPTT_SP2_PATH, (char *) inpTTYdev->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HPTT_SP2_RTS, (bool) btnRTSptt->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HPTT_SP2_RTS_V, (bool) btnRTSplusV->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HPTT_SP2_DTR, (bool) btnDTRptt->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HPTT_SP2_DTR_V, (bool) btnDTRplusV->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HPTT_PARALLEL, (bool) btnUsePPortPTT->value(), 1)) return fclose(fd); #if HAVE_UHROUTER if(add_command(fd, (char *)CMD_HPTT_UHROUTER, (bool) btnUseUHrouterPTT->value(), 1)) return fclose(fd); #endif if(add_command(fd, (char *)CMD_HPTT_SP2_START_DELAY, (int) cntPTT_on_delay->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HPTT_SP2_END_DELAY, (int) cntPTT_off_delay->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HPTT_SP2_INITIALIZE, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); // Cmedia PTT if(add_command(fd, (char *)CMD_CMEDIA_PTT, 0)) return fclose(fd); if(add_command(fd, (char *)CMD_USE_CMEDIA_PTT, (bool) btn_use_cmedia_PTT->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_CMEDIA_DEV, (char *) progdefaults.cmedia_device.c_str(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_CMEDIA_GPIO_LINE, (char *) progdefaults.cmedia_gpio_line.c_str(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); // RIG CAT if(add_command(fd, (char *)CMD_RIGCAT, 0)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_STATE, (bool) chkUSERIGCAT->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_DEV_PATH, (char *) inpXmlRigDevice->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_DESC_FILE, (char *) progdefaults.XmlRigFilename.c_str(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_RETRIES, (int) cntRigCatRetries->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_RETRY_INTERVAL, (int) cntRigCatTimeout->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_WRITE_DELAY, (int) cntRigCatWait->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_INTIAL_DELAY, (int) cntRigCatInitDelay->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_BAUD_RATE, (char *) listbox_xml_rig_baudrate->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_STOP_BITS, (int) valRigCatStopbits->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_ECHO, (bool) btnRigCatEcho->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_TOGGLE_RTS_PTT, (bool) btnRigCatRTSptt->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_RESTORE, (bool) chk_restore_tio->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_PTT_COMMAND, (bool) btnRigCatCMDptt->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_TOGGLE_DTR_PTT, (bool) btnRigCatDTRptt->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_TOGGLE_RTS_PTT, (bool) btnRigCatRTSptt->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_RTS_12V, (bool) btnRigCatRTSplus->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_DTR_12V, (bool) btnRigCatDTRplus->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_HRDWR_FLOW, (bool) chkRigCatRTSCTSflow->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_VSP, (bool) chkRigCatVSP->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_RIGCAT_INITIALIZE, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); #if USE_HAMLIB // HAMLIB if(add_command(fd, (char *)CMD_HAMLIB, 0)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_STATE, (bool) chkUSEHAMLIB->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_RIG, (char *) cboHamlibRig->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_DEV_PATH, (char *) inpRIGdev->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_RETRIES, (int) cntHamlibRetries->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_RETRY_INTERVAL, (int) cntHamlibTimeout->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_WRITE_DELAY, (int) cntHamlibWriteDelay->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_POST_WRITE_DELAY, (int) cntHamlibWait->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_BAUD_RATE, (char *) listbox_baudrate->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_STOP_BITS, (int) valHamRigStopbits->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_POLL_RATE, (int) valHamRigPollrate->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_SIDE_BAND, (char *) listbox_sideband->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_PTT_COMMAND, (bool) btnHamlibCMDptt->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_DTR_12V, (bool) btnHamlibDTRplus->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_RTS_12V, (bool) btnHamlibDTRplus->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_HRDWR_FLOW, (bool) chkHamlibRTSCTSflow->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_SFTWR_FLOW, (bool) chkHamlibXONXOFFflow->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_ADV_CONFIG, (char *) inpHamlibConfig->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_HAMLIB_INITIALIZE, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); #endif //#if USE_HAMLIB // IO Config Panel if(add_command(fd, (char *)CMD_IO, 0)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_LOCK, (bool) btnDisable_p2p_io_widgets->value(), 1)) return fclose(fd); if(btnEnable_arq->value()) { if(add_command(fd, (char *)CMD_IO_ACT_PORT, (char *) PARM_ARQ, 1)) return fclose(fd); } else if(btnEnable_kiss->value()) { if(add_command(fd, (char *)CMD_IO_ACT_PORT, (char *) PARM_KISS, 1)) return fclose(fd); } if(add_command(fd, (char *)CMD_IO_AX25_DECODE, (bool) btnEnable_ax25_decode->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_CSMA, (bool) btnEnable_csma->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_KISS, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_KISS_IPA, (char *) txtKiss_ip_address->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_KISS_IOPN, (char *) txtKiss_ip_io_port_no->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_KISS_OPN, (char *) txtKiss_ip_out_port_no->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_KISS_DP, (bool) btnEnable_dual_port->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_KISS_BUSY, (bool) btnEnableBusyChannel->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_KISS_CONT, (int) cntBusyChannelSeconds->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_KISS_ATTEN, (int) cntKPSQLAttenuation->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_ARQ, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_ARQ_IPA, (char *) txtArq_ip_address->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_ARQ_IOPN, (char *) txtArq_ip_port_no->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_XMLRPC, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_XMLRPC_IPA, (char *) txtXmlrpc_ip_address->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_IO_XMLRPC_IOPN, (char *) txtXmlrpc_ip_port_no->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); // NBEMS if(add_command(fd, (char *)CMD_NBEMS, 0)) return fclose(fd); if(add_command(fd, (char *)CMD_NBEMS_STATE, (bool) chkAutoExtract->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_NBEMS_MSG, (bool) chk_open_wrap_folder->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_NBEMS_FLMSG, (bool) chk_open_flmsg->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_NBEMS_FLMSG_PATH, (char *) txt_flmsg_pathname->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_NBEMS_BRWSR, (bool) chk_open_flmsg_print->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_NBEMS_TIMEOUT, (double) sldr_extract_timeout->value(), 1)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); // ID/RSID/VIDEO/CW if(add_command(fd, (char *)CMD_ID, 0)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_RSID, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_RSID_NOTIFY, (bool) chkRSidNotifyOnly->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_RSID_SRCH_BP, (bool) chkRSidWideSearch->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_RSID_MARK_PREV, (bool) chkRSidMark->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_RSID_DETECTOR, (bool) chkRSidAutoDisable->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_RSID_ALRT_DIALOG, (bool) chkRSidShowAlert->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_RSID_TX_FREQ_LOCK, (bool) chkRetainFreqLock->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_RSID_FREQ_CHANGE, (bool) chkDisableFreqChange->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_RSID_ALLOW_ERRORS, (char *) listbox_rsid_errors->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_RSID_SQL_OPEN, (int) val_RSIDsquelch->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_RSID_PRETONE, (double) val_pretone->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_RSID_END_XMT_ID, (bool) btn_post_rsid->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_VIDEO, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_VIDEO_TX_ID_MODE, (bool) btnsendid->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_VIDEO_TX_VIDEO_TXT, (bool) btnsendvideotext->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_VIDEO_TX_TXT_INP, (char *) valVideotext->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_VIDEO_SMALL_FONT, (bool) chkID_SMALL->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_VIDEO_500_HZ, (bool) btn_vidlimit->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_VIDEO_WIDTH_LIMIT, (bool) btn_vidmodelimit->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_VIDEO_CHAR_ROW, (int) sldrVideowidth->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_CW, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_CW_TX_CALLSIGN, (bool) btnCWID->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_ID_CW_SPEED, (int) sldrCWIDwpm->value(), 2)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 1)) return fclose(fd); if(add_command(fd, (char *)CMD_END_CMD, 0)) return fclose(fd); // MACROS write_macro_list(fd); return fclose(fd); } /** ******************************************************** * \brief Write the current macro list in script format * \param fd File descriptor * \param cmd Pointer to the file name and path. * \return 0 OK, other Error ***********************************************************/ static void write_macro_list(FILE *fd) { if(!fd) return; int index = 0; int row = 0; int col = 0; bool save_flag = false; int count = 0; char * cPtr = (char *)0; for(index = 0; index < MAXMACROS; index++) { // Do not save empty macros count = macros.text[index].size(); if(count < 1) continue; cPtr = (char *) macros.text[index].c_str(); while(count-- > 0) { if(*cPtr++ > ' ') { save_flag = true; break; } } if(save_flag) { col = (index / NUMMACKEYS) + 1; row = (index % NUMMACKEYS) + 1; fprintf(fd, "\n%s:%d,%d,\"%s\"\n", (char *) CMD_LOAD_MACRO, col, row, macros.name[index].c_str()); fprintf(fd, "%s\n", macros.text[index].c_str()); fprintf(fd, "%s:\n",(char *) CMD_END_CMD); save_flag = false; } } } /** ******************************************************** * \brief Add command and paramter to script file * \param fd File descriptor * \param cmd Pointer to the file name and path. * \return 0 OK, other Error ***********************************************************/ static int add_command(FILE *fd, char *cmd, double param, int indent_level) { if(!fd || !cmd) return -1; char buffer[32]; memset(buffer, 0, sizeof(buffer)); if((param > -1000.0) && (param < 1000.0)) snprintf(buffer, sizeof(buffer) - 1, "%1.3f", param); else snprintf(buffer, sizeof(buffer) - 1, "%1.9e", param); return add_command(fd, cmd, buffer, indent_level); } /** ******************************************************** * \brief Add command and paramter to script file * \param fd File descriptor * \param cmd Pointer to the file name and path. * \return 0 OK, other Error ***********************************************************/ static int add_command(FILE *fd, char *cmd, bool param, int indent_level) { if(!fd || !cmd) return -1; char buffer[32]; memset(buffer, 0, sizeof(buffer)); if(param) strncpy(buffer, PARM_ENABLE, sizeof(buffer)-1); else strncpy(buffer, PARM_DISABLE, sizeof(buffer)-1); return add_command(fd, cmd, buffer, indent_level); } /** ******************************************************** * \brief Add command and paramter to script file * \param fd File descriptor * \param cmd Pointer to the file name and path. * \return 0 OK, other Error ***********************************************************/ static int add_command(FILE *fd, char *cmd, int param, int indent_level) { if(!fd || !cmd) return -1; char buffer[32]; memset(buffer, 0, sizeof(buffer)); snprintf(buffer, sizeof(buffer) - 1, "%d", param); return add_command(fd, cmd, buffer, indent_level); } /** ******************************************************** * \brief Add command and paramter to script file * \param fd File descriptor * \param cmd Pointer to the file name and path. * \return 0 OK, other Error ***********************************************************/ static int add_command(FILE *fd, char *cmd, char *param, int indent_level) { if(!fd || !cmd || !param) return -1; bool q_flag = false; int size = strnlen(param, FILENAME_MAX); if(size < 1) return 0; for(int i = 0; i < size; i++) { if(param[i] == 0) break; if((param[i] == ',') || (param[i] <= ' ')) { q_flag = true; } } std::string indent = ""; for(int i = 0; i < indent_level; i++) indent.append(" "); if(q_flag) fprintf(fd, "%s%s:\"%s\"\n", indent.c_str(), cmd, param); else fprintf(fd, "%s%s:%s\n", indent.c_str(), cmd, param); return ferror(fd); } /** ******************************************************** * \brief Add command and paramter to script file * \param fd File descriptor * \param cmd Pointer to the file name and path. * \return 0 OK, other Error ***********************************************************/ static int add_command(FILE *fd, char *cmd, int indent_level) { if(!fd || !cmd) return -1; std::string indent = ""; for(int i = 0; i < indent_level; i++) indent.append(" "); fprintf(fd, "%s%s:\n", indent.c_str(), cmd); return ferror(fd); } /** ******************************************************** * \brief Add command and paramter to script file * \param fd File descriptor * \param cmd Pointer to the file name and path. * \return 0 OK, other Error ***********************************************************/ static int add_string(FILE *fd, char *cmd, int indent_level) { if(!fd || !cmd) return -1; std::string indent = ""; for(int i = 0; i < indent_level; i++) indent.append(" "); fprintf(fd, "%s%s\n", indent.c_str(), cmd); return ferror(fd); }
30,772
C++
.cxx
593
49.917369
136
0.612297
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,235
run_scripts.cxx
w1hkj_fldigi/src/config_script/run_scripts.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2015 // Robert Stiles // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <cstdlib> #include <cstdarg> #include <string> #include <fstream> #include <algorithm> #include <map> #include <unistd.h> #include <iostream> #include <fstream> #include <sstream> #include <cstring> #include <ctime> #include <vector> #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <errno.h> #include <time.h> #include <pthread.h> #include <libgen.h> #include <ctype.h> #include <sys/time.h> #include "config.h" #include <sys/types.h> #ifdef __WOE32__ # ifdef __CYGWIN__ # include <w32api/windows.h> # else # include <windows.h> # endif #endif #include <cstdlib> #include <cstdarg> #include <string> #include <fstream> #include <algorithm> #include <map> #ifndef __WOE32__ #include <sys/wait.h> #endif #include "gettext.h" #include "fl_digi.h" #include <FL/Fl.H> #include <FL/fl_ask.H> #include <FL/Fl_Pixmap.H> #include <FL/Fl_Image.H> //#include <FL/Fl_Tile.H> #include <FL/x.H> #include <FL/Fl_Help_Dialog.H> #include <FL/Fl_Progress.H> #include <FL/Fl_Tooltip.H> #include <FL/Fl_Tabs.H> #include <FL/Fl_Multiline_Input.H> #include <FL/Fl_Menu_Bar.H> #include <FL/Fl_Pack.H> #include <FL/filename.H> #include <FL/fl_ask.H> #include "waterfall.h" #include "raster.h" #include "progress.h" #include "Panel.h" #include "main.h" #include "threads.h" #include "trx.h" #if USE_HAMLIB #include "hamlib.h" #endif #include "timeops.h" #include "rigio.h" #include "nullmodem.h" #include "psk.h" #include "cw.h" #include "mfsk.h" #include "wefax.h" #include "wefax-pic.h" #include "navtex.h" #include "mt63.h" #include "view_rtty.h" #include "olivia.h" #include "contestia.h" #include "thor.h" #include "dominoex.h" #include "feld.h" #include "throb.h" //#include "pkt.h" #include "wwv.h" #include "analysis.h" #include "ssb.h" #include "smeter.h" #include "pwrmeter.h" #include "ascii.h" #include "globals.h" #include "misc.h" #include "FTextRXTX.h" #include "confdialog.h" #include "configuration.h" #include "status.h" #include "macros.h" #include "macroedit.h" #include "logger.h" #include "lookupcall.h" #include "font_browser.h" #include "icons.h" #include "pixmaps.h" #include "rigsupport.h" #include "qrunner.h" #include "Viewer.h" #include "soundconf.h" #include "htmlstrings.h" # include "xmlrpc.h" #if BENCHMARK_MODE # include "benchmark.h" #endif #include "debug.h" #include "re.h" #include "network.h" #include "spot.h" #include "dxcc.h" #include "locator.h" #include "notify.h" #include "logbook.h" #include "rx_extract.h" #include "speak.h" #include "flmisc.h" #include "arq_io.h" #include "data_io.h" #include "kmlserver.h" #include "notifydialog.h" #include "macroedit.h" #include "rx_extract.h" #include "wefax-pic.h" #include "charsetdistiller.h" #include "charsetlist.h" #include "outputencoder.h" #include "record_loader.h" #include "record_browse.h" #include "fileselect.h" #include "script_parsing.h" #include "run_script.h" pthread_mutex_t mutex_script_io = PTHREAD_MUTEX_INITIALIZER; extern std::string ScriptsDir; void script_execute(void *); static void script_execute(const char *filename, bool queue_flag); /** ******************************************************** * \brief Template for assigning bool values to various widget types. * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ template <typename widget_type> static int assign_bool(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc, bool &data) { if(!sp || !sc) return script_function_parameter_error; bool value = 0; int error = sp->check_bool(sc->args[0], value); if(error != script_no_errors) return error; if(!widget) return script_no_errors; widget->value(value); widget->do_callback(); data = value; return script_no_errors; } /** ******************************************************** * \brief Template for assigning bool values to various widget types. * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ template <typename widget_type> static int assign_bool(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc) { bool data = false; return assign_bool(widget, sp, sc, data); } /** ******************************************************** * \brief Template for assigning integer values to various widget types. * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ template <typename widget_type> static int assign_integer(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc, int &data) { if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; int value = 0; int cnt = sscanf(str_data.c_str(), "%d", &value); if(cnt < 1) return script_invalid_parameter; if(!widget) return script_no_errors; int min = (int) widget->minimum(); int max = (int) widget->maximum(); if((value < min) || (value > max)) return script_invalid_parameter; widget->value(value); widget->do_callback(); data = value; return script_no_errors; } /** ******************************************************** * \brief Template for assigning integer values to various widget types. * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ template <typename widget_type> static int assign_integer(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc) { int data = 0.0; return assign_integer(widget, sp, sc, data); } /** ******************************************************** * \brief Template for assigning double values to various widget types. * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ template <typename widget_type> static int assign_double(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc, double &data) { if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; double value = 0; int cnt = sscanf(str_data.c_str(), "%lf", &value); if(cnt < 1) return script_invalid_parameter; if(!widget) return script_no_errors; double min = (double) widget->minimum(); double max = (double) widget->maximum(); if((value < min) || (value > max)) return script_invalid_parameter; widget->value(value); widget->do_callback(); data = value; return script_no_errors; } /** ******************************************************** * \brief Template for assigning double values to various widget types. * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ template <typename widget_type> static int assign_double(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc) { double data = 0.0; return assign_double(widget, sp, sc, data); } /** ******************************************************** * \brief Template for assigning string values to various widget types. * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ template <typename widget_type> static int assign_string(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc, std::string &data) { if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!widget) return script_no_errors; widget->value(str_data.c_str()); widget->do_callback(); data.assign(str_data); return script_no_errors; } /** ******************************************************** * \brief Template for assigning string values to various widget types. * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ template <typename widget_type> static int assign_string(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc) { std::string data = ""; return assign_string(widget, sp, sc, data); } /** ******************************************************** * \brief Template for assigning index values to various widget types. * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ template <typename widget_type> static int assign_index(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc, int &data) { if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!widget) return script_no_errors; int index = widget->find_index(str_data.c_str()); if(index < 0) return script_invalid_parameter; widget->index(index); widget->do_callback(); data = index; return script_no_errors; } /** ******************************************************** * \brief Template for assigning index values to various widget types. * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ template <typename widget_type> static int assign_index(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc) { int data = 0; return assign_index(widget, sp, sc, data); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rsid_notify(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkRSidNotifyOnly, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rsid_search_bp(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkRSidWideSearch, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rsid_mark_prev(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkRSidMark, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rsid_detector(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkRSidAutoDisable, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rsid_alert_dialog(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkRSidShowAlert, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rsid_tx_freq_lock(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkRetainFreqLock, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rsid_freq_change(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkDisableFreqChange, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rsid_allow_errors(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_index(listbox_rsid_errors, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rsid_sql_open(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_integer(val_RSIDsquelch, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rsid_pretone(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_double(val_pretone, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rsid_char_per_row(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_integer(sldrVideowidth, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rsid_end_xmt_id(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btn_post_rsid, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_video_tx_id_mode(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnsendid, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_video_tx_vid_txt(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnsendvideotext, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_video_txt_input(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_string(valVideotext, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_video_small_font(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkID_SMALL, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_video_500hz(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btn_vidlimit, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_video_width_limit(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btn_vidmodelimit, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_cw_callsign(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnCWID, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_cw_speed(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_integer(sldrCWIDwpm, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_misc_nbems_state(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkAutoExtract, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_misc_nbems_open_flmsg(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chk_open_flmsg, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_misc_nbems_open_msg(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chk_open_wrap_folder, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_misc_nbems_open_brwsr(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chk_open_flmsg_print, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_misc_nbems_flmsg_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_string(txt_flmsg_pathname, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_misc_nbems_timeout(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_integer(sldr_extract_timeout, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rig_freq(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!qsoFreqDisp) return script_no_errors; double value = 0; double max = (double) qsoFreqDisp->maximum(); int cnt = sscanf(str_data.c_str(), "%lf", &value); if(cnt < 1 || value < 0.0 || value > max) return script_invalid_parameter; qsy((long int) value, active_modem ? active_modem->get_freq() : 1500); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rig_mode(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_index(qso_opMODE, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_wf_hz_offset(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!cntrWfwidth) return script_no_errors; int value = 0; int cnt = sscanf(str_data.c_str(), "%d", &value); int min = 0; int max = cntrWfwidth->maximum(); if(cnt < 1 || value < min || value > max) return script_invalid_parameter; active_modem->set_freq(value); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rx_rsid(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnRSID, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_tx_rsid(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnTxRSID, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_spot(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnAutoSpot, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rev(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { if(!wf) return script_no_errors; return assign_bool(wf->btnRev, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_afc(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnAFC, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_lock(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { if(!wf) return script_no_errors; return assign_bool(wf->xmtlock, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_sql(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnSQL, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_kpsql(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnPSQL, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) **********************************************************/ int process_modem(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; bool modem_found = false; int index = 0; std::string value; value.assign(sc->args[0]); if(value.empty()) return script_parameter_error; sp->to_uppercase(value); for(index = 0; index < NUM_MODES; index++) { if(strncmp(value.c_str(), mode_info[index].sname, 32) == 0) { modem_found = true; break; } } if(modem_found == false) return script_invalid_parameter; if((data_io_enabled == KISS_IO) && (!(mode_info[index].iface_io & KISS_IO))) { LOG_INFO(_("Invalid Modem for KISS IO")); return script_invalid_parameter; } REQ_SYNC(init_modem_sync, index, 0); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_kiss_ip_address(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!txtKiss_ip_address) return script_no_errors; if(strncmp((const char *)str_data.c_str(), (const char *)txtKiss_ip_address->value(), 32) != 0) { txtKiss_ip_address->value(str_data.c_str()); txtKiss_ip_address->do_callback(); sp->restart_flag(true); } return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_kiss_io_port_no(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!txtKiss_ip_io_port_no) return script_no_errors; if(strncmp((const char *)str_data.c_str(), (const char *)txtKiss_ip_io_port_no->value(), 32) != 0) { txtKiss_ip_io_port_no->value(str_data.c_str()); txtKiss_ip_io_port_no->do_callback(); sp->restart_flag(true); } return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_kiss_o_port_no(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!txtKiss_ip_out_port_no) return script_no_errors; if(strncmp((const char *)str_data.c_str(), (const char *)txtKiss_ip_out_port_no->value(), 32) != 0) { txtKiss_ip_out_port_no->value(str_data.c_str()); txtKiss_ip_out_port_no->do_callback(); sp->restart_flag(true); } return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_kiss_dual_port(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnEnable_dual_port, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_kiss_busy_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnEnableBusyChannel, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_kiss_continue_after(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_integer(cntBusyChannelSeconds, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_kiss_kpsql_atten(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_integer(cntKPSQLAttenuation, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_arq_ip_address(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!txtArq_ip_address) return script_no_errors; if(strncmp((const char *)str_data.c_str(), (const char *)txtArq_ip_address->value(), 32) != 0) { txtArq_ip_address->value(str_data.c_str()); txtArq_ip_address->do_callback(); sp->restart_flag(true); } return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_arq_io_port_no(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!txtArq_ip_address) return script_no_errors; if(strncmp((const char *)str_data.c_str(), (const char *)txtArq_ip_port_no->value(), 32) != 0) { txtArq_ip_port_no->value(str_data.c_str()); txtArq_ip_port_no->do_callback(); sp->restart_flag(true); } return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_xmlrpc_ip_address(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!txtXmlrpc_ip_address) return script_no_errors; if(strncmp((const char *)str_data.c_str(), (const char *)txtXmlrpc_ip_address->value(), 32) != 0) { txtXmlrpc_ip_address->value(str_data.c_str()); txtXmlrpc_ip_address->do_callback(); sp->restart_flag(true); } return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_xmlrpc_io_port_no(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!txtXmlrpc_ip_port_no) return script_no_errors; if(strncmp((const char *)str_data.c_str(), (const char *)txtXmlrpc_ip_port_no->value(), 32) != 0) { txtXmlrpc_ip_port_no->value(str_data.c_str()); txtXmlrpc_ip_port_no->do_callback(); sp->restart_flag(true); } return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_lock(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnDisable_p2p_io_widgets, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_active_port(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string value; value.assign(sc->args[0]); if(value.empty()) return script_parameter_error; sp->to_uppercase(value); if(!btnEnable_kiss || !btnEnable_arq) return script_no_errors; if(value.find(PARM_KISS) != std::string::npos) { enable_kiss(); } else if(value.find(PARM_ARQ) != std::string::npos) { enable_arq(); } else { return script_invalid_parameter; } return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_ax25_decode(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnEnable_ax25_decode, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_io_csma(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnEnable_csma, sp, sc); } /** ******************************************************** * \brief Assign Call Sign. * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) * \par Note: * This string storage can be assigned to anything. User * should follow the limitations imposed by the rules * of the host country. ***********************************************************/ int process_callsign_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_string(inpMyCallsign, sp, sc); } /** ******************************************************** * \brief Operator Name * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_name_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_string(inpMyName, sp, sc); } /** ******************************************************** * \brief QTH Location of Operator * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_qth_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_string(inpMyQth, sp, sc); } /** ******************************************************** * \brief Assign Locator * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_locator_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_string(inpMyLocator, sp, sc); } /** ******************************************************** * \brief Assign Antenna information * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_antenna_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_string(inpMyAntenna, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_use_oss_audio_device(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_OSS return assign_bool(btnAudioIO[0], sp, sc); #else return script_no_errors; #endif // USE_OSS } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_oss_audio_device_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx #if USE_OSS if(!sp || !sc) return script_function_parameter_error; std::string str_data; std::string valid_data; str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!menuOSSDev) return script_no_errors; if(sp->check_dev_path(str_data.c_str())) return script_device_path_not_found; int index = 0; bool found = false; int count = menuOSSDev->menubutton()->size(); for (index = 0; index < count; index++ ) { const Fl_Menu_Item &item = menuOSSDev->menubutton()->menu()[index]; valid_data.assign(item.label()); if(!valid_data.empty()) { if(strncmp(valid_data.c_str(), str_data.c_str(), FL_PATH_MAX) == 0) { found = true; break; } } } if(!found) return script_invalid_parameter; menuOSSDev->value(index); menuOSSDev->do_callback(); return script_no_errors; #else return script_no_errors; #endif // USE_OSS } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_use_port_audio_device(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_PORTAUDIO return assign_bool(btnAudioIO[1], sp, sc); #else return script_no_errors; #endif // USE_PORTAUDIO } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_capture_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx #if USE_PORTAUDIO if(!sp || !sc) return script_function_parameter_error; int value = 0; std::string str_data = ""; if(sc->argc < 2) return script_invalid_parameter; int cnt = sscanf(sc->args[0], "%d", &value); if(cnt < 1 || value < 0) return script_invalid_parameter; str_data.assign(sc->args[1]); if(str_data.empty()) return script_invalid_parameter; if(!menuPortInDev) return script_no_errors; cnt = pa_set_dev(menuPortInDev, str_data, value); if(cnt == PA_DEV_NOT_FOUND) return script_invalid_parameter; #endif // USE_PORTAUDIO return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_playback_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx #if USE_PORTAUDIO if(!sp || !sc) return script_function_parameter_error; int value = 0; std::string str_data = ""; if(sc->argc < 2) return script_invalid_parameter; int cnt = sscanf(sc->args[0], "%d", &value); if(cnt < 1 || value < 0) return script_invalid_parameter; str_data.assign(sc->args[1]); if(str_data.empty()) return script_invalid_parameter; if(!menuPortOutDev) return script_no_errors; cnt = pa_set_dev(menuPortOutDev, str_data, value); if(cnt == PA_DEV_NOT_FOUND) return script_invalid_parameter; #endif return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_use_pulse_audio_device(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_PULSEAUDIO return assign_bool(btnAudioIO[2], sp, sc); #else return script_no_errors; #endif // USE_PULSEAUDIO } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_pulse_audio_device_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_PULSEAUDIO return assign_string(inpPulseServer, sp, sc); #else return script_no_errors; #endif // USE_PULSEAUDIO } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_audio_device_sample_rate_capture(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!menuInSampleRate) return script_no_errors; int index = menuInSampleRate->find_index(str_data.c_str()); if(index < 0) { str_data.append(" (native)"); index = menuInSampleRate->find_index(str_data.c_str()); } if(index < 0) return script_invalid_parameter; menuInSampleRate->index(index); menuInSampleRate->do_callback(); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_audio_device_sample_rate_playback(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!menuOutSampleRate) return script_no_errors; int index = menuOutSampleRate->find_index(str_data.c_str()); if(index < 0) { str_data.append(" (native)"); index = menuOutSampleRate->find_index(str_data.c_str()); } if(index < 0) return script_invalid_parameter; menuOutSampleRate->index(index); menuOutSampleRate->do_callback(); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_audio_device_converter(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data; std::string append_string; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; append_string.assign(" Sinc Interpolator"); if(str_data.find(append_string) != std::string::npos) append_string.clear(); if(append_string.empty()) { append_string.assign(" Interpolator"); if(str_data.find(append_string) != std::string::npos) { append_string.clear(); } } str_data.append(append_string); if(!menuSampleConverter) return script_no_errors; int index = menuSampleConverter->find_index(str_data.c_str()); if(index < 0) return script_invalid_parameter; menuSampleConverter->index(index); menuSampleConverter->do_callback(); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rx_ppm(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_integer(cntRxRateCorr, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_tx_ppm(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_integer(cntTxRateCorr, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_tx_offset(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_integer(cntTxOffset, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_modem_signal_left_right(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkAudioStereoOut, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_reverse_left_right(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkReverseAudio, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_ptt_tone_right_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnPTTrightchannel2, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_cw_qsk_right_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnQSK2, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_pseudo_fsk_right_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkPseudoFSK2, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_wave_file_sample_rate(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; char buffer[32]; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; int value = 0; int cnt = sscanf(str_data.c_str(), "%d", &value); if(cnt < 1) return script_invalid_parameter; if((value < 8000) || (value > 48000)) return script_invalid_parameter; memset(buffer, 0, sizeof(buffer)); snprintf(buffer, sizeof(buffer) - 1, "%d", value); if(!listbox_wav_samplerate) return script_no_errors; int index = listbox_wav_samplerate->find_index(buffer); if(index < 0) return script_invalid_parameter; listbox_wav_samplerate->index(index); listbox_wav_samplerate->do_callback(); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hrdw_ptt_right_audio_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnPTTrightchannel, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hrdw_ptt_sep_serial_port(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnTTYptt, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) * \par NOTE: * Fl_ComboBox (custom widget) * find_index() located in combo.cxx and used here returns -1 * on non-matching. ***********************************************************/ int process_hrdw_ptt_sep_serial_port_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_index(inpTTYdev, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hrdw_ptt_sep_serial_port_rts(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnRTSptt, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hrdw_ptt_sep_serial_port_dtr(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnDTRptt, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hrdw_ptt_sep_serial_port_rts_v(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnRTSplusV, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hrdw_ptt_sep_serial_port_dtr_v(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnDTRplusV, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hrdw_ptt_start_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_integer(cntPTT_on_delay, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hrdw_ptt_end_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_integer(cntPTT_off_delay, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hrdw_ptt_uhrouter(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if HAVE_UHROUTER return assign_bool(btnUseUHrouterPTT, sp, sc); #else return script_no_errors; #endif // HAVE_UHROUTER } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hrdw_ptt_parallel(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnUsePPortPTT, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hrdw_ptt_initialize(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { if(!btnInitHWPTT) return script_no_errors; btnInitHWPTT->do_callback(); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_cmedia_ptt(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { if (!btn_use_cmedia_PTT) return script_no_errors; btn_use_cmedia_PTT->do_callback(); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_cmedia_device(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; progdefaults.cmedia_device.assign(str_data); inp_cmedia_dev->value(progdefaults.cmedia_device.c_str()); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_cmedia_gpio_line(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; progdefaults.cmedia_gpio_line.assign(str_data); inp_cmedia_GPIO_line->value(progdefaults.cmedia_gpio_line.c_str()); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_use_rigcat(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(chkUSERIGCAT, sp, sc); } extern void loadRigXmlFile(void); /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_desc_file(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(str_data.find(DEFAULT_RIGXML_FILENAME) != std::string::npos) return script_no_errors; if(sp->check_filename((char *) str_data.c_str())) return script_file_not_found; if(!txtXmlRigFilename) return script_no_errors; progdefaults.XmlRigFilename.assign(str_data); txtXmlRigFilename->value(fl_filename_name(progdefaults.XmlRigFilename.c_str())); loadRigXmlFile(); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_device_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_index(inpXmlRigDevice, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_retries(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { int value = 0; int error = assign_integer(cntRigCatRetries, sp, sc, value); if(!error && cntRigCatRetries) { progdefaults.RigCatRetries = value; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_retry_interval(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { int value = 0; int error = assign_integer(cntRigCatTimeout, sp, sc, value); if(!error && cntRigCatTimeout) { progdefaults.RigCatTimeout = value; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_write_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { int value = 0; int error = assign_integer(cntRigCatWait, sp, sc, value); if(!error && cntRigCatWait) { progdefaults.RigCatTimeout = value; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_init_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { int value = 0; int error = assign_integer(cntRigCatInitDelay, sp, sc, value); if(!error && cntRigCatInitDelay) { progdefaults.RigCatInitDelay = value; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_baud_rate(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { int index = 0; int error = assign_index(listbox_xml_rig_baudrate, sp, sc, index); if(!error && listbox_xml_rig_baudrate) { progdefaults.XmlRigBaudrate = index; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_cat_command_ptt(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return assign_bool(btnRigCatCMDptt, sp, sc); } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_stop_bits(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { int value = 0; int error = assign_integer(valRigCatStopbits, sp, sc, value); if(!error && valRigCatStopbits) { progdefaults.RigCatStopbits = value; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_commands_echoed(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { bool value = 0; int error = assign_bool(btnRigCatEcho, sp, sc, value); if(!error && btnRigCatEcho) { progdefaults.RigCatECHO = value; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_toggle_rts_ptt(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { bool value = 0; int error = assign_bool(btnRigCatRTSptt, sp, sc, value); if(!error && btnRigCatRTSptt) { progdefaults.RigCatRTSptt = value; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_restore_on_close(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { bool value = 0; int error = assign_bool(chk_restore_tio, sp, sc, value); if(!error && chk_restore_tio) { progdefaults.RigCatRestoreTIO = value; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_rts_12v(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { bool value = 0; int error = assign_bool(btnRigCatRTSplus, sp, sc, value); if(!error && btnRigCatRTSplus) { progdefaults.RigCatRTSplus = value; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_dtr_12v(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { bool value = 0; int error = assign_bool(btnRigCatDTRplus, sp, sc, value); if(!error && btnRigCatDTRplus) { progdefaults.RigCatDTRplus = value; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_hrdwr_flow(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { bool value = 0; int error = assign_bool(chkRigCatRTSCTSflow, sp, sc, value); if(!error && chkRigCatRTSCTSflow) { progdefaults.RigCatRTSCTSflow = value; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_vsp_enable(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { bool value = 0; int error = assign_bool(chkRigCatVSP, sp, sc, value); if(!error && chkRigCatVSP) { progdefaults.RigCatVSP = value; progdefaults.changed = true; } return error; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_rigcat_initialize(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { if(!btnInitRIGCAT) return script_no_errors; btnInitRIGCAT->do_callback(); return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_use_hamlib(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB return assign_bool(chkUSEHAMLIB, sp, sc); #endif // USE_HAMLIB return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_rig(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB return assign_index(cboHamlibRig, sp, sc); #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_retries(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB int value = 0; int error = assign_integer(cntHamlibRetries, sp, sc, value); if(!error && cntHamlibRetries) { progdefaults.HamlibRetries = value; progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_retry_interval(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB int value = 0; int error = assign_integer(cntHamlibTimeout, sp, sc, value); if(!error && cntHamlibTimeout) { progdefaults.HamlibTimeout = value; progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_write_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB int value = 0; int error = assign_integer(cntHamlibWriteDelay, sp, sc, value); if(!error && cntHamlibWriteDelay) { progdefaults.HamlibWriteDelay = value; progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_post_write_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB int value = 0; int error = assign_integer(cntHamlibWait, sp, sc, value); if(!error && cntHamlibWait) { progdefaults.HamlibWait = value; progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) * \par Note: * This string storage can be assigned to anything. User * should follow the limitations imposed by the rules * of the host country. ***********************************************************/ int process_hamlib_device_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string str_data = ""; if(sc->argc > 0) str_data.assign(sc->args[0]); if(str_data.empty()) return script_invalid_parameter; if(!inpRIGdev) return script_no_errors; int index = inpRIGdev->find_index(str_data.c_str()); if(index < 0) return script_invalid_parameter; progdefaults.HamRigDevice.assign(str_data); progdefaults.changed = true; inpRIGdev->value(str_data.c_str()); inpRIGdev->do_callback(); #endif // USE_HAMLIB return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_baud_rate(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB int index = 0; int error = assign_index(listbox_baudrate, sp, sc, index); if(!error && listbox_baudrate) { progdefaults.HamRigBaudrate = index; progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_stop_bits(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB int value = 0; int error = assign_integer(valHamRigStopbits, sp, sc, value); if(!error && valHamRigStopbits) { progdefaults.HamRigStopbits = value; progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_poll_rate(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB int value = 0; int error = assign_integer(valHamRigPollrate, sp, sc, value); if(!error && valHamRigPollrate) { progdefaults.HamRigPollrate = value; progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_sideband(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB int index = 0; int error = assign_index(listbox_sideband, sp, sc, index); if(!error && listbox_sideband) { progdefaults.HamlibSideband = index; progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_ptt_hl_command(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB bool value = 0; int error = assign_bool(btnHamlibCMDptt, sp, sc, value); if(!error && btnHamlibCMDptt) { progdefaults.HamlibCMDptt = value; progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_dtr_12(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB bool value = 0; int error = assign_bool(btnHamlibDTRplus, sp, sc, value); if(!error && btnHamlibDTRplus) { progdefaults.HamlibDTRplus = value; progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_rts_12(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; bool value = 0; int error = sp->check_bool(sc->args[0], value); if(error != script_no_errors) return error; if(!chkHamlibRTSCTSflow || !chkHamlibRTSplus) return script_no_errors; if(chkHamlibRTSCTSflow->value()) value = false; progdefaults.HamlibRTSplus = value; progdefaults.changed = true; chkHamlibRTSplus->value(value); chkHamlibRTSplus->do_callback(); #endif // USE_HAMLIB return script_no_errors; } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_rts_cts_flow(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB bool value = 0; int error = assign_bool(chkHamlibRTSCTSflow, sp, sc, value); if(!error && chkHamlibRTSCTSflow) { progdefaults.HamlibRTSCTSflow = value; progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_xon_xoff_flow(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB bool value = 0; int error = assign_bool(chkHamlibXONXOFFflow, sp, sc, value); if(!error && chkHamlibXONXOFFflow) { progdefaults.HamlibXONXOFFflow = value; progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_advanced_config(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB std::string value = ""; int error = assign_string(inpHamlibConfig, sp, sc, value); if(!error && inpHamlibConfig) { progdefaults.HamConfig.assign(value); progdefaults.changed = true; } return error; #else return script_no_errors; #endif // USE_HAMLIB } /** ******************************************************** * \brief Initialize HAMLIB Parameters * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_hamlib_initialize(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { #if USE_HAMLIB if(!btnInitHAMLIB) return script_no_errors; btnInitHAMLIB->do_callback(); #endif // USE_HAMLIB return script_no_errors; } /** ******************************************************** * \brief Assign Macro information to there respective * macro button. * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_load_macro(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { // Not suitable for assign_xxxx if(!sp || !sc) return script_function_parameter_error; std::string macro_data = sp->macro_command(); std::string macro_label = ""; int col = 0; int row = 0; int index = 0; if(sc->argc < 3) return script_invalid_parameter; if((!sc->args[0]) || (!sc->args[1]) || (!sc->args[2])) return script_invalid_parameter; index = sscanf(sc->args[0], "%d", &col); if(index < 1) return script_invalid_parameter; index = sscanf(sc->args[1], "%d", &row); if(index < 1) return script_invalid_parameter; macro_label.assign(sc->args[2]); if(macro_label.empty()) return script_invalid_parameter; if(col > 0) col--; if(row > 0) row--; index = (col * NUMMACKEYS) + row; if((index < 0) || (index > MAXMACROS)) return script_invalid_parameter; if((col == 0) || ((col == altMacros) && (progdefaults.mbar_scheme > MACRO_SINGLE_BAR_MAX))) { update_macro_button(index, macro_data.c_str(), macro_label.c_str()); } else { macros.text[index].assign(macro_data); macros.name[index].assign(macro_label); } return script_no_errors; } /** ******************************************************** * \brief Reset Configuration panel attributes * \param sp Access to ScritpParsing members. * \param sc Access to SCRIPT_COMMANDS structure variables. * \return 0 (no error) Other (error) ***********************************************************/ int process_reset(ScriptParsing *sp, SCRIPT_COMMANDS *sc) { return script_no_errors; } /** ******************************************************** * \brief Pass script file name to script passing class * for execution. * Called from the File->Execute Config Script menu item. * \param void ***********************************************************/ static void script_execute(const char *filename, bool queue_flag) { ScriptParsing *sp = 0; static std::string script_filename = ""; if(!filename) { LOG_INFO(_("Script file name (path) null pointer")); return; } script_filename.assign(filename); if(script_filename.empty()) { LOG_INFO(_("Script file name (path) invalid")); return; } sp = new ScriptParsing; if(!sp) { LOG_INFO(_("Script Parsing Class Allocation Fail (%s)"), script_filename.c_str()); return; } LOG_INFO(_("Executing script file: %s"), script_filename.c_str()); sp->parse_commands((char *) script_filename.c_str()); if(sp->script_errors()) { LOG_INFO(_("Issues reported in processing script file: %s"), script_filename.c_str()); fl_alert("%s", _("Script file contains potential issues\nSee documentation and/or Log file for details.")); } if(sp->restart_flag()) { fl_alert("%s", _("Some changes made by the script requires program\nrestart before they become active.")); } if(sp) delete sp; } /** ******************************************************** * \brief Call back function when executing a configuration script. * Called from the File->Execute Config Script menu item. * \param void ***********************************************************/ void cb_scripts(bool reset_path = false) { pthread_mutex_lock(&mutex_script_io); static bool first_time = true; static char script_filename[FL_PATH_MAX + 1]; std::string new_path = ""; if(reset_path || first_time) { memset(script_filename, 0, sizeof(script_filename)); strncpy(script_filename, ScriptsDir.c_str(), FL_PATH_MAX); int len = strnlen(script_filename, FL_PATH_MAX); if(len > 0) { len--; if(script_filename[len] == PATH_CHAR_SEPERATOR); else strncat(script_filename, PATH_SEPERATOR, FL_PATH_MAX); } else { return; } first_time = false; } const char *p = FSEL::select((char *)_("Script Files"), (char *)_("*.txt"), \ script_filename); if(p) { memset(script_filename, 0, sizeof(script_filename)); strncpy(script_filename, p, FL_PATH_MAX); Fl::lock(); script_execute(script_filename, false); Fl::unlock(); } pthread_mutex_unlock(&mutex_script_io); }
85,232
C++
.cxx
2,434
33.031635
109
0.583268
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,236
script_parsing.cxx
w1hkj_fldigi/src/config_script/script_parsing.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2015 // Robert Stiles // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <string.h> #include "config.h" #include "util.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <pthread.h> #include <unistd.h> #include <sys/stat.h> #include <FL/fl_utf8.h> #include "debug.h" #include "gettext.h" #include "script_parsing.h" #include "run_script.h" // Do not use directly. It's copied for each instance static const SCRIPT_COMMANDS default_operator_command_table[] = { { CMD_CALLSIGN, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_callsign_info, 0, 0}, { CMD_NAME, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_name_info, 0, 0}, { CMD_QTH, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_qth_info, 0, 0}, { CMD_LOCATOR, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_locator_info, 0, 0}, { CMD_ANTENNA, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_antenna_info, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_audio_device_command_table[] = { { CMD_OSS_AUDIO, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_use_oss_audio_device, 0, 0}, { CMD_OSS_AUDIO_DEV_PATH, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_oss_audio_device_path, 0, 0}, { CMD_PORT_AUDIO, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_use_port_audio_device, 0, 0}, { CMD_PORTA_CAP, SCRIPT_COMMAND, 0, 2, {0}, { p_int, p_dev_name }, 0, 0, 0, process_capture_path, 0, 0}, { CMD_PORTA_PLAY, SCRIPT_COMMAND, 0, 2, {0}, { p_int, p_dev_name }, 0, 0, 0, process_playback_path, 0, 0}, { CMD_PULSEA, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_use_pulse_audio_device, 0, 0}, { CMD_PULSEA_SERVER, SCRIPT_COMMAND, 0, 1, {0}, { p_dev_path }, 0, 0, 0, process_pulse_audio_device_path, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_audio_settings_command_table[] = { { CMD_CAPTURE_SAMPLE_RATE, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_audio_device_sample_rate_capture, 0, 0}, { CMD_PLAYBACK_SAMPLE_RATE, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_audio_device_sample_rate_playback, 0, 0}, { CMD_AUDIO_CONVERTER, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_audio_device_converter, 0, 0}, { CMD_RX_PPM, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_rx_ppm, 0, 0}, { CMD_TX_PPM, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_tx_ppm, 0, 0}, { CMD_TX_OFFSET, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_tx_offset, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_audio_rt_channel_command_table[] = { { CMD_AUDIO_L_R, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_modem_signal_left_right, 0, 0}, { CMD_AUDIO_REV_L_R, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_reverse_left_right, 0, 0}, { CMD_PTT_RIGHT_CHAN, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_ptt_tone_right_channel, 0, 0}, { CMD_CW_QSK_RT_CHAN, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_cw_qsk_right_channel, 0, 0}, { CMD_PSEUDO_FSK_RT_CHAN, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_pseudo_fsk_right_channel, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_audio_wave_command_table[] = { { CMD_WAVE_SR, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_wave_file_sample_rate, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_rig_hrdwr_ptt_command_table[] = { { CMD_HPPT_PTT_RT, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_hrdw_ptt_right_audio_channel, 0, 0}, { CMD_HPTT_SP2, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_hrdw_ptt_sep_serial_port, 0, 0}, { CMD_HPTT_SP2_PATH, SCRIPT_COMMAND, 0, 1, {0}, { p_dev_path }, 0, 0, 0, process_hrdw_ptt_sep_serial_port_path, 0, 0}, { CMD_HPTT_SP2_RTS, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_hrdw_ptt_sep_serial_port_rts, 0, 0}, { CMD_HPTT_SP2_DTR, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_hrdw_ptt_sep_serial_port_dtr, 0, 0}, { CMD_HPTT_SP2_RTS_V, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_hrdw_ptt_sep_serial_port_rts_v, 0, 0}, { CMD_HPTT_SP2_DTR_V, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_hrdw_ptt_sep_serial_port_dtr_v, 0, 0}, { CMD_HPTT_SP2_START_DELAY, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_hrdw_ptt_start_delay, 0, 0}, { CMD_HPTT_SP2_END_DELAY, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_hrdw_ptt_end_delay, 0, 0}, { CMD_HPTT_UHROUTER, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_hrdw_ptt_uhrouter, 0, 0}, { CMD_HPTT_SP2_INITIALIZE, SCRIPT_COMMAND, 0, 0, {0}, { p_void }, 0, 0, 0, process_hrdw_ptt_initialize, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_cmedia_ptt_command_table[] = { { CMD_USE_CMEDIA_PTT, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_cmedia_ptt, 0, 0}, { CMD_CMEDIA_DEV, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_cmedia_device, 0, 0}, { CMD_CMEDIA_GPIO_LINE, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_cmedia_gpio_line, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_rigcat_command_table[] = { { CMD_RIGCAT_STATE, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_use_rigcat, 0, 0}, { CMD_RIGCAT_DESC_FILE, SCRIPT_COMMAND, 0, 1, {0}, { p_filename }, 0, 0, 0, process_rigcat_desc_file, 0, 0}, { CMD_RIGCAT_DEV_PATH, SCRIPT_COMMAND, 0, 1, {0}, { p_dev_path }, 0, 0, 0, process_rigcat_device_path, 0, 0}, { CMD_RIGCAT_RETRIES, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_rigcat_retries, 0, 0}, { CMD_RIGCAT_RETRY_INTERVAL, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_rigcat_retry_interval, 0, 0}, { CMD_RIGCAT_WRITE_DELAY, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_rigcat_write_delay, 0, 0}, { CMD_RIGCAT_INTIAL_DELAY, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_rigcat_init_delay, 0, 0}, { CMD_RIGCAT_BAUD_RATE, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_rigcat_baud_rate, 0, 0}, { CMD_RIGCAT_STOP_BITS, SCRIPT_COMMAND, 0, 1, {0}, { p_float }, 0, 0, 0, process_rigcat_stop_bits, 0, 0}, { CMD_RIGCAT_ECHO, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rigcat_commands_echoed, 0, 0}, { CMD_RIGCAT_TOGGLE_RTS_PTT, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rigcat_toggle_rts_ptt, 0, 0}, { CMD_RIGCAT_RESTORE, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rigcat_restore_on_close, 0, 0}, { CMD_RIGCAT_PTT_COMMAND, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rigcat_cat_command_ptt, 0, 0}, { CMD_RIGCAT_RTS_12V, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rigcat_rts_12v, 0, 0}, { CMD_RIGCAT_DTR_12V, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rigcat_dtr_12v, 0, 0}, { CMD_RIGCAT_HRDWR_FLOW, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rigcat_hrdwr_flow, 0, 0}, { CMD_RIGCAT_VSP, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rigcat_vsp_enable, 0, 0}, { CMD_RIGCAT_INITIALIZE, SCRIPT_COMMAND, 0, 0, {0}, { p_void }, 0, 0, 0, process_rigcat_initialize, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_hamlib_command_table[] = { { CMD_HAMLIB_STATE, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_use_hamlib, 0, 0}, { CMD_HAMLIB_RIG, SCRIPT_COMMAND, 0, 1, {0}, { p_dev_name }, 0, 0, 0, process_hamlib_rig, 0, 0}, { CMD_HAMLIB_DEV_PATH, SCRIPT_COMMAND, 0, 1, {0}, { p_dev_path }, 0, 0, 0, process_hamlib_device_path, 0, 0}, { CMD_HAMLIB_RETRIES, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_hamlib_retries, 0, 0}, { CMD_HAMLIB_RETRY_INTERVAL, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_hamlib_retry_interval, 0, 0}, { CMD_HAMLIB_WRITE_DELAY, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_hamlib_write_delay, 0, 0}, { CMD_HAMLIB_POST_WRITE_DELAY, SCRIPT_COMMAND, 0, 1, {0}, { p_unsigned_int }, 0, 0, 0, process_hamlib_post_write_delay, 0, 0}, { CMD_HAMLIB_BAUD_RATE, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_hamlib_baud_rate, 0, 0}, { CMD_HAMLIB_STOP_BITS, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_hamlib_stop_bits, 0, 0}, { CMD_HAMLIB_SIDE_BAND, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_hamlib_sideband, 0, 0}, { CMD_HAMLIB_PTT_COMMAND, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_hamlib_ptt_hl_command, 0, 0}, { CMD_HAMLIB_DTR_12V, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_hamlib_dtr_12, 0, 0}, { CMD_HAMLIB_RTS_12V, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_hamlib_rts_12, 0, 0}, { CMD_HAMLIB_HRDWR_FLOW, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_hamlib_rts_cts_flow, 0, 0}, { CMD_HAMLIB_SFTWR_FLOW, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_hamlib_xon_xoff_flow, 0, 0}, { CMD_HAMLIB_ADV_CONFIG, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_hamlib_advanced_config, 0, 0}, { CMD_HAMLIB_INITIALIZE, SCRIPT_COMMAND, 0, 0, {0}, { p_void }, 0, 0, 0, process_hamlib_initialize, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_kiss_command_table[] = { { CMD_IO_KISS_IPA, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_io_kiss_ip_address, 0, 0}, { CMD_IO_KISS_IOPN, SCRIPT_COMMAND, 0, 1, {0}, { p_int }, 0, 0, 0, process_io_kiss_io_port_no, 0, 0}, { CMD_IO_KISS_OPN, SCRIPT_COMMAND, 0, 1, {0}, { p_int }, 0, 0, 0, process_io_kiss_o_port_no, 0, 0}, { CMD_IO_KISS_DP, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_io_kiss_dual_port, 0, 0}, { CMD_IO_KISS_BUSY, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_io_kiss_busy_channel, 0, 0}, { CMD_IO_KISS_CONT, SCRIPT_COMMAND, 0, 1, {0}, { p_int }, 0, 0, 0, process_io_kiss_continue_after, 0, 0}, { CMD_IO_KISS_ATTEN, SCRIPT_COMMAND, 0, 1, {0}, { p_int }, 0, 0, 0, process_io_kiss_kpsql_atten, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_arq_command_table[] = { { CMD_IO_ARQ_IPA, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_io_arq_ip_address, 0, 0}, { CMD_IO_ARQ_IOPN, SCRIPT_COMMAND, 0, 1, {0}, { p_int }, 0, 0, 0, process_io_arq_io_port_no, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_xmlrpc_command_table[] = { { CMD_IO_XMLRPC_IPA, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_io_xmlrpc_ip_address, 0, 0}, { CMD_IO_XMLRPC_IOPN, SCRIPT_COMMAND, 0, 1, {0}, { p_int }, 0, 0, 0, process_io_xmlrpc_io_port_no, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_io_command_table[] = { { CMD_IO_LOCK, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_io_lock, 0, 0}, { CMD_IO_ACT_PORT, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_io_active_port, 0, 0}, { CMD_IO_AX25_DECODE, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_io_ax25_decode, 0, 0}, { CMD_IO_CSMA, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_io_csma, 0, 0}, { CMD_IO_KISS, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_kiss_command_table, sizeof(default_kiss_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_IO_ARQ, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_arq_command_table, sizeof(default_arq_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_IO_XMLRPC, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_xmlrpc_command_table, sizeof(default_xmlrpc_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_fldigi_command_table[] = { { CMD_FLDIGI_FREQ, SCRIPT_COMMAND, 0, 1, {0}, { p_double }, 0, 0, 0, process_rig_freq, 0, 0}, { CMD_FLDIGI_MODE, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_rig_mode, 0, 0}, { CMD_FLDIGI_WFHZ, SCRIPT_COMMAND, 0, 1, {0}, { p_int }, 0, 0, 0, process_wf_hz_offset, 0, 0}, { CMD_FLDIGI_RXID, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rx_rsid, 0, 0}, { CMD_FLDIGI_TXID, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_tx_rsid, 0, 0}, { CMD_FLDIGI_SPOT, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_spot, 0, 0}, { CMD_FLDIGI_REV, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rev, 0, 0}, { CMD_FLDIGI_AFC, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_afc, 0, 0}, { CMD_FLDIGI_LOCK, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_lock, 0, 0}, { CMD_FLDIGI_SQL, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_sql, 0, 0}, { CMD_FLDIGI_KPSQL, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_kpsql, 0, 0}, { CMD_FLDIGI_KPSM, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_kpsql, 0, 0}, { CMD_FLDIGI_MODEM, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_modem, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_nbems_command_table[] = { { CMD_NBEMS_FLMSG_PATH, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_misc_nbems_flmsg_path, 0, 0}, { CMD_NBEMS_TIMEOUT, SCRIPT_COMMAND, 0, 1, {0}, { p_double }, 0, 0, 0, process_misc_nbems_timeout, 0, 0}, { CMD_NBEMS_STATE, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_misc_nbems_state, 0, 0}, { CMD_NBEMS_MSG, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_misc_nbems_open_msg, 0, 0}, { CMD_NBEMS_FLMSG, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_misc_nbems_open_flmsg, 0, 0}, { CMD_NBEMS_BRWSR, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_misc_nbems_open_brwsr, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_id_rsid_command_table[] = { { CMD_ID_RSID_NOTIFY, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rsid_notify, 0, 0}, { CMD_ID_RSID_SRCH_BP, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rsid_search_bp, 0, 0}, { CMD_ID_RSID_MARK_PREV, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rsid_mark_prev, 0, 0}, { CMD_ID_RSID_DETECTOR, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rsid_detector, 0, 0}, { CMD_ID_RSID_ALRT_DIALOG, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rsid_alert_dialog, 0, 0}, { CMD_ID_RSID_TX_FREQ_LOCK, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rsid_tx_freq_lock, 0, 0}, { CMD_ID_RSID_FREQ_CHANGE, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rsid_freq_change, 0, 0}, { CMD_ID_RSID_ALLOW_ERRORS, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_rsid_allow_errors, 0, 0}, { CMD_ID_RSID_SQL_OPEN, SCRIPT_COMMAND, 0, 1, {0}, { p_int }, 0, 0, 0, process_rsid_sql_open, 0, 0}, { CMD_ID_RSID_PRETONE, SCRIPT_COMMAND, 0, 1, {0}, { p_double }, 0, 0, 0, process_rsid_pretone, 0, 0}, { CMD_ID_RSID_END_XMT_ID, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_rsid_end_xmt_id, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_id_video_command_table[] = { { CMD_ID_VIDEO_TX_ID_MODE, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_video_tx_id_mode, 0, 0}, { CMD_ID_VIDEO_TX_VIDEO_TXT, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_video_tx_vid_txt, 0, 0}, { CMD_ID_VIDEO_TX_TXT_INP, SCRIPT_COMMAND, 0, 1, {0}, { p_string }, 0, 0, 0, process_video_txt_input, 0, 0}, { CMD_ID_VIDEO_SMALL_FONT, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_video_small_font, 0, 0}, { CMD_ID_VIDEO_500_HZ, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_video_500hz, 0, 0}, { CMD_ID_VIDEO_WIDTH_LIMIT, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_video_width_limit, 0, 0}, { CMD_ID_VIDEO_CHAR_ROW, SCRIPT_COMMAND, 0, 1, {0}, { p_int }, 0, 0, 0, process_rsid_char_per_row, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_id_cw_command_table[] = { { CMD_ID_CW_TX_CALLSIGN, SCRIPT_COMMAND, 0, 1, {0}, { p_bool }, 0, 0, 0, process_cw_callsign, 0, 0}, { CMD_ID_CW_SPEED, SCRIPT_COMMAND, 0, 1, {0}, { p_int }, 0, 0, 0, process_cw_speed, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_id_command_table[] = { { CMD_ID_RSID, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_id_rsid_command_table, sizeof(default_id_rsid_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_ID_VIDEO, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_id_video_command_table, sizeof(default_id_video_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_ID_CW, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_id_cw_command_table, sizeof(default_id_cw_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; static const SCRIPT_COMMANDS default_top_level_command_table[] = { { CMD_FLDIGI, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_fldigi_command_table, sizeof(default_fldigi_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_OPERATOR, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_operator_command_table, sizeof(default_operator_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_AUDIO_DEVICE, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_audio_device_command_table, sizeof(default_audio_device_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_AUDIO_SETTINGS, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_audio_settings_command_table, sizeof(default_audio_settings_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_AUDIO_RT_CHANNEL, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_audio_rt_channel_command_table, sizeof(default_audio_rt_channel_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_AUDIO_WAVE, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_audio_wave_command_table, sizeof(default_audio_wave_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_HRDWR_PTT, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_rig_hrdwr_ptt_command_table, sizeof(default_rig_hrdwr_ptt_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_RIGCAT, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_rigcat_command_table, sizeof(default_rigcat_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_HAMLIB, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_hamlib_command_table, sizeof(default_hamlib_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_IO, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_io_command_table, sizeof(default_io_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_NBEMS, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_nbems_command_table, sizeof(default_nbems_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_ID, SCRIPT_COMMAND, 0, 0, {0}, { p_list }, 0, 0, 0, 0, (struct script_cmds *) &default_id_command_table, sizeof(default_id_command_table)/sizeof(SCRIPT_COMMANDS)}, { CMD_LOAD_MACRO, SCRIPT_COMMAND | SCRIPT_STRUCTURED_ONLY, 0, 3, {0}, { p_int, p_int, p_string }, 0, 0, 0, process_load_macro, 0, 0}, { CMD_END_CMD, SCRIPT_COMMAND, 0, 0, {0}, { p_list_end }, 0, 0, 0, 0, 0, 0}, { {0} } }; /** ************************************************************** * \brief Macro command requires special procesing. * \param cmd Pointer to matching struct script_cmds script * command. * \return SCRIPT_CODES error see \ref script_codes *****************************************************************/ SCRIPT_CODES ScriptParsing::sc_macros(struct script_cmds *cmd) { bool not_done = false; std::string temp; SCRIPT_CODES error = script_no_errors; int line_number_start = line_number; char *local_buffer = (char *)0; _macro_command.clear(); temp.clear(); std::string search_cmd; search_cmd.assign(CMD_END_CMD).append(":"); local_buffer = new char[MAX_READLINE_LENGTH]; if(!local_buffer) return script_memory_allocation_error; while(!not_done) { if(ferror(fd)) { error = script_file_read_error; break; } if(feof(fd)) { error = script_unexpected_eof; break; } memset(local_buffer, 0, MAX_READLINE_LENGTH); if (fgets(local_buffer, MAX_READLINE_LENGTH, fd)) line_number++; temp.assign(local_buffer); trim(temp); if(temp.find(search_cmd) == std::string::npos) _macro_command.append(local_buffer); else break; } int pos = _macro_command.length() - 1; bool lf_removed = false; // Remove the last new line in the macro command (script syntax requirement) if(pos > 1) { // Windows way if(_macro_command[pos-1] == '\r' && _macro_command[pos] == '\n') { _macro_command.erase(pos - 1, 2); lf_removed = true; } } if((lf_removed == false) && (pos > 0)) { // Unix/Linux/MacOSX way if(_macro_command[pos] == '\n') _macro_command.erase(pos, 1); } if(error == script_unexpected_eof) { LOG_INFO(_("Missing command %s after line %d"), search_cmd.c_str(), line_number_start); } delete [] local_buffer; return error; } /** ************************************************************** * \brief Used for initialization of the function vector table. * \param cmd Pointer to matching struct script_cmds script * command. * \return SCRIPT_CODES error see \ref script_codes *****************************************************************/ SCRIPT_CODES ScriptParsing::sc_dummy(struct script_cmds *cmd) { return script_no_errors; } /** ************************************************************** * \brief Convert error numbers into human readable form. * \param error_no Error number to convert. * \param ln The offending line number in the script file. * \param cmd The script command is question. * \return SCRIPT_CODES error see \ref script_codes *****************************************************************/ char * ScriptParsing::script_error_string(SCRIPT_CODES error_no, int ln, char *cmd) { char *es = (char *) ""; memset(error_buffer, 0, sizeof(error_buffer)); memset(error_cmd_buffer, 0, sizeof(error_cmd_buffer)); memset(error_string, 0, sizeof(error_string)); if(cmd) { strncpy(error_cmd_buffer, cmd, sizeof(error_cmd_buffer)-1); } if(error_no < 0) { _script_error_detected = true; } switch(error_no) { case script_command_not_found: es = (char *) _("Command Not Found"); break; case script_non_script_file: es = (char *) _("Not a script file/tag not found"); break; case script_parameter_error: es = (char *) _("Invalid parameter"); break; case script_function_parameter_error: es = (char *) _("Invalid function parameter (internal non-script error)"); break; case script_mismatched_quotes: es = (char *) _("Missing paired quotes (\")"); break; case script_general_error: es = (char *) _("General Error"); break; case script_no_errors: es = (char *) _("No Errors"); break; case script_char_match_not_found: es = (char *) _("Character searched not found"); break; case script_end_of_line_reached: es = (char *) _("End of line reached"); break; case script_file_not_found: es = (char *) _("File not found"); break; case script_path_not_found: es = (char *) _("Directory path not found"); break; case script_args_eol: es = (char *) _("Unexpected end of parameter (args[]) list found"); break; case script_param_check_eol: es = (char *) _("Unexpected end of parameter check list found"); break; case script_paramter_exceeds_length: es = (char *) _("Character count in args[] parameter exceeds expectations"); break; case script_memory_allocation_error: es = (char *) _("Memory Allocation Error (internal non-script error)"); break; case script_incorrectly_assigned_value: es = (char *) _("Passed parameter is not of the expected type."); break; case script_invalid_parameter: es = (char *) _("Parameter is not valid."); break; case script_command_seperator_missing: es = (char *) _("Command missing ':'."); break; case script_max_sub_script_reached: es = (char *) _("Maximum open subscripts reached."); break; case script_subscript_exec_fail: es = (char *) _("Subscript execution fail (internal)."); break; case script_device_path_not_found: es = (char *) _("Script device path not found."); break; case script_unexpected_eof: es = (char *) _("Unexpected end of file reached."); break; case script_file_read_error: es = (char *) _("File read error"); break; default: es = (char *) _("Undefined error"); } snprintf(error_buffer, sizeof(error_buffer)-1, _("Line: %d Error:%d %s (%s)"), ln, error_no, es, error_cmd_buffer); return error_buffer; } /** ************************************************************** * \brief Search for first occurrence of a non white space * \param data Data pointer to search. * \param limit Number of bytes in the data buffer. * \param error returned error code. * \return Pointer to character if found. Otherwise, return null * \par Note:<br> * The searched condition is ignored if the expected content is * encapsulated in quotes \(\"\"\). *****************************************************************/ char * ScriptParsing::skip_white_spaces(char * data, char * limit, SCRIPT_CODES &error) { char *cPtr = (char *) 0; if(!data || !limit) { error = script_function_parameter_error; return (char *)0; } for(cPtr = data; cPtr < limit; cPtr++) { if(*cPtr > ' ') { error = script_no_errors; return cPtr; } } error = script_end_of_line_reached; return (char *)0; // End of line reached. } /** ************************************************************** * \brief Search for the first occurrence on a non number. * \param data Data pointer to search. * \param limit Number of bytes in the data buffer. * \param error returned error code. * \return Pointer to character if found. Otherwise, return null * \par Note:<br> * The searched condition is ignored if the expected content is * encapsulated in quotes \(\"\"\). *****************************************************************/ char * ScriptParsing::skip_numbers(char * data, char * limit, SCRIPT_CODES &error) { char *cPtr = (char *) 0; int q_flag = 0; if(!data || !limit) { error = script_function_parameter_error; return (char *)0; } for(cPtr = data; cPtr < limit; cPtr++) { if(*cPtr == '"') // Check for encapsulated strings ("") q_flag++; if((q_flag & 0x1)) // Continue if string is encapsulated continue; if(!isdigit(*cPtr)) { error = script_no_errors; return cPtr; } } if(q_flag & 0x1) { error = script_mismatched_quotes; } else { error = script_end_of_line_reached; } return (char *)0; // End of line reached. } /** ************************************************************** * \brief Skip characters until either a number or white space is * found. * \param data Data pointer to search. * \param limit Number of bytes in the data buffer. * \param error returned error code. * \return Pointer to character if found. Otherwise, return null * \par Note:<br> * The searched condition is ignored if the expected content is * encapsulated in quotes \(\"\"\). *****************************************************************/ char * ScriptParsing::skip_characters(char * data, char * limit, SCRIPT_CODES &error) { char *cPtr = (char *) 0; int q_flag = 0; if(!data || !limit) { error = script_function_parameter_error; return (char *)0; } for(cPtr = data; cPtr < limit; cPtr++) { if(*cPtr == '"') // Check for encapsulated strings ("") q_flag++; if((q_flag & 0x1)) // Continue if string is encapsulated continue; if(isdigit(*cPtr) || *cPtr <= ' ') { error = script_no_errors; return cPtr; } } if(q_flag & 0x1) { error = script_mismatched_quotes; } else { error = script_end_of_line_reached; } return (char *)0; // End of line reached. } /** ************************************************************** * \brief Search for the first occurrence of a white space. * \param data Data pointer to search. * \param limit Number of bytes in the data buffer. * \param error returned error code. * \return Pointer to character if found. Otherwise, return null * \par Note:<br> * The searched condition is ignored if the expected content is * encapsulated in quotes \(\"\"\). *****************************************************************/ char * ScriptParsing::skip_alpha_numbers(char * data, char * limit, SCRIPT_CODES &error) { char *cPtr = (char *) 0; int q_flag = 0; if(!data || !limit) { error = script_function_parameter_error; return (char *)0; } for(cPtr = data; cPtr < limit; cPtr++) { if(*cPtr == '"') // Check for encapsulated strings ("") q_flag++; if((q_flag & 0x1)) // Continue if string is encapsulated continue; if(*cPtr <= ' ') { error = script_no_errors; return cPtr; } } if(q_flag & 0x1) { error = script_mismatched_quotes; } else { error = script_end_of_line_reached; } return (char *)0; // End of line reached. } /** ************************************************************** * \brief Search for first occurrence of 'character' * \param c Character to search for * \param data Pointer to Data to search for character in. * \param limit Number of bytes in the data buffer. * \param error returned error code. * \return Pointer to character if found. Otherwise, return null * \par Note:<br> * The searched condition is ignored if the expected content is * encapsulated in quotes \(\"\"\). *****************************************************************/ char * ScriptParsing::skip_to_character(char c, char * data, char * limit, SCRIPT_CODES &error) { char *cPtr = (char *) 0; int q_flag = 0; if(!data || !limit) { error = script_function_parameter_error; return (char *)0; } for(cPtr = data; cPtr < limit; cPtr++) { if(*cPtr == '"') // Check for encapsulated strings ("") q_flag++; if((q_flag & 0x1)) // Continue if string is encapsulated continue; if(*cPtr == c) { // Match found. Return pointer to it's location error = script_no_errors; return cPtr; } } if(q_flag & 0x1) { error = script_mismatched_quotes; } else { error = script_end_of_line_reached; } return (char *)0; // End of line reached. } /** ************************************************************** * \brief Replace CR, LF, and '#' with '0' (by value) * \param data Search data pointer * \param limit data buffer size * \return void (none) * \par Note:<br> * The searched condition is ignored if the remark character \(#\) * is encapsulated in quotes \(\"\"\). *****************************************************************/ SCRIPT_CODES ScriptParsing::remove_crlf_comments(char *data, char *limit, size_t &count) { char *cPtr = (char *) 0; int q_flag = 0; SCRIPT_CODES error = script_no_errors; if(!data || !limit) return script_function_parameter_error; count = 0; for(cPtr = data; cPtr < limit; cPtr++) { if(*cPtr == '\r' || *cPtr == '\n') { *cPtr = 0; return script_no_errors; } if(*cPtr == '"') q_flag++; if((q_flag & 0x1)) continue; if(*cPtr == '#') { *cPtr = 0; break; } if(*cPtr > ' ') count++; } // Remove trailing white spaces. while(cPtr >= data) { if(*cPtr <= ' ') *cPtr = 0; else break; cPtr--; } if(q_flag & 0x1) { error = script_mismatched_quotes; } else { error = script_end_of_line_reached; } return error; } /** ************************************************************** * \brief Copy memory from address to address. * \param buffer Destination buffer * \param sPtr Start of the copy Address * \param ePtr End of the copy Address * \param limit Destination buffer size * command. * \return SCRIPT_CODES error see \ref script_codes *****************************************************************/ SCRIPT_CODES ScriptParsing::copy_string_uppercase(char *buffer, char *sPtr, char *ePtr, size_t limit) { if(!buffer || !sPtr || !ePtr || limit < 1) { return script_function_parameter_error; } char *dPtr = buffer; size_t index = 0; for(index = 0; index < limit; index++) { *dPtr++ = toupper(*sPtr++); if(sPtr >= ePtr) break; } return script_no_errors; } /** ************************************************************** * \brief Parse the parameters and seperate into individual components. * \param s char pointer to the start of the string. * \param e char pointer to the end of the string. * \param matching_command pointer to the data strucure of the matching * command. See \ref SCRIPT_COMMANDS * \return SCRIPT_CODES error see \ref script_codes *****************************************************************/ SCRIPT_CODES ScriptParsing::parse_parameters(char *s, char *e, SCRIPT_COMMANDS *matching_command) { char *c = s; char *d = (char *)0; int index = 0; int parameter_count = matching_command->argc; int count = 0; long tmp = 0; SCRIPT_CODES error = script_no_errors; // Clear the old pointers. for(index = 0; index < MAX_CMD_PARAMETERS; index++) { matching_command->args[index] = (char *)0; } if(parameter_count > 0) { count = parameter_count - 1; for(index = 0; index < count; index++) { c = skip_white_spaces(c, e, error); if(error != script_no_errors) return script_parameter_error; d = skip_to_character(',', c, e, error); if(error != script_no_errors) return script_parameter_error; *d = 0; tmp = (long) (d - c); if(tmp > 0) trim(c, (size_t)(tmp)); matching_command->args[index] = c; c = d + 1; } c = skip_white_spaces(c, e, error); if(error) return error; d = skip_alpha_numbers(c, e, error); if(error) return error; *d = 0; tmp = (long) (d - c); if(tmp > 0) trim(c, (size_t)(tmp)); matching_command->args[index] = c; } #ifdef TESTING for(int i = 0; i < parameter_count; i++) if(matching_command->args[i]) printf("parameters %d (%s)\n", i, matching_command->args[i]); #endif error = check_parameters(matching_command); if(error != script_no_errors) return error; // If assigned then special processing is required. if(matching_command->func) error = (this->*matching_command->func)(matching_command); if(error) return error; return script_no_errors; } /** ************************************************************** * \brief Execute callback function. * \param cb_data Pointer for making a copy of the data to prevent * exterior alteration of source information. * \return 0 = No error<br> \< 0 = Error<br> *****************************************************************/ int ScriptParsing::call_callback(SCRIPT_COMMANDS *cb_data) { int argc = 0; int error = 0; int index = 0; SCRIPT_COMMANDS *tmp = (SCRIPT_COMMANDS *)0; size_t count = 0; if(!cb_data || !cb_data->cb) return -1; argc = cb_data->argc; tmp = new SCRIPT_COMMANDS; if(!tmp) return -1; memset(tmp, 0, sizeof(SCRIPT_COMMANDS)); for(index = 0; index < argc; index++) { if(cb_data->args[index]) { count = strnlen(cb_data->args[index], MAX_PARAMETER_LENGTH-1); tmp->args[index] = new char[count+1]; if(tmp->args[index]) { memset(tmp->args[index], 0, count+1); strncpy(tmp->args[index], cb_data->args[index], count); } else { error = -1; break; } } else break; } if(error > -1) { // Fill SCRIPT_COMMANDS (tmp) struct with useful data. tmp->flags = cb_data->flags; tmp->command_length = cb_data->command_length; tmp->argc = cb_data->argc; strncpy(tmp->command, cb_data->command, MAX_COMMAND_LENGTH); // Initialize with do nothing functions tmp->func = &ScriptParsing::sc_dummy; tmp->cb = callback_dummy; error = (*cb_data->cb)(this, tmp); } if(tmp) { for(index = 0; index < argc; index++) { if(tmp->args[index]) { delete [] tmp->args[index]; } } delete tmp; } return error; } /** ************************************************************** * \brief Parse a single line of data from the script file being read. * \param data Pointer the the script scring in question * \param buffer_size buffer size of the data pointer. * command. * \return SCRIPT_CODES error see \ref script_codes *****************************************************************/ SCRIPT_CODES ScriptParsing::parse_hierarchy_command(char *data, size_t buffer_size) { char *buffer = (char *)0; char *cPtr = (char *)0; char *endPtr = (char *)0; char *ePtr = (char *)0; int allocated_buffer_size = MAX_COMMAND_LENGTH; SCRIPT_CODES error = script_no_errors; SCRIPT_COMMANDS *local_list = _script_commands; size_t local_limit = _script_command_count; cPtr = data; endPtr = &data[buffer_size]; cPtr = skip_white_spaces(cPtr, endPtr, error); if(error != script_no_errors) return error; ePtr = skip_to_character(':', cPtr, endPtr, error); if(error != script_no_errors) return script_command_seperator_missing; buffer = new char [allocated_buffer_size]; if(!buffer) { LOG_INFO(_("Buffer allocation Error near File: %s Line %d"), __FILE__, __LINE__); return script_memory_allocation_error; } memset(buffer, 0, allocated_buffer_size); error = copy_string_uppercase(buffer, cPtr, ePtr, allocated_buffer_size-1); if(error != script_no_errors) { buffer[0] = 0; delete [] buffer; return error; } int str_count = str_cnt(buffer, allocated_buffer_size); trim(buffer, (size_t) str_count); char sub_command[MAX_COMMAND_LENGTH]; bool not_found = true; char *endCmd = ePtr; char *endCmdPtr = endPtr; cPtr = buffer; endPtr = &buffer[str_count]; while(not_found) { memset(sub_command, 0, sizeof(sub_command)); ePtr = skip_to_character('.', cPtr, endPtr, error); if(error == script_end_of_line_reached) { ePtr = endPtr; error = script_no_errors; } if(error == script_no_errors) { copy_string_uppercase(sub_command, cPtr, ePtr, MAX_COMMAND_LENGTH-1); cPtr = ePtr + 1; } else break; for(size_t i = 0; i < local_limit; i++) { if(local_list[i].command[0] == 0) { not_found = false; error = script_command_not_found; break; } if(strncmp(sub_command, local_list[i].command, MAX_COMMAND_LENGTH) == 0) { if((local_list[i].param_check[0] == p_list) && local_list[i].sub_commands) { local_limit = local_list[i].sub_command_count; local_list = local_list[i].sub_commands; break; } if((file_type() & local_list[i].flags) && !(SCRIPT_STRUCTURED_ONLY & local_list[i].flags)) { error = parse_parameters(++endCmd, endCmdPtr, &local_list[i]); if(error) { buffer[0] = 0; delete [] buffer; return error; } if(local_list[i].cb) { error = (SCRIPT_CODES) call_callback(&local_list[i]); if(error < script_no_errors) LOG_INFO(_("Call back for script command %s reported an Error"), local_list[local_limit].command); not_found = false; error = script_command_handled; break; } } else { LOG_INFO(_("Command %s ignored, dot notation not supported"), buffer); not_found = false; error = script_general_error; break; } } } } buffer[0] = 0; delete [] buffer; return error; } /** ************************************************************** * \brief Parse a single line of data from the script file being read. * \param data Pointer the the script scring in question * \param buffer_size buffer size of the data pointer. * command. * \return SCRIPT_CODES error see \ref script_codes *****************************************************************/ SCRIPT_CODES ScriptParsing::parse_single_command(FILE *fd, SCRIPT_COMMANDS *cur_list, size_t limit, char *data, size_t buffer_size) { char *buffer = (char *)0; char *cPtr = (char *)0; char *endPtr = (char *)0; char *ePtr = (char *)0; int allocated_buffer_size = MAX_COMMAND_LENGTH; size_t cmd_size = 0; size_t cmp_results = 0; size_t index = 0; size_t size = 0; bool dot_notation = false; SCRIPT_CODES error = script_no_errors; SCRIPT_COMMANDS *local_list = cur_list; size_t local_limit = limit; cPtr = data; endPtr = &data[buffer_size]; cPtr = skip_white_spaces(cPtr, endPtr, error); if(error != script_no_errors) return error; ePtr = skip_to_character(':', cPtr, endPtr, error); if(error != script_no_errors) return script_command_seperator_missing; buffer = new char [allocated_buffer_size]; if(!buffer) { LOG_INFO(_("Buffer allocation Error near File: %s Line %d"), __FILE__, __LINE__); return script_memory_allocation_error; } memset(buffer, 0, allocated_buffer_size); error = copy_string_uppercase(buffer, cPtr, ePtr, allocated_buffer_size-1); if(error != script_no_errors) { buffer[0] = 0; delete [] buffer; return error; } int str_count = (int) strnlen(buffer, allocated_buffer_size); trim(buffer, (size_t) str_count); for(int i = 0; i < str_count; i++) { if(buffer[i] == '.') { error = parse_hierarchy_command(data, buffer_size); if(error == script_no_errors) dot_notation = true; break; } } if(dot_notation == false && error == script_no_errors) { for(index = 0; index < local_limit; index++) { size = strnlen(local_list[index].command, MAX_COMMAND_LENGTH); cmd_size = strnlen(buffer, MAX_COMMAND_LENGTH); cmp_results = memcmp(buffer, local_list[index].command, size); if(cmp_results == 0 && (cmd_size == size)) { if(local_list[index].param_check[0] == p_list_end) { return script_end_of_list_reached; } if(local_list[index].sub_commands && local_list[index].param_check[0] == p_list) { if(recursive_count <= RECURSIVE_LIMIT) { read_file(fd, local_list[index].sub_commands, local_list[index].sub_command_count); } else { error = script_recursive_limit_reached; } break; } if((file_type() & local_list[index].flags) && !(SCRIPT_DOT_NOTATION_ONLY & local_list[index].flags)) { if(local_list[index].argc > 0) { error = parse_parameters(++ePtr, endPtr, &local_list[index]); if(error) { buffer[0] = 0; delete [] buffer; return error; } } if(local_list[index].cb) { error = (SCRIPT_CODES) call_callback(&local_list[index]); if(error < script_no_errors) LOG_INFO(_("Call back for script command %s reported an Error"), local_list[index].command); } } else { LOG_INFO(_("Command %s ignored, structured command not supported"), buffer); error = script_general_error; } break; } } } buffer[0] = 0; delete [] buffer; return error; } /** ************************************************************** * \brief Script entry point for parsing the script file. * \param file_name_path path and file name for the script to parse. * \return SCRIPT_CODES error see \ref script_codes *****************************************************************/ SCRIPT_CODES ScriptParsing::read_file(FILE *fd, SCRIPT_COMMANDS *cur_list, size_t limit) { SCRIPT_CODES return_code = script_no_errors; SCRIPT_COMMANDS *local_list = cur_list; size_t count = 0; bool errors_reported = false; recursive_count++; if(recursive_count > RECURSIVE_LIMIT) return script_recursive_limit_reached; while(1) { if(ferror(fd) || feof(fd)) break; memset(line_buffer, 0, sizeof(line_buffer)); if (fgets(line_buffer, sizeof(line_buffer) - 1, fd)) line_number++; #ifdef TESTING printf("Reading: %s", line_buffer); #endif return_code = remove_crlf_comments(line_buffer, &line_buffer[sizeof(line_buffer)], count); if(count < 1) { continue; } if(return_code >= script_no_errors) { return_code = parse_single_command(fd, local_list, limit, line_buffer, sizeof(line_buffer) - 1); } if(return_code == script_end_of_list_reached) break; if(return_code < script_no_errors) { LOG_INFO("%s", script_error_string(return_code, line_number, line_buffer)); errors_reported = true; } } recursive_count--; if(errors_reported) return script_errors_reported; return script_no_errors; } /** ************************************************************** * \brief Script entry point for parsing the script file. * \param file_name_path path and file name for the script to parse. * \return SCRIPT_CODES error see \ref script_codes *****************************************************************/ SCRIPT_CODES ScriptParsing::parse_commands(char *file_name_path) { char *cPtr = (char *)0; SCRIPT_CODES error_code = script_no_errors; size_t tmp = 0; SCRIPT_COMMANDS *local_script_commands = _script_commands; size_t local_script_command_count = _script_command_count; if(!file_name_path) { LOG_INFO(_("Invalid function parameter 'char *file_name_path' (null)")); return script_function_parameter_error; } fd = fl_fopen(file_name_path, "r"); line_number = 0; if(!fd) { LOG_INFO(_("Unable to open file %s"), file_name_path); return script_file_not_found; } memset(line_buffer, 0, sizeof(line_buffer)); char *retval = fgets(line_buffer, sizeof(line_buffer) - 1, fd); line_number++; tmp = strlen(SCRIPT_FILE_TAG); line_buffer[tmp] = 0; tmp = strncmp(SCRIPT_FILE_TAG, line_buffer, tmp); if(!retval || tmp) { cPtr = script_error_string(script_non_script_file, line_number, line_buffer); LOG_INFO("%s", cPtr); fclose(fd); return script_non_script_file; } error_code = read_file(fd, local_script_commands, local_script_command_count); fclose(fd); return error_code; } /** ************************************************************** * \brief Assign a list of valid parameters for verification checks. * \param array An Array of pointers to each element. * \param array_count Number of entries in the array. * \return the array count or '0' if error. * \par Note: * This array is limited to the first parameter of the command * used in it's comparison. *****************************************************************/ int ScriptParsing::assign_valid_parameters(const char *command, const char **array, const int array_count) { if(!array || array_count < 1 || !command) return 0; int index = 0; int count = 0; SCRIPT_COMMANDS * cmd_sc = search_command(_script_commands, 0, command); if(!cmd_sc) { return 0; } for(index = 0; index < array_count; index++) { if(*array[index]) count++; } if(count != array_count) return 0; cmd_sc->valid_values = array; cmd_sc->valid_value_count = array_count; return array_count; } /** ************************************************************** * \brief Return true state if string is matched. * \param state Referenced value to assign results to. * \param string Pointer to the data string. * \param true_state Pointer to the data to match with. * \return SCRIPT_CODES error code. *****************************************************************/ inline SCRIPT_CODES ScriptParsing::test_on_off_state(bool &state, char *string, char *true_state=(char *)"ON") { if(!string || !true_state) { return script_function_parameter_error; } bool flag = false; if(strncmp(string, true_state, MAX_PARAMETER_LENGTH) == 0) flag = true; state = flag; return script_no_errors; } /** ************************************************************** * \brief Validate if file is located in the specified location. * \param filename Pointer to a series of charcters * \return SCRIPT_CODES error code. *****************************************************************/ SCRIPT_CODES ScriptParsing::check_filename(char *filename) { SCRIPT_CODES error = script_no_errors; if(!filename) { return script_function_parameter_error; } FILE *fd = (FILE *)0; fd = fl_fopen(filename, "r"); if(!fd) { error = script_file_not_found; } else { fclose(fd); } return error; } /** ************************************************************** * \brief Validate if path is present. * \param path The path to verify. * \return SCRIPT_CODES error code. *****************************************************************/ SCRIPT_CODES ScriptParsing::check_path(const char *path) { if(!path) { return script_function_parameter_error; } struct stat st; memset(&st, 0, sizeof(struct stat)); if(stat(path, &st) == 0) { if(st.st_mode & S_IFDIR) return script_no_errors; } return script_path_not_found; } /** ************************************************************** * \brief Validate if device path is present. * \param path The path to verify. * \return SCRIPT_CODES error code. *****************************************************************/ SCRIPT_CODES ScriptParsing::check_dev_path(const char *path) { if(!path) { return script_function_parameter_error; } struct stat st; memset(&st, 0, sizeof(struct stat)); #ifdef __WIN32__ std::string alt_path; int value = 0; int cnt = 0; alt_path.assign(path); if(!alt_path.empty()) { if(alt_path.find("COM") != std::string::npos) { cnt = sscanf(alt_path.c_str(), "COM%d", &value); if(cnt && (value > 0)) return script_no_errors; } } #endif if(stat(path, &st) == 0) { if(st.st_mode & S_IFCHR) return script_no_errors; } return script_device_path_not_found; } /** ************************************************************** * \brief Validate bool representation. * \param value String data <ENABLE|YES|1> or <DISABLE|NO|0> * \param flag Depending on string content a value of true or false assigned * \return SCRIPT_CODES error code. *****************************************************************/ SCRIPT_CODES ScriptParsing::check_bool(const char *value, bool &flag) { if(!value) { return script_function_parameter_error; } flag = false; std::string uc_value; uc_value.assign(value); to_uppercase(uc_value); static char *bool_true_flags[] = { (char *)PARM_ENABLE, (char *)PARM_YES, (char *)_("1"), (char *)0 }; static char *bool_false_flags[] = { (char *) PARM_DISABLE, (char *)PARM_NO, (char *)_("0"), (char *)0 }; for(size_t i = 0; i < sizeof(bool_true_flags)/sizeof(char *); i++) { if(bool_true_flags[i] == (char *)0) break; if(strncmp(uc_value.c_str(), bool_true_flags[i], 7) == 0) { flag = true; return script_no_errors; } } for(size_t i = 0; i < sizeof(bool_false_flags)/sizeof(char *); i++) { if(bool_false_flags[i] == (char *)0) break; if(strncmp(uc_value.c_str(), bool_false_flags[i], 7) == 0) { flag = false; return script_no_errors; } } flag = false; return script_invalid_parameter; } /** ************************************************************** * \brief Validate if the parameter is a value. * \param value The string in question. * \param p format verification. * \return SCRIPT_CODES error code. *****************************************************************/ SCRIPT_CODES ScriptParsing::check_numbers(char *value, paramter_types p) { SCRIPT_CODES error = script_no_errors; size_t length = 0; size_t index = 0; int data_count = 0; int signed_value = 0; int decimal_point = 0; if(!value) return script_function_parameter_error; length = strnlen(value, MAX_PARAMETER_LENGTH); if(length < 1) return script_parameter_error; // Skip any leading white spaces. for(index = 0; index < length; index++) { if(value[index] > ' ') break; } if((index >= length)) return script_parameter_error; switch(p) { case p_int: case p_long: if(value[0] == '-' || value[0] == '+') { index++; signed_value++; } case p_unsigned_int: case p_unsigned_long: for(; index< length; index++) { if(isdigit(value[index])) data_count++; else break; } break; if(data_count) return script_no_errors; case p_float: case p_double: if(value[0] == '-' || value[0] == '+') { index++; signed_value++; } for(; index< length; index++) { if(isdigit(value[index])) data_count++; if(value[index] == '.') decimal_point++; if(decimal_point > 1) return script_parameter_error; } if(data_count) return script_no_errors; break; default:; } return error; } /** ************************************************************** * \brief Validate the script parameter(s) are of the expected format. * \param cmd Matching command data structure. * \param p A table of expected parameters types (null terminated). * \param p_count the number of 'p[]' items in the table (includes null termination). * \return SCRIPT_CODES error code. *****************************************************************/ SCRIPT_CODES ScriptParsing::check_parameters(struct script_cmds *cmd) { SCRIPT_CODES error = script_no_errors; int count = 0; int index = 0; size_t size = 0; bool flag = false; if(!cmd) return script_function_parameter_error; count = cmd->argc; if(count < 1) return script_no_errors; for(index = 0; index < count; index++) { if(!cmd->args[index]) { return script_args_eol; } if(cmd->param_check[index] == p_null) { size = 0; } else { size = strnlen(cmd->args[index], MAX_COMMAND_LENGTH); } switch(cmd->param_check[index]) { case p_null: error = script_param_check_eol; break; case p_char: if(size > 1) error = script_paramter_exceeds_length; break; case p_bool: error = check_bool(cmd->args[index], flag); break; case p_int: case p_long: case p_unsigned_int: case p_unsigned_long: case p_float: case p_double: error = check_numbers(cmd->args[index], cmd->param_check[index]); break; case p_dev_path: error = check_dev_path(cmd->args[index]); break; case p_dev_name: case p_string: if(size < 1) error = script_parameter_error; break; case p_path: error = check_path(cmd->args[index]); break; case p_filename: error = check_filename(cmd->args[index]); break; case p_list: case p_list_end: case p_void: break; } if(error != script_no_errors) break; } return error; } /** ************************************************************** * \brief Search the content of SCRIPT_COMMANDS structure table * for the specified command. * \param command The command to search for. * \return Pointer to the matching SCRIPT_COMMANDS entry. Null if * not found. *****************************************************************/ SCRIPT_COMMANDS * ScriptParsing::search_command(SCRIPT_COMMANDS * table, size_t limit, const char *command) { char *cmd_buffer = (char *)0; int diff = 0; SCRIPT_COMMANDS * found = (SCRIPT_COMMANDS *) 0; size_t count = limit; size_t index = 0; if(!command) return found; cmd_buffer = new char [MAX_COMMAND_LENGTH]; if(!cmd_buffer) { LOG_INFO(_("cmd_buffer allocation error near line %d"), __LINE__); return found; } memset(cmd_buffer, 0, MAX_COMMAND_LENGTH); strncpy(cmd_buffer, command, MAX_COMMAND_LENGTH-1); to_uppercase(cmd_buffer, (int) MAX_COMMAND_LENGTH); trim(cmd_buffer, (size_t) MAX_COMMAND_LENGTH); for(index = 0; index < count; index++) { diff = strncmp(cmd_buffer, table[index].command, MAX_COMMAND_LENGTH); if(diff == 0) { found = &table[index]; break; } } cmd_buffer[0] = 0; delete [] cmd_buffer; return found; } /** ************************************************************** * \brief Convert string to uppercase characters.<br> * \par str Pointer to data. * \par limit data buffer size * \return void *****************************************************************/ void ScriptParsing::to_uppercase(char *str, int limit) { if(!str || limit < 1) return; int character = 0; int count = 0; int index = 0; count = (int) strnlen(str, limit); for(index = 0; index < count; index++) { character = str[index]; if(character == 0) break; character = (char) toupper(character); str[index] = character; } } /** ************************************************************** * \brief Convert string to uppercase characters.<br> * \par str String storage passed by reference. * \return void *****************************************************************/ void ScriptParsing::to_uppercase(std::string &str) { int character = 0; int count = 0; int index = 0; count = (int) str.length(); for(index = 0; index < count; index++) { character = str[index]; if(character == 0) break; character = (char) toupper(character); str[index] = character; } } #if 0 /** ************************************************************** * \brief Assign Call back function to a given script command.<br> * \param scriptCommand Script command string<br> * \param cb Pointer to call back function. int (*cb)(ScriptParsing *sp, SCRIPT_COMMANDS *sc) *****************************************************************/ int ScriptParsing::assign_callback(const char *scriptCommand, int (*cb)(ScriptParsing *sp, SCRIPT_COMMANDS *sc)) { char *cmd_buffer = (char *)0; int diff = 0; size_t count = _script_command_count; size_t index = 0; if(!scriptCommand || !cb) return 0; cmd_buffer = new char[MAX_COMMAND_LENGTH]; if(!cmd_buffer) { LOG_INFO(_("cmd_buffer allocation error near line %d"), __LINE__); return 0; } memset(cmd_buffer, 0, MAX_COMMAND_LENGTH); strncpy(cmd_buffer, scriptCommand, MAX_COMMAND_LENGTH-1); to_uppercase(cmd_buffer, (int) MAX_COMMAND_LENGTH); trim(cmd_buffer, (size_t) MAX_COMMAND_LENGTH); for(index = 0; index < count; index++) { diff = strncmp(cmd_buffer, _script_commands[index].command, MAX_COMMAND_LENGTH); if(diff == 0) { if(_script_commands[index].cb) LOG_INFO(_("Over writing call back funcion for \"%s\""), cmd_buffer); _script_commands[index].cb = cb; break; } } cmd_buffer[0] = 0; delete [] cmd_buffer; return 0; } #endif // #if 0 /** ************************************************************** * \brief Assign member calling function to a command * \param top_command Top Command * \param sub_command Sub command * \param func Assigned calling function member * \return void (nothing) *****************************************************************/ SCRIPT_CODES ScriptParsing::assign_member_func(char *cmd, SCRIPT_CODES (ScriptParsing::*func)(struct script_cmds *)) { char *buffer = (char *)0; char *cPtr = (char *)0; char *endPtr = (char *)0; char *ePtr = (char *)0; int allocated_buffer_size = MAX_COMMAND_LENGTH; size_t size = 0; SCRIPT_CODES error = script_no_errors; SCRIPT_COMMANDS *local_list = _script_commands; size_t local_limit = _script_command_count; if(!cmd || !func) return script_invalid_parameter; size = strnlen(cmd, MAX_COMMAND_LENGTH); cPtr = cmd; endPtr = &cmd[size]; size = 0; cPtr = skip_white_spaces(cPtr, endPtr, error); if(error != script_no_errors) return error; ePtr = skip_to_character(':', cPtr, endPtr, error); if(error != script_no_errors) return script_command_seperator_missing; buffer = new char [allocated_buffer_size]; if(!buffer) { LOG_INFO(_("Buffer allocation Error near File: %s Line %d"), __FILE__, __LINE__); return script_memory_allocation_error; } memset(buffer, 0, allocated_buffer_size); error = copy_string_uppercase(buffer, cPtr, ePtr, allocated_buffer_size-1); if(error != script_no_errors) { buffer[0] = 0; delete [] buffer; return error; } int str_count = str_cnt(buffer, allocated_buffer_size); trim(buffer, (size_t) str_count); char sub_command[MAX_COMMAND_LENGTH]; bool not_found = true; cPtr = buffer; endPtr = &buffer[str_count]; while(not_found) { memset(sub_command, 0, sizeof(sub_command)); ePtr = skip_to_character('.', cPtr, endPtr, error); if(error == script_end_of_line_reached) { ePtr = endPtr; error = script_no_errors; } if(error == script_no_errors) { copy_string_uppercase(sub_command, cPtr, ePtr, MAX_COMMAND_LENGTH-1); cPtr = ePtr + 1; } else break; for(size_t i = 0; i < local_limit; i++) { if(local_list[i].command[0] == 0) { not_found = false; error = script_command_not_found; break; } if(strncmp(sub_command, local_list[i].command, MAX_COMMAND_LENGTH) == 0) { if((local_list[i].param_check[0] == p_list) && local_list[i].sub_commands) { local_limit = local_list[i].sub_command_count; local_list = local_list[i].sub_commands; break; } local_list[i].func = func; local_list[i].command_length = strnlen(local_list[i].command, MAX_COMMAND_LENGTH); not_found = false; error = script_no_errors; break; } } } buffer[0] = 0; delete [] buffer; return error; } #if 0 /** ************************************************************** * \brief Assign member calling function to a command * \param top_command Top Command * \param sub_command Sub command * \param func Assigned calling function member * \return void (nothing) *****************************************************************/ void ScriptParsing::assign_member_func(char *cmd, SCRIPT_CODES (ScriptParsing::*func)(struct script_cmds *)) { if(!top_command || !func) return; SCRIPT_COMMANDS *top_table = (SCRIPT_COMMANDS *)0; SCRIPT_COMMANDS *modify_table = (SCRIPT_COMMANDS *)0; if(top_cache) { if(strncmp(top_cache->command, top_command, MAX_COMMAND_LENGTH) == 0) { top_table = top_cache; } } if(!top_table) { for(int i = 0; i < _script_command_count; i++) { if(strncmp(_script_commands[i].command, top_command, MAX_COMMAND_LENGTH) == 0) { top_cache = &_script_commands[i]; top_table = top_cache; break; } } } if(!top_table) return; if(!sub_command) modify_table = top_table; if(modify_table == (SCRIPT_COMMANDS *)0) { if(top_table->sub_commands) { for(int i = 0; i < top_table->sub_command_count; i++) { if(strncmp(sub_command, top_table->sub_commands[i].command, MAX_COMMAND_LENGTH) == 0) { modify_table = &top_table->sub_commands[i]; break; } } } } if(modify_table != (SCRIPT_COMMANDS *)0) { modify_table->func = func; modify_table->command_length = strnlen(modify_table->command, MAX_COMMAND_LENGTH); } } #endif // #if 0 /** ************************************************************** * \brief Initialize variables * \return void (nothing) *****************************************************************/ void ScriptParsing::clear_script_parameters(bool all) { _path.clear(); _file_type = SCRIPT_COMMAND; _macro_command.clear(); } /** ************************************************************** * \brief Initialize callable members. * \return void (nothing) *****************************************************************/ void ScriptParsing::initialize_function_members(void) { std::string cmd; cmd.assign(CMD_LOAD_MACRO).append(":"); // For localization assign_member_func((char *) cmd.c_str(), &ScriptParsing::sc_macros); } /** ************************************************************** * \brief Copy environment to the sub ScriptParsing class * \param src Source Class pointer to copy from. *****************************************************************/ int ScriptParsing::CopyScriptParsingEnv(ScriptParsing *src) { if(!src || (src == this)) return -1; parent(src); script_commands(src->script_commands()); script_command_count(src->script_command_count()); initialize_function_members(); return 0; } /** ************************************************************** * \brief Constructor: Copy and initialize.<br> *****************************************************************/ int ScriptParsing::copy_tables(struct script_cmds * subcmds, size_t count) { size_t index = 0; size_t table_count = 0; SCRIPT_COMMANDS * dst_table = 0; SCRIPT_COMMANDS * src_table = 0; recursive_count++; if(recursive_count > RECURSIVE_LIMIT) return 0; for(index = 0; index < count; index++) { src_table = subcmds[index].sub_commands; table_count = subcmds[index].sub_command_count; if(src_table && table_count) { dst_table = new SCRIPT_COMMANDS[table_count]; if(dst_table) { add_to_delete_list(dst_table); memcpy(dst_table, src_table, sizeof(SCRIPT_COMMANDS) * table_count); subcmds[index].sub_commands = dst_table; subcmds[index].sub_command_count = table_count; copy_tables(dst_table, table_count); } } } recursive_count--; return 0; } /** ************************************************************** * \brief Constructor: Copy and initialize function arrays.<br> *****************************************************************/ ScriptParsing::ScriptParsing() { size_t count = 0; clear_script_parameters(true); memset(line_buffer, 0, sizeof(line_buffer)); memset(error_cmd_buffer, 0, sizeof(error_cmd_buffer)); memset(error_string, 0, sizeof(error_string)); memset(error_buffer, 0, sizeof(error_buffer)); memset(memory_delete_list, 0, sizeof(memory_delete_list)); delete_list_count = 0; top_cache = 0; recursive_count = 0; _script_error_detected = false; _restart_flag = false; fd = 0; count = sizeof(default_top_level_command_table)/sizeof(SCRIPT_COMMANDS); _script_commands = new SCRIPT_COMMANDS[count]; if(_script_commands) { add_to_delete_list(_script_commands); _script_command_count = count; memcpy(_script_commands, default_top_level_command_table, sizeof(SCRIPT_COMMANDS) * _script_command_count); copy_tables(_script_commands, _script_command_count); } recursive_count = 0; initialize_function_members(); } /** ************************************************************** * \brief Destructor *****************************************************************/ ScriptParsing::~ScriptParsing() { int index = 0; for(index = 0; index < MAX_DELETE_LIST_COUNT; index++) { if(memory_delete_list[index]) { delete [] memory_delete_list[index]; } } } /** ************************************************************** * \brief Keep track of memory allocation for easy deallocation. *****************************************************************/ void ScriptParsing::add_to_delete_list(SCRIPT_COMMANDS *ptr) { if(!ptr) return; if(delete_list_count < MAX_DELETE_LIST_COUNT) { memory_delete_list[delete_list_count] = ptr; delete_list_count++; } } /** ************************************************************** * \brief Dummy callback function for initialization of * function pointers. * \param sp The calling ScriptParsing Class * \param sc Command data structure pointer to the matching script * command. * \return 0 = No error<br> \< 0 = Error<br> *****************************************************************/ int callback_dummy(ScriptParsing *sp, struct script_cmds *sc) { return 0; } /** ******************************************************** * \brief Determine the length of the string with a count * limitation. * \return signed integer. The number of characters in the * array not to excede count limit. ***********************************************************/ int ScriptParsing::str_cnt(char * str, int count_limit) { if(!str || (count_limit < 1)) return 0; int value = 0; for(int index = 0; index < count_limit; index++) { if(str[index] == 0) break; value++; } return value; } /** ******************************************************** * \brief Trim leading and trailing spaces from string. * \param s String to modify * \return s modified string. ***********************************************************/ std::string &ScriptParsing::trim(std::string &s) { char *buffer = (char *)0; char *dst = (char *)0; char *end = (char *)0; char *src = (char *)0; long count = s.size(); buffer = new char[count + 1]; if(!buffer) return s; memcpy(buffer, s.c_str(), count); buffer[count] = 0; dst = src = buffer; end = &buffer[count]; while(src < end) { if(*src > ' ') break; src++; } if(src > dst) { while((dst < end) && (src < end)) *dst++ = *src++; *dst = 0; } while(end >= buffer) { if(*end > ' ') break; *end-- = 0; } s.assign(buffer); delete [] buffer; return s; } /** ************************************************************** * \brief Remove leading/trailing white spaces and quotes. * \param buffer Destination buffer * \param limit passed buffer size * \return void *****************************************************************/ void ScriptParsing::trim(char *buffer, size_t limit) { char *s = (char *)0; char *e = (char *)0; char *dst = (char *)0; size_t count = 0; if(!buffer || limit < 1) { return; } for(count = 0; count < limit; count++) if(buffer[count] == 0) break; if(count < 1) return; s = buffer; e = &buffer[count-1]; for(size_t i = 0; i < count; i++) { if((*s <= ' ') || (*s == '"')) s++; else break; } while(e > s) { if(*e == '"') { *e-- = 0; break; } if(*e > ' ') break; if(*e <= ' ') *e = 0; e--; } dst = buffer; while(s <= e) { *dst++ = *s++; } *dst = 0; }
73,534
C++
.cxx
1,779
38.604834
215
0.583575
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,237
lgbook.cxx
w1hkj_fldigi/src/logbook/lgbook.cxx
// generated by Fast Light User Interface Designer (fluid) version 1.0305 #include "gettext.h" #include "lgbook.h" #include <config.h> #include <FL/Fl_Pixmap.H> #include "flmisc.h" #include "logsupport.h" #include "pixmaps.h" Fl_Double_Window *wExport=(Fl_Double_Window *)0; Fl_Check_Browser *chkExportBrowser=(Fl_Check_Browser *)0; Fl_Button *btnClearAll=(Fl_Button *)0; static void cb_btnClearAll(Fl_Button*, void*) { btn_export_by_date->value(0); chkExportBrowser->check_none(); } Fl_Button *btnCheckAll=(Fl_Button *)0; static void cb_btnCheckAll(Fl_Button*, void*) { btn_export_by_date->value(0); chkExportBrowser->check_all(); } Fl_DateInput *inp_export_start_date=(Fl_DateInput *)0; static void cb_inp_export_start_date(Fl_DateInput*, void*) { cb_export_date_select(); } Fl_DateInput *inp_export_stop_date=(Fl_DateInput *)0; static void cb_inp_export_stop_date(Fl_DateInput*, void*) { cb_export_date_select(); } Fl_Check_Button *btn_export_by_date=(Fl_Check_Button *)0; static void cb_btn_export_by_date(Fl_Check_Button*, void*) { cb_export_date_select(); } Fl_Check_Button *btnSelectCall=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectName=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectFreq=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectBand=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectMode=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectQSOdateOn=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectQSOdateOff=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectTimeON=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectTimeOFF=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectTX_pwr=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectRSTsent=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectRSTrcvd=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectQth=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectLOC=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectState=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectAge=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectStaCall=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectStaCity=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectStaGrid=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectOperator=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectProvince=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectCountry=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectNotes=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectQSLrcvd=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectQSLsent=(Fl_Check_Button *)0; Fl_Check_Button *btnSelecteQSLrcvd=(Fl_Check_Button *)0; Fl_Check_Button *btnSelecteQSLsent=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectLOTWrcvd=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectLOTWsent=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectQSL_VIA=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectSerialIN=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectSerialOUT=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectCheck=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectXchgIn=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectMyXchg=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectCNTY=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectCONT=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectCQZ=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectDXCC=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectIOTA=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectITUZ=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectClass=(Fl_Check_Button *)0; Fl_Check_Button *btnSelectSection=(Fl_Check_Button *)0; Fl_Check_Button *btnSelect_cwss_serno=(Fl_Check_Button *)0; Fl_Check_Button *btnSelect_cwss_prec=(Fl_Check_Button *)0; Fl_Check_Button *btnSelect_cwss_check=(Fl_Check_Button *)0; Fl_Check_Button *btnSelect_cwss_section=(Fl_Check_Button *)0; Fl_Check_Button *btnSelect_1010=(Fl_Check_Button *)0; Fl_Button *btnClearAllFields=(Fl_Button *)0; static void cb_btnClearAllFields(Fl_Button*, void*) { btnSelectCall->value(0); btnSelectName->value(0); btnSelectFreq->value(0); btnSelectBand->value(0); btnSelectMode->value(0); btnSelectQSOdateOn->value(0); btnSelectQSOdateOff->value(0); btnSelectTimeON->value(0); btnSelectTimeOFF->value(0); btnSelectTX_pwr->value(0); btnSelectRSTsent->value(0); btnSelectRSTrcvd->value(0); btnSelectQth->value(0); btnSelectLOC->value(0); btnSelectState->value(0); btnSelectAge->value(0); btnSelectStaCall->value(0); btnSelectStaGrid->value(0); btnSelectStaCity->value(0); btnSelectOperator->value(0); btnSelectProvince->value(0); btnSelectCountry->value(0); btnSelectNotes->value(0); btnSelectQSLrcvd->value(0); btnSelectQSLsent->value(0); btnSelecteQSLrcvd->value(0); btnSelecteQSLsent->value(0); btnSelectLOTWrcvd->value(0); btnSelectLOTWsent->value(0); btnSelectQSL_VIA->value(0); btnSelectSerialIN->value(0); btnSelectSerialOUT->value(0); btnSelectCheck->value(0); btnSelectXchgIn->value(0); btnSelectMyXchg->value(0); btnSelectCNTY->value(0); btnSelectCONT->value(0); btnSelectCQZ->value(0); btnSelectDXCC->value(0); btnSelectIOTA->value(0); btnSelectITUZ->value(0); btnSelectClass->value(0); btnSelectSection->value(0); btnSelect_cwss_serno->value(0); btnSelect_cwss_prec->value(0); btnSelect_cwss_check->value(0); btnSelect_1010->value(0); } Fl_Button *btnCheckAllFields=(Fl_Button *)0; static void cb_btnCheckAllFields(Fl_Button*, void*) { btnSelectCall->value(1); btnSelectName->value(1); btnSelectFreq->value(1); btnSelectBand->value(1); btnSelectMode->value(1); btnSelectQSOdateOn->value(1); btnSelectQSOdateOff->value(1); btnSelectTimeON->value(1); btnSelectTimeOFF->value(1); btnSelectTX_pwr->value(1); btnSelectRSTsent->value(1); btnSelectRSTrcvd->value(1); btnSelectQth->value(1); btnSelectLOC->value(1); btnSelectState->value(1); btnSelectAge->value(1); btnSelectStaCall->value(1); btnSelectStaGrid->value(1); btnSelectStaCity->value(1); btnSelectOperator->value(1); btnSelectProvince->value(1); btnSelectCountry->value(1); btnSelectNotes->value(1); btnSelectQSLrcvd->value(1); btnSelectQSLsent->value(1); btnSelecteQSLrcvd->value(1); btnSelecteQSLsent->value(1); btnSelectLOTWrcvd->value(1); btnSelectLOTWsent->value(1); btnSelectQSL_VIA->value(1); btnSelectSerialIN->value(1); btnSelectSerialOUT->value(1); btnSelectCheck->value(1); btnSelectXchgIn->value(1); btnSelectMyXchg->value(1); btnSelectCNTY->value(1); btnSelectCONT->value(1); btnSelectCQZ->value(1); btnSelectDXCC->value(1); btnSelectIOTA->value(1); btnSelectITUZ->value(1); btnSelectClass->value(1); btnSelectSection->value(1); btnSelect_cwss_serno->value(1); btnSelect_cwss_prec->value(1); btnSelect_cwss_check->value(1); btnSelect_cwss_section->value(1); btnSelect_1010->value(1); } Fl_Button *btnSetFieldDefaults=(Fl_Button *)0; static void cb_btnSetFieldDefaults(Fl_Button*, void*) { btnSelectCall->value(1); btnSelectName->value(1); btnSelectFreq->value(1); btnSelectBand->value(1); btnSelectMode->value(1); btnSelectQSOdateOn->value(1); btnSelectQSOdateOff->value(1); btnSelectTimeON->value(1); btnSelectTimeOFF->value(1); btnSelectTX_pwr->value(0); btnSelectRSTsent->value(1); btnSelectRSTrcvd->value(1); btnSelectQth->value(0); btnSelectLOC->value(0); btnSelectState->value(0); btnSelectAge->value(0); btnSelectStaCall->value(0); btnSelectStaGrid->value(0); btnSelectStaCity->value(0); btnSelectOperator->value(0); btnSelectProvince->value(0); btnSelectCountry->value(0); btnSelectNotes->value(0); btnSelectQSLrcvd->value(0); btnSelectQSLsent->value(0); btnSelecteQSLrcvd->value(0); btnSelecteQSLsent->value(0); btnSelectLOTWrcvd->value(0); btnSelectLOTWsent->value(0); btnSelectQSL_VIA->value(0); btnSelectSerialIN->value(0); btnSelectSerialOUT->value(0); btnSelectCheck->value(0); btnSelectXchgIn->value(0); btnSelectMyXchg->value(0); btnSelectCNTY->value(0); btnSelectCONT->value(0); btnSelectCQZ->value(0); btnSelectDXCC->value(0); btnSelectIOTA->value(0); btnSelectITUZ->value(0); btnSelectClass->value(0); btnSelectSection->value(0); btnSelect_cwss_serno->value(0); btnSelect_cwss_prec->value(0); btnSelect_cwss_check->value(0); btnSelect_1010->value(0); } Fl_Button *btnSetLoTWfields=(Fl_Button *)0; static void cb_btnSetLoTWfields(Fl_Button*, void*) { btnSelectCall->value(1); btnSelectName->value(0); btnSelectFreq->value(1); btnSelectBand->value(0); btnSelectMode->value(1); btnSelectQSOdateOn->value(1); btnSelectQSOdateOff->value(0); btnSelectTimeON->value(1); btnSelectTimeOFF->value(0); btnSelectTX_pwr->value(0); btnSelectRSTsent->value(0); btnSelectRSTrcvd->value(0); btnSelectQth->value(0); btnSelectLOC->value(0); btnSelectState->value(0); btnSelectAge->value(0); btnSelectStaCall->value(0); btnSelectStaGrid->value(0); btnSelectStaCity->value(0); btnSelectOperator->value(0); btnSelectProvince->value(0); btnSelectCountry->value(0); btnSelectNotes->value(0); btnSelectQSLrcvd->value(0); btnSelectQSLsent->value(0); btnSelecteQSLrcvd->value(0); btnSelecteQSLsent->value(0); btnSelectLOTWrcvd->value(0); btnSelectLOTWsent->value(0); btnSelectQSL_VIA->value(0); btnSelectSerialIN->value(0); btnSelectSerialOUT->value(0); btnSelectCheck->value(0); btnSelectXchgIn->value(0); btnSelectMyXchg->value(0); btnSelectCNTY->value(0); btnSelectCONT->value(0); btnSelectCQZ->value(0); btnSelectDXCC->value(0); btnSelectIOTA->value(0); btnSelectITUZ->value(0); btnSelectClass->value(0); btnSelectSection->value(0); btnSelect_cwss_serno->value(0); btnSelect_cwss_prec->value(0); btnSelect_cwss_check->value(0); btnSelect_1010->value(0); } Fl_Return_Button *btnOK=(Fl_Return_Button *)0; static void cb_btnOK(Fl_Return_Button*, void*) { wExport->hide(); Export_log(); } Fl_Button *btnCancel=(Fl_Button *)0; static void cb_btnCancel(Fl_Button*, void*) { wExport->hide(); } Fl_Double_Window *dlgLogbook=(Fl_Double_Window *)0; Fl_DateInput *inpDate_log=(Fl_DateInput *)0; Fl_Input2 *inpTimeOn_log=(Fl_Input2 *)0; Fl_Input2 *inpCall_log=(Fl_Input2 *)0; Fl_Input2 *inpName_log=(Fl_Input2 *)0; Fl_Input2 *inpRstR_log=(Fl_Input2 *)0; Fl_Input2 *txtNbrRecs_log=(Fl_Input2 *)0; Fl_DateInput *inpDateOff_log=(Fl_DateInput *)0; Fl_Input2 *inpTimeOff_log=(Fl_Input2 *)0; Fl_Input2 *inpFreq_log=(Fl_Input2 *)0; Fl_Input2 *inpMode_log=(Fl_Input2 *)0; Fl_Input2 *inpTX_pwr_log=(Fl_Input2 *)0; Fl_Input2 *inpLoc_log=(Fl_Input2 *)0; Fl_Input2 *inpRstS_log=(Fl_Input2 *)0; Fl_Input2 *inpQth_log=(Fl_Input2 *)0; Fl_Input2 *inpState_log=(Fl_Input2 *)0; Fl_Input2 *inpVE_Prov_log=(Fl_Input2 *)0; Fl_Input2 *inpCountry_log=(Fl_Input2 *)0; Fl_Group *grpTabsSearch=(Fl_Group *)0; Fl_Tabs *Tabs=(Fl_Tabs *)0; Fl_Group *tab_log_qsl=(Fl_Group *)0; Fl_DateInput *inpQSLrcvddate_log=(Fl_DateInput *)0; Fl_DateInput *inpEQSLrcvddate_log=(Fl_DateInput *)0; Fl_DateInput *inpLOTWrcvddate_log=(Fl_DateInput *)0; Fl_DateInput *inpQSLsentdate_log=(Fl_DateInput *)0; Fl_DateInput *inpEQSLsentdate_log=(Fl_DateInput *)0; Fl_DateInput *inpLOTWsentdate_log=(Fl_DateInput *)0; Fl_Input2 *inpQSL_VIA_log=(Fl_Input2 *)0; Fl_Group *tab_log_other=(Fl_Group *)0; Fl_Input2 *inpCNTY_log=(Fl_Input2 *)0; Fl_Input2 *inpIOTA_log=(Fl_Input2 *)0; Fl_Input2 *inpCQZ_log=(Fl_Input2 *)0; Fl_Input2 *inpCONT_log=(Fl_Input2 *)0; Fl_Input2 *inpITUZ_log=(Fl_Input2 *)0; Fl_Input2 *inpDXCC_log=(Fl_Input2 *)0; Fl_Group *tab_log_notes=(Fl_Group *)0; Fl_Input2 *inpNotes_log=(Fl_Input2 *)0; Fl_Group *tab_log_my_station=(Fl_Group *)0; Fl_Input2 *inp_log_sta_call=(Fl_Input2 *)0; Fl_Input2 *inp_log_op_call=(Fl_Input2 *)0; Fl_Input2 *inp_log_sta_qth=(Fl_Input2 *)0; Fl_Input2 *inp_log_sta_loc=(Fl_Input2 *)0; Fl_Group *tab_log_contest=(Fl_Group *)0; Fl_Input2 *inpSerNoOut_log=(Fl_Input2 *)0; Fl_Input2 *inpMyXchg_log=(Fl_Input2 *)0; Fl_Input2 *inpSerNoIn_log=(Fl_Input2 *)0; Fl_Input2 *inpXchgIn_log=(Fl_Input2 *)0; Fl_Input2 *inpClass_log=(Fl_Input2 *)0; Fl_Input2 *inpSection_log=(Fl_Input2 *)0; Fl_Input2 *inp_age_log=(Fl_Input2 *)0; Fl_Input2 *inp_1010_log=(Fl_Input2 *)0; Fl_Input2 *inpBand_log=(Fl_Input2 *)0; Fl_Input2 *inp_check_log=(Fl_Input2 *)0; Fl_Group *tab_log_cwss=(Fl_Group *)0; Fl_Input2 *inp_log_cwss_serno=(Fl_Input2 *)0; Fl_Input2 *inp_log_cwss_sec=(Fl_Input2 *)0; Fl_Input2 *inp_log_cwss_prec=(Fl_Input2 *)0; Fl_Input2 *inp_log_cwss_chk=(Fl_Input2 *)0; Fl_Group *tab_log_jota=(Fl_Group *)0; Fl_Input2 *inp_log_troop_s=(Fl_Input2 *)0; Fl_Input2 *inp_log_troop_r=(Fl_Input2 *)0; Fl_Input2 *inp_log_scout_s=(Fl_Input2 *)0; Fl_Input2 *inp_log_scout_r=(Fl_Input2 *)0; Fl_Group *grpCallSearch=(Fl_Group *)0; Fl_Input2 *inpSearchString=(Fl_Input2 *)0; Fl_Button *bSearchPrev=(Fl_Button *)0; Fl_Button *bSearchNext=(Fl_Button *)0; Fl_Button *bRetrieve=(Fl_Button *)0; Fl_Group *grpFileButtons=(Fl_Group *)0; Fl_Button *bNewSave=(Fl_Button *)0; Fl_Button *bUpdateCancel=(Fl_Button *)0; Fl_Button *bDelete=(Fl_Button *)0; Fl_Output *txtLogFile=(Fl_Output *)0; Table *wBrowser=(Table *)0; Fl_Double_Window *wCabrillo=(Fl_Double_Window *)0; Fl_Check_Browser *chkCabBrowser=(Fl_Check_Browser *)0; Fl_Button *btnCabClearAll=(Fl_Button *)0; static void cb_btnCabClearAll(Fl_Button*, void*) { chkCabBrowser->check_none(); } Fl_Button *btnCabCheckAll=(Fl_Button *)0; static void cb_btnCabCheckAll(Fl_Button*, void*) { chkCabBrowser->check_all(); } Fl_Return_Button *btnCabOK=(Fl_Return_Button *)0; static void cb_btnCabOK(Fl_Return_Button*, void*) { wCabrillo->hide(); WriteCabrillo(); } Fl_Button *btnCabCancel=(Fl_Button *)0; static void cb_btnCabCancel(Fl_Button*, void*) { wCabrillo->hide(); } Fl_ComboBox *cboContest=(Fl_ComboBox *)0; static void cb_cboContest(Fl_ComboBox*, void*) { setContestType(); } Fl_Check_Button *btnCabCall=(Fl_Check_Button *)0; Fl_Check_Button *btnCabFreq=(Fl_Check_Button *)0; Fl_Check_Button *btnCabMode=(Fl_Check_Button *)0; Fl_Check_Button *btnCabQSOdate=(Fl_Check_Button *)0; Fl_Check_Button *btnCabTimeOFF=(Fl_Check_Button *)0; Fl_Check_Button *btnCabRSTsent=(Fl_Check_Button *)0; Fl_Check_Button *btnCabRSTrcvd=(Fl_Check_Button *)0; Fl_Check_Button *btnCabSerialIN=(Fl_Check_Button *)0; Fl_Check_Button *btnCabSerialOUT=(Fl_Check_Button *)0; Fl_Check_Button *btnCabXchgIn=(Fl_Check_Button *)0; Fl_Check_Button *btnCabMyXchg=(Fl_Check_Button *)0; Fl_Check_Button *btnCabState=(Fl_Check_Button *)0; Fl_Check_Button *btnCabCounty=(Fl_Check_Button *)0; Fl_Button *btnCabClearAllFields=(Fl_Button *)0; static void cb_btnCabClearAllFields(Fl_Button*, void*) { btnCabCall->value(0); btnCabFreq->value(0); btnCabMode->value(0); btnCabQSOdate->value(0); btnCabTimeOFF->value(0); btnCabSerialIN->value(0); btnCabSerialOUT->value(0); btnCabXchgIn->value(0); btnCabMyXchg->value(0); btnCabRSTsent->value(0); btnCabRSTrcvd->value(0); } Fl_Button *btnCabCheckAllFields=(Fl_Button *)0; static void cb_btnCabCheckAllFields(Fl_Button*, void*) { btnCabCall->value(1); btnCabFreq->value(1); btnCabMode->value(1); btnCabQSOdate->value(1); btnCabTimeOFF->value(1); btnCabSerialIN->value(1); btnCabSerialOUT->value(1); btnCabXchgIn->value(1); btnCabMyXchg->value(1); btnCabRSTsent->value(1); btnCabRSTrcvd->value(1); } void create_logbook_dialogs() { { wExport = new Fl_Double_Window(805, 440, _("Export Setup")); { Fl_Group* o = new Fl_Group(4, 4, 388, 430, _("Select Records to Export")); o->box(FL_ENGRAVED_FRAME); o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE)); { chkExportBrowser = new Fl_Check_Browser(13, 25, 370, 330); } // Fl_Check_Browser* chkExportBrowser { btnClearAll = new Fl_Button(78, 362, 90, 20, _("Clear All")); btnClearAll->callback((Fl_Callback*)cb_btnClearAll); } // Fl_Button* btnClearAll { btnCheckAll = new Fl_Button(201, 362, 90, 20, _("Check All")); btnCheckAll->callback((Fl_Callback*)cb_btnCheckAll); } // Fl_Button* btnCheckAll { inp_export_start_date = new Fl_DateInput(20, 402, 100, 22, _("Start Date")); inp_export_start_date->tooltip(_("Start date for export")); inp_export_start_date->box(FL_DOWN_BOX); inp_export_start_date->color(FL_BACKGROUND2_COLOR); inp_export_start_date->selection_color(FL_SELECTION_COLOR); inp_export_start_date->labeltype(FL_NORMAL_LABEL); inp_export_start_date->labelfont(0); inp_export_start_date->labelsize(14); inp_export_start_date->labelcolor(FL_FOREGROUND_COLOR); inp_export_start_date->callback((Fl_Callback*)cb_inp_export_start_date); inp_export_start_date->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inp_export_start_date->when(FL_WHEN_RELEASE); inp_export_start_date->format(2); } // Fl_DateInput* inp_export_start_date { inp_export_stop_date = new Fl_DateInput(144, 402, 100, 22, _("Stop Date")); inp_export_stop_date->tooltip(_("Inclusive stop date for export")); inp_export_stop_date->box(FL_DOWN_BOX); inp_export_stop_date->color(FL_BACKGROUND2_COLOR); inp_export_stop_date->selection_color(FL_SELECTION_COLOR); inp_export_stop_date->labeltype(FL_NORMAL_LABEL); inp_export_stop_date->labelfont(0); inp_export_stop_date->labelsize(14); inp_export_stop_date->labelcolor(FL_FOREGROUND_COLOR); inp_export_stop_date->callback((Fl_Callback*)cb_inp_export_stop_date); inp_export_stop_date->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inp_export_stop_date->when(FL_WHEN_RELEASE); inp_export_stop_date->format(2); } // Fl_DateInput* inp_export_stop_date { btn_export_by_date = new Fl_Check_Button(269, 405, 70, 15, _("select by date")); btn_export_by_date->tooltip(_("Enable to select date range")); btn_export_by_date->down_box(FL_DOWN_BOX); btn_export_by_date->callback((Fl_Callback*)cb_btn_export_by_date); } // Fl_Check_Button* btn_export_by_date o->end(); } // Fl_Group* o { Fl_Group* o = new Fl_Group(392, 4, 414, 430, _("Select Fields to Export")); o->box(FL_ENGRAVED_FRAME); o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE)); { btnSelectCall = new Fl_Check_Button(402, 26, 70, 15, _("Call")); btnSelectCall->down_box(FL_DOWN_BOX); btnSelectCall->value(1); } // Fl_Check_Button* btnSelectCall { btnSelectName = new Fl_Check_Button(402, 47, 70, 15, _("Name")); btnSelectName->down_box(FL_DOWN_BOX); btnSelectName->value(1); } // Fl_Check_Button* btnSelectName { btnSelectFreq = new Fl_Check_Button(402, 68, 70, 15, _("Freq")); btnSelectFreq->down_box(FL_DOWN_BOX); btnSelectFreq->value(1); } // Fl_Check_Button* btnSelectFreq { btnSelectBand = new Fl_Check_Button(402, 90, 70, 15, _("Band")); btnSelectBand->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectBand { btnSelectMode = new Fl_Check_Button(402, 111, 70, 15, _("Mode")); btnSelectMode->down_box(FL_DOWN_BOX); btnSelectMode->value(1); } // Fl_Check_Button* btnSelectMode { btnSelectQSOdateOn = new Fl_Check_Button(402, 133, 70, 15, _("QSO Date On")); btnSelectQSOdateOn->down_box(FL_DOWN_BOX); btnSelectQSOdateOn->value(1); } // Fl_Check_Button* btnSelectQSOdateOn { btnSelectQSOdateOff = new Fl_Check_Button(402, 154, 70, 15, _("QSO Date Off")); btnSelectQSOdateOff->down_box(FL_DOWN_BOX); btnSelectQSOdateOff->value(1); } // Fl_Check_Button* btnSelectQSOdateOff { btnSelectTimeON = new Fl_Check_Button(402, 176, 70, 15, _("Time ON")); btnSelectTimeON->down_box(FL_DOWN_BOX); btnSelectTimeON->value(1); } // Fl_Check_Button* btnSelectTimeON { btnSelectTimeOFF = new Fl_Check_Button(402, 197, 70, 15, _("Time OFF")); btnSelectTimeOFF->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectTimeOFF { btnSelectTX_pwr = new Fl_Check_Button(402, 219, 70, 15, _("TX Power")); btnSelectTX_pwr->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectTX_pwr { btnSelectRSTsent = new Fl_Check_Button(402, 240, 70, 15, _("RST sent")); btnSelectRSTsent->down_box(FL_DOWN_BOX); btnSelectRSTsent->value(1); } // Fl_Check_Button* btnSelectRSTsent { btnSelectRSTrcvd = new Fl_Check_Button(402, 262, 70, 15, _("RST rcvd")); btnSelectRSTrcvd->down_box(FL_DOWN_BOX); btnSelectRSTrcvd->value(1); } // Fl_Check_Button* btnSelectRSTrcvd { btnSelectQth = new Fl_Check_Button(402, 283, 70, 15, _("Qth")); btnSelectQth->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectQth { btnSelectLOC = new Fl_Check_Button(402, 305, 70, 15, _("LOC")); btnSelectLOC->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectLOC { btnSelectState = new Fl_Check_Button(402, 326, 70, 15, _("State")); btnSelectState->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectState { btnSelectAge = new Fl_Check_Button(402, 348, 70, 15, _("Age")); btnSelectAge->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectAge { btnSelectStaCall = new Fl_Check_Button(536, 26, 70, 15, _("Station Call")); btnSelectStaCall->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectStaCall { btnSelectStaCity = new Fl_Check_Button(536, 47, 70, 15, _("Station QTH")); btnSelectStaCity->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectStaCity { btnSelectStaGrid = new Fl_Check_Button(536, 68, 70, 15, _("Station LOC")); btnSelectStaGrid->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectStaGrid { btnSelectOperator = new Fl_Check_Button(536, 90, 70, 15, _("Operator")); btnSelectOperator->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectOperator { btnSelectProvince = new Fl_Check_Button(536, 111, 70, 15, _("Province")); btnSelectProvince->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectProvince { btnSelectCountry = new Fl_Check_Button(536, 133, 70, 15, _("Country")); btnSelectCountry->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectCountry { btnSelectNotes = new Fl_Check_Button(536, 154, 70, 15, _("Notes")); btnSelectNotes->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectNotes { btnSelectQSLrcvd = new Fl_Check_Button(536, 176, 70, 15, _("QSL rcvd date")); btnSelectQSLrcvd->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectQSLrcvd { btnSelectQSLsent = new Fl_Check_Button(536, 197, 70, 15, _("QSL sent date")); btnSelectQSLsent->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectQSLsent { btnSelecteQSLrcvd = new Fl_Check_Button(536, 219, 70, 15, _("eQSL rcvd date")); btnSelecteQSLrcvd->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelecteQSLrcvd { btnSelecteQSLsent = new Fl_Check_Button(536, 240, 70, 15, _("eQSL sent date")); btnSelecteQSLsent->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelecteQSLsent { btnSelectLOTWrcvd = new Fl_Check_Button(536, 262, 70, 15, _("LoTW rcvd date")); btnSelectLOTWrcvd->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectLOTWrcvd { btnSelectLOTWsent = new Fl_Check_Button(536, 283, 70, 15, _("LoTW sent date")); btnSelectLOTWsent->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectLOTWsent { btnSelectQSL_VIA = new Fl_Check_Button(536, 305, 70, 15, _("QSL-VIA")); btnSelectQSL_VIA->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectQSL_VIA { btnSelectSerialIN = new Fl_Check_Button(536, 326, 70, 15, _("Serial # in")); btnSelectSerialIN->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectSerialIN { btnSelectSerialOUT = new Fl_Check_Button(536, 348, 70, 15, _("Serial # out")); btnSelectSerialOUT->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectSerialOUT { btnSelectCheck = new Fl_Check_Button(670, 26, 70, 15, _("Check")); btnSelectCheck->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectCheck { btnSelectXchgIn = new Fl_Check_Button(670, 47, 70, 15, _("Exchange In")); btnSelectXchgIn->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectXchgIn { btnSelectMyXchg = new Fl_Check_Button(670, 68, 70, 15, _("Exchange Out")); btnSelectMyXchg->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectMyXchg { btnSelectCNTY = new Fl_Check_Button(670, 90, 70, 15, _("County")); btnSelectCNTY->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectCNTY { btnSelectCONT = new Fl_Check_Button(670, 111, 70, 15, _("Continent")); btnSelectCONT->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectCONT { btnSelectCQZ = new Fl_Check_Button(670, 133, 70, 15, _("CQZ")); btnSelectCQZ->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectCQZ { btnSelectDXCC = new Fl_Check_Button(670, 154, 70, 15, _("DXCC")); btnSelectDXCC->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectDXCC { btnSelectIOTA = new Fl_Check_Button(670, 176, 70, 15, _("IOTA")); btnSelectIOTA->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectIOTA { btnSelectITUZ = new Fl_Check_Button(670, 197, 70, 15, _("ITUZ")); btnSelectITUZ->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectITUZ { btnSelectClass = new Fl_Check_Button(670, 219, 70, 15, _("FD class")); btnSelectClass->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectClass { btnSelectSection = new Fl_Check_Button(670, 240, 70, 15, _("FD section")); btnSelectSection->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelectSection { btnSelect_cwss_serno = new Fl_Check_Button(670, 262, 70, 15, _("CW SS SerNo R")); btnSelect_cwss_serno->tooltip(_("CW sweepstakes rcvd ser. no.")); btnSelect_cwss_serno->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelect_cwss_serno { btnSelect_cwss_prec = new Fl_Check_Button(670, 283, 70, 15, _("CW SS Prec\'")); btnSelect_cwss_prec->tooltip(_("CW sweepstakes precedence")); btnSelect_cwss_prec->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelect_cwss_prec { btnSelect_cwss_check = new Fl_Check_Button(670, 305, 70, 15, _("CW SS Check")); btnSelect_cwss_check->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelect_cwss_check { btnSelect_cwss_section = new Fl_Check_Button(670, 326, 70, 15, _("CW SS Section")); btnSelect_cwss_section->tooltip(_("CW sweepstakes section")); btnSelect_cwss_section->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelect_cwss_section { btnSelect_1010 = new Fl_Check_Button(670, 348, 70, 15, _("10-10")); btnSelect_1010->tooltip(_("CW sweepstakes section")); btnSelect_1010->down_box(FL_DOWN_BOX); } // Fl_Check_Button* btnSelect_1010 { btnClearAllFields = new Fl_Button(412, 373, 85, 20, _("Clear All")); btnClearAllFields->callback((Fl_Callback*)cb_btnClearAllFields); } // Fl_Button* btnClearAllFields { btnCheckAllFields = new Fl_Button(507, 373, 85, 20, _("Check All")); btnCheckAllFields->callback((Fl_Callback*)cb_btnCheckAllFields); } // Fl_Button* btnCheckAllFields { btnSetFieldDefaults = new Fl_Button(602, 373, 85, 20, _("Defaults")); btnSetFieldDefaults->callback((Fl_Callback*)cb_btnSetFieldDefaults); } // Fl_Button* btnSetFieldDefaults { btnSetLoTWfields = new Fl_Button(697, 373, 85, 20, _("LoTW")); btnSetLoTWfields->callback((Fl_Callback*)cb_btnSetLoTWfields); } // Fl_Button* btnSetLoTWfields { btnOK = new Fl_Return_Button(697, 403, 85, 20, _("OK")); btnOK->callback((Fl_Callback*)cb_btnOK); } // Fl_Return_Button* btnOK { btnCancel = new Fl_Button(602, 403, 85, 20, _("Cancel")); btnCancel->callback((Fl_Callback*)cb_btnCancel); } // Fl_Button* btnCancel o->end(); } // Fl_Group* o wExport->end(); } // Fl_Double_Window* wExport { Fl_Double_Window* o = dlgLogbook = new Fl_Double_Window(590, 390, _("Logbook")); { inpDate_log = new Fl_DateInput(4, 24, 100, 24, _("Date On")); inpDate_log->tooltip(_("Date QSO started")); inpDate_log->box(FL_DOWN_BOX); inpDate_log->color(FL_BACKGROUND2_COLOR); inpDate_log->selection_color(FL_SELECTION_COLOR); inpDate_log->labeltype(FL_NORMAL_LABEL); inpDate_log->labelfont(0); inpDate_log->labelsize(14); inpDate_log->labelcolor(FL_FOREGROUND_COLOR); inpDate_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpDate_log->when(FL_WHEN_RELEASE); inpDate_log->format(2); } // Fl_DateInput* inpDate_log { inpTimeOn_log = new Fl_Input2(106, 24, 70, 24, _("Time On")); inpTimeOn_log->tooltip(_("Time QSO started")); inpTimeOn_log->box(FL_DOWN_BOX); inpTimeOn_log->color(FL_BACKGROUND2_COLOR); inpTimeOn_log->selection_color(FL_SELECTION_COLOR); inpTimeOn_log->labeltype(FL_NORMAL_LABEL); inpTimeOn_log->labelfont(0); inpTimeOn_log->labelsize(14); inpTimeOn_log->labelcolor(FL_FOREGROUND_COLOR); inpTimeOn_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpTimeOn_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpTimeOn_log { inpCall_log = new Fl_Input2(178, 24, 100, 24, _("Call")); inpCall_log->tooltip(_("Call sign worked")); inpCall_log->box(FL_DOWN_BOX); inpCall_log->color(FL_BACKGROUND2_COLOR); inpCall_log->selection_color(FL_SELECTION_COLOR); inpCall_log->labeltype(FL_NORMAL_LABEL); inpCall_log->labelfont(0); inpCall_log->labelsize(14); inpCall_log->labelcolor(FL_FOREGROUND_COLOR); inpCall_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpCall_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpCall_log { inpName_log = new Fl_Input2(280, 24, 185, 24, _("Name")); inpName_log->tooltip(_("Operator worked")); inpName_log->box(FL_DOWN_BOX); inpName_log->color(FL_BACKGROUND2_COLOR); inpName_log->selection_color(FL_SELECTION_COLOR); inpName_log->labeltype(FL_NORMAL_LABEL); inpName_log->labelfont(0); inpName_log->labelsize(14); inpName_log->labelcolor(FL_FOREGROUND_COLOR); inpName_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpName_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpName_log { inpRstR_log = new Fl_Input2(468, 24, 36, 24, _("In")); inpRstR_log->tooltip(_("Rst received")); inpRstR_log->box(FL_DOWN_BOX); inpRstR_log->color(FL_BACKGROUND2_COLOR); inpRstR_log->selection_color(FL_SELECTION_COLOR); inpRstR_log->labeltype(FL_NORMAL_LABEL); inpRstR_log->labelfont(0); inpRstR_log->labelsize(14); inpRstR_log->labelcolor(FL_FOREGROUND_COLOR); inpRstR_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpRstR_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpRstR_log { txtNbrRecs_log = new Fl_Input2(520, 24, 65, 24, _("Recs")); txtNbrRecs_log->tooltip(_("# Records in logbook")); txtNbrRecs_log->box(FL_DOWN_BOX); txtNbrRecs_log->color(FL_BACKGROUND2_COLOR); txtNbrRecs_log->selection_color(FL_SELECTION_COLOR); txtNbrRecs_log->labeltype(FL_NORMAL_LABEL); txtNbrRecs_log->labelfont(0); txtNbrRecs_log->labelsize(14); txtNbrRecs_log->labelcolor(FL_FOREGROUND_COLOR); txtNbrRecs_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); txtNbrRecs_log->when(FL_WHEN_RELEASE); } // Fl_Input2* txtNbrRecs_log { inpDateOff_log = new Fl_DateInput(4, 68, 100, 24, _("Date Off")); inpDateOff_log->tooltip(_("Date QSO Ended")); inpDateOff_log->box(FL_DOWN_BOX); inpDateOff_log->color(FL_BACKGROUND2_COLOR); inpDateOff_log->selection_color(FL_SELECTION_COLOR); inpDateOff_log->labeltype(FL_NORMAL_LABEL); inpDateOff_log->labelfont(0); inpDateOff_log->labelsize(14); inpDateOff_log->labelcolor(FL_FOREGROUND_COLOR); inpDateOff_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpDateOff_log->when(FL_WHEN_RELEASE); inpDateOff_log->format(2); } // Fl_DateInput* inpDateOff_log { inpTimeOff_log = new Fl_Input2(106, 68, 70, 24, _("Time Off")); inpTimeOff_log->tooltip(_("Time QSO ended")); inpTimeOff_log->box(FL_DOWN_BOX); inpTimeOff_log->color(FL_BACKGROUND2_COLOR); inpTimeOff_log->selection_color(FL_SELECTION_COLOR); inpTimeOff_log->labeltype(FL_NORMAL_LABEL); inpTimeOff_log->labelfont(0); inpTimeOff_log->labelsize(14); inpTimeOff_log->labelcolor(FL_FOREGROUND_COLOR); inpTimeOff_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpTimeOff_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpTimeOff_log { inpFreq_log = new Fl_Input2(178, 68, 100, 24, _("Freq.")); inpFreq_log->tooltip(_("Frequency in MHz")); inpFreq_log->box(FL_DOWN_BOX); inpFreq_log->color(FL_BACKGROUND2_COLOR); inpFreq_log->selection_color(FL_SELECTION_COLOR); inpFreq_log->labeltype(FL_NORMAL_LABEL); inpFreq_log->labelfont(0); inpFreq_log->labelsize(14); inpFreq_log->labelcolor(FL_FOREGROUND_COLOR); inpFreq_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpFreq_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpFreq_log { inpMode_log = new Fl_Input2(280, 68, 146, 24, _("Mode")); inpMode_log->tooltip(_("Mode in use")); inpMode_log->box(FL_DOWN_BOX); inpMode_log->color(FL_BACKGROUND2_COLOR); inpMode_log->selection_color(FL_SELECTION_COLOR); inpMode_log->labeltype(FL_NORMAL_LABEL); inpMode_log->labelfont(0); inpMode_log->labelsize(14); inpMode_log->labelcolor(FL_FOREGROUND_COLOR); inpMode_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpMode_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpMode_log { inpTX_pwr_log = new Fl_Input2(429, 68, 36, 24, _("Pwr")); inpTX_pwr_log->tooltip(_("Transmit power used")); inpTX_pwr_log->box(FL_DOWN_BOX); inpTX_pwr_log->color(FL_BACKGROUND2_COLOR); inpTX_pwr_log->selection_color(FL_SELECTION_COLOR); inpTX_pwr_log->labeltype(FL_NORMAL_LABEL); inpTX_pwr_log->labelfont(0); inpTX_pwr_log->labelsize(14); inpTX_pwr_log->labelcolor(FL_FOREGROUND_COLOR); inpTX_pwr_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpTX_pwr_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpTX_pwr_log { inpLoc_log = new Fl_Input2(508, 68, 76, 24, _("Loc")); inpLoc_log->tooltip(_("Stations grid square")); inpLoc_log->box(FL_DOWN_BOX); inpLoc_log->color(FL_BACKGROUND2_COLOR); inpLoc_log->selection_color(FL_SELECTION_COLOR); inpLoc_log->labeltype(FL_NORMAL_LABEL); inpLoc_log->labelfont(0); inpLoc_log->labelsize(14); inpLoc_log->labelcolor(FL_FOREGROUND_COLOR); inpLoc_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpLoc_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpLoc_log { inpRstS_log = new Fl_Input2(468, 68, 36, 24, _("Out")); inpRstS_log->tooltip(_("Rst sent")); inpRstS_log->box(FL_DOWN_BOX); inpRstS_log->color(FL_BACKGROUND2_COLOR); inpRstS_log->selection_color(FL_SELECTION_COLOR); inpRstS_log->labeltype(FL_NORMAL_LABEL); inpRstS_log->labelfont(0); inpRstS_log->labelsize(14); inpRstS_log->labelcolor(FL_FOREGROUND_COLOR); inpRstS_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpRstS_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpRstS_log { inpQth_log = new Fl_Input2(5, 112, 280, 24, _("Qth")); inpQth_log->tooltip(_("City of station worked")); inpQth_log->box(FL_DOWN_BOX); inpQth_log->color(FL_BACKGROUND2_COLOR); inpQth_log->selection_color(FL_SELECTION_COLOR); inpQth_log->labeltype(FL_NORMAL_LABEL); inpQth_log->labelfont(0); inpQth_log->labelsize(14); inpQth_log->labelcolor(FL_FOREGROUND_COLOR); inpQth_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpQth_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpQth_log { inpState_log = new Fl_Input2(288, 112, 44, 24, _("St")); inpState_log->tooltip(_("US state of station worked")); inpState_log->box(FL_DOWN_BOX); inpState_log->color(FL_BACKGROUND2_COLOR); inpState_log->selection_color(FL_SELECTION_COLOR); inpState_log->labeltype(FL_NORMAL_LABEL); inpState_log->labelfont(0); inpState_log->labelsize(14); inpState_log->labelcolor(FL_FOREGROUND_COLOR); inpState_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpState_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpState_log { inpVE_Prov_log = new Fl_Input2(335, 112, 44, 24, _("Pr")); inpVE_Prov_log->tooltip(_("Province of station worked")); inpVE_Prov_log->box(FL_DOWN_BOX); inpVE_Prov_log->color(FL_BACKGROUND2_COLOR); inpVE_Prov_log->selection_color(FL_SELECTION_COLOR); inpVE_Prov_log->labeltype(FL_NORMAL_LABEL); inpVE_Prov_log->labelfont(0); inpVE_Prov_log->labelsize(14); inpVE_Prov_log->labelcolor(FL_FOREGROUND_COLOR); inpVE_Prov_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpVE_Prov_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpVE_Prov_log { inpCountry_log = new Fl_Input2(382, 112, 202, 24, _("Country")); inpCountry_log->tooltip(_("Country of station worked")); inpCountry_log->box(FL_DOWN_BOX); inpCountry_log->color(FL_BACKGROUND2_COLOR); inpCountry_log->selection_color(FL_SELECTION_COLOR); inpCountry_log->labeltype(FL_NORMAL_LABEL); inpCountry_log->labelfont(0); inpCountry_log->labelsize(14); inpCountry_log->labelcolor(FL_FOREGROUND_COLOR); inpCountry_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpCountry_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpCountry_log { Fl_Group* o = grpTabsSearch = new Fl_Group(0, 137, 590, 125); { Tabs = new Fl_Tabs(0, 140, 481, 120); { tab_log_qsl = new Fl_Group(0, 161, 481, 97, _("QSL")); { Fl_DateInput* o = inpQSLrcvddate_log = new Fl_DateInput(14, 188, 100, 24, _("QSL-rcvd")); inpQSLrcvddate_log->tooltip(_("QSL received on this date")); inpQSLrcvddate_log->box(FL_DOWN_BOX); inpQSLrcvddate_log->color(FL_BACKGROUND2_COLOR); inpQSLrcvddate_log->selection_color(FL_SELECTION_COLOR); inpQSLrcvddate_log->labeltype(FL_NORMAL_LABEL); inpQSLrcvddate_log->labelfont(0); inpQSLrcvddate_log->labelsize(14); inpQSLrcvddate_log->labelcolor(FL_FOREGROUND_COLOR); inpQSLrcvddate_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpQSLrcvddate_log->when(FL_WHEN_RELEASE); o->format(2); } // Fl_DateInput* inpQSLrcvddate_log { Fl_DateInput* o = inpEQSLrcvddate_log = new Fl_DateInput(118, 188, 100, 24, _("EQSL-rcvd")); inpEQSLrcvddate_log->tooltip(_("QSL received on this date")); inpEQSLrcvddate_log->box(FL_DOWN_BOX); inpEQSLrcvddate_log->color(FL_BACKGROUND2_COLOR); inpEQSLrcvddate_log->selection_color(FL_SELECTION_COLOR); inpEQSLrcvddate_log->labeltype(FL_NORMAL_LABEL); inpEQSLrcvddate_log->labelfont(0); inpEQSLrcvddate_log->labelsize(14); inpEQSLrcvddate_log->labelcolor(FL_FOREGROUND_COLOR); inpEQSLrcvddate_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpEQSLrcvddate_log->when(FL_WHEN_RELEASE); o->format(2); } // Fl_DateInput* inpEQSLrcvddate_log { Fl_DateInput* o = inpLOTWrcvddate_log = new Fl_DateInput(222, 188, 100, 24, _("LOTW-rcvd")); inpLOTWrcvddate_log->tooltip(_("QSL received on this date")); inpLOTWrcvddate_log->box(FL_DOWN_BOX); inpLOTWrcvddate_log->color(FL_BACKGROUND2_COLOR); inpLOTWrcvddate_log->selection_color(FL_SELECTION_COLOR); inpLOTWrcvddate_log->labeltype(FL_NORMAL_LABEL); inpLOTWrcvddate_log->labelfont(0); inpLOTWrcvddate_log->labelsize(14); inpLOTWrcvddate_log->labelcolor(FL_FOREGROUND_COLOR); inpLOTWrcvddate_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpLOTWrcvddate_log->when(FL_WHEN_RELEASE); o->format(2); } // Fl_DateInput* inpLOTWrcvddate_log { Fl_DateInput* o = inpQSLsentdate_log = new Fl_DateInput(14, 234, 100, 24, _("QSL-sent")); inpQSLsentdate_log->tooltip(_("QSL sent on this date")); inpQSLsentdate_log->box(FL_DOWN_BOX); inpQSLsentdate_log->color(FL_BACKGROUND2_COLOR); inpQSLsentdate_log->selection_color(FL_SELECTION_COLOR); inpQSLsentdate_log->labeltype(FL_NORMAL_LABEL); inpQSLsentdate_log->labelfont(0); inpQSLsentdate_log->labelsize(14); inpQSLsentdate_log->labelcolor(FL_FOREGROUND_COLOR); inpQSLsentdate_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpQSLsentdate_log->when(FL_WHEN_RELEASE); o->format(2); } // Fl_DateInput* inpQSLsentdate_log { Fl_DateInput* o = inpEQSLsentdate_log = new Fl_DateInput(118, 234, 100, 24, _("EQSL-sent")); inpEQSLsentdate_log->tooltip(_("QSL sent on this date")); inpEQSLsentdate_log->box(FL_DOWN_BOX); inpEQSLsentdate_log->color(FL_BACKGROUND2_COLOR); inpEQSLsentdate_log->selection_color(FL_SELECTION_COLOR); inpEQSLsentdate_log->labeltype(FL_NORMAL_LABEL); inpEQSLsentdate_log->labelfont(0); inpEQSLsentdate_log->labelsize(14); inpEQSLsentdate_log->labelcolor(FL_FOREGROUND_COLOR); inpEQSLsentdate_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpEQSLsentdate_log->when(FL_WHEN_RELEASE); o->format(2); } // Fl_DateInput* inpEQSLsentdate_log { Fl_DateInput* o = inpLOTWsentdate_log = new Fl_DateInput(222, 234, 100, 24, _("LOTW-sent")); inpLOTWsentdate_log->tooltip(_("QSL sent on this date")); inpLOTWsentdate_log->box(FL_DOWN_BOX); inpLOTWsentdate_log->color(FL_BACKGROUND2_COLOR); inpLOTWsentdate_log->selection_color(FL_SELECTION_COLOR); inpLOTWsentdate_log->labeltype(FL_NORMAL_LABEL); inpLOTWsentdate_log->labelfont(0); inpLOTWsentdate_log->labelsize(14); inpLOTWsentdate_log->labelcolor(FL_FOREGROUND_COLOR); inpLOTWsentdate_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpLOTWsentdate_log->when(FL_WHEN_RELEASE); o->format(2); } // Fl_DateInput* inpLOTWsentdate_log { inpQSL_VIA_log = new Fl_Input2(325, 188, 156, 70, _("QSL-VIA")); inpQSL_VIA_log->tooltip(_("QSL route of contacted station")); inpQSL_VIA_log->type(4); inpQSL_VIA_log->box(FL_DOWN_BOX); inpQSL_VIA_log->color(FL_BACKGROUND2_COLOR); inpQSL_VIA_log->selection_color(FL_SELECTION_COLOR); inpQSL_VIA_log->labeltype(FL_NORMAL_LABEL); inpQSL_VIA_log->labelfont(0); inpQSL_VIA_log->labelsize(14); inpQSL_VIA_log->labelcolor(FL_FOREGROUND_COLOR); inpQSL_VIA_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpQSL_VIA_log->when(FL_WHEN_RELEASE); Fl_Group::current()->resizable(inpQSL_VIA_log); } // Fl_Input2* inpQSL_VIA_log tab_log_qsl->end(); } // Fl_Group* tab_log_qsl { tab_log_other = new Fl_Group(0, 161, 475, 99, _("Other")); tab_log_other->hide(); { inpCNTY_log = new Fl_Input2(21, 192, 241, 24, _("County")); inpCNTY_log->tooltip(_("County")); inpCNTY_log->box(FL_DOWN_BOX); inpCNTY_log->color(FL_BACKGROUND2_COLOR); inpCNTY_log->selection_color(FL_SELECTION_COLOR); inpCNTY_log->labeltype(FL_NORMAL_LABEL); inpCNTY_log->labelfont(0); inpCNTY_log->labelsize(14); inpCNTY_log->labelcolor(FL_FOREGROUND_COLOR); inpCNTY_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpCNTY_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpCNTY_log { inpIOTA_log = new Fl_Input2(276, 192, 90, 24, _("IOTA")); inpIOTA_log->tooltip(_("Islands on the air")); inpIOTA_log->box(FL_DOWN_BOX); inpIOTA_log->color(FL_BACKGROUND2_COLOR); inpIOTA_log->selection_color(FL_SELECTION_COLOR); inpIOTA_log->labeltype(FL_NORMAL_LABEL); inpIOTA_log->labelfont(0); inpIOTA_log->labelsize(14); inpIOTA_log->labelcolor(FL_FOREGROUND_COLOR); inpIOTA_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpIOTA_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpIOTA_log { inpCQZ_log = new Fl_Input2(383, 192, 90, 24, _("CQZ")); inpCQZ_log->tooltip(_("CQ zone")); inpCQZ_log->box(FL_DOWN_BOX); inpCQZ_log->color(FL_BACKGROUND2_COLOR); inpCQZ_log->selection_color(FL_SELECTION_COLOR); inpCQZ_log->labeltype(FL_NORMAL_LABEL); inpCQZ_log->labelfont(0); inpCQZ_log->labelsize(14); inpCQZ_log->labelcolor(FL_FOREGROUND_COLOR); inpCQZ_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpCQZ_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpCQZ_log { inpCONT_log = new Fl_Input2(21, 236, 241, 24, _("Cont\'")); inpCONT_log->tooltip(_("Continent")); inpCONT_log->box(FL_DOWN_BOX); inpCONT_log->color(FL_BACKGROUND2_COLOR); inpCONT_log->selection_color(FL_SELECTION_COLOR); inpCONT_log->labeltype(FL_NORMAL_LABEL); inpCONT_log->labelfont(0); inpCONT_log->labelsize(14); inpCONT_log->labelcolor(FL_FOREGROUND_COLOR); inpCONT_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpCONT_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpCONT_log { inpITUZ_log = new Fl_Input2(277, 236, 90, 24, _("ITUZ")); inpITUZ_log->tooltip(_("ITU zone")); inpITUZ_log->box(FL_DOWN_BOX); inpITUZ_log->color(FL_BACKGROUND2_COLOR); inpITUZ_log->selection_color(FL_SELECTION_COLOR); inpITUZ_log->labeltype(FL_NORMAL_LABEL); inpITUZ_log->labelfont(0); inpITUZ_log->labelsize(14); inpITUZ_log->labelcolor(FL_FOREGROUND_COLOR); inpITUZ_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpITUZ_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpITUZ_log { inpDXCC_log = new Fl_Input2(383, 236, 90, 24, _("DXCC")); inpDXCC_log->tooltip(_("DXCC designator")); inpDXCC_log->box(FL_DOWN_BOX); inpDXCC_log->color(FL_BACKGROUND2_COLOR); inpDXCC_log->selection_color(FL_SELECTION_COLOR); inpDXCC_log->labeltype(FL_NORMAL_LABEL); inpDXCC_log->labelfont(0); inpDXCC_log->labelsize(14); inpDXCC_log->labelcolor(FL_FOREGROUND_COLOR); inpDXCC_log->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inpDXCC_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpDXCC_log tab_log_other->end(); } // Fl_Group* tab_log_other { tab_log_notes = new Fl_Group(0, 161, 480, 96, _("Notes")); tab_log_notes->hide(); { inpNotes_log = new Fl_Input2(15, 171, 465, 85); inpNotes_log->tooltip(_("Interesting notes")); inpNotes_log->type(4); inpNotes_log->box(FL_DOWN_BOX); inpNotes_log->color(FL_BACKGROUND2_COLOR); inpNotes_log->selection_color(FL_SELECTION_COLOR); inpNotes_log->labeltype(FL_NORMAL_LABEL); inpNotes_log->labelfont(0); inpNotes_log->labelsize(14); inpNotes_log->labelcolor(FL_FOREGROUND_COLOR); inpNotes_log->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE)); inpNotes_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpNotes_log tab_log_notes->end(); } // Fl_Group* tab_log_notes { tab_log_my_station = new Fl_Group(0, 161, 475, 99, _("My Station")); tab_log_my_station->hide(); { inp_log_sta_call = new Fl_Input2(15, 192, 100, 24, _("Station Call")); inp_log_sta_call->tooltip(_("Interesting notes")); inp_log_sta_call->box(FL_DOWN_BOX); inp_log_sta_call->color(FL_BACKGROUND2_COLOR); inp_log_sta_call->selection_color(FL_SELECTION_COLOR); inp_log_sta_call->labeltype(FL_NORMAL_LABEL); inp_log_sta_call->labelfont(0); inp_log_sta_call->labelsize(14); inp_log_sta_call->labelcolor(FL_FOREGROUND_COLOR); inp_log_sta_call->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inp_log_sta_call->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_log_sta_call { inp_log_op_call = new Fl_Input2(140, 192, 100, 24, _("Operator Call")); inp_log_op_call->tooltip(_("Interesting notes")); inp_log_op_call->box(FL_DOWN_BOX); inp_log_op_call->color(FL_BACKGROUND2_COLOR); inp_log_op_call->selection_color(FL_SELECTION_COLOR); inp_log_op_call->labeltype(FL_NORMAL_LABEL); inp_log_op_call->labelfont(0); inp_log_op_call->labelsize(14); inp_log_op_call->labelcolor(FL_FOREGROUND_COLOR); inp_log_op_call->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inp_log_op_call->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_log_op_call { inp_log_sta_qth = new Fl_Input2(15, 236, 334, 24, _("Station QTH")); inp_log_sta_qth->tooltip(_("Interesting notes")); inp_log_sta_qth->box(FL_DOWN_BOX); inp_log_sta_qth->color(FL_BACKGROUND2_COLOR); inp_log_sta_qth->selection_color(FL_SELECTION_COLOR); inp_log_sta_qth->labeltype(FL_NORMAL_LABEL); inp_log_sta_qth->labelfont(0); inp_log_sta_qth->labelsize(14); inp_log_sta_qth->labelcolor(FL_FOREGROUND_COLOR); inp_log_sta_qth->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inp_log_sta_qth->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_log_sta_qth { inp_log_sta_loc = new Fl_Input2(355, 236, 120, 24, _("Station Locator")); inp_log_sta_loc->tooltip(_("Interesting notes")); inp_log_sta_loc->box(FL_DOWN_BOX); inp_log_sta_loc->color(FL_BACKGROUND2_COLOR); inp_log_sta_loc->selection_color(FL_SELECTION_COLOR); inp_log_sta_loc->labeltype(FL_NORMAL_LABEL); inp_log_sta_loc->labelfont(0); inp_log_sta_loc->labelsize(14); inp_log_sta_loc->labelcolor(FL_FOREGROUND_COLOR); inp_log_sta_loc->align(Fl_Align(FL_ALIGN_TOP_LEFT)); inp_log_sta_loc->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_log_sta_loc tab_log_my_station->end(); } // Fl_Group* tab_log_my_station { tab_log_contest = new Fl_Group(0, 161, 480, 99, _("Contest")); tab_log_contest->hide(); { inpSerNoOut_log = new Fl_Input2(69, 179, 55, 24, _("Ser out")); inpSerNoOut_log->tooltip(_("Contest seral # sent")); inpSerNoOut_log->box(FL_DOWN_BOX); inpSerNoOut_log->color(FL_BACKGROUND2_COLOR); inpSerNoOut_log->selection_color(FL_SELECTION_COLOR); inpSerNoOut_log->labeltype(FL_NORMAL_LABEL); inpSerNoOut_log->labelfont(0); inpSerNoOut_log->labelsize(14); inpSerNoOut_log->labelcolor(FL_FOREGROUND_COLOR); inpSerNoOut_log->align(Fl_Align(FL_ALIGN_LEFT)); inpSerNoOut_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpSerNoOut_log { inpMyXchg_log = new Fl_Input2(204, 179, 170, 24, _("Exch Out")); inpMyXchg_log->tooltip(_("Contest exchange sent")); inpMyXchg_log->box(FL_DOWN_BOX); inpMyXchg_log->color(FL_BACKGROUND2_COLOR); inpMyXchg_log->selection_color(FL_SELECTION_COLOR); inpMyXchg_log->labeltype(FL_NORMAL_LABEL); inpMyXchg_log->labelfont(0); inpMyXchg_log->labelsize(14); inpMyXchg_log->labelcolor(FL_FOREGROUND_COLOR); inpMyXchg_log->align(Fl_Align(FL_ALIGN_LEFT)); inpMyXchg_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpMyXchg_log { inpSerNoIn_log = new Fl_Input2(69, 207, 55, 24, _("Ser in")); inpSerNoIn_log->tooltip(_("Contest serial # received")); inpSerNoIn_log->box(FL_DOWN_BOX); inpSerNoIn_log->color(FL_BACKGROUND2_COLOR); inpSerNoIn_log->selection_color(FL_SELECTION_COLOR); inpSerNoIn_log->labeltype(FL_NORMAL_LABEL); inpSerNoIn_log->labelfont(0); inpSerNoIn_log->labelsize(14); inpSerNoIn_log->labelcolor(FL_FOREGROUND_COLOR); inpSerNoIn_log->align(Fl_Align(FL_ALIGN_LEFT)); inpSerNoIn_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpSerNoIn_log { inpXchgIn_log = new Fl_Input2(204, 207, 170, 24, _("Exch In")); inpXchgIn_log->tooltip(_("Contest exchange received")); inpXchgIn_log->box(FL_DOWN_BOX); inpXchgIn_log->color(FL_BACKGROUND2_COLOR); inpXchgIn_log->selection_color(FL_SELECTION_COLOR); inpXchgIn_log->labeltype(FL_NORMAL_LABEL); inpXchgIn_log->labelfont(0); inpXchgIn_log->labelsize(14); inpXchgIn_log->labelcolor(FL_FOREGROUND_COLOR); inpXchgIn_log->align(Fl_Align(FL_ALIGN_LEFT)); inpXchgIn_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpXchgIn_log { inpClass_log = new Fl_Input2(69, 236, 55, 24, _("Class")); inpClass_log->tooltip(_("Field Day class received")); inpClass_log->box(FL_DOWN_BOX); inpClass_log->color(FL_BACKGROUND2_COLOR); inpClass_log->selection_color(FL_SELECTION_COLOR); inpClass_log->labeltype(FL_NORMAL_LABEL); inpClass_log->labelfont(0); inpClass_log->labelsize(14); inpClass_log->labelcolor(FL_FOREGROUND_COLOR); inpClass_log->align(Fl_Align(FL_ALIGN_LEFT)); inpClass_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpClass_log { inpSection_log = new Fl_Input2(204, 236, 56, 24, _("ARRL Sect")); inpSection_log->tooltip(_("Field Section received")); inpSection_log->box(FL_DOWN_BOX); inpSection_log->color(FL_BACKGROUND2_COLOR); inpSection_log->selection_color(FL_SELECTION_COLOR); inpSection_log->labeltype(FL_NORMAL_LABEL); inpSection_log->labelfont(0); inpSection_log->labelsize(14); inpSection_log->labelcolor(FL_FOREGROUND_COLOR); inpSection_log->align(Fl_Align(FL_ALIGN_LEFT)); inpSection_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpSection_log { inp_age_log = new Fl_Input2(420, 179, 60, 24, _("Age")); inp_age_log->tooltip(_("Operators age received")); inp_age_log->box(FL_DOWN_BOX); inp_age_log->color(FL_BACKGROUND2_COLOR); inp_age_log->selection_color(FL_SELECTION_COLOR); inp_age_log->labeltype(FL_NORMAL_LABEL); inp_age_log->labelfont(0); inp_age_log->labelsize(14); inp_age_log->labelcolor(FL_FOREGROUND_COLOR); inp_age_log->align(Fl_Align(FL_ALIGN_LEFT)); inp_age_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_age_log { inp_1010_log = new Fl_Input2(420, 207, 60, 24, _("10-10")); inp_1010_log->tooltip(_("Ten Ten number received")); inp_1010_log->box(FL_DOWN_BOX); inp_1010_log->color(FL_BACKGROUND2_COLOR); inp_1010_log->selection_color(FL_SELECTION_COLOR); inp_1010_log->labeltype(FL_NORMAL_LABEL); inp_1010_log->labelfont(0); inp_1010_log->labelsize(14); inp_1010_log->labelcolor(FL_FOREGROUND_COLOR); inp_1010_log->align(Fl_Align(FL_ALIGN_LEFT)); inp_1010_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_1010_log { inpBand_log = new Fl_Input2(420, 236, 60, 24, _("Band")); inpBand_log->tooltip(_("Operating band")); inpBand_log->box(FL_DOWN_BOX); inpBand_log->color(FL_BACKGROUND2_COLOR); inpBand_log->selection_color(FL_SELECTION_COLOR); inpBand_log->labeltype(FL_NORMAL_LABEL); inpBand_log->labelfont(0); inpBand_log->labelsize(14); inpBand_log->labelcolor(FL_FOREGROUND_COLOR); inpBand_log->align(Fl_Align(FL_ALIGN_LEFT)); inpBand_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inpBand_log { inp_check_log = new Fl_Input2(314, 236, 60, 24, _("Check")); inp_check_log->tooltip(_("Check value received")); inp_check_log->box(FL_DOWN_BOX); inp_check_log->color(FL_BACKGROUND2_COLOR); inp_check_log->selection_color(FL_SELECTION_COLOR); inp_check_log->labeltype(FL_NORMAL_LABEL); inp_check_log->labelfont(0); inp_check_log->labelsize(14); inp_check_log->labelcolor(FL_FOREGROUND_COLOR); inp_check_log->align(Fl_Align(FL_ALIGN_LEFT)); inp_check_log->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_check_log tab_log_contest->end(); } // Fl_Group* tab_log_contest { tab_log_cwss = new Fl_Group(0, 161, 475, 96, _("CW SS")); tab_log_cwss->tooltip(_("CW Sweepstakes Contest")); tab_log_cwss->hide(); { inp_log_cwss_serno = new Fl_Input2(77, 179, 55, 24, _("Ser NoR")); inp_log_cwss_serno->tooltip(_("Contest seral # sent")); inp_log_cwss_serno->box(FL_DOWN_BOX); inp_log_cwss_serno->color(FL_BACKGROUND2_COLOR); inp_log_cwss_serno->selection_color(FL_SELECTION_COLOR); inp_log_cwss_serno->labeltype(FL_NORMAL_LABEL); inp_log_cwss_serno->labelfont(0); inp_log_cwss_serno->labelsize(14); inp_log_cwss_serno->labelcolor(FL_FOREGROUND_COLOR); inp_log_cwss_serno->align(Fl_Align(FL_ALIGN_LEFT)); inp_log_cwss_serno->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_log_cwss_serno { inp_log_cwss_sec = new Fl_Input2(77, 207, 56, 24, _("Section")); inp_log_cwss_sec->tooltip(_("SS section")); inp_log_cwss_sec->box(FL_DOWN_BOX); inp_log_cwss_sec->color(FL_BACKGROUND2_COLOR); inp_log_cwss_sec->selection_color(FL_SELECTION_COLOR); inp_log_cwss_sec->labeltype(FL_NORMAL_LABEL); inp_log_cwss_sec->labelfont(0); inp_log_cwss_sec->labelsize(14); inp_log_cwss_sec->labelcolor(FL_FOREGROUND_COLOR); inp_log_cwss_sec->align(Fl_Align(FL_ALIGN_LEFT)); inp_log_cwss_sec->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_log_cwss_sec { inp_log_cwss_prec = new Fl_Input2(238, 179, 77, 24, _("Precedence")); inp_log_cwss_prec->tooltip(_("Contest exchange sent")); inp_log_cwss_prec->box(FL_DOWN_BOX); inp_log_cwss_prec->color(FL_BACKGROUND2_COLOR); inp_log_cwss_prec->selection_color(FL_SELECTION_COLOR); inp_log_cwss_prec->labeltype(FL_NORMAL_LABEL); inp_log_cwss_prec->labelfont(0); inp_log_cwss_prec->labelsize(14); inp_log_cwss_prec->labelcolor(FL_FOREGROUND_COLOR); inp_log_cwss_prec->align(Fl_Align(FL_ALIGN_LEFT)); inp_log_cwss_prec->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_log_cwss_prec { inp_log_cwss_chk = new Fl_Input2(238, 207, 77, 24, _("Check")); inp_log_cwss_chk->tooltip(_("Contest exchange received")); inp_log_cwss_chk->box(FL_DOWN_BOX); inp_log_cwss_chk->color(FL_BACKGROUND2_COLOR); inp_log_cwss_chk->selection_color(FL_SELECTION_COLOR); inp_log_cwss_chk->labeltype(FL_NORMAL_LABEL); inp_log_cwss_chk->labelfont(0); inp_log_cwss_chk->labelsize(14); inp_log_cwss_chk->labelcolor(FL_FOREGROUND_COLOR); inp_log_cwss_chk->align(Fl_Align(FL_ALIGN_LEFT)); inp_log_cwss_chk->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_log_cwss_chk tab_log_cwss->end(); } // Fl_Group* tab_log_cwss { tab_log_jota = new Fl_Group(0, 161, 475, 96, _("JOTA")); tab_log_jota->tooltip(_("Jamboree On The Air")); tab_log_jota->hide(); { inp_log_troop_s = new Fl_Input2(115, 179, 100, 24, _("Troop-S")); inp_log_troop_s->tooltip(_("Sent troop number")); inp_log_troop_s->box(FL_DOWN_BOX); inp_log_troop_s->color(FL_BACKGROUND2_COLOR); inp_log_troop_s->selection_color(FL_SELECTION_COLOR); inp_log_troop_s->labeltype(FL_NORMAL_LABEL); inp_log_troop_s->labelfont(0); inp_log_troop_s->labelsize(14); inp_log_troop_s->labelcolor(FL_FOREGROUND_COLOR); inp_log_troop_s->align(Fl_Align(FL_ALIGN_LEFT)); inp_log_troop_s->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_log_troop_s { inp_log_troop_r = new Fl_Input2(292, 179, 100, 24, _("Troop-R")); inp_log_troop_r->tooltip(_("Received troop number")); inp_log_troop_r->box(FL_DOWN_BOX); inp_log_troop_r->color(FL_BACKGROUND2_COLOR); inp_log_troop_r->selection_color(FL_SELECTION_COLOR); inp_log_troop_r->labeltype(FL_NORMAL_LABEL); inp_log_troop_r->labelfont(0); inp_log_troop_r->labelsize(14); inp_log_troop_r->labelcolor(FL_FOREGROUND_COLOR); inp_log_troop_r->align(Fl_Align(FL_ALIGN_LEFT)); inp_log_troop_r->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_log_troop_r { inp_log_scout_s = new Fl_Input2(115, 215, 100, 24, _("Name-S")); inp_log_scout_s->tooltip(_("Sent scout name")); inp_log_scout_s->box(FL_DOWN_BOX); inp_log_scout_s->color(FL_BACKGROUND2_COLOR); inp_log_scout_s->selection_color(FL_SELECTION_COLOR); inp_log_scout_s->labeltype(FL_NORMAL_LABEL); inp_log_scout_s->labelfont(0); inp_log_scout_s->labelsize(14); inp_log_scout_s->labelcolor(FL_FOREGROUND_COLOR); inp_log_scout_s->align(Fl_Align(FL_ALIGN_LEFT)); inp_log_scout_s->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_log_scout_s { inp_log_scout_r = new Fl_Input2(292, 215, 100, 24, _("Name-R")); inp_log_scout_r->tooltip(_("Received scout name")); inp_log_scout_r->box(FL_DOWN_BOX); inp_log_scout_r->color(FL_BACKGROUND2_COLOR); inp_log_scout_r->selection_color(FL_SELECTION_COLOR); inp_log_scout_r->labeltype(FL_NORMAL_LABEL); inp_log_scout_r->labelfont(0); inp_log_scout_r->labelsize(14); inp_log_scout_r->labelcolor(FL_FOREGROUND_COLOR); inp_log_scout_r->align(Fl_Align(FL_ALIGN_LEFT)); inp_log_scout_r->when(FL_WHEN_RELEASE); } // Fl_Input2* inp_log_scout_r tab_log_jota->end(); } // Fl_Group* tab_log_jota Tabs->end(); } // Fl_Tabs* Tabs { grpCallSearch = new Fl_Group(482, 137, 105, 125); { inpSearchString = new Fl_Input2(482, 160, 105, 24, _("Call Search")); inpSearchString->tooltip(_("Search for this callsign")); inpSearchString->box(FL_DOWN_BOX); inpSearchString->color(FL_BACKGROUND2_COLOR); inpSearchString->selection_color(FL_SELECTION_COLOR); inpSearchString->labeltype(FL_NORMAL_LABEL); inpSearchString->labelfont(0); inpSearchString->labelsize(14); inpSearchString->labelcolor(FL_FOREGROUND_COLOR); inpSearchString->align(Fl_Align(FL_ALIGN_TOP)); inpSearchString->when(FL_WHEN_RELEASE); } // Fl_Input2* inpSearchString { bSearchPrev = new Fl_Button(500, 193, 24, 22); bSearchPrev->tooltip(_("Find previous")); bSearchPrev->color(FL_LIGHT1); bSearchPrev->selection_color((Fl_Color)48); bSearchPrev->callback((Fl_Callback*)cb_search); bSearchPrev->align(Fl_Align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE)); bSearchPrev->image(new Fl_Pixmap(left_arrow_icon)); } // Fl_Button* bSearchPrev { bSearchNext = new Fl_Button(552, 193, 24, 22); bSearchNext->tooltip(_("Find next")); bSearchNext->color(FL_LIGHT1); bSearchNext->selection_color((Fl_Color)48); bSearchNext->callback((Fl_Callback*)cb_search); bSearchNext->align(Fl_Align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE)); bSearchNext->image(new Fl_Pixmap(right_arrow_icon)); } // Fl_Button* bSearchNext { bRetrieve = new Fl_Button(500, 223, 75, 22, _("Retrieve")); bRetrieve->tooltip(_("Retrieve for active modem use")); bRetrieve->shortcut(0x50066); bRetrieve->color(FL_LIGHT1); bRetrieve->selection_color((Fl_Color)48); bRetrieve->callback((Fl_Callback*)cb_btnRetrieve); } // Fl_Button* bRetrieve grpCallSearch->end(); } // Fl_Group* grpCallSearch o->resizable(Tabs); grpTabsSearch->end(); } // Fl_Group* grpTabsSearch { Fl_Group* o = grpFileButtons = new Fl_Group(0, 262, 589, 25); { bNewSave = new Fl_Button(396, 263, 59, 22, _("New")); bNewSave->tooltip(_("New record / Save record")); bNewSave->shortcut(0x8004e); bNewSave->color(FL_LIGHT1); bNewSave->selection_color((Fl_Color)48); bNewSave->callback((Fl_Callback*)cb_btnNewSave); } // Fl_Button* bNewSave { bUpdateCancel = new Fl_Button(459, 263, 59, 22, _("Update")); bUpdateCancel->tooltip(_("Update the current record")); bUpdateCancel->shortcut(0x80055); bUpdateCancel->color(FL_LIGHT1); bUpdateCancel->selection_color((Fl_Color)48); bUpdateCancel->callback((Fl_Callback*)cb_btnUpdateCancel); } // Fl_Button* bUpdateCancel { bDelete = new Fl_Button(522, 263, 59, 22, _("Delete")); bDelete->tooltip(_("Delete the current record")); bDelete->shortcut(0x80044); bDelete->color(FL_LIGHT1); bDelete->selection_color((Fl_Color)48); bDelete->callback((Fl_Callback*)cb_btnDelete); } // Fl_Button* bDelete { txtLogFile = new Fl_Output(35, 263, 357, 22, _("File:")); txtLogFile->color(FL_LIGHT3); } // Fl_Output* txtLogFile o->resizable(txtLogFile); grpFileButtons->end(); } // Fl_Group* grpFileButtons { wBrowser = new Table(2, 288, 586, 100); wBrowser->box(FL_DOWN_FRAME); wBrowser->color(FL_BACKGROUND2_COLOR); wBrowser->selection_color(FL_SELECTION_COLOR); wBrowser->labeltype(FL_NORMAL_LABEL); wBrowser->labelfont(0); wBrowser->labelsize(14); wBrowser->labelcolor(FL_FOREGROUND_COLOR); wBrowser->align(Fl_Align(FL_ALIGN_TOP)); wBrowser->when(FL_WHEN_RELEASE); wBrowser->end(); Fl_Group::current()->resizable(wBrowser); } // Table* wBrowser o->resizable(wBrowser); dlgLogbook->end(); } // Fl_Double_Window* dlgLogbook wBrowser->align (FL_ALIGN_TOP | FL_ALIGN_LEFT); wBrowser->addColumn (_("Date"),85); wBrowser->colcallback (0,cb_SortByDate); wBrowser->addColumn (_("Time"),47); wBrowser->addColumn (_("Callsign"),100); wBrowser->colcallback (2,cb_SortByCall); wBrowser->addColumn (_("Name"),110); wBrowser->addColumn (_("Frequency"),120); wBrowser->colcallback (4,cb_SortByFreq); wBrowser->addColumn (_("Mode"),103); wBrowser->colcallback (5,cb_SortByMode); wBrowser->addHiddenColumn ("rn"); wBrowser->allowSort(true); wBrowser->callback(cb_browser); wBrowser->when(FL_WHEN_CHANGED); wBrowser->rowSize (FL_NORMAL_SIZE); wBrowser->headerSize (FL_NORMAL_SIZE); wBrowser->allowResize (1); wBrowser->gridEnabled (0); dlgLogbook->xclass(PACKAGE_TARNAME); { wCabrillo = new Fl_Double_Window(675, 340, _("Cabrillo Setup")); { Fl_Group* o = new Fl_Group(4, 4, 388, 305, _("Select Records to Export")); o->box(FL_ENGRAVED_FRAME); o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE)); { chkCabBrowser = new Fl_Check_Browser(13, 25, 370, 245); } // Fl_Check_Browser* chkCabBrowser { btnCabClearAll = new Fl_Button(69, 277, 110, 24, _("Clear All")); btnCabClearAll->callback((Fl_Callback*)cb_btnCabClearAll); } // Fl_Button* btnCabClearAll { btnCabCheckAll = new Fl_Button(200, 277, 110, 24, _("Check All")); btnCabCheckAll->callback((Fl_Callback*)cb_btnCabCheckAll); } // Fl_Button* btnCabCheckAll o->end(); } // Fl_Group* o { btnCabOK = new Fl_Return_Button(544, 312, 100, 24, _("OK")); btnCabOK->callback((Fl_Callback*)cb_btnCabOK); } // Fl_Return_Button* btnCabOK { btnCabCancel = new Fl_Button(414, 312, 100, 24, _("Cancel")); btnCabCancel->callback((Fl_Callback*)cb_btnCabCancel); } // Fl_Button* btnCabCancel { Fl_Group* o = new Fl_Group(390, 4, 283, 305, _("Select Cabrillo Contest & Fields")); o->box(FL_ENGRAVED_FRAME); o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE)); { cboContest = new Fl_ComboBox(486, 41, 180, 20, _("Contest:")); cboContest->box(FL_BORDER_BOX); cboContest->color(FL_BACKGROUND2_COLOR); cboContest->selection_color(FL_BACKGROUND_COLOR); cboContest->labeltype(FL_NORMAL_LABEL); cboContest->labelfont(0); cboContest->labelsize(14); cboContest->labelcolor(FL_FOREGROUND_COLOR); cboContest->callback((Fl_Callback*)cb_cboContest); cboContest->align(Fl_Align(FL_ALIGN_LEFT)); cboContest->when(FL_WHEN_RELEASE); cboContest->end(); } // Fl_ComboBox* cboContest { btnCabCall = new Fl_Check_Button(423, 75, 70, 16, _("Call")); btnCabCall->down_box(FL_DOWN_BOX); btnCabCall->value(1); } // Fl_Check_Button* btnCabCall { btnCabFreq = new Fl_Check_Button(423, 100, 70, 15, _("Freq")); btnCabFreq->down_box(FL_DOWN_BOX); btnCabFreq->value(1); } // Fl_Check_Button* btnCabFreq { btnCabMode = new Fl_Check_Button(423, 124, 70, 15, _("Mode")); btnCabMode->down_box(FL_DOWN_BOX); btnCabMode->value(1); } // Fl_Check_Button* btnCabMode { btnCabQSOdate = new Fl_Check_Button(423, 148, 70, 15, _("QSO Date")); btnCabQSOdate->down_box(FL_DOWN_BOX); btnCabQSOdate->value(1); } // Fl_Check_Button* btnCabQSOdate { btnCabTimeOFF = new Fl_Check_Button(423, 172, 70, 15, _("Time OFF")); btnCabTimeOFF->down_box(FL_DOWN_BOX); btnCabTimeOFF->value(1); } // Fl_Check_Button* btnCabTimeOFF { btnCabRSTsent = new Fl_Check_Button(423, 196, 70, 15, _("RST sent")); btnCabRSTsent->down_box(FL_DOWN_BOX); btnCabRSTsent->value(1); } // Fl_Check_Button* btnCabRSTsent { btnCabRSTrcvd = new Fl_Check_Button(423, 221, 70, 16, _("RST rcvd")); btnCabRSTrcvd->down_box(FL_DOWN_BOX); btnCabRSTrcvd->value(1); } // Fl_Check_Button* btnCabRSTrcvd { btnCabSerialIN = new Fl_Check_Button(533, 100, 70, 15, _("Serial # in")); btnCabSerialIN->down_box(FL_DOWN_BOX); btnCabSerialIN->value(1); } // Fl_Check_Button* btnCabSerialIN { btnCabSerialOUT = new Fl_Check_Button(533, 124, 70, 15, _("Serial # out")); btnCabSerialOUT->down_box(FL_DOWN_BOX); btnCabSerialOUT->value(1); } // Fl_Check_Button* btnCabSerialOUT { btnCabXchgIn = new Fl_Check_Button(533, 148, 70, 15, _("Exchange In")); btnCabXchgIn->down_box(FL_DOWN_BOX); btnCabXchgIn->value(1); } // Fl_Check_Button* btnCabXchgIn { btnCabMyXchg = new Fl_Check_Button(533, 172, 70, 15, _("Exchange Out")); btnCabMyXchg->down_box(FL_DOWN_BOX); btnCabMyXchg->value(1); } // Fl_Check_Button* btnCabMyXchg { btnCabState = new Fl_Check_Button(533, 196, 70, 15, _("State")); btnCabState->down_box(FL_DOWN_BOX); btnCabState->value(1); } // Fl_Check_Button* btnCabState { btnCabCounty = new Fl_Check_Button(533, 221, 70, 15, _("County")); btnCabCounty->down_box(FL_DOWN_BOX); btnCabCounty->value(1); } // Fl_Check_Button* btnCabCounty { btnCabClearAllFields = new Fl_Button(409, 277, 110, 24, _("Clear All")); btnCabClearAllFields->callback((Fl_Callback*)cb_btnCabClearAllFields); } // Fl_Button* btnCabClearAllFields { btnCabCheckAllFields = new Fl_Button(539, 277, 110, 24, _("Check All")); btnCabCheckAllFields->callback((Fl_Callback*)cb_btnCabCheckAllFields); } // Fl_Button* btnCabCheckAllFields o->end(); } // Fl_Group* o wCabrillo->end(); } // Fl_Double_Window* wCabrillo }
73,343
C++
.cxx
1,543
40.241737
104
0.646359
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,238
textio.cxx
w1hkj_fldigi/src/logbook/textio.cxx
// ---------------------------------------------------------------------------- // textio.cxx // // Copyright (C) 2006-2010 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <string> #include <cstdio> #include <cstring> #include "textio.h" #include "lgbook.h" #include "globals.h" #ifdef __WOE32__ static const char *szEOL = "\r\n"; #else static const char *szEOL = "\n"; #endif char * cTextFile::adif_to_date( char *s) { static char date[9]; strcpy(date, " / / "); for (int i = 0; i < 2; i++) { date[i+6] = s[i+2]; date[i] = s[i+4]; date[i+3] = s[i+6]; } return date; } char * cTextFile::adif_to_time( char *s) { static char time[6]; strcpy(time, " : "); for (int i = 0; i < 2; i++) { time[i] = s[i]; time[i+3] = s[i+2]; } return time; } void cTextFile::writeCSVHeader(FILE *txtFile) { if (btnSelectQSOdateOn->value()) fprintf (txtFile, "%s", "\"DATE_ON\""); if (btnSelectQSOdateOff->value())fprintf (txtFile, "%s", ",\"DATE_OFF\""); if (btnSelectTimeON->value()) fprintf (txtFile, "%s", ",\"ON\""); if (btnSelectTimeOFF->value()) fprintf (txtFile, "%s", ",\"OFF\""); if (btnSelectCall->value()) fprintf (txtFile, "%s", ",\"CALL\""); if (btnSelectName->value()) fprintf (txtFile, "%s", ",\"NAME\""); if (btnSelectBand->value()) fprintf (txtFile, "%s", ",\"BAND\""); if (btnSelectFreq->value()) fprintf (txtFile, "%s", ",\"FREQ\""); if (btnSelectMode->value()) fprintf (txtFile, "%s", ",\"MODE\""); if (btnSelectTX_pwr->value()) fprintf (txtFile, "%s", ",\"TX_PWR\""); if (btnSelectRSTsent->value()) fprintf (txtFile, "%s", ",\"RSTSENT\""); if (btnSelectRSTrcvd->value()) fprintf (txtFile, "%s", ",\"RSTRCVD\""); if (btnSelectQth->value()) fprintf (txtFile, "%s", ",\"QTH\""); if (btnSelectState->value()) fprintf (txtFile, "%s", ",\"ST\""); if (btnSelectProvince->value()) fprintf (txtFile, "%s", ",\"PR\""); if (btnSelectCNTY->value()) fprintf (txtFile, "%s", ",\"CNTY\""); if (btnSelectCountry->value()) fprintf (txtFile, "%s", ",\"CNTRY\""); if (btnSelectDXCC->value()) fprintf (txtFile, "%s", ",\"DXCC\""); if (btnSelectCQZ->value()) fprintf (txtFile, "%s", ",\"CQZONE\""); if (btnSelectIOTA->value()) fprintf (txtFile, "%s", ",\"IOTA\""); if (btnSelectCONT->value()) fprintf (txtFile, "%s", ",\"CONT\""); if (btnSelectITUZ->value()) fprintf (txtFile, "%s", ",\"ITUZ\""); if (btnSelectLOC->value()) fprintf (txtFile, "%s", ",\"GRIDSQUARE\""); if (btnSelectQSLrcvd->value()) fprintf (txtFile, "%s", ",\"QSL_RCVD\""); if (btnSelectQSLsent->value()) fprintf (txtFile, "%s", ",\"QSL_SENT\""); if (btnSelecteQSLrcvd->value()) fprintf (txtFile, "%s", ",\"EQSL_RCVD\""); if (btnSelecteQSLsent->value()) fprintf (txtFile, "%s", ",\"EQSL_SENT\""); if (btnSelectLOTWrcvd->value()) fprintf (txtFile, "%s", ",\"LOTW_RCVD\""); if (btnSelectLOTWsent->value()) fprintf (txtFile, "%s", ",\"LOTW_SENT\""); if (btnSelectNotes->value()) fprintf (txtFile, "%s", ",\"NOTES\""); if (btnSelectSerialIN->value()) fprintf (txtFile, "%s", ",\"SERIAL RCVD\""); if (btnSelectSerialOUT->value()) fprintf (txtFile, "%s", ",\"SERIAL_SENT\""); if (btnSelectXchgIn->value()) fprintf (txtFile, "%s", ",\"XCHG1\""); if (btnSelectMyXchg->value()) fprintf (txtFile, "%s", ",\"MYXCHG\""); if (btnSelectClass->value()) fprintf (txtFile, "%s", ",\"CLASS\""); if (btnSelectSection->value()) fprintf (txtFile, "%s", ",\"ARRl_SECT\""); if (btnSelectOperator->value()) fprintf (txtFile, "%s", ",\"OPER\""); if (btnSelectStaCall->value()) fprintf (txtFile, "%s", ",\"STA_CALL\""); if (btnSelectStaGrid->value()) fprintf (txtFile, "%s", ",\"STA_GRID\""); if (btnSelectStaCity->value()) fprintf (txtFile, "%s", ",\"STA_CITY\""); if (btnSelectCheck->value()) fprintf (txtFile, "%s", ",\"CHECK\""); if (btnSelectAge->value()) fprintf (txtFile, "%s", ",\"AGE\""); if (btnSelect_1010->value()) fprintf (txtFile, "%s", ",\"10-10\""); fprintf (txtFile, "%s", szEOL); } int cTextFile::writeCSVFile (const char *fname, cQsoDb *db) { cQsoRec *pRec = (cQsoRec *)0; FILE *txtFile = fl_fopen (fname, "w"); if (!txtFile) return 1; if (txtFile) { writeCSVHeader(txtFile); for (int i = 0; i < db->nbrRecs(); i++) { pRec = db->getRec(i); if (pRec->getField(EXPORT)[0] == 'E') { if (btnSelectQSOdateOn->value()) fprintf (txtFile, "\"%s\"", pRec->getField(QSO_DATE)); if (btnSelectQSOdateOff->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(QSO_DATE_OFF)); if (btnSelectTimeON->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(TIME_ON)); if (btnSelectTimeOFF->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(TIME_OFF)); if (btnSelectCall->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(CALL)); if (btnSelectName->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(NAME)); if (btnSelectBand->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(BAND)); if (btnSelectFreq->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(FREQ)); if (btnSelectMode->value()) { if (!adif2submode(pRec->getField(ADIF_MODE)).empty()) fprintf (txtFile, ",\"%s\"", adif2submode(pRec->getField(ADIF_MODE)).c_str()); else fprintf (txtFile, ",\"%s\"", adif2export(pRec->getField(ADIF_MODE)).c_str()); } if (btnSelectTX_pwr->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(TX_PWR)); if (btnSelectRSTsent->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(RST_SENT)); if (btnSelectRSTrcvd->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(RST_RCVD)); if (btnSelectQth->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(QTH)); if (btnSelectState->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(STATE)); if (btnSelectProvince->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(VE_PROV)); if (btnSelectCNTY->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(CNTY)); if (btnSelectCountry->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(COUNTRY)); if (btnSelectDXCC->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(DXCC)); if (btnSelectCQZ->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(CQZ)); if (btnSelectIOTA->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(IOTA)); if (btnSelectCONT->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(CONT)); if (btnSelectITUZ->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(ITUZ)); if (btnSelectLOC->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(GRIDSQUARE)); if (btnSelectQSLrcvd->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(QSLRDATE)); if (btnSelectQSLsent->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(QSLSDATE)); if (btnSelecteQSLrcvd->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(EQSLRDATE)); if (btnSelecteQSLsent->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(EQSLSDATE)); if (btnSelectLOTWrcvd->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(LOTWSDATE)); if (btnSelectLOTWsent->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(LOTWSDATE)); if (btnSelectNotes->value()) { std::string temp = pRec->getField(NOTES); for (size_t n = 0; n < temp.length(); n++) if (temp[n] == '\r' || temp[n] == '\n') temp[n] = '-'; fprintf (txtFile, ",\"%s\"", temp.c_str()); } if (btnSelectSerialIN->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(SRX)); if (btnSelectSerialOUT->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(STX)); if (btnSelectXchgIn->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(XCHG1)); if (btnSelectMyXchg->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(MYXCHG)); if (btnSelectClass->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(CLASS)); if (btnSelectSection->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(ARRL_SECT)); if (btnSelectOperator->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(OP_CALL)); if (btnSelectStaCall->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(STA_CALL)); if (btnSelectStaGrid->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(MY_GRID)); if (btnSelectStaCity->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(MY_CITY)); if (btnSelectCheck->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(CHECK)); if (btnSelectAge->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(AGE)); if (btnSelect_1010->value()) fprintf (txtFile, ",\"%s\"", pRec->getField(TEN_TEN)); fprintf (txtFile, "%s", szEOL); pRec->putField(EXPORT,""); db->qsoUpdRec(i, pRec); } } fclose (txtFile); } return 0; } // text file in fixed fields void cTextFile::writeTXTHeader(FILE *txtFile) { if (btnSelectQSOdateOn->value()) fprintf (txtFile, "%-10s", "DATE_ON"); if (btnSelectQSOdateOff->value())fprintf (txtFile, "%-10s", "DATE_OFF"); if (btnSelectTimeON->value()) fprintf (txtFile, "%-8s", "ON"); if (btnSelectTimeOFF->value()) fprintf (txtFile, "%-8s", "OFF"); if (btnSelectCall->value()) fprintf (txtFile, "%-10s", "CALL"); if (btnSelectName->value()) fprintf (txtFile, "%-15s", "NAME"); if (btnSelectBand->value()) fprintf (txtFile, "%-7s", "BAND"); if (btnSelectFreq->value()) fprintf (txtFile, "%-12s", "FREQ"); if (btnSelectMode->value()) fprintf (txtFile, "%-8s", "MODE"); if (btnSelectTX_pwr->value()) fprintf (txtFile, "%-8s", "TX_PWR"); if (btnSelectRSTsent->value()) fprintf (txtFile, "%-6s", "RSTX"); if (btnSelectRSTrcvd->value()) fprintf (txtFile, "%-6s", "RSTR"); if (btnSelectQth->value()) fprintf (txtFile, "%-20s", "QTH"); if (btnSelectState->value()) fprintf (txtFile, "%-5s", "ST"); if (btnSelectProvince->value()) fprintf (txtFile, "%-5s", "PR"); if (btnSelectCountry->value()) fprintf (txtFile, "%-15s", "CNTRY"); if (btnSelectCNTY->value()) fprintf (txtFile, "%-8s", "CNTY"); if (btnSelectDXCC->value()) fprintf (txtFile, "%-8s", "DXCC"); if (btnSelectCQZ->value()) fprintf (txtFile, "%-8s", "CQZONE"); if (btnSelectIOTA->value()) fprintf (txtFile, "%-8s", "IOTA"); if (btnSelectCONT->value()) fprintf (txtFile, "%-8s", "CONT"); if (btnSelectITUZ->value()) fprintf (txtFile, "%-8s", "ITUZ"); if (btnSelectLOC->value()) fprintf (txtFile, "%-15s", "GRIDSQUARE"); if (btnSelectQSLrcvd->value()) fprintf (txtFile, "%-10s", "QSLR"); if (btnSelectQSLsent->value()) fprintf (txtFile, "%-10s", "QSLS"); if (btnSelecteQSLrcvd->value()) fprintf (txtFile, "%-10s", "EQSLR"); if (btnSelecteQSLsent->value()) fprintf (txtFile, "%-10s", "EQSLS"); if (btnSelectLOTWrcvd->value()) fprintf (txtFile, "%-10s", "LOTWR"); if (btnSelectLOTWsent->value()) fprintf (txtFile, "%-10s", "LOTWS"); if (btnSelectNotes->value()) fprintf (txtFile, "%-80s", "NOTES"); if (btnSelectSerialIN->value()) fprintf (txtFile, "%-7s", "SRX"); if (btnSelectSerialOUT->value()) fprintf (txtFile, "%-7s", "STX"); if (btnSelectXchgIn->value()) fprintf (txtFile, "%-15s", "XCHG1"); if (btnSelectMyXchg->value()) fprintf (txtFile, "%-15s", "MYXCHG"); if (btnSelectClass->value()) fprintf (txtFile, "%-15s", "CLASS"); if (btnSelectSection->value()) fprintf (txtFile, "%-15s", "ARRL_SECT"); if (btnSelectOperator->value()) fprintf (txtFile, "%-15s", "OPER"); if (btnSelectStaCall->value()) fprintf (txtFile, "%-15s", "STA_CALL"); if (btnSelectStaGrid->value()) fprintf (txtFile, "%-15s", "STA_GRID"); if (btnSelectStaCity->value()) fprintf (txtFile, "%-15s", "STA_CITY"); if (btnSelectCheck->value()) fprintf (txtFile, "%-15s", "CHECK"); if (btnSelectAge->value()) fprintf (txtFile, "%-15s", "AGE"); if (btnSelect_1010->value()) fprintf (txtFile, "%-15s", "10-10"); fprintf (txtFile, "%s", szEOL); } int cTextFile::writeTXTFile (const char *fname, cQsoDb *db) { cQsoRec *pRec = (cQsoRec *)0; FILE *txtFile = fl_fopen (fname, "w"); if (!txtFile) return 1; if (txtFile) { writeTXTHeader(txtFile); for (int i = 0; i < db->nbrRecs(); i++) { pRec = db->getRec(i); if (pRec->getField(EXPORT)[0] == 'E') { if (btnSelectQSOdateOn->value()) fprintf (txtFile, "%-10s", pRec->getField(QSO_DATE)); if (btnSelectQSOdateOff->value()) fprintf (txtFile, "%-10s", pRec->getField(QSO_DATE_OFF)); if (btnSelectTimeON->value()) fprintf (txtFile, "%-8s", pRec->getField(TIME_ON)); if (btnSelectTimeOFF->value()) fprintf (txtFile, "%-8s", pRec->getField(TIME_OFF)); if (btnSelectCall->value()) fprintf (txtFile, "%-10s", pRec->getField(CALL)); if (btnSelectName->value()) fprintf (txtFile, "%-15s", pRec->getField(NAME)); if (btnSelectBand->value()) fprintf (txtFile, "%-7s", pRec->getField(BAND)); if (btnSelectFreq->value()) fprintf (txtFile, "%-12s", pRec->getField(FREQ)); if (btnSelectMode->value()) { if (!adif2submode(pRec->getField(ADIF_MODE)).empty()) fprintf (txtFile, "%-12s", adif2submode(pRec->getField(ADIF_MODE)).c_str()); else fprintf (txtFile, "%-12s", adif2export(pRec->getField(ADIF_MODE)).c_str()); } if (btnSelectTX_pwr->value()) fprintf (txtFile, "%-8s", pRec->getField(TX_PWR)); if (btnSelectRSTsent->value()) fprintf (txtFile, "%-6s", pRec->getField(RST_SENT)); if (btnSelectRSTrcvd->value()) fprintf (txtFile, "%-6s", pRec->getField(RST_RCVD)); if (btnSelectQth->value()) fprintf (txtFile, "%-20s", pRec->getField(QTH)); if (btnSelectState->value()) fprintf (txtFile, "%-5s", pRec->getField(STATE)); if (btnSelectProvince->value()) fprintf (txtFile, "%-5s", pRec->getField(VE_PROV)); if (btnSelectCountry->value()) fprintf (txtFile, "%-15s", pRec->getField(COUNTRY)); if (btnSelectCNTY->value()) fprintf (txtFile, "%-8s", pRec->getField(CNTY)); if (btnSelectDXCC->value()) fprintf (txtFile, "%-8s", pRec->getField(DXCC)); if (btnSelectCQZ->value()) fprintf (txtFile, "%-8s", pRec->getField(CQZ)); if (btnSelectIOTA->value()) fprintf (txtFile, "%-8s", pRec->getField(IOTA)); if (btnSelectCONT->value()) fprintf (txtFile, "%-8s", pRec->getField(CONT)); if (btnSelectITUZ->value()) fprintf (txtFile, "%-8s", pRec->getField(ITUZ)); if (btnSelectLOC->value()) fprintf (txtFile, "%-15s", pRec->getField(GRIDSQUARE)); if (btnSelectQSLrcvd->value()) fprintf (txtFile, "%-10s", pRec->getField(QSLRDATE)); if (btnSelectQSLsent->value()) fprintf (txtFile, "%-10s", pRec->getField(QSLSDATE)); if (btnSelecteQSLrcvd->value()) fprintf (txtFile, "%-10s", pRec->getField(EQSLRDATE)); if (btnSelecteQSLsent->value()) fprintf (txtFile, "%-10s", pRec->getField(EQSLSDATE)); if (btnSelectLOTWrcvd->value()) fprintf (txtFile, "%-10s", pRec->getField(LOTWRDATE)); if (btnSelectLOTWsent->value()) fprintf (txtFile, "%-10s", pRec->getField(LOTWSDATE)); if (btnSelectNotes->value()) { std::string temp = pRec->getField(NOTES); for (size_t n = 0; n < temp.length(); n++) if (temp[n] == '\n') temp[n] = ';'; fprintf (txtFile, "%-80s", temp.c_str()); } if (btnSelectSerialIN->value()) fprintf (txtFile, "%-7s", pRec->getField(SRX)); if (btnSelectSerialOUT->value()) fprintf (txtFile, "%-7s", pRec->getField(STX)); if (btnSelectXchgIn->value()) fprintf (txtFile, "%-15s", pRec->getField(XCHG1)); if (btnSelectMyXchg->value()) fprintf (txtFile, "%-15s", pRec->getField(MYXCHG)); if (btnSelectClass->value()) fprintf (txtFile, "%-15s", pRec->getField(CLASS)); if (btnSelectSection->value()) fprintf (txtFile, "%-15s", pRec->getField(ARRL_SECT)); if (btnSelectOperator->value()) fprintf (txtFile, "%-15s", pRec->getField(OP_CALL)); if (btnSelectStaCall->value()) fprintf (txtFile, "%-15s", pRec->getField(STA_CALL)); if (btnSelectStaGrid->value()) fprintf (txtFile, "%-15s", pRec->getField(MY_GRID)); if (btnSelectStaCity->value()) fprintf (txtFile, "%-15s", pRec->getField(MY_CITY)); if (btnSelectCheck->value()) fprintf (txtFile, "%-15s", pRec->getField(CHECK)); if (btnSelectAge->value()) fprintf (txtFile, "%-15s", pRec->getField(AGE)); if (btnSelect_1010->value()) fprintf (txtFile, "%-15s", pRec->getField(TEN_TEN)); fprintf (txtFile, "%s", szEOL); pRec->putField(EXPORT,""); db->qsoUpdRec(i, pRec); } } fclose (txtFile); } return 0; }
17,431
C++
.cxx
371
43.088949
84
0.607638
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,239
table.cxx
w1hkj_fldigi/src/logbook/table.cxx
/* Copyright (c) 2004 Markus Niemistö Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <config.h> #include <FL/Fl.H> #include <FL/fl_draw.H> #include <stdarg.h> #include <stdlib.h> #include <string.h> #include <string> #include "table.h" //#define DAMAGE_HEADER FL_DAMAGE_USER1 //#define DAMAGE_ROWS FL_DAMAGE_USER2 #define DAMAGE_HEADER FL_DAMAGE_ALL #define DAMAGE_ROWS FL_DAMAGE_ALL /* * nullptr is not available in gcc < 4.6 * Redefine to NULL for CentOS 6 and OSX Darwin */ #ifndef __FreeBSD__ #ifndef nullptr #define nullptr NULL #endif #endif /* * ====================================== * void Table.drawHeader(int x, int y); * ====================================== * * Draws header buttons starting at (x, y). */ void Table::drawHeader(int x, int y) { int w; struct ColumnInfo col; fl_font(tbl_font, tbl_fontsize); /* * Draw all header cells that aren't clipped. */ for (int i = leftCol; i <= rightCol; i++) { col = header[i]; if (col.hidden) continue; // Draw box if (pushed != i) fl_draw_box(FL_THIN_UP_BOX, x, y, w = col.width, headerHeight, FL_GRAY); else fl_draw_box(FL_THIN_DOWN_BOX, x, y, w = col.width, headerHeight, FL_GRAY); fl_color(FL_FOREGROUND_COLOR); // Draw labels if (col.title != NULL) fl_draw(col.title, x + 2, y - 1, w - 2, headerHeight, col.hdr_align); x += w; // Draw "the sort arrow", if any. if (sortColumn == i) { int mod = headerHeight - 10; if (ascent) fl_polygon(x - mod - 6, y + 5, x - mod / 2 - 6, y + mod + 5, x - 6, y + 5); else fl_polygon(x - mod - 6, y + mod + 5, x - mod / 2 - 6, y + 5, x - 6, y + mod + 5); } } } /* * ============================================================= * void Table.drawRow(int row, char *rowData[], int x, int y); * ============================================================= * * Draws all items in the row. Starts drawing from (x, y). */ void Table::drawRow(int row, char *rowData[], int x, int y) { int w; ColumnInfo col; fl_font(tbl_font, tbl_fontsize); // Draw background box. if (row != selected) { Fl_Color bg; if (!withGrid && row % 2 == 0) // different bg for consecutive rows bg = color(); else { bg = fl_color_average(color(), FL_BLACK, .9); if (fl_contrast(bg, FL_BLACK) == FL_WHITE) // widget has very dark text bg bg = fl_color_average(color(), FL_WHITE, .9); } fl_rectf(iX, y, tableWidth - hScroll->value(), rowHeight, bg); fl_color(FL_FOREGROUND_COLOR); } else { if (Fl::focus() == this) { fl_rectf(iX, y, tableWidth - hScroll->value(), rowHeight, selection_color()); fl_color(FL_FOREGROUND_COLOR); // Draw focus fl_line_style(FL_DOT); fl_rect(iX, y, tableWidth - hScroll->value(), rowHeight); fl_line_style(FL_SOLID); } else fl_rectf(iX, y, tableWidth - hScroll->value(), rowHeight, selection_color()); fl_color(fl_contrast(FL_FOREGROUND_COLOR, selection_color())); } // Get color from highlighter. Fl_Color color; if ((highlighter != NULL) && (highlighter(row, rowData, &color))) fl_color(color); const char *str; // Draw the data. for (int i = leftCol; i <= rightCol; i++) { w = (col = header[i]).width; if (col.hidden) continue; if (withGrid == true) { fl_color(FL_FOREGROUND_COLOR); fl_line_style(FL_SOLID); fl_rect(x,y,w,rowHeight); fl_color(FL_FOREGROUND_COLOR); } if ((str = rowData[i]) != NULL) fl_draw(str, x + 1, y - 1, w - 2, rowHeight + 1, col.align); x += w; } } /* * ======================================================= * Table.Table(int x, int y, int w, int h, char *label); * ======================================================= * * This is standard FLTK constructor. See FLTK documentation for * more information. */ Table::Table(int x, int y, int w, int h, char *label) : Fl_Group(x, y, w, h, label) { // Setup variables. align((Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP)); box(FL_THIN_DOWN_FRAME); color(FL_BACKGROUND2_COLOR, FL_SELECTION_COLOR); tbl_fontsize = 14; headerHeight = tbl_fontsize + 4; rowHeight = tbl_fontsize + 4; scrollbarSize = 16; // Create scrollbars. vScroll = new Fl_Scrollbar(x + w - scrollbarSize, y, scrollbarSize, h + scrollbarSize); vScroll->type(FL_VERTICAL); vScroll->linesize(3 * rowHeight); vScroll->callback(scrollCallback, (void*)this); vScroll->hide(); hScroll = new Fl_Scrollbar(x, y + h - scrollbarSize, w, scrollbarSize); hScroll->type(FL_HORIZONTAL); hScroll->callback(scrollCallback, (void*)this); hScroll->hide(); Fl_Group::end(); // Setup the rest of the variables to reasonable defaults. nCols = nRows = 0; cPos = 0; dragX = 0; resizing = -1; pushed = -1; curRow = NULL; highlighter = NULL; sortColumn = -1; selected = -1; canSort = true; canResize = true; ascent = false; noMoreColumns = false; dimensionsChanged = false; toBeSorted = false; headerEnabled = true; withGrid = false; popupMenu = NULL; menuAlloc = false; Vscroll = var; Hscroll = var; tbl_font = FL_HELVETICA; } /* * ================= * Table.~Table(); * ================= * * Destructor. */ Table::~Table() { delete vScroll; delete hScroll; menuClear(); clear(); } /* * ==================================== * bool Table.headerOn(); * void Table.headerOn(bool enabled); * ==================================== * * These methods get or set the value of variable controlling * whether header buttons are displayed. */ bool Table::headerOn() const { return headerEnabled; } void Table::headerOn(bool enabled) { headerEnabled = enabled; dimensionsChanged = true; redraw(); } /* * ==================================== * bool Table.gridEnabled(); * void Table.gridEnabled(bool enabled); * ==================================== * * These methods get or set the value of variable controlling * whether the table grid is displayed. */ bool Table::gridEnabled() const { return withGrid; } void Table::gridEnabled(bool enabled) { withGrid = enabled; dimensionsChanged = true; redraw(); } /* * ===================================== * bool Table.allowResize(); * void Table.allowResize(bool allow); * ===================================== * * These methods get or set the value of variable controlling * whether user may resize columns by dragging the column border. */ bool Table::allowResize() const { return canResize; } void Table::allowResize(bool allow) { canResize = allow; } /* * =================================== * bool Table.allowSort(); * void Table.allowSort(bool allow); * =================================== * * These methods get or set the value of variable controlling * whether user can determine how data on table is sorted by * clicking on the header buttons. */ bool Table::allowSort() const { return canSort; } void Table::allowSort(bool allow) { canSort = allow; } /* * ================================== * int Table.headerSize(); * void Table.headerSize(int size); * ================================== * * These methods get or set the value of variable controlling * the height of header buttons. */ int Table::headerSize() const { return headerHeight; } void Table::headerSize(int height) { headerHeight = height + 4; dimensionsChanged = true; redraw(); } /* * =============================== * int Table.rowSize(); * void Table.rowSize(int size); * =============================== * * These methods get or set the value of variable controlling * the height of rows. */ int Table::rowSize() const { return rowHeight; } void Table::rowSize(int height) { height += 4; rowHeight = height; vScroll->linesize(3 * height); dimensionsChanged = true; redraw(); } /* * =================================== * int Table.scrollbSize(); * void Table.scrollbSize(int size); * =================================== * * These methods get or set the value of variable controlling * the size (width) of the scrollbars. */ int Table::scrollbSize() const { return scrollbarSize; } void Table::scrollbSize(int size) { scrollbarSize = size; dimensionsChanged = true; redraw(); } /* * ===================================================== * Fl_Align Table.columnAlign(int column); * void Table.columnAlign(int column, Fl_Align align); * ===================================================== * * These methods get or set the value of variable controlling * the alignment of the specified column. */ Fl_Align Table::columnAlign(int column) const { if ((column < 0) && (column >= nCols)) return (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP); /* NOT REACHED */ return header[column].align; } void Table::columnAlign(int column, Fl_Align align) { if ((column < 0) || (column >= nCols)) return; /* NOT REACHED */ header[column].align = (Fl_Align)(align | FL_ALIGN_CLIP); redraw(); } Fl_Align Table::headerAlign(int column) const { if ((column < 0) && (column >= nCols)) return (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP); /* NOT REACHED */ return header[column].hdr_align; } void Table::headerAlign(int column, Fl_Align align) { if ((column < 0) && (column >= nCols)) return; /* NOT REACHED */ header[column].hdr_align = (Fl_Align)(align | FL_ALIGN_CLIP); redraw(); } /* * ===================================================== * int Table.columnWidth(int column); * void Table.columnWidth(int column, int width); * ===================================================== * * These methods get or set the value of variable controlling * the width of the specified column. */ int Table::columnWidth(int column) const { if ((column < 0) && (column >= nCols)) return 0; /* NOT REACHED */ return header[column].width; } void Table::columnWidth(int column, int width) { if ((column < 0) && (column >= nCols)) return; /* NOT REACHED */ header[column].width = width; dimensionsChanged = true; redraw(); } /* * ======================================================== * const char *Table.columnTitle(int column); * void Table.columnTitle(int column, const char *title); * ======================================================== * * These methods get or set the value of variable controlling * the width of the specified column. */ const char *Table::columnTitle(int column) { if ((column < 0) && (column >= nCols)) return NULL; /* NOT REACHED */ return header[column].title; } void Table::columnTitle(int column, const char *title) { if ((column < 0) && (column >= nCols)) return; /* NOT REACHED */ free((void*)header[column].title); header[column].title = strdup(title); damage(DAMAGE_HEADER); } /* * =================================================== * bool Table.columnHidden(int column); * void Table.columnHidden(int column, bool hidden); * =================================================== * * These methods get or set the value of variable controlling * whether column is visible or not. */ bool Table::columnHidden(int column) { if ((column < 0) && (column >= nCols)) return false; /* NOT REACHED */ return header[column].hidden; } void Table::columnHidden(int column, bool hidden) { if ((column < 0) && (column >= nCols)) return; /* NOT REACHED */ header[column].hidden = hidden; dimensionsChanged = true; damage(DAMAGE_HEADER | DAMAGE_ROWS); } /* * =================== * int Table.rows(); * =================== * * Returns the number of rows in table. */ int Table::rows() { return nRows; } /* * ====================== * int Table.columns(); * ====================== * * Returns the number of columns in table. */ int Table::columns() { return nCols; } /* * ================================== * void Table.value(int selection); * ================================== * * Sets the currently selected row. */ void Table::value(int selection) { if ((selection >= 0) && (selection < nRows)) selected = selection; damage(DAMAGE_ROWS); } /* * ==================== * int Table.value(); * ==================== * * Returns the number of the currently selected row. */ int Table::value() { return selected; } /* * ==================================================================== * void Table.addColumn(const char *label, int width, Fl_Align align, * int (*comparator)(const char*, const char*)); * ==================================================================== * * Adds column with label as title, width, align and comparator as * sort function. */ void Table::addColumn(const char *label, int width, Fl_Align align, int (*comparator)(const char*, const char*)) { if (!noMoreColumns) { struct ColumnInfo col; dimensionsChanged = true; col.title = strdup(label); col.width = width; col.hidden = false; col.align = (Fl_Align)(align | FL_ALIGN_CLIP); col.hdr_align = (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_CLIP); col.comparator = comparator; col.callback = NULL; header.push_back(col); nCols++; } } void Table::colcomparator(int col, int (*comparator)(const char*, const char*)) { header[col].comparator = comparator; } void Table::colcallback (int col, void (*callback)()) { header[col].callback = callback; } /* * ================================================ * void Table.addHiddenColumn(const char *label); * ================================================ * * Adds a nonvisible column with label as title. */ void Table::addHiddenColumn(const char *label) { if (!noMoreColumns) { struct ColumnInfo col; col.title = strdup(label); col.width = 0; col.hidden = true; col.align = FL_ALIGN_LEFT; col.comparator = NULL; header.push_back(col); nCols++; } } /* * ================================= * void Table.addCell(char *data); * ================================= * * Adds a cell with data to the table. */ void Table::addCell(char *data) { if (!noMoreColumns) noMoreColumns = true; if ((cPos >= nCols) || (curRow == NULL)) { this->data.push_back(curRow = new char*[nCols]); dimensionsChanged = true; nRows++; cPos = 0; } if (data != NULL) curRow[cPos] = strdup(data); else curRow[cPos] = strdup(""); if (cPos == sortColumn) toBeSorted = true; cPos++; } /* * =================================== * void Table.addRow(int cols, ...); * =================================== * * Adds cols number of cells to table. */ void Table::addRow(int cols, ...) { char *temp; if (!noMoreColumns) noMoreColumns = true; if ((cPos != 0) || (curRow == NULL)) { this->data.push_back(curRow = new char*[nCols]); dimensionsChanged = true; nRows++; cPos = 0; } if (cols > nCols) cols = nCols; va_list ap; va_start(ap, cols); for (int c = 0; c < cols; c++, cPos++) { if (cPos >= nCols) { this->data.push_back(curRow = new char*[nCols]); dimensionsChanged = true; nRows++; cPos = 0; } if ((temp = va_arg(ap, char *)) != NULL) curRow[cPos] = strdup(temp); else curRow[cPos] = strdup(""); } va_end(ap); toBeSorted = true; dimensionsChanged = true; } /* * ================================ * void Table.removeRow(int row); * ================================ * * Removes row referenced by row. */ void Table::removeRow(int row) { if ((row == -1) && (selected >= 0)) row = selected; if ((row >= 0) && (row < nRows)) { char **rowData = data[row]; if (rowData == curRow) curRow = NULL; for (int i = 0; i < nCols; i++) free(rowData[i]); data.erase(row + data.begin()); nRows--; dimensionsChanged = true; toBeSorted = true; selected = -1; } redraw (); } /* * ======================================= * void Table.clear(bool removeColumns); * ======================================= * * Frees all data in table. If removeColumns is true, frees also header * structures. */ void Table::clear(bool removeColumns) { nRows = 0; curRow = NULL; cPos = 0; // Delete row data. std::vector<char**>::iterator end = data.end(); char **row; for (std::vector<char**>::iterator i = data.begin(); i < end; ++i) { row = *i; for (int i = 0; i < nCols; i++) free(row[i]); delete [] row; } data.clear(); if (removeColumns) { // Delete header data. std::vector<struct ColumnInfo>::iterator end = header.end(); for (std::vector<struct ColumnInfo>::iterator i = header.begin(); i < end; ++i) free((void*)(*i).title); header.clear(); nCols = 0; } selected = -1; dimensionsChanged = true; redraw (); } /* * ============================================ * char *Table.valueAt(int row, int column); * int Table.intValueAt(int row, int column); * ============================================ * * Returns value in cell referenced by row and column. */ char *Table::valueAt(int row, int column) { if ((row >= 0) && (row < nRows) && (column >= 0) && (column < nCols)) return data[row][column]; else if ((row == -1) && (selected >= 0) && (column >= 0) && (column < nCols)) return data[selected][column]; else return NULL; } int Table::intValueAt(int row, int column) { if ((row == -1) && (selected >= 0)) row = selected; if ((row >= 0) && (row < nRows) && (column >= 0) && (column < nCols)) return strtol(data[row][column], NULL, 10); else return 0; } /* * ====================================================== * void Table.valueAt(int row, int column, char *data); * void Table.valueAt(int row, int column, int data); * ====================================================== * * Sets alue in cell referenced by row and column. */ void Table::valueAt(int row, int column, char *data) { if ((row == -1) && (selected >= 0)) row = selected; if ((row >= 0) && (row < nRows) && (column >= 0) && (column < nCols)) { if (column == sortColumn) toBeSorted = true; if (this->data[row][column] != NULL) free(this->data[row][column]); this->data[row][column] = strdup(data); } } void Table::valueAt(int row, int column, int data) { if ((row == -1) && (selected >= 0)) row = selected; if ((row >= 0) && (row < nRows) && (column >= 0) && (column < nCols)) { if (column == sortColumn) toBeSorted = true; if (this->data[row][column] != NULL) free(this->data[row][column]); std::string temp = ""; temp += data; strcpy(this->data[row][column] = (char*)malloc(temp.length()), temp.c_str()); } } /* * ===================================== * const char **Table.getRow(int row); * ===================================== * * Returns pointer to the data of the row number row. */ const char **Table::getRow(int row) { if ((row == -1) && (selected >= 0)) row = selected; if ((row >= 0) && (row < nRows)) return (const char**)data[row]; else return NULL; } /* * ============== * Menu methods * ============== * * These work in the same way as in class Fl_Menu_ (methods menu, * copy and clear). These are used for handling the popup menu. */ const Fl_Menu_Item *Table::menu() { return popupMenu; } void Table::menu(const Fl_Menu_Item *m) { menuClear(); popupMenu = m; } void Table::menuCopy(const Fl_Menu_Item *m) { int n = m->size(); Fl_Menu_Item* newMenu = new Fl_Menu_Item[n]; memcpy(newMenu, m, n * sizeof(Fl_Menu_Item)); menu(newMenu); menuAlloc = true; } void Table::menuClear() { if (menuAlloc) delete[] popupMenu; popupMenu = NULL; } /* * ================================================================ * Table.where(int x, int y, int &row, int &column, int &resize); * ================================================================ * * Finds corresponding row and column for x and y coordinates. This function * uses Fl::event_inside() method. * * row = -1 means header and row = -2 means that coordinates don't * correspond any cell. */ void Table::where(int x, int y, int &row, int &column, int &resize) { int temp, temp2; // Inside the header if ((nCols > 0) && headerEnabled && Fl::event_inside(oX, oY, iW, headerHeight)) { row = -1; temp = leftColX + iX - hScroll->value(); // Scan visible columns until found one that matches. for (column = leftCol; column <= rightCol; column++ ) { if (header[column].hidden) continue; temp2 = temp; // Near the left border of the column header if ((x >= temp) && (x <= temp + 3)) { resize = 1; return; /* NOT REACHED */ } // Near the right border of the column header else if ((x >= (temp += header[column].width) - 3) && (x < temp)) { resize = 2; return; /* NOT REACHED */ } // Somewhere else else if ((x >= temp2) && (x < temp)) { resize = 0; return; /* NOT REACHED */ } } } // Header /* * Now the harder one. X and Y lie somewhere in the table. * Find correct row and column. */ else if ((nRows > 0) && Fl::event_inside(iX, iY, iW, iH)) { temp = topRowY; int yMod = iY - vScroll->value(); int leftX = leftColX + iX - hScroll->value(); // Scan rows for (row = topRow; row <= bottomRow; row++) { int temp2 = leftX; for (column = leftCol; column <= rightCol; column++) { if (header[column].hidden) continue; if (Fl::event_inside(temp2, temp + yMod, header[column].width, rowHeight)) return; /* NOT REACHED */ temp2 += header[column].width; } temp += rowHeight; } } row = column = -2; } void Table::FirstRow() { if (nRows == 0 || selected == 0) return; scrollTo (selected = 0); } void Table::PrevPage () { // Does it make sense to move up? if (selected > 0) { // Number of rows on the 'page' int step = iH / rowHeight; // Change selection if (selected >= step) selected -= step; else selected = 0; scrollTo(selected * rowHeight); } } void Table::PrevRow() { int newpos, oldpos; if (nRows == 0) return; selected = (selected > 0) ? selected - 1 : 0; oldpos = vScroll->value(); newpos = rowHeight * selected; if (newpos - oldpos > 0) scrollTo (oldpos); else scrollTo (newpos); } void Table::NextRow() { int newpos, oldpos, lastrow; if (nRows == 0 || selected == (nRows - 1)) return; lastrow = nRows -1; selected = (selected < lastrow) ? selected + 1 : lastrow; oldpos = vScroll->value(); newpos = rowHeight *(selected + 1) - iH; if (newpos - oldpos < 0) scrollTo (oldpos); else scrollTo (newpos); } void Table::NextPage () { if ((selected >= 0) && (selected < (nRows - 1))) { int step = iH / rowHeight; if ((selected += step) >= nRows) selected = nRows - 1; scrollTo(rowHeight * (selected + 1) - iH); } } void Table::LastRow() { if (nRows == 0) return; selected = nRows - 1; scrollTo (rowHeight * (selected + 1) - iH); } void Table::GotoRow(int n) { if (n >= 0 && (n < nRows)) { selected = n; scrollTo(rowHeight * (selected + 1) - iH); } } /* * ============================== * int Table.handle(int event); * ============================== * * FLTK internal. Handles incoming events. */ int Table::handle(int event) { int ret = 0; static int row, prev_row; int column, resize; if (event != FL_KEYDOWN) ret = Fl_Group::handle(event); /* * MAIN SWITCH */ switch (event) { /* * PUSH event */ case FL_PUSH: // Which row/column are we over? where(Fl::event_x(), Fl::event_y(), row, column, resize); switch (row) { // Push on nothing... Not interested case -2: if (selected != -1) { // selected = -1; damage(DAMAGE_ROWS); } break; // Push on header. case -1: if ((canResize) && (Fl::event_button() == 1) && (resize != 0)) { resizing = (resize == 1) ? column - 1 : column; dragX = Fl::event_x(); ret = 1; } else if ((canSort) && (Fl::event_button() == 1)) { pushed = column; damage(DAMAGE_HEADER); ret = 1; } break; // Push on cell. default: bool changed = selected != row; selected = row; // Create new selection int len = 0; char **tableRow = data[selected]; char *buffer = nullptr; for (int col = 0; col < nCols; col++) len += strlen(tableRow[col]) + 1; // Create a tab separated list from data. buffer = (char*)malloc(len); if (buffer != nullptr) { strcpy(buffer, tableRow[0]); for (int col = 1; col < nCols; col++) { strcat(buffer, "\t"); strcat(buffer, tableRow[col]); } Fl::selection(*this, buffer, len); free(buffer); } // Update view. damage(DAMAGE_ROWS); take_focus(); // Show popup menu if ((Fl::event_button() == 3) && (popupMenu != NULL)) { const Fl_Menu_Item *m; m = popupMenu->popup(Fl::event_x(), Fl::event_y()); if (m != NULL) m->do_callback(this, m->user_data()); ret = 1; break; } // Callback if ((Fl::event_clicks() != 0) && !changed && (when() & TABLE_WHEN_DCLICK)) { Fl::event_is_click(0); do_callback(); } else if (changed && (when() & FL_WHEN_CHANGED)) do_callback(); else if (!changed && (when() & FL_WHEN_NOT_CHANGED)) do_callback(); ret = 1; break; } // switch(row) break; /* * DRAG event */ case FL_DRAG: // Resizing... if (resizing > -1 ) { int offset = dragX - Fl::event_x(); int newWidth = header[resizing].width - offset; // Width must be at least 1. if (newWidth < 1) newWidth = 1; // Test if column really is resized. if (header[resizing].width != newWidth) { header[resizing].width = newWidth; dragX = Fl::event_x(); resized(); redraw(); } ret = 1; } else { prev_row = row; where(Fl::event_x(), Fl::event_y(), row, column, resize); if (row < 0 || pushed != -1) { ret = 1; break; } if (prev_row != row) { selected = row; damage(DAMAGE_ROWS); take_focus(); if (when() & FL_WHEN_CHANGED) do_callback(); } } break; /* * RELEASE event */ case FL_RELEASE: // Which row/column are we over? where(Fl::event_x(), Fl::event_y(), row, column, resize); // Restore cursor and end resizing. if (Fl::event_button() == 1) { fl_cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE); if ((pushed == column) && canSort) { if (this->header[pushed].callback != NULL) (this->header[pushed].callback)(); if (this->header[pushed].comparator != NULL) { if (sortColumn == pushed) { if (ascent) ascent = false; else sortColumn = -1; } else { ascent = true; sortColumn = pushed; } sort(); } redraw(); } pushed = -1; resizing = -1; ret = 1; } // Callback. if ((row >= 0) && (when() & FL_WHEN_RELEASE)) do_callback(); break; /* * MOVE event */ case FL_MOVE: // Which row/column are we over? where(Fl::event_x(), Fl::event_y(), row, column, resize); // If near header boundary. if ((row == -1) && canResize && resize) fl_cursor(FL_CURSOR_WE, FL_BLACK, FL_WHITE); else fl_cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE); ret = 1; break; case FL_ENTER: case FL_LEAVE: if (event == FL_LEAVE) fl_cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE); ret = 1; break; case FL_FOCUS: case FL_UNFOCUS: if (Fl::visible_focus()) { damage(DAMAGE_ROWS); ret = 1; } break; /* * KEYDOWN event */ case FL_KEYDOWN: switch(Fl::event_key()) { case FL_Enter: if ((selected > -1) && ((when() & TABLE_WHEN_DCLICK) || (when() & FL_WHEN_ENTER_KEY))) do_callback(); ret = 1; break; case FL_Home: FirstRow(); ret = 1; break; case FL_Up: PrevRow(); ret = 1; break; case FL_Down: NextRow(); ret = 1; break; case FL_End: LastRow(); ret = 1; break; case FL_Page_Up: PrevPage (); ret = 1; break; case FL_Page_Down: NextPage (); ret = 1; break; } break; } return ret; } /* * =============================== * void Table.scrollTo(int pos); * =============================== * * Scrolls table to given position. */ void Table::scrollTo(int pos) { if (vScroll->visible() || nRows > (iH / rowHeight)) { int max = rowHeight * nRows - iH; //printf ("pos %d, max %d\n", pos, max); fflush (stdout); if (pos < 0 || max < 0) pos = 0; if (pos > max) pos = max; vScroll->Fl_Valuator::value(1.0*pos); vScroll->damage (FL_DAMAGE_ALL); vScroll->redraw (); scrolled(); } damage(DAMAGE_ROWS); if (when() & FL_WHEN_CHANGED) do_callback(); } int Table::scrollPos() const { return (int)vScroll->value(); } /* * =========================================== * void Table.sort(int column, bool ascent); * =========================================== * * Sets sortColumn and ascent and sorts table. Does not redraw. */ void Table::sort(int column, bool ascent) { if ((column < -1) || (column >= nCols)) return; sortColumn = column; this->ascent = ascent; sort(); } void Table::aSort(int start, int end, int (*compare)(const char *, const char*)) { int i, j; const char *x; char **temp; x = data[(start + end) / 2][sortColumn]; i = start; j = end; for (;;) { while ((i < end) && (compare(data[i][sortColumn], x) < 0)) i++; while ((j > 0) && (compare(data[j][sortColumn], x) > 0)) j--; while ((i < end) && (i != j) && (compare(data[i][sortColumn], data[j][sortColumn]) == 0)) i++; if (i == j) break; temp = data[i]; data[i] = data[j]; data[j] = temp; } if (start < --i) aSort(start, i, compare); if (end > ++j) aSort(j, end, compare); } void Table::dSort(int start, int end, int (*compare)(const char *, const char*)) { int i, j; const char *x; char **temp; x = data[(start + end) / 2][sortColumn]; i = start; j = end; for (;;) { while ((i < end) && (compare(data[i][sortColumn], x) > 0)) i++; while ((j > 0) && (compare(data[j][sortColumn], x) < 0)) j--; while ((i < end) && (i != j) && (compare(data[i][sortColumn], data[j][sortColumn]) == 0)) i++; if (i == j) break; temp = data[i]; data[i] = data[j]; data[j] = temp; } if (start < --i) dSort(start, i, compare); if (end > ++j) dSort(j, end, compare); } /* * ==================== * void Table.sort(); * ==================== * * Sorts table according sortColumn and ascent. Does not redraw. */ void Table::sort() { if ((sortColumn == -1) || !canSort) return; /* NOT REACHED */ toBeSorted = false; int (*compare)(const char *, const char*); // Get comparator function or set it to the default. if (this->header[sortColumn].comparator == NULL) // compare = strcasecmp; return; else compare = header[sortColumn].comparator; // Sort in descending order. if ((nRows > 1) && ascent) aSort(0, nRows - 1, compare); // Sort in ascending order. else if (nRows > 1) dSort(0, nRows - 1, compare); } /* * ==================================================== * void Table.getSort(int &sortColumn, bool &ascent); * ==================================================== * * Set sortColumn and ascent according to current sort policy. */ void Table::getSort(int &sortColumn, bool &ascent) { sortColumn = this->sortColumn; ascent = this->ascent; } /* * ===================================================== * int compareInt(const char *val1, const char *val2); * ===================================================== * * This function compares values as numbers instead of strings. Solves * problem with string sorting (eg. 1 - 10 - 11 - 12 - 2 - 3 ...). */ int compareInt(const char *val1, const char *val2) { return strtol(val1, NULL, 0) - strtol(val2, NULL, 0); } /* * ============================================================================== * void Table.setHighlighter(bool (*highliter)(int, char **, Fl_Color &color)); * ============================================================================== * * Sets highlighter function to highlighter. Highlighter is used to determine * text color in Table.drawRow(). */ void Table::setHighlighter(bool (*highlighter)(int, char **, Fl_Color *)) { this->highlighter = highlighter; } /* * ==================== * void Table.draw(); * ==================== * * FLTK internal. Called when Table widget needs to be drawn. */ void Table::draw() { int damage; if (dimensionsChanged) { dimensionsChanged = false; resized(); } if (toBeSorted) sort(); damage = Fl_Widget::damage(); // Draw children. if (damage & (FL_DAMAGE_ALL | FL_DAMAGE_CHILD)) { fl_push_clip(oX, oY, oW, oH); Fl_Group::draw(); fl_pop_clip(); } // Draw box. if (damage & FL_DAMAGE_ALL) { // Draw box. draw_box(box(), x(), y(), w(), h(), FL_GRAY); // Draw label. draw_label(); } // Draw header. int xPos = leftColX + iX - hScroll->value(); if (headerEnabled && (damage & (FL_DAMAGE_ALL | DAMAGE_HEADER)) && (nCols > 0)) { fl_push_clip(iX, oY, iW, headerHeight); drawHeader(xPos, oY); fl_pop_clip(); } // Draw all the cells. if ((damage & (FL_DAMAGE_ALL | DAMAGE_ROWS)) && (nRows > 0) && (nCols > 0)) { fl_push_clip(iX, iY, iW, iH); int yMod = iY - vScroll->value(); for (int row = topRow, rowY = topRowY; row <= bottomRow; row++, rowY += rowHeight) drawRow(row, data[row], xPos, rowY + yMod); fl_pop_clip(); } fl_push_clip(oX, oY, oW, oH); if (tableWidth < iW) fl_rectf(iX + tableWidth, oY, iW - tableWidth, oH, FL_GRAY); // Table height smaller than window? Fill remainder with rectangle if (tableHeight < iH) fl_rectf(iX, iY + tableHeight, iW, iH - tableHeight, FL_GRAY); if (vScroll->visible()) { vScroll->damage (FL_DAMAGE_ALL); vScroll->redraw(); } if (hScroll->visible()) { hScroll->damage (FL_DAMAGE_ALL); hScroll->redraw(); } // Both scrollbars? Draw little box in lower right if (vScroll->visible() && hScroll->visible()) fl_rectf(vScroll->x(), hScroll->y(), vScroll->w(), hScroll->h(), FL_GRAY); fl_pop_clip(); } /* * ================================================ * void Table.resize(int x, int y, int w, int h); * ================================================ * * FLTK internal. Called when Table widget is resized. */ void Table::resize(int x, int y, int w2, int h) { // resize the columns proportionally if the width changes if (w2 != w()) { int iw = w() - (vScroll->visible() ? vScroll->w() : 0) - 4; int iw2 = w2 - (vScroll->visible() ? vScroll->w() : 0) - 4; if (iw > 0 && iw2 > 0) { int lastcol = 0; int iw3 = 0; for (int i = 0; i < nCols - 1; i++) { if (!header[i].hidden) { header[i].width = (int)(1.0 * header[i].width * iw2 / iw + 0.5); iw3 += header[i].width; lastcol = i; } } // adjust last visible column if (iw3 < iw2) header[lastcol].width += (iw2 - iw3); if (iw3 > iw2) header[lastcol].width -= (iw3 - iw2); } } Fl_Widget::resize(x, y, w2, h); resized(); damage(FL_DAMAGE_ALL); } /* * ============================== * void Table.calcDimensions(); * ============================== * * Calculates table dimensions. */ void Table::calcDimensions() { // Calculate width and height of the table (in pixels). tableWidth = 0; for (int i = 0; i < nCols; i++) if (!header[i].hidden) tableWidth +=header[i].width; tableHeight = nRows * rowHeight; Fl_Boxtype b; iX = oX = x() + Fl::box_dx(b = box()); iY = oY = y() + Fl::box_dy(b); iW = oW = w() - Fl::box_dw(b); iH = oH = h() - Fl::box_dh(b); // Trim inner size if header enabled. if (headerEnabled) { iY += headerHeight; iH -= headerHeight; } // Hide scrollbars if window is large enough int hideV, hideH; hideV = (tableHeight <= iH), hideH = (tableWidth <= iW); if (!hideH && hideV) hideV = (tableHeight - iH - scrollbarSize) <= 0; if (!hideV && hideH) hideH = (tableWidth - iW + scrollbarSize) <= 0; if (Vscroll == always) { vScroll->show(); iW -= scrollbarSize; } else if (Vscroll == never) { vScroll->hide(); vScroll->Fl_Valuator::value(0); } else if (hideV) { vScroll->hide(); vScroll->Fl_Valuator::value(0); } else { vScroll->show(); iW -= scrollbarSize; } if (Hscroll == always) { hScroll->show(); iH -= scrollbarSize; } else if (Hscroll == never) { hScroll->hide(); hScroll->Fl_Valuator::value(0); } else if (hideH) { hScroll->hide(); hScroll->Fl_Valuator::value(0); } else { hScroll->show(); iH -= scrollbarSize; } } /* * ======================== * void Table.scrolled(); * ======================== * * Calculates visible are after scroll or adding data. */ void Table::scrolled() { int y, row, voff = vScroll->value(); // First visible row row = voff / rowHeight; topRow = (row >= nRows) ? (nRows - 1) : row; topRow = (topRow < 0) ? 0 : topRow; y = topRow * rowHeight; if ((topRow > 0) && (y > voff)) { topRow--; y -= rowHeight; } topRowY = y; // Last visible row row = (voff + iH) / rowHeight; bottomRow = (row >= nRows) ? (nRows - 1) : row; // First visible column int x, col, h = hScroll->value(); for (col = x = 0; col < nCols; col++) { if (header[col].hidden) continue; x += header[col].width; if (x >= h) { x -= header[col].width; break; } } leftCol = (col >= nCols) ? (nCols - 1) : col; leftColX = x; // Last visible column h += iW; for (; col < nCols; col++) { if (header[col].hidden) continue; x += header[col].width; if (x >= h) break; } rightCol = (col >= nCols) ? (nCols - 1) : col; } /* * ======================= * void Table.resized(); * ======================= * * Calculates scrollbar properties after resizing or adding data. */ void Table::resized() { calcDimensions(); // Calculate properties for vertical scrollbar. if (vScroll->visible()) { vScroll->bounds(0, tableHeight - iH); vScroll->resize(oX + oW - scrollbarSize, oY, scrollbarSize, oH - (hScroll->visible() ? scrollbarSize : 0)); vScroll->Fl_Valuator::value(vScroll->clamp(vScroll->value())); vScroll->slider_size(iH > tableHeight ? 1 : (float)iH / tableHeight); } // Calculate properties for horizontal scrollbar. if (hScroll->visible()) { hScroll->bounds(0, tableWidth - iW); hScroll->resize(oX, oY + oH - scrollbarSize, oW - (vScroll->visible() ? scrollbarSize : 0), scrollbarSize); hScroll->Fl_Valuator::value(hScroll->clamp(hScroll->value())); hScroll->slider_size(iW > tableWidth ? 1 : (float)iW / tableWidth); } scrolled(); dimensionsChanged = false; } /* * =========================================================== * void Table.scrollCallback(Fl_Widget *widget, void *data); * =========================================================== * * Internal callback for scrollbars. Scrolls view. */ void Table::scrollCallback(Fl_Widget *widget, void *data) { Table *me = (Table*)data; me->scrolled(); if (widget == me->vScroll) me->damage(DAMAGE_ROWS); else me->damage(DAMAGE_ROWS | DAMAGE_HEADER); } #include "re.h" inline static bool search_row(const std::vector<char**>& data, int row, int col, int ncols, fre_t& re, bool allcols) { if (unlikely(allcols)) { for (col = 0; col < ncols; col++) if (re.match(data[row][col])) return true; } else if (re.match(data[row][col])) return true; return false; } /* * ================================================================== * void Table.search(int& row, int& col, bool rev, const char* re); * ================================================================== * * Searches Table data starting at `row', in direction indicated by `rev', * for column data matching regexp `re'. Looks in all row columns if `col' * is equal to nCols, or just the specified column if 0 <= col < nCols. * Returns true if found, in which case the `row' and `col' arguments will * point to the matching data. If false is returned, the contents of * `row' and `col' are undefined. */ bool Table::search(int& row, int& col, bool rev, const char* re) { if (unlikely(col < 0 || col > nCols || row < 0 || row >= nRows)) return false; bool allcols = col == nCols; fre_t sre(re, REG_EXTENDED | REG_ICASE | REG_NOSUB); if (!sre) return false; int r = row; if (rev) { for (; row >= 0; row--) if (search_row(data, row, col, nCols, sre, allcols)) return true; for (row = nRows - 1; row > r; row--) if (search_row(data, row, col, nCols, sre, allcols)) return true; } else { for (; row < nRows; row++) if (search_row(data, row, col, nCols, sre, allcols)) return true; for (row = 0; row < r; row++) if (search_row(data, row, col, nCols, sre, allcols)) return true; } return false; }
43,206
C++
.cxx
1,560
23.769231
102
0.554069
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,240
cty-dat.cxx
w1hkj_fldigi/src/logbook/cty-dat.cxx
// ---------------------------------------------------------------------------- // cty-dat.cxx // // Copyright (C) 2018 // David Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // internal data file string that is the latest cty.dat as of the // publishing date of the software #include <config.h> #include <string> std::string s_ctydat = "\ Sov Mil Order of Malta: 15: 28: EU: 41.90: -12.43: -1.0: 1A:\n\ 1A;\n\ Spratly Islands: 26: 50: AS: 9.88: -114.23: -8.0: 1S:\n\ 9M0,BM9S,BN9S,BO9S,BP9S,BQ9S,BU9S,BV9S,BW9S,BX9S;\n\ Monaco: 14: 27: EU: 43.73: -7.40: -1.0: 3A:\n\ 3A;\n\ Agalega & St. Brandon: 39: 53: AF: -10.45: -56.67: -4.0: 3B6:\n\ 3B6,3B7;\n\ Mauritius: 39: 53: AF: -20.35: -57.50: -4.0: 3B8:\n\ 3B8;\n\ Rodriguez Island: 39: 53: AF: -19.70: -63.42: -4.0: 3B9:\n\ 3B9;\n\ Equatorial Guinea: 36: 47: AF: 1.70: -10.33: -1.0: 3C:\n\ 3C;\n\ Annobon Island: 36: 52: AF: -1.43: -5.62: -1.0: 3C0:\n\ 3C0;\n\ Fiji: 32: 56: OC: -17.78: -177.92: -12.0: 3D2:\n\ 3D2;\n\ Conway Reef: 32: 56: OC: -22.00: -175.00: -12.0: 3D2/c:\n\ =3D2CR;\n\ Rotuma Island: 32: 56: OC: -12.48: -177.08: -12.0: 3D2/r:\n\ =3D2RI;\n\ Kingdom of Eswatini: 38: 57: AF: -26.65: -31.48: -2.0: 3DA:\n\ 3DA;\n\ Tunisia: 33: 37: AF: 35.40: -9.32: -1.0: 3V:\n\ 3V,TS;\n\ Vietnam: 26: 49: AS: 15.80: -107.90: -7.0: 3W:\n\ 3W,XV;\n\ Guinea: 35: 46: AF: 11.00: 10.68: 0.0: 3X:\n\ 3X;\n\ Bouvet: 38: 67: AF: -54.42: -3.38: -1.0: 3Y/b:\n\ =3Y0E;\n\ Peter 1 Island: 12: 72: SA: -68.77: 90.58: 4.0: 3Y/p:\n\ =3Y0X;\n\ Azerbaijan: 21: 29: AS: 40.45: -47.37: -4.0: 4J:\n\ 4J,4K;\n\ Georgia: 21: 29: AS: 42.00: -45.00: -4.0: 4L:\n\ 4L;\n\ Montenegro: 15: 28: EU: 42.50: -19.28: -1.0: 4O:\n\ 4O;\n\ Sri Lanka: 22: 41: AS: 7.60: -80.70: -5.5: 4S:\n\ 4P,4Q,4R,4S;\n\ ITU HQ: 14: 28: EU: 46.17: -6.05: -1.0: 4U1I:\n\ =4U1ITU,=4U1WRC;\n\ United Nations HQ: 05: 08: NA: 40.75: 73.97: 5.0: 4U1U:\n\ =4U1UN,=4U75UN;\n\ Vienna Intl Ctr: 15: 28: EU: 48.20: -16.30: -1.0: *4U1V:\n\ =4U0R,=4U1A,=4U1VIC,=4U2STAYHOME,=4U2U,=4U75A,=4Y1A,=C7A;\n\ Timor - Leste: 28: 54: OC: -8.80: -126.05: -9.0: 4W:\n\ 4W,=VERSION;\n\ Israel: 20: 39: AS: 31.32: -34.82: -2.0: 4X:\n\ 4X,4Z;\n\ Libya: 34: 38: AF: 27.20: -16.60: -2.0: 5A:\n\ 5A;\n\ Cyprus: 20: 39: AS: 35.00: -33.00: -2.0: 5B:\n\ 5B,C4,H2,P3;\n\ Tanzania: 37: 53: AF: -5.75: -33.92: -3.0: 5H:\n\ 5H,5I;\n\ Nigeria: 35: 46: AF: 9.87: -7.55: -1.0: 5N:\n\ 5N,5O;\n\ Madagascar: 39: 53: AF: -19.00: -46.58: -3.0: 5R:\n\ 5R,5S,6X;\n\ Mauritania: 35: 46: AF: 20.60: 10.50: 0.0: 5T:\n\ 5T;\n\ Niger: 35: 46: AF: 17.63: -9.43: -1.0: 5U:\n\ 5U;\n\ Togo: 35: 46: AF: 8.40: -1.28: 0.0: 5V:\n\ 5V;\n\ Samoa: 32: 62: OC: -13.93: 171.70: -13.0: 5W:\n\ 5W;\n\ Uganda: 37: 48: AF: 1.92: -32.60: -3.0: 5X:\n\ 5X;\n\ Kenya: 37: 48: AF: 0.32: -38.15: -3.0: 5Z:\n\ 5Y,5Z;\n\ Senegal: 35: 46: AF: 15.20: 14.63: 0.0: 6W:\n\ 6V,6W;\n\ Jamaica: 08: 11: NA: 18.20: 77.47: 5.0: 6Y:\n\ 6Y;\n\ Yemen: 21: 39: AS: 15.65: -48.12: -3.0: 7O:\n\ 7O;\n\ Lesotho: 38: 57: AF: -29.22: -27.88: -2.0: 7P:\n\ 7P;\n\ Malawi: 37: 53: AF: -14.00: -34.00: -2.0: 7Q:\n\ 7Q;\n\ Algeria: 33: 37: AF: 28.00: -2.00: -1.0: 7X:\n\ 7R,7T,7U,7V,7W,7X,7Y;\n\ Barbados: 08: 11: NA: 13.18: 59.53: 4.0: 8P:\n\ 8P;\n\ Maldives: 22: 41: AS: 4.15: -73.45: -5.0: 8Q:\n\ 8Q;\n\ Guyana: 09: 12: SA: 6.02: 59.45: 4.0: 8R:\n\ 8R;\n\ Croatia: 15: 28: EU: 45.18: -15.30: -1.0: 9A:\n\ 9A;\n\ Ghana: 35: 46: AF: 7.70: 1.57: 0.0: 9G:\n\ 9G;\n\ Malta: 15: 28: EU: 35.88: -14.42: -1.0: 9H:\n\ 9H;\n\ Zambia: 36: 53: AF: -14.22: -26.73: -2.0: 9J:\n\ 9I,9J;\n\ Kuwait: 21: 39: AS: 29.38: -47.38: -3.0: 9K:\n\ 9K,NLD;\n\ Sierra Leone: 35: 46: AF: 8.50: 13.25: 0.0: 9L:\n\ 9L;\n\ West Malaysia: 28: 54: AS: 3.95: -102.23: -8.0: 9M2:\n\ 9M,9W;\n\ East Malaysia: 28: 54: OC: 2.68: -113.32: -8.0: 9M6:\n\ 9M6,9M8,9W6,9W8,=9M4CAK,=9M4CPT,=9M4JAY,=9M4CCB,=9M4CKT,=9M4CRB,=9M4CRP;\n\ Nepal: 22: 42: AS: 27.70: -85.33: -5.75: 9N:\n\ 9N;\n\ Dem. Rep. of the Congo: 36: 52: AF: -3.12: -23.03: -1.0: 9Q:\n\ 9O,9P,9Q,9R,9S,9T;\n\ Burundi: 36: 52: AF: -3.17: -29.78: -2.0: 9U:\n\ 9U;\n\ Singapore: 28: 54: AS: 1.37: -103.78: -8.0: 9V:\n\ 9V,S6;\n\ Rwanda: 36: 52: AF: -1.75: -29.82: -2.0: 9X:\n\ 9X;\n\ Trinidad & Tobago: 09: 11: SA: 10.38: 61.28: 4.0: 9Y:\n\ 9Y,9Z;\n\ Botswana: 38: 57: AF: -22.00: -24.00: -2.0: A2:\n\ 8O,A2;\n\ Tonga: 32: 62: OC: -21.22: 175.13: -13.0: A3:\n\ A3;\n\ Oman: 21: 39: AS: 23.60: -58.55: -4.0: A4:\n\ A4;\n\ Bhutan: 22: 41: AS: 27.40: -90.18: -6.0: A5:\n\ A5;\n\ United Arab Emirates: 21: 39: AS: 24.00: -54.00: -4.0: A6:\n\ A6;\n\ Qatar: 21: 39: AS: 25.25: -51.13: -3.0: A7:\n\ A7;\n\ Bahrain: 21: 39: AS: 26.03: -50.53: -3.0: A9:\n\ A9;\n\ Pakistan: 21: 41: AS: 30.00: -70.00: -5.0: AP:\n\ 6P,6Q,6R,6S,AP,AQ,AR,AS;\n\ Scarborough Reef: 27: 50: AS: 15.08: -117.72: -8.0: BS7:\n\ =BS7H;\n\ Taiwan: 24: 44: AS: 23.72: -120.88: -8.0: BV:\n\ BM,BN,BO,BP,BQ,BU,BV,BW,BX;\n\ Pratas Island: 24: 44: AS: 20.70: -116.70: -8.0: BV9P:\n\ BM9P,BN9P,BO9P,BP9P,BQ9P,BU9P,BV9P,BW9P,BX9P;\n\ China: 24: 44: AS: 36.00: -102.00: -8.0: BY:\n\ 3H,3H0(23)[42],3H9(23)[43],3I,3I0(23)[42],3I9(23)[43],3J,3J0(23)[42],\n\ 3J9(23)[43],3K,3K0(23)[42],3K9(23)[43],3L,3L0(23)[42],3L9(23)[43],3M,\n\ 3M0(23)[42],3M9(23)[43],3N,3N0(23)[42],3N9(23)[43],3O,3O0(23)[42],\n\ 3O9(23)[43],3P,3P0(23)[42],3P9(23)[43],3Q,3Q0(23)[42],3Q9(23)[43],3R,\n\ 3R0(23)[42],3R9(23)[43],3S,3S0(23)[42],3S9(23)[43],3T,3T0(23)[42],\n\ 3T9(23)[43],3U,3U0(23)[42],3U9(23)[43],B0(23)[42],B2,B3,B4,B5,B6,B7,B8,\n\ B9(23)[43],BA,BA0(23)[42],BA9(23)[43],BD,BD0(23)[42],BD9(23)[43],BG,\n\ BG0(23)[42],BG9(23)[43],BH,BH0(23)[42],BH9(23)[43],BI,BI0(23)[42],\n\ BI9(23)[43],BJ,BJ0(23)[42],BJ9(23)[43],BL,BL0(23)[42],BL9(23)[43],BT,\n\ BT0(23)[42],BT9(23)[43],BY,BY0(23)[42],BY9(23)[43],BZ,BZ0(23)[42],\n\ BZ9(23)[43],XS,XS0(23)[42],XS9(23)[43],B1,B2A[33],B2B[33],B2C[33],B2D[33],\n\ B2E[33],B2F[33],B2G[33],B2H[33],B2I[33],B2J[33],B2K[33],B2L[33],B2M[33],\n\ B2N[33],B2O[33],B2P[33],B3G(23)[33],B3H(23)[33],B3I(23)[33],B3J(23)[33],\n\ B3K(23)[33],B3L(23)[33],B6Q[43],B6R[43],B6S[43],B6T[43],B6U[43],B6V[43],\n\ B6W[43],B6X[43],B7A[43],B7B[43],B7C[43],B7D[43],B7E[43],B7F[43],B7G[43],\n\ B7H[43],B7Q[43],B7R[43],B7S[43],B7T[43],B7U[43],B7V[43],B7W[43],B7X[43],\n\ B8A[43],B8B[43],B8C[43],B8D[43],B8E[43],B8F[43],B8G[43],B8H[43],B8I[43],\n\ B8J[43],B8K[43],B8L[43],B8M[43],B8N[43],B8O[43],B8P[43],B8Q[43],B8R[43],\n\ B8S[43],B8T[43],B8U[43],B8V[43],B8W[43],B8X[43],B9A(24)[43],B9B(24)[43],\n\ B9C(24)[43],B9D(24)[43],B9E(24)[43],B9F(24)[43],B9S(23)[42],B9T(23)[42],\n\ B9U(23)[42],B9V(23)[42],B9W(23)[42],B9X(23)[42],BA2A[33],BA2B[33],\n\ BA2C[33],BA2D[33],BA2E[33],BA2F[33],BA2G[33],BA2H[33],BA2I[33],BA2J[33],\n\ BA2K[33],BA2L[33],BA2M[33],BA2N[33],BA2O[33],BA2P[33],BA3G(23)[33],\n\ BA3H(23)[33],BA3I(23)[33],BA3J(23)[33],BA3K(23)[33],BA3L(23)[33],BA6Q[43],\n\ BA6R[43],BA6S[43],BA6T[43],BA6U[43],BA6V[43],BA6W[43],BA6X[43],BA7A[43],\n\ BA7B[43],BA7C[43],BA7D[43],BA7E[43],BA7F[43],BA7G[43],BA7H[43],BA7Q[43],\n\ BA7R[43],BA7S[43],BA7T[43],BA7U[43],BA7V[43],BA7W[43],BA7X[43],BA8A[43],\n\ BA8B[43],BA8C[43],BA8D[43],BA8E[43],BA8F[43],BA8G[43],BA8H[43],BA8I[43],\n\ BA8J[43],BA8K[43],BA8L[43],BA8M[43],BA8N[43],BA8O[43],BA8P[43],BA8Q[43],\n\ BA8R[43],BA8S[43],BA8T[43],BA8U[43],BA8V[43],BA8W[43],BA8X[43],\n\ BA9A(24)[43],BA9B(24)[43],BA9C(24)[43],BA9D(24)[43],BA9E(24)[43],\n\ BA9F(24)[43],BA9S(23)[42],BA9T(23)[42],BA9U(23)[42],BA9V(23)[42],\n\ BA9W(23)[42],BA9X(23)[42],BD2A[33],BD2B[33],BD2C[33],BD2D[33],BD2E[33],\n\ BD2F[33],BD2G[33],BD2H[33],BD2I[33],BD2J[33],BD2K[33],BD2L[33],BD2M[33],\n\ BD2N[33],BD2O[33],BD2P[33],BD3G(23)[33],BD3H(23)[33],BD3I(23)[33],\n\ BD3J(23)[33],BD3K(23)[33],BD3L(23)[33],BD6Q[43],BD6R[43],BD6S[43],\n\ BD6T[43],BD6U[43],BD6V[43],BD6W[43],BD6X[43],BD7A[43],BD7B[43],BD7C[43],\n\ BD7D[43],BD7E[43],BD7F[43],BD7G[43],BD7H[43],BD7Q[43],BD7R[43],BD7S[43],\n\ BD7T[43],BD7U[43],BD7V[43],BD7W[43],BD7X[43],BD8A[43],BD8B[43],BD8C[43],\n\ BD8D[43],BD8E[43],BD8F[43],BD8G[43],BD8H[43],BD8I[43],BD8J[43],BD8K[43],\n\ BD8L[43],BD8M[43],BD8N[43],BD8O[43],BD8P[43],BD8Q[43],BD8R[43],BD8S[43],\n\ BD8T[43],BD8U[43],BD8V[43],BD8W[43],BD8X[43],BD9A(24)[43],BD9B(24)[43],\n\ BD9C(24)[43],BD9D(24)[43],BD9E(24)[43],BD9F(24)[43],BD9S(23)[42],\n\ BD9T(23)[42],BD9U(23)[42],BD9V(23)[42],BD9W(23)[42],BD9X(23)[42],BG2A[33],\n\ BG2B[33],BG2C[33],BG2D[33],BG2E[33],BG2F[33],BG2G[33],BG2H[33],BG2I[33],\n\ BG2J[33],BG2K[33],BG2L[33],BG2M[33],BG2N[33],BG2O[33],BG2P[33],\n\ BG3G(23)[33],BG3H(23)[33],BG3I(23)[33],BG3J(23)[33],BG3K(23)[33],\n\ BG3L(23)[33],BG6Q[43],BG6R[43],BG6S[43],BG6T[43],BG6U[43],BG6V[43],\n\ BG6W[43],BG6X[43],BG7A[43],BG7B[43],BG7C[43],BG7D[43],BG7E[43],BG7F[43],\n\ BG7G[43],BG7H[43],BG7Q[43],BG7R[43],BG7S[43],BG7T[43],BG7U[43],BG7V[43],\n\ BG7W[43],BG7X[43],BG8A[43],BG8B[43],BG8C[43],BG8D[43],BG8E[43],BG8F[43],\n\ BG8G[43],BG8H[43],BG8I[43],BG8J[43],BG8K[43],BG8L[43],BG8M[43],BG8N[43],\n\ BG8O[43],BG8P[43],BG8Q[43],BG8R[43],BG8S[43],BG8T[43],BG8U[43],BG8V[43],\n\ BG8W[43],BG8X[43],BG9A(24)[43],BG9B(24)[43],BG9C(24)[43],BG9D(24)[43],\n\ BG9E(24)[43],BG9F(24)[43],BG9S(23)[42],BG9T(23)[42],BG9U(23)[42],\n\ BG9V(23)[42],BG9W(23)[42],BG9X(23)[42],BH2A[33],BH2B[33],BH2C[33],\n\ BH2D[33],BH2E[33],BH2F[33],BH2G[33],BH2H[33],BH2I[33],BH2J[33],BH2K[33],\n\ BH2L[33],BH2M[33],BH2N[33],BH2O[33],BH2P[33],BH3G(23)[33],BH3H(23)[33],\n\ BH3I(23)[33],BH3J(23)[33],BH3K(23)[33],BH3L(23)[33],BH6Q[43],BH6R[43],\n\ BH6S[43],BH6T[43],BH6U[43],BH6V[43],BH6W[43],BH6X[43],BH7A[43],BH7B[43],\n\ BH7C[43],BH7D[43],BH7E[43],BH7F[43],BH7G[43],BH7H[43],BH7Q[43],BH7R[43],\n\ BH7S[43],BH7T[43],BH7U[43],BH7V[43],BH7W[43],BH7X[43],BH8A[43],BH8B[43],\n\ BH8C[43],BH8D[43],BH8E[43],BH8F[43],BH8G[43],BH8H[43],BH8I[43],BH8J[43],\n\ BH8K[43],BH8L[43],BH8M[43],BH8N[43],BH8O[43],BH8P[43],BH8Q[43],BH8R[43],\n\ BH8S[43],BH8T[43],BH8U[43],BH8V[43],BH8W[43],BH8X[43],BH9A(24)[43],\n\ BH9B(24)[43],BH9C(24)[43],BH9D(24)[43],BH9E(24)[43],BH9F(24)[43],\n\ BH9S(23)[42],BH9T(23)[42],BH9U(23)[42],BH9V(23)[42],BH9W(23)[42],\n\ BH9X(23)[42],BI2A[33],BI2B[33],BI2C[33],BI2D[33],BI2E[33],BI2F[33],\n\ BI2G[33],BI2H[33],BI2I[33],BI2J[33],BI2K[33],BI2L[33],BI2M[33],BI2N[33],\n\ BI2O[33],BI2P[33],BI3G(23)[33],BI3H(23)[33],BI3I(23)[33],BI3J(23)[33],\n\ BI3K(23)[33],BI3L(23)[33],BI6Q[43],BI6R[43],BI6S[43],BI6T[43],BI6U[43],\n\ BI6V[43],BI6W[43],BI6X[43],BI7A[43],BI7B[43],BI7C[43],BI7D[43],BI7E[43],\n\ BI7F[43],BI7G[43],BI7H[43],BI7Q[43],BI7R[43],BI7S[43],BI7T[43],BI7U[43],\n\ BI7V[43],BI7W[43],BI7X[43],BI8A[43],BI8B[43],BI8C[43],BI8D[43],BI8E[43],\n\ BI8F[43],BI8G[43],BI8H[43],BI8I[43],BI8J[43],BI8K[43],BI8L[43],BI8M[43],\n\ BI8N[43],BI8O[43],BI8P[43],BI8Q[43],BI8R[43],BI8S[43],BI8T[43],BI8U[43],\n\ BI8V[43],BI8W[43],BI8X[43],BI9A(24)[43],BI9B(24)[43],BI9C(24)[43],\n\ BI9D(24)[43],BI9E(24)[43],BI9F(24)[43],BI9S(23)[42],BI9T(23)[42],\n\ BI9U(23)[42],BI9V(23)[42],BI9W(23)[42],BI9X(23)[42],BJ2A[33],BJ2B[33],\n\ BJ2C[33],BJ2D[33],BJ2E[33],BJ2F[33],BJ2G[33],BJ2H[33],BJ2I[33],BJ2J[33],\n\ BJ2K[33],BJ2L[33],BJ2M[33],BJ2N[33],BJ2O[33],BJ2P[33],BJ3G(23)[33],\n\ BJ3H(23)[33],BJ3I(23)[33],BJ3J(23)[33],BJ3K(23)[33],BJ3L(23)[33],BJ6Q[43],\n\ BJ6R[43],BJ6S[43],BJ6T[43],BJ6U[43],BJ6V[43],BJ6W[43],BJ6X[43],BJ7A[43],\n\ BJ7B[43],BJ7C[43],BJ7D[43],BJ7E[43],BJ7F[43],BJ7G[43],BJ7H[43],BJ7Q[43],\n\ BJ7R[43],BJ7S[43],BJ7T[43],BJ7U[43],BJ7V[43],BJ7W[43],BJ7X[43],BJ8A[43],\n\ BJ8B[43],BJ8C[43],BJ8D[43],BJ8E[43],BJ8F[43],BJ8G[43],BJ8H[43],BJ8I[43],\n\ BJ8J[43],BJ8K[43],BJ8L[43],BJ8M[43],BJ8N[43],BJ8O[43],BJ8P[43],BJ8Q[43],\n\ BJ8R[43],BJ8S[43],BJ8T[43],BJ8U[43],BJ8V[43],BJ8W[43],BJ8X[43],\n\ BJ9A(24)[43],BJ9B(24)[43],BJ9C(24)[43],BJ9D(24)[43],BJ9E(24)[43],\n\ BJ9F(24)[43],BJ9S(23)[42],BJ9T(23)[42],BJ9U(23)[42],BJ9V(23)[42],\n\ BJ9W(23)[42],BJ9X(23)[42],BL2A[33],BL2B[33],BL2C[33],BL2D[33],BL2E[33],\n\ BL2F[33],BL2G[33],BL2H[33],BL2I[33],BL2J[33],BL2K[33],BL2L[33],BL2M[33],\n\ BL2N[33],BL2O[33],BL2P[33],BL3G(23)[33],BL3H(23)[33],BL3I(23)[33],\n\ BL3J(23)[33],BL3K(23)[33],BL3L(23)[33],BL6Q[43],BL6R[43],BL6S[43],\n\ BL6T[43],BL6U[43],BL6V[43],BL6W[43],BL6X[43],BL7A[43],BL7B[43],BL7C[43],\n\ BL7D[43],BL7E[43],BL7F[43],BL7G[43],BL7H[43],BL7Q[43],BL7R[43],BL7S[43],\n\ BL7T[43],BL7U[43],BL7V[43],BL7W[43],BL7X[43],BL8A[43],BL8B[43],BL8C[43],\n\ BL8D[43],BL8E[43],BL8F[43],BL8G[43],BL8H[43],BL8I[43],BL8J[43],BL8K[43],\n\ BL8L[43],BL8M[43],BL8N[43],BL8O[43],BL8P[43],BL8Q[43],BL8R[43],BL8S[43],\n\ BL8T[43],BL8U[43],BL8V[43],BL8W[43],BL8X[43],BL9A(24)[43],BL9B(24)[43],\n\ BL9C(24)[43],BL9D(24)[43],BL9E(24)[43],BL9F(24)[43],BL9S(23)[42],\n\ BL9T(23)[42],BL9U(23)[42],BL9V(23)[42],BL9W(23)[42],BL9X(23)[42],BT2A[33],\n\ BT2B[33],BT2C[33],BT2D[33],BT2E[33],BT2F[33],BT2G[33],BT2H[33],BT2I[33],\n\ BT2J[33],BT2K[33],BT2L[33],BT2M[33],BT2N[33],BT2O[33],BT2P[33],\n\ BT3G(23)[33],BT3H(23)[33],BT3I(23)[33],BT3J(23)[33],BT3K(23)[33],\n\ BT3L(23)[33],BT6Q[43],BT6R[43],BT6S[43],BT6T[43],BT6U[43],BT6V[43],\n\ BT6W[43],BT6X[43],BT7A[43],BT7B[43],BT7C[43],BT7D[43],BT7E[43],BT7F[43],\n\ BT7G[43],BT7H[43],BT7Q[43],BT7R[43],BT7S[43],BT7T[43],BT7U[43],BT7V[43],\n\ BT7W[43],BT7X[43],BT8A[43],BT8B[43],BT8C[43],BT8D[43],BT8E[43],BT8F[43],\n\ BT8G[43],BT8H[43],BT8I[43],BT8J[43],BT8K[43],BT8L[43],BT8M[43],BT8N[43],\n\ BT8O[43],BT8P[43],BT8Q[43],BT8R[43],BT8S[43],BT8T[43],BT8U[43],BT8V[43],\n\ BT8W[43],BT8X[43],BT9A(24)[43],BT9B(24)[43],BT9C(24)[43],BT9D(24)[43],\n\ BT9E(24)[43],BT9F(24)[43],BT9S(23)[42],BT9T(23)[42],BT9U(23)[42],\n\ BT9V(23)[42],BT9W(23)[42],BT9X(23)[42],BY2A[33],BY2B[33],BY2C[33],\n\ BY2D[33],BY2E[33],BY2F[33],BY2G[33],BY2H[33],BY2I[33],BY2J[33],BY2K[33],\n\ BY2L[33],BY2M[33],BY2N[33],BY2O[33],BY2P[33],BY3G(23)[33],BY3H(23)[33],\n\ BY3I(23)[33],BY3J(23)[33],BY3K(23)[33],BY3L(23)[33],BY6Q[43],BY6R[43],\n\ BY6S[43],BY6T[43],BY6U[43],BY6V[43],BY6W[43],BY6X[43],BY7A[43],BY7B[43],\n\ BY7C[43],BY7D[43],BY7E[43],BY7F[43],BY7G[43],BY7H[43],BY7Q[43],BY7R[43],\n\ BY7S[43],BY7T[43],BY7U[43],BY7V[43],BY7W[43],BY7X[43],BY8A[43],BY8B[43],\n\ BY8C[43],BY8D[43],BY8E[43],BY8F[43],BY8G[43],BY8H[43],BY8I[43],BY8J[43],\n\ BY8K[43],BY8L[43],BY8M[43],BY8N[43],BY8O[43],BY8P[43],BY8Q[43],BY8R[43],\n\ BY8S[43],BY8T[43],BY8U[43],BY8V[43],BY8W[43],BY8X[43],BY9A(24)[43],\n\ BY9B(24)[43],BY9C(24)[43],BY9D(24)[43],BY9E(24)[43],BY9F(24)[43],\n\ BY9S(23)[42],BY9T(23)[42],BY9U(23)[42],BY9V(23)[42],BY9W(23)[42],\n\ BY9X(23)[42],BZ2A[33],BZ2B[33],BZ2C[33],BZ2D[33],BZ2E[33],BZ2F[33],\n\ BZ2G[33],BZ2H[33],BZ2I[33],BZ2J[33],BZ2K[33],BZ2L[33],BZ2M[33],BZ2N[33],\n\ BZ2O[33],BZ2P[33],BZ3G(23)[33],BZ3H(23)[33],BZ3I(23)[33],BZ3J(23)[33],\n\ BZ3K(23)[33],BZ3L(23)[33],BZ6Q[43],BZ6R[43],BZ6S[43],BZ6T[43],BZ6U[43],\n\ BZ6V[43],BZ6W[43],BZ6X[43],BZ7A[43],BZ7B[43],BZ7C[43],BZ7D[43],BZ7E[43],\n\ BZ7F[43],BZ7G[43],BZ7H[43],BZ7Q[43],BZ7R[43],BZ7S[43],BZ7T[43],BZ7U[43],\n\ BZ7V[43],BZ7W[43],BZ7X[43],BZ8A[43],BZ8B[43],BZ8C[43],BZ8D[43],BZ8E[43],\n\ BZ8F[43],BZ8G[43],BZ8H[43],BZ8I[43],BZ8J[43],BZ8K[43],BZ8L[43],BZ8M[43],\n\ BZ8N[43],BZ8O[43],BZ8P[43],BZ8Q[43],BZ8R[43],BZ8S[43],BZ8T[43],BZ8U[43],\n\ BZ8V[43],BZ8W[43],BZ8X[43],BZ9A(24)[43],BZ9B(24)[43],BZ9C(24)[43],\n\ BZ9D(24)[43],BZ9E(24)[43],BZ9F(24)[43],BZ9S(23)[42],BZ9T(23)[42],\n\ BZ9U(23)[42],BZ9V(23)[42],BZ9W(23)[42],BZ9X(23)[42];\n\ Nauru: 31: 65: OC: -0.52: -166.92: -12.0: C2:\n\ C2;\n\ Andorra: 14: 27: EU: 42.58: -1.62: -1.0: C3:\n\ C3;\n\ The Gambia: 35: 46: AF: 13.40: 16.38: 0.0: C5:\n\ C5;\n\ Bahamas: 08: 11: NA: 24.25: 76.00: 5.0: C6:\n\ C6;\n\ Mozambique: 37: 53: AF: -18.25: -35.00: -2.0: C9:\n\ C8,C9;\n\ Chile: 12: 14: SA: -30.00: 71.00: 4.0: CE:\n\ 3G,CA,CB,CC,CD,CE,XQ,XR,3G7[16],3G8[16],CA7[16],CA8[16],CB7[16],CB8[16],\n\ CC7[16],CC8[16],CD7[16],CD8[16],CE7[16],CE8[16],XQ7[16],XQ8[16],XR7[16],\n\ XR8[16],=XQ6CFX[16],=XQ6OA[16];\n\ San Felix & San Ambrosio: 12: 14: SA: -26.28: 80.07: 4.0: CE0X:\n\ 3G0X,CA0X,CB0X,CC0X,CD0X,CE0X,XQ0X,XR0X;\n\ Easter Island: 12: 63: SA: -27.10: 109.37: 6.0: CE0Y:\n\ 3G0,CA0,CB0,CC0,CD0,CE0,XQ0,XR0;\n\ Juan Fernandez Islands: 12: 14: SA: -33.60: 78.85: 4.0: CE0Z:\n\ 3G0Z,CA0Z,CB0Z,CC0Z,CD0Z,CE0I,CE0Z,XQ0Z,XR0Z;\n\ Antarctica: 13: 74: SA: -90.00: 0.00: 0.0: CE9:\n\ 3Y[73],AX0(39)[69],AY1Z[73],AY2Z[73],AY3Z[73],AY4Z[73],AY5Z[73],AY6Z[73],\n\ AY7Z[73],AY8Z[73],AY9Z[73],FT0Y(30)[70],FT1Y(30)[70],FT2Y(30)[70],\n\ FT3Y(30)[70],FT4Y(30)[70],FT5Y(30)[70],FT6Y(30)[70],FT7Y(30)[70],\n\ FT8Y(30)[70],LU1Z[73],LU2Z[73],LU3Z[73],LU4Z[73],LU5Z[73],LU6Z[73],\n\ LU7Z[73],LU8Z[73],LU9Z[73],RI1AN(29)[69],VI0(39)[69],VK0(39)[69],\n\ ZL5(30)[71],ZM5(30)[71],ZS7(38)[67],=8J1RL(39)[67],=DP0GVN(38)[67],\n\ =DP1POL(38)[67],=KC4AAA(39),=KC4AAC[73],=KC4USB(12),=KC4USV(30)[71],\n\ =LU3HRS/Z[73],=RI1ANC(29)[70],=VP8AL[73];\n\ Cuba: 08: 11: NA: 21.50: 80.00: 5.0: CM:\n\ CL,CM,CO,T4;\n\ Morocco: 33: 37: AF: 32.00: 5.00: 0.0: CN:\n\ 5C,5D,5E,5F,5G,CN;\n\ Bolivia: 10: 12: SA: -17.00: 65.00: 4.0: CP:\n\ CP,CP2[14],CP3[14],CP4[14],CP5[14],CP6[14],CP7[14];\n\ Portugal: 14: 37: EU: 39.50: 8.00: 0.0: CT:\n\ CQ,CR,CS,CT;\n\ Madeira Islands: 33: 36: AF: 32.75: 16.95: 0.0: CT3:\n\ CQ2,CQ3,CQ9,CR3,CR9,CS3,CS9,CT3,CT9;\n\ Azores: 14: 36: EU: 38.70: 27.23: 1.0: CU:\n\ CQ1,CQ8,CR1,CR2,CR8,CS4,CS8,CT8,CU;\n\ Uruguay: 13: 14: SA: -33.00: 56.00: 3.0: CX:\n\ CV,CW,CX;\n\ Sable Island: 05: 09: NA: 43.93: 59.90: 4.0: CY0:\n\ CY0;\n\ St. Paul Island: 05: 09: NA: 47.00: 60.00: 4.0: CY9:\n\ CY9;\n\ Angola: 36: 52: AF: -12.50: -18.50: -1.0: D2:\n\ D2,D3;\n\ Cape Verde: 35: 46: AF: 16.00: 24.00: 1.0: D4:\n\ D4;\n\ Comoros: 39: 53: AF: -11.63: -43.30: -3.0: D6:\n\ D6;\n\ Fed. Rep. of Germany: 14: 28: EU: 51.00: -10.00: -1.0: DL:\n\ DA,DB,DC,DD,DE,DF,DG,DH,DI,DJ,DK,DL,DM,DN,DO,DP,DQ,DR,Y2,Y3,Y4,Y5,Y6,Y7,\n\ Y8,Y9;\n\ Philippines: 27: 50: OC: 13.00: -122.00: -8.0: DU:\n\ 4D,4E,4F,4G,4H,4I,DU,DV,DW,DX,DY,DZ;\n\ Eritrea: 37: 48: AF: 15.00: -39.00: -3.0: E3:\n\ E3;\n\ Palestine: 20: 39: AS: 31.28: -34.27: -2.0: E4:\n\ E4;\n\ North Cook Islands: 32: 62: OC: -10.02: 161.08: 10.0: E5/n:\n\ =E51PT,=E51WL[63];\n\ South Cook Islands: 32: 63: OC: -21.90: 157.93: 10.0: E5/s:\n\ E5;\n\ Niue: 32: 62: OC: -19.03: 169.85: 11.0: E6:\n\ E6;\n\ Bosnia-Herzegovina: 15: 28: EU: 44.32: -17.57: -1.0: E7:\n\ E7;\n\ Spain: 14: 37: EU: 40.37: 4.88: -1.0: EA:\n\ AM,AN,AO,EA,EB,EC,ED,EE,EF,EG,EH,=EA2EZ/P,=EA5CC/P,=EA5EZ/P,=EA5URE/P,\n\ =EA5ZD/URE,=EA9HU;\n\ Balearic Islands: 14: 37: EU: 39.60: -2.95: -1.0: EA6:\n\ AM6,AN6,AO6,EA6,EB6,EC6,ED6,EE6,EF6,EG6,EH6;\n\ Canary Islands: 33: 36: AF: 28.32: 15.85: 0.0: EA8:\n\ AM8,AN8,AO8,EA8,EB8,EC8,ED8,EE8,EF8,EG8,EH8,=EA2EJO/8,=EA8VK/URE;\n\ Ceuta & Melilla: 33: 37: AF: 35.90: 5.27: -1.0: EA9:\n\ AM9,AN9,AO9,EA9,EB9,EC9,ED9,EE9,EF9,EG9,EH9;\n\ Ireland: 14: 27: EU: 53.13: 8.02: 0.0: EI:\n\ EI,EJ;\n\ Armenia: 21: 29: AS: 40.40: -44.90: -4.0: EK:\n\ EK;\n\ Liberia: 35: 46: AF: 6.50: 9.50: 0.0: EL:\n\ 5L,5M,6Z,A8,D5,EL;\n\ Iran: 21: 40: AS: 32.00: -53.00: -3.5: EP:\n\ 9B,9C,9D,EP,EQ;\n\ Moldova: 16: 29: EU: 47.00: -29.00: -2.0: ER:\n\ ER;\n\ Estonia: 15: 29: EU: 59.00: -25.00: -2.0: ES:\n\ ES;\n\ Ethiopia: 37: 48: AF: 9.00: -39.00: -3.0: ET:\n\ 9E,9F,ET;\n\ Belarus: 16: 29: EU: 54.00: -28.00: -2.0: EU:\n\ EU,EV,EW;\n\ Kyrgyzstan: 17: 30: AS: 41.70: -74.13: -6.0: EX:\n\ EX,EX0P[31],EX0Q[31],EX2P[31],EX2Q[31],EX6P[31],EX6Q[31],EX7P[31],\n\ EX7Q[31],EX8P[31],EX8Q[31];\n\ Tajikistan: 17: 30: AS: 38.82: -71.22: -5.0: EY:\n\ EY;\n\ Turkmenistan: 17: 30: AS: 38.00: -58.00: -5.0: EZ:\n\ EZ;\n\ France: 14: 27: EU: 46.00: -2.00: -1.0: F:\n\ F,HW,HX,HY,TH,TM,TP,TQ,TV;\n\ Guadeloupe: 08: 11: NA: 16.13: 61.67: 4.0: FG:\n\ FG,=TO10CWO;\n\ Mayotte: 39: 53: AF: -12.88: -45.15: -3.0: FH:\n\ FH;\n\ St. Barthelemy: 08: 11: NA: 17.90: 62.83: 4.0: FJ:\n\ FJ;\n\ New Caledonia: 32: 56: OC: -21.50: -165.50: -11.0: FK:\n\ FK;\n\ Chesterfield Islands: 30: 56: OC: -19.87: -158.32: -11.0: FK/c:\n\ =TX3X;\n\ Martinique: 08: 11: NA: 14.70: 61.03: 4.0: FM:\n\ FM,=TO5A,=TO5T,=TO7A;\n\ French Polynesia: 32: 63: OC: -17.65: 149.40: 10.0: FO:\n\ FO,=TX0T;\n\ Austral Islands: 32: 63: OC: -23.37: 149.48: 10.0: FO/a:\n\ =TX2A;\n\ Clipperton Island: 07: 10: NA: 10.28: 109.22: 8.0: FO/c:\n\ =TX5P;\n\ Marquesas Islands: 31: 63: OC: -8.92: 140.07: 9.5: FO/m:\n\ =FO/F6BCW;\n\ St. Pierre & Miquelon: 05: 09: NA: 46.77: 56.20: 3.0: FP:\n\ FP;\n\ Reunion Island: 39: 53: AF: -21.12: -55.48: -4.0: FR:\n\ FR;\n\ St. Martin: 08: 11: NA: 18.08: 63.03: 4.0: FS:\n\ FS;\n\ Glorioso Islands: 39: 53: AF: -11.55: -47.28: -4.0: FT/g:\n\ FT0G,FT1G,FT2G,FT3G,FT4G,FT5G,FT6G,FT7G,FT8G,FT9G;\n\ Juan de Nova, Europa: 39: 53: AF: -17.05: -42.72: -3.0: FT/j:\n\ FT0E,FT0J,FT1E,FT1J,FT2E,FT2J,FT3E,FT3J,FT4E,FT4J,FT6E,FT6J,FT7E,FT7J,\n\ FT8E,FT8J,FT9E,FT9J;\n\ Tromelin Island: 39: 53: AF: -15.88: -54.50: -4.0: FT/t:\n\ FT0T,FT1T,FT2T,FT3T,FT4T,FT5T,FT6T,FT7T,FT8T,FT9T;\n\ Crozet Island: 39: 68: AF: -46.42: -51.75: -5.0: FT/w:\n\ FT0W,FT4W,FT5W,FT8W;\n\ Kerguelen Islands: 39: 68: AF: -49.00: -69.27: -5.0: FT/x:\n\ FT0X,FT2X,FT4X,FT5X,FT8X;\n\ Amsterdam & St. Paul Is.: 39: 68: AF: -37.85: -77.53: -5.0: FT/z:\n\ FT0Z,FT1Z,FT2Z,FT3Z,FT4Z,FT5Z,FT6Z,FT7Z,FT8Z;\n\ Wallis & Futuna Islands: 32: 62: OC: -13.30: 176.20: -12.0: FW:\n\ FW,TW;\n\ French Guiana: 09: 12: SA: 4.00: 53.00: 3.0: FY:\n\ FY,=TO1A;\n\ England: 14: 27: EU: 52.77: 1.47: 0.0: G:\n\ 2E,G,M,=2E0CVN/NHS;\n\ Isle of Man: 14: 27: EU: 54.20: 4.53: 0.0: GD:\n\ 2D,GD,GT,MD,MT;\n\ Northern Ireland: 14: 27: EU: 54.73: 6.68: 0.0: GI:\n\ 2I,GI,GN,MI,MN,=2I0NGM/NHS,=GB3NGI,=GB5NHS,=GB8NHS,=GB9AFD;\n\ Jersey: 14: 27: EU: 49.22: 2.18: 0.0: GJ:\n\ 2J,GH,GJ,MH,MJ,=GH5DX/NHS;\n\ Shetland Islands: 14: 27: EU: 60.50: 1.50: 0.0: *GM/s:\n\ =2M0BDR,=2M0BDT,=2M0CPN,=2M0GFC,=2M0SEG,=2M0SPX,=2M0ZET,=GB2ELH,=GB3LER,\n\ =GB3LER/B,=GB4LER,=GM0AVR,=GM0CXQ,=GM0EKM,=GM0GFL,=GM0ILB,=GM0JDB,=GM1FGN,\n\ =GM1KKI,=GM1ZNR,=GM3WHT,=GM3ZET,=GM4IPK,=GM4JPI,=GM4LBE,=GM4LER,=GM4PXG,\n\ =GM4SLV,=GM4SSA,=GM4WXQ,=GM4ZHL,=GM6RQW,=GM6YQA,=GM7AFE,=GM7GWW,=GM8LNH,\n\ =GM8MMA,=GM8YEC,=GS3ZET,=MM0LSM,=MM0NQY,=MM0VIK,=MM0XAU,=MM0ZAL,=MM0ZCG,\n\ =MM0ZRC,=MM1FEO,=MM1FJM,=MM3VQO,=MM5PSL,=MM5YLO,=MM6BDU,=MM6BZQ,=MM6IKB,\n\ =MM6IMB,=MM6MFA,=MM6PTE,=MM6SJK,=MM6YLO,=MM6ZBG,=MM6ZDW,=MM7CGR,=MM8A,\n\ =MS0ZCG,=MS0ZET;\n\ Scotland: 14: 27: EU: 56.82: 4.18: 0.0: GM:\n\ 2A,2M,GM,GS,MA,MM,MS,=GB0CSG,=GB0SJR,=GB1RST,=GB2ELH,=GB2FEA,=GB2JCM,\n\ =GB2OWM,=GB2SBS,=GB3ANG,=GB3LER,=GB3LER/B,=GB4LER,=GM0WED/NHS,=GM3YDN/NHS,\n\ =GM4SQM/NHS,=GM4SQN/NHS,=GM6JNJ/NHS,=MM0DHQ/NHS,=MM3AWD/NHS,=MM3DDQ/NHS,\n\ =MM7WAB/NHS;\n\ Guernsey: 14: 27: EU: 49.45: 2.58: 0.0: GU:\n\ 2U,GP,GU,MP,MU,=GB100RS;\n\ Wales: 14: 27: EU: 52.28: 3.73: 0.0: GW:\n\ 2W,GC,GW,MC,MW,=GB1LWF,=GB1RTF,=GB1WIW,=GB2VK;\n\ Solomon Islands: 28: 51: OC: -9.00: -160.00: -11.0: H4:\n\ H4;\n\ Temotu Province: 32: 51: OC: -10.72: -165.80: -11.0: H40:\n\ H40;\n\ Hungary: 15: 28: EU: 47.12: -19.28: -1.0: HA:\n\ HA,HG;\n\ Switzerland: 14: 28: EU: 46.87: -8.12: -1.0: HB:\n\ HB,HE;\n\ Liechtenstein: 14: 28: EU: 47.13: -9.57: -1.0: HB0:\n\ HB0,HE0;\n\ Ecuador: 10: 12: SA: -1.40: 78.40: 5.0: HC:\n\ HC,HD;\n\ Galapagos Islands: 10: 12: SA: -0.78: 91.03: 6.0: HC8:\n\ HC8,HD8;\n\ Haiti: 08: 11: NA: 19.02: 72.18: 5.0: HH:\n\ 4V,HH;\n\ Dominican Republic: 08: 11: NA: 19.13: 70.68: 4.0: HI:\n\ HI;\n\ Colombia: 09: 12: SA: 5.00: 74.00: 5.0: HK:\n\ 5J,5K,HJ,HK;\n\ San Andres & Providencia: 07: 11: NA: 12.55: 81.72: 5.0: HK0/a:\n\ 5J0,5K0,HJ0,HK0;\n\ Malpelo Island: 09: 12: SA: 3.98: 81.58: 5.0: HK0/m:\n\ HJ0M,HK0M,=HK0TU;\n\ Republic of Korea: 25: 44: AS: 36.23: -127.90: -9.0: HL:\n\ 6K,6L,6M,6N,D7,D8,D9,DS,DT,HL,KL9K;\n\ Panama: 07: 11: NA: 9.00: 80.00: 5.0: HP:\n\ 3E,3F,H3,H8,H9,HO,HP;\n\ Honduras: 07: 11: NA: 15.00: 87.00: 6.0: HR:\n\ HQ,HR;\n\ Thailand: 26: 49: AS: 12.60: -99.70: -7.0: HS:\n\ E2,HS;\n\ Vatican City: 15: 28: EU: 41.90: -12.47: -1.0: HV:\n\ HV;\n\ Saudi Arabia: 21: 39: AS: 24.20: -43.83: -3.0: HZ:\n\ 7Z,8Z,HZ;\n\ Italy: 15: 28: EU: 42.82: -12.58: -1.0: I:\n\ I,=4U0WFP,=4U5F,=4U75B,=IT9ELM/0,=IT9PQJ/0;\n\ African Italy: 33: 37: AF: 35.67: -12.67: -1.0: *IG9:\n\ IG9,IH9;\n\ Sardinia: 15: 28: EU: 40.15: -9.27: -1.0: IS:\n\ IM0,IS,IW0U,IW0V,IW0W,IW0X,IW0Y,IW0Z,=II0GD,=II0ICH,=II0IDP,=II0M,=IQ0AG,\n\ =IQ0AH,=IQ0AI,=IQ0AK,=IQ0AK/P,=IQ0AL,=IQ0AM,=IQ0EH,=IQ0HO,=IQ0ID,=IQ0JY,\n\ =IQ0NU,=IQ0NV,=IQ0NV/P,=IQ0OG,=IQ0OH,=IQ0QP,=IQ0SS,=IY0GA;\n\ Sicily: 15: 28: EU: 37.50: -14.00: -1.0: *IT9:\n\ IB9,ID9,IE9,IF9,II9,IJ9,IO9,IQ9,IR9,IT9,IU9,IW9,IY9,=IQ6KX/9;\n\ Djibouti: 37: 48: AF: 11.75: -42.35: -3.0: J2:\n\ J2;\n\ Grenada: 08: 11: NA: 12.13: 61.68: 4.0: J3:\n\ J3;\n\ Guinea-Bissau: 35: 46: AF: 12.02: 14.80: 0.0: J5:\n\ J5;\n\ St. Lucia: 08: 11: NA: 13.87: 61.00: 4.0: J6:\n\ J6;\n\ Dominica: 08: 11: NA: 15.43: 61.35: 4.0: J7:\n\ J7;\n\ St. Vincent: 08: 11: NA: 13.23: 61.20: 4.0: J8:\n\ J8;\n\ Japan: 25: 45: AS: 36.40: -138.38: -9.0: JA:\n\ 7J,7K,7L,7M,7N,8J,8K,8L,8M,8N,JA,JE,JF,JG,JH,JI,JJ,JK,JL,JM,JN,JO,JP,JQ,\n\ JR,JS;\n\ Minami Torishima: 27: 90: OC: 24.28: -153.97: -10.0: JD/m:\n\ =JG8NQJ/JD1;\n\ Ogasawara: 27: 45: AS: 27.05: -142.20: -9.0: JD/o:\n\ JD1;\n\ Mongolia: 23: 32: AS: 46.77: -102.17: -7.0: JT:\n\ JT,JU,JV,JT2[33],JT3[33],JU2[33],JU3[33],JV2[33],JV3[33];\n\ Svalbard: 40: 18: EU: 78.00: -16.00: -1.0: JW:\n\ JW;\n\ Bear Island: 40: 18: EU: 74.43: -19.08: -1.0: *JW/b:\n\ =JW/LB2PG;\n\ Jan Mayen: 40: 18: EU: 71.05: 8.28: 1.0: JX:\n\ JX;\n\ Jordan: 20: 39: AS: 31.18: -36.42: -2.0: JY:\n\ JY;\n\ United States: 05: 08: NA: 37.53: 91.67: 5.0: K:\n\ AA,AB,AC,AD,AE,AF,AG,AI,AJ,AK,K,N,W,=4U1WB(5)[8],=AA0O(5)[8],=AA2IL(3)[6],\n\ =AA4DD(4)[8],=AA4Q(3)[6],=AA5JF(5)[8],=AA8R(5)[8],=AB4B(4)[8],\n\ =AB4GG(4)[8],=AB4IQ(4)[8],=AB8RL(5)[8],=AB8YZ(4)[7],=AC4CA(4)[7],\n\ =AC4G(4)[8],=AC4GW(4)[8],=AC6WI(5)[8],=AC6ZM(4)[8],=AC7AF(4)[7],\n\ =AC8Y(5)[8],=AC9TO(4)[7],=AD1C(4)[7],=AD4EB(4)[8],=AD4TA(4)[8],\n\ =AD8J(5)[8],=AE4ED(4)[8],=AE6JV(5)[8],=AE7AP(4)[6],=AF4T(4)[8],\n\ =AG4W(4)[8],=AH0U(3)[6],=AH2AV(4)[8],=AH2O(5)[8],=AH6FF(4)[8],\n\ =AI4DB(4)[8],=AI6O(4)[7],=AI9K(4)[7],=AJ4A(4)[8],=AJ4F(4)[7],=AJ7G(5)[8],\n\ =AL0A(5)[8],=AL1VE(3)[6],=AL4B(4)[8],=AL7CR(3)[6],=AL7RF(3)[6],\n\ =G8ERJ(5)[8],=K0ACP(4)[8],=K0EJ(4)[8],=K0IP(3)[6],=K0LUZ(5)[8],\n\ =K0NW(3)[6],=K0PJ(4)[8],=K0SN(4)[6],=K0TQ(4)[8],=K0ZR(5)[8],=K1DC(4)[8],\n\ =K1DW(4)[7],=K1GU(4)[8],=K1KD(4)[7],=K1LT(4)[8],=K1OU(4)[8],=K2DRH(4)[7],\n\ =K2DSW(4)[7],=K2GMY(3)[6],=K2KR(4)[7],=K2PM(4)[8],=K2PO(3)[6],=K2RD(3)[6],\n\ =K2RP(3)[6],=K2UR(4)[8],=K2VV(4)[7],=K3DMG(4)[8],=K3EST(3)[6],=K3IE(4)[8],\n\ =K3JWI(4)[8],=K3NT(4)[7],=K3PA(4)[7],=K3WT(4)[7],=K3WYC(3)[6],=K3YP(4)[8],\n\ =K4AB(4)[8],=K4AFE(4)[8],=K4AMC(4)[8],=K4AVX(4)[8],=K4BWP(4)[8],\n\ =K4BX(4)[8],=K4CWW(4)[8],=K4FN(4)[8],=K4FT(4)[8],=K4IE(4)[8],=K4IU(4)[7],\n\ =K4OAQ(4)[8],=K4OWR(4)[8],=K4RO(4)[8],=K4TCG(4)[8],=K4TZ(4)[8],\n\ =K4UU(4)[8],=K4WG(4)[8],=K4WI(4)[8],=K4WW(4)[8],=K4XU(3)[6],=K4YJ(4)[8],\n\ =K4ZGB(4)[8],=K5EK(5)[8],=K5GDX(4)[8],=K5KG(5)[8],=K5OA(3)[6],\n\ =K5VIP(5)[8],=K5ZD(5)[8],=K6BFL(4)[7],=K6XT(4)[7],=K7ABV(4)[6],\n\ =K7BG(4)[7],=K7BV(5)[8],=K7CS(4)[8],=K7DR(4)[8],=K7IA(4)[7],=K7MSO(4)[6],\n\ =K7OM(5)[8],=K7QA(4)[6],=K7SCX(4)[7],=K7SV(5)[8],=K7TD(4)[7],=K8AC(5)[8],\n\ =K8ARY(5)[8],=K8CN(5)[8],=K8IA(3)[6],=K8JQ(5)[8],=K8LBQ(5)[8],=K8LF(5)[8],\n\ =K8LS(4)[7],=K8NYG(5)[8],=K8PO(5)[8],=K8TE(4)[7],=K8TR(3)[6],=K9CHP(5)[8],\n\ =K9DR(4)[7],=K9DU(4)[7],=K9GWS(5)[8],=K9JF(3)[6],=K9JM(3)[6],=K9OM(5)[8],\n\ =K9OZ(4)[7],=K9RS(5)[8],=K9WA(4)[7],=K9WZB(3)[6],=K9YC(3)[6],\n\ =KA3MTT(4)[8],=KA4GAV(4)[7],=KA4OTB(4)[8],=KA8HDE(4)[7],=KA8Q(5)[8],\n\ =KA9FOX(4)[7],=KA9VVQ(4)[7],=KB4QZH(4)[8],=KB7Q(4)[6],=KB9S(4)[7],\n\ =KC2LM(4)[7],=KC4HW(4)[8],=KC4NX(4)[8],=KC4SAW(4)[8],=KC4TEO(4)[8],\n\ =KC4WQ(4)[8],=KC7QY(4)[7],=KC8GCR(5)[8],=KC8J(3)[6],=KC9K(4)[7],\n\ =KD0EE(4)[8],=KD2KW(4)[7],=KD4EE(4)[8],=KD4TRG(4)[8],=KD5DD(4)[8],\n\ =KE0L(4)[8],=KE0YI(4)[8],=KE1B(3)[6],=KE2VB(3)[6],=KE3K(4)[8],\n\ =KE4KY(4)[8],=KE8FT(3)[6],=KF4AV(4)[8],=KF5BA(4)[8],=KF5MU(4)[8],\n\ =KG0F(3)[6],=KG4CUY(4)[8],=KG5HVO(4)[8],=KH2BR(3)[6],=KH2D(5)[8],\n\ =KH2GM(4)[8],=KH2PM(5)[8],=KH2TJ(3)[6],=KH6CT(5)[8],=KH6DHK(5)[8],\n\ =KH6M(5)[8],=KH6VM(3)[6],=KH6XS(3)[6],=KI6DY(4)[8],=KI6QDH(4)[7],\n\ =KI7ID(4)[7],=KJ4AOM(4)[8],=KJ4IWZ(4)[8],=KJ4M(4)[8],=KJ9C(4)[6],\n\ =KK9A(5)[8],=KK9N(4)[7],=KL0SS(5)[8],=KL1SE(4)[8],=KL2AX(4)[7],\n\ =KL2RA(4)[7],=KL4CZ(4)[6],=KL7DJ(3)[6],=KL7HQR(3)[6],=KL7IKV(3)[6],\n\ =KL7NW(4)[7],=KL7QW(4)[7],=KL7SK(3)[6],=KM4FO(4)[8],=KM4JA(4)[8],\n\ =KM6Z(4)[8],=KM7W(4)[6],=KN1CBR(4)[7],=KN8U(5)[8],=KO4OL(4)[8],\n\ =KO8SCA(5)[8],=KO8V(5)[8],=KO9V(4)[7],=KP3M(5)[8],=KP4MD(3)[6],\n\ =KR4F(4)[8],=KS0CW(5)[8],=KS4X(4)[8],=KS7T(4)[6],=KS9W(4)[7],=KT3M(4)[7],\n\ =KT4O(4)[8],=KT4RR(4)[8],=KU1CW(3)[6],=KU8E(5)[8],=KV4T(4)[8],=KV8S(4)[7],\n\ =KW4J(4)[8],=KW7D(4)[7],=KW7Q(4)[7],=KX2P(4)[7],=KX4X(4)[8],=KY0Q(4)[8],\n\ =KZ1W(3)[6],=KZ4KX(4)[8],=KZ9V(4)[7],=N0SMX(5)[8],=N1JM(3)[6],=N1XK(4)[7],\n\ =N2AU(3)[6],=N2BJ(4)[8],=N2IC(4)[7],=N2JNR(3)[6],=N2NL(4)[8],=N3BB(4)[7],\n\ =N3CI(4)[7],=N3RA(4)[8],=N3RC(3)[6],=N3ZZ(3)[6],=N4ARO(4)[8],=N4AU(4)[8],\n\ =N4BAA(4)[8],=N4BCD(4)[8],=N4DW(4)[8],=N4EL(4)[8],=N4JRG(4)[8],\n\ =N4KC(4)[8],=N4KH(4)[8],=N4NA(4)[8],=N4NO(4)[8],=N4OGW(4)[8],=N4QS(4)[8],\n\ =N4SL(4)[6],=N4TZ(4)[8],=N4UC(4)[8],=N4UW(4)[8],=N4VI(4)[7],=N4VV(4)[8],\n\ =N4WE(4)[8],=N4ZY(4)[8],=N4ZZ(4)[8],=N5CR(3)[6],=N5CW(4)[8],=N5DX(5)[8],\n\ =N5KO(3)[6],=N5RP(4)[8],=N5SMQ(5)[8],=N5TB(5)[8],=N5TOO(5)[8],=N5YT(4)[8],\n\ =N5ZO(3)[6],=N6AR(5)[8],=N6DW(5)[8],=N6RSH(4)[7],=N7DR(4)[7],=N7IP(4)[6],\n\ =N7IV(4)[7],=N7MZW(4)[7],=N7NG(4)[7],=N7RCS(5)[8],=N7US(4)[8],=N7WY(4)[7],\n\ =N7ZZ(4)[8],=N8AID(5)[8],=N8GU(5)[8],=N8II(5)[8],=N8NA(5)[8],=N8NN(5)[8],\n\ =N8OO(4)[7],=N8RA(5)[8],=N8WXQ(5)[8],=N9CIQ(4)[7],=N9GB(4)[7],\n\ =N9HDE(4)[7],=N9JF(4)[7],=N9NA(3)[6],=N9NB(5)[8],=N9NC(5)[8],=N9NM(4)[7],\n\ =N9OU(5)[8],=N9RV(4)[6],=N9SB(4)[7],=N9VPV(4)[7],=NA5NN(4)[8],=ND2T(3)[6],\n\ =ND3N(4)[8],=ND4Y(4)[8],=NE8P(5)[8],=NE9U(4)[7],=NF4J(4)[8],=NG7A(4)[7],\n\ =NH6L(4)[7],=NH6T(4)[8],=NI7R(5)[8],=NJ4P(4)[8],=NJ8J(5)[8],=NJ8M(4)[7],\n\ =NK7U(5)[8],=NK8Q(5)[8],=NL7CQ(4)[7],=NL7D(3)[6],=NL7QC(4)[7],\n\ =NL7WA(5)[8],=NL7XM(5)[8],=NN1N(4)[7],=NN4NT(4)[8],=NN5O(4)[8],\n\ =NN7A(4)[7],=NN7CW(5)[8],=NN9DD(5)[8],=NO9E(5)[8],=NP2GG(5)[8],\n\ =NP3FB(4)[8],=NP3K(5)[8],=NQ6N(4)[8],=NR4L(4)[8],=NR5W(3)[6],=NR7DX(4)[6],\n\ =NS2X(4)[8],=NS4X(4)[8],=NT0K(5)[8],=NW2P(3)[6],=NW8U(5)[8],=NX1P(3)[6],\n\ =NX3U(4)[8],=NY6DX(5)[8],=NZ6T(5)[8],=NZ7Q(4)[7],=W0BR(5)[8],=W0NA(5)[8],\n\ =W0PV(5)[8],=W0QQG(5)[8],=W0RIC(3)[6],=W0YK(3)[6],=W0ZP(4)[8],\n\ =W1GKT(4)[8],=W1NN(4)[8],=W1PDI(4)[8],=W1PR(3)[6],=W1RH(3)[6],\n\ =W1SRD(3)[6],=W2ACY(4)[7],=W2GS(4)[7],=W2VJN(3)[6],=W3CB(4)[8],\n\ =W3HDH(4)[8],=W3HKK(4)[8],=W3NX(3)[6],=W3TB(4)[8],=W4BCG(4)[8],\n\ =W4DAN(4)[8],=W4ER(4)[8],=W4GKM(4)[8],=W4KW(4)[8],=W4LC(4)[8],\n\ =W4NBS(4)[8],=W4NI(4)[8],=W4NNF(4)[8],=W4NZ(4)[8],=W4PF(4)[8],\n\ =W4RYW(4)[8],=W4TLK(4)[8],=W4TTM(4)[8],=W4UT(4)[8],=W5JR(5)[8],\n\ =W5MX(4)[8],=W5NZ(4)[8],=W5UE(4)[8],=W5UJ(3)[6],=W5VE(5)[8],=W5VS(5)[8],\n\ =W6DVS(5)[8],=W6GMT(4)[7],=W6KGP(4)[7],=W6LFB(4)[7],=W6NWS(5)[8],\n\ =W6SFG(5)[8],=W6UB(4)[8],=W6XR(5)[8],=W7DXX(4)[7],=W7EE(4)[6],\n\ =W7GKF(5)[8],=W7HJ(5)[8],=W7II(4)[7],=W7IMP(5)[8],=W7IY(5)[8],=W7RY(4)[7],\n\ =W7UT(4)[7],=W8AT(5)[8],=W8FJ(5)[8],=W8FN(5)[8],=W8HAP(5)[8],=W8HGH(5)[8],\n\ =W8LYJ(4)[7],=W8OV(4)[7],=W8TK(3)[6],=W9CF(3)[6],=W9DC(5)[8],=W9ET(4)[7],\n\ =W9FI(3)[6],=W9JA(4)[7],=W9JEF(4)[7],=W9KKN(3)[6],=W9MAF(4)[7],\n\ =W9PL(3)[6],=W9RM(4)[7],=W9RNY(4)[7],=WA0LJM(5)[8],=WA0WWW(3)[6],\n\ =WA1FCN(4)[8],=WA1UJU(4)[8],=WA2VYA(4)[7],=WA3C(4)[8],=WA5POK(4)[8],\n\ =WA8KAN(5)[8],=WA8OJR(5)[8],=WA8ZBT(4)[7],=WB3JFS(3)[6],=WB4YDY(4)[8],\n\ =WB5WAJ(4)[8],=WB8BPU(5)[8],=WB8YYY(5)[8],=WB9QAF(4)[7],=WC7S(4)[7],\n\ =WE5P(4)[8],=WE6EZ(4)[7],=WF7T(4)[8],=WF9A(5)[8],=WH0AI(4)[7],\n\ =WH6AQ(5)[8],=WH6LE(5)[8],=WH7R(4)[7],=WJ4HCP(4)[8],=WJ9B(3)[6],\n\ =WL5H(4)[7],=WL7OU(4)[7],=WM5DX(4)[8],=WN7S(5)[8],=WN7Y(4)[7],=WO7U(4)[7],\n\ =WP2J(5)[8],=WP3ME(5)[8],=WQ5L(4)[8],=WR3O(4)[8],=WS6K(4)[8],=WS6X(5)[8],\n\ =WS7X(5)[8],=WS9M(5)[8],=WT2P(4)[8],=WT7TT(4)[7],=WT8WV(5)[8],=WU0B(5)[8],\n\ =WU9B(3)[6],=WV4P(4)[8],=WW4R(4)[8],=WW5M(4)[8],=WX4W(4)[8],=WX5S(3)[6],\n\ =WY6K(4)[7],=WY7FD(4)[7],=WZ1Y(4)[7],=WZ4F(4)[8],=WZ7I(5)[8],=WZ8T(3)[6];\n\ Guantanamo Bay: 08: 11: NA: 20.00: 75.00: 5.0: KG4:\n\ KG4,=KG4NE;\n\ Mariana Islands: 27: 64: OC: 15.18: -145.72: -10.0: KH0:\n\ AH0,KH0,NH0,WH0,=AA1AB,=K8RN,=KI5DQL,=NH2B;\n\ Baker & Howland Islands: 31: 61: OC: 0.00: 176.00: 12.0: KH1:\n\ AH1,KH1,NH1,WH1;\n\ Guam: 27: 64: OC: 13.37: -144.70: -10.0: KH2:\n\ AH2,KH2,NH2,WH2,=KG6DX,=KG6JDX,=KH6KK,=KN4LVP;\n\ Johnston Island: 31: 61: OC: 16.72: 169.53: 10.0: KH3:\n\ AH3,KH3,NH3,WH3;\n\ Midway Island: 31: 61: OC: 28.20: 177.37: 11.0: KH4:\n\ AH4,KH4,NH4,WH4;\n\ Palmyra & Jarvis Islands: 31: 61: OC: 5.87: 162.07: 11.0: KH5:\n\ AH5,KH5,NH5,WH5;\n\ Hawaii: 31: 61: OC: 21.12: 157.48: 10.0: KH6:\n\ AH6,AH7,KH6,KH7,NH6,NH7,WH6,WH7,=K1TOR,=K2GT,=K4JMB,=K4XV,=K5PKT,=K6HNL,\n\ =K9FD,=KB1KAC,=KB3HXI,=KB5OXR,=KC0HFI,=KC2CLQ,=KC6MCC,=KC8JNV,=KD0JNO,\n\ =KE0KIE,=KE7DES,=KE7DET,=KF4UJC,=KF5JFX,=KF6OHL,=KG5CH,=KG5CNO,=KG5IVP,\n\ =KG7TSD,=KH0WJ,=KH3AE,=KJ6CPN,=KJ6CQT,=KJ6FDF,=KK6DWS,=KL3JC,=KM6RWE,\n\ =KM6UVP,=N0VYO,=N3GWR,=N4BER,=N7JRO,=N7OBR,=NB6R,=ND1A,=NR0G,=W1ETT,\n\ =W1JJS,=W6QPV,=W7NX,=W7WKS,=WA6AW,=WA6CZL,=WA6QDQ,=WA7WSU,=WB4JTT,=WK1K;\n\ Kure Island: 31: 61: OC: 29.00: 178.00: 10.0: KH7K:\n\ AH7K,KH7K,NH7K,WH7K;\n\ American Samoa: 32: 62: OC: -14.32: 170.78: 11.0: KH8:\n\ AH8,KH8,NH8,WH8,=KD2UVU;\n\ Swains Island: 32: 62: OC: -11.05: 171.25: 11.0: KH8/s:\n\ =K9CS/KH8S;\n\ Wake Island: 31: 65: OC: 19.28: -166.63: -12.0: KH9:\n\ AH9,KH9,NH9,WH9;\n\ Alaska: 01: 01: NA: 61.40: 148.87: 8.0: KL:\n\ AL,KL,NL,WL,=AI7CF,=K0ESQ,=K1IEE,=K1LQ,=K1TMT,=K5RD,=K7BUF,=K7CAP,=K7VRK,\n\ =KA1NCN,=KB5NOW,=KB7RWK,=KB9THD,=KC0EFL,=KC1LVR,=KC3BWW,=KC3NUH,=KC5NHL,\n\ =KC7DNT,=KC9IKH,=KC9SXX,=KD5MQC,=KD5SHW,=KD8KQL,=KD9QKS,=KE0PRX,=KE5WGZ,\n\ =KE7ZXH,=KF7ARC,=KF7FLL,=KF7FLM,=KF7GCF,=KF7ING,=KF7ITN,=KF7KTH,=KF7WVE,\n\ =KG7OYE,=KG7ZEV,=KI4FJK,=KI7BKQ,=KJ6RFQ,=KK6SNS,=KM6YOD,=KN4ENR,=KN4LJD,\n\ =KW4XD,=N0JOB,=N4DBX,=N7CGC,=N7DUD,=N7ELD,=NH2LS,=W1LYD,=W2KRZ,=W3MKG,\n\ =W7EGG,=WA1FVJ,=WA1OUS,=WA4RRE,=WA7B;\n\ Navassa Island: 08: 11: NA: 18.40: 75.00: 5.0: KP1:\n\ KP1,NP1,WP1;\n\ US Virgin Islands: 08: 11: NA: 17.73: 64.80: 4.0: KP2:\n\ KP2,NP2,WP2,=K5KUB,=K9VV,=KV4CF,=KV4KW,=W4LIS;\n\ Puerto Rico: 08: 11: NA: 18.18: 66.55: 4.0: KP4:\n\ KP3,KP4,NP3,NP4,WP3,WP4,=KB2BVX,=KB3TTV,=KC2GRZ,=KC2TE,=KC5FWS,=KF5YGN,\n\ =KF5YGX,=KG6WWV,=KH2RU,=KI5KQH,=KM4ZWY,=N2FVA,=N4MMT,=N4NDL,=N8MQ;\n\ Desecheo Island: 08: 11: NA: 18.08: 67.88: 4.0: KP5:\n\ KP5,NP5,WP5;\n\ Norway: 14: 18: EU: 61.00: -9.00: -1.0: LA:\n\ LA,LB,LC,LD,LE,LF,LG,LH,LI,LJ,LK,LL,LM,LN;\n\ Argentina: 13: 14: SA: -34.80: 65.92: 3.0: LU:\n\ AY,AZ,L1,L2,L3,L4,L5,L6,L7,L8,L9,LO,LP,LQ,LR,LS,LT,LU,LV,LW,AY0V[16],\n\ AY0W[16],AY0X[16],AY0Y[16],AY1V[16],AY1W[16],AY1X[16],AY1Y[16],AY2V[16],\n\ AY2W[16],AY2X[16],AY2Y[16],AY3V[16],AY3W[16],AY3X[16],AY3Y[16],AY4V[16],\n\ AY4W[16],AY4X[16],AY4Y[16],AY5V[16],AY5W[16],AY5X[16],AY5Y[16],AY6V[16],\n\ AY6W[16],AY6X[16],AY6Y[16],AY7V[16],AY7W[16],AY7X[16],AY7Y[16],AY8V[16],\n\ AY8W[16],AY8X[16],AY8Y[16],AY9V[16],AY9W[16],AY9X[16],AY9Y[16],AZ0V[16],\n\ AZ0W[16],AZ0X[16],AZ0Y[16],AZ1V[16],AZ1W[16],AZ1X[16],AZ1Y[16],AZ2V[16],\n\ AZ2W[16],AZ2X[16],AZ2Y[16],AZ3V[16],AZ3W[16],AZ3X[16],AZ3Y[16],AZ4V[16],\n\ AZ4W[16],AZ4X[16],AZ4Y[16],AZ5V[16],AZ5W[16],AZ5X[16],AZ5Y[16],AZ6V[16],\n\ AZ6W[16],AZ6X[16],AZ6Y[16],AZ7V[16],AZ7W[16],AZ7X[16],AZ7Y[16],AZ8V[16],\n\ AZ8W[16],AZ8X[16],AZ8Y[16],AZ9V[16],AZ9W[16],AZ9X[16],AZ9Y[16],L20V[16],\n\ L20W[16],L20X[16],L20Y[16],L21V[16],L21W[16],L21X[16],L21Y[16],L22V[16],\n\ L22W[16],L22X[16],L22Y[16],L23V[16],L23W[16],L23X[16],L23Y[16],L24V[16],\n\ L24W[16],L24X[16],L24Y[16],L25V[16],L25W[16],L25X[16],L25Y[16],L26V[16],\n\ L26W[16],L26X[16],L26Y[16],L27V[16],L27W[16],L27X[16],L27Y[16],L28V[16],\n\ L28W[16],L28X[16],L28Y[16],L29V[16],L29W[16],L29X[16],L29Y[16],L30V[16],\n\ L30W[16],L30X[16],L30Y[16],L31V[16],L31W[16],L31X[16],L31Y[16],L32V[16],\n\ L32W[16],L32X[16],L32Y[16],L33V[16],L33W[16],L33X[16],L33Y[16],L34V[16],\n\ L34W[16],L34X[16],L34Y[16],L35V[16],L35W[16],L35X[16],L35Y[16],L36V[16],\n\ L36W[16],L36X[16],L36Y[16],L37V[16],L37W[16],L37X[16],L37Y[16],L38V[16],\n\ L38W[16],L38X[16],L38Y[16],L39V[16],L39W[16],L39X[16],L39Y[16],L40V[16],\n\ L40W[16],L40X[16],L40Y[16],L41V[16],L41W[16],L41X[16],L41Y[16],L42V[16],\n\ L42W[16],L42X[16],L42Y[16],L43V[16],L43W[16],L43X[16],L43Y[16],L44V[16],\n\ L44W[16],L44X[16],L44Y[16],L45V[16],L45W[16],L45X[16],L45Y[16],L46V[16],\n\ L46W[16],L46X[16],L46Y[16],L47V[16],L47W[16],L47X[16],L47Y[16],L48V[16],\n\ L48W[16],L48X[16],L48Y[16],L49V[16],L49W[16],L49X[16],L49Y[16],L50V[16],\n\ L50W[16],L50X[16],L50Y[16],L51V[16],L51W[16],L51X[16],L51Y[16],L52V[16],\n\ L52W[16],L52X[16],L52Y[16],L53V[16],L53W[16],L53X[16],L53Y[16],L54V[16],\n\ L54W[16],L54X[16],L54Y[16],L55V[16],L55W[16],L55X[16],L55Y[16],L56V[16],\n\ L56W[16],L56X[16],L56Y[16],L57V[16],L57W[16],L57X[16],L57Y[16],L58V[16],\n\ L58W[16],L58X[16],L58Y[16],L59V[16],L59W[16],L59X[16],L59Y[16],L60V[16],\n\ L60W[16],L60X[16],L60Y[16],L61V[16],L61W[16],L61X[16],L61Y[16],L62V[16],\n\ L62W[16],L62X[16],L62Y[16],L63V[16],L63W[16],L63X[16],L63Y[16],L64V[16],\n\ L64W[16],L64X[16],L64Y[16],L65V[16],L65W[16],L65X[16],L65Y[16],L66V[16],\n\ L66W[16],L66X[16],L66Y[16],L67V[16],L67W[16],L67X[16],L67Y[16],L68V[16],\n\ L68W[16],L68X[16],L68Y[16],L69V[16],L69W[16],L69X[16],L69Y[16],L70V[16],\n\ L70W[16],L70X[16],L70Y[16],L71V[16],L71W[16],L71X[16],L71Y[16],L72V[16],\n\ L72W[16],L72X[16],L72Y[16],L73V[16],L73W[16],L73X[16],L73Y[16],L74V[16],\n\ L74W[16],L74X[16],L74Y[16],L75V[16],L75W[16],L75X[16],L75Y[16],L76V[16],\n\ L76W[16],L76X[16],L76Y[16],L77V[16],L77W[16],L77X[16],L77Y[16],L78V[16],\n\ L78W[16],L78X[16],L78Y[16],L79V[16],L79W[16],L79X[16],L79Y[16],L80V[16],\n\ L80W[16],L80X[16],L80Y[16],L81V[16],L81W[16],L81X[16],L81Y[16],L82V[16],\n\ L82W[16],L82X[16],L82Y[16],L83V[16],L83W[16],L83X[16],L83Y[16],L84V[16],\n\ L84W[16],L84X[16],L84Y[16],L85V[16],L85W[16],L85X[16],L85Y[16],L86V[16],\n\ L86W[16],L86X[16],L86Y[16],L87V[16],L87W[16],L87X[16],L87Y[16],L88V[16],\n\ L88W[16],L88X[16],L88Y[16],L89V[16],L89W[16],L89X[16],L89Y[16],L90V[16],\n\ L90W[16],L90X[16],L90Y[16],L91V[16],L91W[16],L91X[16],L91Y[16],L92V[16],\n\ L92W[16],L92X[16],L92Y[16],L93V[16],L93W[16],L93X[16],L93Y[16],L94V[16],\n\ L94W[16],L94X[16],L94Y[16],L95V[16],L95W[16],L95X[16],L95Y[16],L96V[16],\n\ L96W[16],L96X[16],L96Y[16],L97V[16],L97W[16],L97X[16],L97Y[16],L98V[16],\n\ L98W[16],L98X[16],L98Y[16],L99V[16],L99W[16],L99X[16],L99Y[16],LO0V[16],\n\ LO0W[16],LO0X[16],LO0Y[16],LO1V[16],LO1W[16],LO1X[16],LO1Y[16],LO2V[16],\n\ LO2W[16],LO2X[16],LO2Y[16],LO3V[16],LO3W[16],LO3X[16],LO3Y[16],LO4V[16],\n\ LO4W[16],LO4X[16],LO4Y[16],LO5V[16],LO5W[16],LO5X[16],LO5Y[16],LO6V[16],\n\ LO6W[16],LO6X[16],LO6Y[16],LO7V[16],LO7W[16],LO7X[16],LO7Y[16],LO8V[16],\n\ LO8W[16],LO8X[16],LO8Y[16],LO9V[16],LO9W[16],LO9X[16],LO9Y[16],LP0V[16],\n\ LP0W[16],LP0X[16],LP0Y[16],LP1V[16],LP1W[16],LP1X[16],LP1Y[16],LP2V[16],\n\ LP2W[16],LP2X[16],LP2Y[16],LP3V[16],LP3W[16],LP3X[16],LP3Y[16],LP4V[16],\n\ LP4W[16],LP4X[16],LP4Y[16],LP5V[16],LP5W[16],LP5X[16],LP5Y[16],LP6V[16],\n\ LP6W[16],LP6X[16],LP6Y[16],LP7V[16],LP7W[16],LP7X[16],LP7Y[16],LP8V[16],\n\ LP8W[16],LP8X[16],LP8Y[16],LP9V[16],LP9W[16],LP9X[16],LP9Y[16],LQ0V[16],\n\ LQ0W[16],LQ0X[16],LQ0Y[16],LQ1V[16],LQ1W[16],LQ1X[16],LQ1Y[16],LQ2V[16],\n\ LQ2W[16],LQ2X[16],LQ2Y[16],LQ3V[16],LQ3W[16],LQ3X[16],LQ3Y[16],LQ4V[16],\n\ LQ4W[16],LQ4X[16],LQ4Y[16],LQ5V[16],LQ5W[16],LQ5X[16],LQ5Y[16],LQ6V[16],\n\ LQ6W[16],LQ6X[16],LQ6Y[16],LQ7V[16],LQ7W[16],LQ7X[16],LQ7Y[16],LQ8V[16],\n\ LQ8W[16],LQ8X[16],LQ8Y[16],LQ9V[16],LQ9W[16],LQ9X[16],LQ9Y[16],LR0V[16],\n\ LR0W[16],LR0X[16],LR0Y[16],LR1V[16],LR1W[16],LR1X[16],LR1Y[16],LR2V[16],\n\ LR2W[16],LR2X[16],LR2Y[16],LR3V[16],LR3W[16],LR3X[16],LR3Y[16],LR4V[16],\n\ LR4W[16],LR4X[16],LR4Y[16],LR5V[16],LR5W[16],LR5X[16],LR5Y[16],LR6V[16],\n\ LR6W[16],LR6X[16],LR6Y[16],LR7V[16],LR7W[16],LR7X[16],LR7Y[16],LR8V[16],\n\ LR8W[16],LR8X[16],LR8Y[16],LR9V[16],LR9W[16],LR9X[16],LR9Y[16],LS0V[16],\n\ LS0W[16],LS0X[16],LS0Y[16],LS1V[16],LS1W[16],LS1X[16],LS1Y[16],LS2V[16],\n\ LS2W[16],LS2X[16],LS2Y[16],LS3V[16],LS3W[16],LS3X[16],LS3Y[16],LS4V[16],\n\ LS4W[16],LS4X[16],LS4Y[16],LS5V[16],LS5W[16],LS5X[16],LS5Y[16],LS6V[16],\n\ LS6W[16],LS6X[16],LS6Y[16],LS7V[16],LS7W[16],LS7X[16],LS7Y[16],LS8V[16],\n\ LS8W[16],LS8X[16],LS8Y[16],LS9V[16],LS9W[16],LS9X[16],LS9Y[16],LT0V[16],\n\ LT0W[16],LT0X[16],LT0Y[16],LT1V[16],LT1W[16],LT1X[16],LT1Y[16],LT2V[16],\n\ LT2W[16],LT2X[16],LT2Y[16],LT3V[16],LT3W[16],LT3X[16],LT3Y[16],LT4V[16],\n\ LT4W[16],LT4X[16],LT4Y[16],LT5V[16],LT5W[16],LT5X[16],LT5Y[16],LT6V[16],\n\ LT6W[16],LT6X[16],LT6Y[16],LT7V[16],LT7W[16],LT7X[16],LT7Y[16],LT8V[16],\n\ LT8W[16],LT8X[16],LT8Y[16],LT9V[16],LT9W[16],LT9X[16],LT9Y[16],LU0V[16],\n\ LU0W[16],LU0X[16],LU0Y[16],LU1V[16],LU1W[16],LU1X[16],LU1Y[16],LU2V[16],\n\ LU2W[16],LU2X[16],LU2Y[16],LU3V[16],LU3W[16],LU3X[16],LU3Y[16],LU4V[16],\n\ LU4W[16],LU4X[16],LU4Y[16],LU5V[16],LU5W[16],LU5X[16],LU5Y[16],LU6V[16],\n\ LU6W[16],LU6X[16],LU6Y[16],LU7V[16],LU7W[16],LU7X[16],LU7Y[16],LU8V[16],\n\ LU8W[16],LU8X[16],LU8Y[16],LU9V[16],LU9W[16],LU9X[16],LU9Y[16],LV0V[16],\n\ LV0W[16],LV0X[16],LV0Y[16],LV1V[16],LV1W[16],LV1X[16],LV1Y[16],LV2V[16],\n\ LV2W[16],LV2X[16],LV2Y[16],LV3V[16],LV3W[16],LV3X[16],LV3Y[16],LV4V[16],\n\ LV4W[16],LV4X[16],LV4Y[16],LV5V[16],LV5W[16],LV5X[16],LV5Y[16],LV6V[16],\n\ LV6W[16],LV6X[16],LV6Y[16],LV7V[16],LV7W[16],LV7X[16],LV7Y[16],LV8V[16],\n\ LV8W[16],LV8X[16],LV8Y[16],LV9V[16],LV9W[16],LV9X[16],LV9Y[16],LW0V[16],\n\ LW0W[16],LW0X[16],LW0Y[16],LW1V[16],LW1W[16],LW1X[16],LW1Y[16],LW2V[16],\n\ LW2W[16],LW2X[16],LW2Y[16],LW3V[16],LW3W[16],LW3X[16],LW3Y[16],LW4V[16],\n\ LW4W[16],LW4X[16],LW4Y[16],LW5V[16],LW5W[16],LW5X[16],LW5Y[16],LW6V[16],\n\ LW6W[16],LW6X[16],LW6Y[16],LW7V[16],LW7W[16],LW7X[16],LW7Y[16],LW8V[16],\n\ LW8W[16],LW8X[16],LW8Y[16],LW9V[16],LW9W[16],LW9X[16],LW9Y[16],\n\ =LU1AW/X[16],=LU1HB/J,=LU1JGU/J,=LU2DVI/H,=LU3DVN/X[16],=LU4AA/D,=LU4AA/X,\n\ =LU4ARU/D,=LU6FLZ/F;\n\ Luxembourg: 14: 27: EU: 50.00: -6.00: -1.0: LX:\n\ LX,=LX9S/J;\n\ Lithuania: 15: 29: EU: 55.45: -23.63: -2.0: LY:\n\ LY;\n\ Bulgaria: 20: 28: EU: 42.83: -25.08: -2.0: LZ:\n\ LZ;\n\ Peru: 10: 12: SA: -10.00: 76.00: 5.0: OA:\n\ 4T,OA,OB,OC;\n\ Lebanon: 20: 39: AS: 33.83: -35.83: -2.0: OD:\n\ OD;\n\ Austria: 15: 28: EU: 47.33: -13.33: -1.0: OE:\n\ OE,=4U0R,=4U1A,=4U1VIC,=4U2STAYHOME,=4U2U,=4U75A,=4Y1A,=C7A;\n\ Finland: 15: 18: EU: 63.78: -27.08: -2.0: OH:\n\ OF,OG,OH,OI,OJ;\n\ Aland Islands: 15: 18: EU: 60.13: -20.37: -2.0: OH0:\n\ OF0,OG0,OH0,OI0;\n\ Market Reef: 15: 18: EU: 60.00: -19.00: -2.0: OJ0:\n\ OJ0;\n\ Czech Republic: 15: 28: EU: 50.00: -16.00: -1.0: OK:\n\ OK,OL;\n\ Slovak Republic: 15: 28: EU: 49.00: -20.00: -1.0: OM:\n\ OM;\n\ Belgium: 14: 27: EU: 50.70: -4.85: -1.0: ON:\n\ ON,OO,OP,OQ,OR,OS,OT;\n\ Greenland: 40: 05: NA: 74.00: 42.78: 3.0: OX:\n\ OX,XP;\n\ Faroe Islands: 14: 18: EU: 62.07: 6.93: 0.0: OY:\n\ OW,OY;\n\ Denmark: 14: 18: EU: 56.00: -10.00: -1.0: OZ:\n\ 5P,5Q,OU,OV,OZ;\n\ Papua New Guinea: 28: 51: OC: -9.50: -147.12: -10.0: P2:\n\ P2;\n\ Aruba: 09: 11: SA: 12.53: 69.98: 4.0: P4:\n\ P4;\n\ DPR of Korea: 25: 44: AS: 39.78: -126.30: -9.0: P5:\n\ P5,P6,P7,P8,P9;\n\ Netherlands: 14: 27: EU: 52.28: -5.47: -1.0: PA:\n\ PA,PB,PC,PD,PE,PF,PG,PH,PI,=PE1BOJ/J;\n\ Curacao: 09: 11: SA: 12.17: 69.00: 4.0: PJ2:\n\ PJ2;\n\ Bonaire: 09: 11: SA: 12.20: 68.25: 4.0: PJ4:\n\ PJ4;\n\ Saba & St. Eustatius: 08: 11: NA: 17.57: 63.10: 4.0: PJ5:\n\ PJ5,PJ6;\n\ Sint Maarten: 08: 11: NA: 18.07: 63.07: 4.0: PJ7:\n\ PJ0,PJ7,PJ8;\n\ Brazil: 11: 15: SA: -10.00: 53.00: 3.0: PY:\n\ PP,PQ,PR,PS,PT,PU,PV,PW,PX,PY,ZV,ZW,ZX,ZY,ZZ,PP6[13],PP7[13],PP8[12],\n\ PQ2[13],PQ8[13],PR7[13],PR8[13],PS7[13],PS8[13],PT2[13],PT7[13],PT8[12],\n\ PV8[12],PW8[12],PY6[13],PY7[13],PY8[13],PY9[13];\n\ Fernando de Noronha: 11: 13: SA: -3.85: 32.43: 2.0: PY0F:\n\ PP0F,PP0ZF,PQ0F,PQ0ZF,PR0F,PR0ZF,PS0F,PS0ZF,PT0F,PT0ZF,PU0F,PU0ZF,PV0F,\n\ PV0ZF,PW0F,PW0ZF,PX0F,PX0ZF,PY0F,PY0Z,ZV0F,ZV0ZF,ZW0F,ZW0ZF,ZX0F,ZX0ZF,\n\ ZY0F,ZY0Z,ZZ0F,ZZ0ZF,PP0R,PP0ZR,PQ0R,PQ0ZR,PR0R,PR0ZR,PS0R,PS0ZR,PT0R,\n\ PT0ZR,PU0R,PU0ZR,PV0R,PV0ZR,PW0R,PW0ZR,PX0R,PX0ZR,PY0R,ZV0R,ZV0ZR,ZW0R,\n\ ZW0ZR,ZX0R,ZX0ZR,ZY0R,ZZ0R,ZZ0ZR;\n\ St. Peter & St. Paul: 11: 13: SA: 0.00: 29.00: 2.0: PY0S:\n\ PP0S,PP0ZS,PQ0S,PQ0ZS,PR0S,PR0ZS,PS0S,PS0ZS,PT0S,PT0ZS,PU0S,PU0ZS,PV0S,\n\ PV0ZS,PW0S,PW0ZS,PX0S,PX0ZS,PY0S,PY0ZS,ZV0S,ZV0ZS,ZW0S,ZW0ZS,ZX0S,ZX0ZS,\n\ ZY0S,ZY0ZS,ZZ0S,ZZ0ZS;\n\ Trindade & Martim Vaz: 11: 15: SA: -20.50: 29.32: 2.0: PY0T:\n\ PP0T,PP0ZT,PQ0T,PQ0ZT,PR0T,PR0ZT,PS0T,PS0ZT,PT0T,PT0ZT,PU0T,PU0ZT,PV0T,\n\ PV0ZT,PW0T,PW0ZT,PX0T,PX0ZT,PY0T,PY0ZT,ZV0T,ZV0ZT,ZW0T,ZW0ZT,ZX0T,ZX0ZT,\n\ ZY0T,ZY0ZT,ZZ0T,ZZ0ZT;\n\ Suriname: 09: 12: SA: 4.00: 56.00: 3.0: PZ:\n\ PZ;\n\ Franz Josef Land: 40: 75: EU: 80.68: -49.92: -3.0: R1FJ:\n\ RI1F;\n\ Western Sahara: 33: 46: AF: 24.82: 13.85: 0.0: S0:\n\ S0;\n\ Bangladesh: 22: 41: AS: 24.12: -89.65: -6.0: S2:\n\ S2,S3;\n\ Slovenia: 15: 28: EU: 46.00: -14.00: -1.0: S5:\n\ S5;\n\ Seychelles: 39: 53: AF: -4.67: -55.47: -4.0: S7:\n\ S7;\n\ Sao Tome & Principe: 36: 47: AF: 0.22: -6.57: 0.0: S9:\n\ S9;\n\ Sweden: 14: 18: EU: 61.20: -14.57: -1.0: SM:\n\ 7S,8S,SA,SB,SC,SD,SE,SF,SG,SH,SI,SJ,SK,SL,SM;\n\ Poland: 15: 28: EU: 52.28: -18.67: -1.0: SP:\n\ 3Z,HF,SN,SO,SP,SQ,SR;\n\ Sudan: 34: 48: AF: 14.47: -28.62: -3.0: ST:\n\ 6T,6U,ST;\n\ Egypt: 34: 38: AF: 26.28: -28.60: -2.0: SU:\n\ 6A,6B,SS,SU;\n\ Greece: 20: 28: EU: 39.78: -21.78: -2.0: SV:\n\ J4,SV,SW,SX,SY,SZ,=SV2JAO/J;\n\ Mount Athos: 20: 28: EU: 40.00: -24.00: -2.0: SV/a:\n\ =SV2ASP/A,=SV2RSG/A;\n\ Dodecanese: 20: 28: EU: 36.17: -27.93: -2.0: SV5:\n\ J45,SV5,SW5,SX5,SY5,SZ5;\n\ Crete: 20: 28: EU: 35.23: -24.78: -2.0: SV9:\n\ J49,SV9,SW9,SX9,SY9,SZ9,=SV0XAZ;\n\ Tuvalu: 31: 65: OC: -8.50: -179.20: -12.0: T2:\n\ T2;\n\ Western Kiribati: 31: 65: OC: 1.42: -173.00: -12.0: T30:\n\ T30;\n\ Central Kiribati: 31: 62: OC: -2.83: 171.72: -13.0: T31:\n\ T31;\n\ Eastern Kiribati: 31: 61: OC: 1.80: 157.35: -14.0: T32:\n\ T32;\n\ Banaba Island: 31: 65: OC: -0.88: -169.53: -12.0: T33:\n\ T33;\n\ Somalia: 37: 48: AF: 2.03: -45.35: -3.0: T5:\n\ 6O,T5;\n\ San Marino: 15: 28: EU: 43.95: -12.45: -1.0: T7:\n\ T7;\n\ Palau: 27: 64: OC: 7.45: -134.53: -9.0: T8:\n\ T8;\n\ Asiatic Turkey: 20: 39: AS: 39.18: -35.65: -2.0: TA:\n\ TA,TB,TC,YM,=TA1C/2,=TA1CX/2,=TA1D/3,=TA1D/4,=TA1FA/2,=TA1HZ/2,=TA1UT/3;\n\ European Turkey: 20: 39: EU: 41.02: -28.97: -2.0: *TA1:\n\ TA1,TB1,TC1,YM1,=TA6CQ/1;\n\ Iceland: 40: 17: EU: 64.80: 18.73: 0.0: TF:\n\ TF;\n\ Guatemala: 07: 11: NA: 15.50: 90.30: 6.0: TG:\n\ TD,TG;\n\ Costa Rica: 07: 11: NA: 10.00: 84.00: 6.0: TI:\n\ TE,TI;\n\ Cocos Island: 07: 11: NA: 5.52: 87.05: 6.0: TI9:\n\ TE9,TI9;\n\ Cameroon: 36: 47: AF: 5.38: -11.87: -1.0: TJ:\n\ TJ;\n\ Corsica: 15: 28: EU: 42.00: -9.00: -1.0: TK:\n\ TK;\n\ Central African Republic: 36: 47: AF: 6.75: -20.33: -1.0: TL:\n\ TL;\n\ Republic of the Congo: 36: 52: AF: -1.02: -15.37: -1.0: TN:\n\ TN;\n\ Gabon: 36: 52: AF: -0.37: -11.73: -1.0: TR:\n\ TR;\n\ Chad: 36: 47: AF: 15.80: -18.17: -1.0: TT:\n\ TT;\n\ Cote d'Ivoire: 35: 46: AF: 7.58: 5.80: 0.0: TU:\n\ TU;\n\ Benin: 35: 46: AF: 9.87: -2.25: -1.0: TY:\n\ TY;\n\ Mali: 35: 46: AF: 18.00: 2.58: 0.0: TZ:\n\ TZ;\n\ European Russia: 16: 29: EU: 53.65: -41.37: -4.0: UA:\n\ R,U,R1I(17)[20],R1N[19],R1O[19],R1P[20],R1Z[19],R4H[30],R4I[30],R4W[30],\n\ R8F(17)[30],R8G(17)[30],R8X(17)[20],R9F(17)[30],R9G(17)[30],R9X(17)[20],\n\ RA1I(17)[20],RA1N[19],RA1O[19],RA1P[20],RA1Z[19],RA4H[30],RA4I[30],\n\ RA4W[30],RA8F(17)[30],RA8G(17)[30],RA8X(17)[20],RA9F(17)[30],RA9G(17)[30],\n\ RA9X(17)[20],RC1I(17)[20],RC1N[19],RC1O[19],RC1P[20],RC1Z[19],RC4H[30],\n\ RC4I[30],RC4W[30],RC8F(17)[30],RC8G(17)[30],RC8X(17)[20],RC9F(17)[30],\n\ RC9G(17)[30],RC9X(17)[20],RD1I(17)[20],RD1N[19],RD1O[19],RD1P[20],\n\ RD1Z[19],RD4H[30],RD4I[30],RD4W[30],RD8F(17)[30],RD8G(17)[30],\n\ RD8X(17)[20],RD9F(17)[30],RD9G(17)[30],RD9X(17)[20],RE1I(17)[20],RE1N[19],\n\ RE1O[19],RE1P[20],RE1Z[19],RE4H[30],RE4I[30],RE4W[30],RE8F(17)[30],\n\ RE8G(17)[30],RE8X(17)[20],RE9F(17)[30],RE9G(17)[30],RE9X(17)[20],\n\ RF1I(17)[20],RF1N[19],RF1O[19],RF1P[20],RF1Z[19],RF4H[30],RF4I[30],\n\ RF4W[30],RF8F(17)[30],RF8G(17)[30],RF8X(17)[20],RF9F(17)[30],RF9G(17)[30],\n\ RF9X(17)[20],RG1I(17)[20],RG1N[19],RG1O[19],RG1P[20],RG1Z[19],RG4H[30],\n\ RG4I[30],RG4W[30],RG8F(17)[30],RG8G(17)[30],RG8X(17)[20],RG9F(17)[30],\n\ RG9G(17)[30],RG9X(17)[20],RI8X(17)[20],RI9X(17)[20],RJ1I(17)[20],RJ1N[19],\n\ RJ1O[19],RJ1P[20],RJ1Z[19],RJ4H[30],RJ4I[30],RJ4W[30],RJ8F(17)[30],\n\ RJ8G(17)[30],RJ8X(17)[20],RJ9F(17)[30],RJ9G(17)[30],RJ9X(17)[20],\n\ RK1I(17)[20],RK1N[19],RK1O[19],RK1P[20],RK1Z[19],RK4H[30],RK4I[30],\n\ RK4W[30],RK8F(17)[30],RK8G(17)[30],RK8X(17)[20],RK9F(17)[30],RK9G(17)[30],\n\ RK9X(17)[20],RL1I(17)[20],RL1N[19],RL1O[19],RL1P[20],RL1Z[19],RL4H[30],\n\ RL4I[30],RL4W[30],RL8F(17)[30],RL8G(17)[30],RL8X(17)[20],RL9F(17)[30],\n\ RL9G(17)[30],RL9X(17)[20],RM1I(17)[20],RM1N[19],RM1O[19],RM1P[20],\n\ RM1Z[19],RM4H[30],RM4I[30],RM4W[30],RM8F(17)[30],RM8G(17)[30],\n\ RM8X(17)[20],RM9F(17)[30],RM9G(17)[30],RM9X(17)[20],RN1I(17)[20],RN1N[19],\n\ RN1O[19],RN1P[20],RN1Z[19],RN4H[30],RN4I[30],RN4W[30],RN8F(17)[30],\n\ RN8G(17)[30],RN8X(17)[20],RN9F(17)[30],RN9G(17)[30],RN9X(17)[20],\n\ RO1I(17)[20],RO1N[19],RO1O[19],RO1P[20],RO1Z[19],RO4H[30],RO4I[30],\n\ RO4W[30],RO8F(17)[30],RO8G(17)[30],RO8X(17)[20],RO9F(17)[30],RO9G(17)[30],\n\ RO9X(17)[20],RQ1I(17)[20],RQ1N[19],RQ1O[19],RQ1P[20],RQ1Z[19],RQ4H[30],\n\ RQ4I[30],RQ4W[30],RQ8F(17)[30],RQ8G(17)[30],RQ8X(17)[20],RQ9F(17)[30],\n\ RQ9G(17)[30],RQ9X(17)[20],RT1I(17)[20],RT1N[19],RT1O[19],RT1P[20],\n\ RT1Z[19],RT4H[30],RT4I[30],RT4W[30],RT8F(17)[30],RT8G(17)[30],\n\ RT8X(17)[20],RT9F(17)[30],RT9G(17)[30],RT9X(17)[20],RU1I(17)[20],RU1N[19],\n\ RU1O[19],RU1P[20],RU1Z[19],RU4H[30],RU4I[30],RU4W[30],RU8F(17)[30],\n\ RU8G(17)[30],RU8X(17)[20],RU9F(17)[30],RU9G(17)[30],RU9X(17)[20],\n\ RV1I(17)[20],RV1N[19],RV1O[19],RV1P[20],RV1Z[19],RV4H[30],RV4I[30],\n\ RV4W[30],RV8F(17)[30],RV8G(17)[30],RV8X(17)[20],RV9F(17)[30],RV9G(17)[30],\n\ RV9X(17)[20],RW1I(17)[20],RW1N[19],RW1O[19],RW1P[20],RW1Z[19],RW4H[30],\n\ RW4I[30],RW4W[30],RW8F(17)[30],RW8G(17)[30],RW8X(17)[20],RW9F(17)[30],\n\ RW9G(17)[30],RW9X(17)[20],RX1I(17)[20],RX1N[19],RX1O[19],RX1P[20],\n\ RX1Z[19],RX4H[30],RX4I[30],RX4W[30],RX8F(17)[30],RX8G(17)[30],\n\ RX8X(17)[20],RX9F(17)[30],RX9G(17)[30],RX9X(17)[20],RY1I(17)[20],RY1N[19],\n\ RY1O[19],RY1P[20],RY1Z[19],RY4H[30],RY4I[30],RY4W[30],RY8F(17)[30],\n\ RY8G(17)[30],RY8X(17)[20],RY9F(17)[30],RY9G(17)[30],RY9X(17)[20],\n\ RZ1I(17)[20],RZ1N[19],RZ1O[19],RZ1P[20],RZ1Z[19],RZ4H[30],RZ4I[30],\n\ RZ4W[30],RZ8F(17)[30],RZ8G(17)[30],RZ8X(17)[20],RZ9F(17)[30],RZ9G(17)[30],\n\ RZ9X(17)[20],U1I(17)[20],U1N[19],U1O[19],U1P[20],U1Z[19],U4H[30],U4I[30],\n\ U4W[30],U8F(17)[30],U8G(17)[30],U8X(17)[20],U9F(17)[30],U9G(17)[30],\n\ U9X(17)[20],UA1I(17)[20],UA1N[19],UA1O[19],UA1P[20],UA1Z[19],UA4H[30],\n\ UA4I[30],UA4W[30],UA8F(17)[30],UA8G(17)[30],UA8X(17)[20],UA9F(17)[30],\n\ UA9G(17)[30],UA9X(17)[20],UB1I(17)[20],UB1N[19],UB1O[19],UB1P[20],\n\ UB1Z[19],UB4H[30],UB4I[30],UB4W[30],UB8F(17)[30],UB8G(17)[30],\n\ UB8X(17)[20],UB9F(17)[30],UB9G(17)[30],UB9X(17)[20],UC1I(17)[20],UC1N[19],\n\ UC1O[19],UC1P[20],UC1Z[19],UC4H[30],UC4I[30],UC4W[30],UC8F(17)[30],\n\ UC8G(17)[30],UC8X(17)[20],UC9F(17)[30],UC9G(17)[30],UC9X(17)[20],\n\ UD1I(17)[20],UD1N[19],UD1O[19],UD1P[20],UD1Z[19],UD4H[30],UD4I[30],\n\ UD4W[30],UD8F(17)[30],UD8G(17)[30],UD8X(17)[20],UD9F(17)[30],UD9G(17)[30],\n\ UD9X(17)[20],UE1I(17)[20],UE1N[19],UE1O[19],UE1P[20],UE1Z[19],UE4H[30],\n\ UE4I[30],UE4W[30],UE8F(17)[30],UE8G(17)[30],UE8X(17)[20],UE9F(17)[30],\n\ UE9G(17)[30],UE9X(17)[20],UF1I(17)[20],UF1N[19],UF1O[19],UF1P[20],\n\ UF1Z[19],UF4H[30],UF4I[30],UF4W[30],UF8F(17)[30],UF8G(17)[30],\n\ UF8X(17)[20],UF9F(17)[30],UF9G(17)[30],UF9X(17)[20],UG1I(17)[20],UG1N[19],\n\ UG1O[19],UG1P[20],UG1Z[19],UG4H[30],UG4I[30],UG4W[30],UG8F(17)[30],\n\ UG8G(17)[30],UG8X(17)[20],UG9F(17)[30],UG9G(17)[30],UG9X(17)[20],\n\ UH1I(17)[20],UH1N[19],UH1O[19],UH1P[20],UH1Z[19],UH4H[30],UH4I[30],\n\ UH4W[30],UH8F(17)[30],UH8G(17)[30],UH8X(17)[20],UH9F(17)[30],UH9G(17)[30],\n\ UH9X(17)[20],UI1I(17)[20],UI1N[19],UI1O[19],UI1P[20],UI1Z[19],UI4H[30],\n\ UI4I[30],UI4W[30],UI8F(17)[30],UI8G(17)[30],UI8X(17)[20],UI9F(17)[30],\n\ UI9G(17)[30],UI9X(17)[20],=R7AB/P,=RA9UUY/6,=RT9T/3,=R0AI/3,=R100UD[30],\n\ =R4HAT[29],=R4HC[29],=R4HCE[29],=R4HCZ[29],=R4HD[29],=R4HDC[29],\n\ =R4HDR[29],=R4HL[29],=R4IC[29],=R4ID[29],=R4II[29],=R4IK[29],=R4IM[29],\n\ =R4IN[29],=R4IO[29],=R4IT[29],=R925RZ,=RA4HL[29],=RA4NCC[30],=RC4HT[29],\n\ =RC4I[29],=RC8C/6,=RJ4I[29],=RJ4P[30],=RK4HM[29],=RK4P[30],=RM4I[29],\n\ =RM4R[30],=RN2FA/3,=RN4HFJ[29],=RN4HIF[29],=RT30DX[30],=RT9K/6,=RU4HD[29],\n\ =RU4HP[29],=RU4I[29],=RU9CK/7,=RW4HM[29],=RW4HTK[29],=RW4HW[29],\n\ =RW4HZ[29],=RW9WJ/4[30],=RX9KT/6,=UA3LMR/P,=UA4H[29],=UA4HBM[29],\n\ =UA4HGL[29],=UA4HIP[29],=UA4HRZ[29],=UA4HY[29],=UA4NF[30],=UA4PN[30],\n\ =UA4RF[30],=UA9CSA/1[19],=UC4I[29],=UI4I[29];\n\ Kaliningrad: 15: 29: EU: 54.72: -20.52: -3.0: UA2:\n\ R2F,R2K,RA2,RC2F,RC2K,RD2F,RD2K,RE2F,RE2K,RF2F,RF2K,RG2F,RG2K,RJ2F,RJ2K,\n\ RK2F,RK2K,RL2F,RL2K,RM2F,RM2K,RN2F,RN2K,RO2F,RO2K,RQ2F,RQ2K,RT2F,RT2K,\n\ RU2F,RU2K,RV2F,RV2K,RW2F,RW2K,RX2F,RX2K,RY2F,RY2K,RZ2F,RZ2K,U2F,U2K,UA2,\n\ UB2,UC2,UD2,UE2,UF2,UG2,UH2,UI2,=R2MWO,=RN1M/P,=RV30DX;\n\ Asiatic Russia: 17: 30: AS: 55.88: -84.08: -7.0: UA9:\n\ R0,R8(17)[30],R9,RA0,RA8(17)[30],RA9,RC0,RC8(17)[30],RC9,RD0,RD8(17)[30],\n\ RD9,RE0,RE8(17)[30],RE9,RF0,RF8(17)[30],RF9,RG0,RG8(17)[30],RG9,RI0,\n\ RI8(17)[30],RI9,RJ0,RJ8(17)[30],RJ9,RK0,RK8(17)[30],RK9,RL0,RL8(17)[30],\n\ RL9,RM0,RM8(17)[30],RM9,RN0,RN8(17)[30],RN9,RO0,RO8(17)[30],RO9,RQ0,\n\ RQ8(17)[30],RQ9,RT0,RT8(17)[30],RT9,RU0,RU8(17)[30],RU9,RV0,RV8(17)[30],\n\ RV9,RW0,RW8(17)[30],RW9,RX0,RX8(17)[30],RX9,RY0,RY8(17)[30],RY9,RZ0,\n\ RZ8(17)[30],RZ9,U0,U8(17)[30],U9,UA0,UA8(17)[30],UA9,UB0,UB8(17)[30],UB9,\n\ UC0,UC8(17)[30],UC9,UD0,UD8(17)[30],UD9,UE0,UE8(17)[30],UE9,UF0,\n\ UF8(17)[30],UF9,UG0,UG8(17)[30],UG9,UH0,UH8(17)[30],UH9,UI0,UI8(17)[30],\n\ UI9,R0T(18)[32],R8H(18)[31],R8I(18)[31],R8O(18)[31],R8P(18)[31],\n\ R8S(16)[30],R8T(16)[30],R8U(18)[31],R8V(18)[31],R8W(16)[30],R8Y(18)[31],\n\ R8Z(18)[31],R9I(18)[31],R9M(17)[30],R9P(18)[31],R9S(16),R9T(16),\n\ R9V(18)[31],R9W(16),RA0T(18)[32],RA8H(18)[31],RA8I(18)[31],RA8O(18)[31],\n\ RA8P(18)[31],RA8S(16)[30],RA8T(16)[30],RA8U(18)[31],RA8V(18)[31],\n\ RA8W(16)[30],RA8Y(18)[31],RA8Z(18)[31],RA9I(18)[31],RA9M(17)[30],\n\ RA9P(18)[31],RA9S(16),RA9T(16),RA9V(18)[31],RA9W(16),RC0T(18)[32],\n\ RC8H(18)[31],RC8I(18)[31],RC8O(18)[31],RC8P(18)[31],RC8S(16)[30],\n\ RC8T(16)[30],RC8U(18)[31],RC8V(18)[31],RC8W(16)[30],RC8Y(18)[31],\n\ RC8Z(18)[31],RC9I(18)[31],RC9M(17)[30],RC9P(18)[31],RC9S(16),RC9T(16),\n\ RC9V(18)[31],RC9W(16),RD0T(18)[32],RD8H(18)[31],RD8I(18)[31],RD8O(18)[31],\n\ RD8P(18)[31],RD8S(16)[30],RD8T(16)[30],RD8U(18)[31],RD8V(18)[31],\n\ RD8W(16)[30],RD8Y(18)[31],RD8Z(18)[31],RD9I(18)[31],RD9M(17)[30],\n\ RD9P(18)[31],RD9S(16),RD9T(16),RD9V(18)[31],RD9W(16),RE0T(18)[32],\n\ RE8H(18)[31],RE8I(18)[31],RE8O(18)[31],RE8P(18)[31],RE8S(16)[30],\n\ RE8T(16)[30],RE8U(18)[31],RE8V(18)[31],RE8W(16)[30],RE8Y(18)[31],\n\ RE8Z(18)[31],RE9I(18)[31],RE9M(17)[30],RE9P(18)[31],RE9S(16),RE9T(16),\n\ RE9V(18)[31],RE9W(16),RF0T(18)[32],RF8H(18)[31],RF8I(18)[31],RF8O(18)[31],\n\ RF8P(18)[31],RF8S(16)[30],RF8T(16)[30],RF8U(18)[31],RF8V(18)[31],\n\ RF8W(16)[30],RF8Y(18)[31],RF8Z(18)[31],RF9I(18)[31],RF9M(17)[30],\n\ RF9P(18)[31],RF9S(16),RF9T(16),RF9V(18)[31],RF9W(16),RG0T(18)[32],\n\ RG8H(18)[31],RG8I(18)[31],RG8O(18)[31],RG8P(18)[31],RG8S(16)[30],\n\ RG8T(16)[30],RG8U(18)[31],RG8V(18)[31],RG8W(16)[30],RG8Y(18)[31],\n\ RG8Z(18)[31],RG9I(18)[31],RG9M(17)[30],RG9P(18)[31],RG9S(16),RG9T(16),\n\ RG9V(18)[31],RG9W(16),RJ0T(18)[32],RJ8H(18)[31],RJ8I(18)[31],RJ8O(18)[31],\n\ RJ8P(18)[31],RJ8S(16)[30],RJ8T(16)[30],RJ8U(18)[31],RJ8V(18)[31],\n\ RJ8W(16)[30],RJ8Y(18)[31],RJ8Z(18)[31],RJ9I(18)[31],RJ9M(17)[30],\n\ RJ9P(18)[31],RJ9S(16),RJ9T(16),RJ9V(18)[31],RJ9W(16),RK0T(18)[32],\n\ RK8H(18)[31],RK8I(18)[31],RK8O(18)[31],RK8P(18)[31],RK8S(16)[30],\n\ RK8T(16)[30],RK8U(18)[31],RK8V(18)[31],RK8W(16)[30],RK8Y(18)[31],\n\ RK8Z(18)[31],RK9I(18)[31],RK9M(17)[30],RK9P(18)[31],RK9S(16),RK9T(16),\n\ RK9V(18)[31],RK9W(16),RL0T(18)[32],RL8H(18)[31],RL8I(18)[31],RL8O(18)[31],\n\ RL8P(18)[31],RL8S(16)[30],RL8T(16)[30],RL8U(18)[31],RL8V(18)[31],\n\ RL8W(16)[30],RL8Y(18)[31],RL8Z(18)[31],RL9I(18)[31],RL9M(17)[30],\n\ RL9P(18)[31],RL9S(16),RL9T(16),RL9V(18)[31],RL9W(16),RM0T(18)[32],\n\ RM8H(18)[31],RM8I(18)[31],RM8O(18)[31],RM8P(18)[31],RM8S(16)[30],\n\ RM8T(16)[30],RM8U(18)[31],RM8V(18)[31],RM8W(16)[30],RM8Y(18)[31],\n\ RM8Z(18)[31],RM9I(18)[31],RM9M(17)[30],RM9P(18)[31],RM9S(16),RM9T(16),\n\ RM9V(18)[31],RM9W(16),RN0T(18)[32],RN8H(18)[31],RN8I(18)[31],RN8O(18)[31],\n\ RN8P(18)[31],RN8S(16)[30],RN8T(16)[30],RN8U(18)[31],RN8V(18)[31],\n\ RN8W(16)[30],RN8Y(18)[31],RN8Z(18)[31],RN9I(18)[31],RN9M(17)[30],\n\ RN9P(18)[31],RN9S(16),RN9T(16),RN9V(18)[31],RN9W(16),RO0T(18)[32],\n\ RO8H(18)[31],RO8I(18)[31],RO8O(18)[31],RO8P(18)[31],RO8S(16)[30],\n\ RO8T(16)[30],RO8U(18)[31],RO8V(18)[31],RO8W(16)[30],RO8Y(18)[31],\n\ RO8Z(18)[31],RO9I(18)[31],RO9M(17)[30],RO9P(18)[31],RO9S(16),RO9T(16),\n\ RO9V(18)[31],RO9W(16),RQ0T(18)[32],RQ8H(18)[31],RQ8I(18)[31],RQ8O(18)[31],\n\ RQ8P(18)[31],RQ8S(16)[30],RQ8T(16)[30],RQ8U(18)[31],RQ8V(18)[31],\n\ RQ8W(16)[30],RQ8Y(18)[31],RQ8Z(18)[31],RQ9I(18)[31],RQ9M(17)[30],\n\ RQ9P(18)[31],RQ9S(16),RQ9T(16),RQ9V(18)[31],RQ9W(16),RT0T(18)[32],\n\ RT8H(18)[31],RT8I(18)[31],RT8O(18)[31],RT8P(18)[31],RT8S(16)[30],\n\ RT8T(16)[30],RT8U(18)[31],RT8V(18)[31],RT8W(16)[30],RT8Y(18)[31],\n\ RT8Z(18)[31],RT9I(18)[31],RT9M(17)[30],RT9P(18)[31],RT9S(16),RT9T(16),\n\ RT9V(18)[31],RT9W(16),RU0T(18)[32],RU8H(18)[31],RU8I(18)[31],RU8O(18)[31],\n\ RU8P(18)[31],RU8S(16)[30],RU8T(16)[30],RU8U(18)[31],RU8V(18)[31],\n\ RU8W(16)[30],RU8Y(18)[31],RU8Z(18)[31],RU9I(18)[31],RU9M(17)[30],\n\ RU9P(18)[31],RU9S(16),RU9T(16),RU9V(18)[31],RU9W(16),RV0T(18)[32],\n\ RV8H(18)[31],RV8I(18)[31],RV8O(18)[31],RV8P(18)[31],RV8S(16)[30],\n\ RV8T(16)[30],RV8U(18)[31],RV8V(18)[31],RV8W(16)[30],RV8Y(18)[31],\n\ RV8Z(18)[31],RV9I(18)[31],RV9M(17)[30],RV9P(18)[31],RV9S(16),RV9T(16),\n\ RV9V(18)[31],RV9W(16),RW0T(18)[32],RW8H(18)[31],RW8I(18)[31],RW8O(18)[31],\n\ RW8P(18)[31],RW8S(16)[30],RW8T(16)[30],RW8U(18)[31],RW8V(18)[31],\n\ RW8W(16)[30],RW8Y(18)[31],RW8Z(18)[31],RW9I(18)[31],RW9M(17)[30],\n\ RW9P(18)[31],RW9S(16),RW9T(16),RW9V(18)[31],RW9W(16),RX0T(18)[32],\n\ RX8H(18)[31],RX8I(18)[31],RX8O(18)[31],RX8P(18)[31],RX8S(16)[30],\n\ RX8T(16)[30],RX8U(18)[31],RX8V(18)[31],RX8W(16)[30],RX8Y(18)[31],\n\ RX8Z(18)[31],RX9I(18)[31],RX9M(17)[30],RX9P(18)[31],RX9S(16),RX9T(16),\n\ RX9V(18)[31],RX9W(16),RY0T(18)[32],RY8H(18)[31],RY8I(18)[31],RY8O(18)[31],\n\ RY8P(18)[31],RY8S(16)[30],RY8T(16)[30],RY8U(18)[31],RY8V(18)[31],\n\ RY8W(16)[30],RY8Y(18)[31],RY8Z(18)[31],RY9I(18)[31],RY9M(17)[30],\n\ RY9P(18)[31],RY9S(16),RY9T(16),RY9V(18)[31],RY9W(16),RZ0T(18)[32],\n\ RZ8H(18)[31],RZ8I(18)[31],RZ8O(18)[31],RZ8P(18)[31],RZ8S(16)[30],\n\ RZ8T(16)[30],RZ8U(18)[31],RZ8V(18)[31],RZ8W(16)[30],RZ8Y(18)[31],\n\ RZ8Z(18)[31],RZ9I(18)[31],RZ9M(17)[30],RZ9P(18)[31],RZ9S(16),RZ9T(16),\n\ RZ9V(18)[31],RZ9W(16),U0T(18)[32],U8H(18)[31],U8I(18)[31],U8O(18)[31],\n\ U8P(18)[31],U8S(16)[30],U8T(16)[30],U8U(18)[31],U8V(18)[31],U8W(16)[30],\n\ U8Y(18)[31],U8Z(18)[31],U9I(18)[31],U9M(17)[30],U9P(18)[31],U9S(16),\n\ U9T(16),U9V(18)[31],U9W(16),UA0T(18)[32],UA8H(18)[31],UA8I(18)[31],\n\ UA8O(18)[31],UA8P(18)[31],UA8S(16)[30],UA8T(16)[30],UA8U(18)[31],\n\ UA8V(18)[31],UA8W(16)[30],UA8Y(18)[31],UA8Z(18)[31],UA9I(18)[31],\n\ UA9M(17)[30],UA9P(18)[31],UA9S(16),UA9T(16),UA9V(18)[31],UA9W(16),\n\ UB0T(18)[32],UB8H(18)[31],UB8I(18)[31],UB8O(18)[31],UB8P(18)[31],\n\ UB8S(16)[30],UB8T(16)[30],UB8U(18)[31],UB8V(18)[31],UB8W(16)[30],\n\ UB8Y(18)[31],UB8Z(18)[31],UB9I(18)[31],UB9M(17)[30],UB9P(18)[31],UB9S(16),\n\ UB9T(16),UB9V(18)[31],UB9W(16),UC0T(18)[32],UC8H(18)[31],UC8I(18)[31],\n\ UC8O(18)[31],UC8P(18)[31],UC8S(16)[30],UC8T(16)[30],UC8U(18)[31],\n\ UC8V(18)[31],UC8W(16)[30],UC8Y(18)[31],UC8Z(18)[31],UC9I(18)[31],\n\ UC9M(17)[30],UC9P(18)[31],UC9S(16),UC9T(16),UC9V(18)[31],UC9W(16),\n\ UD0T(18)[32],UD8H(18)[31],UD8I(18)[31],UD8O(18)[31],UD8P(18)[31],\n\ UD8S(16)[30],UD8T(16)[30],UD8U(18)[31],UD8V(18)[31],UD8W(16)[30],\n\ UD8Y(18)[31],UD8Z(18)[31],UD9I(18)[31],UD9M(17)[30],UD9P(18)[31],UD9S(16),\n\ UD9T(16),UD9V(18)[31],UD9W(16),UE0T(18)[32],UE8H(18)[31],UE8I(18)[31],\n\ UE8O(18)[31],UE8P(18)[31],UE8S(16)[30],UE8T(16)[30],UE8U(18)[31],\n\ UE8V(18)[31],UE8W(16)[30],UE8Y(18)[31],UE8Z(18)[31],UE9I(18)[31],\n\ UE9M(17)[30],UE9P(18)[31],UE9S(16),UE9T(16),UE9V(18)[31],UE9W(16),\n\ UF0T(18)[32],UF8H(18)[31],UF8I(18)[31],UF8O(18)[31],UF8P(18)[31],\n\ UF8S(16)[30],UF8T(16)[30],UF8U(18)[31],UF8V(18)[31],UF8W(16)[30],\n\ UF8Y(18)[31],UF8Z(18)[31],UF9I(18)[31],UF9M(17)[30],UF9P(18)[31],UF9S(16),\n\ UF9T(16),UF9V(18)[31],UF9W(16),UG0T(18)[32],UG8H(18)[31],UG8I(18)[31],\n\ UG8O(18)[31],UG8P(18)[31],UG8S(16)[30],UG8T(16)[30],UG8U(18)[31],\n\ UG8V(18)[31],UG8W(16)[30],UG8Y(18)[31],UG8Z(18)[31],UG9I(18)[31],\n\ UG9M(17)[30],UG9P(18)[31],UG9S(16),UG9T(16),UG9V(18)[31],UG9W(16),\n\ UH0T(18)[32],UH8H(18)[31],UH8I(18)[31],UH8O(18)[31],UH8P(18)[31],\n\ UH8S(16)[30],UH8T(16)[30],UH8U(18)[31],UH8V(18)[31],UH8W(16)[30],\n\ UH8Y(18)[31],UH8Z(18)[31],UH9I(18)[31],UH9M(17)[30],UH9P(18)[31],UH9S(16),\n\ UH9T(16),UH9V(18)[31],UH9W(16),UI0T(18)[32],UI8H(18)[31],UI8I(18)[31],\n\ UI8O(18)[31],UI8P(18)[31],UI8S(16)[30],UI8T(16)[30],UI8U(18)[31],\n\ UI8V(18)[31],UI8W(16)[30],UI8Y(18)[31],UI8Z(18)[31],UI9I(18)[31],\n\ UI9M(17)[30],UI9P(18)[31],UI9S(16),UI9T(16),UI9V(18)[31],UI9W(16),\n\ =R05SOTA(16),=R0WA/P(18)[32],=R1FW/0(19)[34],=R2ET/9(18)[31],=R30EMER,\n\ =R30MDXC(17)[30],=R8MZ/9(23)[32],=R9GM/8(17)[30],=RA/UT5IA(19)[23],\n\ =RA0QK/8(17)[30],=RA4RU/9[20],=RM30DX,=RN1CR/0(19)[34],=RN9S(16),\n\ =RQ30DX(18)[32],=RT8T(16)[30],=RT9S(16),=RV7B/9[20],=RX30DX(19)[34],\n\ =RX6DL/8(17)[30],=RY30DX,=RZ30DX(19)[34],=UD6AOP/0(19)[35];\n\ Uzbekistan: 17: 30: AS: 41.40: -63.97: -5.0: UK:\n\ UJ,UK,UL,UM;\n\ Kazakhstan: 17: 30: AS: 48.17: -65.18: -5.0: UN:\n\ UN,UO,UP,UQ,UN0F[31],UN0G[31],UN0J[31],UN0Q[31],UN2F[31],UN2G[31],\n\ UN2J[31],UN2Q[31],UN3F[31],UN3G[31],UN3J[31],UN3Q[31],UN4F[31],UN4G[31],\n\ UN4J[31],UN4Q[31],UN5F[31],UN5G[31],UN5J[31],UN5Q[31],UN6F[31],UN6G[31],\n\ UN6J[31],UN6Q[31],UN7F[31],UN7G[31],UN7J[31],UN7Q[31],UN8F[31],UN8G[31],\n\ UN8J[31],UN8Q[31],UN9F[31],UN9G[31],UN9J[31],UN9Q[31],UO0F[31],UO0G[31],\n\ UO0J[31],UO0Q[31],UO1F[31],UO1G[31],UO1J[31],UO1Q[31],UO2F[31],UO2G[31],\n\ UO2J[31],UO2Q[31],UO3F[31],UO3G[31],UO3J[31],UO3Q[31],UO4F[31],UO4G[31],\n\ UO4J[31],UO4Q[31],UO5F[31],UO5G[31],UO5J[31],UO5Q[31],UO6F[31],UO6G[31],\n\ UO6J[31],UO6Q[31],UO7F[31],UO7G[31],UO7J[31],UO7Q[31],UO8F[31],UO8G[31],\n\ UO8J[31],UO8Q[31],UO9F[31],UO9G[31],UO9J[31],UO9Q[31],UP0F[31],UP0G[31],\n\ UP0J[31],UP0Q[31],UP1F[31],UP1G[31],UP1J[31],UP1Q[31],UP2F[31],UP2G[31],\n\ UP2J[31],UP2Q[31],UP3F[31],UP3G[31],UP3J[31],UP3Q[31],UP4F[31],UP4G[31],\n\ UP4J[31],UP4Q[31],UP5F[31],UP5G[31],UP5J[31],UP5Q[31],UP6F[31],UP6G[31],\n\ UP6J[31],UP6Q[31],UP7F[31],UP7G[31],UP7J[31],UP7Q[31],UP8F[31],UP8G[31],\n\ UP8J[31],UP8Q[31],UP9F[31],UP9G[31],UP9J[31],UP9Q[31],UQ0F[31],UQ0G[31],\n\ UQ0J[31],UQ0Q[31],UQ1F[31],UQ1G[31],UQ1J[31],UQ1Q[31],UQ2F[31],UQ2G[31],\n\ UQ2J[31],UQ2Q[31],UQ3F[31],UQ3G[31],UQ3J[31],UQ3Q[31],UQ4F[31],UQ4G[31],\n\ UQ4J[31],UQ4Q[31],UQ5F[31],UQ5G[31],UQ5J[31],UQ5Q[31],UQ6F[31],UQ6G[31],\n\ UQ6J[31],UQ6Q[31],UQ7F[31],UQ7G[31],UQ7J[31],UQ7Q[31],UQ8F[31],UQ8G[31],\n\ UQ8J[31],UQ8Q[31],UQ9F[31],UQ9G[31],UQ9J[31],UQ9Q[31];\n\ Ukraine: 16: 29: EU: 50.00: -30.00: -2.0: UR:\n\ EM,EN,EO,U5,UR,US,UT,UU,UV,UW,UX,UY,UZ;\n\ Antigua & Barbuda: 08: 11: NA: 17.07: 61.80: 4.0: V2:\n\ V2;\n\ Belize: 07: 11: NA: 16.97: 88.67: 6.0: V3:\n\ V3;\n\ St. Kitts & Nevis: 08: 11: NA: 17.37: 62.78: 4.0: V4:\n\ V4;\n\ Namibia: 38: 57: AF: -22.00: -17.00: -1.0: V5:\n\ V5;\n\ Micronesia: 27: 65: OC: 6.88: -158.20: -10.0: V6:\n\ V6;\n\ Marshall Islands: 31: 65: OC: 9.08: -167.33: -12.0: V7:\n\ V7;\n\ Brunei Darussalam: 28: 54: OC: 4.50: -114.60: -8.0: V8:\n\ V8;\n\ Canada: 05: 09: NA: 44.35: 78.75: 5.0: VE:\n\ CF,CG,CJ,CK,VA,VB,VC,VE,VG,VX,VY9,XL,XM,CF2[4],CG2[4],CH1,CH2(2),\n\ CI0(2)[4],CI1(1)[2],CI2,CJ2[4],CK2[4],CY1,CY2(2),CZ0(2)[4],CZ1(1)[2],CZ2,\n\ VA2[4],VB2[4],VC2[4],VD1,VD2(2),VE2[4],VF0(2)[4],VF1(1)[2],VF2,VG2[4],VO1,\n\ VO2(2),VX2[4],VY0(2)[4],VY1(1)[2],VY2,XJ1,XJ2(2),XK0(2)[4],XK1(1)[2],XK2,\n\ XL2[4],XM2[4],XN1,XN2(2),XO0(2)[4],XO1(1)[2],XO2,=VER20201112,\n\ =VA2VVV(2)[4],=VE2CSI(2)[4],=VE2EKA(2)[4],=VE2FK[9],=VE2IDX(2)[4],\n\ =VE2IM(2)[4],=VE2TKH(2)[4],=VY0AA(4)[3],=VY0PW(4)[3];\n\ Australia: 30: 59: OC: -23.70: -132.33: -10.0: VK:\n\ AX,VH,VI,VJ,VK,VL,VM,VN,VZ,AX4[55],VH4[55],VI4[55],VJ4[55],VK4[55],\n\ VL4[55],VM4[55],VN4[55],VZ4[55],=VK65PFA[55];\n\ Heard Island: 39: 68: AF: -53.08: -73.50: -5.0: VK0H:\n\ =VK0EK;\n\ Macquarie Island: 30: 60: OC: -54.60: -158.88: -10.0: VK0M:\n\ =VK0AI;\n\ Cocos (Keeling) Islands: 29: 54: OC: -12.15: -96.82: -6.5: VK9C:\n\ AX9C,AX9Y,VH9C,VH9Y,VI9C,VI9Y,VJ9C,VJ9Y,VK9C,VK9FC,VK9KC,VK9Y,VK9ZY,VL9C,\n\ VL9Y,VM9C,VM9Y,VN9C,VN9Y,VZ9C,VZ9Y;\n\ Lord Howe Island: 30: 60: OC: -31.55: -159.08: -10.5: VK9L:\n\ AX9L,VH9L,VI9L,VJ9L,VK9FL,VK9L,VK9ZL,VL9L,VM9L,VN9L,VZ9L,=VK3YQS/9,\n\ =VK3YQS/VK9;\n\ Mellish Reef: 30: 56: OC: -17.40: -155.85: -10.0: VK9M:\n\ AX9M,VH9M,VI9M,VJ9M,VK9M,VL9M,VM9M,VN9M,VZ9M;\n\ Norfolk Island: 32: 60: OC: -29.03: -167.93: -11.5: VK9N:\n\ AX9,VH9,VI9,VJ9,VK9,VL9,VM9,VN9,VZ9;\n\ Willis Island: 30: 55: OC: -16.22: -150.02: -10.0: VK9W:\n\ AX9W,AX9Z,VH9W,VH9Z,VI9W,VI9Z,VJ9W,VJ9Z,VK9FW,VK9W,VK9Z,VL9W,VL9Z,VM9W,\n\ VM9Z,VN9W,VN9Z,VZ9W,VZ9Z;\n\ Christmas Island: 29: 54: OC: -10.48: -105.63: -7.0: VK9X:\n\ AX9X,VH9X,VI9X,VJ9X,VK9FX,VK9KX,VK9X,VL9X,VM9X,VN9X,VZ9X;\n\ Anguilla: 08: 11: NA: 18.23: 63.00: 4.0: VP2E:\n\ VP2E;\n\ Montserrat: 08: 11: NA: 16.75: 62.18: 4.0: VP2M:\n\ VP2M;\n\ British Virgin Islands: 08: 11: NA: 18.33: 64.75: 4.0: VP2V:\n\ VP2V;\n\ Turks & Caicos Islands: 08: 11: NA: 21.77: 71.75: 5.0: VP5:\n\ VP5,VQ5;\n\ Pitcairn Island: 32: 63: OC: -25.07: 130.10: 8.0: VP6:\n\ VP6;\n\ Ducie Island: 32: 63: OC: -24.70: 124.80: 8.0: VP6/d:\n\ =VP6D;\n\ Falkland Islands: 13: 16: SA: -51.63: 58.72: 4.0: VP8:\n\ VP8;\n\ South Georgia Island: 13: 73: SA: -54.48: 37.08: 2.0: VP8/g:\n\ =VP8CA;\n\ South Shetland Islands: 13: 73: SA: -62.08: 58.67: 4.0: VP8/h:\n\ CE9,XR9,=HF0POL;\n\ South Orkney Islands: 13: 73: SA: -60.60: 45.55: 3.0: VP8/o:\n\ =VP8PJ;\n\ South Sandwich Islands: 13: 73: SA: -58.43: 26.33: 2.0: VP8/s:\n\ =VP8DXU;\n\ Bermuda: 05: 11: NA: 32.32: 64.73: 4.0: VP9:\n\ VP9;\n\ Chagos Islands: 39: 41: AF: -7.32: -72.42: -6.0: VQ9:\n\ VQ9;\n\ Hong Kong: 24: 44: AS: 22.28: -114.18: -8.0: VR:\n\ VR;\n\ India: 22: 41: AS: 22.50: -77.58: -5.5: VU:\n\ 8T,8U,8V,8W,8X,8Y,AT,AU,AV,AW,VT,VU,VV,VW;\n\ Andaman & Nicobar Is.: 26: 49: AS: 12.37: -92.78: -5.5: VU4:\n\ VU4;\n\ Lakshadweep Islands: 22: 41: AS: 11.23: -72.78: -5.5: VU7:\n\ VU7;\n\ Mexico: 06: 10: NA: 21.32: 100.23: 6.0: XE:\n\ 4A,4B,4C,6D,6E,6F,6G,6H,6I,6J,XA,XB,XC,XD,XE,XF,XG,XH,XI;\n\ Revillagigedo: 06: 10: NA: 18.77: 110.97: 7.0: XF4:\n\ 4A4,4B4,4C4,6D4,6E4,6F4,6G4,6H4,6I4,6J4,XA4,XB4,XC4,XD4,XE4,XF4,XG4,XH4,\n\ XI4;\n\ Burkina Faso: 35: 46: AF: 12.00: 2.00: 0.0: XT:\n\ XT;\n\ Cambodia: 26: 49: AS: 12.93: -105.13: -7.0: XU:\n\ XU;\n\ Laos: 26: 49: AS: 18.20: -104.55: -7.0: XW:\n\ XW;\n\ Macao: 24: 44: AS: 22.10: -113.50: -8.0: XX9:\n\ XX9;\n\ Myanmar: 26: 49: AS: 20.00: -96.37: -6.5: XZ:\n\ XY,XZ;\n\ Afghanistan: 21: 40: AS: 34.70: -65.80: -4.5: YA:\n\ T6,YA;\n\ Indonesia: 28: 51: OC: -7.30: -109.88: -7.0: YB:\n\ 7A,7B,7C,7D,7E,7F,7G,7H,7I,8A,8B,8C,8D,8E,8F,8G,8H,8I,PK,PL,PM,PN,PO,YB,\n\ YC,YD,YE,YF,YG,YH,7A0[54],7A1[54],7A2[54],7A3[54],7A4[54],7A5[54],7A6[54],\n\ 7A7[54],7A8[54],7B0[54],7B1[54],7B2[54],7B3[54],7B4[54],7B5[54],7B6[54],\n\ 7B7[54],7B8[54],7C0[54],7C1[54],7C2[54],7C3[54],7C4[54],7C5[54],7C6[54],\n\ 7C7[54],7C8[54],7D0[54],7D1[54],7D2[54],7D3[54],7D4[54],7D5[54],7D6[54],\n\ 7D7[54],7D8[54],7E0[54],7E1[54],7E2[54],7E3[54],7E4[54],7E5[54],7E6[54],\n\ 7E7[54],7E8[54],7F0[54],7F1[54],7F2[54],7F3[54],7F4[54],7F5[54],7F6[54],\n\ 7F7[54],7F8[54],7G0[54],7G1[54],7G2[54],7G3[54],7G4[54],7G5[54],7G6[54],\n\ 7G7[54],7G8[54],7H0[54],7H1[54],7H2[54],7H3[54],7H4[54],7H5[54],7H6[54],\n\ 7H7[54],7H8[54],7I0[54],7I1[54],7I2[54],7I3[54],7I4[54],7I5[54],7I6[54],\n\ 7I7[54],7I8[54],8A0[54],8A1[54],8A2[54],8A3[54],8A4[54],8A5[54],8A6[54],\n\ 8A7[54],8A8[54],8B0[54],8B1[54],8B2[54],8B3[54],8B4[54],8B5[54],8B6[54],\n\ 8B7[54],8B8[54],8C0[54],8C1[54],8C2[54],8C3[54],8C4[54],8C5[54],8C6[54],\n\ 8C7[54],8C8[54],8D0[54],8D1[54],8D2[54],8D3[54],8D4[54],8D5[54],8D6[54],\n\ 8D7[54],8D8[54],8E0[54],8E1[54],8E2[54],8E3[54],8E4[54],8E5[54],8E6[54],\n\ 8E7[54],8E8[54],8F0[54],8F1[54],8F2[54],8F3[54],8F4[54],8F5[54],8F6[54],\n\ 8F7[54],8F8[54],8G0[54],8G1[54],8G2[54],8G3[54],8G4[54],8G5[54],8G6[54],\n\ 8G7[54],8G8[54],8H0[54],8H1[54],8H2[54],8H3[54],8H4[54],8H5[54],8H6[54],\n\ 8H7[54],8H8[54],8I0[54],8I1[54],8I2[54],8I3[54],8I4[54],8I5[54],8I6[54],\n\ 8I7[54],8I8[54],YB0[54],YB1[54],YB2[54],YB3[54],YB4[54],YB5[54],YB6[54],\n\ YB7[54],YB8[54],YC0[54],YC1[54],YC2[54],YC3[54],YC4[54],YC5[54],YC6[54],\n\ YC7[54],YC8[54],YD0[54],YD1[54],YD2[54],YD3[54],YD4[54],YD5[54],YD6[54],\n\ YD7[54],YD8[54],YE0[54],YE1[54],YE2[54],YE3[54],YE4[54],YE5[54],YE6[54],\n\ YE7[54],YE8[54],YF0[54],YF1[54],YF2[54],YF3[54],YF4[54],YF5[54],YF6[54],\n\ YF7[54],YF8[54],YG0[54],YG1[54],YG2[54],YG3[54],YG4[54],YG5[54],YG6[54],\n\ YG7[54],YG8[54],YH0[54],YH1[54],YH2[54],YH3[54],YH4[54],YH5[54],YH6[54],\n\ YH7[54],YH8[54];\n\ Iraq: 21: 39: AS: 33.92: -42.78: -3.0: YI:\n\ HN,YI;\n\ Vanuatu: 32: 56: OC: -17.67: -168.38: -11.0: YJ:\n\ YJ;\n\ Syria: 20: 39: AS: 35.38: -38.20: -2.0: YK:\n\ 6C,YK;\n\ Latvia: 15: 29: EU: 57.03: -24.65: -2.0: YL:\n\ YL;\n\ Nicaragua: 07: 11: NA: 12.88: 85.05: 6.0: YN:\n\ H6,H7,HT,YN;\n\ Romania: 20: 28: EU: 45.78: -24.70: -2.0: YO:\n\ YO,YP,YQ,YR;\n\ El Salvador: 07: 11: NA: 14.00: 89.00: 6.0: YS:\n\ HU,YS;\n\ Serbia: 15: 28: EU: 44.00: -21.00: -1.0: YU:\n\ YT,YU;\n\ Venezuela: 09: 12: SA: 8.00: 66.00: 4.5: YV:\n\ 4M,YV,YW,YX,YY;\n\ Aves Island: 08: 11: NA: 15.67: 63.60: 4.0: YV0:\n\ 4M0,YV0,YW0,YX0,YY0;\n\ Zimbabwe: 38: 53: AF: -18.00: -31.00: -2.0: Z2:\n\ Z2;\n\ North Macedonia: 15: 28: EU: 41.60: -21.65: -1.0: Z3:\n\ Z3;\n\ Republic of Kosovo: 15: 28: EU: 42.67: -21.17: -1.0: Z6:\n\ Z6;\n\ Republic of South Sudan: 34: 48: AF: 4.85: -31.60: -3.0: Z8:\n\ Z8;\n\ Albania: 15: 28: EU: 41.00: -20.00: -1.0: ZA:\n\ ZA;\n\ Gibraltar: 14: 37: EU: 36.15: 5.37: -1.0: ZB:\n\ ZB,ZG;\n\ UK Base Areas on Cyprus: 20: 39: AS: 35.32: -33.57: -2.0: ZC4:\n\ ZC4;\n\ St. Helena: 36: 66: AF: -15.97: 5.72: 0.0: ZD7:\n\ ZD7;\n\ Ascension Island: 36: 66: AF: -7.93: 14.37: 0.0: ZD8:\n\ ZD8;\n\ Tristan da Cunha & Gough: 38: 66: AF: -37.13: 12.30: 0.0: ZD9:\n\ ZD9;\n\ Cayman Islands: 08: 11: NA: 19.32: 81.22: 5.0: ZF:\n\ ZF;\n\ Tokelau Islands: 31: 62: OC: -9.40: 171.20: -13.0: ZK3:\n\ ZK3;\n\ New Zealand: 32: 60: OC: -39.03: -174.47: -12.0: ZL:\n\ ZK,ZL,ZL50,ZM;\n\ Chatham Islands: 32: 60: OC: -43.85: 176.48: -12.75: ZL7:\n\ ZL7,ZM7;\n\ Kermadec Islands: 32: 60: OC: -29.25: 177.92: -12.0: ZL8:\n\ ZL8,ZM8;\n\ N.Z. Subantarctic Is.: 32: 60: OC: -51.62: -167.62: -12.0: ZL9:\n\ ZL9;\n\ Paraguay: 11: 14: SA: -25.27: 57.67: 4.0: ZP:\n\ ZP;\n\ South Africa: 38: 57: AF: -29.07: -22.63: -2.0: ZS:\n\ H5,S4,S8,V9,ZR,ZS,ZT,ZU;\n\ Pr. Edward & Marion Is.: 38: 57: AF: -46.88: -37.72: -3.0: ZS8:\n\ ZR8,ZS8,ZT8,ZU8;\ " ;
84,128
C++
.cxx
1,351
58.373797
81
0.520647
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,241
counties.cxx
w1hkj_fldigi/src/logbook/counties.cxx
// ---------------------------------------------------------------------------- // counties.cxx // // Copyright (C) 2006-2010 // Dave Freese, W1HKJ // Copyright (C) 2008-2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // Extracted from FIPS 2010 census data #include <iostream> #include <fstream> #include "main.h" #include "counties.h" #include "contest.h" #include "configuration.h" #include "debug.h" #include "strutil.h" //---------------------------------------------------------------------- Cstates states; std::vector<STATE_COUNTY_QUAD> vec_SQSO; std::vector<STATE_COUNTY_QUAD> vec_6QP; std::vector<STATE_COUNTY_QUAD> vec_7QP; void load_from_string(std::string &str, std::vector<STATE_COUNTY_QUAD> &vec) { size_t ptr1 = 0; size_t ptr2 = 0; size_t ptr3 = 0; std::string line; STATE_COUNTY_QUAD scq; vec.clear(); // eat first line ptr1 = str.find("\n"); line = str.substr(ptr1); LOG_INFO("%s data read from internal data string", (&vec == &vec_SQSO ? "SQSO" : &vec == &vec_6QP ? "NEQP" : "7QP")); ptr1++; ptr2 = str.find("\n", ptr1); while (ptr2 != std::string::npos) { line = str.substr(ptr1, ptr2 - ptr1); if (line.empty()) break; ptr3 = line.find(","); scq.state = line.substr(0,ptr3); line.erase(0, ptr3 + 1); ptr3 = line.find(","); scq.ST = line.substr(0,ptr3); line.erase(0, ptr3 + 1); ptr3 = line.find(","); scq.county = line.substr(0,ptr3); line.erase(0, ptr3 + 1); scq.CTY = line; if (!scq.ST.empty()) vec.push_back(scq); ptr1 = ptr2 + 1; ptr2 = str.find("\n", ptr1); } LOG_INFO("Read %d records", (int)vec.size()); } void load_from_file( std::string &fname, std::vector<STATE_COUNTY_QUAD> &vec) { std::ifstream csvfile(fname.c_str()); if (!csvfile) return; vec.clear(); std::string line; line.reserve(1024); char str[1024]; STATE_COUNTY_QUAD scq; // eat the header line memset(str, 0, 1024); csvfile.getline(str, 1024); LOG_INFO("%s data read from %s", (&vec == &vec_SQSO ? "SQSO" : &vec == &vec_6QP ? "NEQP" : "7QP"), fname.c_str()); size_t ptr = 0; while (!csvfile.eof()) { memset(str, 0, 1024); csvfile.getline(str, 1024); line = str; if (line.empty()) break; ptr = line.find(","); scq.state = line.substr(0,ptr); line.erase(0, ptr + 1); ptr = line.find(","); scq.ST = line.substr(0,ptr); line.erase(0, ptr + 1); ptr = line.find(","); scq.county = line.substr(0,ptr); line.erase(0, ptr + 1); scq.CTY = line; if (!scq.ST.empty()) vec.push_back(scq); } csvfile.close(); LOG_INFO("Read %d records", (int)vec.size()); } void load_SQSO() { std::string cnty_file = DATA_dir; cnty_file.append("SQSO.txt"); std::ifstream csvfile(cnty_file.c_str()); if (!csvfile) { std::string str = szSQSO; load_from_string( str, vec_SQSO ); return; } csvfile.close(); load_from_file( cnty_file, vec_SQSO ); } void load_7qp() { std::string cnty_file = DATA_dir; cnty_file.append("7QP.txt"); std::ifstream csvfile(cnty_file.c_str()); if (!csvfile) { std::string str = sz7QP; load_from_string( str, vec_7QP ); return; } csvfile.close(); load_from_file( cnty_file, vec_7QP ); } void load_neqp() { std::string cnty_file = DATA_dir; cnty_file.append("NEQP.txt"); std::ifstream csvfile(cnty_file.c_str()); if (!csvfile) { std::string str = szNEQP; load_from_string(str, vec_6QP); return; } csvfile.close(); load_from_file( cnty_file, vec_6QP ); } void save_SQSO() { std::string cnty_file = DATA_dir; cnty_file.append("SQSO.txt"); std::ofstream csvfile(cnty_file.c_str()); if (!csvfile) { // std::cout << "cannot create " << cnty_file << std::endl; return; } csvfile << "State/Province, ST/PR, County/City/Disrict, CCD" << std::endl; for (size_t n = 0; n < vec_SQSO.size(); n++ ) csvfile << vec_SQSO[n].state << "," << vec_SQSO[n].ST << "," << vec_SQSO[n].county << "," << vec_SQSO[n].CTY << std::endl; csvfile.close(); //std::cout << vec_SQSO.size() << " records written to " << cnty_file << std::endl; } void save_7qp() { std::string cnty_file = DATA_dir; cnty_file.append("7QP.txt"); std::ofstream csvfile(cnty_file.c_str()); if (!csvfile) { // std::cout << "cannot create " << cnty_file << std::endl; return; } csvfile << "State, ST, County/City, CC" << std::endl; for (size_t n = 0; n < vec_7QP.size(); n++) csvfile << vec_7QP[n].state << "," << vec_7QP[n].ST << "," << vec_7QP[n].county << "," << vec_7QP[n].CTY << std::endl; csvfile.close(); //std::cout << vec_7QP.size() << " records written to " << cnty_file << std::endl; } void save_neqp() { std::string cnty_file = DATA_dir; cnty_file.append("NEQP.txt"); std::ofstream csvfile(cnty_file.c_str()); if (!csvfile) { // std::cout << "cannot create " << cnty_file << std::endl; return; } csvfile << "State, ST, County/City, CC" << std::endl; for (size_t n = 0; n < vec_6QP.size(); n++) csvfile << vec_6QP[n].state << "," << vec_6QP[n].ST << "," << vec_6QP[n].county << "," << vec_6QP[n].CTY << std::endl; csvfile.close(); //std::cout << vec_6QP.size() << " records written to " << cnty_file << std::endl; } void save_counties() { save_SQSO(); save_7qp(); save_neqp(); } void load_counties() { load_SQSO(); load_7qp(); load_neqp(); } //---------------------------------------------------------------------- bool Cstates::valid_county( std::string st, std::string cnty ) { std::string ST = ucasestr(st); std::string CNTY = ucasestr(cnty); std::string dST, dCNTY, dCOUNTY; if (std::string(QSOparties.qso_parties[progdefaults.SQSOcontest].state) == "7QP") { for (size_t n = 0; n < vec_7QP.size(); n++) { dST = ucasestr(vec_7QP[n].ST); dCNTY = ucasestr(vec_7QP[n].CTY); dCOUNTY = ucasestr(vec_7QP[n].county); if ( ST != dST ) continue; if (CNTY == dCNTY) return true; if (CNTY == dCOUNTY) return true; } } else if (std::string(QSOparties.qso_parties[progdefaults.SQSOcontest].state) == "6NE") { for (size_t n = 0; n < vec_6QP.size(); n++) { dST = ucasestr(vec_6QP[n].ST); dCNTY = ucasestr(vec_6QP[n].CTY); dCOUNTY = ucasestr(vec_6QP[n].county); if ( ST != dST ) continue; if (CNTY == dCNTY) return true; if (CNTY == dCOUNTY) return true; } } else { for (size_t n = 0; n < vec_SQSO.size(); n++) { dST = ucasestr(vec_SQSO[n].ST); dCNTY = ucasestr(vec_SQSO[n].CTY); dCOUNTY = ucasestr(vec_SQSO[n].county); if ( ST != dST ) continue; if (CNTY == dCNTY) return true; if (CNTY == dCOUNTY) return true; } } return false; } const std::string Cstates::names() { std::string _names = vec_SQSO[0].state; std::string _st = vec_SQSO[0].ST; for (size_t n = 0; n < vec_SQSO.size(); n++) { if (_st != vec_SQSO[n].ST && !vec_SQSO[n].ST.empty()) { _names.append("|").append(vec_SQSO[n].state); _st = vec_SQSO[n].ST; } } return _names; } const std::string Cstates::state_short(std::string ST) // ST can be either short or long form { for (size_t n = 0; n < vec_SQSO.size(); n++) if (ST == vec_SQSO[n].ST || ST == vec_SQSO[n].state) return vec_SQSO[n].ST; return ""; } const std::string Cstates::state(std::string ST) // ST can be either short or long form { for (size_t n = 0; n < vec_SQSO.size(); n++) if (ST == vec_SQSO[n].ST || ST == vec_SQSO[n].state) return vec_SQSO[n].state; return ""; } const std::string Cstates::counties(std::string ST) { std::string _counties = ""; if (ST == "NIL") return _counties; size_t n = 0; if (std::string(QSOparties.qso_parties[progdefaults.SQSOcontest].state) == "7QP") { for (n = 0; n < vec_7QP.size(); n++) { if (ST == vec_7QP[n].ST || ST == vec_7QP[n].state) { ST = vec_7QP[n].ST; if (!_counties.empty() ) _counties.append("|"); _counties.append(vec_7QP[n].county); continue; } if (!_counties.empty() && ST != vec_7QP[n].ST && ST != vec_7QP[n].state ) break; } } else if (std::string(QSOparties.qso_parties[progdefaults.SQSOcontest].state) == "6NE") { for (size_t n = 0; n < vec_6QP.size(); n++) { if (ST == vec_6QP[n].ST || ST == vec_6QP[n].state) { ST = vec_6QP[n].ST; if (!_counties.empty() ) _counties.append("|"); _counties.append(vec_6QP[n].county); continue; } if (!_counties.empty() && ST != vec_6QP[n].ST && ST != vec_6QP[n].state ) break; } } else { for (n = 0; n < vec_SQSO.size(); n++) { if (ST == vec_SQSO[n].ST || ST == vec_SQSO[n].state) { ST = vec_SQSO[n].ST; if (!_counties.empty() ) _counties.append("|"); _counties.append(vec_SQSO[n].county); continue; } if (!_counties.empty() && ST != vec_SQSO[n].ST && ST != vec_SQSO[n].state ) break; } } return _counties; } const std::string Cstates::cnty_short( std::string st, std::string cnty) // st/cnty can be either short or long { std::string ST = ucasestr(st); std::string CNTY = ucasestr(cnty); std::string dSTATE, dST, dCNTY, dCOUNTY; std::string answer = ""; size_t n = 0; bool OK = false; if (std::string(QSOparties.qso_parties[progdefaults.SQSOcontest].state) == "7QP") { for (n = 0; n < vec_7QP.size(); n++) { dST = ucasestr(vec_7QP[n].ST); dSTATE = ucasestr(vec_7QP[n].state); if (ST == dST) {OK = true; break;} if (ST == dSTATE) { OK = true; break; } } if (!OK) return answer; ST = vec_7QP[n].ST; for (size_t k = n; ST == vec_7QP[k].ST, k < vec_7QP.size(); k++) { dCNTY = ucasestr(vec_7QP[k].CTY); dCOUNTY = ucasestr(vec_7QP[k].county); if (CNTY == dCNTY) { answer = vec_7QP[k].CTY; break; } if (CNTY == dCOUNTY) { answer = vec_7QP[k].CTY; break; } } } else if (std::string(QSOparties.qso_parties[progdefaults.SQSOcontest].state) == "6NE") { for (n = 0; n < vec_6QP.size(); n++) { dST = ucasestr(vec_6QP[n].ST); dSTATE = ucasestr(vec_6QP[n].state); if (ST == dST) {OK = true; break;} if (ST == dSTATE) { OK = true; break; } } if (!OK) return answer; ST = vec_6QP[n].ST; for (size_t k = n; ST == vec_6QP[k].ST, k < vec_6QP.size(); k++) { dCNTY = ucasestr(vec_6QP[k].CTY); dCOUNTY = ucasestr(vec_6QP[k].county); if (CNTY == dCNTY) { answer = vec_6QP[k].CTY; break; } if (CNTY == dCOUNTY) { answer = vec_6QP[k].CTY; break; } } } else { for (n = 0; n < vec_SQSO.size(); n++) { dST = ucasestr(vec_SQSO[n].ST); dSTATE = ucasestr(vec_SQSO[n].state); if (ST == dST) {OK = true; break;} if (ST == dSTATE) { OK = true; break; } } if (!OK) return answer; ST = vec_SQSO[n].ST; for (size_t k = n; ST == vec_SQSO[k].ST, k < vec_SQSO.size(); k++) { dCNTY = ucasestr(vec_SQSO[k].CTY); dCOUNTY = ucasestr(vec_SQSO[k].county); if (CNTY == dCNTY) { answer = vec_SQSO[k].CTY; break; } if (CNTY == dCOUNTY) { answer = vec_SQSO[k].CTY; break; } } } return answer; } const std::string Cstates::county( std::string st, std::string cnty) // st/cnty can be either short or long { std::string ST = ucasestr(st); std::string CNTY = ucasestr(cnty); std::string dST, dCNTY, dCOUNTY; size_t n = 0; if (std::string(QSOparties.qso_parties[progdefaults.SQSOcontest].state) == "7QP") { for (n = 0; n < vec_7QP.size(); n++) { dST = ucasestr(vec_7QP[n].ST); if (ST == dST) break; } if (ST != dST) return ""; ST = vec_7QP[n].ST; for (size_t k = n; ST == vec_7QP[k].ST, k < vec_7QP.size(); k++) { dCNTY = ucasestr(vec_7QP[k].CTY); dCOUNTY = ucasestr(vec_7QP[k].county); if (CNTY == dCNTY) return vec_7QP[k].county; if (CNTY == dCOUNTY) return vec_7QP[k].county; } return ""; } else if (std::string(QSOparties.qso_parties[progdefaults.SQSOcontest].state) == "6NE") { for (n = 0; n < vec_6QP.size(); n++) { dST = ucasestr(vec_6QP[n].ST); if (ST == dST) break; } if (ST != dST) return ""; ST = vec_6QP[n].ST; for (size_t k = n; ST == vec_6QP[k].ST, k < vec_6QP.size(); k++) { if (vec_6QP[k].ST.empty()) return ""; dCNTY = ucasestr(vec_6QP[k].CTY); dCOUNTY = ucasestr(vec_6QP[k].county); if (CNTY == dCNTY) return vec_6QP[k].county; if (CNTY == dCOUNTY) return vec_6QP[k].county; } return ""; } else { for (n = 0; !vec_SQSO[n].ST.empty(); n++) { dST = ucasestr(vec_SQSO[n].ST); if (ST == dST) break; } if (ST != dST) return ""; ST = vec_SQSO[n].ST; for (size_t k = n; ST == vec_SQSO[k].ST, k < vec_SQSO.size(); k++) { if (vec_SQSO[k].ST.empty()) return ""; dCNTY = ucasestr(vec_SQSO[k].CTY); dCOUNTY = ucasestr(vec_SQSO[k].county); if (CNTY == dCNTY) return vec_SQSO[k].county; if (CNTY == dCOUNTY) return vec_SQSO[k].county; } return ""; } return ""; } static std::string __counties; const std::string counties() { load_counties(); if (vec_SQSO.empty()) return ""; __counties.clear(); for (size_t n = 0; n < vec_SQSO.size(); n++ ) { __counties.append(vec_SQSO[n].ST).append(" ").append(vec_SQSO[n].county); if (n < (vec_SQSO.size() - 1)) __counties.append("|"); } return __counties; } /* const std::string seven_qp_counties() { load_7qp(); if (vec_7QP.empty()) return ""; __counties.clear(); for (size_t n = 0; n < vec_7QP.size(); n++ ) { __counties.append(vec_7QP[n].ST).append(" ").append(vec_7QP[n].county).append("|"); if (n < (vec_7QP.size() - 1)) __counties.append("|"); } return __counties; } const std::string six_qp_counties() { load_neqp(); if (vec_6QP.empty()) return ""; __counties.clear(); for (size_t n = 0; n < vec_6QP.size(); n++ ) { __counties.append(vec_6QP[n].ST).append(" ").append(vec_6QP[n].county).append("|"); if (n < (vec_6QP.size() - 1)) __counties.append("|"); } return __counties; } */
14,311
C++
.cxx
488
26.547131
111
0.599156
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,242
maclogger.cxx
w1hkj_fldigi/src/logbook/maclogger.cxx
// ===================================================================== // // maclogger.cxx // // receive log data from maclogger udp broadcast message // // Copyright (C) 2016 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ===================================================================== #include <iostream> #include <cmath> #include <cstring> #include <vector> #include <list> #include <stdlib.h> #include <FL/Fl_Text_Display.H> #include <FL/Fl_Text_Buffer.H> #include "rigsupport.h" #include "modem.h" #include "trx.h" #include "fl_digi.h" #include "configuration.h" #include "main.h" #include "waterfall.h" #include "macros.h" #include "qrunner.h" #include "debug.h" #include "status.h" #include "icons.h" #include "maclogger.h" #include "confdialog.h" LOG_FILE_SOURCE(debug::LOG_MACLOGGER); //====================================================================== // Socket MACLOGGER i/o used on all platforms //====================================================================== pthread_t maclogger_thread; pthread_t maclogger_rx_socket_thread; pthread_mutex_t mclg_str_mutex = PTHREAD_MUTEX_INITIALIZER; Socket *maclogger_socket = 0; bool maclogger_enabled = false; bool maclogger_exit = false; std::string maclogger_ip_address= "";; std::string maclogger_ip_port= "";; std::string mclg_str = ""; int mclg_rxhz; int mclg_txhz; std::string mclg_band; std::string mclg_mode; std::string mclg_power; std::string mclg_call; std::string mclg_dxccnum; std::string mclg_dxccstr; std::string mclg_city; std::string mclg_state; std::string mclg_firstname; std::string mclg_lastname; std::string mclg_comment; std::string mclg_bearing; std::string mclg_longpath; std::string mclg_distance; //====================================================================== // MacLogger UDP string parsing //====================================================================== static std::string get_str(std::string s) { size_t p = s.find(":"); if (p == std::string::npos) return ""; s.erase(0, p+1); p = s.find(","); if (p == std::string::npos) p = s.find("]"); if (p == std::string::npos) return ""; std::string s2 = s.substr(0, p); if (s2 == "(null)") return ""; return s2; } static int get_freq(std::string s) { std::string s2 = get_str(s); size_t dpt = s2.find("."); if (dpt == std::string::npos) return 0; std::string sf = s2.substr(0, dpt); std::string sm = s2.substr(dpt+1); while(sm.length() < 6) sm.append("0"); sf.append(sm); int fr = sf[0] - '0'; for (size_t n = 1; n < sf.length(); n++) { fr *= 10; fr += (sf[n] - '0'); } //std::cout << "string: " << sf << ", int freq: " << fr << std::endl; return fr; } void maclogger_set_qsy() { long hz = mclg_rxhz; if (hz <= 0 || !progdefaults.maclogger_spot_rx) hz = mclg_txhz; if (hz <= 0) return; sendFreq(hz); wf->rfcarrier(hz); wf->movetocenter(); show_frequency(hz); } void maclogger_set_call() { inpCall->value(mclg_call.c_str()); inpCall->do_callback(); } void maclogger_set_name() { inpName->value(mclg_firstname.c_str()); inpName->do_callback(); } void maclogger_set_mode() { // inpMode->value(mclg_mode.c_str()); // inpMode->do_callback(); } void maclogger_set_qth() { inpQth->value(mclg_city.c_str()); inpQth->do_callback(); } void maclogger_set_state() { inpState->value(mclg_state.c_str()); inpState->do_callback(); } void maclogger_disp_report(const char * s) { txt_UDP_data->insert(s); txt_UDP_data->redraw(); } void show_mac_strings() { SET_THREAD_ID(MACLOGGER_TID); if (mclg_txhz > 0) REQ(maclogger_set_qsy); else if (mclg_rxhz > 0) REQ(maclogger_set_qsy); if (!mclg_mode.empty()) REQ(maclogger_set_mode); if (!mclg_call.empty()) REQ(maclogger_set_call); if (!mclg_city.empty()) REQ(maclogger_set_qth); if (!mclg_state.empty()) REQ(maclogger_set_state); if (!mclg_firstname.empty()) REQ(maclogger_set_name); // if (!mclg_power.empty()) // if (!mclg_band.empty()) // if (!mclg_lastname.empty()) // if (!mclg_comment.empty()) // if (!mclg_bearing.empty()) // if (!mclg_longpath.empty()) // if (!mclg_distance.empty()) // if (!mclg_dxccnum.empty()) // if (!mclg_dxccstr.empty()) } void parse_report(std::string str) { size_t p; mclg_rxhz = 0; mclg_txhz = 0; mclg_band.clear(); mclg_mode.clear(); mclg_power.clear(); mclg_call.clear(); mclg_dxccnum.clear(); mclg_dxccstr.clear(); mclg_city.clear(); mclg_state.clear(); mclg_firstname.clear(); mclg_lastname.clear(); mclg_comment.clear(); mclg_bearing.clear(); mclg_longpath.clear(); mclg_distance.clear(); if ((p = str.find("RxMHz:")) != std::string::npos) mclg_rxhz = get_freq(str.substr(p)); if ((p = str.find("TxMHz:")) != std::string::npos) mclg_txhz = get_freq(str.substr(p)); if ((p = str.find("Mode:")) != std::string::npos) mclg_mode = get_str(str.substr(p)); if ((p = str.find("Call:")) != std::string::npos) mclg_call = get_str(str.substr(p)); if ((p = str.find("city:")) != std::string::npos) mclg_city = get_str(str.substr(p)); if ((p = str.find("state:")) != std::string::npos) mclg_state = get_str(str.substr(p)); if ((p = str.find("first_name:")) != std::string::npos) mclg_firstname = get_str(str.substr(p)); // if ((p = mclg_str.find("dxcc_num:")) != std::string::npos) // mclg_dxccnum = get_str(mclg_str.substr(p)); // if ((p = mclg_str.find("dxcc_string:")) != std::string::npos) // mclg_dxccstr = get_str(mclg_str.substr(p)); // if ((p = mclg_str.find("Power:")) != std::string::npos) // mclg_power = get_str(mclg_str.substr(p)); // if ((p = mclg_str.find("Band:")) != std::string::npos) // mclg_band = get_str(mclg_str.substr(p)); // if ((p = mclg_str.find("last_name:")) != std::string::npos) // mclg_lastname = get_str(mclg_str.substr(p)); // if ((p = mclg_str.find("Comment:")) != std::string::npos) // mclg_comment = get_str(mclg_str.substr(p)); // if ((p = mclg_str.find("Bearing:")) != std::string::npos) // mclg_bearing = get_str(mclg_str.substr(p)); // if ((p = mclg_str.find("LongPath:")) != std::string::npos) // mclg_longpath = get_str(mclg_str.substr(p)); // if ((p = mclg_str.find("Distance:")) != std::string::npos) // mclg_distance = get_str(mclg_str.substr(p)); show_mac_strings(); } void parse_maclog() { size_t p1, p2; std::string str; static std::string srep; while (!mclg_str.empty()) { p1 = mclg_str.find("["); if (p1 == std::string::npos) return; if (p1 != 0) mclg_str.erase(0, p1); p2 = mclg_str.find("]"); if (p2 == std::string::npos) return; str = mclg_str.substr(0, p2 + 1); srep = str; srep.append("\n"); REQ(maclogger_disp_report, srep.c_str()); if (progdefaults.enable_maclogger_log) { std::string pathname = TempDir; pathname.append("maclogger_udp_strings.txt"); FILE *maclog = fl_fopen(pathname.c_str(), "a"); fprintf(maclog, "%s", srep.c_str()); fclose(maclog); } if ((progdefaults.capture_maclogger_radio && mclg_str.find("[Radio Report:") != std::string::npos) || (progdefaults.capture_maclogger_spot_tune && mclg_str.find("[SpotTune:") != std::string::npos) || (progdefaults.capture_maclogger_spot_report && mclg_str.find("[Spot Report:") != std::string::npos) || (progdefaults.capture_maclogger_log && mclg_str.find("[Log Report:") != std::string::npos) || (progdefaults.capture_maclogger_lookup && mclg_str.find("[Lookup Report") != std::string::npos) ) parse_report(str); mclg_str.erase(0, p2 + 1); MilliSleep(100); } } //====================================================================== // uncomment to use UDP test strings // // #define TESTSTRINGS 1 // //====================================================================== #ifdef TESTSTRINGS std::string tstring[6] = { "[Radio Report:RxMHz:24.96400, TxMHz:24.96400, Band:12M, Mode:USB, Power:5]", "[SpotTune:RxMHz:3.5095, TxMHz:3.549525, Band:10M, Mode:USB]", "[Log Report: Call:N2BJ, RxMHz:21.08580, TxMHz:21.08580, Band:15M, Mode:FSK, Power:5, dxcc_num:291, dxcc_string:United States, city:NEW LENOX, state:IL, first_name:Barry, last_name:COHEN]", "[Spot Report: RxMHz:3.50300, TxMHz:3.50300, Band:80M, Mode:CW, Call:EP6T, dxcc_string:Iran, Comment:UP , TNX CARLO , GL]", "[Rotor Report: Bearing:304.7, LongPath:0, Distance:0.0]", "[Lookup Report:Call:YC8RBI, RxMHz:21.32500, Band:15M, Mode:USB, dxcc_num:327, dxcc_string:Indonesia, Bearing:328.1, city:SANGIHE ISLAND NORTH SULAWESI, state:(null), first_name:RICHARD, last_name:BYL ( ICHA )]" }; int tnbr = 0; #endif void get_maclogger_udp() { #ifdef TESTSTRINGS if (tnbr == 0) { for (int n = 0; n < 6; n++) { mclg_str = tstring[n]; parse_maclog(); } tnbr = 1; } #else if(!maclogger_socket) return; if (!progdefaults.connect_to_maclogger) return; char buffer[MACLOGGER_BUFFER_SIZE]; size_t count = 0; memset(buffer, 0, sizeof(buffer)); try { count = maclogger_socket->recvFrom( (void *) buffer, sizeof(buffer) - 1); } catch (...) { LOG_WARN("MAC_logger socket error"); count = 0; } if (count) { mclg_str.append(buffer, count); parse_maclog(); } #endif } //====================================================================== // //====================================================================== void *maclogger_loop(void *args) { SET_THREAD_ID(MACLOGGER_TID); LOG_INFO("%s", "MAC_logger loop started. "); while(1) { for (int i = 0; i < 100; i++) { MilliSleep(10); if (maclogger_exit) break; } if (maclogger_exit) break; get_maclogger_udp(); } // exit the maclogger thread SET_THREAD_CANCEL(); return NULL; } //====================================================================== // //====================================================================== bool maclogger_start(void) { maclogger_ip_address = "255.255.255.255"; maclogger_ip_port = "9932"; try { maclogger_socket = new Socket( Address( maclogger_ip_address.c_str(), maclogger_ip_port.c_str(), "udp") ); maclogger_socket->set_autoclose(true); maclogger_socket->set_nonblocking(false); maclogger_socket->bindUDP(); } catch (const SocketException& e) { LOG_ERROR( "Could not resolve %s: %s", maclogger_ip_address.c_str(), e.what() ); return false; } return true; } //====================================================================== // //====================================================================== void maclogger_init(void) { maclogger_enabled = false; maclogger_exit = false; #ifndef TESTSTRINGS if(!maclogger_start()) return; LOG_INFO("%s", "UDP Init - OK"); #endif if (pthread_create(&maclogger_thread, NULL, maclogger_loop, NULL) < 0) { LOG_ERROR("MACLOGGER maclogger_thread: pthread_create failed"); return; } LOG_INFO("MACLOGGER thread started"); maclogger_enabled = true; } //====================================================================== // //====================================================================== void maclogger_close(void) { if (!maclogger_enabled) return; if(maclogger_socket) { maclogger_socket->shut_down(); maclogger_socket->close(); } maclogger_exit = true; pthread_join(maclogger_thread, NULL); LOG_INFO("%s", "MAC_logger loop terminated. "); maclogger_enabled = false; #ifdef TESTSTRINGS tnbr = 0; #endif }
11,854
C++
.cxx
384
28.914063
212
0.606783
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,243
contest.cxx
w1hkj_fldigi/src/logbook/contest.cxx
// ---------------------------------------------------------------------------- // contest.cxx // // Copyright (C) 2006-2010 // Dave Freese, W1HKJ // Copyright (C) 2008-2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <iostream> #include <FL/Fl.H> #include "fl_digi.h" #include "confdialog.h" #include "contest.h" #include "icons.h" #include "dxcc.h" #include "strutil.h" static std::string SECTIONS = "\ DX \ CT RI EMA VT ME WMA NH \ ENY NNY NLI SNJ NNJ WHY \ DE MDC EPA WPA \ AL GA KY NC NFL PR SC SFL TN VA \ VI WCF AR LA MS NM NTX OK STX WTX \ EB LAX ORG PAC SB SCV SDG SF SJV SV \ AK AZ EWA ID MT NV OR UT WWA WY \ MI OH WV \ IL IN WI \ CO IA KS MN MO ND NE SD \ AB BC GTA MAR MB NL NT ONE ONN ONS QC SK "; static std::string STATES = "\ DX CT MA ME NH RI VT \ NY NJ \ DE PA MD DC \ AL FL GA KY NC SC TN VA \ AR LA MS NM OK TX \ CA HI \ AK AZ ID MT NV OR UT WA WY \ MI OH WV \ IL WI IN \ CO IA KS MN MO ND NE SD "; static std::string PROVINCES = "\ AB BC LB MB NB NF NS NU NWT ON PEI QC SK YT "; static std::string MEXICO = "\ XE1 XE2 XE3 XF1 XF4 "; static std::string IT1_ = "AL AT BI CN GE IM NO SP SV TO VB VC "; static std::string IX1_ = "AO "; static std::string IT2_ = "BG BS CO CR LC LO MB MI MN PV SO VA "; static std::string IT3_ = "BL PD RO TV VE VI VR "; static std::string IN3_ = "BZ TN "; static std::string IV3_ = "GO PN TS UD "; static std::string IT4_ = "BO FC FE MO PC PR RA RE RN "; static std::string IT5_ = "AR FI GR LI LU MS PI PO PT SI "; static std::string IT6_ = "AN AP AQ CH FM MC PE PS PU TE "; static std::string IT7_ = "BA BR BT FG LE MT TA "; static std::string IT8_ = "AV BN CB CE CS CZ IS KR NA PZ RC SA VV "; static std::string IT0_ = "FR LT PG RI RM TR VT "; static std::string IT9_ = "AG CL CT EN ME PA RG SR TP "; static std::string IS0_ = "CA NU OR SS SU "; static const std::vector<dxcc*>* dxcc_list; std::string country_match = ""; bool class_test(std::string s) { if (s.length() < 2) return false; static std::string clss = "ABCDEF"; if (clss.find(toupper(s[s.length()-1])) == std::string::npos) return false; for (size_t n = 0; n < s.length() - 1; n++) if (s[n] < '0' || s[n] > '9') return false; return true; } bool state_test(std::string s) { if (s.empty()) return false; while (s.length() < 4) s.append(" "); bool isState = (STATES.find(ucasestr(s)) != std::string::npos); return isState; } bool county_test(std::string st, std::string cty) { if (st.empty() && !progdefaults.SQSOinstate) st = QSOparties.qso_parties[progdefaults.SQSOcontest].state; if (!state_test(st)) return false; return states.valid_county( st, cty ); } bool province_test(std::string s) { while (s.length() < 4) s.append(" "); return (PROVINCES.find(ucasestr(s)) != std::string::npos); } bool district_test(std::string pr, std::string dist) { if (pr.empty() && !progdefaults.SQSOinstate) pr = QSOparties.qso_parties[progdefaults.SQSOcontest].state; if (!province_test(pr)) return false; return states.valid_county( pr, dist ); } bool check_test(std::string s) { if (s.length() < 4) { while (s.length() < 4) s.append(" "); std::string CHECK = std::string(STATES).append(PROVINCES).append(MEXICO); return (CHECK.find(s) != std::string::npos); } else return false; } bool country_test(std::string s) { std::string str = ucasestr(s); dxcc_list = dxcc_entity_list(); if (!dxcc_list) return true; for (std::vector<dxcc*>::const_iterator i = dxcc_list->begin(); i != dxcc_list->end(); ++i) { if (ucasestr((*i)->country).find(str) != std::string::npos) { country_match = (*i)->country; return true; } } country_match.clear(); return false; } bool wfd_class_test(std::string s) { if (s.length() < 2) return false; static std::string clss = "IOH"; if (clss.find(toupper(s[s.length()-1])) == std::string::npos) return false; for (size_t n = 0; n < s.length() - 1; n++) if (s[n] < '0' || s[n] > '9') return false; return true; } bool ascr_class_test(std::string s) { if (s.length() != 1) return false; if (toupper(s[0]) == 'I' || toupper(s[0]) == 'C' || toupper(s[0]) == 'S') return true; return false; } bool section_test(std::string s) { while (s.length() < 4) s.append(" "); return (SECTIONS.find(s) != std::string::npos); } bool rookie_test(std::string s) { int year_licensed = 0; if (!sscanf(s.c_str(), "%d", &year_licensed)) return false; if (year_licensed < 100) year_licensed += 2000; int year_worked = 0; std::string s_year = std::string(zdate()).substr(0,4); sscanf(s_year.c_str(), "%d", &year_worked); if (year_worked < year_licensed) year_licensed -= 100; if (year_worked - year_licensed < 3) return true; return false; } bool c1010_test(std::string s) { for (size_t n = 0; n < s.length(); n++) if (s[n] < '0' || s[n] > '9') return false; return true; } static std::string nbrs0 = "1234567890"; static std::string nbrs1 = "12345"; static std::string nbrs2 = "123456789Nn"; static std::string nbrs3 = "1234567890NnTt"; std::string cut_to_numeric(std::string s) { for (size_t n = 0; n < s.length(); n++) { if (s[n] == 'N' || s[n] == 'n' ) s[n] = '9'; if (s[n] == 'T' || s[n] == 't' ) s[n] = '0'; } return s; } bool cut_numeric_test(std::string s) { if (s.empty()) return false; for (size_t n = 0; n < s.length(); n++) if (nbrs3.find(s[n]) == std::string::npos) return false; return true; } bool numeric_test(std::string s) { if (s.empty()) return false; for (size_t n = 0; n < s.length(); n++) if (nbrs0.find(s[n]) == std::string::npos) return false; return true; } bool rst_test(std::string s) { if (s.length() < 3 && active_modem->get_mode() < MODE_SSB) return false; if (s.length() < 2 || s.length() > 3) return false; if (s[0] == '0') return false; if (s.length() == 2) { if (nbrs1.find(s[0]) == std::string::npos) return false; if (nbrs2.find(s[1]) == std::string::npos) return false; } else { if (nbrs1.find(s[0]) == std::string::npos) return false; if (nbrs2.find(s[1]) == std::string::npos) return false; if (nbrs2.find(s[2]) == std::string::npos) return false; } return true; } bool italian_test(std::string s) { if (s.length() != 2) return false; s.append(" "); if (IT1_.find(s) != std::string::npos || IX1_.find(s) != std::string::npos || IT2_.find(s) != std::string::npos || IT3_.find(s) != std::string::npos || IN3_.find(s) != std::string::npos || IV3_.find(s) != std::string::npos || IT4_.find(s) != std::string::npos || IT5_.find(s) != std::string::npos || IT6_.find(s) != std::string::npos || IT7_.find(s) != std::string::npos || IT8_.find(s) != std::string::npos || IT0_.find(s) != std::string::npos || IT9_.find(s) != std::string::npos || IS0_.find(s) != std::string::npos ) return true; return false; } bool ss_chk_test(std::string s) { std::string nums = "0123456789"; if (nums.find(s[0]) != std::string::npos && nums.find(s[0]) != std::string::npos) return true; return false; } bool ss_prec_test(std::string s) { std::string prec = "QABUMS"; if (prec.find(ucasestr(s)[0]) != std::string::npos) return true; return false; } int check_field(std::string s, CONTEST_FIELD field, std::string s2) { switch (field) { case cSTATE: return state_test(s); break; case cVE_PROV: return province_test(s); break; case cCHECK: return check_test(s); break; case cCOUNTRY: return country_test(s); break; case cCLASS: case cFD_CLASS: return class_test(s); break; case cWFD_CLASS: return wfd_class_test(s); break; case cASCR_CLASS: return ascr_class_test(s); break; case cARRL_SECT: case cFD_SECTION: return section_test(s); break; case cROOKIE: return rookie_test(s); break; case c1010: return c1010_test(s); break; case cRST: return rst_test(s); break; case cSRX: case cNUMERIC: return numeric_test(s); break; case cITALIAN: return italian_test(s); break; case cCNTY: return county_test(s2, s); break; case cDIST: return district_test(s2, s); break; case cSS_CHK: return ss_chk_test(s); break; case cSS_PREC: return ss_prec_test(s); break; case cSS_SERNO: return numeric_test(s); break; case cSS_SEC: return section_test(s); break; case cNAME: break; case cQTH: break; case cGRIDSQUARE: break; case cXCHG1: break; case cKD_XCHG: break; case cARR_XCHG: break; case cCQZ: break; default: break; } return true; } CONTESTS contests[] = { { "No Contest", "CALL if (RSTr), if (LOCATOR), NAME, QTH" }, { "Generic contest", "CALL EXCHANGE" }, { "Africa All-Mode International", "CALL SERNO, COUNTRY, RSTr, RSTs" }, { "ARRL Field Day", "CALL SECTION, CLASS, RSTr, RSTs" }, { "ARRL International DX (cw)", "CALL COUNTRY, POWER, RSTr, RSTs" }, { "ARRL Jamboree on the Air", "CALL TROOP_NO, STATE / VE_PROV / COUNTRY, RSTr, RSTs, SCOUT_NAME" }, { "ARRL Kids Day", "CALL, NAME, AGE, QTH, COMMENT, RSTr, RSTs" }, { "ARRL Rookie Roundup", "CALL, NAME, CHECK, STATE / VE_PROV, RSTr, RSTs" }, { "ARRL RTTY Roundup", "CALL STATE, SERNO, COUNTRY, RSTr, RSTs" }, { "ARRL School Club Roundup", "CALL CLASS, STATE / VE_PROV, NAME, RSTr, RSTs" }, { "ARRL November Sweepstakes", "CALL SECTION, SERNO, PREC, CHECK, RSTr, RSTs" }, { "ARRL Winter FD", "CALL SECTION, CLASS, RSTr, RSTs" }, { "BARTG RTTY contest", "CALL NAME, SERIAL, EXCHANGE" }, { "CQ WPX", "CALL SERNO, COUNTRY, RSTr, RSTs" }, { "CQ WW DX", "CALL COUNTRY, ZONE, RSTr, RSTs" }, { "CQ WW DX RTTY", "CALL STATE, COUNTRY, ZONE, RSTr" }, { "Italian A.R.I. International DX", "CALL PR(ovince), COUNTRY, SERNO, RSTr, RSTs" }, { "NAQP", "CALL NAME, STATE / VE_PROV / COUNTRY" }, { "NA Sprint", "CALL SERNO, STATE / VE_PROV / COUNTRY, NAME, RSTr, RSTs" }, { "Ten Ten", "CALL 1010NR, STATE, NAME, RSTr, RSTs" }, { "VHF", "CALL RSTr, RSTs" }, //{ "Worked All Europe", "CALL SERNO, COUNTRY, RSTr, RSTs" }, { "State QSO parties", "" }, { "", "" } }; struct QSOP Ccontests::qso_parties[] = { /* {"QSO Party Contest", "ST", "in", "rRST","rST","rCY","rSER","rXCHG","rNAM","rCAT", "STCTY", "Notes"}, */ {"None selected", "", "", "", "", "", "", "", "", "", "", "CALL if (RSTr), if (LOCATOR), NAME, QTH" }, {"Alabama QSO Party", "AL", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"ALQP (Out of State)", "AL", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Arizona QSO Party", "AZ", "T", "B", "B", "B", "" , "", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"AZQP (Out of State)", "AZ", "", "B", "B", "B", "" , "", "", "", "", "CALL RST CNTY"}, {"Arkansas QSO Party", "AR", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"ARQP (Out of State)", "AR", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"British Columbia QSO Party", "BC", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"BCQP (Out of Province)", "BC", "", "B", "B", "B", "", "", "", "", "", "CALL RST CNTY"}, {"California QSO Party", "CA", "T", "", "B", "B", "B", "I", "", "", "", "CALL SERNO CNTY ST/PR/CNTRY"}, {"CAQP (Out of State)", "CA", "", "", "B", "B", "B", "I", "", "", "", "CALL SERNO CNTY"}, {"Colorado QSO Party", "CO", "T", "", "B", "B", "", "I", "B", "", "", "CALL NAME CNTY ST/PR/CNTRY"}, {"COQP (Out of State)", "CO", "", "", "B", "B", "", "I", "B", "", "", "CALL NAME CNTY"}, {"Delaware QSO Party", "DE", "T", "B", "B", "B", "", "", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"DEQP (Out of State)", "DE", "", "B", "B", "B", "", "", "", "", "", "CALL RST CNTY"}, {"Florida QSO Party", "FL", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"FLQP (Out of State)", "FL", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Georgia QSO Party", "GA", "T", "B", "B", "B", "", "" , "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"GAQP (Out of State)", "GA", "", "B", "B", "B", "", "" , "", "", "", "CALL RST CNTY"}, {"Hawaii QSO Party", "HI", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"HIQP (Out of State)", "HI", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Idaho QSO Party", "ID", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"IDQP (Out of State)", "ID", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Illinois QSO Party", "IL", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"ILQP (Out of State)", "IL", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Indiana QSO Party", "IN", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"INQP (Out of State)", "IN", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Iowa QSO Party", "IA", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"IAQP (Out of State)", "IA", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Kansas QSO Party", "KS", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"KSQP (Out of State)", "KS", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Kentucky QSO Party", "KY", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"KYQP (Out of State)", "KY", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Louisiana QSO Party", "LA", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"LAQP (Out of State)", "LA", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Maine QSO Party", "ME", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"MEQP (Out of State)", "ME", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Maryland QSO Party", "MD", "T", "", "B", "B", "", "", "", "B", "", "CALL CAT CNTY ST/PR/CNTRY"}, {"MDQP (Out of State)", "MD", "", "", "B", "B", "", "", "", "B", "", "CALL CAT CNTY"}, {"Michigan QSO Party", "MI", "T", "", "B", "B", "B", "I", "", "", "", "CALL SERNO CNTY ST/PR/CNTRY"}, {"MIQP (Out of State)", "MI", "", "", "B", "B", "B", "I", "", "", "", "CALL SERNO CNTY"}, {"Minnesota QSO Party", "MN", "T", "", "B", "B", "", "I", "B", "", "", "CALL NAME CNTY ST/PR/CNTRY"}, {"MNQP (Out of State)", "MN", "", "", "B", "B", "", "I", "B", "", "", "CALL NAME CNTY"}, {"Missouri QSO Party", "MO", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"MOQP (Out of State)", "MO", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Mississippi QSO Party", "MS", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"MSQP (Out of State)", "MS", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Montana QSO Party", "MT", "T", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"MTQP (Out of State)", "MT", "", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY"}, {"North Carolina QSO Party", "NC", "T", "B", "B", "B", "", "I", "", "", "", "CALL CNTY ST/PR/CNTRY"}, {"NCQP (Out of State)", "NC", "", "B", "B", "B", "", "I", "", "", "", "CALL CNTY"}, {"Nebraska QSO Party", "NE", "T", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"NEQP (Out of State)", "NE", "", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY"}, {"New Jersey QSO Party", "NJ", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"NJQP (Out of State)", "NJ", "", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"New Mexico QSO Party", "NM", "T", "", "B", "B", "", "I", "B", "", "", "CALL NAME CNTY ST/PR/CNTRY"}, {"NMQP (Out of State)", "NM", "", "", "B", "B", "", "I", "B", "", "", "CALL NAME CNTY"}, {"New York QSO Party", "NY", "T", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"NYQP (Out of State)", "NY", "", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY"}, {"North Dakota QSO Party", "ND", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"NDQP (Out of State)", "ND", " ", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY"}, {"Ohio QSO Party", "OH", "T", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"OHQP (Out of State)", "OH", "", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY"}, {"Oklahoma QSO Party", "OK", "T", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"OKQP (Out of State)", "OK", "", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY"}, {"Ontario QSO Party", "ON", "T", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"ONQP (Out of Province)", "ON", "", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY"}, {"Pennsylvania QSO Party", "PA", "T", "", "B", "B", "B", "I", "", "", "", "CALL SERNO CNTY ST/PR/CNTRY"}, {"PAQP (Out of State)", "PA", "", "", "B", "B", "B", "I", "", "", "", "CALL SERNO CNTY"}, {"South Carolina QSO Party" , "SC", "T", "B", "B", "B", "", "", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"SCQP (Out of State)", "SC", "", "B", "B", "B", "", "", "", "", "", "CALL CNTY"}, {"South Dakota QSO Party", "SD", "T", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"SDQP (Out of State)", "SD", "", "B", "B", "B", "", "B", "", "", "", "CALL CNTY"}, {"Tennessee QSO Party", "TN", "T", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"TNQP (Out of State)", "TN", "", "B", "B", "B", "", "B", "", "", "", "CALL CNTY"}, {"Texas QSO Party", "TX", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"TXQP (Out of State)", "TX", "", "B", "B", "B", "", "I", "", "", "", "CALL CNTY"}, {"Vermont QSO Party", "VT", "T", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"VTQP (Out of State)", "VT", "", "B", "B", "B", "", "B", "", "", "", "CALL CNTY"}, {"Virginia QSO Party", "VA", "T", "", "B", "B", "B", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"VAQP (Out of State)", "VA", "", "", "B", "B", "B", "I", "", "", "", "CALL CNTY"}, {"Washington Salmon Run QSO Party","WA", "T", "B", "B", "B", "", "B", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"WAQP (Out of State)", "WA", "", "B", "B", "B", "", "B", "", "", "", "CALL CNTY"}, {"Wisconsin QSO Party", "WI", "T", "B", "B", "B", "", "I", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"WIQP (Out of State)", "WI", "", "B", "B", "B", "", "I", "", "", "", "CALL CNTY"}, {"West Virginia QSO Party", "WV", "T", "B", "B", "B", "", "", "", "", "", "CALL RST CNTY ST/PR/CNTRY"}, {"WVQP (Out of State)", "WV", "", "B", "B", "B", "", "", "", "", "", "CALL CNTY"}, {"7QP QSO Party", "7QP","T", "B", "B", "B", "", "I", "", "", "S", "CALL RST [(ST COUNTY) or (STCNTY) or (DX)]"}, {"7QP (Out of Region)", "7QP","", "B", "B", "B", "", "I", "", "", "S", "CALL RST [(ST COUNTY) or (STCNTY)]"}, {"New England QSO Party", "6NE","T", "B", "B", "B", "", "I", "", "", "C", "CALL RST [(ST COUNTY) or (CNTYST) or (DX)]"}, {"NEQP (Out of Region)", "6NE","", "B", "B", "B", "", "I", "", "", "C", "CALL RST [(ST COUNTY) or (CNTYST)]"}, {"", "", "", "", "", "", "", "", "", "", "", ""} }; //{"Alaska QSO Party", "AK", "T", "", "", "", "", "", "", "", "", ""}, //{"Connecticut QSO Party", "CT", "T", "", "", "", "", "", "", "", "", ""}, //{"Massachusetts QSO Party", "MA", "T", "", "", "", "", "", "", "", "", ""}, //{"New Hampshire QSO Party", "NH", "T", "", "", "", "", "", "", "", "", ""}, //{"Nevada QSO Party", "NV", "T", "", "", "", "", "", "", "", "", ""}, //{"Oregon QSO Party", "OR", "T", "", "", "", "", "", "", "", "", ""}, //{"Rhode Island QSO Party", "RI", "T", "", "", "", "", "", "", "", "", ""}, //{"Utah QSO Party", "UT", "T", "", "", "", "", "", "", "", "", ""}, //{"Wyoming QSO Party", "WY", "T", "", "", "", "", "", "", "", "", ""}, std::string contest_names() { std::string _names; for (size_t n = 0; n < sizeof(contests) / sizeof(*contests) - 1; n++) _names.append(contests[n].name).append("|"); return _names; } Ccontests QSOparties; const std::string Ccontests::names() { std::string _names; for (size_t n = 0; n < sizeof(qso_parties) / sizeof(*qso_parties) - 1; n++ ) _names.append(qso_parties[n].contest).append("|"); return _names; } const char *Ccontests::notes(std::string party) { for (size_t n = 0; n < sizeof(qso_parties) / sizeof(*qso_parties); n++) if (party == qso_parties[n].contest) return qso_parties[n].notes; return ""; } char Ccontests::rst(std::string party) { for (size_t n = 0; n < sizeof(qso_parties) / sizeof(*qso_parties); n++) if (party == qso_parties[n].contest) return qso_parties[n].rst[0]; return ' '; } char Ccontests::st(std::string party) { for (size_t n = 0; n < sizeof(qso_parties) / sizeof(*qso_parties); n++) if (party == qso_parties[n].contest) return qso_parties[n].st[0]; return ' '; } char Ccontests::cnty(std::string party) { for (size_t n = 0; n < sizeof(qso_parties) / sizeof(*qso_parties); n++) if (party == qso_parties[n].contest) return qso_parties[n].cnty[0]; return ' '; } char Ccontests::serno(std::string party) { for (size_t n = 0; n < sizeof(qso_parties) / sizeof(*qso_parties); n++) if (party == qso_parties[n].contest) return qso_parties[n].serno[0]; return ' '; } char Ccontests::xchg(std::string party) { for (size_t n = 0; n < sizeof(qso_parties) / sizeof(*qso_parties); n++) if (party == qso_parties[n].contest) return qso_parties[n].xchg[0]; return ' '; } char Ccontests::name(std::string party) { for (size_t n = 0; n < sizeof(qso_parties) / sizeof(*qso_parties); n++) if (party == qso_parties[n].contest) return qso_parties[n].name[0]; return ' '; } char Ccontests::cat(std::string party) { for (size_t n = 0; n < sizeof(qso_parties) / sizeof(*qso_parties); n++) if (party == qso_parties[n].contest) return qso_parties[n].cat[0]; return ' '; } char Ccontests::stcty(std::string party) { for (size_t n = 0; n < sizeof(qso_parties) / sizeof(*qso_parties); n++) if (party == qso_parties[n].contest) return qso_parties[n].stcty[0]; return ' '; } void adjust_for_contest(void *) { int n = progdefaults.SQSOcontest; progdefaults.SQSOinstate = false; progdefaults.SQSOlogcounty = false; progdefaults.SQSOlogstate = false; progdefaults.SQSOlogxchg = false; progdefaults.SQSOlogrst = false; progdefaults.SQSOlogname = false; progdefaults.SQSOlogserno = false; progdefaults.SQSOlogstcty = false; progdefaults.SQSOlogctyst = false; progdefaults.SQSOlogcat = false; if (QSOparties.qso_parties[n].instate[0] == 'T') progdefaults.SQSOinstate = true; if (progdefaults.SQSOinstate) { if (QSOparties.qso_parties[n].st[0] == 'I' || QSOparties.qso_parties[n].st[0] == 'B') progdefaults.SQSOlogstate = true; if (QSOparties.qso_parties[n].cnty[0] == 'I' || QSOparties.qso_parties[n].cnty[0] == 'B') progdefaults.SQSOlogcounty = true; if (QSOparties.qso_parties[n].xchg[0] == 'I' || QSOparties.qso_parties[n].xchg[0] == 'B') progdefaults.SQSOlogxchg = true; if (QSOparties.qso_parties[n].rst[0] == 'I' || QSOparties.qso_parties[n].rst[0] == 'B') progdefaults.SQSOlogrst = true; if (QSOparties.qso_parties[n].name[0] == 'I' || QSOparties.qso_parties[n].name[0] == 'B') progdefaults.SQSOlogname = true; if (QSOparties.qso_parties[n].serno[0] == 'I' || QSOparties.qso_parties[n].serno[0] == 'B') progdefaults.SQSOlogserno = true; if (QSOparties.qso_parties[n].cat[0] == 'I' || QSOparties.qso_parties[n].cat[0] == 'B') progdefaults.SQSOlogcat = true; } else { if (QSOparties.qso_parties[n].st[0] == 'O' || QSOparties.qso_parties[n].st[0] == 'B') progdefaults.SQSOlogstate = true; if (QSOparties.qso_parties[n].cnty[0] == 'O' || QSOparties.qso_parties[n].cnty[0] == 'B') progdefaults.SQSOlogcounty = true; if (QSOparties.qso_parties[n].xchg[0] == 'O' || QSOparties.qso_parties[n].xchg[0] == 'B') progdefaults.SQSOlogxchg = true; if (QSOparties.qso_parties[n].rst[0] == 'O' || QSOparties.qso_parties[n].rst[0] == 'B') progdefaults.SQSOlogrst = true; if (QSOparties.qso_parties[n].name[0] == 'O' || QSOparties.qso_parties[n].name[0] == 'B') progdefaults.SQSOlogname = true; if (QSOparties.qso_parties[n].serno[0] == 'O' || QSOparties.qso_parties[n].serno[0] == 'B') progdefaults.SQSOlogserno = true; if (QSOparties.qso_parties[n].cat[0] == 'O' || QSOparties.qso_parties[n].cat[0] == 'B') progdefaults.SQSOlogcat = true; } if (QSOparties.qso_parties[n].stcty[0] == 'S') progdefaults.SQSOlogstcty = true; if (QSOparties.qso_parties[n].stcty[0] == 'C') progdefaults.SQSOlogctyst = true; update_main_title(); //std::cout << "QSOparties.qso_parties[" << n << "]\n" // << QSOparties.qso_parties[n].contest << std::endl // << "instate: " << progdefaults.SQSOinstate << std::endl // << "ST: " << QSOparties.qso_parties[n].state << std::endl // << "rRST: " << QSOparties.qso_parties[n].rst << std::endl // << "rST: " << QSOparties.qso_parties[n].st << std::endl // << "rCY: " << QSOparties.qso_parties[n].cnty << std::endl // << "rSER: " << QSOparties.qso_parties[n].serno << std::endl // << "rXCHG: " << QSOparties.qso_parties[n].xchg << std::endl // << "rNAM: " << QSOparties.qso_parties[n].name << std::endl // << "rCAT: " << QSOparties.qso_parties[n].cat << std::endl // << "STCTY: " << QSOparties.qso_parties[n].stcty << std::endl // << "Notes: " << QSOparties.qso_parties[n].notes << std::endl; }
29,505
C++
.cxx
605
46.82314
152
0.478974
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,244
lookupcall.cxx
w1hkj_fldigi/src/logbook/lookupcall.cxx
// ---------------------------------------------------------------------------- // lookupcall.cxx -- a part of fldigi // // Copyright (C) 2006-2009 // Dave Freese, W1HKJ // Copyright (C) 2006-2007 // Leigh Klotz, WA5ZNU // Copyright (C) 2008-2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #ifdef __MINGW32__ # include "compat.h" #endif #include <sys/time.h> #include "signal.h" #include <string> #include <iostream> #include <cstring> #include <cmath> #include <cctype> #include "threads.h" #include "misc.h" #include "configuration.h" #include "lookupcall.h" #include "logsupport.h" #include "main.h" #include "confdialog.h" #include "fl_digi.h" #include "flmisc.h" #include "qrzlib.h" #include "trx.h" #include "xmlreader.h" #include "qrunner.h" #include "debug.h" #include "network.h" #include "locator.h" std::string qrzhost = "xmldata.qrz.com"; std::string qrzSessionKey; std::string qrzalert; std::string qrzerror; std::string callsign; std::string lookup_name; std::string lookup_addr1; std::string lookup_addr2; std::string lookup_state; std::string lookup_province; std::string lookup_zip; std::string lookup_country; std::string lookup_born; std::string lookup_fname; std::string lookup_qth; std::string lookup_grid; std::string lookup_latd; std::string lookup_lond; std::string lookup_notes; qrz_xmlquery_t DB_XML_query = QRZXMLNONE; qrz_webquery_t DB_WEB_query = QRZWEBNONE; enum TAG { QRZ_IGNORE, QRZ_KEY, QRZ_ALERT, QRZ_ERROR, QRZ_CALL, QRZ_FNAME, QRZ_NAME, QRZ_ADDR1, QRZ_ADDR2, QRZ_STATE, QRZ_ZIP, QRZ_COUNTRY, QRZ_LATD, QRZ_LOND, QRZ_GRID, QRZ_DOB }; pthread_t* QRZ_thread = 0; pthread_mutex_t qrz_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t qrz_cond = PTHREAD_COND_INITIALIZER; static void *LOOKUP_loop(void *args); bool parseSessionKey(); bool parse_xml(); bool getSessionKey(std::string& sessionpage); bool QRZGetXML(std::string& xmlpage); int bearing(const char *, const char *); void qra(const char *, double &, double &); void QRZ_disp_result(); void QRZ_CD_query(); void Lookup_init(void); void QRZclose(void); void qthappend(std::string &qth, std::string &datum); void QRZAlert(); bool QRZLogin(std::string& sessionpage); void QRZquery(); void parse_html(const std::string& htmlpage); bool HAMCALLget(std::string& htmlpage); void HAMCALLquery(); void QRZ_DETAILS_query(); QRZ *qCall = 0; static notify_dialog *announce = 0; void print_query(const std::string &name, const std::string &s) { // LOG_WARN("%s query:\n%s", name.c_str(), s.c_str()); LOG_VERBOSE("%s query:\n%s", name.c_str(), s.c_str()); } void print_data(const std::string &name, const std::string &s) { // LOG_WARN("%s data:\n%s", name.c_str(), s.c_str()); LOG_VERBOSE("%s data:\n%s", name.c_str(), s.c_str()); } void clear_Lookup() { lookup_name.clear(); lookup_addr1.clear(); lookup_addr2.clear(); lookup_state.clear(); lookup_province.clear(); lookup_zip.clear(); lookup_born.clear(); lookup_fname.clear(); lookup_qth.clear(); lookup_grid.clear(); lookup_latd.clear(); lookup_lond.clear(); lookup_notes.clear(); lookup_country.clear(); } // ---------------------------------------------------------------------------- // QRZ subscription query // ---------------------------------------------------------------------------- bool parseSessionKey(const std::string& sessionpage) { if (sessionpage.find("Bad Request") != std::string::npos) { return false; } IrrXMLReader* xml = createIrrXMLReader(new IIrrXMLStringReader(sessionpage)); TAG tag=QRZ_IGNORE; while(xml && xml->read()) { switch(xml->getNodeType()) { case EXN_TEXT: case EXN_CDATA: switch (tag) { default: break; case QRZ_KEY: qrzSessionKey = xml->getNodeData(); break; case QRZ_ALERT: qrzalert = xml->getNodeData(); break; case QRZ_ERROR: qrzerror = xml->getNodeData(); break; } break; case EXN_ELEMENT_END: tag=QRZ_IGNORE; break; case EXN_ELEMENT: { const char *nodeName = xml->getNodeName(); if (!strcmp("Key", nodeName)) tag=QRZ_KEY; else if (!strcmp("Alert", nodeName)) tag=QRZ_ALERT; else if (!strcmp("Error", nodeName)) tag=QRZ_ERROR; else tag=QRZ_IGNORE; break; } case EXN_NONE: case EXN_COMMENT: case EXN_UNKNOWN: break; } } delete xml; return true; } bool parse_xml(const std::string& xmlpage) { print_data("xmldata.qrz.com", xmlpage); if (xmlpage.find("<Error>Not found") != std::string::npos) { if (!announce) announce = new notify_dialog; announce->notify("Not found", 2.0); REQ(show_notifier, announce); return false; } IrrXMLReader* xml = createIrrXMLReader(new IIrrXMLStringReader(xmlpage)); // If we got any result back, clear the session key so that it will be // refreshed by this response, or if not present, will be removed and we'll // know to log in next time. if (xml) { qrzSessionKey.clear(); qrzalert.clear(); qrzerror.clear(); clear_Lookup(); } TAG tag = QRZ_IGNORE; // parse the file until end reached while(xml && xml->read()) { switch(xml->getNodeType()) { case EXN_TEXT: case EXN_CDATA: switch (tag) { default: case QRZ_IGNORE: break; case QRZ_CALL: break; case QRZ_FNAME: lookup_fname = xml->getNodeData(); break; case QRZ_NAME: lookup_name = xml->getNodeData(); break; case QRZ_ADDR1: { lookup_addr1 = xml->getNodeData(); size_t apt = lookup_addr1.find("#"); if (apt != std::string::npos) lookup_addr1.erase(apt, lookup_addr1.length() - apt); break; } case QRZ_ADDR2: lookup_addr2 = xml->getNodeData(); break; case QRZ_STATE: lookup_state = xml->getNodeData(); break; case QRZ_ZIP: lookup_zip = xml->getNodeData(); break; case QRZ_COUNTRY: lookup_country = xml->getNodeData(); break; case QRZ_LATD: lookup_latd = xml->getNodeData(); break; case QRZ_LOND: lookup_lond = xml->getNodeData(); break; case QRZ_GRID: lookup_grid = xml->getNodeData(); break; case QRZ_ALERT: qrzalert = xml->getNodeData(); break; case QRZ_ERROR: qrzerror = xml->getNodeData(); break; case QRZ_KEY: qrzSessionKey = xml->getNodeData(); break; } break; case EXN_ELEMENT_END: tag=QRZ_IGNORE; break; case EXN_ELEMENT: { const char *nodeName = xml->getNodeName(); if (!strcmp("call", nodeName)) tag = QRZ_CALL; else if (!strcmp("fname", nodeName)) tag = QRZ_FNAME; else if (!strcmp("name", nodeName)) tag = QRZ_NAME; else if (!strcmp("addr1", nodeName)) tag = QRZ_ADDR1; else if (!strcmp("addr2", nodeName)) tag = QRZ_ADDR2; else if (!strcmp("state", nodeName)) tag = QRZ_STATE; else if (!strcmp("zip", nodeName)) tag = QRZ_ZIP; else if (!strcmp("country", nodeName)) tag = QRZ_COUNTRY; else if (!strcmp("lat", nodeName)) tag = QRZ_LATD; else if (!strcmp("lon", nodeName)) tag = QRZ_LOND; else if (!strcmp("grid", nodeName)) tag = QRZ_GRID; else if (!strcmp("dob", nodeName)) tag = QRZ_DOB; else if (!strcmp("Alert", nodeName)) tag = QRZ_ALERT; else if (!strcmp("Error", nodeName)) tag = QRZ_ERROR; else if (!strcmp("Key", nodeName)) tag = QRZ_KEY; else tag = QRZ_IGNORE; } break; case EXN_NONE: case EXN_COMMENT: case EXN_UNKNOWN: break; } } // delete the xml parser after usage delete xml; return true; } bool getSessionKey(std::string& sessionpage) { std::string html = "http://"; html.append(qrzhost); html.append(" /xml/current/?username="); html.append(progdefaults.QRZusername); html.append(";password="); html.append(progdefaults.QRZuserpassword); html.append(";agent="); html.append(PACKAGE_NAME); html.append("-"); html.append(PACKAGE_VERSION); return get_http(html, sessionpage, 5.0); } bool QRZGetXML(std::string& xmlpage) { std::string html; html.assign("http://").append(qrzhost); html.append(" /bin/xml?s="); html.append(qrzSessionKey); html.append(";callsign="); html.append(callsign); return get_http(html, xmlpage, 5.0); } void camel_case(std::string &s) { bool first_letter = true; for (size_t n = 0; n < s.length(); n++) { if (s[n] == ' ') first_letter = true; else if (first_letter) { s[n] = toupper(s[n]); first_letter = false; } else s[n] = tolower(s[n]); } } void QRZ_disp_result() { ENSURE_THREAD(FLMAIN_TID); if (lookup_fname.length() > 0) { camel_case(lookup_fname); std::string::size_type spacePos = lookup_fname.find(" "); // if fname is "ABC" then display "ABC" // or if fname is "A BCD" then display "A BCD" if (spacePos == std::string::npos || (spacePos == 1)) { inpName->value(lookup_fname.c_str()); } // if fname is "ABC Y" then display "ABC" else if (spacePos > 2) { std::string fname; fname.assign(lookup_fname, 0, spacePos); inpName->value(fname.c_str()); } // fname must be "ABC DEF" so display "ABC DEF" else { inpName->value(lookup_fname.c_str()); } } else if (lookup_name.length() > 0) { // only name is set; don't know first/last, so just show all inpName->value(lookup_name.c_str()); } inpQth->value(lookup_qth.c_str()); inpQth->position (0); inpState->value(lookup_state.c_str()); inpState->position (0); inpVEprov->value(lookup_province.c_str()); inpVEprov->position (0); inpLoc->value(lookup_grid.c_str()); inpLoc->position (0); if (!lookup_country.empty()) { cboCountry->value(lookup_country.c_str()); } if (!progdefaults.myLocator.empty() && !lookup_grid.empty()) { char buf[10]; buf[0] = '\0'; double distance, azimuth, lon[2], lat[2]; if (QRB::locator2longlat(&lon[0], &lat[0], progdefaults.myLocator.c_str()) == QRB::QRB_OK && QRB::locator2longlat(&lon[1], &lat[1], lookup_grid.c_str()) == QRB::QRB_OK && QRB::qrb(lon[0], lat[0], lon[1], lat[1], &distance, &azimuth) == QRB::QRB_OK) snprintf(buf, sizeof(buf), "%03.0f", round(azimuth)); inpAZ->value(buf); inpAZ->position (0); } inpNotes->value(lookup_notes.c_str()); inpNotes->position (0); } void QRZ_CD_query() { ENSURE_THREAD(QRZ_TID); char srch[20]; size_t snip; memset( srch, 0, sizeof(srch) ); strncpy( srch, callsign.c_str(), 6 ); for (size_t i = 0; i < strlen(srch); i ++ ) srch[i] = toupper(srch[i]); std::string notes; if (!progdefaults.clear_notes) notes.assign(inpNotes->value()); else notes.clear(); if( qCall->FindRecord( srch ) == 1) { lookup_fname = qCall->GetFname(); camel_case(lookup_fname); snip = lookup_fname.find(' '); if (snip != std::string::npos) lookup_fname.erase(snip, lookup_fname.length() - snip); lookup_qth = qCall->GetCity(); lookup_state = qCall->GetState(); lookup_grid.clear(); if (progdefaults.notes_address) { if (!notes.empty()) notes.append("\n"); notes.append(lookup_fname).append(" ").append(lookup_name).append("\n"); notes.append(lookup_addr1).append("\n"); notes.append(lookup_addr2); if (!lookup_state.empty()) notes.append(", ").append(lookup_state).append(" ").append(lookup_zip); else if (!lookup_province.empty()) notes.append(", ").append(lookup_province).append(" ").append(lookup_zip); else notes.append(" ").append(lookup_country); } } else { lookup_fname.clear(); lookup_qth.clear(); lookup_grid.clear(); lookup_born.clear(); lookup_notes.append("Not found in CD database"); } REQ(QRZ_disp_result); } void Lookup_init(void) { ENSURE_THREAD(FLMAIN_TID); if (QRZ_thread) return; QRZ_thread = new pthread_t; if (pthread_create(QRZ_thread, NULL, LOOKUP_loop, NULL) != 0) { LOG_PERROR("pthread_create"); return; } MilliSleep(10); } void QRZclose(void) { ENSURE_THREAD(FLMAIN_TID); if (!QRZ_thread) return; CANCEL_THREAD(*QRZ_thread); DB_XML_query = QRZXML_EXIT; DB_WEB_query = QRZWEB_EXIT; pthread_mutex_lock(&qrz_mutex); pthread_cond_signal(&qrz_cond); pthread_mutex_unlock(&qrz_mutex); pthread_join(*QRZ_thread, NULL); delete QRZ_thread; QRZ_thread = 0; } void qthappend(std::string &qth, std::string &datum) { if (datum.empty()) return; if (!qth.empty()) qth += ", "; qth += datum; } void QRZAlert() { ENSURE_THREAD(FLMAIN_TID); std::string qrznote; if (!qrzalert.empty()) { qrznote.append("QRZ alert:\n"); qrznote.append(qrzalert); qrznote.append("\n"); qrzalert.clear(); } if (!qrzerror.empty()) { qrznote.append("QRZ error:\n"); qrznote.append(qrzerror); qrzerror.clear(); } std::string notes; if (!progdefaults.clear_notes) notes.assign(inpNotes->value()); else notes.clear(); if (!qrznote.empty()) { if (!notes.empty()) notes.append("\n"); notes.append(qrznote); inpNotes->value(notes.c_str()); } } bool QRZLogin(std::string& sessionpage) { bool ok = true; if (qrzSessionKey.empty()) { ok = getSessionKey(sessionpage); if (ok) ok = parseSessionKey(sessionpage); } if (!ok) { LOG_VERBOSE("failed"); REQ(QRZAlert); } return ok; } void QRZquery() { ENSURE_THREAD(QRZ_TID); bool ok = true; std::string qrzpage; if (qrzSessionKey.empty()) ok = QRZLogin(qrzpage); if (ok) ok = QRZGetXML(qrzpage); if (ok) { parse_xml(qrzpage); if (!qrzalert.empty() || !qrzerror.empty()) REQ(QRZAlert); else { lookup_qth = lookup_addr2; if (lookup_country.find("Canada") != std::string::npos) { lookup_province = lookup_state; lookup_state.clear(); } std::string notes; if (!progdefaults.clear_notes) notes.assign(inpNotes->value()); else notes.clear(); if (progdefaults.notes_address) { if (!notes.empty()) notes.append("\n"); notes.append(lookup_fname).append(" ").append(lookup_name).append("\n"); notes.append(lookup_addr1).append("\n"); notes.append(lookup_addr2); if (!lookup_state.empty()) notes.append(", ").append(lookup_state).append(" ").append(lookup_zip); else if (!lookup_province.empty()) notes.append(", ").append(lookup_province).append(" ").append(lookup_zip); else notes.append(" ").append(lookup_country); } lookup_notes = notes; REQ(QRZ_disp_result); } } else { qrzerror = qrzpage; REQ(QRZAlert); } } // --------------------------------------------------------------------- // HTTP:://callook.info queries // --------------------------------------------------------------------- std::string node_data(const std::string &xmlpage, const std::string nodename) { size_t pos1, pos2; std::string test; test.assign("<").append(nodename).append(">"); pos1 = xmlpage.find(test); if (pos1 == std::string::npos) return ""; pos1 += test.length(); test.assign("</").append(nodename).append(">"); pos2 = xmlpage.find(test); if (pos2 == std::string::npos) return ""; return xmlpage.substr(pos1, pos2 - pos1); } void parse_callook(std::string& xmlpage) { print_data("Callook info", xmlpage); if (xmlpage.find("INVALID") != std::string::npos) { if (!announce) announce = new notify_dialog; announce->notify("Call not found", 2.0); REQ(show_notifier, announce); return; } std::string nodestr = node_data(xmlpage, "current"); if (nodestr.empty()) { if (!announce) announce = new notify_dialog; announce->notify("no data from callook.info", 2.0); REQ(show_notifier, announce); return; } size_t start_pos = xmlpage.find("</trustee>"); if (start_pos == std::string::npos) return; start_pos += 10; xmlpage = xmlpage.substr(start_pos); lookup_name = node_data(xmlpage, "name"); camel_case(lookup_name); lookup_fname = lookup_name; nodestr = node_data(xmlpage, "address"); if (!nodestr.empty()) { lookup_addr1 = node_data(nodestr, "line1"); lookup_addr2 = node_data(nodestr, "line2"); } nodestr = node_data(xmlpage, "location"); if (!nodestr.empty()) { lookup_lond = node_data(nodestr, "longitude"); lookup_latd = node_data(nodestr, "latitude"); lookup_grid = node_data(nodestr, "gridsquare"); } std::string notes; if (!progdefaults.clear_notes) notes.assign(inpNotes->value()); else notes.clear(); if (progdefaults.notes_address) { if (!notes.empty()) notes.append("\n"); notes.append(lookup_name).append("\n"); notes.append(lookup_addr1).append("\n"); notes.append(lookup_addr2); } lookup_notes = notes; size_t p = lookup_addr2.find(","); if (p != std::string::npos) { lookup_qth = lookup_addr2.substr(0, p); lookup_addr2.erase(0, p+2); p = lookup_addr2.find(" "); if (p != std::string::npos) lookup_state = lookup_addr2.substr(0, p); } } bool CALLOOKGetXML(std::string& xmlpage) { std::string url = progdefaults.callookurl; size_t p = 0; if ((p = url.find("https")) != std::string::npos) url.erase(p+4,1); url.append(callsign).append("/xml"); bool res = get_http(url, xmlpage, 5.0); LOG_VERBOSE("result = %d", res); return res; } void CALLOOKquery() { ENSURE_THREAD(QRZ_TID); // bool ok = true; std::string CALLOOKpage; clear_Lookup(); // ok = CALLOOKGetXML(CALLOOKpage); // if (ok) parse_callook(CALLOOKpage); REQ(QRZ_disp_result); } // --------------------------------------------------------------------- // Hamcall specific functions // --------------------------------------------------------------------- #define HAMCALL_CALL (char)181 #define HAMCALL_FIRST (char)184 #define HAMCALL_CITY (char)191 #define HAMCALL_STATE (char)192 #define HAMCALL_GRID (char)202 #define HAMCALL_DOB (char)194 void parse_html(const std::string& htmlpage) { print_data("Hamcall data", htmlpage); size_t p; clear_Lookup(); if ((p = htmlpage.find(HAMCALL_FIRST)) != std::string::npos) { p++; while ((uchar)htmlpage[p] < 128 && p < htmlpage.length() ) lookup_fname.append(1, htmlpage[p++]); camel_case(lookup_fname); } if ((p = htmlpage.find(HAMCALL_CITY)) != std::string::npos) { p++; while ((uchar)htmlpage[p] < 128 && p < htmlpage.length()) lookup_qth.append(1, htmlpage[p++]); } if ((p = htmlpage.find(HAMCALL_STATE)) != std::string::npos) { p++; while ((uchar)htmlpage[p] < 128 && p < htmlpage.length()) lookup_state.append(1, htmlpage[p++]); } if ((p = htmlpage.find(HAMCALL_GRID)) != std::string::npos) { p++; while ((uchar)htmlpage[p] < 128 && p < htmlpage.length()) lookup_grid.append(1, htmlpage[p++]); } if ((p = htmlpage.find(HAMCALL_DOB)) != std::string::npos) { p++; lookup_notes.append("DOB: "); while ((uchar)htmlpage[p] < 128 && p < htmlpage.length()) lookup_notes.append(1, htmlpage[p++]); } } bool HAMCALLget(std::string& htmlpage) { std::string html; size_t p1; html.assign(progdefaults.hamcallurl); if ((p1 = html.find("https")) != std::string::npos) html.erase(p1+4,1); if (html[html.length()-1] != '/') html += '/'; html.append("/call?username="); html.append(progdefaults.QRZusername); html.append("&password="); html.append(progdefaults.QRZuserpassword); html.append("&rawlookup=1&callsign="); html.append(callsign); html.append("&program=fldigi-"); html.append(VERSION); return get_http(html, htmlpage, 5.0); // print_query("hamcall", url_html); // std::string url = progdefaults.hamcallurl; // size_t p = url.find("//"); // std::string service = url.substr(0, p); // url.erase(0, p+2); // size_t len = url.length(); // if (url[len-1]=='/') url.erase(len-1, 1); // return network_query(url, service, url_html, htmlpage, 5.0); } void HAMCALLquery() { ENSURE_THREAD(QRZ_TID); std::string htmlpage; if (HAMCALLget(htmlpage)) parse_html(htmlpage); else lookup_notes = htmlpage; REQ(QRZ_disp_result); } // --------------------------------------------------------------------- // Hamcall specific functions // --------------------------------------------------------------------- static std::string HAMQTH_session_id = ""; static std::string HAMQTH_reply = ""; #define HAMQTH_DEBUG 1 #undef HAMQTH_DEBUG /* * send: https://www.hamqth.com/xml.php?u=username&p=password * response: <?xml version="1.0"?> <HamQTH version="2.7" xmlns="https://www.hamqth.com"> <session> <session_id>09b0ae90050be03c452ad235a1f2915ad684393c</session_id> </session> </HamQTH> * * send: https://www.hamqth.com/xml.php?id=09b0ae90050be03c452ad235a1f2915ad684393c\ &callsign=ok7an&prg=YOUR_PROGRAM_NAME * response: <?xml version="1.0"?> <HamQTH version="2.7" xmlns="https://www.hamqth.com"> <search> <callsign>ok7an</callsign> <nick>Petr</nick> <qth>Neratovice</qth> <country>Czech Republic</country> <adif>503</adif> <itu>28</itu> <cq>15</cq> <grid>jo70gg</grid> <adr_name>Petr Hlozek</adr_name> <adr_street1>17. listopadu 1065</adr_street1> <adr_city>Neratovice</adr_city> <adr_zip>27711</adr_zip> <adr_country>Czech Republic</adr_country> <adr_adif>503</adr_adif> <district>GZL</district> <lotw>Y</lotw> <qsl>Y</qsl> <qsldirect>Y</qsldirect> <eqsl>Y</eqsl> <email>petr@ok7an.com</email> <jabber>petr@ok7an.com</jabber> <skype>PetrHH</skype> <birth_year>1982</birth_year> <lic_year>1998</lic_year> <web>https://www.ok7an.com</web> <latitude>50.07</latitude> <longitude>14.42</longitude> <continent>EU</continent> <utc_offset>-1</utc_offset> <picture>https://www.hamqth.com/userfiles/o/ok/ok7an/_profile/ok7an_nove.jpg</picture> </search> </HamQTH> */ bool HAMQTH_get_session_id() { std::string url; std::string retstr = ""; size_t p1 = std::string::npos; size_t p2 = std::string::npos; url.assign(progdefaults.hamqthurl); if ((p1 = url.find("https")) != std::string::npos) url.erase(p1+4,1); if (url[url.length()-1] != '/') url += '/'; url.append("xml.php?u=").append(progdefaults.QRZusername); url.append("&p=").append(progdefaults.QRZuserpassword); HAMQTH_session_id.clear(); int ret = get_http(url, retstr, 5.0); if (ret == 0 ) { LOG_ERROR("get_http( %s, retstr, 5.0) failed\n", url.c_str()); return false; } LOG_VERBOSE("url: %s", url.c_str()); LOG_VERBOSE("reply: %s\n", retstr.c_str()); p1 = retstr.find("<error>"); if (p1 != std::string::npos) { p2 = retstr.find("</error>"); if (p2 != std::string::npos) { p1 += 7; lookup_notes = retstr.substr(p1, p2 - p1); } return false; } p1 = retstr.find("<session_id>"); if (p1 == std::string::npos) { lookup_notes = "HamQTH not available"; return false; } p2 = retstr.find("</session_id>"); HAMQTH_session_id = retstr.substr(p1 + 12, p2 - p1 - 12); print_data("HamQTH session id", HAMQTH_session_id); return true; } void parse_HAMQTH_html(const std::string& htmlpage) { print_data("HamQth html", htmlpage); size_t p = std::string::npos; size_t p1 = std::string::npos; std::string tempstr; clear_Lookup(); lookup_fname.clear(); lookup_qth.clear(); lookup_state.clear(); lookup_grid.clear(); lookup_notes.clear(); lookup_country.clear(); if ((p = htmlpage.find("<error>")) != std::string::npos) { p += 7; p1 = htmlpage.find("</error>", p); if (p1 != std::string::npos) { std::string errstr = htmlpage.substr(p, p1 - p); if (!announce) announce = new notify_dialog; announce->notify(errstr.c_str(), 2.0); REQ(show_notifier, announce); } return; } if ((p = htmlpage.find("<nick>")) != std::string::npos) { p += 6; p1 = htmlpage.find("</nick>", p); if (p1 != std::string::npos) { lookup_fname = htmlpage.substr(p, p1 - p); camel_case(lookup_fname); } } if ((p = htmlpage.find("<qth>")) != std::string::npos) { p += 5; p1 = htmlpage.find("</qth>", p); if (p1 != std::string::npos) lookup_qth = htmlpage.substr(p, p1 - p); } if ((p = htmlpage.find("<country>")) != std::string::npos) { p += 9; p1 = htmlpage.find("</country>", p); if (p1 != std::string::npos) { lookup_country = htmlpage.substr(p, p1 - p); if (lookup_country == "Canada") { p = htmlpage.find("<district>"); if (p != std::string::npos) { p += 10; p1 = htmlpage.find("</district>", p); if (p1 != std::string::npos) lookup_province = htmlpage.substr(p, p1 - p); } } } } if ((p = htmlpage.find("<us_state>")) != std::string::npos) { p += 10; p1 = htmlpage.find("</us_state>", p); if (p1 != std::string::npos) lookup_state = htmlpage.substr(p, p1 - p); } if ((p = htmlpage.find("<grid>")) != std::string::npos) { p += 6; p1 = htmlpage.find("</grid>", p); if (p1 != std::string::npos) lookup_grid = htmlpage.substr(p, p1 - p); } if ((p = htmlpage.find("<qsl_via>")) != std::string::npos) { p += 9; p1 = htmlpage.find("</qsl_via>", p); if (p1 != std::string::npos) { tempstr.assign(htmlpage.substr(p, p1 - p)); if (!tempstr.empty()) lookup_notes.append("QSL via: ").append(tempstr).append("\n"); } } if (progdefaults.notes_address) { if ((p = htmlpage.find("<adr_name>")) != std::string::npos) { p += 10; p1 = htmlpage.find("</adr_name>", p); if (p1 != std::string::npos) { tempstr.assign(htmlpage.substr(p, p1 - p)); if (!tempstr.empty()) lookup_notes.append(tempstr).append("\n"); } } if ((p = htmlpage.find("<adr_street1>")) != std::string::npos) { p += 13; p1 = htmlpage.find("</adr_street1>", p); if (p1 != std::string::npos) { tempstr.assign(htmlpage.substr(p, p1 - p)); if (!tempstr.empty()) lookup_notes.append(tempstr).append("\n"); } } if ((p = htmlpage.find("<adr_city>")) != std::string::npos) { p += 10; p1 = htmlpage.find("</adr_city>", p); if (p1 != std::string::npos) { tempstr.assign(htmlpage.substr(p, p1 - p)); if (!tempstr.empty()) lookup_notes.append(tempstr); if (!lookup_state.empty()) lookup_notes.append(", ").append(lookup_state); else if (!lookup_province.empty()) lookup_notes.append(", ").append(lookup_province); } } if ((p = htmlpage.find("<adr_zip>")) != std::string::npos) { p += 9; p1 = htmlpage.find("</adr_zip>", p); if (p1 != std::string::npos) { tempstr.assign(htmlpage.substr(p, p1 - p)); if (!tempstr.empty()) lookup_notes.append(" ").append(tempstr); } } } } bool HAMQTHget(std::string& htmlpage) { std::string url; bool ret; if (HAMQTH_session_id.empty()) { if (!HAMQTH_get_session_id()) { LOG_WARN("HAMQTH session id failed!"); lookup_notes = "Get session id failed!\n"; return false; } } size_t p1; url.assign(progdefaults.hamqthurl); if ((p1 = url.find("https")) != std::string::npos) url.erase(p1+4,1); if (url[url.length()-1] != '/') url += '/'; url.append("xml.php?id=").append(HAMQTH_session_id); url.append("&callsign=").append(callsign); url.append("&prg=FLDIGI"); print_query("HamQTH", url); ret = get_http(url, htmlpage, 5.0); size_t p = htmlpage.find("Session does not exist or expired"); if (p != std::string::npos) { htmlpage.clear(); LOG_WARN("HAMQTH session id expired!"); HAMQTH_session_id.clear(); if (!HAMQTH_get_session_id()) { LOG_WARN("HAMQTH get session id failed!"); lookup_notes = "Get session id failed!\n"; htmlpage.clear(); return false; } ret = get_http(url, htmlpage, 5.0); } #ifdef HAMQTH_DEBUG FILE *fetchit = fopen("fetchit.txt", "a"); fprintf(fetchit, "%s\n", htmlpage.c_str()); fclose(fetchit); #endif return ret; } void HAMQTHquery() { ENSURE_THREAD(QRZ_TID); std::string htmlpage; if (!HAMQTHget(htmlpage)) return; parse_HAMQTH_html(htmlpage); REQ(QRZ_disp_result); } // ---------------------------------------------------------------------------- void QRZ_DETAILS_query() { std::string qrz = progdefaults.qrzurl; qrz.append("db/").append(callsign); cb_mnuVisitURL(0, (void*)qrz.c_str()); } void HAMCALL_DETAILS_query() { std::string hamcall = progdefaults.hamcallurl; hamcall.append("call?callsign=").append(callsign); cb_mnuVisitURL(0, (void*)hamcall.c_str()); } void HAMQTH_DETAILS_query() { std::string hamqth = progdefaults.hamqthurl; hamqth.append(callsign); cb_mnuVisitURL(0, (void*)hamqth.c_str()); } void CALLOOK_DETAILS_query() { std::string hamcall = progdefaults.callookurl; hamcall.append(callsign); cb_mnuVisitURL(0, (void *)hamcall.c_str()); } // ---------------------------------------------------------------------------- static void *LOOKUP_loop(void *args) { SET_THREAD_ID(QRZ_TID); SET_THREAD_CANCEL(); for (;;) { TEST_THREAD_CANCEL(); pthread_mutex_lock(&qrz_mutex); pthread_cond_wait(&qrz_cond, &qrz_mutex); pthread_mutex_unlock(&qrz_mutex); switch (DB_XML_query) { case QRZCD : QRZ_CD_query(); break; case QRZNET : QRZquery(); break; case HAMCALLNET : HAMCALLquery(); break; case CALLOOK: CALLOOKquery(); break; case HAMQTH: HAMQTHquery(); break; case QRZXML_EXIT: return NULL; default: break; } switch (DB_WEB_query) { case QRZHTML : QRZ_DETAILS_query(); break; case HAMCALLHTML : HAMCALL_DETAILS_query(); break; case HAMQTHHTML : HAMQTH_DETAILS_query(); break; case CALLOOKHTML : CALLOOK_DETAILS_query(); break; case QRZWEB_EXIT: return NULL; default: break; } } return NULL; } void CALLSIGNquery() { ENSURE_THREAD(FLMAIN_TID); if (!QRZ_thread) Lookup_init(); // Filter callsign for nonsense characters (remove all but [A-Za-z0-9/]) callsign.clear(); for (const char* p = inpCall->value(); *p; p++) if (isalnum(*p) || *p == '/') callsign += *p; if (callsign.empty()) return; if (callsign != inpCall->value()) inpCall->value(callsign.c_str()); size_t slash; while ((slash = callsign.rfind('/')) != std::string::npos) { if (((slash+1) * 2) < callsign.length()) callsign.erase(0, slash + 1); else callsign.erase(slash); } switch (DB_XML_query = static_cast<qrz_xmlquery_t>(progdefaults.QRZXML)) { case QRZNET: LOG_INFO("%s","Request sent to qrz.com..."); break; case HAMCALLNET: LOG_INFO("%s","Request sent to www.hamcall.net..."); break; case QRZCD: if (!qCall) qCall = new QRZ( "callbkc" ); if (progdefaults.QRZchanged) { qCall->NewDBpath("callbkc"); progdefaults.QRZchanged = false; } if (!qCall->getQRZvalid()) { LOG_ERROR("%s","QRZ DB error"); DB_XML_query = QRZXMLNONE; return; } break; case CALLOOK: LOG_INFO("Request sent to %s", progdefaults.callookurl.c_str()); break; case HAMQTH: LOG_INFO("Request sent to %s", progdefaults.hamqthurl.c_str()); break; case QRZXMLNONE: break; default: LOG_ERROR("Bad query type %d", DB_XML_query); return; } DB_WEB_query = static_cast<qrz_webquery_t>(progdefaults.QRZWEB); pthread_mutex_lock(&qrz_mutex); pthread_cond_signal(&qrz_cond); pthread_mutex_unlock(&qrz_mutex); } /// With this constructor, no need to declare the array mode_info[] in the calling program. QsoHelper::QsoHelper(int the_mode) : qso_rec( new cQsoRec ) { qso_rec->putField(ADIF_MODE, mode_info[the_mode].adif_name ); } /// This saves the new record to a file and must be run in the main thread. static void QsoHelperSave(cQsoRec * qso_rec_ptr) { qsodb.qsoNewRec (qso_rec_ptr); qsodb.isdirty(0); qsodb.isdirty(0); loadBrowser(true); /// It is mandatory to do this in the main thread. TODO: Crash suspected. adifFile.writeLog (logbook_filename.c_str(), &qsodb); /// Beware that this object is created in a thread and deleted in the main one. delete qso_rec_ptr ; } /// This must be called from the main thread, according to writeLog(). QsoHelper::~QsoHelper() { qso_rec->setDateTime(true); qso_rec->setDateTime(false); qso_rec->setFrequency( wf->rfcarrier() ); REQ( QsoHelperSave, qso_rec ); // It will be deleted in the main thread. qso_rec = NULL ; } /// Adds one key-value pair to display in the ADIF file. void QsoHelper::Push( ADIF_FIELD_POS pos, const std::string & value ) { qso_rec->putField( pos, value.c_str() ); }
32,392
C++
.cxx
1,132
25.801237
94
0.646537
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,246
fd_logger.cxx
w1hkj_fldigi/src/logbook/fd_logger.cxx
// ===================================================================== // // FD_logger.cxx // // interface to tcpip application fdserver.tcl // fdserver is a multiple client tcpip server // // Copyright (C) 2016 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ===================================================================== #include <iostream> #include <cmath> #include <cstring> #include <vector> #include <list> #include <stdlib.h> #include <FL/Fl_Text_Display.H> #include <FL/Fl_Text_Buffer.H> #include "fl_digi.h" #include "rigsupport.h" #include "modem.h" #include "trx.h" #include "configuration.h" #include "main.h" #include "waterfall.h" #include "macros.h" #include "qrunner.h" #include "debug.h" #include "status.h" #include "icons.h" #include "logsupport.h" #include "fd_logger.h" #include "fd_view.h" #include "flmisc.h" #include "confdialog.h" LOG_FILE_SOURCE(debug::LOG_FD); //forward declarations of local functions void FD_start(); //====================================================================== // Socket FD i/o used on all platforms //====================================================================== pthread_t FD_thread; pthread_t FD_rx_socket_thread; pthread_mutex_t FD_mutex = PTHREAD_MUTEX_INITIALIZER; Socket *FD_socket = 0; bool FD_connected = false; bool FD_logged_on = false; bool FD_enabled = false; bool FD_exit = false; std::string FD_ip_addr = ""; std::string FD_ip_port = ""; std::string FD_rxbuffer; //====================================================================== // data report from fdserver.tcl // LOGON w1hkj 40,DIG // LOGON_OK W1HKJ 1A 5 // SCORE 35 // WORKED ... all on a single line // {160 CW 1} {160 DIG 0} {160 PHONE 0} // {80 CW 0} {80 DIG 0} {80 PHONE 0} // {40 CW 1} {40 DIG 0} {40 PHONE 0} // {20 CW 0} {20 DIG 1} {20 PHONE 0} // {17 CW 0} {17 DIG 0} {17 PHONE 1} // {15 CW 0} {15 DIG 0} {15 PHONE 1} // {10 CW 0} {10 DIG 0} {10 PHONE 0} // {2 CW 0} {2 DIG 0} {2 PHONE 0} // {440 CW 0} {440 DIG 0} {440 PHONE 0} //====================================================================== //====================================================================== // //====================================================================== void post(Fl_Input2 *w, const char * s) { w->value(s); } //====================================================================== // //====================================================================== void view(Fl_Output *w, const char * s) { w->value(s); } //====================================================================== // //====================================================================== static std::string toparse; void parse_logon_ok(std::string s) { size_t p = 0; static std::string call, clss, mult, sect; call.clear(); clss.clear(); sect.clear(); s.erase(0, 9); call = s; call.erase(call.find(" ")); p = s.find(" "); if (p != std::string::npos) { s.erase(0, p+1); clss = s; p = clss.find(" "); clss.erase(p); p = s.find(" "); if (p != std::string::npos) { s.erase(0,p+1); mult = s; p = mult.find(" "); mult.erase(p); p = s.find(" "); if (p != std::string::npos) { s.erase(0,p+1); sect = s; p = sect.find("\r"); if (p != std::string::npos) sect.erase(p); p = sect.find("\n"); if (p != std::string::npos) sect.erase(p); } } } progdefaults.my_FD_call = call; REQ(&post, inp_my_FD_call, call.c_str()); REQ(&view, view_FD_call, call.c_str()); progdefaults.my_FD_class = clss; REQ(&post, inp_my_FD_class, clss.c_str()); REQ(&view, view_FD_class, clss.c_str()); progdefaults.my_FD_section = sect; REQ(&post, inp_my_FD_section, sect.c_str()); REQ(&view, view_FD_section, sect.c_str()); progdefaults.my_FD_mult = mult; REQ(&view, view_FD_mult, mult.c_str()); } //====================================================================== // //====================================================================== void parse_score(std::string s) { static std::string sscore; size_t p = s.find("\r"); if (p != std::string::npos) s.erase(p); p = s.find("\n"); if (p != std::string::npos) s.erase(p); p = s.find(" "); if (p != std::string::npos) s.erase(0, p+1); sscore = s; REQ(&view, view_FD_score, sscore.c_str()); } //====================================================================== // //====================================================================== void parse_entry( std::string needle, Fl_Output *view1, Fl_Output *view2 ) { size_t p1 = toparse.find(needle); if (p1 == std::string::npos) return; p1 += needle.length(); size_t p2 = toparse.find(" ", p1); size_t p3 = toparse.find("}", p1); if (p3 == std::string::npos) return; std::string num = "", op = ""; num = toparse.substr(p1, p2 - p1); op = toparse.substr(p2+1, p3 - (p2+1)); view1->value(num.c_str()); view2->value(op.c_str()); } //====================================================================== // //====================================================================== void parse_worked() { // CW contacts parse_entry("{160 CW ", view_FD_CW[0], view_FD_CW_OP[0]); parse_entry("{80 CW ", view_FD_CW[1], view_FD_CW_OP[1]); parse_entry("{40 CW ", view_FD_CW[2], view_FD_CW_OP[2]); parse_entry("{20 CW ", view_FD_CW[3], view_FD_CW_OP[3]); parse_entry("{17 CW ", view_FD_CW[4], view_FD_CW_OP[4]); parse_entry("{15 CW ", view_FD_CW[5], view_FD_CW_OP[5]); parse_entry("{12 CW ", view_FD_CW[6], view_FD_CW_OP[6]); parse_entry("{10 CW ", view_FD_CW[7], view_FD_CW_OP[7]); parse_entry("{6 CW ", view_FD_CW[8], view_FD_CW_OP[8]); parse_entry("{2 CW ", view_FD_CW[9], view_FD_CW_OP[9]); parse_entry("{220 CW ", view_FD_CW[10], view_FD_CW_OP[10]); parse_entry("{440 CW ", view_FD_CW[11], view_FD_CW_OP[11]); // DIG contacts parse_entry("{160 DIG ", view_FD_DIG[0], view_FD_DIG_OP[0]); parse_entry("{80 DIG ", view_FD_DIG[1], view_FD_DIG_OP[1]); parse_entry("{40 DIG ", view_FD_DIG[2], view_FD_DIG_OP[2]); parse_entry("{20 DIG ", view_FD_DIG[3], view_FD_DIG_OP[3]); parse_entry("{17 DIG ", view_FD_DIG[4], view_FD_DIG_OP[4]); parse_entry("{15 DIG ", view_FD_DIG[5], view_FD_DIG_OP[5]); parse_entry("{12 DIG ", view_FD_DIG[6], view_FD_DIG_OP[6]); parse_entry("{10 DIG ", view_FD_DIG[7], view_FD_DIG_OP[7]); parse_entry("{6 DIG ", view_FD_DIG[8], view_FD_DIG_OP[8]); parse_entry("{2 DIG ", view_FD_DIG[9], view_FD_DIG_OP[9]); parse_entry("{220 DIG ", view_FD_DIG[10], view_FD_DIG_OP[10]); parse_entry("{440 DIG ", view_FD_DIG[11], view_FD_DIG_OP[11]); // PHONE contacts parse_entry("{160 PHONE ", view_FD_PHONE[0], view_FD_PHONE_OP[0]); parse_entry("{80 PHONE ", view_FD_PHONE[1], view_FD_PHONE_OP[1]); parse_entry("{40 PHONE ", view_FD_PHONE[2], view_FD_PHONE_OP[2]); parse_entry("{20 PHONE ", view_FD_PHONE[3], view_FD_PHONE_OP[3]); parse_entry("{17 PHONE ", view_FD_PHONE[4], view_FD_PHONE_OP[4]); parse_entry("{15 PHONE ", view_FD_PHONE[5], view_FD_PHONE_OP[5]); parse_entry("{12 PHONE ", view_FD_PHONE[6], view_FD_PHONE_OP[6]); parse_entry("{10 PHONE ", view_FD_PHONE[7], view_FD_PHONE_OP[7]); parse_entry("{6 PHONE ", view_FD_PHONE[8], view_FD_PHONE_OP[8]); parse_entry("{2 PHONE ", view_FD_PHONE[9], view_FD_PHONE_OP[9]); parse_entry("{220 PHONE ", view_FD_PHONE[10], view_FD_PHONE_OP[10]); parse_entry("{440 PHONE ", view_FD_PHONE[11], view_FD_PHONE_OP[11]); } void clear_fd_viewer() { for (int i = 0; i < 12; i++) { view_FD_CW[i]->value(""); view_FD_CW_OP[i]->value(""); view_FD_DIG[i]->value(""); view_FD_DIG_OP[i]->value(""); view_FD_PHONE[i]->value(""); view_FD_PHONE_OP[i]->value(""); } view_FD_call->value(""); view_FD_class->value(""); view_FD_section->value(""); view_FD_mult->value(""); box_fdserver_connected->color((Fl_Color)31); box_fdserver_connected->redraw(); } //====================================================================== // //====================================================================== void parse_FD_stream(std::string data) { size_t p = 0; if (data.empty()) return; //std::cout << "RX Stream:\n" << data << std::endl; if (data.find("QUIT") != std::string::npos) { //std::cout << "Quit\n"; FD_disconnect(); btn_fd_connect->value(0); return; } if (data.find("LOGON_DENIED") != std::string::npos) { //std::cout << "Logon denied\n"; FD_logged_on = false; LOG_ERROR("FD logon DENIED"); btn_fd_connect->value(0); return; } if (data.find("LOGOFF_OK") != std::string::npos) { //std::cout << "Log off OK\n"; FD_logged_on = false; return; } if (data.find("LOGON_OK") != std::string::npos) { //std::cout << "Logon OK\n"; parse_logon_ok(data.substr(p)); FD_logged_on = true; box_fdserver_connected->color((Fl_Color)2); box_fdserver_connected->redraw(); } if ( (p = data.find("SCORE") ) != std::string::npos) { //std::cout << "SCORE\n"; parse_score(data.substr(p)); } if ( (p = data.find("WORKED"))!= std::string::npos) { //std::cout << "WORKED\n"; toparse = data.substr(p); REQ(parse_worked); return; } if ( data.find("NODUP") != std::string::npos) { //std::cout << "Not a duplicate\n"; return; } else if (data.find("DUP") != std::string::npos) { //std::cout << "Duplicate\n"; } else if (data.find("REJECT") != std::string::npos) { //std::cout << "Reject\n"; } else if (data.find("ACCEPT") != std::string::npos) { //std::cout << "Accept\n"; } } //====================================================================== // //====================================================================== void FD_write(std::string s) { FD_socket->send(s.append("\n")); } //====================================================================== // //====================================================================== void FD_get_record(std::string call) { if(!FD_socket) return; if (!FD_connected) return; } //====================================================================== // //====================================================================== void FD_add_record() { if(!FD_socket) return; if (!FD_connected) return; guard_lock send_lock(&FD_mutex); std::string cmd = "ADD "; cmd.append(inpCall->value()).append(" "); cmd.append(inpSection->value()).append(" "); cmd.append(inpClass->value()); FD_write(cmd); } //====================================================================== // //====================================================================== static std::string fd_band; static std::string fd_mode; static std::string FD_opmode() { if (!active_modem) { return "DIG"; } if (active_modem->get_mode() == MODE_CW) return "CW"; else if (active_modem->get_mode() < MODE_SSB) return "DIG"; else if (active_modem->get_mode() == MODE_SSB) return "PHONE"; return ""; } //====================================================================== // //====================================================================== static std::string FD_opband() { if (!active_modem) return "40"; float freq = qsoFreqDisp->value(); freq /= 1e6; if (freq >= 1.8 && freq < 3.5) return "160"; if (freq >= 3.5 && freq <= 7.0) return "80"; if (freq >= 7.0 && freq <= 7.5) return "40"; if (freq >= 14.0 && freq < 18.0) return "20"; if (freq >= 18.0 && freq < 21.0) return "17"; if (freq >= 21.0 && freq < 24.0) return "15"; if (freq >= 24.0 && freq < 28.0) return "12"; if (freq >= 28.0 && freq < 50.0) return "10"; if (freq >= 50.0 && freq < 70.0) return "6"; if (freq >= 144.0 && freq < 222.0) return "2"; if (freq >= 222.0 && freq < 420.0) return "222"; if (freq >= 420.0 && freq < 444.0) return "440"; return ""; } //====================================================================== // //====================================================================== int FD_dupcheck() { if(!FD_socket) return 0; if (!FD_connected) return 0; std::string response; std::string cmd = "DUPCHECK "; cmd.append(inpCall->value()); try { guard_lock send_lock(&FD_mutex); FD_write(cmd); MilliSleep(50); FD_socket->recv(response); if (response.empty()) return 0; if (response.find("NODUP") != std::string::npos) return 0; if (response.find("DUP") != std::string::npos) return 1; return 0; } catch (const SocketException& e) { LOG_ERROR("Error %d, %s", e.error(), e.what()); FD_exit = true; } return 0; } //====================================================================== // //====================================================================== void FD_logon() { std::string ucasecall = progdefaults.fd_op_call; std::string buffer; std::string cmd = "LOGON "; if (ucasecall.empty()) return; for (size_t n = 0; n < ucasecall.length(); n++) ucasecall[n] = toupper(ucasecall[n]); fd_band = FD_opband(); fd_mode = FD_opmode(); if (fd_band.empty() || fd_mode.empty()) return; cmd.append(ucasecall).append(" "); cmd.append(fd_band).append(","); cmd.append(fd_mode); try { guard_lock send_lock(&FD_mutex); //std::cout << "Log On: " << cmd << std::endl; FD_write(cmd); FD_socket->recv(buffer); parse_FD_stream(buffer); LOG_INFO("Logged on to fdserver"); FD_logged_on = true; } catch (const SocketException& e) { LOG_ERROR("Error %d, %s", e.error(), e.what()); } } //====================================================================== // //====================================================================== void FD_logoff() { if (!FD_socket) return; guard_lock send_lock(&FD_mutex); try { std::string buffer; FD_write("LOGOFF"); MilliSleep(100); FD_socket->recv(buffer); parse_FD_stream(buffer); FD_disconnect(); LOG_INFO("Logged off FD server"); } catch (const SocketException& e) { LOG_ERROR("Error %d, %s", e.error(), e.what()); } } //====================================================================== // //====================================================================== void FD_band_check() { if (fd_band != FD_opband()) { FD_logoff(); MilliSleep(50); FD_start(); FD_logon(); } } //====================================================================== // //====================================================================== void FD_mode_check() { if (fd_mode != FD_opmode()) { FD_logoff(); MilliSleep(50); FD_start(); FD_logon(); } } //====================================================================== // //====================================================================== void FD_rcv_data() { std::string tempbuff; try { guard_lock send_lock(&FD_mutex); FD_socket->recv(tempbuff); if (tempbuff.empty()) return; parse_FD_stream(tempbuff); } catch (const SocketException& e) { LOG_ERROR("Error %d, %s", e.error(), e.what()); FD_exit = true; } } //====================================================================== // //====================================================================== static int fd_looptime = 1000; // in milliseconds void FD_start() { guard_lock send_lock(&FD_mutex); FD_ip_addr = progdefaults.fd_tcpip_addr; FD_ip_port = progdefaults.fd_tcpip_port; try { FD_socket = new Socket( Address( FD_ip_addr.c_str(), FD_ip_port.c_str(), "tcp") ); FD_socket->set_timeout(0.01); FD_socket->connect(); FD_socket->set_nonblocking(true); LOG_INFO( "Connected to fdserver %s:%s", FD_ip_addr.c_str(), FD_ip_port.c_str() ); fd_looptime = 100; FD_connected = true; } catch (const SocketException& e) { // LOG_ERROR("%s", e.what() ); delete FD_socket; FD_socket = 0; FD_connected = false; } } //====================================================================== // //====================================================================== void FD_restart() { guard_lock send_lock(&FD_mutex); FD_ip_addr = progdefaults.fd_tcpip_addr; FD_ip_port = progdefaults.fd_tcpip_port; try { FD_socket->shut_down(); FD_socket->close(); delete FD_socket; FD_connected = false; FD_socket = new Socket( Address( FD_ip_addr.c_str(), FD_ip_port.c_str(), "tcp") ); FD_socket->set_timeout(0.01); FD_socket->connect(); FD_socket->set_nonblocking(true); fd_looptime = 100; LOG_INFO( "Connected to fdserver %s:%s", FD_ip_addr.c_str(), FD_ip_port.c_str() ); } catch (const SocketException& e) { // LOG_ERROR("%s", e.what() ); delete FD_socket; FD_socket = 0; FD_connected = false; } } //====================================================================== // Disconnect from FD tcpip server //====================================================================== void FD_disconnect() { if (!FD_socket) return; // send disconnect string FD_socket->shut_down(); FD_socket->close(); delete FD_socket; FD_socket = 0; FD_connected = false; FD_logged_on = false; REQ(clear_fd_viewer); LOG_INFO("Disconnected from fdserver"); } //////////////////////////////////////////////// // NEED TO DETECT WHEN SERVER IS CLOSED OR FAILS //////////////////////////////////////////////// //====================================================================== // Thread loop //====================================================================== static notify_dialog *fd_alert_window = 0; void ui_feedback() { btn_fd_connect->value(0); if (!fd_alert_window) fd_alert_window = new notify_dialog; fd_alert_window->notify(_("Check FD server, connect failed"), 15.0); show_notifier(fd_alert_window); } void *FD_loop(void *args) { SET_THREAD_ID(FD_TID); int try_count = 10; while(1) { for (int i = 0; i < fd_looptime/50; i++) { MilliSleep(50); if (FD_exit) break; } if (!FD_connected && progdefaults.connect_to_fdserver) { if (try_count--) FD_start(); else { progdefaults.connect_to_fdserver = false; REQ(ui_feedback); try_count = 10; } } if ( FD_connected && ((FD_ip_addr != progdefaults.fd_tcpip_addr) || (FD_ip_port != progdefaults.fd_tcpip_port)) ) FD_restart(); if (FD_exit) break; if (FD_connected && !progdefaults.connect_to_fdserver) { if (FD_logged_on) FD_logoff(); FD_disconnect(); } else if ( FD_connected && !FD_logged_on && progdefaults.connect_to_fdserver) { FD_logon(); } else if (FD_connected && FD_logged_on) { FD_rcv_data(); FD_mode_check(); FD_band_check(); } } if (FD_logged_on && FD_socket) FD_logoff(); // calls FD_disconnect() else FD_disconnect(); // exit the FD thread SET_THREAD_CANCEL(); return NULL; } //====================================================================== // //====================================================================== void FD_init(void) { FD_enabled = false; FD_exit = false; if (pthread_create(&FD_thread, NULL, FD_loop, NULL) < 0) { LOG_ERROR("%s", "pthread_create failed"); return; } LOG_INFO("%s", "fdserver thread started"); FD_enabled = true; } //====================================================================== // //====================================================================== void FD_close(void) { if (!FD_enabled) return; FD_exit = true; pthread_join(FD_thread, NULL); FD_enabled = false; LOG_INFO("%s", "fdserver thread terminated. "); if (FD_socket) { FD_socket->shut_down(); FD_socket->close(); } }
19,837
C++
.cxx
641
28.836193
74
0.50314
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,247
logsupport.cxx
w1hkj_fldigi/src/logbook/logsupport.cxx
// ---------------------------------------------------------------------------- // logsupport.cxx // // Copyright (C) 2006-2010 // Dave Freese, W1HKJ // Copyright (C) 2008-2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <string> #include <cstring> #include <cstdlib> #include <ctime> #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <fstream> #include <vector> #include "main.h" #include "trx.h" #include "debug.h" #include "macros.h" #include "status.h" #include "date.h" #include "logger.h" #include "n3fjp_logger.h" #include "adif_io.h" #include "textio.h" #include "logbook.h" #include "rigsupport.h" #include "fd_logger.h" #include "fl_digi.h" #include "fileselect.h" #include "configuration.h" #include "main.h" #include "locator.h" #include "icons.h" #include "gettext.h" #include "qrunner.h" #include "flmisc.h" #include "network.h" #include "timeops.h" #include "strutil.h" #include <FL/filename.H> #include <FL/fl_ask.H> #include <FL/Fl_Double_Window.H> #include <FL/Fl_Text_Display.H> #include <FL/Fl_Text_Editor.H> #include <FL/Fl_Button.H> extern std::vector<int> lotw_recs_sent; cQsoDb qsodb; cAdifIO adifFile; cTextFile txtFile; std::string logbook_filename; enum sorttype {NONE, SORTCALL, SORTDATE, SORTFREQ, SORTMODE}; sorttype lastsort = SORTDATE; bool callfwd = true; bool modefwd = true; bool freqfwd = true; int editNbr = 0; void restore_sort(); void addBrowserRow(cQsoRec *, int); void adjustBrowser(bool keep_pos = false); // convert to and from "00:00:00" <=> "000000" const char *timeview(const char *s) { static char ds[9]; int len = strlen(s); strcpy(ds, "00:00:00"); if (len < 4) return ds; ds[0] = s[0]; ds[1] = s[1]; ds[3] = s[2]; ds[4] = s[3]; if (len < 6) return ds; ds[6] = s[4]; ds[7] = s[5]; return ds; } const char *timestring(const char *s) { static char ds[7]; int len = strlen(s); if (len <= 4) return s; ds[0] = s[0]; ds[1] = s[1]; ds[2] = s[3]; ds[3] = s[4]; if (len < 8) { ds[4] = ds[5] = '0'; ds[6] = 0; return ds; } ds[4] = s[6]; ds[5] = s[7]; ds[6] = 0; return ds; } const char *timeview4(const char *s) { static char ds[6]; int len = strlen(s); strcpy(ds, "00:00"); if (len < 5) return ds; ds[0] = s[0]; ds[1] = s[1]; ds[3] = s[2]; ds[4] = s[3]; return ds; } const char *time4(const char *s) { static char ds[5]; int len = strlen(s); if (len <= 4) return ds; memset(ds, 0, 5); strncpy(ds, s, 4); return ds; } void Export_CSV() { if (chkExportBrowser->nchecked() == 0) return; cQsoRec *rec; std::string title = _("Export to CSV file"); std::string filters = "CSV\t*.csv"; #ifdef __APPLE__ filters.append("\n"); #endif const char* p = FSEL::saveas( title.c_str(), filters.c_str(), "export.csv"); if (!p) return; if (!*p) return; for (int i = 0; i < chkExportBrowser->FLTK_nitems(); i++) { if (chkExportBrowser->checked(i + 1)) { rec = qsodb.getRec(i); rec->putField(EXPORT, "E"); qsodb.qsoUpdRec (i, rec); } } std::string sp = p; if (sp.find(".csv") == std::string::npos) sp.append(".csv"); txtFile.writeCSVFile(sp.c_str(), &qsodb); } void Export_TXT() { if (chkExportBrowser->nchecked() == 0) return; cQsoRec *rec; std::string title = _("Export to fixed field text file"); std::string filters = "TEXT\t*.txt"; #ifdef __APPLE__ filters.append("\n"); #endif const char* p = FSEL::saveas( title.c_str(), filters.c_str(), "export.txt"); if (!p) return; if (!*p) return; for (int i = 0; i < chkExportBrowser->FLTK_nitems(); i++) { if (chkExportBrowser->checked(i + 1)) { rec = qsodb.getRec(i); rec->putField(EXPORT, "E"); qsodb.qsoUpdRec (i, rec); } } std::string sp = p; if (sp.find(".txt") == std::string::npos) sp.append(".txt"); txtFile.writeTXTFile(p, &qsodb); } void Export_ADIF() { if (chkExportBrowser->nchecked() == 0) return; cQsoRec *rec; std::string title = _("Export to ADIF file"); std::string filters; std::string defname; filters.assign("ADIF\t*.").append(ADIF_SUFFIX); #ifdef __APPLE__ filters.append("\n"); #endif defname.assign("export.").append(ADIF_SUFFIX); const char* p = FSEL::saveas( title.c_str(), filters.c_str(), defname.c_str()); if (!p) return; if (!*p) return; for (int i = 0; i < chkExportBrowser->FLTK_nitems(); i++) { if (chkExportBrowser->checked(i + 1)) { rec = qsodb.getRec(i); rec->putField(EXPORT, "E"); qsodb.qsoUpdRec (i, rec); } } std::string sp = p; std::string temp = "."; temp.append(ADIF_SUFFIX); if (sp.find(temp) == std::string::npos) sp.append(temp); adifFile.writeFile (sp.c_str(), &qsodb); } // refresh_logbook_dialog ONLY called as an Fl::awake process // insures that logbook dialog LOTWSDATE field is updated by // FLTK UI thread. // called by Export_LOTW() and saveRecord() static std::string lotwsdate; void refresh_logbook_dialog(void *) { inpLOTWsentdate_log->value(lotwsdate.c_str()); inpLOTWsentdate_log->redraw(); } void Export_LOTW() { if (chkExportBrowser->nchecked() == 0) return; cQsoRec *rec; if (str_lotw.empty()) str_lotw = "Fldigi LoTW upload file\n<ADIF_VER:5>3.1.2\n<EOH>\n"; std::string adifrec; for (int i = 0; i < chkExportBrowser->FLTK_nitems(); i++) { if (chkExportBrowser->checked(i + 1)) { rec = qsodb.getRec(i); rec->putField(EXPORT, "E"); rec->putField(LOTWSDATE, zdate()); qsodb.qsoUpdRec (i, rec); lotw_recs_sent.push_back(i); if (i == editNbr) { lotwsdate = rec->getField(LOTWSDATE); Fl::awake(refresh_logbook_dialog); } adifrec = lotw_rec(*rec); if (adifrec.empty()) { LOG_INFO("%s", "Invalid LOTW record"); } else str_lotw.append(adifrec); } } } Fl_Double_Window *lotw_review_dialog = 0; static Fl_Text_Buffer *buff = 0; static Fl_Text_Editor *disp = 0; static Fl_Button *lotw_close_review = 0; static Fl_Button *lotw_save_review = 0; static Fl_Button *lotw_clear_review = 0; void cb_lotw_close_review(Fl_Button *, void *) { lotw_review_dialog->hide(); delete lotw_review_dialog; lotw_review_dialog = 0; lotw_close_review = 0; buff = 0; disp = 0; } void cb_lotw_save_review(Fl_Button *, void *) { str_lotw = buff->text(); } void cb_lotw_clear_review(Fl_Button *, void *) { buff->text(""); } void cb_review_lotw() { if (str_lotw.empty()) return; if (!lotw_review_dialog) { lotw_review_dialog = new Fl_Double_Window(50,50, 640, 400, _("LoTW Review")); lotw_review_dialog->begin(); buff = new Fl_Text_Buffer(); disp = new Fl_Text_Editor(4, 4, 632, 364); disp->textfont(FL_SCREEN); disp->buffer(buff); // attach text buffer to display widget lotw_close_review = new Fl_Button(576, 372, 60, 24, _("Close")); lotw_close_review->callback((Fl_Callback *)cb_lotw_close_review); lotw_clear_review = new Fl_Button(4, 372, 60, 24, _("Clear")); lotw_clear_review->callback((Fl_Callback *)cb_lotw_clear_review); lotw_save_review = new Fl_Button(lotw_review_dialog->w()/2-30, 372, 60, 24, _("Save")); lotw_save_review->callback((Fl_Callback *)cb_lotw_save_review); lotw_review_dialog->end(); } buff->text(str_lotw.c_str()); lotw_review_dialog->show(); } void cb_send_lotw() { send_to_lotw(NULL); } static savetype export_to = ADIF; void Export_log() { if (export_to == LOTW) Export_LOTW(); else if (export_to == ADIF) Export_ADIF(); else if (export_to == CSV) Export_CSV(); else Export_TXT(); } void saveLogbook(bool force) { if (!force && !qsodb.isdirty()) return; if (!force && progdefaults.NagMe) if (!fl_choice2(_("Save changed Logbook?"), _("No"), _("Yes"), NULL)) return; qsodb.isdirty(0); restore_sort(); if (force) adifFile.writeLog (logbook_filename.c_str(), &qsodb, true); else adifFile.writeLog (logbook_filename.c_str(), &qsodb); } static void dxcc_entity_cache_clear(void); static void dxcc_entity_cache_add(cQsoRec* r); static void dxcc_entity_cache_rm(cQsoRec* r); static void dxcc_entity_cache_add(cQsoDb& db); void cb_mnuNewLogbook(Fl_Menu_* m, void* d){ saveLogbook(true); std::string title = _("Create new logbook file"); std::string filter; filter.assign("ADIF\t*.").append(ADIF_SUFFIX); #ifdef __APPLE__ filter.append("\n"); #endif logbook_filename = LogsDir; logbook_filename.append("newlog.").append(ADIF_SUFFIX); const char* p = FSEL::saveas( title.c_str(), filter.c_str(), logbook_filename.c_str()); if (!p) return; if (!*p) return; std::string temp = p; std::string suffix = "."; suffix.append(ADIF_SUFFIX); if (temp.find(suffix) == std::string::npos) temp.append(suffix); FILE *testopen = fl_fopen(temp.c_str(), "r"); if (testopen) { std::string warn = logbook_filename; int ans = fl_choice2( _("%s exists, overwrite?"), _("No"), _("Yes"), NULL, temp.c_str()); if (!ans) return; fclose(testopen); } progdefaults.logbookfilename = logbook_filename = temp; dlgLogbook->label(fl_filename_name(logbook_filename.c_str())); txtLogFile->value(logbook_filename.c_str()); txtLogFile->redraw(); progdefaults.changed = true; qsodb.deleteRecs(); dxcc_entity_cache_clear(); wBrowser->clear(); clearRecord(); qsodb.isdirty(1); saveLogbook(); } void adif_read_OK() { if (qsodb.nbrRecs() == 0) adifFile.writeFile(logbook_filename.c_str(), &qsodb); dxcc_entity_cache_clear(); dxcc_entity_cache_add(qsodb); qsodb.isdirty(0); restore_sort(); activateButtons(); loadBrowser(); } void cb_mnuOpenLogbook(Fl_Menu_* m, void* d) { std::string title = _("Open logbook file"); std::string filter; filter.assign("ADIF file\t*.{adi,adif}"); #ifdef __APPLE__ filter.append("\n"); #endif std::string deffilename = LogsDir; deffilename.append(fl_filename_name(logbook_filename.c_str())); const char* p = FSEL::select( title.c_str(), filter.c_str(), deffilename.c_str()); if (!p) return; if (!*p) return; saveLogbook(true); qsodb.deleteRecs(); logbook_filename = p; progdefaults.logbookfilename = logbook_filename; progdefaults.changed = true; adifFile.readFile (logbook_filename.c_str(), &qsodb); dlgLogbook->label(fl_filename_name(logbook_filename.c_str())); txtLogFile->value(logbook_filename.c_str()); txtLogFile->redraw(); qsodb.isdirty(0); } void cb_mnuSaveLogbook(Fl_Menu_*m, void* d) { std::string title = _("Save logbook file"); std::string filter; filter.assign("ADIF\t*.").append(ADIF_SUFFIX); #ifdef __APPLE__ filter.append("\n"); #endif std::string deffilename = LogsDir; deffilename.append(fl_filename_name(logbook_filename.c_str())); const char* p = FSEL::saveas( title.c_str(), filter.c_str(), deffilename.c_str()); if (!p) return; if (!*p) return; logbook_filename = p; std::string temp = "."; temp.append(ADIF_SUFFIX); if (logbook_filename.find(temp) == std::string::npos) logbook_filename.append(temp); progdefaults.logbookfilename = logbook_filename; progdefaults.changed = true; dlgLogbook->label(fl_filename_name(logbook_filename.c_str())); txtLogFile->value(logbook_filename.c_str()); txtLogFile->redraw(); // cQsoDb::reverse = false; // qsodb.SortByDate(progdefaults.sort_date_time_off); qsodb.isdirty(0); restore_sort(); adifFile.writeLog (logbook_filename.c_str(), &qsodb); } //====================================================================== // separate thread for performing the database merger // // thread 'merge_thread' is instantiated for a database file merger // either on failure or successful merger the thread signals the main // UI thread to close the merge_thread and release all of it's resources // // merge_thread is not re-entrant. Only a single instance of the thread // is allowed. // // the user will be notified if an attempt is made to start a new merger // while one is already in progress. // //====================================================================== pthread_t* MERGE_thread = 0; pthread_mutex_t MERGE_mutex = PTHREAD_MUTEX_INITIALIZER; static std::string mrg_fname; static std::string disptxt; static bool abort_merger; static int num_merge_recs; static float read_secs; static void merge_announce_1(void *) { static char announce[500]; snprintf(announce, sizeof(announce), "Merging records:\n File: %s\n", mrg_fname.c_str()); ReceiveText->addstr(announce); ReceiveText->redraw(); Fl::flush(); } static void merge_announce_2(void *) { static char announce[500]; snprintf(announce, sizeof(announce), " Read %d records in %4.1f seconds\n Merging ... please wait", num_merge_recs, read_secs ); ReceiveText->addstr(announce); ReceiveText->redraw(); Fl::flush(); } void close_MERGE_thread (void *) { ENSURE_THREAD(FLMAIN_TID); if (!MERGE_thread) return; pthread_mutex_lock(&MERGE_mutex); abort_merger = true; pthread_mutex_unlock(&MERGE_mutex); pthread_join(*MERGE_thread, NULL); delete MERGE_thread; MERGE_thread = 0; abort_merger = false; qsodb.isdirty(1); saveLogbook(true); // force the save independent of user settings loadBrowser(); ReceiveText->addstr(disptxt.c_str()); ReceiveText->redraw(); } std::string adif_record(cQsoRec *rec) { static char recfield[200]; static std::string record; static std::string sFld; record.clear(); sFld.clear(); for (int j = 0; fields[j].type != NUMFIELDS; j++) { if (strcmp(fields[j].name,"MYXCHG") == 0) continue; if (strcmp(fields[j].name,"XCHG1") == 0) continue; sFld = rec->getField(fields[j].type); if (!sFld.empty()) { memset(recfield, 0, 200); snprintf(recfield, sizeof(recfield), "<%s:%lu>", fields[j].name, sFld.length()); record.append(recfield).append(sFld); } } record.append("<EOR>\n"); return record; } std::string last_adif_record() { if (qsodb.nbrRecs() < 1) return "NONE"; cQsoRec *rec = qsodb.getRec(qsodb.nbrRecs() - 1); return adif_record(rec); } // entire logbook in adif standard format std::string all_adif_records() { cQsoRec *rec; std::string records; records.assign("Fldigi logbook records\n<ADIF_VER:5>3.1.2\n<EOH>\n"); for (int i = 0; i < qsodb.nbrRecs(); i++) { rec = qsodb.getRec(i); records.append(adif_record(rec)); } records.append("<EOH>\n"); return records; } static void *merge_thread(void *args) { SET_THREAD_ID(ADIF_MERGE_TID); static char msg1[200]; sorttype orig_sort = lastsort; int orig_reverse = cQsoDb::reverse; cQsoDb::reverse = false; cQsoDb *db = &qsodb; cQsoDb *mrgdb = new cQsoDb; cQsoDb *merge_dups = new cQsoDb; cQsoDb *orig_dups = new cQsoDb; cQsoDb *copy = new cQsoDb(db); std::string mergedir; std::string mrg_dups_name; std::string orig_dups_name; std::string lg_recs_name; std::string fname; size_t pname; cQsoRec *lastrec = 0; cQsoRec *rec_n; cQsoRec *rec_m; int N; int M; int n = 0; int m = 0; int cmp = 0; int cmp2 = 0; int merged = 0; int merge_duplicates = 0; int orig_duplicates = 0; struct timespec t0, t1, t2; float merger_time = 0; Fl::awake(merge_announce_1); #ifdef _POSIX_MONOTONIC_CLOCK clock_gettime(CLOCK_MONOTONIC, &t0); #else clock_gettime(CLOCK_REALTIME, &t0); #endif LOG_INFO("MERGE: adifFile.do_readfile(%s)", mrg_fname.c_str()); adifFile.do_readfile (mrg_fname.c_str(), mrgdb); #ifdef _POSIX_MONOTONIC_CLOCK clock_gettime(CLOCK_MONOTONIC, &t1); #else clock_gettime(CLOCK_REALTIME, &t1); #endif N = copy->nbrRecs(); M = mrgdb->nbrRecs(); if (M == 0) { disptxt.assign("\n================================================\n"); disptxt.append("Merge file contains no records\n"); disptxt.append("\n================================================"); LOG_INFO("%s", disptxt.c_str()); disptxt.append("\n"); goto exit_merge_thread; } read_secs = t1.tv_sec - t0.tv_sec + (t1.tv_nsec- t0.tv_nsec)/1e9; num_merge_recs = M; Fl::awake(merge_announce_2); disptxt.assign("\n================================================\n"); copy->SortByCall(); mrgdb->SortByCall(); for (int i = 0; i < M; i++) { mrgdb->getRec(i)->checkBand(); mrgdb->getRec(i)->checkDateTimes(); } //writeLog("copy.adi", copy); //writeLog("mrgdb.adi", mrgdb); db->clearDatabase(); for (;;) { pthread_mutex_lock(&MERGE_mutex); if (abort_merger) goto abort; pthread_mutex_unlock(&MERGE_mutex); rec_n = copy->getRec(n); rec_m = mrgdb->getRec(m); if (N == 0) { if (m == M) break; if (lastrec == 0) { db->qsoNewRec(lastrec = rec_m); merged++; } else { cmp = comparebycall(lastrec, rec_m); if (cmp != 0) { db->qsoNewRec(lastrec = rec_m); merged++; } else { merge_dups->qsoNewRec(rec_m); merge_duplicates++; } } m++; continue; } if (n == N) { if (m == M) break; cmp = comparebycall(lastrec, rec_m); if (cmp == 0) { merge_dups->qsoNewRec(rec_m); merge_duplicates++; } else { db->qsoNewRec(lastrec = rec_m); merged++; } m++; continue; } if (m == M) { if (n == N) break; cmp = comparebycall(lastrec, rec_n); if (cmp == 0) { orig_dups->qsoNewRec(rec_n); orig_duplicates++; } else { db->qsoNewRec(lastrec = rec_n); } n++; continue; } if (lastrec == 0) { cmp = comparebycall(rec_n, rec_m); if (cmp < 0) { db->qsoNewRec(lastrec = rec_n); n++; continue; } if (cmp == 0) { db->qsoNewRec(lastrec = rec_n); n++; merge_dups->qsoNewRec(rec_m); m++; merge_duplicates++; continue; } // cmp > 0 db->qsoNewRec(lastrec = rec_m); m++; } else { // lastrec exists cmp = comparebycall(rec_n, rec_m); if (cmp == 0) { merge_dups->qsoNewRec(rec_m); merge_duplicates++; m++; cmp2 = comparebycall(lastrec, rec_n); if (cmp2 == 0) { orig_dups->qsoNewRec(rec_n); orig_duplicates++; } else db->qsoNewRec(lastrec = rec_n); n++; continue; } if (cmp < 0) { cmp2 = comparebycall(lastrec, rec_n); if (cmp2 == 0) { orig_dups->qsoNewRec(rec_n); orig_duplicates++; } else db->qsoNewRec(lastrec = rec_n); n++; continue; } // cmp > 0 cmp2 = comparebycall(lastrec, rec_m); if (cmp2 == 0) { merge_dups->qsoNewRec(rec_m); merge_duplicates++; } else if (cmp2 < 0) { db->qsoNewRec(lastrec = rec_m); merged++; } m++; } } mergedir = logbook_filename; fname = fl_filename_name(mergedir.c_str()); pname = mergedir.find(fname); mergedir.erase(pname); if (db->nbrRecs()) db->SortByCall(); if (merged > 0) { snprintf(msg1, sizeof(msg1), "Merged %d records\n", merged); disptxt.append(msg1); } if (merge_duplicates) { merge_dups->SortByCall(); mrg_dups_name = mergedir; mrg_dups_name.append("merge_file_dups"); #ifdef __WIN32__ mrg_dups_name.append(".adi"); #else mrg_dups_name.append(".adif"); #endif adifFile.writeLog (mrg_dups_name.c_str(), merge_dups, true); snprintf(msg1, sizeof(msg1), "Found %d duplicate records\n", merge_duplicates); disptxt.append(msg1); snprintf(msg1, sizeof(msg1), "Duplicate's saved in %s\n", mrg_dups_name.c_str()); disptxt.append(msg1); } if (orig_duplicates) { orig_dups->SortByCall(); orig_dups_name = mergedir; orig_dups_name.append("original_file_dups"); #ifdef __WIN32__ orig_dups_name.append(".adi"); #else orig_dups_name.append(".adif"); #endif adifFile.writeLog (orig_dups_name.c_str(), orig_dups, true); snprintf(msg1,sizeof(msg1), "Original database had %d duplicates\n", orig_duplicates); disptxt.append(msg1); snprintf(msg1, sizeof(msg1), "Duplicate's saved in %s\n", orig_dups_name.c_str()); disptxt.append(msg1); } #ifdef _POSIX_MONOTONIC_CLOCK clock_gettime(CLOCK_MONOTONIC, &t2); #else clock_gettime(CLOCK_REALTIME, &t2); #endif merger_time = t2.tv_sec - t0.tv_sec + (t2.tv_nsec- t2.tv_nsec)/1e9; snprintf(msg1, sizeof(msg1), "Merger took %4.1f seconds\n", merger_time); disptxt.append(msg1); disptxt.append("================================================"); LOG_INFO("%s", disptxt.c_str()); disptxt.append("\n"); exit_merge_thread: delete mrgdb; delete orig_dups; delete merge_dups; delete copy; lastsort = orig_sort; cQsoDb::reverse = orig_reverse; Fl::awake(close_MERGE_thread); return NULL; abort: pthread_mutex_unlock(&MERGE_mutex); disptxt.assign("Merger aborted"); delete mrgdb; delete orig_dups; delete merge_dups; delete copy; lastsort = orig_sort; cQsoDb::reverse = orig_reverse; Fl::awake(close_MERGE_thread); return NULL; } static notify_dialog *alert_window = 0; void cb_mnuMergeADIF_log(Fl_Menu_* m, void* d) { ENSURE_THREAD(FLMAIN_TID); if (MERGE_thread) { if (!alert_window) alert_window = new notify_dialog; alert_window->notify(_("Database merger in progress"), 5.0); REQ(show_notifier, alert_window); return; } const char* p = FSEL::select( _("Merge ADIF file"), "ADIF\t*.{adi,adif}", LogsDir.c_str()); fl_digi_main->redraw(); Fl::flush(); if (!p) return; if (!*p) return; mrg_fname = p; abort_merger = false; MERGE_thread = new pthread_t; if (pthread_create(MERGE_thread, NULL, merge_thread, NULL) != 0) { LOG_PERROR("pthread_create"); return; } MilliSleep(10); } //====================================================================== static std::string lotw_download_name = ""; static cQsoDb *lotw_db = 0; extern Fl_Button *btn_view_unmatched; void verify_lotw(void *) { lotw_db = new cQsoDb; LOG_INFO("VERIFY_LOTW: adifFile.do_readfile(%s", lotw_download_name.c_str()); adifFile.do_readfile (lotw_download_name.c_str(), lotw_db); std::stringstream ss_note; if (lotw_db->nbrRecs() == 0) { LOG_INFO("%s", _("No records in lotw download file")); } else { std::string report_fname = LoTWDir; report_fname.append("unverified.txt"); std::ofstream report_file(report_fname.c_str()); int matchrec; cQsoRec *qrec, *lrec; int nverified = 0; int unverified = 0; std::string date; std::string qdate; for (int i = 0; i < lotw_db->nbrRecs(); i++) { lrec = lotw_db->getRec(i); date = lrec->getField(QSLRDATE); matchrec = qsodb.matched( lrec ); if (matchrec != -1) { qrec = qsodb.getRec(matchrec); qdate = qrec->getField(LOTWRDATE); if (date != qdate) { qrec->putField(STATE, lrec->getField(STATE)); qrec->putField(GRIDSQUARE, lrec->getField(GRIDSQUARE)); qrec->putField(CQZ, lrec->getField(CQZ)); qrec->putField(COUNTRY, lrec->getField(COUNTRY)); qrec->putField(CNTY, lrec->getField(CNTY)); qrec->putField(DXCC, lrec->getField(DXCC)); qrec->putField(DXCC, lrec->getField(DXCC)); qrec->putField(LOTWRDATE, lrec->getField(QSLRDATE)); } nverified++; } else { unverified++; report_file << lrec->getField(CALL) << ", " << lrec->getField(QSO_DATE) << ", " << lrec->getField(TIME_ON) << ", " << lrec->getField(FREQ) << ", " << lrec->getField(BAND) << ", " << lrec->getField(ADIF_MODE) << "\n"; } } report_file.close(); if (!unverified) remove(report_fname.c_str()); ss_note << "LoTW download contains " << lotw_db->nbrRecs() << " records\n\n" << nverified << " verified\n"; if (unverified) { ss_note << unverified << " unverified\n\n" << "Check file " << report_fname; btn_view_unmatched->activate(); if (nverified) qsodb.isdirty(1); LOG_INFO("%d records verified", nverified); LOG_INFO("%d records unverified", unverified); } if (!alert_window) alert_window = new notify_dialog; alert_window->notify(ss_note.str().c_str(), 15.0); REQ(show_notifier, alert_window); } delete lotw_db; } static Fl_Window *unmatched_viewer = (Fl_Window *)0; static Fl_Text_Display *viewer = (Fl_Text_Display *)0; static Fl_Text_Buffer *buffer = (Fl_Text_Buffer *)0; static Fl_Button *close_viewer = (Fl_Button *)0; void cb_close_viewer(Fl_Button *, void *) { if (unmatched_viewer) { unmatched_viewer->hide(); delete unmatched_viewer; unmatched_viewer = 0; } } void cb_btn_view_unmatched(Fl_Button *, void *) { btn_view_unmatched->deactivate(); if (!unmatched_viewer) { unmatched_viewer = new Fl_Window(100,100, 400, 500, _("Unmatched LoTW Records")); viewer = new Fl_Text_Display(5, 5, 390, 470, ""); buffer = new Fl_Text_Buffer(8192); viewer->buffer(buffer); viewer->textfont(progdefaults.LOGBOOKtextfont); viewer->textsize(progdefaults.LOGBOOKtextsize); close_viewer = new Fl_Button(320, 477, 75, 20, _("Close")); close_viewer->callback((Fl_Callback *)cb_close_viewer); unmatched_viewer->end(); unmatched_viewer->resizable(viewer); } std::string report_fname = LoTWDir; report_fname.append("unverified.txt"); std::ifstream report_file(report_fname.c_str()); if (report_file) { char linebuff[1025]; viewer->buffer()->text(""); while (!report_file.eof()) { report_file.getline(linebuff, 1024); strcat(linebuff, "\n"); viewer->insert(linebuff); } report_file.close(); unmatched_viewer->show(); } } void cb_btn_verify_lotw(Fl_Button *, void *) { std::string deffname = LoTWDir; deffname.append("lotwreport.adi"); std::ifstream f(deffname.c_str()); if (!f) { std::string alert = _("\ Could not find LoTW report file.\n\n\ Download from ARRL's LoTW page after logging in at:\n\n\ https://lotw.arrl.org/lotwuser/default\n\n\ Store the report file to the fldigi LOTW folder,\n\n\ naming the file 'lotwreport.adi'"); if (!alert_window) alert_window = new notify_dialog; alert_window->notify(alert.c_str(), 20); REQ(show_notifier, alert_window); return; } f.close(); lotw_download_name = deffname; Fl::awake(verify_lotw); } void cb_export_date_select() { if (qsodb.nbrRecs() == 0) return; int start = atoi(inp_export_start_date->value()); int stop = atoi(inp_export_stop_date->value()); chkExportBrowser->check_none(); if (!start || !stop) return; int chkdate; if (!btn_export_by_date->value()) return; cQsoRec *rec; for (int i = 0; i < qsodb.nbrRecs(); i++) { rec = qsodb.getRec (i); chkdate = atoi(rec->getField(progdefaults.sort_date_time_off ? QSO_DATE_OFF : QSO_DATE)); if (chkdate >= start && chkdate <= stop) chkExportBrowser->checked(i+1, 1); } chkExportBrowser->redraw(); } inline const char *szfreq(const char *freq) { static char szf[11]; float f = atof(freq); snprintf(szf, sizeof(szf), "%10.6f", f); return szf; } void cb_Export_log() { if (qsodb.nbrRecs() == 0) return; cQsoRec *rec; char line[80]; chkExportBrowser->clear(); #ifdef __APPLE__ chkExportBrowser->textfont(FL_SCREEN_BOLD); chkExportBrowser->textsize(12); #else chkExportBrowser->textfont(FL_COURIER); chkExportBrowser->textsize(12); #endif for( int i = 0; i < qsodb.nbrRecs(); i++ ) { rec = qsodb.getRec (i); snprintf(line,sizeof(line),"%8s %4s %-10s %-10s %-s %-s", rec->getField(QSO_DATE), rec->getField((export_to == LOTW ? TIME_ON : TIME_OFF) ), rec->getField(CALL), szfreq(rec->getField(FREQ)), adif2export(rec->getField(ADIF_MODE)).c_str(), adif2submode(rec->getField(ADIF_MODE)).c_str() ); chkExportBrowser->add(line); } cb_export_date_select(); wExport->show(); } void cb_mnuExportADIF_log(Fl_Menu_* m, void* d) { export_to = ADIF; cb_Export_log(); } void cb_mnuExportCSV_log(Fl_Menu_* m, void* d) { export_to = CSV; cb_Export_log(); } void cb_btnExportLoTW() { export_to = LOTW; cb_Export_log(); } void cb_mnuExportTEXT_log(Fl_Menu_* m, void *d) { export_to = TEXT; cb_Export_log(); } void cb_mnuShowLogbook(Fl_Menu_* m, void* d) { dlgLogbook->resize( progStatus.logbook_x, progStatus.logbook_y, progStatus.logbook_w, progStatus.logbook_h); dlgLogbook->show(); } enum State {VIEWREC, NEWREC}; static State logState = VIEWREC; void activateButtons() { if (logState == NEWREC) { bNewSave->label(_("Save")); bUpdateCancel->label(_("Cancel")); bUpdateCancel->activate(); bDelete->deactivate (); bSearchNext->deactivate (); bSearchPrev->deactivate (); inpDate_log->take_focus(); return; } bNewSave->label(_("New")); bUpdateCancel->label(_("Update")); if (qsodb.nbrRecs() > 0) { bDelete->activate(); bUpdateCancel->activate(); bSearchNext->activate (); bSearchPrev->activate (); wBrowser->take_focus(); } else { bDelete->deactivate(); bUpdateCancel->deactivate(); bSearchNext->deactivate(); bSearchPrev->deactivate(); } } void cb_btnNewSave(Fl_Button* b, void* d) { if (logState == VIEWREC) { logState = NEWREC; clearRecord(); activateButtons(); } else { saveRecord(); qsodb.SortByDate(progdefaults.sort_date_time_off); loadBrowser(); logState = VIEWREC; activateButtons(); } } void cb_btnUpdateCancel(Fl_Button* b, void* d) { if (logState == NEWREC) { logState = VIEWREC; activateButtons (); } else { updateRecord(); wBrowser->take_focus(); } } void cb_btnDelete(Fl_Button* b, void* d) { deleteRecord(); wBrowser->take_focus(); } void restore_sort() { switch (lastsort) { case SORTCALL : cQsoDb::reverse = callfwd; qsodb.SortByCall(); break; case SORTDATE : cQsoDb::reverse = progStatus.logbook_reverse; qsodb.SortByDate(progdefaults.sort_date_time_off); break; case SORTFREQ : cQsoDb::reverse = freqfwd; qsodb.SortByFreq(); break; case SORTMODE : cQsoDb::reverse = modefwd; qsodb.SortByMode(); break; default: break; } } void cb_SortByCall (void) { if (lastsort == SORTCALL) callfwd = !callfwd; else { callfwd = false; lastsort = SORTCALL; } cQsoDb::reverse = callfwd; qsodb.SortByCall(); loadBrowser(); } void cb_SortByDate (void) { if (lastsort == SORTDATE) progStatus.logbook_reverse = !progStatus.logbook_reverse; else { lastsort = SORTDATE; } cQsoDb::reverse = progStatus.logbook_reverse; qsodb.SortByDate(progdefaults.sort_date_time_off); loadBrowser(); } void reload_browser() { qsodb.SortByDate(progdefaults.sort_date_time_off); loadBrowser(); } void cb_SortByMode (void) { if (lastsort == SORTMODE) modefwd = !modefwd; else { modefwd = false; lastsort = SORTMODE; } cQsoDb::reverse = modefwd; qsodb.SortByMode(); loadBrowser(); } void cb_SortByFreq (void) { if (lastsort == SORTFREQ) freqfwd = !freqfwd; else { freqfwd = false; lastsort = SORTFREQ; } cQsoDb::reverse = freqfwd; qsodb.SortByFreq(); loadBrowser(); } void show_dup(void *dup) { int cdup = 0; if (dup == (void *)1) cdup = 1; if (dup == (void *)2) cdup = 2; Fl_Color call_clr = progdefaults.LOGGINGcolor; Fl_Color dup_clr = fl_rgb_color( progdefaults.dup_color.R, progdefaults.dup_color.G, progdefaults.dup_color.B); Fl_Color pdup_clr = fl_rgb_color( progdefaults.possible_dup_color.R, progdefaults.possible_dup_color.G, progdefaults.possible_dup_color.B); inpCall1->color(cdup == 1 ? dup_clr : cdup == 2 ? pdup_clr : call_clr); inpCall2->color(cdup == 1 ? dup_clr : cdup == 2 ? pdup_clr : call_clr); inpCall3->color(cdup == 1 ? dup_clr : cdup == 2 ? pdup_clr : call_clr); inpCall4->color(cdup == 1 ? dup_clr : cdup == 2 ? pdup_clr : call_clr); inpCall1->redraw(); inpCall2->redraw(); inpCall3->redraw(); inpCall4->redraw(); } void DupCheck() { size_t dup = 0; if (n3fjp_connected) { show_dup(0); n3fjp_dupcheck(); return; } if ( FD_logged_on && strlen(inpCall->value()) > 2) dup = FD_dupcheck(); else if ( progdefaults.xml_logbook) dup = xml_check_dup(); else { // check for call only for possible dup returns 2 if possible dup = qsodb.duplicate(inpCall->value()); if (dup && qsodb.duplicate( inpCall->value(), zdate(), ztime(), progdefaults.timespan, progdefaults.duptimespan, inpFreq->value(), progdefaults.dupband, inpState->value(), progdefaults.dupstate, mode_info[active_modem->get_mode()].adif_name, progdefaults.dupmode, inpXchgIn->value(), progdefaults.dupxchg1 ) ) dup = 1; } show_dup((void*)dup); } cQsoRec* SearchLog(const char *callsign) { if (progdefaults.xml_logbook) return search_fllog(callsign); size_t len = strlen(callsign); char* re = new char[len + 3]; snprintf(re, len + 3, "^%s$", callsign); int row = 0, col = 2; return wBrowser->search(row, col, !cQsoDb::reverse, re) ? qsodb.getRec(row) : 0; } void SearchLastQSO(const char *callsign) { if (n3fjp_connected) { n3fjp_get_record(callsign); return; } size_t len = strlen(callsign); if (len < 3) return; if (progdefaults.xml_logbook) { if(xml_get_record(callsign)) return; } Fl::focus(inpCall); char* re = new char[len + 3]; snprintf(re, len + 3, "^%s$", callsign); int row = 0, col = 2; if (wBrowser->search(row, col, !cQsoDb::reverse, re)) { wBrowser->GotoRow(row); inpName->value(inpName_log->value()); inpQTH->value(inpQth_log->value()); inpLoc1->value(inpLoc_log->value()); inpLoc1->position (0); inpState->value(inpState_log->value()); inpState->position (0); inpVEprov->value(inpVE_Prov_log->value ()); inpVEprov->position (0); inpCounty->value(inpCNTY_log->value ()); inpCounty->position (0); cboCountry->value(inpCountry_log->value ()); inpSearchString->value(callsign); inpNotes->value(inpNotes_log->value ()); if (inpLoc->value()[0]) { double lon1, lat1, lon2, lat2; double azimuth, distance; char szAZ[4]; if ( QRB::locator2longlat(&lon1, &lat1, progdefaults.myLocator.c_str()) == QRB::QRB_OK && QRB::locator2longlat(&lon2, &lat2, inpLoc->value()) == QRB::QRB_OK && QRB::qrb(lon1, lat1, lon2, lat2, &distance, &azimuth) == QRB::QRB_OK ) { snprintf(szAZ,sizeof(szAZ),"%0.f", azimuth); inpAZ->value(szAZ); inpAZ->position (0); } else inpAZ->value(""); } else inpAZ->value(""); } else { clear_log_fields(); } delete [] re; } void cb_search(Fl_Widget* w, void*) { const char* str = inpSearchString->value(); if (!*str) return; bool rev = w == bSearchPrev; int col = 2, row = wBrowser->value() + (rev ? -1 : 1); row = WCLAMP(row, 0, wBrowser->rows() - 1); if (wBrowser->search(row, col, rev, str)) wBrowser->GotoRow(row); wBrowser->take_focus(); } int log_search_handler(int) { if (!(Fl::event_state() & FL_CTRL)) return 0; switch (Fl::event_key()) { case 's': bSearchNext->do_callback(); break; case 'r': bSearchPrev->do_callback(); break; default: return 0; } return 1; } void cb_btnRetrieve(Fl_Button* b, void* d) { double drf = atof(inpFreq_log->value()); if (!drf) return; int rf1, rf, audio; rf1 = drf * 1e6; rf = rf1 / 10000; rf *= 10000; audio = rf1 - rf; // try to keep within normal xcvr bw, 500 - 3000 Hz while (audio > 3000) { audio -= 3000; rf += 3000; } if (audio < 500) { audio += 500; rf -= 500; } qsy(rf, audio); std::string mode_name = inpMode_log->value(); trx_mode m; for (m = 0; m < NUM_MODES; m++) if (mode_name == mode_info[m].adif_name) break; // do we have a valid modem? if (m < NUM_MODES && active_modem->get_mode() != mode_info[m].mode) init_modem(mode_info[m].mode); const cQsoRec *qsoPtr = qsodb.getRec(editNbr); inpCall->value(qsoPtr->getField(CALL)); inpName->value (qsoPtr->getField(NAME)); sDate_on = sDate_off = zdate(); sTime_on = sTime_off = ztime(); inpTimeOn->value(inpTimeOff->value()); inpTimeOn1->value(inpTimeOff->value()); inpTimeOn2->value(inpTimeOff->value()); inpTimeOn3->value(inpTimeOff->value()); inpTimeOn4->value(inpTimeOff->value()); inpTimeOn5->value(inpTimeOff->value()); inpState->value (qsoPtr->getField(STATE)); inpState->position (0); inpCounty->value (qsoPtr->getField(CNTY)); inpCounty->position (0); cboCountry->value (qsoPtr->getField(COUNTRY)); inpXchgIn->value(qsoPtr->getField(XCHG1)); inpQTH->value (qsoPtr->getField(QTH)); inpLoc1->value (qsoPtr->getField(GRIDSQUARE)); inpLoc1->position (0); inpNotes->value (qsoPtr->getField(NOTES)); wBrowser->take_focus(); if (n3fjp_connected) n3fjp_get_record(inpCall->value()); } void clearRecord() { Date tdy; inpCall_log->value (""); inpName_log->value (""); inpDate_log->value (tdy.szDate(2)); inpDateOff_log->value (tdy.szDate(2)); inpTimeOn_log->value (""); inpTimeOff_log->value (""); inpRstR_log->value (""); inpRstS_log->value (""); inpFreq_log->value (""); inpBand_log->value (""); inpMode_log->value (""); inpQth_log->value (""); inpState_log->value (""); inpVE_Prov_log->value (""); inpCountry_log->value (""); inpLoc_log->value (""); inpQSLrcvddate_log->value (""); inpQSLsentdate_log->value (""); inpEQSLrcvddate_log->value (""); inpEQSLsentdate_log->value (""); inpLOTWrcvddate_log->value (""); inpLOTWsentdate_log->value (""); inpSerNoOut_log->value (""); inpSerNoIn_log->value (""); inpXchgIn_log->value(""); inpMyXchg_log->value(progdefaults.myXchg.c_str()); inpNotes_log->value (""); inpIOTA_log->value(""); inpDXCC_log->value(""); inpQSL_VIA_log->value(""); inpCONT_log->value(""); inpCNTY_log->value(""); inpCQZ_log->value(""); inpITUZ_log->value(""); inpTX_pwr_log->value(""); inpSearchString->value (""); inp_log_sta_call->value(""); inp_log_op_call->value(""); inp_log_sta_qth->value(""); inp_log_sta_loc->value(""); inp_log_cwss_serno->value(""); inp_log_cwss_prec->value(""); inp_log_cwss_chk->value(""); inp_log_cwss_sec->value(""); } void saveRecord() { cQsoRec rec; rec.putField(CALL, inpCall_log->value()); rec.putField(NAME, inpName_log->value()); rec.putField(QSO_DATE, inpDate_log->value()); rec.putField(QSO_DATE_OFF, inpDateOff_log->value()); std::string tm = timestring(inpTimeOn_log->value()); rec.putField(TIME_ON, tm.c_str()); inpTimeOn_log->value(timeview(tm.c_str())); tm = timestring(inpTimeOff_log->value()); rec.putField(TIME_OFF, tm.c_str()); inpTimeOff_log->value(timeview(tm.c_str())); rec.putField(FREQ, inpFreq_log->value()); rec.putField(BAND, inpBand_log->value()); rec.putField(ADIF_MODE, inpMode_log->value()); rec.putField(QTH, inpQth_log->value()); rec.putField(STATE, inpState_log->value()); rec.putField(VE_PROV, inpVE_Prov_log->value()); rec.putField(COUNTRY, inpCountry_log->value()); rec.putField(GRIDSQUARE, inpLoc_log->value()); rec.putField(NOTES, inpNotes_log->value()); rec.putField(QSLRDATE, inpQSLrcvddate_log->value()); rec.putField(QSLSDATE, inpQSLsentdate_log->value()); rec.putField(EQSLRDATE, inpEQSLrcvddate_log->value()); rec.putField(EQSLSDATE, inpEQSLsentdate_log->value()); rec.putField(LOTWRDATE, inpLOTWrcvddate_log->value()); if (progdefaults.submit_lotw) { lotwsdate = zdate(); rec.putField(LOTWSDATE, lotwsdate.c_str()); Fl::awake(refresh_logbook_dialog); } else rec.putField(LOTWSDATE, inpLOTWsentdate_log->value()); rec.putField(RST_RCVD, inpRstR_log->value ()); rec.putField(RST_SENT, inpRstS_log->value ()); rec.putField(SRX, inpSerNoIn_log->value()); rec.putField(STX, inpSerNoOut_log->value()); if (inpSPCnum->value()[0]) { inpXchgIn_log->value(inpSPCnum->value()); rec.putField(XCHG1, inpSPCnum->value()); } else if (inpSQSO_category->value()[0]) { inpXchgIn_log->value(inpSQSO_category->value()); rec.putField(XCHG1, inpSQSO_category->value()); } else rec.putField(XCHG1, inpXchgIn_log->value()); rec.putField(CLASS, inpClass_log->value()); rec.putField(ARRL_SECT, inpSection_log->value()); if (!qso_exchange.empty()) { rec.putField(MYXCHG, qso_exchange.c_str()); qso_exchange.clear(); qso_time.clear(); } else if (!qso_time.empty()) { std::string myexch = inpMyXchg_log->value(); myexch.append(" ").append(qso_time); rec.putField(MYXCHG, myexch.c_str()); qso_time.clear(); } else { rec.putField(MYXCHG, inpMyXchg_log->value()); } rec.putField(CNTY, inpCNTY_log->value()); rec.putField(IOTA, inpIOTA_log->value()); rec.putField(DXCC, inpDXCC_log->value()); rec.putField(DXCC, inpQSL_VIA_log->value()); rec.putField(CONT, inpCONT_log->value()); rec.putField(CQZ, inpCQZ_log->value()); rec.putField(ITUZ, inpITUZ_log->value()); rec.putField(TX_PWR, inpTX_pwr_log->value()); rec.putField(STA_CALL, inp_log_sta_call->value()); rec.putField(OP_CALL, inp_log_op_call->value()); rec.putField(MY_CITY, inp_log_sta_qth->value()); rec.putField(MY_GRID, inp_log_sta_loc->value()); rec.putField(SS_SERNO, inp_log_cwss_serno->value()); rec.putField(SS_PREC, inp_log_cwss_prec->value()); rec.putField(SS_CHK, inp_log_cwss_chk->value()); rec.putField(SS_SEC, inp_log_cwss_sec->value()); rec.putField(AGE, inp_age_log->value()); rec.putField(TEN_TEN, inp_1010_log->value()); rec.putField(CHECK, inp_check_log->value()); rec.putField(TROOPS, inp_log_troop_s->value()); rec.putField(TROOPR, inp_log_troop_r->value()); rec.putField(SCOUTS, inp_log_scout_s->value()); rec.putField(SCOUTR, inp_log_scout_r->value()); qsodb.qsoNewRec (&rec); lotw_recs_sent.push_back(qsodb.nbrRecs() - 1); dxcc_entity_cache_add(&rec); submit_record(rec); qsodb.isdirty(0); reload_browser(); if (qsodb.nbrRecs() == 1) adifFile.writeLog (logbook_filename.c_str(), &qsodb); else adifFile.writeAdifRec(&rec, logbook_filename.c_str()); } void updateRecord() { cQsoRec rec; if (qsodb.nbrRecs() == 0) return; rec.putField(CALL, inpCall_log->value()); rec.putField(NAME, inpName_log->value()); rec.putField(QSO_DATE, inpDate_log->value()); rec.putField(QSO_DATE_OFF, inpDateOff_log->value()); std::string tm = timestring(inpTimeOn_log->value()); rec.putField(TIME_ON, tm.c_str()); inpTimeOn_log->value(timeview(tm.c_str())); tm = timestring(inpTimeOff_log->value()); rec.putField(TIME_OFF, tm.c_str()); inpTimeOff_log->value(timeview(tm.c_str())); rec.putField(FREQ, inpFreq_log->value()); rec.putField(BAND, inpBand_log->value()); rec.putField(ADIF_MODE, inpMode_log->value()); rec.putField(QTH, inpQth_log->value()); rec.putField(STATE, inpState_log->value()); rec.putField(VE_PROV, inpVE_Prov_log->value()); rec.putField(COUNTRY, inpCountry_log->value()); rec.putField(GRIDSQUARE, inpLoc_log->value()); rec.putField(NOTES, inpNotes_log->value()); rec.putField(QSLRDATE, inpQSLrcvddate_log->value()); rec.putField(QSLSDATE, inpQSLsentdate_log->value()); rec.putField(EQSLRDATE, inpEQSLrcvddate_log->value()); rec.putField(EQSLSDATE, inpEQSLsentdate_log->value()); rec.putField(LOTWRDATE, inpLOTWrcvddate_log->value()); rec.putField(LOTWSDATE, inpLOTWsentdate_log->value()); rec.putField(RST_RCVD, inpRstR_log->value ()); rec.putField(RST_SENT, inpRstS_log->value ()); rec.putField(SRX, inpSerNoIn_log->value()); rec.putField(STX, inpSerNoOut_log->value()); rec.putField(XCHG1, inpXchgIn_log->value()); rec.putField(MYXCHG, inpMyXchg_log->value()); rec.putField(CLASS, inpClass_log->value()); rec.putField(ARRL_SECT, inpSection_log->value()); rec.putField(CNTY, inpCNTY_log->value()); rec.putField(IOTA, inpIOTA_log->value()); rec.putField(DXCC, inpDXCC_log->value()); rec.putField(QSL_VIA, inpQSL_VIA_log->value()); rec.putField(CONT, inpCONT_log->value()); rec.putField(CQZ, inpCQZ_log->value()); rec.putField(ITUZ, inpITUZ_log->value()); rec.putField(TX_PWR, inpTX_pwr_log->value()); rec.putField(STA_CALL, inp_log_sta_call->value()); rec.putField(OP_CALL, inp_log_op_call->value()); rec.putField(MY_CITY, inp_log_sta_qth->value()); rec.putField(MY_GRID, inp_log_sta_loc->value()); rec.putField(SS_SERNO, inp_log_cwss_serno->value()); rec.putField(SS_PREC, inp_log_cwss_prec->value()); rec.putField(SS_CHK, inp_log_cwss_chk->value()); rec.putField(SS_SEC, inp_log_cwss_sec->value()); rec.putField(AGE, inp_age_log->value()); rec.putField(TEN_TEN, inp_1010_log->value()); rec.putField(CHECK, inp_check_log->value()); rec.putField(TROOPS, inp_log_troop_s->value()); rec.putField(TROOPR, inp_log_troop_r->value()); rec.putField(SCOUTS, inp_log_scout_s->value()); rec.putField(SCOUTR, inp_log_scout_r->value()); dxcc_entity_cache_rm(qsodb.getRec(editNbr)); qsodb.qsoUpdRec (editNbr, &rec); dxcc_entity_cache_add(&rec); qsodb.isdirty(0); restore_sort(); loadBrowser(true); adifFile.writeLog (logbook_filename.c_str(), &qsodb); } void deleteRecord () { if (qsodb.nbrRecs() == 0 || fl_choice2(_("Really delete record for \"%s\"?"), _("Yes"), _("No"), NULL, wBrowser->valueAt(-1, 2))) return; dxcc_entity_cache_rm(qsodb.getRec(editNbr)); qsodb.qsoDelRec(editNbr); qsodb.isdirty(0); restore_sort(); loadBrowser(true); adifFile.writeLog (logbook_filename.c_str(), &qsodb); } void EditRecord( int i ) { cQsoRec *editQSO = qsodb.getRec (i); if( !editQSO ) return; inpCall_log->value (editQSO->getField(CALL)); inpName_log->value (editQSO->getField(NAME)); inpDate_log->value (editQSO->getField(QSO_DATE)); inpDateOff_log->value (editQSO->getField(QSO_DATE_OFF)); inpTimeOn_log->value (timeview(editQSO->getField(TIME_ON))); inpTimeOff_log->value (timeview(editQSO->getField(TIME_OFF))); inpRstR_log->value (editQSO->getField(RST_RCVD)); inpRstS_log->value (editQSO->getField(RST_SENT)); inpFreq_log->value (editQSO->getField(FREQ)); inpBand_log->value (editQSO->getField(BAND)); inpMode_log->value (editQSO->getField(ADIF_MODE)); inpState_log->value (editQSO->getField(STATE)); inpVE_Prov_log->value (editQSO->getField(VE_PROV)); inpCountry_log->value (editQSO->getField(COUNTRY)); inpQth_log->value (editQSO->getField(QTH)); inpLoc_log->value (editQSO->getField(GRIDSQUARE)); inpQSLrcvddate_log->value (editQSO->getField(QSLRDATE)); inpQSLsentdate_log->value (editQSO->getField(QSLSDATE)); inpEQSLrcvddate_log->value (editQSO->getField(EQSLRDATE)); inpEQSLsentdate_log->value (editQSO->getField(EQSLSDATE)); inpLOTWrcvddate_log->value (editQSO->getField(LOTWRDATE)); inpLOTWsentdate_log->value (editQSO->getField(LOTWSDATE)); inpNotes_log->value (editQSO->getField(NOTES)); inpSerNoIn_log->value(editQSO->getField(SRX)); inpSerNoOut_log->value(editQSO->getField(STX)); inpXchgIn_log->value(editQSO->getField(XCHG1)); inpClass_log->value(editQSO->getField(CLASS)); inpSection_log->value(editQSO->getField(ARRL_SECT)); inpMyXchg_log->value(editQSO->getField(MYXCHG)); inpCNTY_log->value(editQSO->getField(CNTY)); inpIOTA_log->value(editQSO->getField(IOTA)); inpDXCC_log->value(editQSO->getField(DXCC)); inpQSL_VIA_log->value(editQSO->getField(QSL_VIA)); inpCONT_log->value(editQSO->getField(CONT)); inpCQZ_log->value(editQSO->getField(CQZ)); inpITUZ_log->value(editQSO->getField(ITUZ)); inpTX_pwr_log->value(editQSO->getField(TX_PWR)); inp_log_sta_call->value(editQSO->getField(STA_CALL)); inp_log_op_call->value(editQSO->getField(OP_CALL)); inp_log_sta_qth->value(editQSO->getField(MY_CITY)); inp_log_sta_loc->value(editQSO->getField(MY_GRID)); inp_log_cwss_serno->value(editQSO->getField(SS_SERNO)); inp_log_cwss_prec->value(editQSO->getField(SS_PREC)); inp_log_cwss_chk->value(editQSO->getField(SS_CHK)); inp_log_cwss_sec->value(editQSO->getField(SS_SEC)); inp_age_log->value(editQSO->getField(AGE)); inp_1010_log->value(editQSO->getField(TEN_TEN)); inp_check_log->value(editQSO->getField(CHECK)); inp_log_troop_s->value(editQSO->getField(TROOPS)); inp_log_troop_r->value(editQSO->getField(TROOPR)); inp_log_scout_s->value(editQSO->getField(SCOUTS)); inp_log_scout_r->value(editQSO->getField(SCOUTR)); } std::string sDate_on = ""; std::string sTime_on = ""; std::string sDate_off = ""; std::string sTime_off = ""; void AddRecord () { inpCall_log->value(inpCall->value()); inpName_log->value (inpName->value()); if (progdefaults.force_date_time) { inpDate_log->value(sDate_off.c_str()); inpTimeOn_log->value (timeview(sTime_off.c_str())); } else { inpDate_log->value(sDate_on.c_str()); inpTimeOn_log->value (timeview(sTime_on.c_str())); } inpDateOff_log->value(sDate_off.c_str()); inpTimeOff_log->value (timeview(sTime_off.c_str())); inpRstR_log->value (inpRstIn->value()); inpRstS_log->value (inpRstOut->value()); { char Mhz[30]; snprintf(Mhz, sizeof(Mhz), "%-f", atof(inpFreq->value()) / 1000.0); inpFreq_log->value(Mhz); inpBand_log->value(band_name(Mhz)); } inpMode_log->value (logmode); inpState_log->value (ucasestr(inpState->value()).c_str()); inpVE_Prov_log->value (ucasestr(inpVEprov->value()).c_str()); inpCountry_log->value (cboCountry->value()); inpCNTY_log->value (inpCounty->value()); inpSerNoIn_log->value(inpSerNo->value()); inpSerNoOut_log->value(outSerNo->value()); inpXchgIn_log->value(inpXchgIn->value()); inpMyXchg_log->value(progdefaults.myXchg.c_str()); inpQth_log->value (inpQTH->value()); inpLoc_log->value (inpLoc->value()); inpQSLrcvddate_log->value (""); inpQSLsentdate_log->value (""); inpEQSLrcvddate_log->value (""); inpEQSLsentdate_log->value (""); inpLOTWrcvddate_log->value (""); inpLOTWsentdate_log->value (""); inpNotes_log->value (inpNotes->value()); inpTX_pwr_log->value (progdefaults.mytxpower.c_str()); inpIOTA_log->value(""); inpDXCC_log->value(""); inpQSL_VIA_log->value(""); inpCONT_log->value(""); inpCQZ_log->value(inp_CQzone->value()); inpITUZ_log->value(""); inpClass_log->value(ucasestr(inpClass->value()).c_str()); inpSection_log->value(ucasestr(inpSection->value()).c_str()); inp_log_sta_call->value(progdefaults.myCall.c_str()); inp_log_op_call->value(progdefaults.operCall.c_str()); inp_log_sta_qth->value(progdefaults.myQth.c_str()); inp_log_sta_loc->value(progdefaults.myLocator.c_str()); inp_log_cwss_serno->value(ucasestr(inp_SS_SerialNoR->value()).c_str()); inp_log_cwss_prec->value(ucasestr(inp_SS_Precedence->value()).c_str()); inp_log_cwss_chk->value(ucasestr(inp_SS_Check->value()).c_str()); inp_log_cwss_sec->value(ucasestr(inp_SS_Section->value()).c_str()); inp_age_log->value(ucasestr(inp_KD_age->value()).c_str()); inp_check_log->value(ucasestr(inp_ARR_check->value()).c_str()); inp_1010_log->value(ucasestr(inp_1010_nr->value()).c_str()); inp_log_troop_s->value(progdefaults.my_JOTA_troop.c_str()); inp_log_troop_r->value(inp_JOTA_troop->value()); inp_log_scout_s->value(progdefaults.my_JOTA_scout.c_str()); inp_log_scout_r->value(inp_JOTA_scout->value()); saveRecord(); logState = VIEWREC; activateButtons(); } void cb_browser (Fl_Widget *w, void *data ) { Table *table = (Table *)w; editNbr = atoi(table->valueAt(-1,6)); EditRecord (editNbr); } void addBrowserRow(cQsoRec *rec, int nbr) { char sNbr[6]; snprintf(sNbr,sizeof(sNbr),"%d", nbr); wBrowser->addRow (7, rec->getField(progdefaults.sort_date_time_off ? QSO_DATE_OFF : QSO_DATE), timeview4(rec->getField(progdefaults.sort_date_time_off ? TIME_OFF : TIME_ON)), rec->getField(CALL), rec->getField(NAME), rec->getField(FREQ), rec->getField(ADIF_MODE), sNbr); } void adjustBrowser(bool keep_pos) { int row = wBrowser->value(), pos = wBrowser->scrollPos(); if (row >= qsodb.nbrRecs()) row = qsodb.nbrRecs() - 1; if (keep_pos && row >= 0) { wBrowser->value(row); wBrowser->scrollTo(pos); } else { if (cQsoDb::reverse == true) wBrowser->FirstRow (); else wBrowser->LastRow (); } char szRecs[6]; snprintf(szRecs, sizeof(szRecs), "%5d", qsodb.nbrRecs()); txtNbrRecs_log->value(szRecs); } void loadBrowser(bool keep_pos) { cQsoRec *rec; wBrowser->clear(); if (qsodb.nbrRecs() == 0) return; for( int i = 0; i < qsodb.nbrRecs(); i++ ) { rec = qsodb.getRec (i); addBrowserRow(rec, i); } adjustBrowser(keep_pos); } //============================================================================= // Cabrillo reporter //============================================================================= const char *szContests[] = { "AP-SPRINT", "ARRL-10", "ARRL-160", "ARRL-DX-CW", "ARRL-DX-SSB", "ARRL-SS-CW", "ARRL-SS-SSB", "ARRL-UHF-AUG", "ARRL-VHF-JAN", "ARRL-VHF-JUN", "ARRL-VHF-SEP", "ARRL-RTTY", "BARTG-RTTY", "BARTG-SPRINT", "CQ-160-CW", "CQ-160-SSB", "CQ-WPX-CW", "CQ-WPX-RTTY", "CQ-WPX-SSB", "CQ-VHF", "CQ-WW-CW", "CQ-WW-RTTY", "CQ-WW-SSB", "DARC-WAEDC-CW", "DARC-WAEDC-RTTY", "DARC-WAEDC-SSB", "FCG-FQP", "IARU-HF", "JIDX-CW", "JIDX-SSB", "NAQP-CW", "NAQP-RTTY", "NAQP-SSB", "NA-SPRINT-CW", "NA-SPRINT-SSB", "NCCC-CQP", "NEQP", "OCEANIA-DX-CW", "OCEANIA-DX-SSB", "RDXC", "RSGB-IOTA", "SAC-CW", "SAC-SSB", "STEW-PERRY", "TARA-RTTY", 0 }; enum icontest { AP_SPRINT, ARRL_10, ARRL_160, ARRL_DX_CW, ARRL_DX_SSB, ARRL_SS_CW, ARRL_SS_SSB, ARRL_UHF_AUG, ARRL_VHF_JAN, ARRL_VHF_JUN, ARRL_VHF_SEP, ARRL_RTTY, BARTG_RTTY, BARTG_SPRINT, CQ_160_CW, CQ_160_SSB, CQ_WPX_CW, CQ_WPX_RTTY, CQ_WPX_SSB, CQ_VHF, CQ_WW_CW, CQ_WW_RTTY, CQ_WW_SSB, DARC_WAEDC_CW, DARC_WAEDC_RTTY, DARC_WAEDC_SSB, FCG_FQP, IARU_HF, JIDX_CW, JIDX_SSB, NAQP_CW, NAQP_RTTY, NAQP_SSB, NA_SPRINT_CW, NA_SPRINT_SSB, NCCC_CQP, NEQP, OCEANIA_DX_CW, OCEANIA_DX_SSB, RDXC, RSGB_IOTA, SAC_CW, SAC_SSB, STEW_PERRY, TARA_RTTY }; bool bInitCombo = true; icontest contestnbr; void setContestType() { contestnbr = (icontest)cboContest->index(); btnCabCall->value(true); btnCabFreq->value(true); btnCabMode->value(true); btnCabQSOdate->value(true); btnCabTimeOFF->value(true); btnCabRSTsent->value(true); btnCabRSTrcvd->value(true); btnCabSerialIN->value(true);btnCabSerialOUT->value(true); btnCabXchgIn->value(true); btnCabMyXchg->value(true); btnCabCounty->value(true); btnCabState->value(true); switch (contestnbr) { case ARRL_SS_CW : case ARRL_SS_SSB : btnCabRSTrcvd->value(false); break; case BARTG_RTTY : case BARTG_SPRINT : break; case ARRL_UHF_AUG : case ARRL_VHF_JAN : case ARRL_VHF_JUN : case ARRL_VHF_SEP : case CQ_VHF : btnCabRSTrcvd->value(false); btnCabSerialIN->value(false); btnCabSerialOUT->value(false); break; case AP_SPRINT : case ARRL_10 : case ARRL_160 : case ARRL_DX_CW : case ARRL_DX_SSB : case CQ_160_CW : case CQ_160_SSB : case CQ_WPX_CW : case CQ_WPX_RTTY : case CQ_WPX_SSB : case RDXC : case OCEANIA_DX_CW : case OCEANIA_DX_SSB : break; case DARC_WAEDC_CW : case DARC_WAEDC_RTTY : case DARC_WAEDC_SSB : break; case NAQP_CW : case NAQP_RTTY : case NAQP_SSB : case NA_SPRINT_CW : case NA_SPRINT_SSB : break; case RSGB_IOTA : break; default : break; } } void cb_Export_Cabrillo(Fl_Menu_* m, void* d) { if (qsodb.nbrRecs() == 0) return; cQsoRec *rec; char line[80]; int indx = 0; if (bInitCombo) { bInitCombo = false; while (szContests[indx]) { cboContest->add(szContests[indx]); indx++; } } cboContest->index(0); chkCabBrowser->clear(); #ifdef __APPLE__ chkCabBrowser->textfont(FL_SCREEN_BOLD); chkCabBrowser->textsize(12); #else chkCabBrowser->textfont(FL_COURIER); chkCabBrowser->textsize(12); #endif for( int i = 0; i < qsodb.nbrRecs(); i++ ) { rec = qsodb.getRec (i); memset(line, 0, sizeof(line)); snprintf(line,sizeof(line),"%8s %4s %-10s %-10s %-s", rec->getField(QSO_DATE), time4(rec->getField(TIME_OFF)), rec->getField(CALL), szfreq(rec->getField(FREQ)), adif2export(rec->getField(ADIF_MODE)).c_str() ); chkCabBrowser->add(line); } wCabrillo->show(); } void cabrillo_append_qso (FILE *fp, cQsoRec *rec) { char freq[16] = ""; std::string rst_in, rst_out, exch_in, exch_out, date, time, mode, mycall, call, exch, state, county; std::string qsoline = "QSO: "; int ifreq = 0; size_t len = 0; size_t p = 0; exch_out.clear(); exch_in.clear(); exch.clear(); if (btnCabFreq->value()) { ifreq = (int)(1000.0 * atof(rec->getField(FREQ))); snprintf(freq, sizeof(freq), "%7d", ifreq); qsoline.append(freq); qsoline.append(" "); } if (btnCabMode->value()) { mode = adif2export(rec->getField(ADIF_MODE)); if (mode.compare("USB") == 0 || mode.compare("LSB") == 0 || mode.compare("FM") == 0 || mode.compare("SSB") == 0 || mode.compare("PH") == 0 ) mode = "PH"; else if (mode.compare("RTTY") == 0) mode = "RY"; if (mode.length() < 10) mode.append(10 - mode.length(), ' '); qsoline.append(mode).append(" "); } if (btnCabQSOdate->value()) { date = rec->getField(progdefaults.sort_date_time_off ? QSO_DATE_OFF : QSO_DATE); date.insert(4,"-"); date.insert(7,"-"); qsoline.append(date).append(" "); } if (btnCabTimeOFF->value()) { time = rec->getField(progdefaults.sort_date_time_off ? TIME_OFF : TIME_ON); qsoline.append(time4(time.c_str())).append(" "); } mycall = progdefaults.myCall; if (mycall.length() > 13) mycall = mycall.substr(0,13); len = mycall.length(); if (len < 13) mycall.append(13 - len, ' '); qsoline.append(mycall).append(" "); if (btnCabRSTsent->value() || contestnbr == BARTG_RTTY) { rst_out = rec->getField(RST_SENT); if (rst_out.length() > 3) rst_out = rst_out.substr(0, 3); len = rst_out.length(); if (len < 3) rst_out.append(3 - len, ' '); exch_out.append(rst_out).append(" "); } if (btnCabSerialOUT->value() || contestnbr == BARTG_RTTY) { exch_out.append(rec->getField(STX)).append(" "); } if (btnCabMyXchg->value()) { exch = rec->getField(MYXCHG); if (!exch.empty()) exch_out.append(exch).append(" "); } if (contestnbr == BARTG_RTTY) { std::string toff = rec->getField(TIME_OFF); if (toff.length() > 4) toff = toff.substr(0,4); toff = toff.append(" "); exch_out.append(toff); } // // ADD CONTESTNBR == FD // // if (exch_out.length() > 20) exch_out = exch_out.substr(0,20); len = exch_out.length(); if (len < 20) exch_out.append(20 - len, ' '); qsoline.append(exch_out); if (btnCabCall->value()) { call = rec->getField(CALL); if (call.length() > 13) call = call.substr(0,13); len = call.length(); if (len < 13) call.append(13 - len, ' '); qsoline.append(call); qsoline.append(" "); } if (btnCabRSTrcvd->value()) { rst_in = rec->getField(RST_RCVD); if (rst_in.length() > 3) rst_in = rst_in.substr(0,3); len = rst_in.length(); if (len < 3) rst_in.append(3 - len, ' '); qsoline.append(rst_in); qsoline.append(" "); } if (btnCabSerialIN->value()) { exch_in = exch_in.append(rec->getField(SRX)); if (exch_in.length()) exch_in += ' '; } if (btnCabXchgIn->value()) { exch = rec->getField(XCHG1); while ((p = exch.find(":")) != std::string::npos) exch.erase(p,1); while ((p = exch.find(" ")) != std::string::npos) exch.erase(p,1); if (exch[0] == ' ') exch.erase(0,1); exch_in.append(exch); } if (exch_in.length() > 14) exch_in = exch_in.substr(0,14); len = exch_in.length(); if (len < 14) exch_in.append(14 - len, ' '); if (btnCabState->value()) { state = rec->getField(STATE); if (!state.empty()) qsoline.append(state).append(" "); } if (btnCabCounty->value()) { county = rec->getField(CNTY); if (!county.empty()) qsoline.append(county).append(" "); } qsoline.append(exch_in); fprintf (fp, "%s\n", qsoline.c_str()); return; } void WriteCabrillo() { if (chkCabBrowser->nchecked() == 0) return; cQsoRec *rec; std::string title = _("Create cabrillo report"); std::string filters = "TEXT\t*.txt"; #ifdef __APPLE__ filters.append("\n"); #endif std::string strContest = ""; const char* p = FSEL::saveas( title.c_str(), filters.c_str(), "contest.txt"); if (!p) return; if (!*p) return; for (int i = 0; i < chkCabBrowser->FLTK_nitems(); i++) { if (chkCabBrowser->checked(i + 1)) { rec = qsodb.getRec(i); rec->putField(EXPORT, "E"); qsodb.qsoUpdRec (i, rec); } } std::string sp = p; if (sp.find(".txt") == std::string::npos) sp.append(".txt"); FILE *cabFile = fl_fopen (p, "w"); if (!cabFile) return; strContest = cboContest->value(); contestnbr = (icontest)cboContest->index(); fprintf (cabFile, "START-OF-LOG: 3.0\n\ CREATED-BY: %s %s\n\ \n\ # The callsign used during the contest.\n\ CALLSIGN: %s\n\ \n\ # ASSISTED or NON-ASSISTED\n\ CATEGORY-ASSISTED: \n\ \n\ # Band: ALL, 160M, 80M, 40M, 20M, 15M, 10M, 6M, 2M, 222, 432, 902, 1.2G\n\ CATEGORY-BAND: \n\ \n\ # Mode: SSB, CW, RTTY, MIXED \n\ CATEGORY-MODE: \n\ \n\ # Operator: SINGLE-OP, MULTI-OP, CHECKLOG \n\ CATEGORY-OPERATOR: \n\ \n\ # Power: HIGH, LOW, QRP \n\ CATEGORY-POWER: \n\ \n\ # Station: FIXED, MOBILE, PORTABLE, ROVER, EXPEDITION, HQ, SCHOOL \n\ CATEGORY-STATION: \n\ \n\ # Time: 6-HOURS, 12-HOURS, 24-HOURS \n\ CATEGORY-TIME: \n\ \n\ # Transmitter: ONE, TWO, LIMITED, UNLIMITED, SWL \n\ CATEGORY-TRANSMITTER: \n\ \n\ # Overlay: ROOKIE, TB-WIRES, NOVICE-TECH, OVER-50 \n\ CATEGORY-OVERLAY: \n\ \n\ # Integer number\n\ CLAIMED-SCORE: \n\ \n\ # Name of the radio club with which the score should be aggregated.\n\ CLUB: \n\ \n\ # Contest: AP-SPRINT, ARRL-10, ARRL-160, ARRL-DX-CW, ARRL-DX-SSB, ARRL-SS-CW,\n\ # ARRL-SS-SSB, ARRL-UHF-AUG, ARRL-VHF-JAN, ARRL-VHF-JUN, ARRL-VHF-SEP,\n\ # ARRL-RTTY, BARTG-RTTY, CQ-160-CW, CQ-160-SSB, CQ-WPX-CW, CQ-WPX-RTTY,\n\ # CQ-WPX-SSB, CQ-VHF, CQ-WW-CW, CQ-WW-RTTY, CQ-WW-SSB, DARC-WAEDC-CW,\n\ # DARC-WAEDC-RTTY, DARC-WAEDC-SSB, FCG-FQP, IARU-HF, JIDX-CW, JIDX-SSB,\n\ # NAQP-CW, NAQP-RTTY, NAQP-SSB, NA-SPRINT-CW, NA-SPRINT-SSB, NCCC-CQP,\n\ # NEQP, OCEANIA-DX-CW, OCEANIA-DX-SSB, RDXC, RSGB-IOTA, SAC-CW, SAC-SSB,\n\ # STEW-PERRY, TARA-RTTY \n\ CONTEST: %s\n\ \n\ # Optional email address\n\ EMAIL: \n\ \n\ LOCATION: \n\ \n\ # Operator name\n\ NAME: \n\ \n\ # Maximum 4 address lines.\n\ ADDRESS: \n\ ADDRESS: \n\ ADDRESS: \n\ ADDRESS: \n\ \n\ # A space-delimited list of operator callsign(s). \n\ OPERATORS: \n\ \n\ # Offtime yyyy-mm-dd nnnn yyyy-mm-dd nnnn \n\ # OFFTIME: \n\ \n\ # Soapbox comments.\n\ SOAPBOX: \n\ SOAPBOX: \n\ SOAPBOX: \n\n", PACKAGE_NAME, PACKAGE_VERSION, progdefaults.myCall.c_str(), strContest.c_str() ); qsodb.SortByDate(progdefaults.sort_date_time_off); for (int i = 0; i < qsodb.nbrRecs(); i++) { rec = qsodb.getRec(i); if (rec->getField(EXPORT)[0] == 'E') { cabrillo_append_qso(cabFile, rec); rec->putField(EXPORT,""); qsodb.qsoUpdRec(i, rec); } } fprintf(cabFile, "END-OF-LOG:\n"); fclose (cabFile); return; } #if HAVE_STD_HASH # include <unordered_map> typedef std::unordered_map<std::string, unsigned> dxcc_entity_cache_t; #elif HAVE_STD_TR1_HASH # include <tr1/unordered_map> typedef std::tr1::unordered_map<std::string, unsigned> dxcc_entity_cache_t; #else # error "No std::hash or std::tr1::hash support" #endif static dxcc_entity_cache_t dxcc_entity_cache; static bool dxcc_entity_cache_enabled = false; #include "dxcc.h" static void dxcc_entity_cache_clear(void) { if (dxcc_entity_cache_enabled) dxcc_entity_cache.clear(); } static void dxcc_entity_cache_add(cQsoRec* r) { if (!dxcc_entity_cache_enabled | !r) return; const dxcc* e = dxcc_lookup(r->getField(CALL)); if (e) dxcc_entity_cache[e->country]++; } static void dxcc_entity_cache_add(cQsoDb& db) { if (!dxcc_entity_cache_enabled) return; int n = db.nbrRecs(); for (int i = 0; i < n; i++) dxcc_entity_cache_add(db.getRec(i)); if (!dxcc_entity_cache.empty()) { unsigned int un = dxcc_entity_cache.size(); LOG_INFO("Found %u countries in %d QSO records", un, n); } } static void dxcc_entity_cache_rm(cQsoRec* r) { if (!dxcc_entity_cache_enabled || !r) return; const dxcc* e = dxcc_lookup(r->getField(CALL)); if (!e) return; dxcc_entity_cache_t::iterator i = dxcc_entity_cache.find(e->country); if (i != dxcc_entity_cache.end()) { if (i->second) i->second--; else dxcc_entity_cache.erase(i); } } void dxcc_entity_cache_enable(bool v) { if (dxcc_entity_cache_enabled == v) return; dxcc_entity_cache_clear(); if ((dxcc_entity_cache_enabled = v)) dxcc_entity_cache_add(qsodb); } bool qsodb_dxcc_entity_find(const char* country) { return dxcc_entity_cache.find(country) != dxcc_entity_cache.end(); } //====================================================================== // eQSL verification support //====================================================================== static std::string eqsl_download_name = ""; static cQsoDb *eqsl_db = 0; void verify_eqsl(void *) { eqsl_db = new cQsoDb; LOG_INFO("VERIFY_EQSL: adifFile.do_readfile(%s)", eqsl_download_name.c_str()); adifFile.do_readfile (eqsl_download_name.c_str(), eqsl_db); if (eqsl_db->nbrRecs() == 0) { LOG_INFO("No records in eqsl download file"); return; } LOG_INFO("logbook %d records, verify with %d records", qsodb.nbrRecs(), eqsl_db->nbrRecs()); int matchrec; cQsoRec *qrec, *lrec; int nverified = 0; for (int i = 0; i < eqsl_db->nbrRecs(); i++) { lrec = eqsl_db->getRec(i); matchrec = qsodb.matched( lrec ); if (matchrec != -1) { qrec = qsodb.getRec(matchrec); if (qrec->getField(EQSLRDATE)[0] == 0) { nverified++; qrec->putField(EQSLRDATE, zdate()); } } else { LOG_INFO("Could not match %s on %s", lrec->getField(CALL), lrec->getField(QSO_DATE)); } } LOG_INFO("%d records updated", nverified); delete eqsl_db; } void cb_btn_verify_eqsl(Fl_Button *, void *) { ENSURE_THREAD(FLMAIN_TID); const char* p = FSEL::select(_("LoTW download file"), "ADIF\t*.{adi,adif}", LoTWDir.c_str()); if (!p) return; if (!*p) return; eqsl_download_name = p; Fl::awake(verify_eqsl); }
65,223
C++
.cxx
2,153
27.755225
101
0.669864
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,248
calendar.cxx
w1hkj_fldigi/src/logbook/calendar.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <cstring> #include <cstdio> #include <cstdlib> #include <FL/Fl.H> #include <FL/Fl_Pixmap.H> #include "pixmaps.h" #include "calendar.h" void popcal_cb (Fl_Widget *v, long d); static void fl_calendar_button_cb (Fl_Button *a, void *b) { long j=0; Fl_Calendar *c = (Fl_Calendar *)b; Fl_Button *sb; int numdays = c->daysinmonth () + 1; for (int i=1; i < numdays; i++) { sb = c->day_button(i); sb->color (52); if (a == sb) { c->Day (i); j = i; sb->color (sb->selection_color()); if (c->target) { ((Fl_Input2 *)(c->target))->value(c->szDate(c->calfmt)); (c->target)->redraw(); } } } c->redraw(); c->do_callback(c, j); } void Fl_Calendar_Base::setTarget (Fl_Widget *tgt) { target = tgt; } Fl_Calendar_Base::Fl_Calendar_Base (int x, int y, int w, int h, const char *l) : Fl_Group (x, y, w, h, l), Date () { int i; for (i = 0; i<(7*6); i++) { days[i] = new Fl_Button ((w/7)*(i%7) + x, (h/6)*(i/7) + y, (w/7), (h/6)); days[i]->down_box (FL_THIN_DOWN_BOX); days[i]->labelsize (10); days[i]->box (FL_THIN_UP_BOX); days[i]->color (52); days[i]->callback ((Fl_Callback*)&fl_calendar_button_cb, (void *)this); } calfmt = 0; } void Fl_Calendar_Base::csize (int cx, int cy, int cw, int ch) { int i; for (i = 0; i<(7*6); i++) { days[i]->resize ((cw/7)*(i%7) + cx, (ch/6)*(i/7) + cy, (cw/7), (ch/6)); } } void Fl_Calendar_Base::update () { int dow = dayofweek (Year(), Month(), 1); int dim = daysinmonth (Month(), isleapyear (Year())); int i; for (i=0; i<dow; i++) { days[i]->hide (); } for (i=(dim+dow); i<(6*7); i++) { days[i]->hide (); } for (i=dow; i<(dim+dow); i++) { char t[12]; snprintf (t, sizeof(t), "%d", (i-dow+1)); days[i]->label (strdup(t)); days[i]->color (52); if ((i-dow+1) == Day()) days[i]->color (selection_color()); days[i]->show (); } } Fl_Button * Fl_Calendar_Base::day_button (int i) { if ((i > 0) && (i <= daysinmonth ())) return days[i + dayofweek (Year(), Month(), 1) - 1]; return 0; } static void fl_calendar_prv_month_cb (Fl_Button *, void *b) { Fl_Calendar *c = (Fl_Calendar *)b; c->previous_month (); c->do_callback(c, (long)0); } static void fl_calendar_nxt_month_cb (Fl_Button *, void *b) { Fl_Calendar *c = (Fl_Calendar *)b; c->next_month (); c->do_callback(c, (long)0); } static void fl_calendar_prv_year_cb (Fl_Button *, void *b) { Fl_Calendar *c = (Fl_Calendar *)b; c->previous_year (); c->do_callback(c, (long)0); } static void fl_calendar_nxt_year_cb (Fl_Button *, void *b) { Fl_Calendar *c = (Fl_Calendar *)b; c->next_year (); c->do_callback(c, (long)0); } Fl_Calendar::Fl_Calendar (int x, int y, int w, int h, const char *l) : Fl_Calendar_Base (x, y, w, h, l) { int i, bw; for (i = 0; i<7; i++) { // weekdays[i] = new Fl_Button ((w/7)*(i%7) + x, weekdays[i] = new Fl_Box ((w/7)*(i%7) + x, (h/8)*((i/7)+1) + y, (w/7), (h/8)); weekdays[i]->box (FL_THIN_UP_BOX); weekdays[i]->labelsize (10); weekdays[i]->color (52); } weekdays[SUNDAY]->label ("S"); weekdays[MONDAY]->label ("M"); weekdays[TUESDAY]->label ("T"); weekdays[WEDNESDAY]->label ("W"); weekdays[THURSDAY]->label ("T"); weekdays[FRIDAY]->label ("F"); weekdays[SATURDAY]->label ("S"); bw = w/10 < 16 ? 16 : w/10; prv_year = new Fl_Button (x, y, bw, (h/8), "@<<"); prv_year->box (FL_THIN_UP_BOX); prv_year->labeltype (FL_SYMBOL_LABEL); prv_year->labelsize (10); prv_year->down_box (FL_THIN_DOWN_BOX); prv_year->callback ((Fl_Callback*)&fl_calendar_prv_year_cb, (void *)this); prv_month = new Fl_Button (x + bw, y, bw, (h/8), "@<"); prv_month->box (FL_THIN_UP_BOX); prv_month->labeltype (FL_SYMBOL_LABEL); prv_month->labelsize (10); prv_month->down_box (FL_THIN_DOWN_BOX); prv_month->callback ((Fl_Callback*)&fl_calendar_prv_month_cb, (void *)this); nxt_month = new Fl_Button (x + w - 2*bw, y, bw, (h/8), "@>"); nxt_month->box (FL_THIN_UP_BOX); nxt_month->labeltype (FL_SYMBOL_LABEL); nxt_month->labelsize (10); nxt_month->down_box (FL_THIN_DOWN_BOX); nxt_month->callback ((Fl_Callback*)&fl_calendar_nxt_month_cb, (void *)this); nxt_year = new Fl_Button (x + w - bw, y, bw, (h/8), "@>>"); nxt_year->box (FL_THIN_UP_BOX); nxt_year->labeltype (FL_SYMBOL_LABEL); nxt_year->labelsize (10); nxt_year->down_box (FL_THIN_DOWN_BOX); nxt_year->callback ((Fl_Callback*)&fl_calendar_nxt_year_cb, (void *)this); // caption = new Fl_Button (x + (w/10)*2, y, (6*w/10), (h/8)); caption = new Fl_Box (x + 2*bw, y, w - 4*bw, (h/8)); caption->box (FL_THIN_UP_BOX); caption->labeltype (FL_SYMBOL_LABEL); caption->labelfont (1); if (bw < 20) caption->labelsize (9); else caption->labelsize (11); // caption->down_box (FL_THIN_DOWN_BOX); Fl_Calendar_Base::csize (x, y + (2*h/8), w, (6*h/8)); target = 0; update (); } void Fl_Calendar::csize (int cx, int cy, int cw, int ch) { int i; for (i = 0; i<7; i++) { // weekdays[i] = new Fl_Button ((cw/7)*(i%7) + cx, weekdays[i] = new Fl_Box ((cw/7)*(i%7) + cx, (ch/8)*((i/7)+1) + cy, (cw/7), (ch/8)); } prv_month->resize (cx + (cw/10), cy, (cw/10), (ch/8)); nxt_month->resize (cx + (cw/10)*8, cy, (cw/10), (ch/8)); prv_year->resize (cx, cy, (cw/10), (ch/8)); nxt_year->resize (cx + (cw/10)*9, cy, (cw/10), (ch/8)); caption->resize (cx + (cw/10)*2, cy, (cw/10)*6, (ch/8)); Fl_Calendar_Base::csize (cx, cy + (2*ch/8), cw, (6*ch/8)); } void Fl_Calendar::update () { int dow = dayofweek (Year(), Month(), 1); int dim = daysinmonth (Month(), isleapyear (Year())); int i; for (i=dow; i<(dim+dow); i++) { char t[12]; snprintf (t, sizeof(t), "%d", (i-dow+1)); days[i]->label (strdup(t)); } char tmp[32]; snprintf (tmp, sizeof(tmp), "%s %d", month_name[Month()-1], Year()); Fl_Calendar_Base::update (); if (caption->label ()) free ((void *) caption->label ()); caption->label (strdup(tmp)); redraw (); } void Fl_Calendar::today () { Date::today(); update (); } void Fl_Calendar::previous_month () { Date::previous_month(); update (); } void Fl_Calendar::next_month () { Date::next_month(); update (); } void Fl_Calendar::previous_year () { Date::previous_year(); update (); } void Fl_Calendar::next_year () { Date::next_year(); update (); } void Fl_Calendar::setDate(int m, int d, int y) { Date::setDate(m,d,y); } int Fl_Calendar::handle (int event) { int m, d, y, o, md; switch (event) { case FL_FOCUS: case FL_UNFOCUS: return 1; case FL_KEYBOARD: m = Month (); d = Day (); y = Year (); switch(Fl::event_key ()) { case FL_Enter: do_callback(this, d); return 1; break; case FL_Up: o = -7; break; case FL_Down: o = 7; break; case FL_Right: o = 1; break; case FL_Left: o = -1; break; case FL_Page_Up: previous_month (); return 1; case FL_Page_Down: next_month (); return 1; default: return Fl_Group::handle (event); } if (datevalid (y, m, d + o)) setDate (m, d + o, y); else { if (o < 0) { previous_month (); m = Month (); y = Year (); md = daysinmonth (m, isleapyear (y)); d = d + o + md; setDate (m, d, y); } else { md = daysinmonth (m, isleapyear (y)); next_month (); m = Month (); y = Year (); d = d + o - md; setDate (m, d, y); } } return 1; } return Fl_Group::handle (event); } // Popup Calendar class Fl_PopCal::Fl_PopCal (int X, int Y, int W, int H, Fl_Input2 * tgt) : Fl_Window (X, Y, W, H, "") { target = tgt; clear_border(); box(FL_UP_BOX); // popcal = new Fl_Calendar(2, 2); popcal = new Fl_Calendar(2, 2, W-4, H-4); popcal->callback ( (Fl_Callback*)popcal_cb); end(); } Fl_PopCal::~Fl_PopCal () { } void Fl_PopCal::popcalfmt (int i) { popcalfmt_ = i; } int Fl_PopCal::popcalfmt () { return popcalfmt_; } void Fl_PopCal::setDate (int m, int d, int y) { popcal->setDate (m,d,y); popcal->update(); } int Fl_PopCal::handle(int event) { int ex = Fl::event_x_root(), ey = Fl::event_y_root(); if (event == FL_PUSH) { if ( ex < x() || ex > (x() + w()) || ey < y() || ey > (y() + h()) ) { pophide(); return 1; } } if (Fl_Group::handle(event)) return 1; return 0; } void Fl_PopCal::popposition (int x, int y) { position (x, y); } void Fl_PopCal::popshow () { show (); Fl::grab(this); } void Fl_PopCal::pophide () { hide (); Fl::release(); } void Fl_PopCal::popcal_cb_i (Fl_Widget *v, long d) { int ey = Fl::event_y_root(); Fl_PopCal *me = (Fl_PopCal *)(v->parent()); Fl_Input2 *tgt = me->target; if (ey > me->y() + 40) { if (d && tgt) tgt->value (((Fl_Calendar *)v)->szDate (me->popcalfmt_)); me->pophide(); } return; } void popcal_cb (Fl_Widget *v, long d) { ((Fl_PopCal *)(v))->popcal_cb_i (v, d); return; } void Fl_DateInput::fl_popcal() { Fl_Widget *who = this, *parent; int xpos = who->x(), ypos = who->h() + who->y(); int w = who->w(), h; int m = 0, d = 0, y = 0; w = w < 140 ? 140 : w; w = w - (w % 7); h = 8*(w/7); w += 4; h += 4; parent = who; while (parent) { who = parent; parent = parent->parent(); if (parent == 0) { xpos += who->x(); ypos += who->y(); } } if (!Cal) // Cal = new Fl_PopCal(xpos, ypos, 7*20+4, 8*20+4, Input); Cal = new Fl_PopCal(xpos, ypos, w, h, Input); else Cal->popposition(xpos, ypos); if (popcalfmt_ < 3) { switch (popcalfmt_) { case 0: case 1: sscanf(Input->value(), "%d/%d/%d", &m, &d, &y); break; case 2: default: sscanf(Input->value(),"%4d%2d%2d", &y, &m, &d); break; } if (y < 10) y+=2000; if (y < 100) y+=1900; Cal->setDate (m,d,y); } Cal->popcalfmt (popcalfmt_); Cal->popshow(); return; } void btnDateInput_cb (Fl_Widget *v, void *d) { ((Fl_DateInput *)(v->parent()))->fl_popcal (); return; } Fl_DateInput::Fl_DateInput (int X,int Y,int W,int H, const char *L) : Fl_Group (X, Y, W, H, 0) { Btn = new Fl_Button (X + W - H, Y, H, H); (new Fl_Pixmap (time_icon))->label (Btn); Btn->callback ((Fl_Callback *)btnDateInput_cb, 0); Input = new Fl_Input2 (X, Y, W-H, H, L); popcalfmt_ = 0; Cal = 0; end(); } void Fl_DateInput::align (Fl_Align how) { Input->align(how); } // DateInput value is contained in the Input widget void Fl_DateInput::value( const char *s ) { Input->value (s); } const char *Fl_DateInput::value() { return (Input->value ()); } void Fl_DateInput::textfont(int tf) { Input->textfont (tf); } void Fl_DateInput::textsize(int sz) { Input->textsize (sz); } void Fl_DateInput::textcolor(Fl_Color c) { Input->textcolor(c); } void Fl_DateInput::color(Fl_Color c) { Input->color(c); } void Fl_DateInput::labelfont(int fnt) { Input->labelfont(fnt); } void Fl_DateInput::labelsize(int size) { Input->labelsize(size); } void Fl_DateInput::labelcolor(int clr) { Input->labelcolor(clr); } void Fl_DateInput::format (int fmt) { switch (fmt) { case 0: case 1: case 2: case 3: case 4: popcalfmt_ = fmt; break; default : popcalfmt_ = 0; } } void Fl_DateInput::take_focus() { Input->take_focus(); }
12,695
C++
.cxx
532
20.161654
80
0.559187
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,249
county_lists.cxx
w1hkj_fldigi/src/logbook/county_lists.cxx
// ---------------------------------------------------------------------------- // county lists // // Copyright (C) 2006-2010 // Dave Freese, W1HKJ // Copyright (C) 2008-2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <string> #include "counties.h" //std::string strSQSO const char *szSQSO = "\ State/Province, ST/PR, County/City/District, CCD\n\ NIL,--,none\n\ Alaska,AK,AK1st (SE),SE\n\ ,AK,AK2nd (NW),NW\n\ ,AK,AK3rd (SC),SC\n\ ,AK,AK4th (C),C\n\ Alberta,AB,MD of Acadia No. 34,ACAD\n\ ,AB,Athabasca County,ATHA\n\ ,AB,County of Barrhead No. 11,BARR\n\ ,AB,Beaver County,BEAV\n\ ,AB,Big Lakes County,BIGL\n\ ,AB,MD of Bighorn No. 8,BIGH\n\ ,AB,Birch Hills County,BIRC\n\ ,AB,MD of Bonnyville No. 87,BONN\n\ ,AB,Brazeau County,BRAZ\n\ ,AB,Camrose County,CAMR\n\ ,AB,Cardston County,CARD\n\ ,AB,Clear Hills County,CLHI\n\ ,AB,Clearwater County,CLWA\n\ ,AB,Cypress County,CYPR\n\ ,AB,MD of Fairview No. 136,FAIR\n\ ,AB,Flagstaff County,FLAG\n\ ,AB,Foothills County,FOOT\n\ ,AB,County of Forty Mile No. 8,FORT\n\ ,AB,County of Grande Prairie No. 1,GRAN\n\ ,AB,MD of Greenview No. 16,GREE\n\ ,AB,Kneehill County,KNEE\n\ ,AB,Lac Ste. Anne County,LACS\n\ ,AB,Lacombe County,LACO\n\ ,AB,Lamont County,LAMO\n\ ,AB,Leduc County,LEDU\n\ ,AB,MD of Lesser Slave River No. 124,LESS\n\ ,AB,Lethbridge County,LETH\n\ ,AB,County of Minburn No. 27,MINB\n\ ,AB,Mountain View County,MOUN\n\ ,AB,County of Newell,NEWE\n\ ,AB,County of Northern Lights,NOLI\n\ ,AB,Northern Sunrise County,NOSU\n\ ,AB,MD of Opportunity No. 17,OPPO\n\ ,AB,County of Paintearth No. 18,PAIN\n\ ,AB,Parkland County,PARK\n\ ,AB,MD of Peace No. 135,PEAC\n\ ,AB,MD of Pincher Creek No. 9,PINC\n\ ,AB,Ponoka County,PONO\n\ ,AB,MD of Provost No. 52,PROV\n\ ,AB,MD of Ranchland No. 66,RANC\n\ ,AB,Red Deer County,RDDR\n\ ,AB,Rocky View County,ROCK\n\ ,AB,Saddle Hills County,SADD\n\ ,AB,Smoky Lake County,SMLA\n\ ,AB,MD of Smoky River No. 130,SMRI\n\ ,AB,MD of Spirit River No. 133,SPRI\n\ ,AB,County of St. Paul No. 19,STPA\n\ ,AB,Starland County,STAR\n\ ,AB,County of Stettler No. 6,STET\n\ ,AB,Sturgeon County,STUR\n\ ,AB,MD of Taber,TABR\n\ ,AB,Thorhild County,THOR\n\ ,AB,County of Two Hills No. 21,TWHI\n\ ,AB,County of Vermilion River,VERM\n\ ,AB,Vulcan County,VULC\n\ ,AB,MD of Wainwright No. 61,WAIN\n\ ,AB,County of Warner No. 5,WARN\n\ ,AB,Westlock County,WEST\n\ ,AB,County of Wetaskiwin No. 10,WETA\n\ ,AB,Wheatland County,WHEA\n\ ,AB,MD of Willow Creek No. 26,WILL\n\ ,AB,Woodlands County,WOOD\n\ ,AB,Yellowhead County,YELL\n\ Alabama,AL,Autauga,AUTA\n\ ,AL,Baldwin,BALD\n\ ,AL,Barbour,BARB\n\ ,AL,Bibb,BIBB\n\ ,AL,Blount,BLOU\n\ ,AL,Bullock,BULL\n\ ,AL,Butler,BUTL\n\ ,AL,Calhoun,CHOU\n\ ,AL,Chambers,CHMB\n\ ,AL,Cherokee,CKEE\n\ ,AL,Chilton,CHIL\n\ ,AL,Choctaw,CHOC\n\ ,AL,Clarke,CLRK\n\ ,AL,Clay,CLAY\n\ ,AL,Cleburne,CLEB\n\ ,AL,Coffee,COFF\n\ ,AL,Colbert,COLB\n\ ,AL,Conecuh,CONE\n\ ,AL,Coosa,COOS\n\ ,AL,Covington,COVI\n\ ,AL,Crenshaw,CREN\n\ ,AL,Cullman,CULM\n\ ,AL,Dale,DALE\n\ ,AL,Dallas,DLLS\n\ ,AL,DeKalb,DKLB\n\ ,AL,Elmore,ELMO\n\ ,AL,Escambia,ESCA\n\ ,AL,Etowah,ETOW\n\ ,AL,Fayette,FAYE\n\ ,AL,Franklin,FRNK\n\ ,AL,Geneva,GENE\n\ ,AL,Greene,GREE\n\ ,AL,Hale,HALE\n\ ,AL,Henry,HNRY\n\ ,AL,Houston,HOUS\n\ ,AL,Jackson,JKSN\n\ ,AL,Jefferson,JEFF\n\ ,AL,Lamar,LAMA\n\ ,AL,Lauderdale,LAUD\n\ ,AL,Lawrence,LAWR\n\ ,AL,Lee,LEE\n\ ,AL,Limestone,LIME\n\ ,AL,Lowndes,LOWN\n\ ,AL,Macon,MACO\n\ ,AL,Madison,MDSN\n\ ,AL,Marengo,MRGO\n\ ,AL,Marion,MARI\n\ ,AL,Marshall,MRSH\n\ ,AL,Mobile,MOBI\n\ ,AL,Monroe,MNRO\n\ ,AL,Montgomery,MGMY\n\ ,AL,Morgan,MORG\n\ ,AL,Perry,PERR\n\ ,AL,Pickens,PICK\n\ ,AL,Pike,PIKE\n\ ,AL,Randolph,RAND\n\ ,AL,Russell,RSSL\n\ ,AL,Shelby,SHEL\n\ ,AL,St. Clair,SCLR\n\ ,AL,Sumter,SUMT\n\ ,AL,Talladega,TDEG\n\ ,AL,Tallapoosa,TPOO\n\ ,AL,Tuscaloosa,TUSC\n\ ,AL,Walker,WLKR\n\ ,AL,Washington,WASH\n\ ,AL,Wilcox,WLCX\n\ ,AL,Winston,WINS\n\ Arizona,AZ,Apache,APH\n\ ,AZ,Cochise,CHS\n\ ,AZ,Coconino,CNO\n\ ,AZ,Gila,GLA\n\ ,AZ,Graham,GHM\n\ ,AZ,Greenlee,GLE\n\ ,AZ,La Paz,LPZ\n\ ,AZ,Maricopa,MCP\n\ ,AZ,Mohave,MHV\n\ ,AZ,Navajo,NVO\n\ ,AZ,Pima,PMA\n\ ,AZ,Pinal,PNL\n\ ,AZ,Santa Cruz,SCZ\n\ ,AZ,Yavapai,YVP\n\ ,AZ,Yuma,YMA\n\ Arkansas,AR,Arkansas,ARKA\n\ ,AR,Ashley,ASHL\n\ ,AR,Baxter,BAXT\n\ ,AR,Benton,BENT\n\ ,AR,Boone,BOON\n\ ,AR,Bradley,BRAD\n\ ,AR,Calhoun,CALH\n\ ,AR,Carroll,CARR\n\ ,AR,Chicot,CHIC\n\ ,AR,Clark,CLRK\n\ ,AR,Clay,CLAY\n\ ,AR,Cleburne,CLEB\n\ ,AR,Cleveland,CLEV\n\ ,AR,Columbia,COLU\n\ ,AR,Conway,CONW\n\ ,AR,Craighead,CRAG\n\ ,AR,Crawford,CRAW\n\ ,AR,Crittenden,CRIT\n\ ,AR,Cross,CROS\n\ ,AR,Dallas,DALL\n\ ,AR,Desha,DESH\n\ ,AR,Drew,DREW\n\ ,AR,Faulkner,FAUL\n\ ,AR,Franklin,FRNK\n\ ,AR,Fulton,FULT\n\ ,AR,Garland,GARL\n\ ,AR,Grant,GRNT\n\ ,AR,Greene,GREN\n\ ,AR,Hempstead,HEMP\n\ ,AR,Hot Spring,HSPR\n\ ,AR,Howard,HOWA\n\ ,AR,Independence,INDE\n\ ,AR,Izard,IZRD\n\ ,AR,Jackson,JACK\n\ ,AR,Jefferson,JEFF\n\ ,AR,Johnson,JOHN\n\ ,AR,Lafayette,LAFA\n\ ,AR,Lawrence,LAWR\n\ ,AR,Lee,LEE\n\ ,AR,Lincoln,LINC\n\ ,AR,Little River,LRVR\n\ ,AR,Logan,LOGN\n\ ,AR,Lonoke,LONO\n\ ,AR,Madison,MADI\n\ ,AR,Marion,MARI\n\ ,AR,Miller,MILL\n\ ,AR,Mississippi,MISS\n\ ,AR,Monroe,MONR\n\ ,AR,Montgomery,MTGY\n\ ,AR,Nevada,NEVA\n\ ,AR,Newton,NEWT\n\ ,AR,Ouachita,OUAC\n\ ,AR,Perry,PERR\n\ ,AR,Phillips,PHIL\n\ ,AR,Pike,PIKE\n\ ,AR,Poinsett,POIN\n\ ,AR,Polk,POLK\n\ ,AR,Pope,POPE\n\ ,AR,Prairie,PRAR\n\ ,AR,Pulaski,PULA\n\ ,AR,Randolph,RAND\n\ ,AR,Saline,SALI\n\ ,AR,Scott,SCOT\n\ ,AR,Searcy,SRCY\n\ ,AR,Sebastian,SEBA\n\ ,AR,Sevier,SEVR\n\ ,AR,Sharp,SHRP\n\ ,AR,St. Francis,STFR\n\ ,AR,Stone,STON\n\ ,AR,Union,UNIO\n\ ,AR,Van Buren,VBRN\n\ ,AR,Washington,WASH\n\ ,AR,White,WHIE\n\ ,AR,Woodruff,WOOD\n\ ,AR,Yell,YELL\n\ British Columbia,BC,Abbotsford,ABF\n\ ,BC,Burnaby North-Seymour,BNS\n\ ,BC,Burnaby South,BUS\n\ ,BC,Cariboo-Prince George,CPG\n\ ,BC,Central Okanagan-Similkameen-Nicola,CSN\n\ ,BC,Chilliwack-Hope,CHP\n\ ,BC,Cloverdale-Langley City,CLC\n\ ,BC,Coquitlam-Port Coquitlam,CPC\n\ ,BC,Courtenay-Alberni,COA\n\ ,BC,Cowichan-Malahat-Langford,CML\n\ ,BC,Delta,DEL\n\ ,BC,Esquimalt-Saanich-Sooke,ESQ\n\ ,BC,Fleetwood-Port Kells,FPK\n\ ,BC,Kamloops-Thompson-Cariboo,KTC\n\ ,BC,Kelowna-Lake Country,KEL\n\ ,BC,Kootenay-Columbia,KOC\n\ ,BC,Langley-Aldergrove,LAA\n\ ,BC,Mission-Matsqui-Fraser Canyon,MMF\n\ ,BC,Nanaimo-Ladysmith,NAL\n\ ,BC,New Westminster-Burnaby,NWB\n\ ,BC,North Island-Powell River,NPR\n\ ,BC,North Okanagan-Shuswap,NOS\n\ ,BC,North Vancouver,NVA\n\ ,BC,Pitt Meadows-Maple Ridge,PMM\n\ ,BC,Port Moody-Coquitlam,PMC\n\ ,BC,Prince George-Peace River-Northern Rockies,PPN\n\ ,BC,Richmond Center,RIC\n\ ,BC,Saanich-Gulf Islands,SGI\n\ ,BC,Skeena-Bulkley Valley,SBV\n\ ,BC,South Okanagan-West Kootenay,SWK\n\ ,BC,South Surrey-White Rock,SWR\n\ ,BC,Steveston-Richmond East,STR\n\ ,BC,Surrey Centre,SUC\n\ ,BC,Surrey-Newton,SUN\n\ ,BC,Vancouver Centre,VAC\n\ ,BC,Vancouver East,VAE\n\ ,BC,Vancouver Kingsway,VAK\n\ ,BC,Vancouver Quadra,VAQ\n\ ,BC,Vancouver South,VAS\n\ ,BC,Vancouver-Granville,VAG\n\ ,BC,Victoria,VIC\n\ ,BC,West Vanc,WVS\n\ California,CA,Alameda,ALAM\n\ ,CA,Alpine,ALPI\n\ ,CA,Amador,AMAD\n\ ,CA,Butte,BUTT\n\ ,CA,Calaveras,CALA\n\ ,CA,Colusa,COLU\n\ ,CA,Contra Costa,CCOS\n\ ,CA,Del Norte,DELN\n\ ,CA,El Dorado,ELDO\n\ ,CA,Fresno,FRES\n\ ,CA,Glenn,GLEN\n\ ,CA,Humboldt,HUMB\n\ ,CA,Imperial,IMPE\n\ ,CA,Inyo,INYO\n\ ,CA,Kern,KERN\n\ ,CA,Kings,KING\n\ ,CA,Lake,LAKE\n\ ,CA,Lassen,LASS\n\ ,CA,Los Angeles,LANG\n\ ,CA,Madera,MADE\n\ ,CA,Marin,MARN\n\ ,CA,Mariposa,MARP\n\ ,CA,Mendocino,MEND\n\ ,CA,Merced,MERC\n\ ,CA,Modoc,MODO\n\ ,CA,Mono,MONO\n\ ,CA,Monterey,MONT\n\ ,CA,Napa,NAPA\n\ ,CA,Nevada,NEVA\n\ ,CA,Orange,ORAN\n\ ,CA,Placer,PLAC\n\ ,CA,Plumas,PLUM\n\ ,CA,Riverside,RIVE\n\ ,CA,Sacramento,SACR\n\ ,CA,San Benito,SBEN\n\ ,CA,San Bernardino,SBER\n\ ,CA,San Diego,SDIE\n\ ,CA,San Francisco,SFRA\n\ ,CA,San Joaquin,SJOA\n\ ,CA,San Luis Obispo,SLUI\n\ ,CA,San Mateo,SMAT\n\ ,CA,Santa Barbara,SBAR\n\ ,CA,Santa Clara,SCLA\n\ ,CA,Santa Cruz,SCRU\n\ ,CA,Shasta,SHAS\n\ ,CA,Sierra,SIER\n\ ,CA,Siskiyou,SISK\n\ ,CA,Solano,SOLA\n\ ,CA,Sonoma,SONO\n\ ,CA,Stanislaus,STAN\n\ ,CA,Sutter,SUTT\n\ ,CA,Tehama,TEHA\n\ ,CA,Trinity,TRIN\n\ ,CA,Tulare,TULA\n\ ,CA,Tuolumne,TUOL\n\ ,CA,Ventura,VENT\n\ ,CA,Yolo,YOLO\n\ ,CA,Yuba,YUBA\n\ Colorado,CO,Adams,ADA\n\ ,CO,Alamosa,ALA\n\ ,CO,Arapahoe,ARA\n\ ,CO,Archuleta,ARC\n\ ,CO,Baca,BAC\n\ ,CO,Bent,BEN\n\ ,CO,Boulder,BOU\n\ ,CO,Broomfield,BRO\n\ ,CO,Chaffee,CHA\n\ ,CO,Cheyenne,CHE\n\ ,CO,Clear Creek,CLC\n\ ,CO,Conejos,CON\n\ ,CO,Costilla,COS\n\ ,CO,Crowley,CRO\n\ ,CO,Custer,CUS\n\ ,CO,Delta,DEL\n\ ,CO,Denver,DEN\n\ ,CO,Dolores,DOL\n\ ,CO,Douglas,DOU\n\ ,CO,Eagle,EAG\n\ ,CO,El Paso,ELP\n\ ,CO,Elbert,ELB\n\ ,CO,Fremont,FRE\n\ ,CO,Garfield,GAR\n\ ,CO,Gilpin,GIL\n\ ,CO,Grand,GRA\n\ ,CO,Gunnison,GUN\n\ ,CO,Hinsdale,HIN\n\ ,CO,Huerfano,HUE\n\ ,CO,Jackson,JAC\n\ ,CO,Jefferson,JEF\n\ ,CO,Kiowa,KIO\n\ ,CO,Kit Carson,KIC\n\ ,CO,La Plata,LAP\n\ ,CO,Lake,LAK\n\ ,CO,Larimer,LAR\n\ ,CO,Las Animas,LAA\n\ ,CO,Lincoln,LIN\n\ ,CO,Logan,LOG\n\ ,CO,Mesa,MES\n\ ,CO,Mineral,MIN\n\ ,CO,Moffat,MOF\n\ ,CO,Montezuma,MON\n\ ,CO,Montrose,MOT\n\ ,CO,Morgan,MOR\n\ ,CO,Otero,OTE\n\ ,CO,Ouray,OUR\n\ ,CO,Park,PAR\n\ ,CO,Phillips,PHI\n\ ,CO,Pitkin,PIT\n\ ,CO,Prowers,PRO\n\ ,CO,Pueblo,PUE\n\ ,CO,Rio Blanco,RIB\n\ ,CO,Rio Grande,RIG\n\ ,CO,Routt,ROU\n\ ,CO,Saguache,SAG\n\ ,CO,San Juan,SAJ\n\ ,CO,San Miguel,SAM\n\ ,CO,Sedgwick,SED\n\ ,CO,Summit,SUM\n\ ,CO,Teller,TEL\n\ ,CO,Washington,WAS\n\ ,CO,Weld,WEL\n\ ,CO,Yuma,YUM\n\ Connecticut,CT,Fairfield,FAI\n\ ,CT,Hartford,HAR\n\ ,CT,Litchfield,LIT\n\ ,CT,Middlesex,MIC\n\ ,CT,New Haven,NHV\n\ ,CT,New London,NLN\n\ ,CT,Tolland,TOL\n\ ,CT,Windham,WIN\n\ Delaware,DE,Kent,KDE\n\ ,DE,New Castle,NDE\n\ ,DE,Sussex,SDE\n\ Dist. of Col.,DC,District of Columbia,\n\ Florida,FL,ALACHUA,ALC\n\ ,FL,BAKER,BAK\n\ ,FL,BAY,BAY\n\ ,FL,BRADFORD,BRA\n\ ,FL,BREVARD,BRE\n\ ,FL,BROWARD,BRO\n\ ,FL,CALHOUN,CAH\n\ ,FL,CHARLOTTE,CHA\n\ ,FL,CITRUS,CIT\n\ ,FL,CLAY,CLA\n\ ,FL,COLLIER,CLR\n\ ,FL,COLUMBIA,CLM\n\ ,FL,MIAMI-DADE,DAD\n\ ,FL,DESOTO,DES\n\ ,FL,DIXIE,DIX\n\ ,FL,DUVAL,DUV\n\ ,FL,ESCAMBIA,ESC\n\ ,FL,FLAGLER,FLG\n\ ,FL,FRANKLIN,FRA\n\ ,FL,GADSDEN,GAD\n\ ,FL,GILCHRIST,GIL\n\ ,FL,GLADES,GLA\n\ ,FL,GULF,GUL\n\ ,FL,HAMILTON,HAM\n\ ,FL,HARDEE,HAR\n\ ,FL,HENDRY,HEN\n\ ,FL,HERNANDO,HER\n\ ,FL,HIGHLANDS,HIG\n\ ,FL,HILLSBOROUGH,HIL\n\ ,FL,HOLMES,HOL\n\ ,FL,INDIAN RIVER,IDR\n\ ,FL,JACKSON,JAC\n\ ,FL,JEFFERSON,JEF\n\ ,FL,LAFAYETTE,LAF\n\ ,FL,LAKE,LAK\n\ ,FL,LEE,LEE\n\ ,FL,LEON,LEO\n\ ,FL,LEVY,LEV\n\ ,FL,LIBERTY,LIB\n\ ,FL,MADISON,MAD\n\ ,FL,MANATEE,MTE\n\ ,FL,MARION,MAO\n\ ,FL,MARTIN,MRT\n\ ,FL,MONROE,MON\n\ ,FL,NASSAU,NAS\n\ ,FL,OKALOOSA,OKA\n\ ,FL,OKEECHOBEE,OKE\n\ ,FL,ORANGE,ORA\n\ ,FL,OSCEOLA,OSC\n\ ,FL,PALM BEACH,PAL\n\ ,FL,PASCO,PAS\n\ ,FL,PINELLAS,PIN\n\ ,FL,POLK,POL\n\ ,FL,PUTNAM,PUT\n\ ,FL,SANTA ROSA,SAN\n\ ,FL,SARASOTA,SAR\n\ ,FL,SEMINOLE,SEM\n\ ,FL,ST. JOHNS,STJ\n\ ,FL,ST. LUCIE,STL\n\ ,FL,SUMTER,SUM\n\ ,FL,SUWANNEE,SUW\n\ ,FL,TAYLOR,TAY\n\ ,FL,UNION,UNI\n\ ,FL,VOLUSIA,VOL\n\ ,FL,WAKULLA,WAK\n\ ,FL,WALTON,WAL\n\ ,FL,WASHINGTON,WAG\n\ Georgia,GA,Appling,APPL\n\ ,GA,Atkinson,ATKN\n\ ,GA,Bacon,BACN\n\ ,GA,Baker,BAKR\n\ ,GA,Baldwin,BALD\n\ ,GA,Banks,BANK\n\ ,GA,Barrow,BARR\n\ ,GA,Bartow,BART\n\ ,GA,Ben Hill,BENH\n\ ,GA,Berrien,BERR\n\ ,GA,Bibb,BIBB\n\ ,GA,Bleckley,BLEC\n\ ,GA,Brantley,BRAN\n\ ,GA,Brooks,BROK\n\ ,GA,Bryan,BRYN\n\ ,GA,Bulloch,BULL\n\ ,GA,Burke,BURK\n\ ,GA,Butts,BUTT\n\ ,GA,Calhoun,CALH\n\ ,GA,Camden,CMDN\n\ ,GA,Candler,CAND\n\ ,GA,Carroll,CARR\n\ ,GA,Catoosa,CATO\n\ ,GA,Charlton,CHAR\n\ ,GA,Chatham,CHTM\n\ ,GA,Chattahoochee,CHAT\n\ ,GA,Chattooga,CHGA\n\ ,GA,Cherokee,CHER\n\ ,GA,Clarke,CLKE\n\ ,GA,Clay,CLAY\n\ ,GA,Clayton,CLTN\n\ ,GA,Clinch,CLCH\n\ ,GA,Cobb,COBB\n\ ,GA,Coffee,COFF\n\ ,GA,Colquitt,COLQ\n\ ,GA,Columbia,COLU\n\ ,GA,Cook,COOK\n\ ,GA,Coweta,COWE\n\ ,GA,Crawford,CRAW\n\ ,GA,Crisp,CRIS\n\ ,GA,Dade,DADE\n\ ,GA,Dawson,DAWS\n\ ,GA,Decatur,DECA\n\ ,GA,DeKalb,DKLB\n\ ,GA,Dodge,DODG\n\ ,GA,Dooly,DOOL\n\ ,GA,Dougherty,DHTY\n\ ,GA,Douglas,DOUG\n\ ,GA,Early,EARL\n\ ,GA,Echols,ECHO\n\ ,GA,Effingham,EFFI\n\ ,GA,Elbert,ELBE\n\ ,GA,Emanuel,EMAN\n\ ,GA,Evans,EVAN\n\ ,GA,Fannin,FANN\n\ ,GA,Fayette,FAYE\n\ ,GA,Floyd,FLOY\n\ ,GA,Forsyth,FORS\n\ ,GA,Franklin,FRAN\n\ ,GA,Fulton,FULT\n\ ,GA,Gilmer,GILM\n\ ,GA,Glascock,GLAS\n\ ,GA,Glynn,GLYN\n\ ,GA,Gordon,GORD\n\ ,GA,Grady,GRAD\n\ ,GA,Greene,GREE\n\ ,GA,Gwinnett,GWIN\n\ ,GA,Habersham,HABE\n\ ,GA,Hall,HALL\n\ ,GA,Hancock,HANC\n\ ,GA,Haralson,HARA\n\ ,GA,Harris,HARR\n\ ,GA,Hart,HART\n\ ,GA,Heard,HEAR\n\ ,GA,Henry,HNRY\n\ ,GA,Houston,HOUS\n\ ,GA,Irwin,IRWI\n\ ,GA,Jackson,JACK\n\ ,GA,Jasper,JASP\n\ ,GA,Jeff Davis,JFDA\n\ ,GA,Jefferson,JEFF\n\ ,GA,Jenkins,JENK\n\ ,GA,Johnson,JOHN\n\ ,GA,Jones,JONE\n\ ,GA,Lamar,LAMA\n\ ,GA,Lanier,LANI\n\ ,GA,Laurens,LAUR\n\ ,GA,Lee,LEE\n\ ,GA,Liberty,LIBE\n\ ,GA,Lincoln,LINC\n\ ,GA,Long,LONG\n\ ,GA,Lowndes,LOWN\n\ ,GA,Lumpkin,LUMP\n\ ,GA,McDuffie,MCDU\n\ ,GA,McIntosh,MCIN\n\ ,GA,Macon,MACO\n\ ,GA,Madison,MADI\n\ ,GA,Marion,MARI\n\ ,GA,Meriwether,MERI\n\ ,GA,Miller,MILL\n\ ,GA,Mitchell,MITC\n\ ,GA,Monroe,MNRO\n\ ,GA,Montgomery,MONT\n\ ,GA,Morgan,MORG\n\ ,GA,Murray,MURR\n\ ,GA,Muscogee,MUSC\n\ ,GA,Newton,NEWT\n\ ,GA,Oconee,OCON\n\ ,GA,Oglethorpe,OGLE\n\ ,GA,Paulding,PAUL\n\ ,GA,Peach,PEAC\n\ ,GA,Pickens,PICK\n\ ,GA,Pierce,PIER\n\ ,GA,Pike,PIKE\n\ ,GA,Polk,POLK\n\ ,GA,Pulaski,PULA\n\ ,GA,Putnam,PUTN\n\ ,GA,Quitman,QCIT\n\ ,GA,Rabun,RABU\n\ ,GA,Randolph,RAND\n\ ,GA,Richmond,RICH\n\ ,GA,Rockdale,ROCK\n\ ,GA,Schley,SCHL\n\ ,GA,Screven,SCRE\n\ ,GA,Seminole,SEMI\n\ ,GA,Spalding,SPAL\n\ ,GA,Stephens,STEP\n\ ,GA,Stewart,STWT\n\ ,GA,Sumter,SUMT\n\ ,GA,Talbot,TLBT\n\ ,GA,Taliaferro,TALI\n\ ,GA,Tattnall,TATT\n\ ,GA,Taylor,TAYL\n\ ,GA,Telfair,TELF\n\ ,GA,Terrell,TERR\n\ ,GA,Thomas,THOM\n\ ,GA,Tift,TIFT\n\ ,GA,Toombs,TOOM\n\ ,GA,Towns,TOWN\n\ ,GA,Treutlen,TREU\n\ ,GA,Troup,TROU\n\ ,GA,Turner,TURN\n\ ,GA,Twiggs,TWIG\n\ ,GA,Union,UNIO\n\ ,GA,Upson,UPSO\n\ ,GA,Walker,WLKR\n\ ,GA,Walton,WALT\n\ ,GA,Ware,WARE\n\ ,GA,Warren,WARR\n\ ,GA,Washington,WASH\n\ ,GA,Wayne,WAYN\n\ ,GA,Webster,WEBS\n\ ,GA,Wheeler,WHEE\n\ ,GA,White,WHIT\n\ ,GA,Whitfield,WFLD\n\ ,GA,Wilcox,WCOX\n\ ,GA,Wilkes,WILK\n\ ,GA,Wilkinson,WKSN\n\ ,GA,Worth,WORT\n\ Guam,GU,Guam,\n\ Hawaii,HI,Hawaii-HIL,HIL\n\ ,HI,Hawaii-KOH,KOH\n\ ,HI,Hawaii-KON,KON\n\ ,HI,Hawaii-VOL,VOL\n\ ,HI,Honolulu-HON,HON\n\ ,HI,Honolulu-LHN,LHN\n\ ,HI,Honolulu-PRL,PRL\n\ ,HI,Honolulu-WHN,WHN\n\ ,HI,Kalawao-KAL,KAL\n\ ,HI,Kauai-KAU,KAU\n\ ,HI,Kauai-NII,NII\n\ ,HI,Maui-LAN,LAN\n\ ,HI,Maui-MAU,MAU\n\ ,HI,Maui-MOL,MOL\n\ Idaho,ID,Ada,ADA\n\ ,ID,Adams,ADM\n\ ,ID,Bannock,BAN\n\ ,ID,Bear Lake,BEA\n\ ,ID,Benewah,BEN\n\ ,ID,Bingham,BIN\n\ ,ID,Blaine,BLA\n\ ,ID,Boise,BOI\n\ ,ID,Bonner,BNR\n\ ,ID,Bonneville,BNV\n\ ,ID,Boundary,BOU\n\ ,ID,Butte,BUT\n\ ,ID,Camas,CAM\n\ ,ID,Canyon,CAN\n\ ,ID,Caribou,CAR\n\ ,ID,Cassia,CAS\n\ ,ID,Clark,CLA\n\ ,ID,Clearwater,CLE\n\ ,ID,Custer,CUS\n\ ,ID,Elmore,ELM\n\ ,ID,Franklin,FRA\n\ ,ID,Fremont,FRE\n\ ,ID,Gem,GEM\n\ ,ID,Gooding,GOO\n\ ,ID,Idaho,IDA\n\ ,ID,Jefferson,JEF\n\ ,ID,Jerome,JER\n\ ,ID,Kootenai,KOO\n\ ,ID,Latah,LAT\n\ ,ID,Lemhi,LEM\n\ ,ID,Lewis,LEW\n\ ,ID,Lincoln,LIN\n\ ,ID,Madison,MAD\n\ ,ID,Minidoka,MIN\n\ ,ID,Nez Perce,NEZ\n\ ,ID,Oneida,ONE\n\ ,ID,Owyhee,OWY\n\ ,ID,Payette,PAY\n\ ,ID,Power,POW\n\ ,ID,Shoshone,SHO\n\ ,ID,Teton,TET\n\ ,ID,Twin Falls,TWI\n\ ,ID,Valley,VAL\n\ ,ID,Washington,WAS\n\ Illinois,IL,Adams,ADAM\n\ ,IL,Alexander,ALEX\n\ ,IL,Bond,BOND\n\ ,IL,Boone,BOON\n\ ,IL,Brown,BROW\n\ ,IL,Bureau,BURO\n\ ,IL,Calhoun,CALH\n\ ,IL,Carroll,CARR\n\ ,IL,Cass,CASS\n\ ,IL,Champaign,CHAM\n\ ,IL,Christian,CHRS\n\ ,IL,Clark,CLRK\n\ ,IL,Clay,CLAY\n\ ,IL,Clinton,CLNT\n\ ,IL,Coles,COLE\n\ ,IL,Cook,COOK\n\ ,IL,Crawford,CRAW\n\ ,IL,Cumberland,CUMB\n\ ,IL,DeWitt,DEWT\n\ ,IL,DeKalb,DEKA\n\ ,IL,Douglas,DOUG\n\ ,IL,DuPage,DUPG\n\ ,IL,Edgar,EDGR\n\ ,IL,Edwards,EDWA\n\ ,IL,Effingham,EFFG\n\ ,IL,Fayette,FAYE\n\ ,IL,Ford,FORD\n\ ,IL,Franklin,FRNK\n\ ,IL,Fulton,FULT\n\ ,IL,Gallatin,GALL\n\ ,IL,Greene,GREE\n\ ,IL,Grundy,GRUN\n\ ,IL,Hamilton,HAML\n\ ,IL,Hancock,HANC\n\ ,IL,Hardin,HARD\n\ ,IL,Henderson,HNDR\n\ ,IL,Henry,HENR\n\ ,IL,Iroquois,IROQ\n\ ,IL,Jackson,JACK\n\ ,IL,Jasper,JASP\n\ ,IL,Jefferson,JEFF\n\ ,IL,Jersey,JERS\n\ ,IL,JoDaviess,JODA\n\ ,IL,Johnson,JOHN\n\ ,IL,Kane,KANE\n\ ,IL,Kankakee,KANK\n\ ,IL,Kendall,KEND\n\ ,IL,Knox,KNOX\n\ ,IL,LaSalle,LASA\n\ ,IL,Lake,LAKE\n\ ,IL,Lawrence,LAWR\n\ ,IL,Lee,LEE\n\ ,IL,Livingston,LIVG\n\ ,IL,Logan,LOGN\n\ ,IL,Macon,MACN\n\ ,IL,Macoupin,MCPN\n\ ,IL,Madison,MADN\n\ ,IL,Marion,MARI\n\ ,IL,Marshall,MSHL\n\ ,IL,Mason,MASN\n\ ,IL,Massac,MSSC\n\ ,IL,McDonough,MCDN\n\ ,IL,McHenry,MCHE\n\ ,IL,McLean,MCLN\n\ ,IL,Menard,MNRD\n\ ,IL,Mercer,MRCR\n\ ,IL,Monroe,MNRO\n\ ,IL,Montgomery,MNTG\n\ ,IL,Morgan,MORG\n\ ,IL,Moultrie,MOUL\n\ ,IL,Ogle,OGLE\n\ ,IL,Peoria,PEOR\n\ ,IL,Perry,PERR\n\ ,IL,Piatt,PIAT\n\ ,IL,Pike,PIKE\n\ ,IL,Pope,POPE\n\ ,IL,Pulaski,PULA\n\ ,IL,Putnam,PUTN\n\ ,IL,Randolph,RAND\n\ ,IL,Richland,RICH\n\ ,IL,Rock Island,ROCK\n\ ,IL,Saline,SALI\n\ ,IL,Sangamon,SANG\n\ ,IL,Schuyler,SCHY\n\ ,IL,Scott,SCOT\n\ ,IL,Shelby,SHEL\n\ ,IL,St. Clair,SCLA\n\ ,IL,Stark,STAR\n\ ,IL,Stephenson,STEP\n\ ,IL,Tazewell,TAZW\n\ ,IL,Union,UNIO\n\ ,IL,Vermilion,VERM\n\ ,IL,Wabash,WABA\n\ ,IL,Warren,WARR\n\ ,IL,Washington,WASH\n\ ,IL,Wayne,WAYN\n\ ,IL,White,WHIT\n\ ,IL,Whiteside,WTSD\n\ ,IL,Will,WILL\n\ ,IL,Williamson,WMSN\n\ ,IL,Winnebago,WBGO\n\ ,IL,Woodford,WOOD\n\ Indiana,IN,Adams,INADA\n\ ,IN,Allen,INALL\n\ ,IN,Bartholomew,INBAR\n\ ,IN,Benton,INBEN\n\ ,IN,Blackford,INBLA\n\ ,IN,Boone,INBOO\n\ ,IN,Brown,INBRO\n\ ,IN,Carroll,INCAR\n\ ,IN,Cass,INCAS\n\ ,IN,Clark,INCLR\n\ ,IN,Clay,INCLY\n\ ,IN,Clinton,INCLI\n\ ,IN,Crawford,INCRA\n\ ,IN,Daviess,INDAV\n\ ,IN,De Kalb,INDEK\n\ ,IN,Dearborn,INDEA\n\ ,IN,Decatur,INDEC\n\ ,IN,Delaware,INDEL\n\ ,IN,Dubois,INDUB\n\ ,IN,Elkhart,INELK\n\ ,IN,Fayette,INFAY\n\ ,IN,Floyd,INFLO\n\ ,IN,Fountain,INFOU\n\ ,IN,Franklin,INFRA\n\ ,IN,Fulton,INFUL\n\ ,IN,Gibson,INGIB\n\ ,IN,Grant,INGRA\n\ ,IN,Greene,INGRE\n\ ,IN,Hamilton,INHAM\n\ ,IN,Hancock,INHAN\n\ ,IN,Harrison,INHAR\n\ ,IN,Hendricks,INHND\n\ ,IN,Henry,INHNR\n\ ,IN,Howard,INHOW\n\ ,IN,Huntington,INHUN\n\ ,IN,Jackson,INJAC\n\ ,IN,Jasper,INJAS\n\ ,IN,Jay,INJAY\n\ ,IN,Jefferson,INJEF\n\ ,IN,Jennings,INJEN\n\ ,IN,Johnson,INJOH\n\ ,IN,Knox,INKNO\n\ ,IN,Kosciusko,INKOS\n\ ,IN,La Porte,INLAP\n\ ,IN,Lagrange,INLAG\n\ ,IN,Lake,INLAK\n\ ,IN,Lawrence,INLAW\n\ ,IN,Madison,INMAD\n\ ,IN,Marion,INMRN\n\ ,IN,Marshall,INMRS\n\ ,IN,Martin,INMRT\n\ ,IN,Miami,INMIA\n\ ,IN,Monroe,INMNR\n\ ,IN,Montgomery,INMNT\n\ ,IN,Morgan,INMOR\n\ ,IN,Newton,INNEW\n\ ,IN,Noble,INNOB\n\ ,IN,Ohio,INOHI\n\ ,IN,Orange,INORA\n\ ,IN,Owen,INOWE\n\ ,IN,Parke,INPAR\n\ ,IN,Perry,INPER\n\ ,IN,Pike,INPIK\n\ ,IN,Porter,INPOR\n\ ,IN,Posey,INPOS\n\ ,IN,Pulaski,INPUL\n\ ,IN,Putnam,INPUT\n\ ,IN,Randolph,INRAN\n\ ,IN,Ripley,INRIP\n\ ,IN,Rush,INRUS\n\ ,IN,Scott,INSCO\n\ ,IN,Shelby,INSHE\n\ ,IN,Spencer,INSPE\n\ ,IN,St. Joseph,INSTJ\n\ ,IN,Starke,INSTA\n\ ,IN,Steuben,INSTE\n\ ,IN,Sullivan,INSUL\n\ ,IN,Switzerland,INSWI\n\ ,IN,Tippecanoe,INTPP\n\ ,IN,Tipton,INTPT\n\ ,IN,Union,INUNI\n\ ,IN,Vanderburgh,INVAN\n\ ,IN,Vermillion,INVER\n\ ,IN,Vigo,INVIG\n\ ,IN,Wabash,INWAB\n\ ,IN,Warren,INWRN\n\ ,IN,Warrick,INWRK\n\ ,IN,Washington,INWAS\n\ ,IN,Wayne,INWAY\n\ ,IN,Wells,INWEL\n\ ,IN,White,INWHT\n\ ,IN,Whitley,INWHL\n\ Iowa,IA,Adair,ADR\n\ ,IA,Adams,ADM\n\ ,IA,Allamakee,ALL\n\ ,IA,Appanoose,APP\n\ ,IA,Audubon,AUD\n\ ,IA,Benton,BEN\n\ ,IA,Black Hawk,BKH\n\ ,IA,Boone,BOO\n\ ,IA,Bremer,BRE\n\ ,IA,Buchanan,BUC\n\ ,IA,Buena Vista,BNV\n\ ,IA,Butler,BTL\n\ ,IA,Calhoun,CAL\n\ ,IA,Carroll,CAR\n\ ,IA,Cass,CAS\n\ ,IA,Cedar,CED\n\ ,IA,Cerro Gordo,CEG\n\ ,IA,Cherokee,CHE\n\ ,IA,Chickasaw,CHI\n\ ,IA,Clarke,CLR\n\ ,IA,Clay,CLA\n\ ,IA,Clayton,CLT\n\ ,IA,Clinton,CLN\n\ ,IA,Crawford,CRF\n\ ,IA,Dallas,DAL\n\ ,IA,Davis,DAV\n\ ,IA,Decatur,DEC\n\ ,IA,Delaware,DEL\n\ ,IA,Des Moines,DSM\n\ ,IA,Dickinson,DIC\n\ ,IA,Dubuque,DUB\n\ ,IA,Emmet,EMM\n\ ,IA,Fayette,FAY\n\ ,IA,Floyd,FLO\n\ ,IA,Franklin,FRA\n\ ,IA,Fremont,FRE\n\ ,IA,Greene,GRE\n\ ,IA,Grundy,GRU\n\ ,IA,Guthrie,GUT\n\ ,IA,Hamilton,HAM\n\ ,IA,Hancock,HAN\n\ ,IA,Hardin,HDN\n\ ,IA,Harrison,HRS\n\ ,IA,Henry,HEN\n\ ,IA,Howard,HOW\n\ ,IA,Humboldt,HUM\n\ ,IA,Ida,IDA\n\ ,IA,Iowa,IOW\n\ ,IA,Jackson,JAC\n\ ,IA,Jasper,JAS\n\ ,IA,Jefferson,JEF\n\ ,IA,Johnson,JOH\n\ ,IA,Jones,JON\n\ ,IA,Keokuk,KEO\n\ ,IA,Kossuth,KOS\n\ ,IA,Lee,LEE\n\ ,IA,Linn,LIN\n\ ,IA,Louisa,LOU\n\ ,IA,Lucas,LUC\n\ ,IA,Lyon,LYN\n\ ,IA,Madison,MAD\n\ ,IA,Mahaska,MAH\n\ ,IA,Marion,MRN\n\ ,IA,Marshall,MSL\n\ ,IA,Mills,MIL\n\ ,IA,Mitchell,MIT\n\ ,IA,Monona,MNA\n\ ,IA,Monroe,MOE\n\ ,IA,Montgomery,MTG\n\ ,IA,Muscatine,MUS\n\ ,IA,O'Brien,OBR\n\ ,IA,Osceola,OSC\n\ ,IA,Page,PAG\n\ ,IA,Palo Alto,PLA\n\ ,IA,Plymouth,PLY\n\ ,IA,Pocahontas,POC\n\ ,IA,Polk,POL\n\ ,IA,Pottawattamie,POT\n\ ,IA,Poweshiek,POW\n\ ,IA,Ringgold,RIN\n\ ,IA,Sac,SAC\n\ ,IA,Scott,SCO\n\ ,IA,Shelby,SHE\n\ ,IA,Sioux,SIO\n\ ,IA,Story,STR\n\ ,IA,Tama,TAM\n\ ,IA,Taylor,TAY\n\ ,IA,Union,UNI\n\ ,IA,Van Buren,VAN\n\ ,IA,Wapello,WAP\n\ ,IA,Warren,WAR\n\ ,IA,Washington,WAS\n\ ,IA,Wayne,WAY\n\ ,IA,Webster,WEB\n\ ,IA,Winnebago,WNB\n\ ,IA,Winneshiek,WNS\n\ ,IA,Woodbury,WOO\n\ ,IA,Worth,WOR\n\ ,IA,Wright,WRI\n\ Kansas,KS,Allen,ALL\n\ ,KS,Anderson,AND\n\ ,KS,Atchison,ATC\n\ ,KS,Barber,BAR\n\ ,KS,Barton,BRT\n\ ,KS,Bourbon,BOU\n\ ,KS,Brown,BRO\n\ ,KS,Butler,BUT\n\ ,KS,Chase,CHS\n\ ,KS,Chautauqua,CHT\n\ ,KS,Cherokee,CHE\n\ ,KS,Cheyenne,CHY\n\ ,KS,Clark,CLK\n\ ,KS,Clay,CLY\n\ ,KS,Cloud,CLO\n\ ,KS,Coffey,COF\n\ ,KS,Comanche,COM\n\ ,KS,Cowley,COW\n\ ,KS,Crawford,CRA\n\ ,KS,Decatur,DEC\n\ ,KS,Dickinson,DIC\n\ ,KS,Doniphan,DON\n\ ,KS,Douglas,DOU\n\ ,KS,Edwards,EDW\n\ ,KS,Elk,ELK\n\ ,KS,Ellis,ELL\n\ ,KS,Ellsworth,ELS\n\ ,KS,Finney,FIN\n\ ,KS,Ford,FOR\n\ ,KS,Franklin,FRA\n\ ,KS,Geary,GEA\n\ ,KS,Gove,GOV\n\ ,KS,Graham,GRM\n\ ,KS,Grant,GRT\n\ ,KS,Gray,GRY\n\ ,KS,Greeley,GLY\n\ ,KS,Greenwood,GRE\n\ ,KS,Hamilton,HAM\n\ ,KS,Harper,HPR\n\ ,KS,Harvey,HVY\n\ ,KS,Haskell,HAS\n\ ,KS,Hodgeman,HOG\n\ ,KS,Jackson,JAC\n\ ,KS,Jefferson,JEF\n\ ,KS,Jewell,JEW\n\ ,KS,Johnson,JOH\n\ ,KS,Kearny,KEA\n\ ,KS,Kingman,KIN\n\ ,KS,Kiowa,KIO\n\ ,KS,Labette,LAB\n\ ,KS,Lane,LAN\n\ ,KS,Leavenworth,LEA\n\ ,KS,Lincoln,LCN\n\ ,KS,Linn,LIN\n\ ,KS,Logan,LOG\n\ ,KS,Lyon,LYO\n\ ,KS,Marion,MRN\n\ ,KS,Marshall,MSH\n\ ,KS,McPherson,MCP\n\ ,KS,Meade,MEA\n\ ,KS,Miami,MIA\n\ ,KS,Mitchell,MIT\n\ ,KS,Montgomery,MGY\n\ ,KS,Morris,MOR\n\ ,KS,Morton,MTN\n\ ,KS,Nemaha,NEM\n\ ,KS,Neosho,NEO\n\ ,KS,Ness,NES\n\ ,KS,Norton,NOR\n\ ,KS,Osage,OSA\n\ ,KS,Osborne,OSB\n\ ,KS,Ottawa,OTT\n\ ,KS,Pawnee,PAW\n\ ,KS,Phillips,PHI\n\ ,KS,Pottawatomie,POT\n\ ,KS,Pratt,PRA\n\ ,KS,Rawlins,RAW\n\ ,KS,Reno,REN\n\ ,KS,Republic,REP\n\ ,KS,Rice,RIC\n\ ,KS,Riley,RIL\n\ ,KS,Rooks,ROO\n\ ,KS,Rush,RUS\n\ ,KS,Russell,RSL\n\ ,KS,Saline,SAL\n\ ,KS,Scott,SCO\n\ ,KS,Sedgwick,SED\n\ ,KS,Seward,SEW\n\ ,KS,Shawnee,SHA\n\ ,KS,Sheridan,SHE\n\ ,KS,Sherman,SMN\n\ ,KS,Smith,SMI\n\ ,KS,Stafford,STA\n\ ,KS,Stanton,STN\n\ ,KS,Stevens,STE\n\ ,KS,Sumner,SUM\n\ ,KS,Thomas,THO\n\ ,KS,Trego,TRE\n\ ,KS,Wabaunsee,WAB\n\ ,KS,Wallace,WAL\n\ ,KS,Washington,WAS\n\ ,KS,Wichita,WIC\n\ ,KS,Wilson,WIL\n\ ,KS,Woodson,WOO\n\ ,KS,Wyandotte,WYA\n\ Kentucky,KY,Adair,ADA\n\ ,KY,Allen,ALL\n\ ,KY,Anderson,AND\n\ ,KY,Ballard,BAL\n\ ,KY,Barren,BAR\n\ ,KY,Bath,BAT\n\ ,KY,Bell,BEL\n\ ,KY,Boone,BOO\n\ ,KY,Bourbon,BOU\n\ ,KY,Boyd,BOY\n\ ,KY,Boyle,BOL\n\ ,KY,Bracken,BRA\n\ ,KY,Breathitt,BRE\n\ ,KY,Breckinridge,BRK\n\ ,KY,Bullitt,BUL\n\ ,KY,Butler,BUT\n\ ,KY,Caldwell,CAL\n\ ,KY,Calloway,CAW\n\ ,KY,Campbell,CAM\n\ ,KY,Carlisle,CAE\n\ ,KY,Carroll,CRL\n\ ,KY,Carter,CTR\n\ ,KY,Casey,CAS\n\ ,KY,Christian,CHR\n\ ,KY,Clark,CLA\n\ ,KY,Clay,CLY\n\ ,KY,Clinton,CLI\n\ ,KY,Crittenden,CRI\n\ ,KY,Cumberland,CUM\n\ ,KY,Daviess,DAV\n\ ,KY,Edmonson,EDM\n\ ,KY,Elliott,ELL\n\ ,KY,Estill,EST\n\ ,KY,Fayette,FAY\n\ ,KY,Fleming,FLE\n\ ,KY,Floyd,FLO\n\ ,KY,Franklin,FRA\n\ ,KY,Fulton,FUL\n\ ,KY,Gallatin,GAL\n\ ,KY,Garrard,GAR\n\ ,KY,Grant,GRT\n\ ,KY,Graves,GRV\n\ ,KY,Grayson,GRY\n\ ,KY,Green,GRE\n\ ,KY,Greenup,GRP\n\ ,KY,Hancock,HAN\n\ ,KY,Hardin,HAR\n\ ,KY,Harlan,HRL\n\ ,KY,Harrison,HSN\n\ ,KY,Hart,HRT\n\ ,KY,Henderson,HEN\n\ ,KY,Henry,HNY\n\ ,KY,Hickman,HIC\n\ ,KY,Hopkins,HOP\n\ ,KY,Jackson,JAC\n\ ,KY,Jefferson,JEF\n\ ,KY,Jessamine,JES\n\ ,KY,Johnson,JOH\n\ ,KY,Kenton,KEN\n\ ,KY,Knott,KNT\n\ ,KY,Knox,KNX\n\ ,KY,Larue,LAR\n\ ,KY,Laurel,LAU\n\ ,KY,Lawrence,LAW\n\ ,KY,LEE,LEE\n\ ,KY,Leslie,LES\n\ ,KY,Letcher,LET\n\ ,KY,Lewis,LEW\n\ ,KY,Lincoln,LIN\n\ ,KY,Livingston,LIV\n\ ,KY,Logan,LOG\n\ ,KY,Lyon,LYO\n\ ,KY,McCracken,MCC\n\ ,KY,McCreary,MCY\n\ ,KY,McLean,MCL\n\ ,KY,Madison,MAD\n\ ,KY,Magoffin,MAG\n\ ,KY,Marion,MAR\n\ ,KY,Marshall,MSL\n\ ,KY,Martin,MAT\n\ ,KY,Mason,MAS\n\ ,KY,Meade,MEA\n\ ,KY,Menifee,MEN\n\ ,KY,Mercer,MER\n\ ,KY,Metcalfe,MET\n\ ,KY,Monroe,MON\n\ ,KY,Montgomery,MOT\n\ ,KY,Morgan,MOR\n\ ,KY,Muhlenberg,MUH\n\ ,KY,Nelson,NEL\n\ ,KY,Nicholas,NIC\n\ ,KY,Ohio,OHI\n\ ,KY,Oldham,OLD\n\ ,KY,Owen,OWE\n\ ,KY,Owsley,OWS\n\ ,KY,Pendleton,PEN\n\ ,KY,Perry,PER\n\ ,KY,Pike,PIK\n\ ,KY,Powell,POW\n\ ,KY,Pulaski,PUL\n\ ,KY,Robertson,ROB\n\ ,KY,Rockcastle,ROC\n\ ,KY,Rowan,ROW\n\ ,KY,Russell,RUS\n\ ,KY,Scott,SCO\n\ ,KY,Shelby,SHE\n\ ,KY,Simpson,SIM\n\ ,KY,Spencer,SPE\n\ ,KY,Taylor,TAY\n\ ,KY,Todd,TOD\n\ ,KY,Trigg,TRI\n\ ,KY,Trimble,TRM\n\ ,KY,Union,UNI\n\ ,KY,Warren,WAR\n\ ,KY,Washington,WAS\n\ ,KY,Wayne,WAY\n\ ,KY,Webster,WEB\n\ ,KY,Whitley,WHI\n\ ,KY,Wolfe,WOL\n\ ,KY,Woodford,WOO\n\ Louisiana,LA,Acadia,ACAD\n\ ,LA,Allen,ALLE\n\ ,LA,Ascension,ASCE\n\ ,LA,Assumption,ASSU\n\ ,LA,Avoyelles,AVOY\n\ ,LA,Beauregard,BEAU\n\ ,LA,Bienville,BIEN\n\ ,LA,Bossier,BOSS\n\ ,LA,Caddo,CADD\n\ ,LA,Calcasieu,CALC\n\ ,LA,Caldwell,CALD\n\ ,LA,Cameron,CAME\n\ ,LA,Catahoula,CATA\n\ ,LA,Claiborne,CLAI\n\ ,LA,Concordia,CONC\n\ ,LA,De Soto,DESO\n\ ,LA,East Baton Rouge,EBR\n\ ,LA,East Carroll,ECAR\n\ ,LA,East Feliciana,EFEL\n\ ,LA,Evangeline,EVAN\n\ ,LA,Franklin,FRAN\n\ ,LA,Grant,GRAN\n\ ,LA,Iberia,IBER\n\ ,LA,Iberville,IBVL\n\ ,LA,Jackson,JACK\n\ ,LA,Jefferson,JEFF\n\ ,LA,Jefferson Davis,JFDV\n\ ,LA,La Salle,LASA\n\ ,LA,Lafayette,LAFA\n\ ,LA,Lafourche,LAFO\n\ ,LA,Lincoln,LINC\n\ ,LA,Livingston,LIVI\n\ ,LA,Madison,MADI\n\ ,LA,Morehouse,MORE\n\ ,LA,Natchitoches,NATC\n\ ,LA,Orleans,ORLE\n\ ,LA,Ouachita,OUAC\n\ ,LA,Plaquemines,PLAQ\n\ ,LA,Pointe Coupee,PCP\n\ ,LA,Rapides,RAPI\n\ ,LA,Red River,REDR\n\ ,LA,Richland,RICH\n\ ,LA,Sabine,SABI\n\ ,LA,St. Bernard,SBND\n\ ,LA,St. Charles,SCHL\n\ ,LA,St. Helena,SHEL\n\ ,LA,St. James,SJAM\n\ ,LA,St. John the Baptist,SJB\n\ ,LA,St. Landry,SLAN\n\ ,LA,St. Martin,SMT\n\ ,LA,St. Mary,SMAR\n\ ,LA,St. Tammany,STAM\n\ ,LA,Tangipahoa,TANG\n\ ,LA,Tensas,TENS\n\ ,LA,Terrebonne,TERR\n\ ,LA,Union,UNIO\n\ ,LA,Vermilion,VERM\n\ ,LA,Vernon,VERN\n\ ,LA,Washington,WASH\n\ ,LA,Webster,WEBS\n\ ,LA,West Baton Rouge,WBR\n\ ,LA,West Carroll,WCAR\n\ ,LA,West Feliciana,WFEL\n\ ,LA,Winn,WINN\n\ Massachusetts,MA,Barnstable,BAR\n\ ,MA,Berkshire,BER\n\ ,MA,Bristol,BRM\n\ ,MA,Dukes,DUK\n\ ,MA,Essex,ESM\n\ ,MA,Franklin,FRA\n\ ,MA,Hampden,HMD\n\ ,MA,Hampshire,MA\n\ ,MA,Middlesex,MIM\n\ ,MA,Nantucket,NAN\n\ ,MA,Norfolk,NOR\n\ ,MA,Plymouth,PLY\n\ ,MA,Suffolk,SUF\n\ ,MA,Worcester,WOR\n\ Maine,ME,Androscoggin,AND\n\ ,ME,Aroostook,ARO\n\ ,ME,Cumberland,CBL\n\ ,ME,Franklin,FRA\n\ ,ME,Hancock,HAN\n\ ,ME,Kennebec,KEN\n\ ,ME,Knox,KNO\n\ ,ME,Lincoln,LIN\n\ ,ME,Oxford,OXF\n\ ,ME,Penobscot,PEN\n\ ,ME,Piscataquis,PSQ\n\ ,ME,Sagadahoc,SAG\n\ ,ME,Somerset,SOM\n\ ,ME,Waldo,WAL\n\ ,ME,Washington,WAS\n\ ,ME,York,YOR\n\ Manitoba,MB,,\n\ Maryland,MD,Allegany,ALY\n\ ,MD,Anne Arundel,ANA\n\ ,MD,Baltimore City,BAL\n\ ,MD,Baltimore,BCT\n\ ,MD,Calvert,CLV\n\ ,MD,Caroline,CLN\n\ ,MD,Carroll,CRL\n\ ,MD,Cecil,CEC\n\ ,MD,Charles,CHS\n\ ,MD,Dorchester,DRC\n\ ,MD,Frederick,FRD\n\ ,MD,Garrett,GAR\n\ ,MD,Harford,HFD\n\ ,MD,Howard,HWD\n\ ,MD,Kent,KEN\n\ ,MD,Montgomery,MON\n\ ,MD,Prince George,PGE\n\ ,MD,Queen Anne,QAN\n\ ,MD,St. Mary,STM\n\ ,MD,Somerset,SMR\n\ ,MD,Talbot,TAL\n\ ,MD,Washington,WAS\n\ ,MD,Washington DC,WRC\n\ ,MD,Wicomico,WIC\n\ ,MD,Worcester,WRC\n\ ,MD,Worcester,\n\ Michigan,MI,Alcona,ALCO\n\ ,MI,Alger,ALGE\n\ ,MI,Allegan,ALLE\n\ ,MI,Alpena,ALPE\n\ ,MI,Antrim,ANTR\n\ ,MI,Arenac,AREN\n\ ,MI,Baraga,BARA\n\ ,MI,Barry,BARR\n\ ,MI,Bay,BAY\n\ ,MI,Benzie,BENZ\n\ ,MI,Berrien,BERR\n\ ,MI,Branch,BRAN\n\ ,MI,Calhoun,CALH\n\ ,MI,Cass,CASS\n\ ,MI,Charlevoix,CHAR\n\ ,MI,Cheboygan,CHEB\n\ ,MI,Chippewa,CHIP\n\ ,MI,Clare,CLAR\n\ ,MI,Clinton,CLIN\n\ ,MI,Crawford,CRAW\n\ ,MI,Delta,DELT\n\ ,MI,Dickinson,DICK\n\ ,MI,Eaton,EATO\n\ ,MI,Emmet,EMME\n\ ,MI,Genesee,GENE\n\ ,MI,Gladwin,GLAD\n\ ,MI,Gogebic,GOGE\n\ ,MI,Gratiot,GRAT\n\ ,MI,Grand Traverse,GRTR\n\ ,MI,Hillsdale,HILL\n\ ,MI,Houghton,HOUG\n\ ,MI,Huron,HURO\n\ ,MI,Ionia,IONI\n\ ,MI,Iosco,IOSC\n\ ,MI,Ingham,INGH\n\ ,MI,Iron,IRON\n\ ,MI,Isabella,ISAB\n\ ,MI,Jackson,JACK\n\ ,MI,Kalamazoo,KZOO\n\ ,MI,Kalkaska,KALK\n\ ,MI,Keweenaw,KEWE\n\ ,MI,Kent,KENT\n\ ,MI,Lake,LAKE\n\ ,MI,Lapeer,LAPE\n\ ,MI,Leelanau,LEEL\n\ ,MI,Lenawee,LENA\n\ ,MI,Livingston,LIVI\n\ ,MI,Luce,LUCE\n\ ,MI,Mackinac,MACK\n\ ,MI,Macomb,MACO\n\ ,MI,Manistee,MANI\n\ ,MI,Marquette,MARQ\n\ ,MI,Mason,MASO\n\ ,MI,Mecosta,MECO\n\ ,MI,Menominee,MENO\n\ ,MI,Midland,MIDL\n\ ,MI,Missaukee,MISS\n\ ,MI,Monroe,MONR\n\ ,MI,Montcalm,MCLM\n\ ,MI,Montmorency,MTMO\n\ ,MI,Muskegon,MUSK\n\ ,MI,Newaygo,NEWA\n\ ,MI,Oakland,OAKL\n\ ,MI,Oceana,OCEA\n\ ,MI,Ogemaw,OGEM\n\ ,MI,Ontonagon,ONTO\n\ ,MI,Osceola,OSCE\n\ ,MI,Oscoda,OSCO\n\ ,MI,Otsego,OTSE\n\ ,MI,Ottawa,OTTA\n\ ,MI,Presque Isle,PRES\n\ ,MI,Roscommon,ROSC\n\ ,MI,Saginaw,SAGI\n\ ,MI,Sanilac,SANI\n\ ,MI,Schoolcraft,SCHO\n\ ,MI,Shiawassee,SHIA\n\ ,MI,St. Clair,STCL\n\ ,MI,St. Joseph,STJO\n\ ,MI,Tuscola,TUSC\n\ ,MI,Van Buren,VANB\n\ ,MI,Washtenaw,WASH\n\ ,MI,Wayne,WAYN\n\ ,MI,Wexford,WEXF\n\ Minnesota,MN,Aitkin,AIT\n\ ,MN,Anoka,ANO\n\ ,MN,Becker,BEC\n\ ,MN,Beltrami,BEL\n\ ,MN,Benton,BEN\n\ ,MN,Big Stone,BIG\n\ ,MN,Blue Earth,BLU\n\ ,MN,Brown,BRO\n\ ,MN,Carlton,CRL\n\ ,MN,Carver,CRV\n\ ,MN,Cass,CAS\n\ ,MN,Chippewa,CHP\n\ ,MN,Chisago,CHS\n\ ,MN,Clay,CLA\n\ ,MN,Clearwater,CLE\n\ ,MN,Cook,COO\n\ ,MN,Cottonwood,COT\n\ ,MN,Crow Wing,CRO\n\ ,MN,Dakota,DAK\n\ ,MN,Dodge,DOD\n\ ,MN,Douglas,DOU\n\ ,MN,Fairbault,FAI\n\ ,MN,Fillmore,FIL\n\ ,MN,Freeborn,FRE\n\ ,MN,Goodhue,GOO\n\ ,MN,Grant,GRA\n\ ,MN,Hennepin,HEN\n\ ,MN,Houston,HOU\n\ ,MN,Hubbard,HUB\n\ ,MN,Isanti,ISA\n\ ,MN,Itasca,ITA\n\ ,MN,Jackson,JAC\n\ ,MN,Kanabec,KNB\n\ ,MN,Kandiyohi,KND\n\ ,MN,Kittson,KIT\n\ ,MN,Koochiching,KOO\n\ ,MN,Lac Qui Parle,LAC\n\ ,MN,Lake,LAK\n\ ,MN,Lake of the Woods,LKW\n\ ,MN,Le Sueur,LES\n\ ,MN,Lincoln,LIN\n\ ,MN,Lyon,LYO\n\ ,MN,McLeod,MCL\n\ ,MN,Mahnomen,MAH\n\ ,MN,Marshall,MRS\n\ ,MN,Martin,MRT\n\ ,MN,Meeker,MEE\n\ ,MN,Mille Lacs,MIL\n\ ,MN,Morrison,MOR\n\ ,MN,Mower,MOW\n\ ,MN,Murray,MUR\n\ ,MN,Nicollet,NIC\n\ ,MN,Nobles,NOB\n\ ,MN,Norman,NOR\n\ ,MN,Olmsted,OLM\n\ ,MN,Ottertail,OTT\n\ ,MN,Pennington,PEN\n\ ,MN,Pine,PIN\n\ ,MN,Pipestone,PIP\n\ ,MN,Polk,POL\n\ ,MN,Pope,POP\n\ ,MN,Ramsey,RAM\n\ ,MN,Red Lake,RDL\n\ ,MN,Redwood,RDW\n\ ,MN,Renville,REN\n\ ,MN,Rice,RIC\n\ ,MN,Rock,ROC\n\ ,MN,Roseau,ROS\n\ ,MN,St Louis,STL\n\ ,MN,Scott,SCO\n\ ,MN,Sherburne,SHE\n\ ,MN,Sibley,SIB\n\ ,MN,Stearns,STR\n\ ,MN,Steele,STE\n\ ,MN,Stevens,STV\n\ ,MN,St. Louis,STL\n\ ,MN,Swift,SWI\n\ ,MN,Todd,TOD\n\ ,MN,Traverse,TRA\n\ ,MN,Wabasha,WAB\n\ ,MN,Wadena,WAD\n\ ,MN,Waseca,WSC\n\ ,MN,Washington,WSH\n\ ,MN,Watonwan,WAT\n\ ,MN,Wilkin,WIL\n\ ,MN,Winona,WIN\n\ ,MN,Wright,WRI\n\ ,MN,Yellow Medicine,YEL\n\ Missouri,MO,Adair,ADR\n\ ,MO,Andrew,AND\n\ ,MO,Atchison,ATC\n\ ,MO,Audrain,AUD\n\ ,MO,Barry,BAR\n\ ,MO,Barton,BTN\n\ ,MO,Bates,BAT\n\ ,MO,Benton,BEN\n\ ,MO,Bollinger,BOL\n\ ,MO,Boone,BOO\n\ ,MO,Buchanan,BUC\n\ ,MO,Butler,BTR\n\ ,MO,Caldwell,CWL\n\ ,MO,Callaway,CAL\n\ ,MO,Camden,CAM\n\ ,MO,Cape Girardeau,CPG\n\ ,MO,Carroll,CRL\n\ ,MO,Carter,CAR\n\ ,MO,Cass,CAS\n\ ,MO,Cedar,CED\n\ ,MO,Chariton,CHN\n\ ,MO,Christian,CHR\n\ ,MO,Clark,CLK\n\ ,MO,Clay,CLA\n\ ,MO,Clinton,CLN\n\ ,MO,Cole,COL\n\ ,MO,Cooper,COP\n\ ,MO,Crawford,CRA\n\ ,MO,Dade,DAD\n\ ,MO,Dallas,DAL\n\ ,MO,Daviess,DVS\n\ ,MO,DeKalb,DEK\n\ ,MO,Dent,DEN\n\ ,MO,Douglas,DGL\n\ ,MO,Dunklin,DUN\n\ ,MO,Franklin,FRA\n\ ,MO,Gasconade,GAS\n\ ,MO,Gentry,GEN\n\ ,MO,Greene,GRN\n\ ,MO,Grundy,GRU\n\ ,MO,Harrison,HAR\n\ ,MO,Henry,HEN\n\ ,MO,Hickory,HIC\n\ ,MO,Holt,HLT\n\ ,MO,Howard,HOW\n\ ,MO,Howell,HWL\n\ ,MO,Iron,IRN\n\ ,MO,Jackson,JAC\n\ ,MO,Jasper,JAS\n\ ,MO,Jefferson,JEF\n\ ,MO,Johnson,JON\n\ ,MO,Knox,KNX\n\ ,MO,Laclede,LAC\n\ ,MO,Lafayette,LAF\n\ ,MO,Lawrence,LAW\n\ ,MO,Lewis,LEW\n\ ,MO,Lincoln,LCN\n\ ,MO,Linn,LIN\n\ ,MO,Livingston,LIV\n\ ,MO,Macon,MAC\n\ ,MO,Madison,MAD\n\ ,MO,Maries,MRE\n\ ,MO,Marion,MAR\n\ ,MO,McDonald,MCD\n\ ,MO,Mercer,MER\n\ ,MO,Miller,MIL\n\ ,MO,Mississippi,MIS\n\ ,MO,Moniteau,MNT\n\ ,MO,Monroe,MON\n\ ,MO,Montgomery,MGM\n\ ,MO,Morgan,MOR\n\ ,MO,New Madrid,NMD\n\ ,MO,Newton,NWT\n\ ,MO,Nodaway,NOD\n\ ,MO,Oregon,ORE\n\ ,MO,Osage,OSA\n\ ,MO,Ozark,OZA\n\ ,MO,Pemiscot,PEM\n\ ,MO,Perry,PER\n\ ,MO,Pettis,PET\n\ ,MO,Phelps,PHE\n\ ,MO,Pike,PIK\n\ ,MO,Platte,PLA\n\ ,MO,Polk,POL\n\ ,MO,Pulaski,PUL\n\ ,MO,Putnam,PUT\n\ ,MO,Ralls,RAL\n\ ,MO,Randolph,RAN\n\ ,MO,Ray,RAY\n\ ,MO,Reynolds,REY\n\ ,MO,Ripley,RIP\n\ ,MO,Saline,SAL\n\ ,MO,Schuyler,SCH\n\ ,MO,Scotland,SCT\n\ ,MO,Scott,SCO\n\ ,MO,Shannon,SHA\n\ ,MO,Shelby,SHL\n\ ,MO,St. Charles,STC\n\ ,MO,St. Clair,SCL\n\ ,MO,St. Francois,STF\n\ ,MO,St. Genevieve,STG\n\ ,MO,St. Louis City,STL\n\ ,MO,St. Louis,SLC\n\ ,MO,Stoddard,STD\n\ ,MO,Stone,STN\n\ ,MO,Sullivan,SUL\n\ ,MO,Taney,TAN\n\ ,MO,Texas,TEX\n\ ,MO,Vernon,VRN\n\ ,MO,Warren,WAR\n\ ,MO,Washington,WAS\n\ ,MO,Wayne,WAY\n\ ,MO,Webster,WEB\n\ ,MO,Worth,WOR\n\ ,MO,Wright,WRT\n\ Mississippi,MS,Adams,ADA\n\ ,MS,Alcorn,ALC\n\ ,MS,Amite,AMI\n\ ,MS,Attala,ATT\n\ ,MS,Benton,BEN\n\ ,MS,Bolivar,BOL\n\ ,MS,Calhoun,CAL\n\ ,MS,Carroll,CAR\n\ ,MS,Chickasaw,CHI\n\ ,MS,Choctaw,CHO\n\ ,MS,Claiborne,CLB\n\ ,MS,Clarke,CLK\n\ ,MS,Clay,CLA\n\ ,MS,Coahoma,COA\n\ ,MS,Copiah,COP\n\ ,MS,Covington,COV\n\ ,MS,DeSoto,DES\n\ ,MS,Forrest,FOR\n\ ,MS,Franklin,FRA\n\ ,MS,George,GEO\n\ ,MS,Greene,GRN\n\ ,MS,Grenada,GRE\n\ ,MS,Hancock,HAN\n\ ,MS,Harrison,HAR\n\ ,MS,Hinds,HIN\n\ ,MS,Holmes,HOL\n\ ,MS,Humphreys,HUM\n\ ,MS,Issaquena,ISS\n\ ,MS,Itawamba,ITA\n\ ,MS,Jackson,JAC\n\ ,MS,Jasper,JAS\n\ ,MS,Jefferson,JEF\n\ ,MS,Jefferson Davis,JDV\n\ ,MS,Jones,JON\n\ ,MS,Kemper,KEM\n\ ,MS,Lafayette,LAF\n\ ,MS,Lamar,LAM\n\ ,MS,Lauderdale,LAU\n\ ,MS,Lawrence,LAW\n\ ,MS,Leake,LEA\n\ ,MS,Lee,LEE\n\ ,MS,Leflore,LEF\n\ ,MS,Lincoln,LIN\n\ ,MS,Lowndes,LOW\n\ ,MS,Madison,MAD\n\ ,MS,Marion,MRN\n\ ,MS,Marshall,MAR\n\ ,MS,Monroe,MON\n\ ,MS,Montgomery,MGY\n\ ,MS,Neshoba,NES\n\ ,MS,Newton,NEW\n\ ,MS,Noxubee,NOX\n\ ,MS,Oktibbeha,OKT\n\ ,MS,Panola,PAN\n\ ,MS,Pearl River,PEA\n\ ,MS,Perry,PER\n\ ,MS,Pike,PIK\n\ ,MS,Pontotoc,PON\n\ ,MS,Prentiss,PRE\n\ ,MS,Quitman,QCI\n\ ,MS,Rankin,RAN\n\ ,MS,Scott,SCO\n\ ,MS,Sharkey,SHA\n\ ,MS,Simpson,SIM\n\ ,MS,Smith,SMI\n\ ,MS,Stone,STO\n\ ,MS,Sunflower,SUN\n\ ,MS,Tallahatchie,TAL\n\ ,MS,Tate,TAT\n\ ,MS,Tippah,TIP\n\ ,MS,Tishomingo,TIS\n\ ,MS,Tunica,TUN\n\ ,MS,Union,UNI\n\ ,MS,Walthall,WAL\n\ ,MS,Warren,WAR\n\ ,MS,Washington,WAS\n\ ,MS,Wayne,WAY\n\ ,MS,Webster,WEB\n\ ,MS,Wilkinson,WIL\n\ ,MS,Winston,WIN\n\ ,MS,Yalobusha,YAL\n\ ,MS,Yazoo,YAZ\n\ Montana,MT,Beaverhead,BEA\n\ ,MT,Big Horn,BIG\n\ ,MT,Blaine,BLA\n\ ,MT,Broadwater,BRO\n\ ,MT,Carbon,CRB\n\ ,MT,Carter,CRT\n\ ,MT,Cascade,CAS\n\ ,MT,Chouteau,CHO\n\ ,MT,Custer,CUS\n\ ,MT,Daniels,DAN\n\ ,MT,Dawson,DAW\n\ ,MT,Deer Lodge,DEE\n\ ,MT,Fallon,FAL\n\ ,MT,Fergus,FER\n\ ,MT,Flathead,FLA\n\ ,MT,Gallatin,GAL\n\ ,MT,Garfield,GAR\n\ ,MT,Glacier,GLA\n\ ,MT,Golden Valley,GOL\n\ ,MT,Granite,GRA\n\ ,MT,Hill,HIL\n\ ,MT,Jefferson,JEF\n\ ,MT,Judith Basin,JUD\n\ ,MT,Lake,LAK\n\ ,MT,Lewis & Clark,LEW\n\ ,MT,Liberty,LIB\n\ ,MT,Lincoln,LIN\n\ ,MT,Madison,MAD\n\ ,MT,McCone,MCC\n\ ,MT,Meagher,MEA\n\ ,MT,Mineral,MIN\n\ ,MT,Missoula,MIS\n\ ,MT,Musselshell,MUS\n\ ,MT,Park,PAR\n\ ,MT,Petroleum,PET\n\ ,MT,Phillips,PHI\n\ ,MT,Pondera,PON\n\ ,MT,Powder River,PWD\n\ ,MT,Powell,PWL\n\ ,MT,Prairie,PRA\n\ ,MT,Ravalli,RAV\n\ ,MT,Richland,RIC\n\ ,MT,Roosevelt,ROO\n\ ,MT,Rosebud,ROS\n\ ,MT,Sanders,SAN\n\ ,MT,Sheridan,SHE\n\ ,MT,Silver Bow,SIL\n\ ,MT,Stillwater,STI\n\ ,MT,Sweet Grass,SWE\n\ ,MT,Teton,TET\n\ ,MT,Toole,TOO\n\ ,MT,Treasure,TRE\n\ ,MT,Valley,VAL\n\ ,MT,Wheatland,WHE\n\ ,MT,Wibaux,WIB\n\ ,MT,Yellowstone,YEL\n\ North Carolina,NC,Alamance,ALA\n\ ,NC,Alexander,ALE\n\ ,NC,Alleghany,ALL\n\ ,NC,Anson,ANS\n\ ,NC,Ashe,ASH\n\ ,NC,Avery,AVE\n\ ,NC,Beaufort,BEA\n\ ,NC,Bertie,BER\n\ ,NC,Bladen,BLA\n\ ,NC,Brunswick,BRU\n\ ,NC,Buncombe,BUN\n\ ,NC,Burke,BUR\n\ ,NC,Cabarrus,CAB\n\ ,NC,Caldwell,CAL\n\ ,NC,Camden,CAM\n\ ,NC,Carteret,CAR\n\ ,NC,Caswell,CAS\n\ ,NC,Catawba,CAT\n\ ,NC,Chatham,CHA\n\ ,NC,Cherokee,CHE\n\ ,NC,Chowan,CHO\n\ ,NC,Clay,CLA\n\ ,NC,Cleveland,CLE\n\ ,NC,Columbus,COL\n\ ,NC,Craven,CRA\n\ ,NC,Cumberland,CUM\n\ ,NC,Currituck,CUR\n\ ,NC,Dare,DAR\n\ ,NC,Davidson,DVD\n\ ,NC,Davie,DAV\n\ ,NC,Duplin,DUP\n\ ,NC,Durham,DUR\n\ ,NC,Edgecombe,EDG\n\ ,NC,Forsyth,FOR\n\ ,NC,Franklin,FRA\n\ ,NC,Gaston,GAS\n\ ,NC,Gates,GAT\n\ ,NC,Graham,GRM\n\ ,NC,Granville,GRA\n\ ,NC,Greene,GRE\n\ ,NC,Guilford,GUI\n\ ,NC,Halifax,HAL\n\ ,NC,Harnett,HAR\n\ ,NC,Haywood,HAY\n\ ,NC,Henderson,HEN\n\ ,NC,Hertford,HER\n\ ,NC,Hoke,HOK\n\ ,NC,Hyde,HYD\n\ ,NC,Iredell,IRE\n\ ,NC,Jackson,JAC\n\ ,NC,Johnston,JOH\n\ ,NC,Jones,JON\n\ ,NC,Lee,LEE\n\ ,NC,Lenoir,LEN\n\ ,NC,Lincoln,LIN\n\ ,NC,Macon,MAC\n\ ,NC,Madison,MAD\n\ ,NC,Martin,MAR\n\ ,NC,McDowell,MCD\n\ ,NC,Mecklenburg,MEC\n\ ,NC,Mitchell,MIT\n\ ,NC,Montgomery,MON\n\ ,NC,Moore,MOO\n\ ,NC,Nash,NAS\n\ ,NC,New Hanover,NEW\n\ ,NC,Northampton,NOR\n\ ,NC,Onslow,ONS\n\ ,NC,Orange,ORA\n\ ,NC,Pamlico,PAM\n\ ,NC,Pasquotank,PAS\n\ ,NC,Pender,PEN\n\ ,NC,Perquimans,PEQ\n\ ,NC,Person,PER\n\ ,NC,Pitt,PIT\n\ ,NC,Polk,POL\n\ ,NC,Randolph,RAN\n\ ,NC,Richmond,RIC\n\ ,NC,Robeson,ROB\n\ ,NC,Rockingham,ROC\n\ ,NC,Rowan,ROW\n\ ,NC,Rutherford,RUT\n\ ,NC,Sampson,SAM\n\ ,NC,Scotland,SCO\n\ ,NC,Stanly,STA\n\ ,NC,Stokes,STO\n\ ,NC,Surry,SUR\n\ ,NC,Swain,SWA\n\ ,NC,Transylvania,TRA\n\ ,NC,Tyrrell,TYR\n\ ,NC,Union,UNI\n\ ,NC,Vance,VAN\n\ ,NC,Wake,WAK\n\ ,NC,Warren,WAR\n\ ,NC,Washington,WAS\n\ ,NC,Watauga,WAT\n\ ,NC,Wayne,WAY\n\ ,NC,Wilkes,WLK\n\ ,NC,Wilson,WIL\n\ ,NC,Yadkin,YAD\n\ ,NC,Yancey,YAN\n\ North Dakota,ND,Adams,ADM\n\ ,ND,Barnes,BRN\n\ ,ND,Benson,BSN\n\ ,ND,Billings,BLL\n\ ,ND,Bottineau,BOT\n\ ,ND,Bowman,BOW\n\ ,ND,Burke,BRK\n\ ,ND,Burleigh,BUR\n\ ,ND,Cass,CSS\n\ ,ND,Cavalier,CAV\n\ ,ND,Dickey,DIK\n\ ,ND,Divide,DIV\n\ ,ND,Dunn,DUN\n\ ,ND,Eddy,EDY\n\ ,ND,Emmons,EMN\n\ ,ND,Foster,FOS\n\ ,ND,Golden Valley,GNV\n\ ,ND,Grand Forks,GFK\n\ ,ND,Grant,GNT\n\ ,ND,Griggs,GRG\n\ ,ND,Hettinger,HET\n\ ,ND,Kidder,KDR\n\ ,ND,LaMoure,LMR\n\ ,ND,Logan,LOG\n\ ,ND,McHenry,MCH\n\ ,ND,McIntosh,MCI\n\ ,ND,McKenzie,MCK\n\ ,ND,McLean,MCL\n\ ,ND,Mercer,MCR\n\ ,ND,Morton,MTN\n\ ,ND,Mountrail,MRL\n\ ,ND,Nelson,NEL\n\ ,ND,Oliver,OLR\n\ ,ND,Pembina,PBA\n\ ,ND,Pierce,PRC\n\ ,ND,Ramsey,RMY\n\ ,ND,Ransom,RSM\n\ ,ND,Renville,REN\n\ ,ND,Richland,RLD\n\ ,ND,Rolette,ROL\n\ ,ND,Sargent,SGT\n\ ,ND,Sheridan,SRN\n\ ,ND,Sioux,SIX\n\ ,ND,Slope,SLP\n\ ,ND,Stark,STK\n\ ,ND,Steele,STL\n\ ,ND,Stutsman,STN\n\ ,ND,Towner,TWR\n\ ,ND,Traill,TRL\n\ ,ND,Walsh,WLH\n\ ,ND,Ward,WRD\n\ ,ND,Wells,WLS\n\ ,ND,Williams,WLM\n\ Nebraska,NE,Adams,ADMS\n\ ,NE,Antelope,ANTE\n\ ,NE,Arthur,ARTH\n\ ,NE,Banner,BANN\n\ ,NE,Blaine,BLAI\n\ ,NE,Boone,BOON\n\ ,NE,Box Butte,BOXB\n\ ,NE,Boyd,BOYD\n\ ,NE,Brown,BRWN\n\ ,NE,Buffalo,BUFF\n\ ,NE,Burt,BURT\n\ ,NE,Butler,BUTL\n\ ,NE,Cass,CASS\n\ ,NE,Cedar,CEDA\n\ ,NE,Chase,CHAS\n\ ,NE,Cherry,CHER\n\ ,NE,Cheyenne,CHEY\n\ ,NE,Clay,CLAY\n\ ,NE,Colfax,COLF\n\ ,NE,Cuming,CUMI\n\ ,NE,Custer,CUST\n\ ,NE,Dakota,DAKO\n\ ,NE,Dawes,DAWE\n\ ,NE,Dawson,DAWS\n\ ,NE,Deuel,DEUE\n\ ,NE,Dixon,DIXO\n\ ,NE,Dodge,DODG\n\ ,NE,Douglas,DGLS\n\ ,NE,Dundy,DUND\n\ ,NE,Fillmore,FILL\n\ ,NE,Franklin,FRNK\n\ ,NE,Frontier,FRON\n\ ,NE,Furnas,FURN\n\ ,NE,Gage,GAGE\n\ ,NE,Garden,GARD\n\ ,NE,Garfield,GARF\n\ ,NE,Gosper,GOSP\n\ ,NE,Grant,GRAN\n\ ,NE,Greeley,GREE\n\ ,NE,Hall,HALL\n\ ,NE,Hamilton,HAMI\n\ ,NE,Harlan,HRLN\n\ ,NE,Hayes,HAYE\n\ ,NE,Hitchcock,HITC\n\ ,NE,Holt,HOLT\n\ ,NE,Hooker,HOOK\n\ ,NE,Howard,HOWA\n\ ,NE,Jefferson,JEFF\n\ ,NE,Johnson,JOHN\n\ ,NE,Kearney,KEAR\n\ ,NE,Keith,KEIT\n\ ,NE,Keya Paha,KEYA\n\ ,NE,Kimball,KIMB\n\ ,NE,Knox,KNOX\n\ ,NE,Lancaster,LNCS\n\ ,NE,Lincoln,LINC\n\ ,NE,Logan,LOGA\n\ ,NE,Loup,LOUP\n\ ,NE,Madison,MDSN\n\ ,NE,McPherson,MCPH\n\ ,NE,Merrick,MERR\n\ ,NE,Morrill,MORR\n\ ,NE,Nance,NANC\n\ ,NE,Nemaha,NEMA\n\ ,NE,Nuckolls,NUCK\n\ ,NE,Otoe,OTOE\n\ ,NE,Pawnee,PAWN\n\ ,NE,Perkins,PERK\n\ ,NE,Phelps,PHEL\n\ ,NE,Pierce,PIER\n\ ,NE,Platte,PLAT\n\ ,NE,Polk,POLK\n\ ,NE,Red Willow,REDW\n\ ,NE,Richardson,RICH\n\ ,NE,Rock,ROCK\n\ ,NE,Saline,SALI\n\ ,NE,Sarpy,SARP\n\ ,NE,Saunders,SAUN\n\ ,NE,Scotts Bluff,SCOT\n\ ,NE,Seward,SEWA\n\ ,NE,Sheridan,SHRD\n\ ,NE,Sherman,SHRM\n\ ,NE,Sioux,SIOU\n\ ,NE,Stanton,STAN\n\ ,NE,Thayer,THAY\n\ ,NE,Thomas,THOM\n\ ,NE,Thurston,THUR\n\ ,NE,Valley,VLLY\n\ ,NE,Washington,WASH\n\ ,NE,Wayne,WAYN\n\ ,NE,Webster,WEBS\n\ ,NE,Wheeler,WHEE\n\ ,NE,York,YORK\n\ New Brunswick,NB,Albert,\ ,NB,Carleton,\ ,NB,Charlotte,\ ,NB,Gloucester,\ ,NB,Kent,\ ,NB,Kings,\ ,NB,Madawaska,\ ,NB,Northumberland,\ ,NB,Queens,\ ,NB,Restigouche,\ ,NB,Saint John,\ ,NB,Sunbury,\ ,NB,Victoria,\ ,NB,Westmorland,\ ,NB,York,\ Newfoundland and Labrador,NL,Avalon Peninsula-St. John's,\n\ ,NL,Burin Peninsula-Marystown,\n\ ,NL,South Coast-Channel-Port aux Basques,\n\ ,NL,St. George's-Stephenville,\n\ ,NL,Humber District-Corner Brook,\n\ ,NL,Central Newfoundland-Grand Falls-Windsor,\n\ ,NL,Bonavista/Trinity-Clarenville,\n\ ,NL,Notre Dame Bay-Lewisporte,\n\ ,NL,Northern Peninsula-St. Anthony,\n\ ,NL,Labrador-Happy Valley-Goose Bay,\n\ ,NL,Nunatsiavut-Nain,\n\ New Hampshire,NH,Belknap,BEL\n\ ,NH,Carroll,CAR\n\ ,NH,Cheshire,CHE\n\ ,NH,Coos,COO\n\ ,NH,Grafton,GRN\n\ ,NH,Hillsborough,HIL\n\ ,NH,Merrimack,MER\n\ ,NH,Rockingham,ROC\n\ ,NH,Strafford,STR\n\ ,NH,Sullivan,SUL\n\ New Jersey,NJ,Atlantic,ATLA\n\ ,NJ,Bergen,BERG\n\ ,NJ,Burlington,BURL\n\ ,NJ,Camden,CMDN\n\ ,NJ,Cape May,CAPE\n\ ,NJ,Cumberland,CUMB\n\ ,NJ,Essex,ESSE\n\ ,NJ,Gloucester,GLOU\n\ ,NJ,Hudson,HUDS\n\ ,NJ,Hunterdon,HUNT\n\ ,NJ,Mercer,MERC\n\ ,NJ,Middlesex,MIDD\n\ ,NJ,Monmouth,MONM\n\ ,NJ,Morris,MORR\n\ ,NJ,Ocean,OCEA\n\ ,NJ,Passaic,PASS\n\ ,NJ,Salem,SALE\n\ ,NJ,Somerset,SOME\n\ ,NJ,Sussex,SUSS\n\ ,NJ,Union,UNIO\n\ ,NJ,Warren,WRRN\n\ New Mexico,NM,Bernalillo,BER\n\ ,NM,Catron,CAT\n\ ,NM,Chaves,CHA\n\ ,NM,Cibola,CIB\n\ ,NM,Colfax,COL\n\ ,NM,Curry,CUR\n\ ,NM,De Baca,DEB\n\ ,NM,Dona Ana,DON\n\ ,NM,Eddy,EDD\n\ ,NM,Grant,GRA\n\ ,NM,Guadalupe,GUA\n\ ,NM,Harding,HAR\n\ ,NM,Hidalgo,HID\n\ ,NM,Lea,LEA\n\ ,NM,Lincoln,LIN\n\ ,NM,Los Alamos,LOS\n\ ,NM,Luna,LUN\n\ ,NM,McKinley,MCK\n\ ,NM,Mora,MOR\n\ ,NM,Otero,OTE\n\ ,NM,Quay,QCA\n\ ,NM,Rio Arriba,RIO\n\ ,NM,Roosevelt,ROO\n\ ,NM,San Juan,SJU\n\ ,NM,San Miguel,SMI\n\ ,NM,Sandoval,SAN\n\ ,NM,Santa Fe,SFE\n\ ,NM,Sierra,SIE\n\ ,NM,Socorro,SOC\n\ ,NM,Taos,TAO\n\ ,NM,Torrance,TOR\n\ ,NM,Union,UNI\n\ ,NM,Valencia,VAL\n\ Nevada,NV,Carson City,CAR\n\ ,NV,Churchill,CHU\n\ ,NV,Clark,CLA\n\ ,NV,Douglas,DOU\n\ ,NV,Elko,ELK\n\ ,NV,Esmeralda,ESM\n\ ,NV,Eureka,EUR\n\ ,NV,Humboldt,HUM\n\ ,NV,Lander,LAN\n\ ,NV,Lincoln,LIN\n\ ,NV,Lyon,LYO\n\ ,NV,Mineral,MIN\n\ ,NV,Nye,NYE\n\ ,NV,Pershing,PER\n\ ,NV,Storey,STO\n\ ,NV,Washoe,WAS\n\ ,NV,White Pine,WHI\n\ New York,NY,Albany,ALB\n\ ,NY,Allegany,ALL\n\ ,NY,Bronx,BRX\n\ ,NY,Broome,BRM\n\ ,NY,Cattaraugus,CAT\n\ ,NY,Cayuga,CAY\n\ ,NY,Chautauqua,CHA\n\ ,NY,Chemung,CHE\n\ ,NY,Chenango,CGO\n\ ,NY,Clinton,CLI\n\ ,NY,Columbia,COL\n\ ,NY,Cortland,COR\n\ ,NY,Delaware,DEL\n\ ,NY,Dutchess,DUT\n\ ,NY,Erie,ERI\n\ ,NY,Essex,ESS\n\ ,NY,Franklin,FRA\n\ ,NY,Fulton,FUL\n\ ,NY,Genesee,GEN\n\ ,NY,Greene,GRE\n\ ,NY,Hamilton,HAM\n\ ,NY,Herkimer,HER\n\ ,NY,Jefferson,JEF\n\ ,NY,Kings,KIN\n\ ,NY,Lewis,LEW\n\ ,NY,Livingston,LIV\n\ ,NY,Madison,MAD\n\ ,NY,Monroe,MON\n\ ,NY,Montgomery,MTG\n\ ,NY,Nassau,NAS\n\ ,NY,New York,NEW\n\ ,NY,Niagara,NIA\n\ ,NY,Oneida,ONE\n\ ,NY,Onondaga,ONO\n\ ,NY,Ontario,ONT\n\ ,NY,Orange,ORA\n\ ,NY,Orleans,ORL\n\ ,NY,Oswego,OSW\n\ ,NY,Otsego,OTS\n\ ,NY,Putnam,PUT\n\ ,NY,Queens,QCE\n\ ,NY,Rensselaer,REN\n\ ,NY,Rockland,ROC\n\ ,NY,Richmond,RIC\n\ ,NY,Saratoga,SAR\n\ ,NY,Schenectady,SCH\n\ ,NY,Schoharie,SCO\n\ ,NY,Schuyler,SCU\n\ ,NY,Seneca,SEN\n\ ,NY,St. Lawrence,STL\n\ ,NY,Steuben,STE\n\ ,NY,Suffolk,SUF\n\ ,NY,Sullivan,SUL\n\ ,NY,Tioga,TIO\n\ ,NY,Tompkins,TOM\n\ ,NY,Ulster,ULS\n\ ,NY,Warren,WAR\n\ ,NY,Washington,WAS\n\ ,NY,Wayne,WAY\n\ ,NY,Westchester,WES\n\ ,NY,Wyoming,WYO\n\ ,NY,Yates,YAT\n\ Northwest Territories,NT,Inuvik,\n\ ,NT,Norman Wells,\n\ ,NT,Behchokǫ̀,\n\ ,NT,Fort Simpson,\n\ ,NT,Fort Smith,\n\ ,NT,Yellowknife,\n\ Nova Scotia,NS,Halifax,\n\ ,NS,Sydney,\n\ ,NS,Kentville,\n\ ,NS,Truro,\n\ ,NS,Liverpool,\n\ ,NS,Shelburne,\n\ ,NS,Yarmouth,\n\ Nunavut,NU,Kitikmeot,\n\ NU,Qikiqtaaluk,\n\ NU,Kivalliq,\n\ Ohio,OH,Adams,ADAM\n\ ,OH,Allen,ALLE\n\ ,OH,Ashland,ASHL\n\ ,OH,Ashtabula,ASHT\n\ ,OH,Athens,ATHE\n\ ,OH,Auglaze,AUGL\n\ ,OH,Belmont,BELM\n\ ,OH,Brown,BROW\n\ ,OH,Butler,BUTL\n\ ,OH,Carroll,CARR\n\ ,OH,Champaign,CHAM\n\ ,OH,Clark,CLAR\n\ ,OH,Clermont,CLER\n\ ,OH,Clinton,CLIN\n\ ,OH,Columbiana,COLU\n\ ,OH,Coshocton,COSH\n\ ,OH,Crawford,CRAW\n\ ,OH,Cuyahoga,CUYA\n\ ,OH,Darke,DARK\n\ ,OH,Defiance,DEFI\n\ ,OH,Delaware,DELA\n\ ,OH,Erie,ERIE\n\ ,OH,Fairfield,FAIR\n\ ,OH,Fayette,FAYE\n\ ,OH,Franklin,FRAN\n\ ,OH,Fulton,FULT\n\ ,OH,Gallia,GALL\n\ ,OH,Geauga,GEAU\n\ ,OH,Greene,GREE\n\ ,OH,Guernsey,GUER\n\ ,OH,Hamilton,HAMI\n\ ,OH,Hancock,HANC\n\ ,OH,Hardin,HARD\n\ ,OH,Harrison,HARR\n\ ,OH,Henry,HENR\n\ ,OH,Highland,HIGH\n\ ,OH,Hocking,HOCK\n\ ,OH,Holmes,HOLM\n\ ,OH,Huron,HURO\n\ ,OH,Jackson,JACK\n\ ,OH,Jefferson,JEFF\n\ ,OH,Knox,KNOX\n\ ,OH,Lake,LAKE\n\ ,OH,Lawrence,LAWR\n\ ,OH,Licking,LICK\n\ ,OH,Logan,LOGA\n\ ,OH,Lorain,LORA\n\ ,OH,Lucas,LUCA\n\ ,OH,Madison,MADI\n\ ,OH,Mahoning,MAHO\n\ ,OH,Marion,MARI\n\ ,OH,Medina,MEDI\n\ ,OH,Meigs,MEIG\n\ ,OH,Mercer,MERC\n\ ,OH,Miami,MIAM\n\ ,OH,Monroe,MONR\n\ ,OH,Montgomery,MONT\n\ ,OH,Morgan,MORG\n\ ,OH,Morrow,MORR\n\ ,OH,Muskingum,MUSK\n\ ,OH,Noble,NOBL\n\ ,OH,Ottawa,OTTA\n\ ,OH,Paulding,PAUL\n\ ,OH,Perry,PERR\n\ ,OH,Pickaway,PICK\n\ ,OH,Pike,PIKE\n\ ,OH,Portage,PORT\n\ ,OH,Preble,PREB\n\ ,OH,Putnam,PUTN\n\ ,OH,Richland,RICH\n\ ,OH,Ross,ROSS\n\ ,OH,Sandusky,SAND\n\ ,OH,Scioto,SCIO\n\ ,OH,Seneca,SENE\n\ ,OH,Shelby,SHEL\n\ ,OH,Stark,STAR\n\ ,OH,Summit,SUMM\n\ ,OH,Trumbull,TRUM\n\ ,OH,Tuscarawas,TUSC\n\ ,OH,Union,UNIO\n\ ,OH,VanWert,VANW\n\ ,OH,Vinton,VINT\n\ ,OH,Warren,WARR\n\ ,OH,Washington,WASH\n\ ,OH,Wayne,WAYN\n\ ,OH,Williams,WILL\n\ ,OH,Wood,WOOD\n\ ,OH,Wyandot,WYAN\n\ Oklahoma,OK,Adair,ADA\n\ ,OK,Alfalfa,ALF\n\ ,OK,Atoka,ATO\n\ ,OK,Beaver,BEA\n\ ,OK,Beckham,BEC\n\ ,OK,Blaine,BLA\n\ ,OK,Bryan,BRY\n\ ,OK,Caddo,CAD\n\ ,OK,Canadian,CAN\n\ ,OK,Carter,CAR\n\ ,OK,Cherokee,CHE\n\ ,OK,Choctaw,CHO\n\ ,OK,Cimarron,CIM\n\ ,OK,Cleveland,CLE\n\ ,OK,Coal,COA\n\ ,OK,Comanche,COM\n\ ,OK,Cotton,COT\n\ ,OK,Craig,CRA\n\ ,OK,Creek,CRE\n\ ,OK,Custer,CUS\n\ ,OK,Delaware,DEL\n\ ,OK,Dewey,DEW\n\ ,OK,Ellis,ELL\n\ ,OK,Garfield,GAR\n\ ,OK,Garvin,GRV\n\ ,OK,Grady,GRA\n\ ,OK,Grant,GNT\n\ ,OK,Greer,GRE\n\ ,OK,Harmon,HAR\n\ ,OK,Harper,HRP\n\ ,OK,Haskell,HAS\n\ ,OK,Hughes,HUG\n\ ,OK,Jackson,JAC\n\ ,OK,Jefferson,JEF\n\ ,OK,Johnston,JOH\n\ ,OK,Kay,KAY\n\ ,OK,Kingfisher,KIN\n\ ,OK,Kiowa,KIO\n\ ,OK,Latimer,LAT\n\ ,OK,Le Flore,LEF\n\ ,OK,Lincoln,LIN\n\ ,OK,Logan,LOG\n\ ,OK,Love,LOV\n\ ,OK,McClain,MCL\n\ ,OK,McCurtain,MCU\n\ ,OK,McIntosh,MCI\n\ ,OK,Major,MAJ\n\ ,OK,Marshall,MAR\n\ ,OK,Mayes,MAY\n\ ,OK,Murray,MUR\n\ ,OK,Muskogee,MUS\n\ ,OK,Noble,NOB\n\ ,OK,Nowata,NOW\n\ ,OK,Okfuskee,OKF\n\ ,OK,Oklahoma,OKL\n\ ,OK,Okmulgee,OKM\n\ ,OK,Osage,OSA\n\ ,OK,Ottawa,OTT\n\ ,OK,Pawnee,PAW\n\ ,OK,Payne,PAY\n\ ,OK,Pittsburg,PIT\n\ ,OK,Pontotoc,PON\n\ ,OK,Pottawatomie,POT\n\ ,OK,Pushmataha,PUS\n\ ,OK,Roger Mills,RGM\n\ ,OK,Rogers,ROG\n\ ,OK,Seminole,SEM\n\ ,OK,Sequoyah,SEQ\n\ ,OK,Stephens,STE\n\ ,OK,Texas,TEX\n\ ,OK,Tillman,TIL\n\ ,OK,Tulsa,TUL\n\ ,OK,Wagoner,WAG\n\ ,OK,Washington,WAS\n\ ,OK,Washita,WAT\n\ ,OK,Woods,WOO\n\ ,OK,Woodward,WDW\n\ Ontario,ON,Algoma District,ALG\n\ ,ON,City of Brant,BRA\n\ ,ON,City of Brantford,BFD\n\ ,ON,Bruce County,BRU\n\ ,ON,City of Chatham-Kent,CHK\n\ ,ON,Cochrane District,COC\n\ ,ON,Dufferin County,DUF\n\ ,ON,Durham Regional Municipality,DUR\n\ ,ON,Elgin County,ELG\n\ ,ON,Essex County,ESX\n\ ,ON,Frontenac County,FRO\n\ ,ON,Grey County,GRY\n\ ,ON,Town of Haldimand,HAL\n\ ,ON,Haliburton County,HLB\n\ ,ON,Halton Regional Municipality,HTN\n\ ,ON,City of Hamilton,HAM\n\ ,ON,Hastings County,HAS\n\ ,ON,Huron County,HUR\n\ ,ON,City of Kawartha Lakes,KAW\n\ ,ON,Kenora District,KEN\n\ ,ON,Lambton County,LAM\n\ ,ON,Lanark County,LAN\n\ ,ON,Leeds Grenville United Counties,LGR\n\ ,ON,Lennox-Addington County,LXA\n\ ,ON,Manitoulin District,MAN\n\ ,ON,Middlesex County,MSX\n\ ,ON,Muskoka District,MUS\n\ ,ON,Niagara Regional Municipality,NIA\n\ ,ON,Nipissing District,NIP\n\ ,ON,Town of Norfolk,NFK\n\ ,ON,Northumberland County,NOR\n\ ,ON,City of Ottawa,OTT\n\ ,ON,Oxford County,OXF\n\ ,ON,Parry Sound District,PSD\n\ ,ON,Peel Regional Municipality,PEL\n\ ,ON,Perth County,PER\n\ ,ON,Peterborough County,PET\n\ ,ON,United Counties of Prescott Russell,PRU\n\ ,ON,City of Prince Edward,PED\n\ ,ON,Rainy River District,RAI\n\ ,ON,Renfrew County,REN\n\ ,ON,Simcoe County,SIM\n\ ,ON,United Counties of Stormont Dundas Glengarry,SDG\n\ ,ON,Sudbury District,SUD\n\ ,ON,Thunder Bay District,TBY\n\ ,ON,Timiskaming District,TIM\n\ ,ON,City of Toronto,TOR\n\ ,ON,Waterloo Regional Municipality,WAT\n\ ,ON,Wellington County,WEL\n\ ,ON,York Regional Municipality,YRK\n\ Oregon,OR,Baker,BAK\n\ ,OR,Benton,BEN\n\ ,OR,Clackamas,CLK\n\ ,OR,Clatsop,CLT\n\ ,OR,Columbia,COL\n\ ,OR,Coos,COO\n\ ,OR,Crook,CRO\n\ ,OR,Curry,CUR\n\ ,OR,Deschutes,DES\n\ ,OR,Douglas,DOU\n\ ,OR,Gilliam,GIL\n\ ,OR,Grant,GRA\n\ ,OR,Harney,HAR\n\ ,OR,Hood River,HOO\n\ ,OR,Jackson,JAC\n\ ,OR,Jefferson,JEF\n\ ,OR,Josephine,JOS\n\ ,OR,Klamath,KLA\n\ ,OR,Lake,LAK\n\ ,OR,Lane,LAN\n\ ,OR,Lincoln,LCN\n\ ,OR,Linn,LNN\n\ ,OR,Malheur,MAL\n\ ,OR,Marion,MAR\n\ ,OR,Morrow,MOR\n\ ,OR,Multnomah,MUL\n\ ,OR,Polk,POL\n\ ,OR,Sherman,SHE\n\ ,OR,Tillamook,TIL\n\ ,OR,Umatilla,UMA\n\ ,OR,Union,UNI\n\ ,OR,Wallowa,WAL\n\ ,OR,Wasco,WCO\n\ ,OR,Washington,WSH\n\ ,OR,Wheeler,WHE\n\ ,OR,Yamhill,YAM\n\ Pennsylvania,PA,Adams,ADA\n\ ,PA,Allegheny,ALL\n\ ,PA,Armstrong,ARM\n\ ,PA,Beaver,BEA\n\ ,PA,Bedford,BED\n\ ,PA,Berks,BER\n\ ,PA,Blair,BLA\n\ ,PA,Bradford,BRA\n\ ,PA,Bucks,BUX\n\ ,PA,Butler,BUT\n\ ,PA,Cambria,CMB\n\ ,PA,Cameron,CRN\n\ ,PA,Carbon,CAR\n\ ,PA,Centre,CEN\n\ ,PA,Chester,CHE\n\ ,PA,Clarion,CLA\n\ ,PA,Clearfield,CLE\n\ ,PA,Clinton,CLI\n\ ,PA,Columbia,COL\n\ ,PA,Crawford,CRA\n\ ,PA,Cumberland,CUM\n\ ,PA,Dauphin,DAU\n\ ,PA,Delaware,DCO\n\ ,PA,Elk,ELK\n\ ,PA,Erie,ERI\n\ ,PA,Fayette,FAY\n\ ,PA,Forest,FOR\n\ ,PA,Franklin,FRA\n\ ,PA,Fulton,FUL\n\ ,PA,Greene,GRE\n\ ,PA,Huntingdon,HUN\n\ ,PA,Indiana,INN\n\ ,PA,Jefferson,JEF\n\ ,PA,Juniata,JUN\n\ ,PA,Lackawanna,LAC\n\ ,PA,Lancaster,LAN\n\ ,PA,Lawrence,LAW\n\ ,PA,Lebanon,LEB\n\ ,PA,Lehigh,LEH\n\ ,PA,Luzerne,LUZ\n\ ,PA,Lycoming,LYC\n\ ,PA,Mc Kean,MCK\n\ ,PA,Mercer,MER\n\ ,PA,Mifflin,MIF\n\ ,PA,Monroe,MOE\n\ ,PA,Montgomery,MGY\n\ ,PA,Montour,MTR\n\ ,PA,Northampton,NHA\n\ ,PA,Northumberland,NUM\n\ ,PA,Perry,PER\n\ ,PA,Philadelphia,PHI\n\ ,PA,Pike,PIK\n\ ,PA,Potter,POT\n\ ,PA,Schuylkill,SCH\n\ ,PA,Snyder,SNY\n\ ,PA,Somerset,SOM\n\ ,PA,Sullivan,SUL\n\ ,PA,Susquehanna,SUS\n\ ,PA,Tioga,TIO\n\ ,PA,Union,UNI\n\ ,PA,Venango,VEN\n\ ,PA,Warren,WAR\n\ ,PA,Washington,WAS\n\ ,PA,Wayne,WAY\n\ ,PA,Westmoreland,WES\n\ ,PA,Wyoming,WYO\n\ ,PA,York,YOR\n\ Prince Edward Island,PE,Alberton,\n\ ,PE,Charlottetown,\n\ ,PE,Cornwall,\n\ ,PE,Georgetown,\n\ ,PE,Kensington,\n\ ,PE,Montague,\n\ ,PE,Souris,\n\ ,PE,Stratford,\n\ ,PE,Summerside,\n\ ,PE,Tignish,\n\ Puerto Rico,PR,Adjuntas Municipio,\n\ ,PR,Aguada Municipio,\n\ ,PR,Aguadilla Municipio,\n\ ,PR,Aguas Buenas Municipio,\n\ ,PR,Aibonito Municipio,\n\ ,PR,Anasco Municipio,\n\ ,PR,Arecibo Municipio,\n\ ,PR,Arroyo Municipio,\n\ ,PR,Barceloneta Municipio,\n\ ,PR,Barranquitas Municipio,\n\ ,PR,Bayamon Municipio,\n\ ,PR,Cabo Rojo Municipio,\n\ ,PR,Caguas Municipio,\n\ ,PR,Camuy Municipio,\n\ ,PR,Canovanas Municipio,\n\ ,PR,Carolina Municipio,\n\ ,PR,Catano Municipio,\n\ ,PR,Cayey Municipio,\n\ ,PR,Ceiba Municipio,\n\ ,PR,Ciales Municipio,\n\ ,PR,Cidra Municipio,\n\ ,PR,Coamo Municipio,\n\ ,PR,Comerio Municipio,\n\ ,PR,Corozal Municipio,\n\ ,PR,Culebra Municipio,\n\ ,PR,Dorado Municipio,\n\ ,PR,Fajardo Municipio,\n\ ,PR,Florida Municipio,\n\ ,PR,Guanica Municipio,\n\ ,PR,Guayama Municipio,\n\ ,PR,Guayanilla Municipio,\n\ ,PR,Guaynabo Municipio,\n\ ,PR,Gurabo Municipio,\n\ ,PR,Hatillo Municipio,\n\ ,PR,Hormigueros Municipio,\n\ ,PR,Humacao Municipio,\n\ ,PR,Isabela Municipio,\n\ ,PR,Jayuya Municipio,\n\ ,PR,Juana Diaz Municipio,\n\ ,PR,Juncos Municipio,\n\ ,PR,Lajas Municipio,\n\ ,PR,Lares Municipio,\n\ ,PR,Las Marias Municipio,\n\ ,PR,Las Piedras Municipio,\n\ ,PR,Loiza Municipio,\n\ ,PR,Luquillo Municipio,\n\ ,PR,Manati Municipio,\n\ ,PR,Maricao Municipio,\n\ ,PR,Maunabo Municipio,\n\ ,PR,Mayaguez Municipio,\n\ ,PR,Moca Municipio,\n\ ,PR,Morovis Municipio,\n\ ,PR,Naguabo Municipio,\n\ ,PR,Naranjito Municipio,\n\ ,PR,Orocovis Municipio,\n\ ,PR,Patillas Municipio,\n\ ,PR,Penuelas Municipio,\n\ ,PR,Ponce Municipio,\n\ ,PR,Quebradillas Municipio,\n\ ,PR,Rincon Municipio,\n\ ,PR,Rio Grande Municipio,\n\ ,PR,Sabana Grande Municipio,\n\ ,PR,Salinas Municipio,\n\ ,PR,San German Municipio,\n\ ,PR,San Juan Municipio,\n\ ,PR,San Lorenzo Municipio,\n\ ,PR,San Sebastian Municipio,\n\ ,PR,Santa Isabel Municipio,\n\ ,PR,Toa Alta Municipio,\n\ ,PR,Toa Baja Municipio,\n\ ,PR,Trujillo Alto Municipio,\n\ ,PR,Utuado Municipio,\n\ ,PR,Vega Alta Municipio,\n\ ,PR,Vega Baja Municipio,\n\ ,PR,Vieques Municipio,\n\ ,PR,Villalba Municipio,\n\ ,PR,Yabucoa Municipio,\n\ ,PR,Yauco Municipio,\n\ Quebec,QC,Bas-Saint-Laurent,\n\ ,QC,Saguenay–Lac-Saint-Jean,\n\ ,QC,Capitale-Nationale,\n\ ,QC,Mauricie,\n\ ,QC,Estrie,\n\ ,QC,Montréal,\n\ ,QC,Outaouais,\n\ ,QC,Abitibi-Témiscamingue,\n\ ,QC,Côte-Nord,\n\ ,QC,Nord-du-Québec,\n\ ,QC,CRÉ de la Baie-James,\n\ ,QC,Cree Regional Authority,\n\ ,QC,Kativik Regional Government,\n\ ,QC,Gaspésie–Îles-de-la-Madeleine,\n\ ,QC,Chaudière-Appalaches,\n\ ,QC,Laval,\n\ ,QC,Lanaudière,\n\ ,QC,Laurentides,\n\ ,QC,Montérégie,\n\ ,QC,CRÉ de Longueuil,\n\ ,QC,CRÉ Montérégie Est,\n\ ,QC,CRÉ Vallée-du-Haut-Saint-Laurent,\n\ ,QC,Centre-du-Québec,\n\ Rhode Island,RI,Bristol,BRI\n\ ,RI,Kent,KNT\n\ ,RI,Newport,NEW\n\ ,RI,Providence,PRO\n\ ,RI,Washington,WAR\n\ Saskatchewan,SA,,\n\ ,SA,Assiniboia,,\n\ ,SA,Battleford,,\n\ ,SA,Estevan,,\n\ ,SA,Kindersley,,\n\ ,SA,La Ronge,,\n\ ,SA,Lloydminster,,\n\ ,SA,Maple Creek,,\n\ ,SA,Melfort,,\n\ ,SA,Melville,,\n\ ,SA,Moose Jaw,,\n\ ,SA,North Battleford,,\n\ ,SA,Prince Albert,,\n\ ,SA,Regina,,\n\ ,SA,Saskatoon,,\n\ ,SA,Swift Current,,\n\ ,SA,Weyburn,,\n\ ,SA,Wynyard,,\n\ ,SA,Yorkton,,\n\ South Carolina,SC,Abbeville,ABBE\n\ ,SC,Aiken,AIKE\n\ ,SC,Allendale,ALLE\n\ ,SC,Anderson,ANDE\n\ ,SC,Bamberg,BAMB\n\ ,SC,Barnwell,BARN\n\ ,SC,Beaufort,BEAU\n\ ,SC,Berkeley,BERK\n\ ,SC,Calhoun,CHOU\n\ ,SC,Charleston,CHAR\n\ ,SC,Chester,CHES\n\ ,SC,Chesterfield,CHFD\n\ ,SC,Cherokee,CKEE\n\ ,SC,Clarendon,CLRN\n\ ,SC,Colleton,COLL\n\ ,SC,Darlington,DARL\n\ ,SC,Dillon,DILL\n\ ,SC,Dorchester,DORC\n\ ,SC,Edgefield,EDGE\n\ ,SC,Fairfield,FAIR\n\ ,SC,Florence,FLOR\n\ ,SC,Georgetown,GEOR\n\ ,SC,Greenwood,GRWD\n\ ,SC,Greenville,GVIL\n\ ,SC,Hampton,HAMP\n\ ,SC,Horry,HORR\n\ ,SC,Jasper,JASP\n\ ,SC,Kershaw,KERS\n\ ,SC,Laurens,LAUR\n\ ,SC,Lee,LEE\n\ ,SC,Lexington,LEXI\n\ ,SC,Lancaster,LNCS\n\ ,SC,Marion,MARI\n\ ,SC,Marlboro,MARL\n\ ,SC,McCormick,MCOR\n\ ,SC,Newberry,NEWB\n\ ,SC,Oconee,OCON\n\ ,SC,Orangeburg,ORNG\n\ ,SC,Pickens,PICK\n\ ,SC,Richland,RICH\n\ ,SC,Saluda,SALU\n\ ,SC,Spartanburg,SPAR\n\ ,SC,Sumter,SUMT\n\ ,SC,Union,UNIO\n\ ,SC,Williamsburg,WILL\n\ ,SC,York,YORK\n\ South Dakota,SD,Aurora,AURO\n\ ,SD,Beadle,BEAD\n\ ,SD,Bennett,BENN\n\ ,SD,Bon Homme,BONH\n\ ,SD,Brookings,BROO\n\ ,SD,Brule,BRUL\n\ ,SD,Brown,BRWN\n\ ,SD,Buffalo,BUFF\n\ ,SD,Butte,BUTT\n\ ,SD,Campbell,CAMP\n\ ,SD,Charles Mix,CHAR\n\ ,SD,Clay,CLAY\n\ ,SD,Clark,CLRK\n\ ,SD,Codington,CODI\n\ ,SD,Corson,CORS\n\ ,SD,Custer,CUST\n\ ,SD,Davison,DAVI\n\ ,SD,Day,DAY\n\ ,SD,Deuel,DEUE\n\ ,SD,Dewey,DEWY\n\ ,SD,Douglas,DGLS\n\ ,SD,Edmunds,EDMU\n\ ,SD,Fall River,FALL\n\ ,SD,Faulk,FAUL\n\ ,SD,Grant,GRAN\n\ ,SD,Gregory,GREG\n\ ,SD,Haakon,HAAK\n\ ,SD,Hamlin,HAML\n\ ,SD,Hand,HAND\n\ ,SD,Hanson,HNSN\n\ ,SD,Harding,HRDG\n\ ,SD,Hughes,HUGH\n\ ,SD,Hutchinson,HUTC\n\ ,SD,Hyde,HYDE\n\ ,SD,Jerauld,JERA\n\ ,SD,Jackson,JKSN\n\ ,SD,Jones,JONE\n\ ,SD,Kingsbury,KING\n\ ,SD,Lake,LAKE\n\ ,SD,Lawrence,LAWR\n\ ,SD,Lincoln,LINC\n\ ,SD,Lyman,LYMA\n\ ,SD,McCook,MCOO\n\ ,SD,McPherson,MCPH\n\ ,SD,Meade,MEAD\n\ ,SD,Mellette,MELL\n\ ,SD,Miner,MINE\n\ ,SD,Minnehaha,MINN\n\ ,SD,Moody,MOOD\n\ ,SD,Marshall,MRSH\n\ ,SD,Oglala Lakota,OGLA\n\ ,SD,Pennington,PENN\n\ ,SD,Perkins,PERK\n\ ,SD,Potter,POTT\n\ ,SD,Roberts,ROBE\n\ ,SD,Sanborn,SANB\n\ ,SD,Spink,SPIN\n\ ,SD,Stanley,STAN\n\ ,SD,Sully,SULL\n\ ,SD,Todd,TODD\n\ ,SD,Tripp,TRIP\n\ ,SD,Turner,TURN\n\ ,SD,Union,UNIO\n\ ,SD,Walworth,WALW\n\ ,SD,Yankton,YANK\n\ ,SD,Ziebach,ZIEB\n\ Tennessee,TN,Anderson,ANDE\n\ ,TN,Bedford,BEDF\n\ ,TN,Benton,BENT\n\ ,TN,Bledsoe,BLED\n\ ,TN,Blount,BLOU\n\ ,TN,Bradley,BRAD\n\ ,TN,Campbell,CAMP\n\ ,TN,Cannon,CANN\n\ ,TN,Carroll,CARR\n\ ,TN,Carter,CART\n\ ,TN,Cheatham,CHEA\n\ ,TN,Chester,CHES\n\ ,TN,Claiborne,CLAI\n\ ,TN,Clay,CLAY\n\ ,TN,Cocke,COCK\n\ ,TN,Coffee,COFF\n\ ,TN,Crockett,CROC\n\ ,TN,Cumberland,CUMB\n\ ,TN,Davidson,DAVI\n\ ,TN,Decatur,DECA\n\ ,TN,DeKalb,DEKA\n\ ,TN,Dickson,DICK\n\ ,TN,Dyer,DYER\n\ ,TN,Fayette,FAYE\n\ ,TN,Fentress,FENT\n\ ,TN,Franklin,FRAN\n\ ,TN,Gibson,GIBS\n\ ,TN,Giles,GILE\n\ ,TN,Grainger,GRAI\n\ ,TN,Greene,GREE\n\ ,TN,Grundy,GRUN\n\ ,TN,Hamblen,HAMB\n\ ,TN,Hamilton,HAMI\n\ ,TN,Hancock,HANC\n\ ,TN,Hardeman,HARD\n\ ,TN,Hardin,HARN\n\ ,TN,Hawkins,HAWK\n\ ,TN,Haywood,HAYW\n\ ,TN,Henderson,HEND\n\ ,TN,Henry,HENR\n\ ,TN,Hickman,HICK\n\ ,TN,Houston,HOUS\n\ ,TN,Humphreys,HUMP\n\ ,TN,Jackson,JACK\n\ ,TN,Jefferson,JEFF\n\ ,TN,Johnson,JOHN\n\ ,TN,Knox,KNOX\n\ ,TN,Lake,LAKE\n\ ,TN,Lauderdale,LAUD\n\ ,TN,Lawrence,LAWR\n\ ,TN,Lewis,LEWI\n\ ,TN,Lincoln,LINC\n\ ,TN,Loudon,LOUD\n\ ,TN,Macon,MACO\n\ ,TN,Madison,MADI\n\ ,TN,Marion,MARI\n\ ,TN,Marshall,MARS\n\ ,TN,Maury,MAUR\n\ ,TN,McMinn,MCMI\n\ ,TN,McNairy,MCNA\n\ ,TN,Meigs,MEIG\n\ ,TN,Monroe,MONR\n\ ,TN,Montgomery,MONT\n\ ,TN,Moore,MOOR\n\ ,TN,Morgan,MORG\n\ ,TN,Obion,OBIO\n\ ,TN,Overton,OVER\n\ ,TN,Perry,PERR\n\ ,TN,Pickett,PICK\n\ ,TN,Polk,POLK\n\ ,TN,Putnam,PUTN\n\ ,TN,Rhea,RHEA\n\ ,TN,Roane,ROAN\n\ ,TN,Robertson,ROBE\n\ ,TN,Rutherford,RUTH\n\ ,TN,Scott,SCOT\n\ ,TN,Sequatchie,SEQU\n\ ,TN,Sevier,SEVI\n\ ,TN,Shelby,SHEL\n\ ,TN,Smith,SMIT\n\ ,TN,Stewart,STEW\n\ ,TN,Sullivan,SULL\n\ ,TN,Sumner,SUMN\n\ ,TN,Tipton,TIPT\n\ ,TN,Trousdale,TROU\n\ ,TN,Unicoi,UNIC\n\ ,TN,Union,UNIO\n\ ,TN,Van Buren,VANB\n\ ,TN,Warren,WARR\n\ ,TN,Washington,WASH\n\ ,TN,Wayne,WAYN\n\ ,TN,Weakley,WEAK\n\ ,TN,White,WHIT\n\ ,TN,Williamson,WILL\n\ ,TN,Wilson,WILS\n\ Texas,TX,Anderson,ANDE\n\ ,TX,Andrews,ANDR\n\ ,TX,Angelina,ANGE\n\ ,TX,Aransas,ARAN\n\ ,TX,Archer,ARCH\n\ ,TX,Armstrong,ARMS\n\ ,TX,Atascosa,ATAS\n\ ,TX,Austin,AUST\n\ ,TX,Bailey,BAIL\n\ ,TX,Bandera,BAND\n\ ,TX,Bastrop,BAST\n\ ,TX,Baylor,BAYL\n\ ,TX,Bee,BEE\n\ ,TX,Bell,BELL\n\ ,TX,Bexar,BEXA\n\ ,TX,Blanco,BLAN\n\ ,TX,Borden,BORD\n\ ,TX,Bosque,BOSQ\n\ ,TX,Bowie,BOWI\n\ ,TX,Brazoria,BZIA\n\ ,TX,Brazos,BZOS\n\ ,TX,Brewster,BREW\n\ ,TX,Briscoe,BRIS\n\ ,TX,Brooks,BROO\n\ ,TX,Brown,BROW\n\ ,TX,Burleson,BURL\n\ ,TX,Burnet,BURN\n\ ,TX,Caldwell,CALD\n\ ,TX,Calhoun,CALH\n\ ,TX,Callahan,CALL\n\ ,TX,Cameron,CMRN\n\ ,TX,Camp,CAMP\n\ ,TX,Carson,CARS\n\ ,TX,Cass,CASS\n\ ,TX,Castro,CAST\n\ ,TX,Chambers,CHAM\n\ ,TX,Cherokee,CHER\n\ ,TX,Childress,CHIL\n\ ,TX,Clay,CLAY\n\ ,TX,Cochran,COCH\n\ ,TX,Coke,COKE\n\ ,TX,Coleman,COLE\n\ ,TX,Collin,COLN\n\ ,TX,Collingsworth,COLW\n\ ,TX,Colorado,COLO\n\ ,TX,Comal,COML\n\ ,TX,Comanche,COMA\n\ ,TX,Concho,CONC\n\ ,TX,Cooke,COOK\n\ ,TX,Coryell,CORY\n\ ,TX,Cottle,COTT\n\ ,TX,Crane,CRAN\n\ ,TX,Crockett,CROC\n\ ,TX,Crosby,CROS\n\ ,TX,Culberson,CULB\n\ ,TX,Dallam,DALM\n\ ,TX,Dallas,DALS\n\ ,TX,Dawson,DAWS\n\ ,TX,Deaf Smith,DSMI\n\ ,TX,Delta,DELT\n\ ,TX,Denton,DENT\n\ ,TX,Dewitt,DEWI\n\ ,TX,Dickens,DICK\n\ ,TX,Dimmit,DIMM\n\ ,TX,Donley,DONL\n\ ,TX,Duval,DUVA\n\ ,TX,Eastland,EAST\n\ ,TX,Ector,ECTO\n\ ,TX,Edwards,EDWA\n\ ,TX,El Paso,EPAS\n\ ,TX,Ellis,ELLI\n\ ,TX,Erath,ERAT\n\ ,TX,Falls,FALL\n\ ,TX,Fannin,FANN\n\ ,TX,Fayette,FAYE\n\ ,TX,Fisher,FISH\n\ ,TX,Floyd,FLOY\n\ ,TX,Foard,FOAR\n\ ,TX,Fort Bend,FBEN\n\ ,TX,Franklin,FRAN\n\ ,TX,Freestone,FREE\n\ ,TX,Frio,FRIO\n\ ,TX,Gaines,GAIN\n\ ,TX,Galveston,GALV\n\ ,TX,Garza,GARZ\n\ ,TX,Gillespie,GILL\n\ ,TX,Glasscock,GLAS\n\ ,TX,Goliad,GOLI\n\ ,TX,Gonzales,GONZ\n\ ,TX,Gray,GRAY\n\ ,TX,Grayson,GRSN\n\ ,TX,Gregg,GREG\n\ ,TX,Grimes,GRIM\n\ ,TX,Guadalupe,GUAD\n\ ,TX,Hale,HALE\n\ ,TX,Hall,HALL\n\ ,TX,Hamilton,HAMI\n\ ,TX,Hansford,HANS\n\ ,TX,Hardeman,HDMN\n\ ,TX,Hardin,HRDN\n\ ,TX,Harris,HARR\n\ ,TX,Harrison,HRSN\n\ ,TX,Hartley,HART\n\ ,TX,Haskell,HASK\n\ ,TX,Hays,HAYS\n\ ,TX,Hemphill,HEMP\n\ ,TX,Henderson,HEND\n\ ,TX,Hidalgo,HIDA\n\ ,TX,Hill,HILL\n\ ,TX,Hockley,HOCK\n\ ,TX,Hood,HOOD\n\ ,TX,Hopkins,HOPK\n\ ,TX,Houston,HOUS\n\ ,TX,Howard,HOWA\n\ ,TX,Hudspeth,HUDS\n\ ,TX,Hunt,HUNT\n\ ,TX,Hutchinson,HUTC\n\ ,TX,Irion,IRIO\n\ ,TX,Jack,JACK\n\ ,TX,Jackson,JKSN\n\ ,TX,Jasper,JASP\n\ ,TX,Jeff Davis,JDAV\n\ ,TX,Jefferson,JEFF\n\ ,TX,Jim Hogg,JHOG\n\ ,TX,Jim Wells,JWEL\n\ ,TX,Johnson,JOHN\n\ ,TX,Jones,JONE\n\ ,TX,Karnes,KARN\n\ ,TX,Kaufman,KAUF\n\ ,TX,Kendall,KEND\n\ ,TX,Kenedy,KENY\n\ ,TX,Kent,KENT\n\ ,TX,Kerr,KERR\n\ ,TX,Kimble,KIMB\n\ ,TX,King,KING\n\ ,TX,Kinney,KINN\n\ ,TX,Kleberg,KLEB\n\ ,TX,Knox,KNOX\n\ ,TX,Lamar,LAMA\n\ ,TX,Lamb,LAMB\n\ ,TX,Lampasas,LAMP\n\ ,TX,La Salle,LSAL\n\ ,TX,Lavaca,LAVA\n\ ,TX,Lee,LEE\n\ ,TX,Leon,LEON\n\ ,TX,Liberty,LIBE\n\ ,TX,Limestone,LIME\n\ ,TX,Lipscomb,LIPS\n\ ,TX,Live Oak,LIVO\n\ ,TX,Llano,LLAN\n\ ,TX,Loving,LOVI\n\ ,TX,Lubbock,LUBB\n\ ,TX,Lynn,LYNN\n\ ,TX,Madison,MADI\n\ ,TX,Marion,MARI\n\ ,TX,Martin,MART\n\ ,TX,Mason,MASO\n\ ,TX,Matagorda,MATA\n\ ,TX,Maverick,MAVE\n\ ,TX,McCulloch,MCUL\n\ ,TX,McLennan,MLEN\n\ ,TX,McMullen,MMUL\n\ ,TX,Medina,MEDI\n\ ,TX,Menard,MENA\n\ ,TX,Midland,MIDL\n\ ,TX,Milam,MILA\n\ ,TX,Mills,MILL\n\ ,TX,Mitchell,MITC\n\ ,TX,Montague,MONT\n\ ,TX,Montgomery,MGMY\n\ ,TX,Moore,MOOR\n\ ,TX,Morris,MORR\n\ ,TX,Motley,MOTL\n\ ,TX,Nacogdoches,NACO\n\ ,TX,Navarro,NAVA\n\ ,TX,Newton,NEWT\n\ ,TX,Nolan,NOLA\n\ ,TX,Nueces,NUEC\n\ ,TX,Ochiltree,OCHI\n\ ,TX,Oldham,OLDH\n\ ,TX,Orange,ORAN\n\ ,TX,Palo Pinto,PPIN\n\ ,TX,Panola,PANO\n\ ,TX,Parker,PARK\n\ ,TX,Parmer,PARM\n\ ,TX,Pecos,PECO\n\ ,TX,Polk,POLK\n\ ,TX,Potter,POTT\n\ ,TX,Presidio,PRES\n\ ,TX,Rains,RAIN\n\ ,TX,Randall,RAND\n\ ,TX,Reagan,REAG\n\ ,TX,Real,REAL\n\ ,TX,Red River,RRIV\n\ ,TX,Reeves,REEV\n\ ,TX,Refugio,REFU\n\ ,TX,Roberts,ROBE\n\ ,TX,Robertson,RBSN\n\ ,TX,Rockwall,ROCK\n\ ,TX,Runnels,RUNN\n\ ,TX,Rusk,RUSK\n\ ,TX,Sabine,SABI\n\ ,TX,San Augustine,SAUG\n\ ,TX,San Jacinto,SJAC\n\ ,TX,San Patricio,SPAT\n\ ,TX,San Saba,SSAB\n\ ,TX,Schleicher,SCHL\n\ ,TX,Scurry,SCUR\n\ ,TX,Shackelford,SHAC\n\ ,TX,Shelby,SHEL\n\ ,TX,Sherman,SHMN\n\ ,TX,Smith,SMIT\n\ ,TX,Somervell,SOME\n\ ,TX,Starr,STAR\n\ ,TX,Stephens,STEP\n\ ,TX,Sterling,STER\n\ ,TX,Stonewall,STON\n\ ,TX,Sutton,SUTT\n\ ,TX,Swisher,SWIS\n\ ,TX,Tarrant,TARR\n\ ,TX,Taylor,TAYL\n\ ,TX,Terrell,TERL\n\ ,TX,Terry,TERY\n\ ,TX,Throckmorton,THRO\n\ ,TX,Titus,TITU\n\ ,TX,Tom Green,TGRE\n\ ,TX,Travis,TRAV\n\ ,TX,Trinity,TRIN\n\ ,TX,Tyler,TYLE\n\ ,TX,Upshur,UPSH\n\ ,TX,Upton,UPTO\n\ ,TX,Uvalde,UVAL\n\ ,TX,Val Verde,VVER\n\ ,TX,Van Zandt,VZAN\n\ ,TX,Victoria,VICT\n\ ,TX,Walker,WALK\n\ ,TX,Waller,WALL\n\ ,TX,Ward,WARD\n\ ,TX,Washington,WASH\n\ ,TX,Webb,WEBB\n\ ,TX,Wharton,WHAR\n\ ,TX,Wheeler,WHEE\n\ ,TX,Wichita,WICH\n\ ,TX,Wilbarger,WILB\n\ ,TX,Willacy,WILY\n\ ,TX,Williamson,WMSN\n\ ,TX,Wilson,WLSN\n\ ,TX,Winkler,WINK\n\ ,TX,Wise,WISE\n\ ,TX,Wood,WOOD\n\ ,TX,Yoakum,YOAK\n\ ,TX,Young,YOUN\n\ ,TX,Zapata,ZAPA\n\ ,TX,Zavala,ZAVA\n\ Midway,UM,Midway Islands,\n\ Utah,UT,Beaver,BEA\n\ ,UT,Box Elder,BOX\n\ ,UT,Cache,CAC\n\ ,UT,Carbon,CAR\n\ ,UT,Daggett,DAG\n\ ,UT,Davis,DAV\n\ ,UT,Duchesne,DUC\n\ ,UT,Emery,EME\n\ ,UT,Garfield,GAR\n\ ,UT,Grand,GRA\n\ ,UT,Iron,IRO\n\ ,UT,Juab,JUA\n\ ,UT,Kane,KAN\n\ ,UT,Millard,MIL\n\ ,UT,Morgan,MOR\n\ ,UT,Piute,PIU\n\ ,UT,Rich,RIC\n\ ,UT,Salt Lake,SAL\n\ ,UT,San Juan,SNJ\n\ ,UT,Sanpete,SNP\n\ ,UT,Sevier,SEV\n\ ,UT,Summit,SUM\n\ ,UT,Tooele,TOO\n\ ,UT,Uintah,UIN\n\ ,UT,Utah,UTA\n\ ,UT,Wasatch,WST\n\ ,UT,Washington,WSH\n\ ,UT,Wayne,WAY\n\ ,UT,Weber,WEB\n\ Vermont,VT,Addison,ADD\n\ ,VT,Bennington,BEN\n\ ,VT,Caledonia,CAL\n\ ,VT,Chittenden,CHI\n\ ,VT,Essex,ESS\n\ ,VT,Franklin,FRA\n\ ,VT,Grand Isle,GRA\n\ ,VT,Lamoille,LAM\n\ ,VT,Orange,ORA\n\ ,VT,Orleans,ORL\n\ ,VT,Rutland,RUT\n\ ,VT,Washington,WAS\n\ ,VT,Windham,WNH\n\ ,VT,Windsor,WNS\n\ Virginia,VA,Accomack,ACC\n\ ,VA,Albemarle,ALB\n\ ,VA,Alexandria,ALX\n\ ,VA,Alleghany,ALL\n\ ,VA,Amelia,AME\n\ ,VA,Amherst,AMH\n\ ,VA,Appomattox,APP\n\ ,VA,Arlington,ARL\n\ ,VA,Augusta,AUG\n\ ,VA,Bath,BAT\n\ ,VA,Bedford,BED\n\ ,VA,Bland,BLA\n\ ,VA,Botetourt,BOT\n\ ,VA,Bristol,BRX\n\ ,VA,Brunswick,BRU\n\ ,VA,Buchanan,BCH\n\ ,VA,Buckingham,BHM\n\ ,VA,Buena Vista,BVX\n\ ,VA,Campbell,CAM\n\ ,VA,Caroline,CLN\n\ ,VA,Carroll,CRL\n\ ,VA,Charles City,CCY\n\ ,VA,Charlotte,CHA\n\ ,VA,Charlottesville,CHX\n\ ,VA,Chesapeake,CPX\n\ ,VA,Chesterfield,CHE\n\ ,VA,Clarke,CLA\n\ ,VA,Colonial Heights,COX\n\ ,VA,Covington,CVX\n\ ,VA,Craig,CRA\n\ ,VA,Culpeper,CUL\n\ ,VA,Cumberland,CUM\n\ ,VA,Danville,DAX\n\ ,VA,Dickenson,DIC\n\ ,VA,Dinwiddie,DIN\n\ ,VA,Emporia,EMX\n\ ,VA,Essex,ESS\n\ ,VA,Fairfax,FFX\n\ ,VA,Fairfax City,FXX\n\ ,VA,Falls Church,FCX\n\ ,VA,Fauquier,FAU\n\ ,VA,Floyd,FLO\n\ ,VA,Fluvanna,FLU\n\ ,VA,Franklin,FRA\n\ ,VA,Franklin City,FRX\n\ ,VA,Frederick,FRE\n\ ,VA,Fredericksburg,FBX\n\ ,VA,Galax,GAX\n\ ,VA,Giles,GIL\n\ ,VA,Gloucester,GLO\n\ ,VA,Goochland,GOO\n\ ,VA,Grayson,GRA\n\ ,VA,Greene,GRN\n\ ,VA,Greensville,GVL\n\ ,VA,Halifax,HAL\n\ ,VA,Hampton,HAX\n\ ,VA,Hanover,HAN\n\ ,VA,Harrisonburg,HBX\n\ ,VA,Henrico,HCO\n\ ,VA,Henry,HRY\n\ ,VA,Highland,HIG\n\ ,VA,Hopewell,HOX\n\ ,VA,Isle of Wight,IOW\n\ ,VA,James City,JAM\n\ ,VA,King and Queen,KQN\n\ ,VA,King George,KGE\n\ ,VA,King William,KWM\n\ ,VA,Lancaster,LAN\n\ ,VA,Lee,LEE\n\ ,VA,Lexington,LEX\n\ ,VA,Loudoun,LDN\n\ ,VA,Louisa,LSA\n\ ,VA,Lunenburg,LUN\n\ ,VA,Lynchburg,LYX\n\ ,VA,Madison,MAD\n\ ,VA,Manassas,MAX\n\ ,VA,Manassas Park,MPX\n\ ,VA,Martinsville,MVX\n\ ,VA,Mathews,MAT\n\ ,VA,Mecklenburg,MEC\n\ ,VA,Middlesex,MID\n\ ,VA,Montgomery,MON\n\ ,VA,Nelson,NEL\n\ ,VA,New Kent,NEW\n\ ,VA,Newport News,NNX\n\ ,VA,Norfolk,NFX\n\ ,VA,Northampton,NHA\n\ ,VA,Northumberland,NUM\n\ ,VA,Norton,NRX\n\ ,VA,Nottoway,NOT\n\ ,VA,Orange,ORG\n\ ,VA,Page,PAG\n\ ,VA,Patrick,PAT\n\ ,VA,Petersburg,PBX\n\ ,VA,Pittsylvania,PIT\n\ ,VA,Poquoson,PQX\n\ ,VA,Portsmouth,POX\n\ ,VA,Powhatan,POW\n\ ,VA,Prince Edward,PRE\n\ ,VA,Prince George,PRG\n\ ,VA,Prince William,PRW\n\ ,VA,Pulaski,PUL\n\ ,VA,Radford,RAX\n\ ,VA,Rappahannock,RAP\n\ ,VA,Richmond,RIC\n\ ,VA,Richmond City,RIX\n\ ,VA,Roanoke,ROA\n\ ,VA,Roanoke City,ROX\n\ ,VA,Rockbridge,RBR\n\ ,VA,Rockingham,RHM\n\ ,VA,Russell,RUS\n\ ,VA,Salem,SAX\n\ ,VA,Scott,SCO\n\ ,VA,Shenandoah,SHE\n\ ,VA,Smyth,SMY\n\ ,VA,Southampton,SHA\n\ ,VA,Spotsylvania,SPO\n\ ,VA,Stafford,STA\n\ ,VA,Staunton,STX\n\ ,VA,Suffolk,SUX\n\ ,VA,Surry,SUR\n\ ,VA,Sussex,SUS\n\ ,VA,Tazewell,TAZ\n\ ,VA,Virginia Beach,VBX\n\ ,VA,Warren,WAR\n\ ,VA,Washington,WAS\n\ ,VA,Waynesboro,WAX\n\ ,VA,Westmoreland,WES\n\ ,VA,Williamsburg,WMX\n\ ,VA,Winchester,WIX\n\ ,VA,Wise,WIS\n\ ,VA,Wythe,WYT\n\ ,VA,York,YOR\n\ U.S. Virgin Islands,VI,St. Croix Island,\n\ ,VI,St. John Island,\n\ ,VI,St. Thomas Island,\n\ Washington,WA,Adams,ADA\n\ ,WA,Asotin,ASO\n\ ,WA,Benton,BEN\n\ ,WA,Chelan,CHE\n\ ,WA,Clallam,CLAL\n\ ,WA,Clark,CLAR\n\ ,WA,Columbia,COL\n\ ,WA,Cowlitz,COW\n\ ,WA,Douglas,DOU\n\ ,WA,Ferry,FER\n\ ,WA,Franklin,FRA\n\ ,WA,Garfield,GAR\n\ ,WA,Grant,GRAN\n\ ,WA,Grays Harbor,GRAY\n\ ,WA,Island,ISL\n\ ,WA,Jefferson,JEFF\n\ ,WA,King,KING\n\ ,WA,Kitsap,KITS\n\ ,WA,Kittitas,KITT\n\ ,WA,Klickitat,KLI\n\ ,WA,Lewis,LEW\n\ ,WA,Lincoln,LIN\n\ ,WA,Mason,MAS\n\ ,WA,Okanogan,OKA\n\ ,WA,Pacific,PAC\n\ ,WA,Pend Oreille,PEND\n\ ,WA,Pierce,PIE\n\ ,WA,San Juan,SAN\n\ ,WA,Skagit,SKAG\n\ ,WA,Skamania,SKAM\n\ ,WA,Snohomish,SNO\n\ ,WA,Spokane,SPO\n\ ,WA,Stevens,STE\n\ ,WA,Thurston,THU\n\ ,WA,Wahkiakum,WAH\n\ ,WA,Walla Walla,WAL\n\ ,WA,Whatcom,WHA\n\ ,WA,Whitman,WHI\n\ ,WA,Yakima,YAK\n\ Wisconsin,WI,Adams,ADA\n\ ,WI,Ashland,ASH\n\ ,WI,Barron,BAR\n\ ,WI,Bayfield,BAY\n\ ,WI,Brown,BRO\n\ ,WI,Buffalo,BUF\n\ ,WI,Burnett,BUR\n\ ,WI,Calumet,CAL\n\ ,WI,Chippewa,CHI\n\ ,WI,Clark,CLA\n\ ,WI,Columbia,COL\n\ ,WI,Crawford,CRA\n\ ,WI,Dane,DAN\n\ ,WI,Dodge,DOD\n\ ,WI,Door,DOO\n\ ,WI,Douglas,DOU\n\ ,WI,Dunn,DUN\n\ ,WI,Eau Claire,EAU\n\ ,WI,Florence,FLO\n\ ,WI,Fond du Lac,FON\n\ ,WI,Forest,FOR\n\ ,WI,Grant,GRA\n\ ,WI,Green,GRE\n\ ,WI,Green Lake,GRL\n\ ,WI,Iowa,IOW\n\ ,WI,Iron,IRO\n\ ,WI,Jackson,JAC\n\ ,WI,Jefferson,JEF\n\ ,WI,Juneau,JUN\n\ ,WI,Kenosha,KEN\n\ ,WI,Kewaunee,KEW\n\ ,WI,La Crosse,LAC\n\ ,WI,Lafayette,LAF\n\ ,WI,Langlade,LAN\n\ ,WI,Lincoln,LIN\n\ ,WI,Manitowoc,MAN\n\ ,WI,Marathon,MAR\n\ ,WI,Marinette,MRN\n\ ,WI,Marquette,MRQ\n\ ,WI,Menominee,MEN\n\ ,WI,Milwaukee,MIL\n\ ,WI,Monroe,MON\n\ ,WI,Oconto,OCO\n\ ,WI,Oneida,ONE\n\ ,WI,Outagamie,OUT\n\ ,WI,Ozaukee,OZA\n\ ,WI,Pepin,PEP\n\ ,WI,Pierce,PIE\n\ ,WI,Polk,POL\n\ ,WI,Portage,POR\n\ ,WI,Price,PRI\n\ ,WI,Racine,RAC\n\ ,WI,Richland,RIC\n\ ,WI,Rock,ROC\n\ ,WI,Rusk,RUS\n\ ,WI,Sauk,SAU\n\ ,WI,Sawyer,SAW\n\ ,WI,Shawano,SHA\n\ ,WI,Sheboygan,SHE\n\ ,WI,St. Croix,STC\n\ ,WI,Taylor,TAY\n\ ,WI,Trempealeau,TRE\n\ ,WI,Vernon,VER\n\ ,WI,Vilas,VIL\n\ ,WI,Walworth,WAL\n\ ,WI,Washburn,WSB\n\ ,WI,Washington,WAS\n\ ,WI,Waukesha,WAU\n\ ,WI,Waupaca,WAP\n\ ,WI,Waushara,WSR\n\ ,WI,Winnebago,WIN\n\ ,WI,Wood,WOO\n\ West Virginia,WV,Barbour,BAR\n\ ,WV,Berkeley,BER\n\ ,WV,Boone,BOO\n\ ,WV,Braxton,BRA\n\ ,WV,Brooke,BRO\n\ ,WV,Cabell,CAB\n\ ,WV,Calhoun,CAL\n\ ,WV,Clay,CLA\n\ ,WV,Doddridge,DOD\n\ ,WV,Fayette,FAY\n\ ,WV,Gilmer,GIL\n\ ,WV,Grant,GRA\n\ ,WV,Greenbrier,GRE\n\ ,WV,Hampshire,HAM\n\ ,WV,Hancock,HAN\n\ ,WV,Hardy,HDY\n\ ,WV,Harrison,HAR\n\ ,WV,Jackson,JAC\n\ ,WV,Jefferson,JEF\n\ ,WV,Kanawha,KAN\n\ ,WV,Lewis,LEW\n\ ,WV,Lincoln,LIN\n\ ,WV,Logan,LOG\n\ ,WV,Marion,MRN\n\ ,WV,Marshall,MAR\n\ ,WV,Mason,MAS\n\ ,WV,McDowell,MCD\n\ ,WV,Mercer,MER\n\ ,WV,Mineral,MIN\n\ ,WV,Mingo,MGO\n\ ,WV,Monongalia,MON\n\ ,WV,Monroe,MRO\n\ ,WV,Morgan,MOR\n\ ,WV,Nicholas,NIC\n\ ,WV,Ohio,OHI\n\ ,WV,Pendleton,PEN\n\ ,WV,Pleasants,PLE\n\ ,WV,Pocahontas,POC\n\ ,WV,Preston,PRE\n\ ,WV,Putnam,PUT\n\ ,WV,Raleigh,RAL\n\ ,WV,Randolph,RAN\n\ ,WV,Ritchie,RIT\n\ ,WV,Roane,ROA\n\ ,WV,Summers,SUM\n\ ,WV,Taylor,TAY\n\ ,WV,Tucker,TUC\n\ ,WV,Tyler,TYL\n\ ,WV,Upshur,UPS\n\ ,WV,Wayne,WAY\n\ ,WV,Webster,WEB\n\ ,WV,Wetzel,WET\n\ ,WV,Wirt,WIR\n\ ,WV,Wood,WOO\n\ ,WV,Wyoming,WYO\n\ Wyoming,WY,Albany,ALB\n\ ,WY,Big Horn,BIG\n\ ,WY,Campbell,CAM\n\ ,WY,Carbon,CAR\n\ ,WY,Converse,CON\n\ ,WY,Crook,CRO\n\ ,WY,Fremont,FRE\n\ ,WY,Goshen,GOS\n\ ,WY,Hot Springs,HOT\n\ ,WY,Johnson,JOH\n\ ,WY,Laramie,LAR\n\ ,WY,Lincoln,LIN\n\ ,WY,Natrona,NAT\n\ ,WY,Niobrara,NIO\n\ ,WY,Park,PAR\n\ ,WY,Platte,PLA\n\ ,WY,Sheridan,SHE\n\ ,WY,Sublette,SUB\n\ ,WY,Sweetwater,SWE\n\ ,WY,Teton,TET\n\ ,WY,Uinta,UIN\n\ ,WY,Washakie,WAS\n\ ,WY,Weston,WES\n\ Yukon,YT,Carmacks,\n\ ,YT,Dawson,\n\ ,YT,Faro,\n\ ,YT,Haines Junction,\n\ ,YT,Mayo,\n\ ,YT,Teslin,\n\ ,YT,Watson Lake,\n\ ,YT,Whitehorse,\n"; //std::string strNEQP const char *szNEQP = "\ State, ST, County/City, CC\n\ Connecticut,CT,Fairfield,FAICT\n\ ,CT,Hartford,HARCT\n\ ,CT,Litchfield,LITCT\n\ ,CT,Middlesex,MIDCT\n\ ,CT,New Haven,NHVCT\n\ ,CT,New London,NLNCT\n\ ,CT,Tolland,TOLCT\n\ ,CT,Windham,WINCT\n\ Massechusetts,MA,Barnstable,BARMA\n\ ,MA,Berkshire,BERMA\n\ ,MA,Bristol,BRIMA\n\ ,MA,Dukes,DUKMA\n\ ,MA,Essex,ESSMA\n\ ,MA,Franklin,FRAMA\n\ ,MA,Hampden,HMDMA\n\ ,MA,Hampshire,HMPMA\n\ ,MA,Middlesex,MIDMA\n\ ,MA,Nantucket,NANMA\n\ ,MA,Norfolk,NORMA\n\ ,MA,Plymouth,PLYMA\n\ ,MA,Suffolk,SUFMA\n\ ,MA,Worcester,WORMA\n\ Maine,ME,Androscoggin,ANDME\n\ ,ME,Aroostook,AROME\n\ ,ME,Cumberland,CUMME\n\ ,ME,Franklin,FRAME\n\ ,ME,Hancock,HANME\n\ ,ME,Kennebec,KENME\n\ ,ME,Knox,KNOME\n\ ,ME,Lincoln,LINME\n\ ,ME,Oxford,OXFME\n\ ,ME,Penobscot,PENME\n\ ,ME,Piscataquis,PISME\n\ ,ME,Sagadahoc,SAGME\n\ ,ME,Somerset,SOMME\n\ ,ME,Waldo,WALME\n\ ,ME,Washington,WASME\n\ ,ME,York,YORME\n\ New Hampshire,NH,Belknap,BELNH\n\ ,NH,Carroll,CARNH\n\ ,NH,Cheshire,CHENH\n\ ,NH,Coos,COONH\n\ ,NH,Grafton,GRANH\n\ ,NH,Hillsborough,HILNH\n\ ,NH,Merrimack,MERNH\n\ ,NH,Rockingham,ROCNH\n\ ,NH,Strafford,STRNH\n\ ,NH,Sullivan,SULNH\n\ Rhode Island,RI,Bristol,BRIRI\n\ ,RI,Kent,KENRI\n\ ,RI,Newport,NEWRI\n\ ,RI,Providence,PRORI\n\ ,RI,Washington,WASRI\n\ Vermont,VT,Addison,ADDVT\n\ ,VT,Bennington,BENVT\n\ ,VT,Caledonia,CALVT\n\ ,VT,Chittenden,CHIVT\n\ ,VT,Essex,ESSVT\n\ ,VT,Franklin,FRAVT\n\ ,VT,Grand Isle,GRAVT\n\ ,VT,Lamoille,LAMVT\n\ ,VT,Orange,ORAVT\n\ ,VT,Orleans,ORLVT\n\ ,VT,Rutland,RUTVT\n\ ,VT,Washington,WASVT\n\ ,VT,Windham,WNHVT\n\ ,VT,Windsor,WNDVT\n"; //std::string str7QP const char *sz7QP = "\ State, ST, County/City, CC\n\ Arizona,AZ,Apache,AZAPH\n\ ,AZ,Cochise,AZCHS\n\ ,AZ,Coconino,AZCNO\n\ ,AZ,Gila,AZGLA\n\ ,AZ,Graham,AZGHM\n\ ,AZ,Greenlee,AZGLE\n\ ,AZ,La Paz,AZLPZ\n\ ,AZ,Maricopa,AZMCP\n\ ,AZ,Mohave,AZMHV\n\ ,AZ,Navajo,AZNVO\n\ ,AZ,Pima,AZPMA\n\ ,AZ,Pinal,AZPNL\n\ ,AZ,Santa Cruz,AZSCZ\n\ ,AZ,Yavapai,AZYVP\n\ ,AZ,Yuma,AZYMA\n\ Idaho,ID,Ada,IDADA\n\ ,ID,Adams,IDADM\n\ ,ID,Bannock,IDBAN\n\ ,ID,Bear Lake,IDBEA\n\ ,ID,Benewah,IDBEN\n\ ,ID,Bingham,IDBIN\n\ ,ID,Blaine,IDBLA\n\ ,ID,Boise,IDBOI\n\ ,ID,Bonner,IDBNR\n\ ,ID,Bonneville,IDBNV\n\ ,ID,Boundary,IDBOU\n\ ,ID,Butte,IDBUT\n\ ,ID,Camas,IDCAM\n\ ,ID,Canyon,IDCAN\n\ ,ID,Caribou,IDCAR\n\ ,ID,Cassia,IDCAS\n\ ,ID,Clark,IDCLA\n\ ,ID,Clearwater,IDCLE\n\ ,ID,Custer,IDCUS\n\ ,ID,Elmore,IDELM\n\ ,ID,Franklin,IDFRA\n\ ,ID,Fremont,IDFRE\n\ ,ID,Gem,IDGEM\n\ ,ID,Gooding,IDGOO\n\ ,ID,Idaho,IDIDA\n\ ,ID,Jefferson,IDJEF\n\ ,ID,Jerome,IDJER\n\ ,ID,Kootenai,IDKOO\n\ ,ID,Latah,IDLAT\n\ ,ID,Lemhi,IDLEM\n\ ,ID,Lewis,IDLEW\n\ ,ID,Lincoln,IDLIN\n\ ,ID,Madison,IDMAD\n\ ,ID,Minidoka,IDMIN\n\ ,ID,Nez Perce,IDNEZ\n\ ,ID,Oneida,IDONE\n\ ,ID,Owyhee,IDOWY\n\ ,ID,Payette,IDPAY\n\ ,ID,Power,IDPOW\n\ ,ID,Shoshone,IDSHO\n\ ,ID,Teton,IDTET\n\ ,ID,Twin Falls,IDTWI\n\ ,ID,Valley,IDVAL\n\ ,ID,Washington,IDWAS\n\ Montana,MT,Beaverhead,MTBEA\n\ ,MT,Big Horn,MTBIG\n\ ,MT,Blaine,MTBLA\n\ ,MT,Broadwater,MTBRO\n\ ,MT,Carbon,MTCRB\n\ ,MT,Carter,MTCRT\n\ ,MT,Cascade,MTCAS\n\ ,MT,Chouteau,MTCHO\n\ ,MT,Custer,MTCUS\n\ ,MT,Daniels,MTDAN\n\ ,MT,Dawson,MTDAW\n\ ,MT,Deer Lodge,MTDEE\n\ ,MT,Fallon,MTFAL\n\ ,MT,Fergus,MTFER\n\ ,MT,Flathead,MTFLA\n\ ,MT,Gallatin,MTGAL\n\ ,MT,Garfield,MTGAR\n\ ,MT,Glacier,MTGLA\n\ ,MT,Golden Valley,MTGOL\n\ ,MT,Granite,MTGRA\n\ ,MT,Hill,MTHIL\n\ ,MT,Jefferson,MTJEF\n\ ,MT,Judith Basin,MTJUD\n\ ,MT,Lake,MTLAK\n\ ,MT,Lewis & Clark,MTLEW\n\ ,MT,Liberty,MTLIB\n\ ,MT,Lincoln,MTLIN\n\ ,MT,Madison,MTMAD\n\ ,MT,McCone,MTMCC\n\ ,MT,Meagher,MTMEA\n\ ,MT,Mineral,MTMIN\n\ ,MT,Missoula,MTMIS\n\ ,MT,Musselshell,MTMUS\n\ ,MT,Park,MTPAR\n\ ,MT,Petroleum,MTPET\n\ ,MT,Phillips,MTPHI\n\ ,MT,Pondera,MTPON\n\ ,MT,Powder River,MTPWD\n\ ,MT,Powell,MTPWL\n\ ,MT,Prairie,MTPRA\n\ ,MT,Ravalli,MTRAV\n\ ,MT,Richland,MTRIC\n\ ,MT,Roosevelt,MTROO\n\ ,MT,Rosebud,MTROS\n\ ,MT,Sanders,MTSAN\n\ ,MT,Sheridan,MTSHE\n\ ,MT,Silver Bow,MTSIL\n\ ,MT,Stillwater,MTSTI\n\ ,MT,Sweet Grass,MTSWE\n\ ,MT,Teton,MTTET\n\ ,MT,Toole,MTTOO\n\ ,MT,Treasure,MTTRE\n\ ,MT,Valley,MTVAL\n\ ,MT,Wheatland,MTWHE\n\ ,MT,Wibaux,MTWIB\n\ ,MT,Yellowstone,MTYEL\n\ Nevada,NV,Carson City,NVCAR\n\ ,NV,Churchill,NVCHU\n\ ,NV,Clark,NVCLA\n\ ,NV,Douglas,NVDOU\n\ ,NV,Elko,NVELK\n\ ,NV,Esmeralda,NVESM\n\ ,NV,Eureka,NVEUR\n\ ,NV,Humboldt,NVHUM\n\ ,NV,Lander,NVLAN\n\ ,NV,Lincoln,NVLIN\n\ ,NV,Lyon,NVLYO\n\ ,NV,Mineral,NVMIN\n\ ,NV,Nye,NVNYE\n\ ,NV,Pershing,NVPER\n\ ,NV,Storey,NVSTO\n\ ,NV,Washoe,NVWAS\n\ ,NV,White Pine,NVWHI\n\ Oregon,OR,Baker,ORBAK\n\ ,OR,Benton,ORBEN\n\ ,OR,Clackamas,ORCLK\n\ ,OR,Clatsop,ORCLT\n\ ,OR,Columbia,ORCOL\n\ ,OR,Coos,ORCOO\n\ ,OR,Crook,ORCRO\n\ ,OR,Curry,ORCUR\n\ ,OR,Deschutes,ORDES\n\ ,OR,Douglas,ORDOU\n\ ,OR,Gilliam,ORGIL\n\ ,OR,Grant,ORGRA\n\ ,OR,Harney,ORHAR\n\ ,OR,Hood River,ORHOO\n\ ,OR,Jackson,ORJAC\n\ ,OR,Jefferson,ORJEF\n\ ,OR,Josephine,ORJOS\n\ ,OR,Klamath,ORKLA\n\ ,OR,Lake,ORLAK\n\ ,OR,Lane,ORLAN\n\ ,OR,Lincoln,ORLCN\n\ ,OR,Linn,ORLNN\n\ ,OR,Malheur,ORMAL\n\ ,OR,Marion,ORMAR\n\ ,OR,Morrow,ORMOR\n\ ,OR,Multnomah,ORMUL\n\ ,OR,Polk,ORPOL\n\ ,OR,Sherman,ORSHE\n\ ,OR,Tillamook,ORTIL\n\ ,OR,Umatilla,ORUMA\n\ ,OR,Union,ORUNI\n\ ,OR,Wallowa,ORWAL\n\ ,OR,Wasco,ORWCO\n\ ,OR,Washington,ORWSH\n\ ,OR,Wheeler,ORWHE\n\ ,OR,Yamhill,ORYAM\n\ Utah,UT,Beaver,UTBEA\n\ ,UT,Box Elder,UTBOX\n\ ,UT,Cache,UTCAC\n\ ,UT,Carbon,UTCAR\n\ ,UT,Daggett,UTDAG\n\ ,UT,Davis,UTDAV\n\ ,UT,Duchesne,UTDUC\n\ ,UT,Emery,UTEME\n\ ,UT,Garfield,UTGAR\n\ ,UT,Grand,UTGRA\n\ ,UT,Iron,UTIRO\n\ ,UT,Juab,UTJUA\n\ ,UT,Kane,UTKAN\n\ ,UT,Millard,UTMIL\n\ ,UT,Morgan,UTMOR\n\ ,UT,Piute,UTPIU\n\ ,UT,Rich,UTRIC\n\ ,UT,Salt Lake,UTSAL\n\ ,UT,San Juan,UTSNJ\n\ ,UT,Sanpete,UTSNP\n\ ,UT,Sevier,UTSEV\n\ ,UT,Summit,UTSUM\n\ ,UT,Tooele,UTTOO\n\ ,UT,Uintah,UTUIN\n\ ,UT,Utah,UTUTA\n\ ,UT,Wasatch,UTWST\n\ ,UT,Washington,UTWSH\n\ ,UT,Wayne,UTWAY\n\ ,UT,Weber,UTWEB\n\ Washington,WA,Adams,WAADA\n\ ,WA,Asotin,WAASO\n\ ,WA,Benton,WABEN\n\ ,WA,Chelan,WACHE\n\ ,WA,Clallam,WACLL\n\ ,WA,Clark,WACLR\n\ ,WA,Columbia,WACOL\n\ ,WA,Cowlitz,WACOW\n\ ,WA,Douglas,WADOU\n\ ,WA,Ferry,WAFER\n\ ,WA,Franklin,WAFRA\n\ ,WA,Garfield,WAGAR\n\ ,WA,Grant,WAGRN\n\ ,WA,Grays Harbor,WAGRY\n\ ,WA,Island,WAISL\n\ ,WA,Jefferson,WAJEF\n\ ,WA,Klickitat,WAKLI\n\ ,WA,King,WAKNG\n\ ,WA,Kitsap,WAKTP\n\ ,WA,Kittitas,WAKTT\n\ ,WA,Lewis,WALEW\n\ ,WA,Lincoln,WALIN\n\ ,WA,Mason,WAMAS\n\ ,WA,Okanogan,WAOKA\n\ ,WA,Pacific,WAPAC\n\ ,WA,Pend Oreille,WAPEN\n\ ,WA,Pierce,WAPIE\n\ ,WA,San Juan,WASAN\n\ ,WA,Skagit,WASKG\n\ ,WA,Skamania,WASKM\n\ ,WA,Snohomish,WASNO\n\ ,WA,Spokane,WASPO\n\ ,WA,Stevens,WASTE\n\ ,WA,Thurston,WATHU\n\ ,WA,Wahkiakum,WAWAH\n\ ,WA,Walla Walla,WAWAL\n\ ,WA,Whatcom,WAWHA\n\ ,WA,Whitman,WAWHI\n\ ,WA,Yakima,WAYAK\n\ Wyoming,WY,Albany,WYALB\n\ ,WY,Big Horn,WYBIG\n\ ,WY,Campbell,WYCAM\n\ ,WY,Carbon,WYCAR\n\ ,WY,Converse,WYCON\n\ ,WY,Crook,WYCRO\n\ ,WY,Fremont,WYFRE\n\ ,WY,Goshen,WYGOS\n\ ,WY,Hot Springs,WYHOT\n\ ,WY,Johnson,WYJOH\n\ ,WY,Laramie,WYLAR\n\ ,WY,Lincoln,WYLIN\n\ ,WY,Natrona,WYNAT\n\ ,WY,Niobrara,WYNIO\n\ ,WY,Park,WYPAR\n\ ,WY,Platte,WYPLA\n\ ,WY,Sheridan,WYSHE\n\ ,WY,Sublette,WYSUB\n\ ,WY,Sweetwater,WYSWE\n\ ,WY,Teton,WYTET\n\ ,WY,Uinta,WYUIN\n\ ,WY,Washakie,WYWAS\n\ ,WY,Weston,WYWES\n";
79,108
C++
.cxx
3,831
19.641086
79
0.730501
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,250
fd_view.cxx
w1hkj_fldigi/src/logbook/fd_view.cxx
// generated by Fast Light User Interface Designer (fluid) version 1.0305 #include "gettext.h" #include "fd_view.h" #include "configuration.h" Fl_Output *view_FD_call=(Fl_Output *)0; Fl_Output *view_FD_class=(Fl_Output *)0; Fl_Output *view_FD_section=(Fl_Output *)0; Fl_Output *view_FD_mult=(Fl_Output *)0; Fl_Output *view_FD_score=(Fl_Output *)0; Fl_Output *view_FD_CW[12]={(Fl_Output *)0}; Fl_Output *view_FD_CW_OP[12]={(Fl_Output *)0}; Fl_Output *view_FD_DIG[12]={(Fl_Output *)0}; Fl_Output *view_FD_DIG_OP[12]={(Fl_Output *)0}; Fl_Output *view_FD_PHONE[12]={(Fl_Output *)0}; Fl_Output *view_FD_PHONE_OP[12]={(Fl_Output *)0}; Fl_Input2 *inp_fd_tcpip_addr=(Fl_Input2 *)0; static void cb_inp_fd_tcpip_addr(Fl_Input2* o, void*) { progdefaults.fd_tcpip_addr=o->value(); progdefaults.changed = true; } Fl_Input2 *inp_fd_tcpip_port=(Fl_Input2 *)0; static void cb_inp_fd_tcpip_port(Fl_Input2* o, void*) { progdefaults.fd_tcpip_port=o->value(); progdefaults.changed = true; } Fl_Input2 *inp_fd_op_call=(Fl_Input2 *)0; static void cb_inp_fd_op_call(Fl_Input2* o, void*) { progdefaults.fd_op_call=o->value(); progdefaults.changed = true; } Fl_Check_Button *btn_fd_connect=(Fl_Check_Button *)0; static void cb_btn_fd_connect(Fl_Check_Button* o, void*) { progdefaults.connect_to_fdserver=o->value(); if (progdefaults.connect_to_fdserver) { listbox_contest->index(LOG_FD); progdefaults.logging = LOG_FD; } else { listbox_contest->index(LOG_QSO); progdefaults.logging = LOG_QSO; } UI_select(); } Fl_Box *box_fdserver_connected=(Fl_Box *)0; Fl_Double_Window* make_fd_view() { Fl_Double_Window* w; { Fl_Double_Window* o = new Fl_Double_Window(670, 270, _("Field Day Viewer - use with program \'fdserver\'")); w = o; if (w) {/* empty */} o->align(Fl_Align(FL_ALIGN_TOP_LEFT)); { Fl_Output* o = view_FD_call = new Fl_Output(59, 6, 77, 24, _("FD Call")); o->value(progdefaults.my_FD_call.c_str()); } // Fl_Output* view_FD_call { Fl_Output* o = view_FD_class = new Fl_Output(219, 5, 38, 24, _("FD Class")); o->value(progdefaults.my_FD_class.c_str()); } // Fl_Output* view_FD_class { Fl_Output* o = view_FD_section = new Fl_Output(341, 5, 38, 24, _("FD Section")); o->value(progdefaults.my_FD_section.c_str()); } // Fl_Output* view_FD_section { Fl_Output* o = view_FD_mult = new Fl_Output(462, 5, 38, 24, _("FD Mult")); o->value(progdefaults.my_FD_mult.c_str()); } // Fl_Output* view_FD_mult { view_FD_score = new Fl_Output(584, 5, 80, 24, _("Score")); } // Fl_Output* view_FD_score { view_FD_CW[0] = new Fl_Output(55, 49, 50, 24, _("CW")); view_FD_CW[0]->textfont(4); view_FD_CW[0]->textsize(12); } // Fl_Output* view_FD_CW[0] { view_FD_CW[1] = new Fl_Output(106, 49, 50, 24); view_FD_CW[1]->textfont(4); view_FD_CW[1]->textsize(12); view_FD_CW[1]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW[1] { view_FD_CW[2] = new Fl_Output(156, 49, 50, 24); view_FD_CW[2]->textfont(4); view_FD_CW[2]->textsize(12); view_FD_CW[2]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW[2] { view_FD_CW[3] = new Fl_Output(207, 49, 50, 24); view_FD_CW[3]->textfont(4); view_FD_CW[3]->textsize(12); view_FD_CW[3]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW[3] { view_FD_CW[4] = new Fl_Output(258, 49, 50, 24); view_FD_CW[4]->textfont(4); view_FD_CW[4]->textsize(12); view_FD_CW[4]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW[4] { view_FD_CW[5] = new Fl_Output(309, 49, 50, 24); view_FD_CW[5]->textfont(4); view_FD_CW[5]->textsize(12); view_FD_CW[5]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW[5] { view_FD_CW[6] = new Fl_Output(360, 49, 50, 24); view_FD_CW[6]->textfont(4); view_FD_CW[6]->textsize(12); view_FD_CW[6]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW[6] { view_FD_CW[7] = new Fl_Output(411, 49, 50, 24); view_FD_CW[7]->textfont(4); view_FD_CW[7]->textsize(12); view_FD_CW[7]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW[7] { view_FD_CW[8] = new Fl_Output(462, 49, 50, 24); view_FD_CW[8]->textfont(4); view_FD_CW[8]->textsize(12); view_FD_CW[8]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW[8] { view_FD_CW[9] = new Fl_Output(513, 49, 50, 24); view_FD_CW[9]->textfont(4); view_FD_CW[9]->textsize(12); view_FD_CW[9]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW[9] { view_FD_CW[10] = new Fl_Output(564, 49, 50, 24); view_FD_CW[10]->textfont(4); view_FD_CW[10]->textsize(12); view_FD_CW[10]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW[10] { view_FD_CW[11] = new Fl_Output(615, 49, 50, 24); view_FD_CW[11]->textfont(4); view_FD_CW[11]->textsize(12); view_FD_CW[11]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW[11] { view_FD_CW_OP[0] = new Fl_Output(55, 75, 50, 24, _("Oper\'")); view_FD_CW_OP[0]->textfont(4); view_FD_CW_OP[0]->textsize(12); } // Fl_Output* view_FD_CW_OP[0] { view_FD_CW_OP[1] = new Fl_Output(106, 73, 50, 24); view_FD_CW_OP[1]->textfont(4); view_FD_CW_OP[1]->textsize(12); view_FD_CW_OP[1]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW_OP[1] { view_FD_CW_OP[2] = new Fl_Output(156, 73, 50, 24); view_FD_CW_OP[2]->textfont(4); view_FD_CW_OP[2]->textsize(12); view_FD_CW_OP[2]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW_OP[2] { view_FD_CW_OP[3] = new Fl_Output(207, 73, 50, 24); view_FD_CW_OP[3]->textfont(4); view_FD_CW_OP[3]->textsize(12); view_FD_CW_OP[3]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW_OP[3] { view_FD_CW_OP[4] = new Fl_Output(258, 73, 50, 24); view_FD_CW_OP[4]->textfont(4); view_FD_CW_OP[4]->textsize(12); view_FD_CW_OP[4]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW_OP[4] { view_FD_CW_OP[5] = new Fl_Output(309, 73, 50, 24); view_FD_CW_OP[5]->textfont(4); view_FD_CW_OP[5]->textsize(12); view_FD_CW_OP[5]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW_OP[5] { view_FD_CW_OP[6] = new Fl_Output(360, 73, 50, 24); view_FD_CW_OP[6]->textfont(4); view_FD_CW_OP[6]->textsize(12); view_FD_CW_OP[6]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW_OP[6] { view_FD_CW_OP[7] = new Fl_Output(411, 73, 50, 24); view_FD_CW_OP[7]->textfont(4); view_FD_CW_OP[7]->textsize(12); view_FD_CW_OP[7]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW_OP[7] { view_FD_CW_OP[8] = new Fl_Output(462, 73, 50, 24); view_FD_CW_OP[8]->textfont(4); view_FD_CW_OP[8]->textsize(12); view_FD_CW_OP[8]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW_OP[8] { view_FD_CW_OP[9] = new Fl_Output(513, 73, 50, 24); view_FD_CW_OP[9]->textfont(4); view_FD_CW_OP[9]->textsize(12); view_FD_CW_OP[9]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW_OP[9] { view_FD_CW_OP[10] = new Fl_Output(564, 73, 50, 24); view_FD_CW_OP[10]->textfont(4); view_FD_CW_OP[10]->textsize(12); view_FD_CW_OP[10]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW_OP[10] { view_FD_CW_OP[11] = new Fl_Output(615, 73, 50, 24); view_FD_CW_OP[11]->textfont(4); view_FD_CW_OP[11]->textsize(12); view_FD_CW_OP[11]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_CW_OP[11] { view_FD_DIG[0] = new Fl_Output(55, 102, 50, 24, _("DIG")); view_FD_DIG[0]->textfont(4); view_FD_DIG[0]->textsize(12); } // Fl_Output* view_FD_DIG[0] { view_FD_DIG[1] = new Fl_Output(106, 103, 50, 24); view_FD_DIG[1]->textfont(4); view_FD_DIG[1]->textsize(12); view_FD_DIG[1]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG[1] { view_FD_DIG[2] = new Fl_Output(156, 103, 50, 24); view_FD_DIG[2]->textfont(4); view_FD_DIG[2]->textsize(12); view_FD_DIG[2]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG[2] { view_FD_DIG[3] = new Fl_Output(207, 103, 50, 24); view_FD_DIG[3]->textfont(4); view_FD_DIG[3]->textsize(12); view_FD_DIG[3]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG[3] { view_FD_DIG[4] = new Fl_Output(258, 103, 50, 24); view_FD_DIG[4]->textfont(4); view_FD_DIG[4]->textsize(12); view_FD_DIG[4]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG[4] { view_FD_DIG[5] = new Fl_Output(309, 103, 50, 24); view_FD_DIG[5]->textfont(4); view_FD_DIG[5]->textsize(12); view_FD_DIG[5]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG[5] { view_FD_DIG[6] = new Fl_Output(360, 103, 50, 24); view_FD_DIG[6]->textfont(4); view_FD_DIG[6]->textsize(12); view_FD_DIG[6]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG[6] { view_FD_DIG[7] = new Fl_Output(411, 103, 50, 24); view_FD_DIG[7]->textfont(4); view_FD_DIG[7]->textsize(12); view_FD_DIG[7]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG[7] { view_FD_DIG[8] = new Fl_Output(462, 103, 50, 24); view_FD_DIG[8]->textfont(4); view_FD_DIG[8]->textsize(12); view_FD_DIG[8]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG[8] { view_FD_DIG[9] = new Fl_Output(513, 103, 50, 24); view_FD_DIG[9]->textfont(4); view_FD_DIG[9]->textsize(12); view_FD_DIG[9]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG[9] { view_FD_DIG[10] = new Fl_Output(564, 103, 50, 24); view_FD_DIG[10]->textfont(4); view_FD_DIG[10]->textsize(12); view_FD_DIG[10]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG[10] { view_FD_DIG[11] = new Fl_Output(615, 103, 50, 24); view_FD_DIG[11]->textfont(4); view_FD_DIG[11]->textsize(12); view_FD_DIG[11]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG[11] { view_FD_DIG_OP[0] = new Fl_Output(55, 129, 50, 24, _("Oper\'")); view_FD_DIG_OP[0]->textfont(4); view_FD_DIG_OP[0]->textsize(12); } // Fl_Output* view_FD_DIG_OP[0] { view_FD_DIG_OP[1] = new Fl_Output(106, 128, 50, 24); view_FD_DIG_OP[1]->textfont(4); view_FD_DIG_OP[1]->textsize(12); view_FD_DIG_OP[1]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG_OP[1] { view_FD_DIG_OP[2] = new Fl_Output(156, 128, 50, 24); view_FD_DIG_OP[2]->textfont(4); view_FD_DIG_OP[2]->textsize(12); view_FD_DIG_OP[2]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG_OP[2] { view_FD_DIG_OP[3] = new Fl_Output(207, 128, 50, 24); view_FD_DIG_OP[3]->textfont(4); view_FD_DIG_OP[3]->textsize(12); view_FD_DIG_OP[3]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG_OP[3] { view_FD_DIG_OP[4] = new Fl_Output(258, 128, 50, 24); view_FD_DIG_OP[4]->textfont(4); view_FD_DIG_OP[4]->textsize(12); view_FD_DIG_OP[4]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG_OP[4] { view_FD_DIG_OP[5] = new Fl_Output(309, 128, 50, 24); view_FD_DIG_OP[5]->textfont(4); view_FD_DIG_OP[5]->textsize(12); view_FD_DIG_OP[5]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG_OP[5] { view_FD_DIG_OP[6] = new Fl_Output(360, 128, 50, 24); view_FD_DIG_OP[6]->textfont(4); view_FD_DIG_OP[6]->textsize(12); view_FD_DIG_OP[6]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG_OP[6] { view_FD_DIG_OP[7] = new Fl_Output(411, 128, 50, 24); view_FD_DIG_OP[7]->textfont(4); view_FD_DIG_OP[7]->textsize(12); view_FD_DIG_OP[7]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG_OP[7] { view_FD_DIG_OP[8] = new Fl_Output(462, 128, 50, 24); view_FD_DIG_OP[8]->textfont(4); view_FD_DIG_OP[8]->textsize(12); view_FD_DIG_OP[8]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG_OP[8] { view_FD_DIG_OP[9] = new Fl_Output(513, 128, 50, 24); view_FD_DIG_OP[9]->textfont(4); view_FD_DIG_OP[9]->textsize(12); view_FD_DIG_OP[9]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG_OP[9] { view_FD_DIG_OP[10] = new Fl_Output(564, 128, 50, 24); view_FD_DIG_OP[10]->textfont(4); view_FD_DIG_OP[10]->textsize(12); view_FD_DIG_OP[10]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG_OP[10] { view_FD_DIG_OP[11] = new Fl_Output(615, 128, 50, 24); view_FD_DIG_OP[11]->textfont(4); view_FD_DIG_OP[11]->textsize(12); view_FD_DIG_OP[11]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_DIG_OP[11] { view_FD_PHONE[0] = new Fl_Output(55, 156, 50, 24, _("PHONE")); view_FD_PHONE[0]->textfont(4); view_FD_PHONE[0]->textsize(12); } // Fl_Output* view_FD_PHONE[0] { view_FD_PHONE[1] = new Fl_Output(106, 158, 50, 24); view_FD_PHONE[1]->textfont(4); view_FD_PHONE[1]->textsize(12); view_FD_PHONE[1]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE[1] { view_FD_PHONE[2] = new Fl_Output(156, 158, 50, 24); view_FD_PHONE[2]->textfont(4); view_FD_PHONE[2]->textsize(12); view_FD_PHONE[2]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE[2] { view_FD_PHONE[3] = new Fl_Output(207, 158, 50, 24); view_FD_PHONE[3]->textfont(4); view_FD_PHONE[3]->textsize(12); view_FD_PHONE[3]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE[3] { view_FD_PHONE[4] = new Fl_Output(258, 158, 50, 24); view_FD_PHONE[4]->textfont(4); view_FD_PHONE[4]->textsize(12); view_FD_PHONE[4]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE[4] { view_FD_PHONE[5] = new Fl_Output(309, 158, 50, 24); view_FD_PHONE[5]->textfont(4); view_FD_PHONE[5]->textsize(12); view_FD_PHONE[5]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE[5] { view_FD_PHONE[6] = new Fl_Output(360, 158, 50, 24); view_FD_PHONE[6]->textfont(4); view_FD_PHONE[6]->textsize(12); view_FD_PHONE[6]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE[6] { view_FD_PHONE[7] = new Fl_Output(411, 158, 50, 24); view_FD_PHONE[7]->textfont(4); view_FD_PHONE[7]->textsize(12); view_FD_PHONE[7]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE[7] { view_FD_PHONE[8] = new Fl_Output(462, 158, 50, 24); view_FD_PHONE[8]->textfont(4); view_FD_PHONE[8]->textsize(12); view_FD_PHONE[8]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE[8] { view_FD_PHONE[9] = new Fl_Output(513, 158, 50, 24); view_FD_PHONE[9]->textfont(4); view_FD_PHONE[9]->textsize(12); view_FD_PHONE[9]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE[9] { view_FD_PHONE[10] = new Fl_Output(564, 158, 50, 24); view_FD_PHONE[10]->textfont(4); view_FD_PHONE[10]->textsize(12); view_FD_PHONE[10]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE[10] { view_FD_PHONE[11] = new Fl_Output(615, 158, 50, 24); view_FD_PHONE[11]->textfont(4); view_FD_PHONE[11]->textsize(12); view_FD_PHONE[11]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE[11] { view_FD_PHONE_OP[0] = new Fl_Output(55, 183, 50, 24, _("Oper\'")); view_FD_PHONE_OP[0]->textfont(4); view_FD_PHONE_OP[0]->textsize(12); } // Fl_Output* view_FD_PHONE_OP[0] { view_FD_PHONE_OP[1] = new Fl_Output(106, 183, 50, 24); view_FD_PHONE_OP[1]->textfont(4); view_FD_PHONE_OP[1]->textsize(12); view_FD_PHONE_OP[1]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE_OP[1] { view_FD_PHONE_OP[2] = new Fl_Output(156, 183, 50, 24); view_FD_PHONE_OP[2]->textfont(4); view_FD_PHONE_OP[2]->textsize(12); view_FD_PHONE_OP[2]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE_OP[2] { view_FD_PHONE_OP[3] = new Fl_Output(207, 183, 50, 24); view_FD_PHONE_OP[3]->textfont(4); view_FD_PHONE_OP[3]->textsize(12); view_FD_PHONE_OP[3]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE_OP[3] { view_FD_PHONE_OP[4] = new Fl_Output(258, 183, 50, 24); view_FD_PHONE_OP[4]->textfont(4); view_FD_PHONE_OP[4]->textsize(12); view_FD_PHONE_OP[4]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE_OP[4] { view_FD_PHONE_OP[5] = new Fl_Output(309, 183, 50, 24); view_FD_PHONE_OP[5]->textfont(4); view_FD_PHONE_OP[5]->textsize(12); view_FD_PHONE_OP[5]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE_OP[5] { view_FD_PHONE_OP[6] = new Fl_Output(360, 183, 50, 24); view_FD_PHONE_OP[6]->textfont(4); view_FD_PHONE_OP[6]->textsize(12); view_FD_PHONE_OP[6]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE_OP[6] { view_FD_PHONE_OP[7] = new Fl_Output(411, 183, 50, 24); view_FD_PHONE_OP[7]->textfont(4); view_FD_PHONE_OP[7]->textsize(12); view_FD_PHONE_OP[7]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE_OP[7] { view_FD_PHONE_OP[8] = new Fl_Output(462, 183, 50, 24); view_FD_PHONE_OP[8]->textfont(4); view_FD_PHONE_OP[8]->textsize(12); view_FD_PHONE_OP[8]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE_OP[8] { view_FD_PHONE_OP[9] = new Fl_Output(513, 183, 50, 24); view_FD_PHONE_OP[9]->textfont(4); view_FD_PHONE_OP[9]->textsize(12); view_FD_PHONE_OP[9]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE_OP[9] { view_FD_PHONE_OP[10] = new Fl_Output(564, 183, 50, 24); view_FD_PHONE_OP[10]->textfont(4); view_FD_PHONE_OP[10]->textsize(12); view_FD_PHONE_OP[10]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE_OP[10] { view_FD_PHONE_OP[11] = new Fl_Output(615, 183, 50, 24); view_FD_PHONE_OP[11]->textfont(4); view_FD_PHONE_OP[11]->textsize(12); view_FD_PHONE_OP[11]->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Output* view_FD_PHONE_OP[11] { Fl_Box* o = new Fl_Box(60, 33, 40, 17, _("160")); o->box(FL_FLAT_BOX); } // Fl_Box* o { Fl_Box* o = new Fl_Box(111, 33, 40, 17, _("80")); o->box(FL_FLAT_BOX); } // Fl_Box* o { Fl_Box* o = new Fl_Box(161, 33, 40, 17, _("40")); o->box(FL_FLAT_BOX); } // Fl_Box* o { Fl_Box* o = new Fl_Box(212, 33, 40, 17, _("20")); o->box(FL_FLAT_BOX); } // Fl_Box* o { Fl_Box* o = new Fl_Box(263, 33, 40, 17, _("17")); o->box(FL_FLAT_BOX); } // Fl_Box* o { Fl_Box* o = new Fl_Box(314, 33, 40, 17, _("15")); o->box(FL_FLAT_BOX); } // Fl_Box* o { Fl_Box* o = new Fl_Box(365, 33, 40, 17, _("12")); o->box(FL_FLAT_BOX); } // Fl_Box* o { Fl_Box* o = new Fl_Box(416, 33, 40, 17, _("10")); o->box(FL_FLAT_BOX); } // Fl_Box* o { Fl_Box* o = new Fl_Box(467, 33, 40, 17, _("6")); o->box(FL_FLAT_BOX); } // Fl_Box* o { Fl_Box* o = new Fl_Box(518, 33, 40, 17, _("2")); o->box(FL_FLAT_BOX); } // Fl_Box* o { Fl_Box* o = new Fl_Box(569, 33, 40, 17, _("220")); o->box(FL_FLAT_BOX); } // Fl_Box* o { Fl_Box* o = new Fl_Box(620, 33, 40, 17, _("440")); o->box(FL_FLAT_BOX); } // Fl_Box* o { Fl_Group* o = new Fl_Group(5, 212, 660, 55, _("\"fdserver\" Client")); o->box(FL_ENGRAVED_BOX); o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE)); { Fl_Input2* o = inp_fd_tcpip_addr = new Fl_Input2(85, 234, 150, 24, _("tcpip addr")); inp_fd_tcpip_addr->tooltip(_("fdserver tcipip address")); inp_fd_tcpip_addr->box(FL_DOWN_BOX); inp_fd_tcpip_addr->color(FL_BACKGROUND2_COLOR); inp_fd_tcpip_addr->selection_color(FL_SELECTION_COLOR); inp_fd_tcpip_addr->labeltype(FL_NORMAL_LABEL); inp_fd_tcpip_addr->labelfont(0); inp_fd_tcpip_addr->labelsize(14); inp_fd_tcpip_addr->labelcolor(FL_FOREGROUND_COLOR); inp_fd_tcpip_addr->callback((Fl_Callback*)cb_inp_fd_tcpip_addr); inp_fd_tcpip_addr->align(Fl_Align(FL_ALIGN_LEFT)); inp_fd_tcpip_addr->when(FL_WHEN_RELEASE); o->value(progdefaults.fd_tcpip_addr.c_str()); } // Fl_Input2* inp_fd_tcpip_addr { Fl_Input2* o = inp_fd_tcpip_port = new Fl_Input2(273, 234, 75, 24, _("port")); inp_fd_tcpip_port->tooltip(_("fdserver tcpip port")); inp_fd_tcpip_port->box(FL_DOWN_BOX); inp_fd_tcpip_port->color(FL_BACKGROUND2_COLOR); inp_fd_tcpip_port->selection_color(FL_SELECTION_COLOR); inp_fd_tcpip_port->labeltype(FL_NORMAL_LABEL); inp_fd_tcpip_port->labelfont(0); inp_fd_tcpip_port->labelsize(14); inp_fd_tcpip_port->labelcolor(FL_FOREGROUND_COLOR); inp_fd_tcpip_port->callback((Fl_Callback*)cb_inp_fd_tcpip_port); inp_fd_tcpip_port->align(Fl_Align(FL_ALIGN_LEFT)); inp_fd_tcpip_port->when(FL_WHEN_RELEASE); o->value(progdefaults.fd_tcpip_port.c_str()); } // Fl_Input2* inp_fd_tcpip_port { Fl_Input2* o = inp_fd_op_call = new Fl_Input2(402, 234, 90, 24, _("OP call")); inp_fd_op_call->tooltip(_("free form exchange")); inp_fd_op_call->box(FL_DOWN_BOX); inp_fd_op_call->color(FL_BACKGROUND2_COLOR); inp_fd_op_call->selection_color(FL_SELECTION_COLOR); inp_fd_op_call->labeltype(FL_NORMAL_LABEL); inp_fd_op_call->labelfont(0); inp_fd_op_call->labelsize(14); inp_fd_op_call->labelcolor(FL_FOREGROUND_COLOR); inp_fd_op_call->callback((Fl_Callback*)cb_inp_fd_op_call); inp_fd_op_call->align(Fl_Align(FL_ALIGN_LEFT)); inp_fd_op_call->when(FL_WHEN_RELEASE); o->value(progdefaults.fd_op_call.c_str()); } // Fl_Input2* inp_fd_op_call { Fl_Check_Button* o = btn_fd_connect = new Fl_Check_Button(502, 236, 70, 20, _("Connect")); btn_fd_connect->tooltip(_("Connect / Disconnect^jAddr/Port/OP required")); btn_fd_connect->down_box(FL_DOWN_BOX); btn_fd_connect->callback((Fl_Callback*)cb_btn_fd_connect); o->value(progdefaults.connect_to_fdserver); } // Fl_Check_Button* btn_fd_connect { box_fdserver_connected = new Fl_Box(608, 237, 18, 18, _("Connected")); box_fdserver_connected->box(FL_ROUND_DOWN_BOX); box_fdserver_connected->color((Fl_Color)31); box_fdserver_connected->align(Fl_Align(FL_ALIGN_TOP)); } // Fl_Box* box_fdserver_connected o->end(); } // Fl_Group* o o->end(); } // Fl_Double_Window* o return w; }
24,108
C++
.cxx
514
40.937743
112
0.597404
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,251
logbook.cxx
w1hkj_fldigi/src/logbook/logbook.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <cstring> #include <string> #include <iostream> #include <fstream> #include <FL/Fl.H> #include <FL/filename.H> #include "main.h" #include "logbook.h" #include "logsupport.h" #include "configuration.h" #include "debug.h" #include "qrunner.h" #include "gettext.h" #include "icons.h" void start_logbook () { if (progdefaults.logbookfilename.empty()) { logbook_filename = LogsDir; logbook_filename.append("logbook." ADIF_SUFFIX); progdefaults.logbookfilename = logbook_filename; progdefaults.changed = true; } else logbook_filename = progdefaults.logbookfilename; qsodb.deleteRecs(); rotate_log(logbook_filename); adifFile.readFile (logbook_filename.c_str(), &qsodb); std::string label = "Logbook - "; label.append(fl_filename_name(logbook_filename.c_str())); dlgLogbook->copy_label(label.c_str()); txtLogFile->value(logbook_filename.c_str()); txtLogFile->redraw(); return; } void close_logbook() { // force immediate write to logbook adif file adifFile.writeLog (logbook_filename.c_str(), &qsodb, true); }
1,956
C++
.cxx
58
32.12069
79
0.687003
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,252
n3fjp_logger.cxx
w1hkj_fldigi/src/logbook/n3fjp_logger.cxx
// ===================================================================== // // n3fjp_logger.cxx // // interface to multiple n3fjp tcpip logbook services // // Copyright (C) 2016 // Dave Freese, W1HKJ // Dave Anderson, KA3PMW // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ===================================================================== #include <iostream> #include <sstream> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <time.h> #include <cmath> #include <cstring> #include <vector> #include <list> #include <stdlib.h> #include <time.h> #include <FL/Fl_Text_Display.H> #include <FL/Fl_Text_Buffer.H> #include "threads.h" #include "socket.h" #include "rigsupport.h" #include "modem.h" #include "trx.h" #include "fl_digi.h" #include "configuration.h" #include "main.h" #include "waterfall.h" #include "macros.h" #include "qrunner.h" #include "debug.h" #include "status.h" #include "icons.h" #include "logsupport.h" #include "n3fjp_logger.h" #include "confdialog.h" #include "rigsupport.h" #include "contest.h" #include "timeops.h" LOG_FILE_SOURCE(debug::LOG_N3FJP); static void send_log_data(); //====================================================================== // Socket N3FJP i/o used on all platforms //====================================================================== pthread_t n3fjp_thread; pthread_t n3fjp_rx_socket_thread; Socket *n3fjp_socket = 0; pthread_mutex_t n3fjp_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t send_this_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t report_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t n3fjp_socket_mutex = PTHREAD_MUTEX_INITIALIZER; static std::string send_this = ""; static std::string pathname; static std::stringstream result; bool n3fjp_connected = false; bool n3fjp_enabled = false; bool n3fjp_exit = false; std::string n3fjp_ip_address = ""; std::string n3fjp_ip_port = ""; std::string n3fjp_rxbuffer; std::string connected_to; enum {UNKNOWN, N3FJP, FLDIGI}; bool n3fjp_bool_add_record = false; int n3fjp_has_xcvr_control = UNKNOWN; std::string tracked_freq = ""; int tracked_mode = -1; enum { FJP_NONE, FJP_ACL, // Amateur Contact Log FJP_FD, // ARRL Field Day FJP_WFD, // ARRL Winter Field Day FJP_KD, // ARRL Kids Day FJP_ARR, // ARRL Rookie Roundup FJP_RTTY, // ARRL Rtty FJP_ASCR, // ARRL School Club Roundup FJP_JOTA, // ARRL Jamboree On The Air FJP_AICW, // ARRL International DX (CW) FJP_SS, // ARRL November Sweepstakes FJP_CQ_WPX, // CQ WPX FJP_CQWWRTTY, // CQWW Rtty FJP_CQWWDX, // CQWW DX FJP_IARI, // Italian ARI International DX FJP_NAQP, // North American QSO Party FJP_NAS, // North American Sprint FJP_1010, // Ten Ten FJP_AIDX, // Africa All Mode FJP_VHF, // VHF FJP_WAE, // Worked All Europe FJP_MDQP, // MD QSOP record format FJP_7QP, // 7QP record format FJP_NEQP, // New England QSO party record format FJP_QP1, // QSO party record format 1 / 7QP contest FJP_QP2, // QSO party record format 2 FJP_QP3, // QSO party record format 3 FJP_QP4, // QSO party record format 4 FJP_QP5, // QSO party record format 5 FJP_QP6 // QSO party record format 6 }; // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // // "7QP", "B", "B", "B", "", "I", "", "", "SSCCC" // "New Eng", "B", "B", "B", "", "I", "", "", "CCCSS" // "MD SQP" "", "B", "B", "", "", "", "B", "" // "QSOP 1" "B", "B", "B", "", "I", "", "", "" // "QSOP 2" "B", "B", "B", "", "B", "", "", "" // "QSOP 3" "", "B", "B", "B", "I", "", "", "" // "QSOP 4" "", "B", "B", "", "I", "B", "", "" // "QSOP 5" "B", "B", "B", "", "", "", "", "" // "QSOP 6" "B", "B", "B", "", "I", "", "", "" struct N3FJP_LOGGER { const char *program; int contest; bool in_state; } n3fjp_logger[] = { {"No Contest", FJP_NONE, false}, {"Amateur Contact Log", FJP_ACL, false}, {"Africa All-Mode International", FJP_AIDX, false}, {"ARRL Field Day", FJP_FD, false}, {"Winter FD", FJP_WFD, false}, {"ARRL International DX", FJP_AICW, false}, {"Jamboree on the Air", FJP_JOTA, false}, {"ARRL Kids Day", FJP_KD, false}, {"ARRL Rookie Roundup", FJP_ARR, false}, {"ARRL RTTY Roundup", FJP_RTTY, false}, {"School Club Roundup", FJP_ASCR, false}, {"ARRL November Sweepstakes", FJP_SS, false}, {"BARTG RTTY Contest", FJP_NONE, false}, {"CQ WPX Contest Log", FJP_CQ_WPX, false}, {"CQ WW DX Contest Log", FJP_CQWWDX, false}, {"CQ WW DX RTTY Contest Log", FJP_CQWWRTTY, false}, {"Italian A.R.I. International DX", FJP_IARI, false}, {"NAQP", FJP_NAQP, false}, {"NA Sprint", FJP_NAS, false}, {"Ten Ten", FJP_1010, false}, {"VHF", FJP_VHF, false}, {"Worked All Europe", FJP_WAE, false}, {"Alabama QSO Party Contest Log", FJP_QP1, true}, {"ALQP Contest Log (Out of State)", FJP_QP1, false}, {"Arkansas QSO Party Contest Log", FJP_QP1, true}, {"ARQP Contest Log (Out of State)", FJP_QP1, false}, {"British Columbia QSO Party Contest Log", FJP_QP1, true}, {"BCQP Contest Log (Out of Province)", FJP_QP1, false}, {"Florida QSO Party Contest Log", FJP_QP1, true}, {"FLQP Contest Log (Out of State)", FJP_QP1, false}, {"Georgia QSO Party Contest Log", FJP_QP1, true}, {"GAQP Contest Log (Out of State)", FJP_QP1, false}, {"Hawaii QSO Party Contest Log", FJP_QP1, true}, {"HIQP Contest Log (Out of State)", FJP_QP1, false}, {"Iowa QSO Party Contest Log", FJP_QP1, true}, {"IAQP Contest Log (Out of State)", FJP_QP1, false}, {"Idaho QSO Party Contest Log", FJP_QP1, true}, {"IDQP Contest Log (Out of State)", FJP_QP1, false}, {"Illinois QSO Party Contest Log", FJP_QP1, true}, {"ILQP Contest Log (Out of State)", FJP_QP1, false}, {"Indiana QSO Party Contest Log", FJP_QP1, true}, {"INQP Contest Log (Out of State)", FJP_QP1, false}, {"Kansas QSO Party Contest Log", FJP_QP1, true}, {"KSQP Contest Log (Out of State)", FJP_QP1, false}, {"Kentucky QSO Party Contest Log", FJP_QP1, true}, {"KYQP Contest Log (Out of State)", FJP_QP1, false}, {"Louisiana QSO Party Contest Log", FJP_QP1, true}, {"LAQP Contest Log (Out of State)", FJP_QP1, false}, {"Missouri QSO Party Contest Log", FJP_QP1, true}, {"MOQP Contest Log (Out of State)", FJP_QP1, false}, {"Mississippi QSO Party Contest Log", FJP_QP1, true}, {"MSQP Contest Log (Out of State)", FJP_QP1, false}, {"North Dakota QSO Party Contest Log", FJP_QP1, true}, {"NDQP Contest Log (Out of State)", FJP_QP1, false}, {"New Jersey QSO Party Contest Log", FJP_QP1, true}, {"NJQP Contest Log (Out of State)", FJP_QP1, false}, {"Montana QSO Party Contest Log", FJP_QP2, true}, {"MTQP Contest Log (Out of State)", FJP_QP2, false}, {"Nebraska QSO Party Contest Log", FJP_QP2, true}, {"NEQP Contest Log (Out of State)", FJP_QP2, false}, {"New York QSO Party Contest Log", FJP_QP2, true}, {"NYQP Contest Log (Out of State)", FJP_QP2, false}, {"Ohio QSO Party Contest Log", FJP_QP2, true}, {"OHQP Contest Log (Out of State)", FJP_QP2, false}, {"Oklahoma QSO Party Contest Log", FJP_QP2, true}, {"OKQP Contest Log (Out of State)", FJP_QP2, false}, {"Ontario QSO Party Contest Log", FJP_QP2, true}, {"ONQP Contest Log (Out of Province)", FJP_QP2, false}, {"South Dakota QSO Party Contest Log", FJP_QP2, true}, {"SDQP Contest Log (Out of State)", FJP_QP2, false}, {"Tennessee QSO Party Contest Log", FJP_QP2, true}, {"TNQP Contest Log (Out of State)", FJP_QP2, false}, {"Texas QSO Party Contest Log", FJP_QP2, true}, {"TXQP Contest Log (Out of State)", FJP_QP2, false}, {"Vermont QSO Party Contest Log", FJP_QP2, true}, {"VTQP Contest Log (Out of State)", FJP_QP2, false}, {"Washington Salmon Run QSO Party Contest Log", FJP_QP2, true}, {"WAQP Contest Log (Out of State)", FJP_QP2, false}, {"Maine QSO Party Contest Log", FJP_QP2, true}, {"MEQP Contest Log (Out of State)", FJP_QP2, false}, {"Arizona QSO Party Contest Log", FJP_QP3, true}, {"AZQP Contest Log (Out of State)", FJP_QP3, false}, {"California QSO Party Contest Log", FJP_QP3, true}, {"CAQP Contest Log (Out of State)", FJP_QP3, false}, {"Michigan QSO Party Contest Log", FJP_QP3, true}, {"MIQP Contest Log (Out of State)", FJP_QP3, false}, {"Pennsylvania QSO Party Contest Log", FJP_QP3, true}, {"PAQP Contest Log (Out of State)", FJP_QP3, false}, {"Virginia QSO Party Contest Log", FJP_QP3, true}, {"VAQP Contest Log (Out of State)", FJP_QP3, false}, {"Colorado QSO Party Contest Log", FJP_QP4, true}, {"COQP Contest Log (Out of State)", FJP_QP4, false}, {"Maryland QSO Party Contest Log", FJP_MDQP, true}, {"MDQP Contest Log (Out of State)", FJP_MDQP, false}, {"Minnesota QSO Party Contest Log", FJP_QP4, true}, {"MNQP Contest Log (Out of State)", FJP_QP4, false}, {"New Mexico QSO Party Contest Log", FJP_QP4, true}, {"NMQP Contest Log (Out of State)", FJP_QP4, false}, {"North Carolina QSO Party Contest Log", FJP_QP6, true}, {"NCQP Contest Log (Out of State)", FJP_QP6, false}, {"South Carolina QSO Party Contest Log", FJP_QP5, true}, {"SCQP Contest Log (Out of State)", FJP_QP5, false}, {"West Virginia QSO Party Contest Log", FJP_QP5, true}, {"WVQP Contest Log (Out of State)", FJP_QP5, false}, {"Wisconsin QSO Party Contest Log", FJP_QP6, true}, {"WIQP Contest Log (Out of State)", FJP_QP6, false}, {"7QP QSO Party Contest Log", FJP_7QP, true}, {"7QP Contest Log (Out of Region)", FJP_7QP, false}, {"New England QSO Party Contest Log", FJP_NEQP, true}, {"NEQP Contest Log (Out of Region)", FJP_NEQP, false} }; int n3fjp_contest = FJP_NONE; bool n3fjp_in_state = false; int n3fjp_wait = 0; void adjust_freq(std::string s); void n3fjp_parse_response(std::string s); void n3fjp_disp_report(std::string s, std::string fm = "", bool tofile = true); void n3fjp_send(std::string cmd, bool tofile = true); void n3fjp_rcv(std::string &rx, bool tofile = true); void n3fjp_send_freq_mode(); void n3fjp_clear_record(); void n3fjp_getfields(); void n3fjp_get_record(std::string call); static std::string ParseField(std::string &record, std::string fieldtag); static std::string ParseTextField(std::string &record, std::string fieldtag); static std::string ucasestr(std::string s); static void n3fjp_parse_data_stream(std::string buffer); static void n3fjp_parse_calltab_event(std::string buffer); std::string fmt_date(std::string date); std::string fmt_time(std::string time); std::string field_rec(std::string fld, std::string val); static std::string n3fjp_tstmode(); static std::string n3fjp_opmode(); static std::string n3fjp_opband(); static std::string n3fjp_freq(); static void send_control(const std::string ctl, std::string val); static void send_action(const std::string action); static void send_command(const std::string command, std::string val=""); static void send_data(); static void send_data_norig(); void get_n3fjp_frequency(); void do_n3fjp_add_record_entries(); void n3fjp_set_freq(long f); void n3fjp_set_ptt(int on); void n3fjp_add_record(cQsoRec &record); void n3fjp_parse_response(std::string tempbuff); void n3fjp_rcv_data(); static bool connect_to_n3fjp_server(); void n3fjp_start(); void n3fjp_disconnect(bool clearlog = false); void *n3fjp_loop(void *args); void n3fjp_init(void); void n3fjp_close(void); //====================================================================== // //====================================================================== static std::string strip(std::string s) { while (s.length() && (s[0] <= ' ')) s.erase(0,1); while (s.length() && (s[s.length()-1] <= ' ')) s.erase(s.length()-1, 1); return s; } //====================================================================== // //====================================================================== void adjust_freq(std::string sfreq) { long freq; size_t pp = sfreq.find("."); if (pp == std::string::npos) return; while ((sfreq.length() - pp) < 7) sfreq.append("0"); sfreq.erase(pp,1); freq = atol(sfreq.c_str()); if (freq == 0) return; wf->rfcarrier(freq); wf->movetocenter(); show_frequency(freq); return; if (progdefaults.N3FJP_sweet_spot) { int afreq; if (active_modem->get_mode() == MODE_CW) { afreq = progdefaults.CWsweetspot; } else if (active_modem->get_mode() == MODE_RTTY) { afreq = progdefaults.RTTYsweetspot; } else if (active_modem->get_mode() < MODE_SSB) afreq = progdefaults.PSKsweetspot; else { wf->rfcarrier(freq); wf->movetocenter(); show_frequency(freq); return; } freq -= (wf->USB() ? afreq : -afreq); wf->rfcarrier(freq); wf->movetocenter(); show_frequency(freq); return; } wf->rfcarrier(freq); wf->movetocenter(); show_frequency(freq); } //====================================================================== // //====================================================================== static notify_dialog *alert_window = 0; void set_connect_box() { if (!alert_window) alert_window = new notify_dialog; box_n3fjp_connected->color( n3fjp_connected ? FL_DARK_GREEN : FL_BACKGROUND2_COLOR); box_n3fjp_connected->redraw(); if (n3fjp_connected) { alert_window->notify(_("Connected to N3FJP logger"), 1.0); REQ(show_notifier, alert_window); REQ(update_main_title); } else { progdefaults.CONTESTnotes = ""; listbox_contest->index(0); listbox_QP_contests->index(0); inp_contest_notes->value(progdefaults.CONTESTnotes.c_str()); } } void n3fjp_print(std::string s) { if (bEXITING) return; FILE *n3fjplog = fl_fopen(pathname.c_str(), "a"); time_t t = time(NULL); struct tm stm; (void)localtime_r(&t, &stm); char sztime[12]; memset(sztime, 0, 11); snprintf(sztime, sizeof(sztime), "[%02d:%02d:%02d] ", stm.tm_hour, stm.tm_min, stm.tm_sec); s.insert(0, sztime); if (n3fjplog) { if (s[s.length()-1]!='\n') fprintf(n3fjplog, "%s\n", s.c_str()); else fprintf(n3fjplog, "%s", s.c_str()); fclose(n3fjplog); } LOG_VERBOSE("%s", s.c_str()); } void n3fjp_show(std::string s) { txt_N3FJP_data->insert(s.c_str()); txt_N3FJP_data->redraw(); } void n3fjp_disp_report(std::string s, std::string fm, bool tofile) { guard_lock report_lock(&report_mutex); if (s.empty()) return; std::string report = fm.append("\n").append(s); size_t p; p = report.find("\r\n"); while (p != std::string::npos) { report.replace(p,2,"<crlf>\n"); p = report.find("\r\n"); } p = report.find("</CMD><CMD>"); while (p != std::string::npos) { report.replace(p, 11, "</CMD>\n<CMD>"); p = report.find("</CMD><CMD>"); } if (progdefaults.enable_N3FJP_log) REQ(n3fjp_show, report); if (tofile) n3fjp_print(report); } void n3fjp_send(std::string cmd, bool tofile) { guard_lock send_lock(&n3fjp_socket_mutex); if (!n3fjp_socket) { n3fjp_print("Socket not present"); return; } try { if (cmd.empty()) return; n3fjp_disp_report(cmd, "SEND:", tofile); cmd.append("\r\n"); n3fjp_socket->send(cmd); } catch (const SocketException& e) { result.str(""); result << "n3fjp_send()::failed " << e.error() << " " << e.what(); n3fjp_print(result.str()); throw e; } catch (...) { throw; } } void n3fjp_rcv(std::string &rx, bool tofile) { guard_lock read_lock(&n3fjp_socket_mutex); if (!n3fjp_socket) return; try { if (!n3fjp_socket->recv(rx)) rx.clear(); if (rx.empty()) return; n3fjp_disp_report(rx, "RCVD:", tofile); } catch (const SocketException& e) { result.str(""); result << "n3fjp_rcv()::failed " << e.error() << " " << e.what(); n3fjp_print(result.str()); throw e; } catch (...) { throw; } } void n3fjp_send_freq_mode() { if (!active_modem) return; std::string cmd; char szfreq[20]; double freq = atof(inpFreq->value()) / 1e3; snprintf(szfreq, sizeof(szfreq), "%f", freq); if (active_modem->get_mode() != tracked_mode || tracked_freq != szfreq) { tracked_mode = active_modem->get_mode(); tracked_freq = szfreq; cmd = "<CMD><SENDRIGPOLL><FREQ>"; cmd.append(tracked_freq); cmd.append("</FREQ><MODE>"); cmd.append( mode_info[tracked_mode].adif_name ); cmd.append("</MODE></CMD>"); n3fjp_send(cmd, progdefaults.enable_N3FJP_log); } } //====================================================================== // //====================================================================== static cQsoRec rec; static void n3fjp_sendRSTS(std::string s) { if (s.empty()) return; try { send_control("RSTS", s); } catch (...) { throw; } } static void n3fjp_sendRSTR(std::string s) { if (s.empty()) return; try { send_control("RSTR", s); } catch (...) { throw; } } void send_call(std::string s) { try { send_control("CALL", s.c_str()); } catch (const SocketException& e) { result.str(""); result << "send_call()::failed " << e.error() << " " << e.what(); n3fjp_print(result.str()); throw e; } catch (...) { throw; } } void send_freq(std::string s) { try { send_control("FREQUENCY", s); } catch (const SocketException& e) { result.str(""); result << "send_freq()::failed " << e.error() << " " << e.what(); n3fjp_print(result.str()); throw e; } catch (...) { throw; } } void send_band(std::string s) { try { send_control("BAND", s); } catch (const SocketException& e) { result.str(""); result << "send_band()::failed " << e.error() << " " << e.what(); n3fjp_print(result.str()); throw e; } catch (...) { throw; } } void send_mode(std::string s) { try { send_control("MODE", s); } catch (const SocketException& e) { result.str(""); result << "send_mode()::failed " << e.error() << " " << e.what(); n3fjp_print(result.str()); throw e; } catch (...) { throw; } } void send_state(std::string s) { try { send_control("STATE", s); } catch (const SocketException& e) { result.str(""); result << "send_state()::failed " << e.error() << " " << e.what(); n3fjp_print(result.str()); throw e; } catch (...) { throw; } } void send_county(std::string s) { try { send_control("COUNTYR", s); } catch (const SocketException& e) { result.str(""); result << "send_county()::failed " << e.error() << " " << e.what(); n3fjp_print(result.str()); throw e; } catch (...) { throw; } } void send_spcnum(std::string s) { try { send_control("SPCNUM", s); } catch (const SocketException& e) { result.str(""); result << "send_spcnum()::failed " << e.error() << " " << e.what(); n3fjp_print(result.str()); throw e; } catch (...) { throw; } } void send_name(std::string s) { try { send_control("NAMER", s); } catch (const SocketException& e) { result.str(""); result << "send_name()::failed " << e.error() << " " << e.what(); n3fjp_print(result.str()); throw e; } catch (...) { throw; } } //====================================================================== // //====================================================================== void n3fjp_clear_record() { if(!n3fjp_socket) return; if (!n3fjp_connected) return; std::string cmd = "<CMD><ACTION><VALUE>CLEAR</VALUE></CMD>"; try { n3fjp_send(cmd, progdefaults.enable_N3FJP_log); n3fjp_wait = 100; } catch (const SocketException& e) { result.str(""); result << "Error: " << e.error() << ", " << e.what(); n3fjp_print(result.str()); } catch (...) { throw; } } //====================================================================== // //====================================================================== bool n3fjp_calltab = false; void n3fjp_getfields() { std::string cmd ="<CMD><ALLFIELDSWITHVALUES></CMD>"; try { n3fjp_send(cmd, progdefaults.enable_N3FJP_log); n3fjp_wait = 100; } catch (const SocketException& e) { result.str(""); result << "Error: " << e.error() << ", " << e.what(); n3fjp_print(result.str()); n3fjp_calltab = false; } catch (...) { throw; } } void n3fjp_get_record(std::string call) { if(!n3fjp_socket) return; if (!n3fjp_connected) return; if (!n3fjp_calltab) return; std::string cmd0, cmd1, cmd2; cmd0.assign("<CMD><ACTION><VALUE>CLEAR</VALUE></CMD>"); cmd1.assign("<CMD><UPDATE><CONTROL>TXTENTRYCALL</CONTROL><VALUE>"); cmd1.append(call).append("</VALUE></CMD>"); cmd2.assign("<CMD><ACTION><VALUE>CALLTAB</VALUE></CMD>"); try { n3fjp_send(cmd0, progdefaults.enable_N3FJP_log); n3fjp_send(cmd1, progdefaults.enable_N3FJP_log); n3fjp_send(cmd2, progdefaults.enable_N3FJP_log); n3fjp_calltab = false; n3fjp_wait = 100; } catch (const SocketException& e) { result.str(""); result << "Error: " << e.error() << ", " << e.what(); n3fjp_print(result.str()); n3fjp_calltab = false; } catch (...) { throw; } } //====================================================================== // parse string containing value, e.g. // <FREQ>14.01310</FREQ> //====================================================================== static std::string ParseField(std::string &record, std::string fieldtag) { std::string fld_tag_start, fld_tag_end; fld_tag_start.assign("<").append(fieldtag).append(">"); fld_tag_end.assign("</").append(fieldtag).append(">"); size_t p1 = record.find(fld_tag_start); if (p1 == std::string::npos) return ""; p1 += fld_tag_start.length(); size_t p2 = record.find(fld_tag_end, p1); if (p2 == std::string::npos) return ""; return record.substr(p1, p2 - p1); } //====================================================================== // parse string containing text entry values, e.g. // <CONTROL>TXTENTRYCOUNTYR</CONTROL><VALUE>Saint Louis City</VALUE></CMD> //====================================================================== static std::string ParseTextField(std::string &record, std::string fieldtag) { std::string fld_tag_start; fld_tag_start.assign("<CONTROL>TXTENTRY").append(fieldtag).append("</CONTROL>"); size_t p1 = record.find(fld_tag_start); if (p1 == std::string::npos) return ""; size_t p2 = record.find("<VALUE>", p1); if (p2 == std::string::npos) return ""; p2 += strlen("<VALUE>"); size_t p3 = record.find("</VALUE>", p2); if (p3 == std::string::npos) return ""; return record.substr(p2, p3 - p2); } //====================================================================== // parse value contents // <VALUE>valuestring</VALUE> //====================================================================== static std::string ParseValueField(std::string field, std::string &record) { std::string start = "<"; start.append(field).append("><VALUE>"); std::string endvalue = "</VALUE>"; size_t p1 = record.find(start); size_t p2 = record.find(endvalue, p1); if ((p1 == std::string::npos) || (p2 == std::string::npos) || (p2 < p1) ) return ""; p1 += start.length(); return record.substr(p1, p2 - p1); } static std::string ucasestr(std::string s) { for (size_t n = 0; n < s.length(); n++) s[n] = toupper(s[n]); return s; } //====================================================================== // //====================================================================== static void n3fjp_parse_data_stream(std::string buffer) { std::string field; field = ParseTextField(buffer, "NAMER"); if (!field.empty() && ucasestr(field) != ucasestr(inpName->value())) { for (size_t n = 1; n < field.length(); n++) field[n] = tolower(field[n]); } field = ParseTextField(buffer, "COUNTYR"); if (!field.empty() && field != inpCounty->value() && n3fjp_contest != FJP_NEQP && n3fjp_contest != FJP_7QP) field = ParseTextField(buffer, "STATE"); if (!field.empty() && field != inpState->value() && n3fjp_contest != FJP_NEQP && n3fjp_contest != FJP_7QP) field = ParseTextField(buffer, "COUNTRYWORKED"); if (!field.empty() && field != cboCountry->value()) field = ParseTextField(buffer, "GRID"); if (!field.empty() && field != inpLoc->value()) field = ParseTextField(buffer, "FREQUENCY"); if (!field.empty()) adjust_freq(field); field = ParseTextField(buffer, "CQZONE"); if (!field.empty() && field != inp_CQzone->value()) // comments field does not contain \n delimiters // substitute \n for each '-' field = ParseTextField(buffer, "COMMENTS"); if (!field.empty()) { size_t p = field.find(" - "); while (p != std::string::npos) { field.replace(p, 3, "\n"); p = field.find(" - "); } } } //====================================================================== //<CMD><CALLTABEVENT> // <CALL>ON6NB/P</CALL> // <BAND>40</BAND> // <MODE>SSB</MODE> // <MODETEST>PH</MODETEST> // <COUNTRY>Belgium</COUNTRY> //</CMD> //====================================================================== static void n3fjp_parse_calltab_event(std::string buffer) { // inpCall->value(ParseField(buffer, "CALL").c_str()); cboCountry->value(ParseField(buffer, "COUNTRY").c_str()); n3fjp_getfields(); } //====================================================================== // //====================================================================== std::string fmt_date(std::string date) { if (date.length() > 6) date.insert(6,"/"); if (date.length() > 4) date.insert(4,"/"); return date; } std::string fmt_time(std::string time) { if (time.length() > 4) time.insert(4,":"); if (time.length() > 2) time.insert(2,":"); return time; } std::string field_rec(std::string fld, std::string val) { std::string s; s.assign("<").append(fld).append(">"); s.append(val); s.append("</").append(fld).append(">"); return s; } static std::string n3fjp_tstmode() { if (!active_modem) return "PH"; if (active_modem->get_mode() == MODE_CW) return "CW"; if (active_modem->get_mode() == MODE_SSB) return "PH"; if (active_modem->get_mode() < MODE_SSB) return mode_info[active_modem->get_mode()].adif_name; return ""; } static std::string n3fjp_opmode() { if (!active_modem) return "PH"; if (active_modem->get_mode() == MODE_CW) return "CW"; if (active_modem->get_mode() == MODE_SSB) return "PH"; if (active_modem->get_mode() < MODE_SSB) return mode_info[active_modem->get_mode()].adif_name; return ""; } static std::string n3fjp_opband() { if (!active_modem) return ""; float freq = qsoFreqDisp->value(); freq /= 1e6; if (freq >= 1.8 && freq < 3.5) return "160"; if (freq >= 3.5 && freq < 5.3) return "80"; if (freq >= 5.3 && freq < 5.5) return "60"; if (freq >= 7.0 && freq < 7.5) return "40"; if (freq >= 14.0 && freq < 18.0) return "20"; if (freq >= 18.0 && freq < 21.0) return "17"; if (freq >= 21.0 && freq < 24.0) return "15"; if (freq >= 24.0 && freq < 28.0) return "12"; if (freq >= 28.0 && freq < 50.0) return "10"; if (freq >= 50.0 && freq < 70.0) return "6"; if (freq >= 144.0 && freq < 222.0) return "2"; if (freq >= 222.0 && freq < 420.0) return "222"; if (freq >= 420.0 && freq < 444.0) return "440"; return ""; } static std::string n3fjp_freq() { if (!active_modem) return ""; float freq = qsoFreqDisp->value(); if (progdefaults.N3FJP_modem_carrier) { if (ModeIsLSB(mode_info[active_modem->get_mode()].adif_name)) { freq -= active_modem->get_txfreq(); if (active_modem->get_mode() == MODE_RTTY) freq -= progdefaults.rtty_shift / 2; } else { freq += active_modem->get_txfreq(); if (active_modem->get_mode() == MODE_RTTY) freq += progdefaults.rtty_shift / 2; } } freq /= 1e6; char szfreq[20]; snprintf(szfreq, sizeof(szfreq), "%f", freq); return szfreq; } static void send_control(const std::string ctl, std::string val) { std::string cmd; cmd.assign("<CMD><UPDATE><CONTROL>TXTENTRY").append(ctl); cmd.append("</CONTROL><VALUE>"); cmd.append(val); cmd.append("</VALUE></CMD>"); try { n3fjp_send(cmd, progdefaults.enable_N3FJP_log); n3fjp_wait = 100; } catch (...) { throw; } } static void send_action(const std::string action) { std::string cmd; cmd.assign("<CMD><ACTION><VALUE>"); cmd.append(action); cmd.append("</VALUE></CMD>"); try { n3fjp_send(cmd, progdefaults.enable_N3FJP_log); n3fjp_wait = 200;//100; } catch (...) { throw; } } static void send_command(const std::string command, std::string val) { std::string cmd; cmd.assign("<CMD><").append(command).append(">"); if (!val.empty()) cmd.append("<VALUE>").append(val).append("</VALUE>"); cmd.append("</CMD>"); try { n3fjp_send(cmd, progdefaults.enable_N3FJP_log); // MilliSleep(5); n3fjp_wait = 100; } catch (...) { throw; } } static void n3fjp_send_NONE() { try { send_control("DATE", fmt_date(rec.getField(QSO_DATE))); send_control("TIMEON", fmt_time(rec.getField(TIME_ON))); send_control("TIMEOFF", fmt_time(rec.getField(TIME_OFF))); send_name(strip(rec.getField(NAME))); send_control("COMMENTS", strip(rec.getField(NOTES))); send_control("POWER", strip(rec.getField(TX_PWR))); send_state(rec.getField(STATE)); send_control("GRID", strip(rec.getField(GRIDSQUARE))); send_control("QTHGROUP", strip(rec.getField(QTH))); send_county(rec.getField(CNTY)); send_control("COUNTRYWORKED", rec.getField(COUNTRY)); } catch (...) { throw; } } // ARRL Field Day static void n3fjp_send_FD() { try { send_control("MODETST", n3fjp_tstmode()); send_control("CLASS", strip(ucasestr(rec.getField(CLASS)))); send_control("SECTION", strip(ucasestr(rec.getField(ARRL_SECT)))); } catch (...) { throw; } } // Winter Field Day static void n3fjp_send_WFD() { try { send_control("MODETST", n3fjp_tstmode()); send_control("CLASS", strip(ucasestr(rec.getField(CLASS)))); send_control("SECTION", strip(ucasestr(rec.getField(ARRL_SECT)))); } catch (...) { throw; } } // Kids Day static void n3fjp_send_KD() { try { send_name(rec.getField(NAME)); send_control("AGE", rec.getField(AGE)); std::string stprc = strip(ucasestr(rec.getField(STATE))); if (stprc.empty()) stprc = strip(ucasestr(rec.getField(VE_PROV))); if (stprc.empty()) stprc = strip(rec.getField(COUNTRY)); send_spcnum(stprc); send_control("COMMENTS", strip(rec.getField(XCHG1))); } catch (...) { throw; } } // ARRL Rookie Roundup static void n3fjp_send_ARR() { try { send_name(rec.getField(NAME)); send_control("CHECK", rec.getField(CHECK)); if (rec.getField(XCHG1)[0]) send_spcnum(strip(ucasestr(rec.getField(XCHG1)))); else send_spcnum(strip(ucasestr(rec.getField(COUNTRY)))); } catch (...) { throw; } } // ARRL RTTY static void n3fjp_send_RTTY() { try { if (rec.getField(SRX)[0]) send_spcnum(strip(rec.getField(SRX))); else if (rec.getField(STATE)[0]) send_spcnum(strip(ucasestr(rec.getField(STATE)))); else if (rec.getField(VE_PROV)[0]) send_spcnum(strip(ucasestr(rec.getField(VE_PROV)))); send_control("COUNTRYWORKED", rec.getField(COUNTRY)); } catch (...) { throw; } } // ARRL School Club Roundup static void n3fjp_send_ASCR() { try { send_name(strip(rec.getField(NAME))); send_control("CLASS", ucasestr(rec.getField(CLASS))); send_spcnum(ucasestr(rec.getField(XCHG1))); } catch (...) { throw; } } // ARRL Jamboree On The Air static void n3fjp_send_JOTA() { try { send_name(rec.getField(SCOUTR)); // received scout name send_control("NAMES", rec.getField(SCOUTS)); // sent scout name send_control("CHECK", rec.getField(TROOPR)); // received troop number send_control("TROOPS", rec.getField(TROOPS)); // sent troop number if (state_test(rec.getField(STATE))) send_spcnum(ucasestr(rec.getField(STATE))); else if (province_test(rec.getField(VE_PROV))) send_spcnum(ucasestr(rec.getField(VE_PROV))); else send_spcnum(rec.getField(COUNTRY)); // St / Pr / Cntry send_control("COMMENTS", rec.getField(NOTES)); } catch (...) { throw; } } // CQ WPX static void n3fjp_send_WPX() { try { send_call(rec.getField(CALL)); send_freq(n3fjp_freq()); send_band(n3fjp_opband()); send_mode(n3fjp_opmode()); send_control("COUNTRYWORKED", rec.getField(COUNTRY)); send_control("SERIALNOR", strip(rec.getField(SRX))); } catch (...) { throw; } } // Italian ARI International DX static void n3fjp_send_IARI() { try { if (rec.getField(SRX)[0]) send_spcnum(rec.getField(SRX)); else send_spcnum(ucasestr(rec.getField(XCHG1))); // send_control("COUNTRYWORKED", rec.getField(COUNTRY)); } catch (...) { throw; } } // North American Sprint static void n3fjp_send_NAS() { try { send_name(rec.getField(NAME)); send_control("SERIALNOR", strip(rec.getField(SRX))); send_spcnum(strip(ucasestr(rec.getField(XCHG1)))); } catch (...) { throw; } } // CQ World Wide RTTY static void n3fjp_send_CQWWRTTY() { try { send_control("CQZONE", strip(rec.getField(CQZ))); send_state(rec.getField(STATE)); send_control("COUNTRYWORKED", strip(rec.getField(COUNTRY))); } catch (...) { throw; } } // CQ World Wide DX static void n3fjp_send_CQWWDX() { try { send_control("CQZONE", strip(rec.getField(CQZ))); send_control("COUNTRYWORKED", strip(rec.getField(COUNTRY))); } catch (...) { throw; } } // Sweepstakes static void n3fjp_send_SS() { try { send_control("SERIALNOR", strip(rec.getField(SS_SERNO))); send_control("PRECEDENCE", strip(rec.getField(SS_PREC))); send_control("CHECK", strip(rec.getField(SS_CHK))); send_control("SECTION", strip(rec.getField(SS_SEC))); } catch (...) { throw; } } // North American QSO Party static void n3fjp_send_NAQP() { try { send_name(rec.getField(NAME)); if (strlen(rec.getField(XCHG1)) > 0) send_spcnum(ucasestr(rec.getField(XCHG1))); } catch (...) { throw; } } // Ten Ten static void n3fjp_send_1010() { try { send_name(rec.getField(NAME)); send_control("1010", rec.getField(TEN_TEN)); if (strlen(rec.getField(XCHG1)) > 0) send_spcnum(ucasestr(rec.getField(XCHG1))); } catch (...) { throw; } } // Africa International DX static void n3fjp_send_AIDX() { try { send_control("SERIALNOR", strip(rec.getField(SRX))); send_control("COUNTRYWORKED", rec.getField(COUNTRY)); } catch (...) { throw; } } // ARRL International DX (CW) static void n3fjp_send_AICW() { try { send_spcnum(rec.getField(XCHG1)); send_control("COUNTRYWORKED", rec.getField(COUNTRY)); } catch (...) { throw; } } static void n3fjp_send_GENERIC() { try { send_control("SERIALNOR", strip(rec.getField(SRX))); send_spcnum(strip(ucasestr(rec.getField(XCHG1)))); } catch (...) { throw; } } static void n3fjp_send_VHF() { try { std::string grid = strip(rec.getField(GRIDSQUARE)); if (grid.length() > 4) grid.erase(4); send_control("GRID", grid); } catch (...) { throw; } } static void n3fjp_send_WAE() { try { send_control("SERIALNOR", strip(rec.getField(SRX))); send_control("COUNTRYWORKED", rec.getField(COUNTRY)); } catch (...) { throw; } } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "MD SQP" "", "B", "B", "", "", "", "B", "" static void n3fjp_send_MDQSP() { try { if (rec.getField(XCHG1)[0]) send_control("CATEGORY", ucasestr(strip(rec.getField(XCHG1)))); send_county(strip(rec.getField(CNTY))); if (n3fjp_in_state) { send_county(ucasestr(strip(rec.getField(CNTY)))); if (rec.getField(STATE)[0]) send_spcnum(rec.getField(STATE)); else if (rec.getField(VE_PROV)[0]) send_spcnum(rec.getField(VE_PROV)); else if (rec.getField(COUNTRY)[0]) send_spcnum(rec.getField(COUNTRY)); } } catch (...) { throw; } } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "New Eng", "B", "B", "B", "", "I", "", "", "CCCSS" // MA, NH, VT, MA, CT, RI static void n3fjp_send_NEQP() { try { if (rec.getField(CNTY)[0]) send_county(rec.getField(CNTY)); if (rec.getField(STATE)[0]) send_spcnum(rec.getField(STATE)); else if (rec.getField(COUNTRY)[0]) send_spcnum(rec.getField(COUNTRY)); } catch (...) { throw; } } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "7QP", "B", "B", "B", "", "I", "", "", "SSCCC" // AZ ID OR MT NV WA WY static void n3fjp_send_7QP() { static std::string st7QP = "AZ ID OR MT NV WA WY UT"; try { std::string st = rec.getField(STATE); std::string cnty = rec.getField(CNTY); if (cnty.length() == 5) { if (st7QP.find(cnty.substr(0,2)) != std::string::npos) st = cnty.substr(0,2); } send_spcnum(st); send_county(cnty); if (progdefaults.SQSOinstate && !st.empty()) { // in region if (st7QP.find(st) != std::string::npos) { if (!cnty.empty()) send_county(cnty); send_spcnum(st); } else send_spcnum(st); } else { // out of region if (!st.empty() && st7QP.find(st) != std::string::npos) { if (!cnty.empty()) send_county(cnty); send_spcnum(st); } } } catch (...) { throw; } } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "QSOP 1" "B", "B", "B", "", "I", "", "", "" //AL, AR, FL, GA, HI, IA, ID, IL, KS, KY, LA, MO, MI, ND, NJ, BC, 7QP static void n3fjp_send_QP1() { try { std::string st = rec.getField(STATE); if (st.empty()) st = QSOparties.qso_parties[progdefaults.SQSOcontest].state; if (rec.getField(STATE)[0]) send_spcnum(rec.getField(STATE)); else if (rec.getField(VE_PROV)[0]) send_spcnum(rec.getField(VE_PROV)); else if (rec.getField(COUNTRY)[0]) send_spcnum(rec.getField(COUNTRY)); if (rec.getField(CNTY)[0]) { if (st == "BC") { // British Columbia Cstates cs; send_county(cs.cnty_short(st, rec.getField(CNTY))); } else send_county(rec.getField(CNTY)); } } catch (...) { throw; } } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "QSOP 2" "B", "B", "B", "", "B", "", "", "" // MT, NE, NY, OH, OK, ON, SK, TN, TX, VT, WA, ME static void n3fjp_send_QP2() { try { if (rec.getField(STATE)[0]) send_spcnum(rec.getField(STATE)); else if (rec.getField(VE_PROV)[0]) send_spcnum(rec.getField(VE_PROV)); else if (rec.getField(COUNTRY)[0]) send_spcnum(rec.getField(COUNTRY)); if (rec.getField(CNTY)[0]) send_county(rec.getField(CNTY)); } catch (...) { throw; } } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "QSOP 3" "", "B", "B", "B", "I", "", "", "" // AZ, CA, MI, PA, VI static void n3fjp_send_QP3() { try { if (n3fjp_in_state) { // in state log if (rec.getField(STATE)[0]) { send_spcnum(rec.getField(STATE)); // string county = states.county(rec.getField(STATE), rec.getField(CNTY)); // if (!county.empty()) if (rec.getField(CNTY)[0]) send_county(rec.getField(CNTY)); } else if (rec.getField(VE_PROV)[0]) send_spcnum(rec.getField(VE_PROV)); else if (rec.getField(COUNTRY)[0]) send_spcnum(rec.getField(COUNTRY)); } else { // out of state log std::string county = rec.getField(CNTY); if (!county.empty()) // { send_county(county); // } else // send_county(rec.getField(CNTY)); // may be ARRL section } send_control("SERIALNOR", strip(rec.getField(SRX))); } catch (...) { throw; } } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "QSOP 4" "", "B", "B", "", "I", "B", "", "" // CO, MN, NM static void n3fjp_send_QP4() { try { // RST sent/rcvd not required, but will be accepted by logger if (n3fjp_in_state) { if (rec.getField(STATE)[0]) send_spcnum(rec.getField(STATE)); else if (rec.getField(VE_PROV)[0]) send_spcnum(rec.getField(VE_PROV)); else if (rec.getField(COUNTRY)[0]) send_spcnum(rec.getField(COUNTRY)); if (rec.getField(NAME)[0]) send_name(rec.getField(NAME)); if (rec.getField(CNTY)[0]) send_county(rec.getField(CNTY)); } else { // std::string st = QSOparties.qso_parties[progdefaults.SQSOcontest].state; // send_county(states.county(st, rec.getField(CNTY))); send_county(rec.getField(CNTY)); if (rec.getField(NAME)[0]) send_name(rec.getField(NAME)); } } catch (...) { throw; } } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "QSOP 5" "B", "I", "B", "", "", "", "", "" // SC, WV static void n3fjp_send_QP5() { try { if (n3fjp_in_state) { if (rec.getField(STATE)[0]) send_spcnum(rec.getField(STATE)); else if (rec.getField(VE_PROV)[0]) send_spcnum(rec.getField(VE_PROV)); else if (rec.getField(COUNTRY)[0]) send_spcnum(rec.getField(COUNTRY)); send_county(rec.getField(CNTY)); } else { send_county(rec.getField(CNTY)); } } catch (...) { throw; } } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "QSOP 6" "B", "B", "B", "", "I", "", "", "" // NC, WI static void n3fjp_send_QP6() { try { if (n3fjp_in_state) { if (rec.getField(STATE)[0]) send_spcnum(rec.getField(STATE)); else if (rec.getField(VE_PROV)[0]) send_spcnum(rec.getField(VE_PROV)); else if (rec.getField(COUNTRY)[0]) send_spcnum(rec.getField(COUNTRY)); if (rec.getField(CNTY)[0]) send_county(rec.getField(CNTY)); } else { // send_county(states.county(rec.getField(STATE), rec.getField(CNTY))); send_county(rec.getField(CNTY)); } } catch (...) { throw; } } // check fields for duplicates // ARRL Field Day static void n3fjp_check_FD() { try { send_control("MODETST", n3fjp_tstmode()); send_control("CLASS", inpClass->value()); send_control("SECTION", inpSection->value()); } catch (...) { throw; } return; } // Winter Field Day static void n3fjp_check_WFD() { try { send_control("MODETST", n3fjp_tstmode()); send_control("CLASS", inpClass->value()); send_control("SECTION", inpSection->value()); } catch (...) { throw; } return; } // Kids Day static void n3fjp_check_KD() { try { send_name(inpName->value()); send_control("AGE", inp_KD_age->value()); send_spcnum(ucasestr(inpQTH->value())); send_control("COMMENTS", inpXchgIn->value()); } catch (...) { throw; } return; } // ARRL Rookie Roundup static void n3fjp_check_ARR() { try { send_name(inpName->value()); send_control("CHECK", inp_ARR_check->value()); if (inpXchgIn->value()[0]) send_spcnum(ucasestr(inpXchgIn->value())); else send_spcnum(ucasestr(cboCountry->value())); } catch (...) { throw; } return; } // ARRL RTTY static void n3fjp_check_RTTY() { try { if (inpSerNo->value()[0]) send_spcnum(inpSerNo->value()); else if (inpState->value()[0]) send_spcnum(ucasestr(inpState->value())); else if (inpVEprov->value()[0]) send_spcnum(ucasestr(ucasestr(inpVEprov->value()))); send_control("COUNTRYWORKED", cboCountry->value()); } catch (...) { throw; } return; } // ARRL School Club Roundup static void n3fjp_check_ASCR() { try { send_name(inpName->value()); send_spcnum(inpXchgIn->value()); send_control("CLASS", ucasestr(inpClass->value())); } catch (...) { throw; } return; } // ARRL Jamboree On The Air static void n3fjp_check_JOTA() { try { send_name(inpName->value()); send_control("CHECK", rec.getField(TROOPR)); // received troop number send_control("TROOPS", inp_JOTA_troop->value()); // sent troop number if (state_test(inpState->value())) send_spcnum(inpState->value()); else if (province_test(inpVEprov->value())) send_spcnum(inpVEprov->value()); else send_spcnum(ucasestr(cboCountry->value())); // St / Pr / Cntry send_control("CHECK", inp_JOTA_troop->value()); } catch (...) { throw; } return; } // CQ WPX static void n3fjp_check_WPX() { try { send_control("COUNTRYWORKED", cboCountry->value()); send_control("SERIALNOR", inpSerNo->value()); // send_control("CHECK", inpXchgIn->value()); } catch (...) { throw; } return; } // Italian ARI International DX static void n3fjp_check_IARI() { try { if (inpSerNo->value()[0]) send_spcnum(inpSerNo->value()); else send_spcnum(inpXchgIn->value()); // send_control("COUNTRYWORKED", cboCountry->value()); } catch (...) { throw; } return; } // North American Sprint static void n3fjp_check_NAS() { try { send_name(inpName->value()); send_control("SERIALNOR", inpSerNo->value()); send_spcnum(inpXchgIn->value()); } catch (...) { throw; } return; } // CQ World Wide RTTY static void n3fjp_check_CQWWRTTY() { try { send_control("CQZONE", inp_CQzone->value()); send_state(inpState->value()); send_control("COUNTRYWORKED", cboCountry->value()); } catch (...) { throw; } return; } // CQ World Wide DX static void n3fjp_check_CQWWDX() { try { send_control("CQZONE", inp_CQzone->value()); send_control("COUNTRYWORKED", cboCountry->value()); } catch (...) { throw; } return; } // Sweepstakes static void n3fjp_check_SS() { try { send_control("SERIALNOR", inpSerNo->value()); send_control("PRECEDENCE", inp_SS_Precedence->value()); send_control("CHECK", inp_SS_Check->value()); send_control("SECTION", inp_SS_Section->value()); } catch (...) { throw; } return; } // North American QSO Party static void n3fjp_check_NAQP() { try { send_name(inpName->value()); send_spcnum(inpXchgIn->value()); } catch (...) { throw; } return; } // Ten Ten static void n3fjp_check_1010() { try { send_name(inpName->value()); send_control("1010", inp_1010_nr->value()); send_spcnum(inpXchgIn->value()); } catch (...) { throw; } return; } // Africa International DX static void n3fjp_check_AIDX() { try { send_control("SERIALNOR", inpSerNo->value()); send_control("COUNTRYWORKED", cboCountry->value()); } catch (...) { throw; } return; } // ARRL International DX (CW) static void n3fjp_check_AICW() { try { send_spcnum(inpSPCnum->value()); send_control("COUNTRYWORKED", cboCountry->value()); } catch (...) { throw; } return; } static void n3fjp_check_GENERIC() { try { send_control("SERIALNOR", inpSerNo->value()); send_spcnum(ucasestr(inpXchgIn->value())); } catch (...) { throw; } return; } static void n3fjp_check_VHF() { try { std::string grid = inpLoc->value(); if (grid.length() > 4) grid.erase(4); send_control("GRID", grid); } catch (...) { throw; } return; } static void n3fjp_check_WAE() { try { send_control("SERIALNOR", inpSerNo->value()); send_control("COUNTRYWORKED", cboCountry->value()); } catch (...) { throw; } return; } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "MD SQP" "", "B", "B", "", "", "", "B", "" static void n3fjp_check_MDQSP() { try { send_county(inpCounty->value()); if (inpSQSO_category->value()[0]) send_control("CATEGORY", inpSQSO_category->value()); if (n3fjp_in_state) { if (inpState->value()[0]) send_spcnum(inpState->value()); else if (inpVEprov->value()[0]) send_spcnum(inpVEprov->value()); else if (cboCountry->value()[0]) send_spcnum(cboCountry->value()); } } catch (...) { throw; } return; } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "New Eng", "B", "B", "B", "", "I", "", "", "CCCSS" // MA, NH, VT, MA, CT, RI static void n3fjp_check_NEQP() { static std::string stNEQP = "CT MA ME NH RI VT"; try { std::string st = inpState->value(); std::string cnty = inpCounty->value(); if (cnty.length() == 5) { if (stNEQP.find(cnty.substr(cnty.length() - 3, 2)) != std::string::npos) st = cnty.substr(cnty.length() - 3, 2); } if (progdefaults.SQSOinstate && !st.empty()) { // in region if (stNEQP.find(st) != std::string::npos) { if(!cnty.empty()) send_county(cnty); send_spcnum(st); } else send_spcnum(st); } else { // out of region if (!st.empty() && stNEQP.find(st) != std::string::npos) { if (!cnty.empty()) send_county(cnty); send_spcnum(st); } } } catch (...) { throw; } return; } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "7QP", "B", "B", "B", "", "I", "", "", "SSCCC" // AZ ID OR MT NV WA WY static void n3fjp_check_7QP() { try { static std::string st7QP = "AZ ID OR MT NV WA WY UT"; std::string st = inpState->value(); std::string cnty = inpCounty->value(); if (cnty.length() == 5 && !inpState->value()[0]) { if (st7QP.find(cnty.substr(0,2)) != std::string::npos) st = cnty.substr(0,2); } if (progdefaults.SQSOinstate && !st.empty()) { // in region if (st7QP.find(st) != std::string::npos) { if (!cnty.empty()) send_county(cnty); send_spcnum(st); } else send_spcnum(st); } else { // out of region if (!st.empty() && st7QP.find(st) != std::string::npos) { if (!cnty.empty()) send_county(cnty); send_spcnum(st); } } } catch (...) { throw; } return; } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "QSOP 1" "B", "B", "B", "", "I", "", "", "" //AL, AR, FL, GA, HI, IA, ID, IL, IN, KS, KY, LA, MO, MI, ND, NJ, BC, 7QP static void n3fjp_check_QP1() { try { std::string st = inpState->value(); std::string cntry = cboCountry->value(); if (st.empty()) st = QSOparties.qso_parties[progdefaults.SQSOcontest].state; if (inpState->value()[0]) send_spcnum(inpState->value()); if (inpVEprov->value()[0]) send_spcnum(inpVEprov->value()); if (!cntry.empty() && cntry != "USA") send_spcnum(cboCountry->value()); if (inpCounty->value()[0]) { if (st == "BC" ) { // British Columbia Cstates cs; send_county(cs.cnty_short("BC", inpCounty->value())); } else send_county(inpCounty->value()); } } catch (...) { throw; } return; } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "QSOP 2" "B", "B", "B", "", "B", "", "", "" // MT, NE, NY, OH, OK, ON, SK, TN, TX, VT, WA, ME static void n3fjp_check_QP2() { try { if (inpState->value()[0]) send_spcnum(inpState->value()); else if (inpVEprov->value()[0]) send_spcnum(inpVEprov->value()); else if (cboCountry->value()[0]) send_spcnum(cboCountry->value()); if (inpCounty->value()[0]) send_county(inpCounty->value()); } catch (...) { throw; } return; } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "QSOP 3" "", "B", "B", "B", "I", "", "", "" // AZ, CA, MI, PA, VI static void n3fjp_check_QP3() { try { if (n3fjp_in_state) { if (inpState->value()[0]) { send_spcnum(inpState->value()); // std::string county = states.county(inpState->value(), inpCounty->value()); // if (!county.empty()) // send_county(county); } if (inpCounty->value()[0]) send_county(inpCounty->value()); if (inpVEprov->value()[0]) send_spcnum(inpVEprov->value()); if (cboCountry->value()[0] && (strcmp(cboCountry->value(), "USA") != 0)) send_spcnum(cboCountry->value()); } else { // std::string stsh = states.state_short(inpState->value()); // std::string county = states.county(stsh, inpCounty->value()); // if (!county.empty()) { // send_county(county); // } else if (inpCounty->value()[0]) send_county(inpCounty->value()); } send_control("SERIALNOR", inpSerNo->value()); } catch (...) { throw; } return; } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "QSOP 4" "", "B", "B", "", "I", "B", "", "" // CO, MN, NM /* N3FJP's Colorado QSO Party Contest Log <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYSPCNUM</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYNAMER</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYCOUNTYR</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYCALL</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>LBLDIALOGUE</CONTROL><VALUE>Ready to begin!<crlf> */ static void n3fjp_check_QP4() { try { if (n3fjp_in_state) { std::string cntry = cboCountry->value(); if (inpState->value()[0]) send_spcnum(inpState->value()); else if (inpVEprov->value()[0]) send_spcnum(inpVEprov->value()); else if (!cntry.empty() && cntry != "USA") send_county(inpCounty->value()); if (inpCounty->value()[0]) send_county(inpCounty->value()); if (inpName->value()[0]) send_name(inpName->value()); } else { std::string st = QSOparties.qso_parties[progdefaults.SQSOcontest].state; // send_county(states.county(st, inpCounty->value())); send_county(inpCounty->value()); if (inpName->value()[0]) send_name(inpName->value()); } } catch (...) { throw; } return; } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "QSOP 5" "B", "I", "B", "", "", "", "", "" // SC, WV static void n3fjp_check_QP5() { try { if (n3fjp_in_state) { if (inpState->value()[0]) send_spcnum(inpState->value()); else if (inpVEprov->value()[0]) send_spcnum(inpVEprov->value()); else if (cboCountry->value()[0]) send_spcnum(cboCountry->value()); if (inpCounty->value()[0]) send_county(inpCounty->value()); }else { send_county(inpCounty->value()); } } catch (...) { throw; } return; } // "QSO Party","rRST","rST","rCNTY","rSER","rXCHG","rNAM","rCAT","STCTY" // "QSOP 6" "B", "B", "B", "", "I", "", "", "" // NC, WI static void n3fjp_check_QP6() { try { if (n3fjp_in_state) { if (inpCounty->value()[0]) send_county(inpCounty->value()); if (inpState->value()[0]) send_spcnum(inpState->value()); else if (inpVEprov->value()[0]) send_spcnum(inpVEprov->value()); else if (cboCountry->value()[0]) send_spcnum(cboCountry->value()); } else { // send_county(states.county(inpState->value(), inpCounty->value())); send_county(inpCounty->value()); } } catch (...) { throw; } return; } static void check_log_data() { try{ switch (n3fjp_contest) { case FJP_FD: n3fjp_check_FD(); break; case FJP_WFD: n3fjp_check_WFD(); break; case FJP_KD: n3fjp_check_KD(); break; case FJP_ARR: n3fjp_check_ARR(); break; case FJP_RTTY: n3fjp_check_RTTY(); break; case FJP_ASCR: n3fjp_check_ASCR(); break; case FJP_JOTA: n3fjp_check_JOTA(); break; case FJP_CQ_WPX: n3fjp_check_WPX(); break; case FJP_IARI: n3fjp_check_IARI(); break; case FJP_NAS: n3fjp_check_NAS(); break; case FJP_CQWWRTTY: n3fjp_check_CQWWRTTY(); break; case FJP_CQWWDX: n3fjp_check_CQWWDX(); break; case FJP_SS: n3fjp_check_SS(); break; case FJP_NAQP: n3fjp_check_NAQP(); break; case FJP_1010: n3fjp_check_1010(); break; case FJP_AIDX: n3fjp_check_AIDX(); break; case FJP_AICW: n3fjp_check_AICW(); break; case FJP_VHF: n3fjp_check_VHF(); break; case FJP_WAE: n3fjp_check_WAE(); break; case FJP_MDQP: n3fjp_check_MDQSP(); break; case FJP_7QP: n3fjp_check_7QP(); break; case FJP_NEQP: n3fjp_check_NEQP(); break; case FJP_QP1: n3fjp_check_QP1(); break; case FJP_QP2: n3fjp_check_QP2(); break; case FJP_QP3: n3fjp_check_QP3(); break; case FJP_QP4: n3fjp_check_QP4(); break; case FJP_QP5: n3fjp_check_QP5(); break; case FJP_QP6: n3fjp_check_QP6(); break; case FJP_ACL: case FJP_NONE: default: n3fjp_check_GENERIC(); } } catch (...) { throw; } } int n3fjp_dupcheck() { guard_lock rx_lock(&n3fjp_mutex); std::string chkcall = inpCall->value(); if (chkcall.length() < 3) return false; if ((chkcall.length() == 3) && isdigit(chkcall[2])) return false; std::string cmd; try { send_call(chkcall); send_band(strip(n3fjp_opband())); send_mode(n3fjp_tstmode()); n3fjp_sendRSTS(inpRstOut->value()); n3fjp_sendRSTR(inpRstIn->value()); check_log_data(); send_action("CALLTAB"); } catch (...) { throw; } return 0; } static void send_log_data() { send_call(rec.getField(CALL)); send_band(strip(n3fjp_opband())); send_freq(n3fjp_freq()); send_mode(n3fjp_opmode()); n3fjp_sendRSTS(rec.getField(RST_SENT)); n3fjp_sendRSTR(rec.getField(RST_RCVD)); try { switch (n3fjp_contest) { case FJP_NONE: n3fjp_send_NONE(); break; case FJP_FD: n3fjp_send_FD(); break; case FJP_WFD: n3fjp_send_WFD(); break; case FJP_KD: n3fjp_send_KD(); break; case FJP_ARR: n3fjp_send_ARR(); break; case FJP_RTTY: n3fjp_send_RTTY(); break; case FJP_ASCR: n3fjp_send_ASCR(); break; case FJP_JOTA: n3fjp_send_JOTA(); break; case FJP_CQ_WPX: n3fjp_send_WPX(); break; case FJP_IARI: n3fjp_send_IARI(); break; case FJP_NAS: n3fjp_send_NAS(); break; case FJP_CQWWRTTY: n3fjp_send_CQWWRTTY(); break; case FJP_CQWWDX: n3fjp_send_CQWWDX(); break; case FJP_SS: n3fjp_send_SS(); break; case FJP_NAQP: n3fjp_send_NAQP(); break; case FJP_1010: n3fjp_send_1010(); break; case FJP_AIDX: n3fjp_send_AIDX(); break; case FJP_AICW: n3fjp_send_AICW(); break; case FJP_VHF: n3fjp_send_VHF(); break; case FJP_WAE: n3fjp_send_WAE(); break; case FJP_MDQP: n3fjp_send_MDQSP(); break; case FJP_7QP: n3fjp_send_7QP(); break; case FJP_NEQP: n3fjp_send_NEQP(); break; case FJP_QP1: n3fjp_send_QP1(); break; case FJP_QP2: n3fjp_send_QP2(); break; case FJP_QP3: n3fjp_send_QP3(); break; case FJP_QP4: n3fjp_send_QP4(); break; case FJP_QP5: n3fjp_send_QP5(); break; case FJP_QP6: n3fjp_send_QP6(); break; case FJP_ACL: n3fjp_send_NONE(); break; default: n3fjp_send_GENERIC(); break; } send_command("NEXTSERIALNUMBER"); } catch (...) { throw; } } static void enter_log_data() { try { send_log_data(); send_action("ENTER"); // if (n3fjp_contest != FJP_SS) { // std::string other = "XCVR:"; // char szfreq[6]; // snprintf(szfreq, sizeof(szfreq), "%d", (int)active_modem->get_txfreq()); // other.append(ModeIsLSB(rec.getField(ADIF_MODE)) ? "LSB" : "USB"); // other.append(" MODE:"); // other.append(strip(rec.getField(ADIF_MODE))); // other.append(" WF:"); // other.append(szfreq); // send_control("OTHER8", other); // } } catch (...) { throw; } } static void send_data() { try { send_command("IGNORERIGPOLLS", "TRUE"); send_call(rec.getField(CALL)); send_freq(n3fjp_freq()); send_band(n3fjp_opband()); send_mode(n3fjp_opmode()); enter_log_data(); send_command("IGNORERIGPOLLS", "FALSE"); } catch (...) { throw; } } static void send_data_norig() { try { std::string cmd; send_call(rec.getField(CALL)); cmd = "<CMD><CHANGEBM>"; cmd.append("<BAND>").append(n3fjp_opband()).append("</BAND>"); cmd.append("<MODE>").append(n3fjp_opmode()).append("</MODE>"); cmd.append("</CMD>"); n3fjp_send(cmd, progdefaults.enable_N3FJP_log); enter_log_data(); } catch (...) { throw; } } void get_n3fjp_frequency() { try { send_command("READBMF"); } catch (...) { throw; } } void do_n3fjp_add_record_entries() { if(!n3fjp_socket) return; if (!n3fjp_connected) return; std::string cmd, response, val; try { if (n3fjp_has_xcvr_control == N3FJP) send_data(); else send_data_norig(); } catch (const SocketException& e) { result.str(""); result << "Error: " << e.error() << ", " << e.what(); n3fjp_print(result.str()); throw e; } n3fjp_bool_add_record = false; } void n3fjp_set_freq(long f) { char szfreq[20]; snprintf(szfreq, sizeof(szfreq), "%ld", f); std::string freq = szfreq; while (freq.length() < 7) freq.insert(0, "0"); freq.insert(freq.length() - 6, "."); std::string cmd; cmd.assign("<CMD><CHANGEFREQ><VALUE>"); cmd.append(freq); cmd.append("</VALUE><SUPPRESSMODEDEFAULT>TRUE</SUPPRESSMODEDEFAULT></CMD>"); { guard_lock send_lock(&send_this_mutex); send_this = cmd; } } void n3fjp_set_ptt(int on) { if (n3fjp_has_xcvr_control != N3FJP) return; std::string cmd = "<CMD>"; if (on) { if (progdefaults.enable_N3FJP_RIGTX) cmd.append("<RIGTX>"); else cmd.append("<CWCOMPORTKEYDOWN>"); } else { if (progdefaults.enable_N3FJP_RIGTX) cmd.append("<RIGRX>"); else cmd.append("<CWCOMPORTKEYUP>"); } cmd.append("</CMD>"); { guard_lock send_lock(&send_this_mutex); send_this = cmd; } } void n3fjp_add_record(cQsoRec &record) { if (!n3fjp_connected) return; rec = record; n3fjp_bool_add_record = true; } std::string n3fjp_serno = ""; void n3fjp_parse_next_serial(std::string buff) { n3fjp_serno = ParseValueField("NEXTSERIALNUMBERRESPONSE", buff); updateOutSerNo(); } //====================================================================== // //====================================================================== void n3fjp_parse_response(std::string tempbuff) { if (tempbuff.empty()) return; size_t p1 = std::string::npos, p2 = std::string::npos; if (tempbuff.find("RIGRESPONSE") != std::string::npos) { size_t p0 = tempbuff.find("<RIG>"); if (p0 != std::string::npos) { p0 += strlen("<RIG>"); std::string rigname = tempbuff.substr(p0); p0 = rigname.find("</RIG>"); if (p0 != std::string::npos) { rigname.erase(p0); if (rigname != "None" && rigname != "Client API") { n3fjp_has_xcvr_control = N3FJP; send_command("READBMF"); } else n3fjp_has_xcvr_control = FLDIGI; } } } if (n3fjp_has_xcvr_control == N3FJP) { if ((p1 = tempbuff.find("<CHANGEFREQ><VALUE>")) != std::string::npos) { p1 += strlen("<CHANGEFREQ><VALUE>"); p2 = tempbuff.find("</VALUE>", p1); if (p2 == std::string::npos) return; std::string sfreq = tempbuff.substr(p1, p2 - p1); REQ(adjust_freq, sfreq); } else if (tempbuff.find("<READBMFRESPONSE>") != std::string::npos) { std::string sfreq = ParseField(tempbuff, "FREQ"); REQ(adjust_freq, sfreq); } } if (tempbuff.find("<CALLTABEVENT>") != std::string::npos) { n3fjp_rxbuffer = tempbuff; REQ(n3fjp_parse_calltab_event, tempbuff); } if (tempbuff.find("ALLFIELDSWVRESPONSE") != std::string::npos) { REQ(n3fjp_parse_data_stream, tempbuff); } if (tempbuff.find("<ENTEREVENT>") != std::string::npos) { send_command("NEXTSERIALNUMBER"); } if (tempbuff.find("<NEXTSERIALNUMBERRESPONSE>") != std::string::npos) { REQ(n3fjp_parse_next_serial, tempbuff); } if (tempbuff.find("CALLTABDUPEEVENT") != std::string::npos && tempbuff.find("Duplicate") != std::string::npos) { if (tempbuff.find("Possible") != std::string::npos) REQ(show_dup, (void*)2); else REQ(show_dup, (void*)1); } } //====================================================================== // //====================================================================== void n3fjp_rcv_data() { std::string tempbuff = ""; try { n3fjp_rcv(tempbuff, progdefaults.enable_N3FJP_log); n3fjp_parse_response(tempbuff); } catch (const SocketException& e) { result.str(""); result << "n3fjp_rcv_data()::failed " << e.error() << " " << e.what(); n3fjp_print(result.str()); throw e; } catch (...) { throw; } } static int logger_nbr = 0; inline bool match(std::string s1, std::string s2) { return (s1.find(s2) != std::string::npos || s2.find(s1) != std::string::npos); } static void select_fldigi_logging() { // check for specific contest size_t n = 0; std::string logger = n3fjp_logger[logger_nbr].program; n3fjp_print(std::string("logger: ").append(logger)); if (logger == "Amateur Contact Log") { listbox_contest->index(0); progdefaults.logging = 0; UI_select(); return; } if ((n = logger.find("Jamboree") != std::string::npos)) { logger.insert(0, "ARRL "); } if (logger.find("CQ WW DX RTTY") != std::string::npos) logger = "WW DX RTTY"; progdefaults.CONTESTnotes = ""; for (int n = 2; !contests[n].name.empty(); n++) { if (match(contests[n].name, logger)) { progdefaults.logging = n; listbox_contest->index(n); listbox_QP_contests->index(0); UI_select(); progdefaults.CONTESTnotes = contests[progdefaults.logging].notes; inp_contest_notes->value(progdefaults.CONTESTnotes.c_str()); n3fjp_print(std::string("found: ").append(contests[n].name)); return; } } n3fjp_print(std::string("Check for SQSO: ").append(logger)); if ((n = logger.find("QP Contest Log")) != std::string::npos) { logger.erase(n + 2, 12); progdefaults.logging = LOG_SQSO; listbox_contest->index(progdefaults.logging); n3fjp_print(std::string("Out of state SQSO log: ").append(logger)); } else if ((n = logger.find(" QSO Party Contest Log")) != std::string::npos) { logger.erase(n + 10); progdefaults.logging = LOG_SQSO; listbox_contest->index(progdefaults.logging); n3fjp_print(std::string("In state SQSO log: ").append(logger)); } for (n = 1; QSOparties.qso_parties[n].contest[0]; n++) { if (logger == QSOparties.qso_parties[n].contest) { n3fjp_print(std::string("QSOparty: ").append(QSOparties.qso_parties[n].contest)); progdefaults.SQSOcontest = n; listbox_QP_contests->index(progdefaults.SQSOcontest - 1); inp_contest_notes->value(progdefaults.CONTESTnotes.c_str()); progdefaults.CONTESTnotes = QSOparties.qso_parties[progdefaults.SQSOcontest].notes; adjust_for_contest(0); } } inp_contest_notes->value(progdefaults.CONTESTnotes.c_str()); UI_select(); clearQSO(); return; } static void fldigi_no_contest() { progdefaults.SQSOcontest = 0;//1; progdefaults.logging = 0; adjust_for_contest(0); UI_select(); set_log_colors(); clearQSO(); listbox_contest->index(0); } static int connect_tries = 0; static bool connect_to_n3fjp_server() { try { n3fjp_serno.clear(); if (!n3fjp_connected) n3fjp_socket->connect(); if (!n3fjp_socket->is_connected()) { MilliSleep(200); n3fjp_socket->connect(); if (!n3fjp_socket->is_connected()) { if (!connect_tries--) { result.str(""); result << "Cannot connect to server: " << n3fjp_socket->fd(); n3fjp_print(result.str()); connect_tries = 20; } return false; } result.str(""); result << "connected to n3fjp server: " << n3fjp_socket->fd(); n3fjp_print(result.str()); connect_tries = 0; } std::string buffer; std::string cmd = "<CMD><PROGRAM></CMD>"; n3fjp_send(cmd, true); buffer.clear(); size_t n; for (n = 0; n < 10; n++) { n3fjp_rcv(buffer, true); if (!buffer.empty()) break; } if (buffer.empty()) { n3fjp_print("N3FJP logger not responding"); return false; } std::string info = ParseField(buffer, "PGM"); connected_to = info; n3fjp_contest = FJP_NONE; n = info.find("N3FJP's "); if (n != std::string::npos) info.erase(n, 8); if (info.find("Winter") != std::string::npos) info = "Winter FD"; n3fjp_print(std::string("Info: ").append(info)); for (n = 0; n < sizeof(n3fjp_logger) / sizeof(*n3fjp_logger); n++) { if (info.find(n3fjp_logger[n].program) == 0) { n3fjp_contest = n3fjp_logger[n].contest; n3fjp_in_state = n3fjp_logger[n].in_state; logger_nbr = n; REQ(select_fldigi_logging); break; } } if (n == sizeof(n3fjp_logger) / sizeof(*n3fjp_logger)) { n3fjp_print(std::string(info).append(" not supported by fldigi")); return false; } else n3fjp_print(std::string("Connected to: ").append(n3fjp_logger[n].program)); send_command("NEXTSERIALNUMBER"); info.insert(0, "Connected to "); std::string ver = ParseField(buffer, "VER"); info.append(", Ver ").append(ver); n3fjp_connected = true; REQ(set_connect_box); cmd = " <CMD><VISIBLEFIELDS></CMD>"; n3fjp_send(cmd, true); buffer.clear(); n3fjp_rcv(buffer, true); cmd = "<CMD><CALLTABENTEREVENTS><VALUE>TRUE</VALUE></CMD>"; n3fjp_send(cmd, progdefaults.enable_N3FJP_log); cmd = "<CMD><READOFFSETENABLED></CMD>"; n3fjp_send(cmd, progdefaults.enable_N3FJP_log); cmd = "<CMD><READOFFSET></CMD>"; n3fjp_send(cmd, progdefaults.enable_N3FJP_log); cmd = "<CMD><READMODEDEFAULTSUPPRESS></CMD>"; n3fjp_send(cmd, progdefaults.enable_N3FJP_log); cmd = "RIGENABLED"; send_command(cmd); } catch (const SocketException& e) { result.str(""); result << e.what() << "(" << e.error() << ")"; n3fjp_print(result.str()); connected_to.clear(); LOG_ERROR("%s", result.str().c_str()); } catch (...) { n3fjp_print("Caught unknown error"); LOG_ERROR("%s", "Caught unknown error"); connected_to.clear(); } return true; } //====================================================================== // //====================================================================== void n3fjp_start() { n3fjp_ip_address = progdefaults.N3FJP_address; n3fjp_ip_port = progdefaults.N3FJP_port; try { if (n3fjp_socket) delete n3fjp_socket; n3fjp_socket = new Socket( Address( n3fjp_ip_address.c_str(), n3fjp_ip_port.c_str(), "tcp") ); if (!n3fjp_socket) return; n3fjp_socket->set_timeout(0.20);//0.05); n3fjp_socket->set_nonblocking(true); result.str(""); result << "Client socket " << n3fjp_socket->fd(); n3fjp_print(result.str()); } catch (const SocketException& e) { result.str(""); result << e.what() << "(" << e.error() << ")"; n3fjp_print(result.str()); LOG_ERROR("%s", result.str().c_str() ); delete n3fjp_socket; n3fjp_socket = 0; n3fjp_connected = false; REQ(set_connect_box); n3fjp_has_xcvr_control = UNKNOWN; } catch (...) { n3fjp_print("Caught unknown error"); n3fjp_print(result.str()); LOG_ERROR("%s", result.str().c_str() ); delete n3fjp_socket; n3fjp_socket = 0; n3fjp_connected = false; REQ(set_connect_box); n3fjp_has_xcvr_control = UNKNOWN; } } //====================================================================== // Disconnect from N3FJP tcpip server //====================================================================== void n3fjp_disconnect(bool clearlog) { if (n3fjp_socket) { n3fjp_send("", false);//progdefaults.enable_N3FJP_log); delete n3fjp_socket; n3fjp_socket = 0; } n3fjp_connected = false; n3fjp_has_xcvr_control = UNKNOWN; n3fjp_serno.clear(); connected_to.clear(); REQ(set_connect_box); if (clearlog) REQ(fldigi_no_contest); n3fjp_print("Disconnected"); } //====================================================================== // Thread loop //====================================================================== void *n3fjp_loop(void *args) { SET_THREAD_ID(N3FJP_TID); int loopcount = 9; int n3fjp_looptime = 100; // initially 0.1 second delay to connect while(1) { if (n3fjp_exit) break; MilliSleep(10); if (n3fjp_wait) n3fjp_wait -= 10; if (n3fjp_looptime) n3fjp_looptime -= 10; if (n3fjp_wait > 0) continue; if (n3fjp_looptime > 0) continue; n3fjp_looptime = 250; // r/w to N3FJP logger every 1/4 second loopcount = (loopcount + 1) % 10; if (progdefaults.connect_to_n3fjp) { if (!n3fjp_socket || (n3fjp_socket->fd() == -1)) n3fjp_start(); else { if ((n3fjp_ip_address != progdefaults.N3FJP_address) || (n3fjp_ip_port != progdefaults.N3FJP_port) ) { n3fjp_disconnect(true); n3fjp_start(); } if (!n3fjp_connected) { if (loopcount == 0) if (!connect_to_n3fjp_server()) n3fjp_disconnect(false); } else try { // insure connection still up (2.5 second interval) if (loopcount == 0) { guard_lock send_lock(&send_this_mutex); std::string buffer; std::string cmd = "<CMD><PROGRAM></CMD>"; n3fjp_send(cmd, false); size_t n; for (n = 0; n < 10; n++) { n3fjp_rcv(buffer, false); if (!buffer.empty()) break; } if (buffer.empty()) { n3fjp_print(std::string("Lost server connection to ").append(connected_to)); n3fjp_disconnect(true); continue; } } if (n3fjp_has_xcvr_control == FLDIGI) n3fjp_send_freq_mode(); if (!send_this.empty()) { guard_lock send_lock(&send_this_mutex); n3fjp_send(send_this, progdefaults.enable_N3FJP_log); send_this.clear(); } else if (n3fjp_bool_add_record) do_n3fjp_add_record_entries(); else { guard_lock rx_lock(&n3fjp_mutex); n3fjp_rcv_data(); } } catch (const SocketException& e) { result.str(""); result << "Error: " << e.error() << ", " << e.what(); n3fjp_print(result.str()); n3fjp_disconnect(true); } catch (...) { n3fjp_print("Caught unknown error"); n3fjp_disconnect(true); } } } else if (n3fjp_connected) n3fjp_disconnect(true); } // exit the n3fjp thread SET_THREAD_CANCEL(); return NULL; } //====================================================================== // //====================================================================== void n3fjp_init(void) { n3fjp_enabled = false; n3fjp_exit = false; if (pthread_create(&n3fjp_thread, NULL, n3fjp_loop, NULL) < 0) { LOG_ERROR("pthread_create failed"); return; } LOG_INFO("N3FJP logger thread started"); pathname = DebugDir; pathname.append("n3fjp_data_stream.txt"); rotate_log(pathname); FILE *n3fjplog = fl_fopen(pathname.c_str(), "w"); fprintf(n3fjplog, "N3FJP / fldigi tcpip log\n\n"); fclose(n3fjplog); n3fjp_enabled = true; } //====================================================================== // //====================================================================== void n3fjp_close(void) { if (!n3fjp_enabled) return; guard_lock close_lock(&n3fjp_socket_mutex); n3fjp_exit = true; CANCEL_THREAD(n3fjp_thread); pthread_join(n3fjp_thread, NULL); n3fjp_enabled = false; LOG_INFO("%s", "N3FJP logger thread terminated. "); if(n3fjp_socket) { delete n3fjp_socket; n3fjp_socket = 0; } } /* FLDIGI log fields FREQ QSO frequency in Mhz CALL contacted stations CALLSIGN MODE QSO mode NAME contacted operators NAME QSO_DATE QSO date QSO_DATE_OFF QSO date OFF, according to ADIF 2.2.6 TIME_OFF HHMM or HHMMSS in UTC TIME_ON HHMM or HHMMSS in UTC QTH contacted stations city RST_RCVD received signal report RST_SENT sent signal report STATE contacted stations STATE VE_PROV 2 letter abbreviation for Canadian Province NOTES QSO notes QSLRDATE QSL received date QSLSDATE QSL sent date EQSLRDATE EQSL received date EQSLSDATE EQSL sent date LOTWRDATE EQSL received date LOTWSDATE EQSL sent date GRIDSQUARE contacted stations Maidenhead Grid Square BAND QSO band CNTY secondary political subdivision, ie: county COUNTRY contacted stations DXCC entity name CQZ contacted stations CQ Zone DXCC contacted stations Country Code QSL_VIA contacted stations QSL manager IOTA Islands on the air ITUZ ITU zone CONT contacted stations continent SRX received serial number for a contest QSO STX QSO transmitted serial number XCHG1 contest exchange received MYXCHG contest exchange sent CLASS Field Day class received ARRL_SECT Field Day section received TX_PWR power transmitted by this station OP_CALL Callsign of person logging the QSO STA_CALL Callsign of transmitting station MY_GRID Xmt station locator MY_CITY Xmt station city SS_SEC CW sweepstakes section SS_SERNO CW sweepstakes serial number received SS_PREC CW sweepstakes precedence SS_CHK CW sweepstakes check AGE contacted operators age in years TEN_TEN contacted stations ten ten # CHECK contacted stations contest identifier |-------------------------------------------------------------| | N3FJP field | FLDIGI LOG FIELD | |--------------------------------|----------------------------| | txtEntry1010 | rec.getField(TEN_TEN) | | txtEntryCall | rec.getField(CALL) | | txtEntryCheck (Rookie Roundup) | rec.getField(CHECK) | | txtEntryCheck (1010 ??) ) | rec.getField(CHECK) | | txtEntryClass | rec.getField(CLASS) | | txtEntryCountyR | rec.getField(CNTY) | | txtEntryGrid | rec.getField(GRIDSQUARE) | | txtEntryNameR | rec.getField(NAME) | | txtEntryRSTR | rec.getField(RST_RCVD) | | txtEntryRSTS | rec.getField(RST_SENT) | | txtEntrySection | rec.getField(ARRL_SECT) | | txtEntrySection | rec.getField(SS_SEC) | | txtEntrySerialNoT | rec.getField(STX) | | txtEntrySerialNoR | rec.getField(SRX) | | txtEntrySpcNum | rec.getField(XCHG1) | | txtEntryState | rec.getField(STATE) | | txtEntryState | rec.getField(VE_PROV) ?? | |-------------------------------------------------------------| Use this command to query N3FJP logger to find which fields are visible for any given program. <CMD><VISIBLEFIELDS></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYCOUNTYR</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYSTATE</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYCOUNTRYWORKED</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYMODE</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYBAND</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYDATE</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYTIMEOFF</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYTIMEON</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYRSTS</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYRSTR</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYPOWER</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYOTHER1</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYNAMER</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYFREQUENCY</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYCOMMENTS</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>TXTENTRYCALL</CONTROL><VALUE></VALUE></CMD> <CMD><VISIBLEFIELDSRESPONSE><CONTROL>LBLDIALOGUE</CONTROL><VALUE>Ready to begin!</VALUE></CMD> Africa All Mode: RST / Serial Received ARRL Field Day: Class / Section ARRL Kids Day: Name / Age / SPCNum ARRL Rookie Roundup: Name / Check / SPCNum ARRL RTTY: RST / SPCNum ARRL School Club Roundup: RST / Class / SPCNum / Name (optional) CQ WPX: RST / Serial Received CQ WW RTTY: RST / CQ Zone (autofilled from call) / State (or Province) Italian ARI International DX: RST / SPCNum Jamboree On The Air (lots of unrequired fields) NCJ North American QSO Party: Name / SPCNum NCJ North American Sprint: Serial Received / Name / SPCNum State QSO Parties, varies: Name State County Serial Received Section SPCNum Ten Ten: Name / SPCNum / 1010 number VHF: Grid / RST Worked All Europe: RST / Serial Received (QTCs not coded in API) Winter Field Day: Category (use class, just like ARRL Field Day) / Section */
79,266
C++
.cxx
2,562
28.400468
94
0.619437
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,253
qrzlib.cxx
w1hkj_fldigi/src/logbook/qrzlib.cxx
// ---------------------------------------------------------------------------- // qrzlib.cc // // Interface library to the QRZ database distributed by AA7BQ // // Copyright (C) 1999-2009 David Freese // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #include <unistd.h> #include <string> #include <iostream> #include "qrzlib.h" #include "configuration.h" #include "debug.h" static char QRZdir[256] = ""; static const char *QRZpath; static const char *QRZtry[] = { #ifdef __WOE32__ "C:/CALLBK/", // look on C: drive first "D:/CALLBK/", "E:/CALLBK/", "F:/CALLBK/", "G:/CALLBK/", #else "~/callbk/", "/cdrom/callbk/", "/mnt/cdrom/callbk/", "/mnt/cdrom0/callbk/", "/mnt/cdrom1/callbk/", "/media/cdrom/callbk/", "/media/cdrom0/callbk/", "/media/cdrom1/callbk/", #endif 0 }; FILE *imagefile = NULL; #define isdirsep(c) ((c)=='/') int filename_expand(char *to,int tolen, const char *from) { char temp[tolen]; strlcpy(temp,from, tolen); char *start = temp; char *end = temp+strlen(temp); int ret = 0; for (char *a=temp; a<end; ) { // for each slash component char *e; for (e=a; e<end && !isdirsep(*e); e++); // find next slash const char *value = 0; // this will point at substitute value switch (*a) { case '~': // a home directory name if (e <= a+1) { // current user's directory value = getenv("HOME"); } break; case '$': /* an environment variable */ {char t = *e; *(char *)e = 0; value = getenv(a+1); *(char *)e = t;} break; } if (value) { // substitutions that start with slash delete everything before them: if (isdirsep(value[0])) start = a; int t = strlen(value); if (isdirsep(value[t-1])) t--; if ((end+1-e+t) >= tolen) end += tolen - (end+1-e+t); memmove(a+t, e, end+1-e); end = a+t+(end-e); *end = '\0'; memcpy(a, value, t); ret++; } else { a = e+1; } } strlcpy(to, start, tolen); return ret; } char *QRZImageFilename (char *call) { static char fname[80], *p, imgcall[12]; FILE *f; strcpy(imgcall, call); p = imgcall; while (*p) {*p = tolower (*p); p++; } strcpy (fname, QRZdir); strcat (fname, "images/"); strcat (fname, &imgcall[strlen(imgcall)-1]); strcat (fname, "/"); strcat (fname, imgcall); while (fname[strlen(fname)-1] == ' ') fname[strlen(fname)-1] = 0; strcat (fname, ".jpg"); f = fl_fopen(fname, "r"); if (f != NULL) { fclose (f); return fname; } return NULL; } int checkPath( const char *filename ) { char fname[120]; FILE *f; bool notfound = false; if (!progdefaults.QRZpathname.empty()) { strcpy ( fname, progdefaults.QRZpathname.c_str()); for (size_t i = 0; i < strlen(fname); i++) if (fname[i] == '\\') fname[i] = '/'; // fix for DOS path convention strcat( fname, filename ); strcat( fname, ".dat" ); if (fname[0] == '~' || fname[0] == '$') { char f2name[80]; filename_expand(f2name, 79, fname); strcpy (fname, f2name); } f = fl_fopen(fname, "r" ); if( f != NULL ) { fclose( f ); char pathname[120]; strcpy( pathname, progdefaults.QRZpathname.c_str()); if (pathname[0] == '~' || pathname[0] == '$') filename_expand(QRZdir, 79, pathname); else strcpy (QRZdir, pathname); return 1; } std::string err = fname; err.append(" not found, performing search"); LOG_WARN("%s", err.c_str()); notfound = true; } // not specified, perform a search const char **pQRZpath = QRZtry; while (*pQRZpath) { strcpy( fname, *pQRZpath ); strcat( fname, filename ); strcat( fname, ".dat" ); if (fname[0] == '~' || fname[0] == '$') { char f2name[80]; filename_expand(f2name, 79, fname); strcpy (fname, f2name); } f = fl_fopen(fname, "r" ); if( f != NULL ) { fclose( f ); QRZpath = *pQRZpath; if (QRZpath[0] == '~' || QRZpath[0] == '$') filename_expand(QRZdir, 79, QRZpath); else strcpy (QRZdir, QRZpath); if (notfound) { std::string err = "Using "; err.append(fname); LOG_WARN("%s", err.c_str()); } return 1; } pQRZpath++; } QRZpath = QRZtry[0]; LOG_WARN("QRZ data base not found"); return 0; } void SetQRZdirectory(char *dir) { strcpy(QRZdir, dir); strcat(QRZdir, "/"); } bool QRZ::ImageExists() { if (Qimagefname == NULL) return (hasImage = false); imagefile = fl_fopen(Qimagefname, "r"); if (imagefile) { fclose (imagefile); return (hasImage = true); } return (hasImage = false); } void QRZ::OpenQRZFiles( const char *fname ) { long fsize; char dfname[64]; char idxname[64]; int num1; int num2; num1 = 0; num2 = 0; if( fname[0] == 0 ) { QRZvalid = 0; return; } QRZvalid = 1; if (*QRZdir == 0) if( checkPath( fname ) == 0 ) { QRZvalid = 0; return; } strcpy( dfname, QRZdir ); strcpy( idxname, QRZdir ); strcat( idxname, fname ); strcat( idxname, ".idx" ); strcat( dfname, fname ); strcat( dfname, ".dat" ); idxfile = fl_fopen( idxname, "r" ); if( idxfile == NULL ) { QRZvalid = 0; return; } fseek( idxfile, 0, SEEK_END ); fsize = ftell( idxfile ); rewind( idxfile ); idxsize = fsize - 48; index = new char[idxsize]; if( index == NULL ) { fclose( idxfile ); QRZvalid = 0; return; } memset( index, 0, idxsize ); num1 = fread( &idxhdr.dataname, 48, 1, idxfile ); num2 = fread( index, idxsize, 1, idxfile ); if (num1 != 1 || num2 != 1) { fclose( idxfile ); delete [] index; QRZvalid = 0; return; } fflush( stdout ); fclose( idxfile ); datafile = fl_fopen( dfname, "r" ); if( datafile == NULL ) { delete [] index; QRZvalid = 0; return; } sscanf( idxhdr.bytesperkey, "%d", &datarecsize ); if( datarecsize == 0 || datarecsize > 32767 ) { delete [] index; QRZvalid = 0; return; } // allocate sufficient data buffer for file read over key boundary if (data) delete [] data; data = new char[datarecsize + 512]; if( data == NULL ) { delete [] index; QRZvalid = 0; return; } // fill buffer with new-lines to insure not reading past end of // the buffer memset( data, '\n', datarecsize + 512 ); sscanf( idxhdr.keylen, "%d", &keylen ); sscanf( idxhdr.numkeys, "%ld", &numkeys ); top = index + idxsize - keylen; } QRZ::QRZ( const char *fname ) { int len = strlen(fname); criteria = fname[ len - 1 ]; OpenQRZFiles( fname ); } QRZ::QRZ( const char *fname, char c ) { criteria = c; OpenQRZFiles( fname ); } void QRZ::NewDBpath( const char *fname ) { int len = strlen(fname); criteria = fname[ len - 1 ]; *QRZdir = 0; OpenQRZFiles( fname ); } QRZ::~QRZ() { if (index) delete [] index; if (data) delete [] data; if( datafile != NULL ) fclose( datafile ); return; } int QRZ::CallComp( char *s1, char *s2 ) { static char sa[7], sb[7]; strncpy( sb, s2, 6 ); strncpy( sa, s1, 6 ); sa[6] = 0; sb[6] = 0; int stest = strncasecmp( sa + 3, sb + 3, 3 ); if( stest < 0 ) return -1; if( stest > 0 ) return 1; // suffix are equal int atest = strncasecmp( sa + 2, sb + 2, 1 ); if( atest < 0 ) return -1; if( atest > 0 ) return 1; // suffix & call area are equal int ptest = strncasecmp( sa, sb, 2 ); if( ptest < 0 ) return -1; if( ptest > 0 ) return 1; // total match of calls return 0; } char *Composite( char *s ) { static char newstr[7]; int ccount = strlen(s) < 7 ? strlen(s) : 6; memset(newstr, ' ', 6 ); newstr[6] = 0; if( isdigit( s[2] ) ) { for( int i = 0; i < ccount; i++ ) newstr[i] = s[i]; } else { newstr[0] = s[0]; newstr[2] = s[1]; for( int i = 2; i < ccount; i++ ) newstr[i+1] = s[i]; } return( newstr ); } int QRZ::ReadDataBlock( long p ) { rewind( datafile ); if ( p < 0 ) p = 0; if( fseek( datafile, p, SEEK_SET ) != 0 ) { return 1; } databytesread = fread( data, 1, datarecsize + 512, datafile ); dataoffset = p; fflush( stdout); return 0; } int QRZ::FindCallsign( char *field ) { char composite[7], testcall[7]; char *endofdata; int matched = 0, iOffset; memset( composite, 0, 6 ); memset( testcall, 0, 6 ); found = 0; idxptr = index; if( strlen( field ) < 3 ) // must be a valid callsign return 0; if ( !(isdigit( field[1] ) || isdigit( field[2] ) ) ) return 0; strcpy( composite, Composite( field ) ); for( iOffset = 0; iOffset < numkeys; iOffset++, idxptr += keylen ) if( CallComp( composite, idxptr) <= 0 ) break; iOffset--; if (iOffset < 0) iOffset = 0; ReadDataBlock( datarecsize * iOffset ); dfptr = data; endofdata = data + databytesread; endofline = strchr( dfptr, '\n' ); if( idxptr != index ) { endofline = strchr( dfptr, '\n' ); if (endofline != NULL ) dfptr = endofline + 1; } found = 0; while ( !found && (dfptr < endofdata ) ) { memcpy( testcall, dfptr, 6 ); if( (matched = CallComp( composite, Composite(testcall) ) ) <= 0 ) found = 1; else { endofline = strchr( dfptr, '\n' ); dfptr = endofline + 1; } } if ( matched == 0 ) { endofline = strchr( dfptr, '\n' ); *endofline = 0; strcpy( recbuffer, dfptr ); // check for old call referencing new call if (strlen(recbuffer) < 15 ) { dfptr = strchr( dfptr, ',' ) + 1; strcpy( recbuffer, dfptr ); // Qcall = recbuffer; found = -1; } else { found = 1; dfptr = endofline + 1; // point to next record } return (found); } found = 0; return 0; } int QRZ::nextrec() { if( dfptr > data + datarecsize ) { if( ReadDataBlock( dataoffset + (dfptr - data) ) != 0) return 0; dfptr = data; } endofline = strchr( dfptr, '\n' ); *endofline = 0; strcpy( recbuffer, dfptr ); dfptr = endofline + 1; if (strlen(recbuffer) < 15 ) { nextrec(); } return 1; } int QRZ::NextRecord() { if( nextrec() == 1 ) return( ReadRec() ); return 0; } int QRZ::FindName( char *field ) { char *endofdata; int matched = 0, iOffset; char *Lname, *Fname; char sFname[17]; char sLname[17]; char sIdxName[33]; char *cptr; memset( sFname, 0, 17 ); memset( sLname, 0, 17 ); memset( sIdxName, 0, 33 ); if ( (cptr = strchr( field, ',' ) ) != NULL ) { strncpy( sLname, field, cptr - field ); strcpy( sFname, cptr + 1 ); } else strcpy( sLname, field ); strcpy( sIdxName, sLname ); if( strlen( sFname ) > 0 ) { strcat( sIdxName, " " ); strcat( sIdxName, sFname ); } found = 0; idxptr = index; for( iOffset = 0; iOffset < numkeys; iOffset++, idxptr += keylen ) if( strncasecmp( sIdxName, idxptr, keylen ) <= 0 ) break; iOffset--; if (iOffset < 0) iOffset = 0; ReadDataBlock( datarecsize * iOffset ); dfptr = data; endofdata = data + databytesread; if( idxptr != index ) { endofline = strchr( dfptr, '\n' ); if (endofline != NULL ) dfptr = endofline + 1; } found = 0; while ( !found && (dfptr < endofdata ) ) { endofline = strchr( dfptr, '\n' ); if( endofline == NULL || endofline > endofdata ) break; if( endofline - dfptr > 14 ) { // valid racord Lname = strchr( dfptr, ',' ) + 1; // locate Lname element Fname = strchr( Lname, ',' ) + 1; // locate Fname element if( *Fname == ',' ) Fname++; else Fname = strchr( Fname, ',' ) + 1; if( (matched = strncasecmp( sLname, Lname, strlen(sLname) ) ) == 0 ) { if( sFname[0] == 0 ) found = 1; else if( ( matched = strncasecmp( sFname, Fname, strlen(sFname) ) ) <= 0 ) found = 1; } } if (!found && (dfptr < endofdata ) ) dfptr = strchr( dfptr, '\n' ) + 1; // move to next record } if ( matched == 0 ) { endofline = strchr( dfptr, '\n' ); *endofline = 0; strcpy( recbuffer, dfptr ); found = 1; dfptr = endofline + 1; // point to next record return (found); } found = 0; return 0; } int QRZ::CompState( const char *field, const char *state, const char *city ) { int compsize = strlen(field+2), chk; if (compsize > keylen) compsize = keylen; if(strlen( field ) == 2) return ( strncasecmp( field, state, 2 ) ); if( (chk = strncasecmp( field, state, 2 ) ) < 0 ) return -1; if( chk > 0 ) return 1; chk = strncasecmp( field + 2, city, compsize); if (chk < 0) return -1; if (chk > 0) return 1; return 0; } int QRZ::FindState( char *field ) { char *endofdata; int matched = 0, iOffset; char *state; char *city; int compsize = strlen(field); if (compsize > keylen) compsize = keylen; found = 0; idxptr = index; for( iOffset = 0; iOffset < numkeys; iOffset++, idxptr += keylen ) if( strncasecmp( field, idxptr, compsize ) <= 0 ) break; iOffset--; if (iOffset < 0) iOffset = 0; ReadDataBlock( datarecsize * iOffset ); dfptr = data; endofdata = data + datarecsize; if( idxptr != index ) { endofline = strchr( dfptr, '\n' ); if (endofline != NULL ) dfptr = endofline + 1; } found = 0; while ( !found && (dfptr < endofdata ) ) { endofline = strchr( dfptr, '\n' ); if( endofline - dfptr > 14 ) { // valid record city = dfptr; for( int i = 0; i < 9; i++ ) // move to city element city = strchr( city, ',' ) + 1; state = strchr( city, ',' ) + 1; // move to state element matched = CompState( field, state, city ); if( matched == 0) found = 1; else { endofline = strchr( dfptr, '\n' ); // no match, move to next dfptr = endofline + 1; } } else { endofline = strchr( dfptr, '\n' ); // invalid record, move to next dfptr = endofline + 1; } } if ( matched == 0 ) { endofline = strchr( dfptr, '\n' ); *endofline = 0; strcpy( recbuffer, dfptr ); found = 1; dfptr = endofline + 1; // point to next record return (found); } found = 0; return 0; } int QRZ::FindZip( char *field ) { char *endofdata; int matched = 0, iOffset; char *zip; found = 0; idxptr = index; for( iOffset = 0; iOffset < numkeys; iOffset++, idxptr += keylen ) if( strncasecmp( field, idxptr, 5 ) <= 0 ) break; iOffset--; if (iOffset < 0) iOffset = 0; ReadDataBlock( datarecsize * iOffset ); dfptr = data; endofdata = data + datarecsize; if( idxptr != index ) { endofline = strchr( dfptr, '\n' ); if (endofline != NULL ) dfptr = endofline + 1; } found = 0; while ( !found && (dfptr < endofdata ) ) { endofline = strchr( dfptr, '\n' ); if( endofline - dfptr > 14 ) { // valid record zip = dfptr; for( int i = 0; i < 11; i++ ) // move to Zip element zip = strchr( zip, ',' ) + 1; if( (matched = strncasecmp( field, zip, 5 ) ) <= 0 ) found = 1; else { endofline = strchr( dfptr, '\n' ); // no match, move to next dfptr = endofline + 1; } } else { endofline = strchr( dfptr, '\n' ); // invalid record, move to next dfptr = endofline + 1; } } if ( matched == 0 ) { endofline = strchr( dfptr, '\n' ); *endofline = 0; strcpy( recbuffer, dfptr ); found = 1; dfptr = endofline + 1; // point to next record return (found); } found = 0; return 0; } int QRZ::FindRecord( char *field ) { if (QRZvalid == 0 ) return 0; switch (criteria) { case 'c' : FindCallsign( field ); break; case 'n' : FindName( field ); break; case 's' : FindState( field ); break; case 'z' : FindZip( field ); } return( ReadRec() ); } int QRZ::ReadRec() { char *comma; static char empty[] = { '\0' }; if( found == 1 ) { Qcall = recbuffer; comma = strchr( Qcall, ',' ); *comma = 0; Qlname = comma + 1; comma = strchr( Qlname, ',' ); *comma = 0; Qfname = comma + 1; comma = strchr( Qfname, ',' ); Qfname = comma + 1; // skip JR field comma = strchr( Qfname, ',' ); *comma = 0; Qdob = comma + 1; comma = strchr( Qdob, ',' ); Qdob = comma + 1; // skip MI field comma = strchr( Qdob, ',' ); *comma = 0; Qefdate = comma + 1; comma = strchr( Qefdate, ',' ); *comma = 0; Qexpdate = comma + 1; comma = strchr( Qexpdate, ',' ); *comma = 0; Qmail_str = comma + 1; comma = strchr( Qmail_str, ',' ); *comma = 0; Qmail_city = comma + 1; comma = strchr( Qmail_city, ',' ); *comma = 0; Qmail_st = comma + 1; comma = strchr( Qmail_st, ',' ); *comma = 0; Qmail_zip = comma + 1; comma = strchr( Qmail_zip, ',' ); *comma = 0; Qopclass = comma + 1; comma = strchr( Qopclass, ',' ); *comma = 0; Qp_call = comma + 1; comma = strchr( Qp_call, ',' ); *comma = 0; Qp_class = comma + 1; //Qp_class[1] = 0; *(comma + 2) = 0; Qimagefname = QRZImageFilename (GetCall()); return( 1 ); } else { Qcall = empty; Qlname = empty; Qfname = empty; Qdob = empty; Qefdate = empty; Qexpdate = empty; Qmail_str = empty; Qmail_city = empty; Qmail_st = empty; Qmail_zip = empty; Qopclass = empty; Qp_call = empty; Qp_class = empty; Qimagefname = NULL; return( 0 ); } } int QRZ::GetCount( char *unknown ) { int matched, cnt = 0; char temp[40]; if( FindRecord( unknown ) != 1 ) return(0); matched = 0; while (matched == 0) { cnt++; NextRecord(); switch (criteria) { case 'c' : matched = 1; break; case 'n' : if( strchr( unknown, ',' ) == 0 ) matched = strcasecmp( unknown, GetLname() ); else { strcpy( temp, GetLname() ); strcat( temp, "," ); strcat( temp, GetFname() ); matched = strncasecmp( unknown, temp, strlen(unknown) ); } break; case 'z' : matched = strncmp( unknown, GetZIP(), 5 ); break; case 's' : matched = CompState( unknown, GetState(), GetCity() ); break; default : matched = 1; } } return cnt; } char * QRZ::GetCall() { static char call[15]; char *p = call; strcpy (call, Qcall); while (*p) { if (*p == ' ') strcpy (p, p+1); if (*p != ' ') p++; } return( call ); }; const char * QRZ::GetLname() { return( Qlname ); }; const char * QRZ::GetFname() { return( Qfname ); }; const char * QRZ::GetDOB() { return( Qdob ); }; const char * QRZ::GetEFdate() { return( Qefdate ); }; const char * QRZ::GetEXPdate() { return( Qexpdate ); }; const char * QRZ::GetStreet() { return( Qmail_str ); }; const char * QRZ::GetCity() { return( Qmail_city ); }; const char * QRZ::GetState() { return( Qmail_st ); }; const char * QRZ::GetZIP() { return( Qmail_zip ); }; const char * QRZ::GetOPclass() { return( Qopclass ); }; const char * QRZ::GetPriorCall() { return( Qp_call ); }; const char * QRZ::GetPriorClass() { return( Qp_class ); }; int QRZ::getQRZvalid() { return( QRZvalid ); } const char * QRZ::GetImageFileName () { return (Qimagefname); } char * QRZ::CSV_Record() { static char info[256]; memset( info, 0, 256 ); snprintf( info, sizeof(info) - 1, "%s,%s,%s,%s,%s,%s,%s,%s,%s", GetCall(), Qopclass, Qefdate, Qlname, Qfname, Qmail_str, Qmail_city, Qmail_st, Qmail_zip ); return info; } char *QRZ::Fmt_Record() { static char info[256]; memset( info, 0, 256 ); snprintf( info, sizeof(info) - 1, "%s %s : %s\n%s %s\n%s\n%s, %s %s\n", GetCall(), Qopclass, Qefdate, Qfname, Qlname, Qmail_str, Qmail_city, Qmail_st, Qmail_zip ); return info; }
19,504
C++
.cxx
828
20.978261
79
0.608123
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,254
xmlrpc_log.cxx
w1hkj_fldigi/src/logbook/xmlrpc_log.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <iostream> #include <cmath> #include <cstring> #include <sstream> #include <stdlib.h> #include <FL/Fl.H> #include <FL/filename.H> #include <FL/fl_ask.H> #include "xmlrpcpp/XmlRpc.h" #include "config.h" #include "lgbook.h" #include "icons.h" #include "gettext.h" #include "debug.h" #include "util.h" #include "date.h" #include "logbook.h" #include "logger.h" #include "locator.h" #include "counties.h" #include "confdialog.h" #include "fl_digi.h" #include "adif_io.h" #include "modem.h" #include "trx.h" #include "status.h" #include "configuration.h" using namespace XmlRpc; XmlRpcClient *log_client = (XmlRpcClient *)0; bool test_connection(bool info = false) { if (!log_client) { create_logbook_dialogs(); return false; } XmlRpcValue query, result; if (log_client->execute("system.listMethods", query, result)) { if (info) { std::string res; int asize = result.size(); XmlRpcValue oneArg, help; res = "Xml-log methods:"; for (int i = 0; i < asize; i++) { oneArg[0] = result[i]; try { if (std::string(result[i]).find("system") == std::string::npos) { log_client->execute("system.methodHelp", oneArg, help); res.append("\n\t").append(help); } } catch ( XmlRpcException err) { res.append("\n").append(oneArg[0]).append(": ").append(err.getMessage()); } } LOG_INFO("%s", res.c_str()); } return true; } return false; } void activate_log_menus(bool val) { set_server_label(!val); activate_menu_item(_("View"), val); activate_menu_item(_("New"), val); activate_menu_item(_("Open..."), val); activate_menu_item(_("Save"), val); activate_menu_item(_("ADIF"), val); activate_menu_item(_("Reports"), val); } std::string get_field(std::string &adifline, int field) { std::string fld; fld.append("<").append(fields[field].name).append(":"); size_t pos1 = adifline.find(fld); if (pos1 == std::string::npos) return ""; pos1 = adifline.find(">", pos1) + 1; size_t pos2 = adifline.find("<", pos1); fld = adifline.substr(pos1, pos2 - pos1); return fld; } cQsoRec* search_fllog(const char *callsign) { cQsoRec *rec = new cQsoRec; XmlRpcValue oneArg, result; if (!test_connection()) { LOG_INFO("%s","Logbook server down!"); progdefaults.xml_logbook = false; activate_log_menus(true); start_logbook(); return (cQsoRec *)0; } oneArg[0] = callsign; if (log_client->execute("log.get_record", oneArg, result)) { std::string adifline = std::string(result); rec->putField(NAME, get_field(adifline, NAME).c_str()); rec->putField(QTH, get_field(adifline, QTH).c_str()); rec->putField(QSO_DATE, get_field(adifline, QSO_DATE).c_str()); rec->putField(BAND, get_field(adifline, BAND).c_str()); rec->putField(ADIF_MODE, get_field(adifline, ADIF_MODE).c_str()); return rec; } return (cQsoRec *)0; } bool xml_get_record(const char *callsign) { XmlRpcValue oneArg, result; if (!test_connection()) { LOG_INFO("%s","Logbook server down!"); progdefaults.xml_logbook = false; activate_log_menus(true); start_logbook(); return false; } oneArg[0] = callsign; if (log_client->execute("log.get_record", oneArg, result)) { std::string adifline = std::string(result); //std::cout << adifline << std::endl; inpName->value(get_field(adifline, NAME).c_str()); inpQth->value(get_field(adifline, QTH).c_str()); inpState->value(get_field(adifline, STATE).c_str()); inpVEprov->value(get_field(adifline, VE_PROV).c_str()); cboCountry->value(get_field(adifline, COUNTRY).c_str()); inpCounty->value(get_field(adifline, CNTY).c_str()); inpLoc->value(get_field(adifline, GRIDSQUARE).c_str()); inp_SS_SerialNoR->value(get_field(adifline, SS_SERNO).c_str()); inp_SS_Precedence->value(get_field(adifline, SS_PREC).c_str()); inp_SS_Check->value(get_field(adifline, SS_CHK).c_str()); inp_SS_Section->value(get_field(adifline, SS_SEC).c_str()); inp_KD_age->value(get_field(adifline, AGE).c_str()); inp_ARR_check->value(get_field(adifline, CHECK).c_str()); inp_1010_nr->value(get_field(adifline, TEN_TEN).c_str()); inp_JOTA_troop->value(get_field(adifline, TROOPR).c_str()); inp_JOTA_scout->value(get_field(adifline, SCOUTR).c_str()); inpNotes->value(get_field(adifline, NOTES).c_str()); } else { inpName->value(""); inpQth->value(""); inpState->value(""); inpVEprov->value(""); cboCountry->value(""); inpCounty->value(""); inpLoc->value(""); inp_SS_SerialNoR->value(""); inp_SS_Precedence->value(""); inp_SS_Check->value(""); inp_SS_Section->value(""); inp_KD_age->value(""); inp_ARR_check->value(""); inp_1010_nr->value(""); inp_JOTA_troop->value(""); inp_JOTA_scout->value(""); inpNotes->value(""); } if (inpLoc->value()[0]) { double lon1, lat1, lon2, lat2; double azimuth, distance; char szAZ[4]; if ( QRB::locator2longlat(&lon1, &lat1, progdefaults.myLocator.c_str()) == QRB::QRB_OK && QRB::locator2longlat(&lon2, &lat2, inpLoc->value()) == QRB::QRB_OK && QRB::qrb(lon1, lat1, lon2, lat2, &distance, &azimuth) == QRB::QRB_OK ) { snprintf(szAZ,sizeof(szAZ),"%0.f", azimuth); inpAZ->value(szAZ); } else inpAZ->value(""); } else inpAZ->value(""); return true; } static std::string adif; static std::string notes; #define adif_str(a, b) { \ std::ostringstream os; \ os << "<" << fields[(a)].name << ":" << strlen((b)) << ">" << (b); \ adif.append(os.str()); } void xml_add_record() { if (!test_connection()) { LOG_INFO("%s","Logbook server down!"); progdefaults.xml_logbook = false; activate_log_menus(true); start_logbook(); AddRecord(); return; } // create the ADIF record char Mhz[30]; adif.erase(); adif_str(QSO_DATE, sDate_on.c_str()); adif_str(QSO_DATE_OFF, sDate_off.c_str()); adif_str(TIME_ON, sTime_on.c_str()); adif_str(TIME_OFF, sTime_off.c_str()); adif_str(CALL, inpCall->value()); { snprintf(Mhz, sizeof(Mhz), "%-f", atof(inpFreq->value()) / 1000.0); inpFreq_log->value(Mhz); adif_str(FREQ, Mhz); } adif_str(ADIF_MODE, mode_info[active_modem->get_mode()].adif_name); adif_str(RST_SENT, inpRstOut->value()); adif_str(RST_RCVD, inpRstIn->value()); adif_str(TX_PWR, progdefaults.mytxpower.c_str()); adif_str(NAME, inpName->value()); adif_str(QTH, inpQth->value()); adif_str(STATE, inpState->value()); adif_str(VE_PROV, inpVEprov->value()); adif_str(COUNTRY, cboCountry->value()); adif_str(CNTY, inpCounty->value()); adif_str(GRIDSQUARE, inpLoc->value()); adif_str(STX, outSerNo->value()); adif_str(SRX, inpSerNo->value()); adif_str(XCHG1, inpXchgIn->value()); adif_str(MYXCHG, progdefaults.myXchg.c_str()); adif_str(NOTES, inpNotes->value()); adif_str(CLASS, inpClass->value()); adif_str(ARRL_SECT, inpSection->value()); adif_str(CQZ, inp_CQzone->value()); // these fields will always be blank unless they are added to the main // QSO log area. // need to add the remaining fields adif_str(IOTA, ""); adif_str(DXCC, ""); adif_str(QSL_VIA, ""); adif_str(QSLRDATE, ""); adif_str(QSLSDATE, ""); // new contest fields adif_str(SS_SEC, inp_SS_Section->value()); adif_str(SS_SERNO, inp_SS_SerialNoR->value()); adif_str(SS_PREC, inp_SS_Precedence->value()); adif_str(SS_CHK, inp_SS_Check->value()); adif_str(AGE, inp_KD_age->value()); adif_str(TEN_TEN, inp_1010_nr->value()); adif_str(CHECK, inp_ARR_check->value()); adif_str(TROOPS, progdefaults.my_JOTA_troop.c_str()); adif_str(TROOPR, inp_JOTA_troop->value()); adif_str(SCOUTS, progdefaults.my_JOTA_scout.c_str()); adif_str(SCOUTR, inp_JOTA_scout->value()); adif_str(OP_CALL, progdefaults.operCall.c_str()); adif_str(STA_CALL, progdefaults.myCall.c_str()); adif_str(MY_CITY, std::string(progdefaults.myQth). append(", "). append(inp_QP_state_short->value()).c_str()); adif_str(MY_GRID, progdefaults.myLocator.c_str()); adif.append("<eor>"); // send it to the server XmlRpcValue oneArg, result; oneArg[0] = adif.c_str(); log_client->execute("log.add_record", oneArg, result); // submit it foreign log programs cQsoRec rec; rec.putField(CALL, inpCall->value()); rec.putField(NAME, inpName->value()); rec.putField(QSO_DATE, sDate_on.c_str()); rec.putField(QSO_DATE_OFF, sDate_off.c_str()); rec.putField(TIME_ON, inpTimeOn->value()); rec.putField(TIME_OFF, ztime()); rec.putField(FREQ, Mhz); rec.putField(ADIF_MODE, mode_info[active_modem->get_mode()].adif_name); rec.putField(QTH, inpQth->value()); rec.putField(STATE, inpState->value()); rec.putField(VE_PROV, inpVEprov->value()); rec.putField(COUNTRY, cboCountry->value()); rec.putField(CNTY, inpCounty->value()); rec.putField(GRIDSQUARE, inpLoc->value()); rec.putField(NOTES, inpNotes->value()); rec.putField(QSLRDATE, ""); rec.putField(QSLSDATE, ""); rec.putField(RST_RCVD, inpRstIn->value ()); rec.putField(RST_SENT, inpRstOut->value ()); rec.putField(SRX, inpSerNo->value()); rec.putField(STX, outSerNo->value()); rec.putField(XCHG1, inpXchgIn->value()); rec.putField(MYXCHG, progdefaults.myXchg.c_str()); rec.putField(CLASS, inpClass->value()); rec.putField(ARRL_SECT, inpSection->value()); rec.putField(CNTY, ""); rec.putField(IOTA, ""); rec.putField(DXCC, ""); rec.putField(CONT, ""); rec.putField(CQZ, ""); rec.putField(ITUZ, ""); rec.putField(TX_PWR, ""); // new contest fields rec.putField(SS_SEC, inp_SS_Section->value()); rec.putField(SS_SERNO, inp_SS_SerialNoR->value()); rec.putField(SS_PREC, inp_SS_Precedence->value()); rec.putField(SS_CHK, inp_SS_Check->value()); rec.putField(AGE, inp_KD_age->value()); rec.putField(TEN_TEN, inp_1010_nr->value()); rec.putField(CHECK, inp_ARR_check->value()); rec.putField(TROOPS, progdefaults.my_JOTA_troop.c_str()); rec.putField(TROOPR, inp_JOTA_troop->value()); rec.putField(SCOUTS, progdefaults.my_JOTA_scout.c_str()); rec.putField(SCOUTR, inp_JOTA_scout->value()); rec.putField(OP_CALL, progdefaults.operCall.c_str()); rec.putField(STA_CALL, progdefaults.myCall.c_str()); submit_record(rec); } int xml_check_dup() { int dup_test = 0; if (!test_connection()) { LOG_INFO("%s","Logbook server down!"); progdefaults.xml_logbook = false; progdefaults.changed = true; activate_log_menus(true); if (!dlgLogbook) create_logbook_dialogs(); start_logbook(); return dup_test; } XmlRpcValue six_args, result; six_args[0] = inpCall->value(); six_args[1] = progdefaults.dupmode ? mode_info[active_modem->get_mode()].adif_name : "0"; char tspn[10]; snprintf(tspn, sizeof(tspn), "%d", progdefaults.timespan); six_args[2] = progdefaults.duptimespan ? tspn : "0"; six_args[3] = progdefaults.dupband ? inpFreq->value() : "0"; six_args[4] = (progdefaults.dupstate && inpState->value()[0]) ? inpState->value() : "0"; six_args[5] = (progdefaults.dupxchg1 && inpXchgIn->value()[0]) ? inpXchgIn->value() : "0"; if (log_client->execute("log.check_dup", six_args, result)) { std::string res = std::string(result); if (res == "true") dup_test = 1; else if (res == "possible") dup_test = 2; } return dup_test; } void xml_update_eqsl() { adif.erase(); adif_str(EQSLSDATE, sDate_on.c_str()); adif.append("<EOR>"); XmlRpcValue oneArg, result; oneArg[0] = adif.c_str(); LOG_INFO("%s", "xmlrpc log: update eqsl date"); log_client->execute("log.update_record", oneArg, result); } void xml_update_lotw() { adif.erase(); adif_str(LOTWSDATE, sDate_on.c_str()); adif.append("<EOR>"); XmlRpcValue oneArg, result; oneArg[0] = adif.c_str(); LOG_INFO("%s", "xmlrpc log: update LoTW date"); log_client->execute("log.update_record", oneArg, result); } void connect_to_log_server(void *) { if (log_client) { delete log_client; log_client = 0; } LOG_INFO("%s","Create XMLRPC client"); log_client = new XmlRpcClient( progdefaults.xmllog_address.c_str(), atoi(progdefaults.xmllog_port.c_str())); LOG_INFO("%s","Created"); if (progdefaults.xml_logbook) { if (test_connection(true)) { LOG_INFO("%s","Close local logbook"); close_logbook(); if (dlgLogbook) dlgLogbook->hide(); activate_log_menus(false); } else { LOG_INFO("%s","Remote server not responding"); progdefaults.xml_logbook = false; activate_log_menus(true); start_logbook(); LOG_INFO("%s","Use local logbook"); } } else { LOG_INFO("%s","Enable local logbook"); activate_log_menus(true); start_logbook(); } }
13,159
C++
.cxx
398
30.698492
91
0.674536
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,255
adif_io.cxx
w1hkj_fldigi/src/logbook/adif_io.cxx
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <FL/Fl.H> #include <FL/filename.H> #include <FL/fl_ask.H> #include <cstring> #include <cstdlib> #include <string> #include "fl_digi.h" #include "signal.h" #include "threads.h" #include "adif_io.h" #include "config.h" #include "configuration.h" #include "lgbook.h" #include "icons.h" #include "gettext.h" #include "debug.h" #include "util.h" #include "date.h" #include "logsupport.h" #include "qrunner.h" #include "timeops.h" static pthread_mutex_t logfile_mutex = PTHREAD_MUTEX_INITIALIZER; size_t ptr, ptr2; std::string sbuff; #ifdef __WOE32__ static const char *szEOL = "\r\n"; #else static const char *szEOL = "\n"; #endif static const char *szEOR = "<EOR>"; // These ADIF fields define the ADIF database FIELD fields[] = { // TYPE, FSIZE, NAME, WIDGET {FREQ, 12, "FREQ", &btnSelectFreq}, // QSO frequency in Mhz {CALL, 30, "CALL", &btnSelectCall}, // contacted stations CALLSIGN {ADIF_MODE, 20, "MODE", &btnSelectMode}, // QSO mode {SUBMODE, 20, "SUBMODE", NULL}, // QSO submode {NAME, 80, "NAME", &btnSelectName}, // contacted operators NAME {QSO_DATE, 8, "QSO_DATE", &btnSelectQSOdateOn}, // QSO data {QSO_DATE_OFF, 8, "QSO_DATE_OFF", &btnSelectQSOdateOff},// QSO data OFF, according to ADIF 2.2.6 {TIME_OFF, 6, "TIME_OFF", &btnSelectTimeOFF}, // HHMM or HHMMSS in UTC {TIME_ON, 6, "TIME_ON", &btnSelectTimeON}, // HHMM or HHMMSS in UTC {QTH, 100, "QTH", &btnSelectQth}, // contacted stations city {RST_RCVD, 3, "RST_RCVD", &btnSelectRSTrcvd}, // received signal report {RST_SENT, 3, "RST_SENT", &btnSelectRSTsent}, // sent signal report {STATE, 20, "STATE", &btnSelectState}, // contacted stations STATE {VE_PROV, 20, "VE_PROV", &btnSelectProvince}, // 2 letter abbreviation for Canadian Province {NOTES, 512, "NOTES", &btnSelectNotes}, // QSO notes {QSLRDATE, 8, "QSLRDATE", &btnSelectQSLrcvd}, // QSL received date {QSLSDATE, 8, "QSLSDATE", &btnSelectQSLsent}, // QSL sent date {EQSLRDATE, 8, "EQSLRDATE", &btnSelecteQSLrcvd}, // EQSL received date {EQSLSDATE, 8, "EQSLSDATE", &btnSelecteQSLsent}, // EQSL sent date {LOTWRDATE, 8, "LOTWRDATE", &btnSelectLOTWrcvd}, // LOTW received date {LOTWSDATE, 8, "LOTWSDATE", &btnSelectLOTWsent}, // LOTW sent date {GRIDSQUARE, 8, "GRIDSQUARE", &btnSelectLOC}, // contacted stations Maidenhead Grid Square {BAND, 8, "BAND", &btnSelectBand}, // QSO band {CNTY, 60, "CNTY", &btnSelectCNTY}, // secondary political subdivision, ie: county {COUNTRY, 60, "COUNTRY", &btnSelectCountry}, // contacted stations DXCC entity name {CQZ, 8, "CQZ", &btnSelectCQZ}, // contacted stations CQ Zone {DXCC, 8, "DXCC", &btnSelectDXCC}, // contacted stations Country Code {QSL_VIA, 256, "QSL_VIA", &btnSelectQSL_VIA}, // contacted stations path {IOTA, 20, "IOTA", &btnSelectIOTA}, // Islands on the air {ITUZ, 20, "ITUZ", &btnSelectITUZ}, // ITU zone {CONT, 60, "CONT", &btnSelectCONT}, // contacted stations continent {SRX, 50, "SRX", &btnSelectSerialIN}, // received serial number for a contest QSO {STX, 50, "STX", &btnSelectSerialOUT}, // QSO transmitted serial number {XCHG1, 100, "SRX_STRING", &btnSelectXchgIn}, // contest exchange #1 / free1 in xlog {MYXCHG, 100, "STX_STRING", &btnSelectMyXchg}, // contest exchange sent {CLASS, 20, "CLASS", &btnSelectClass}, // Field Day / School RR class received {ARRL_SECT, 20, "ARRL_SECT", &btnSelectSection}, // ARRL section received {TX_PWR, 8, "TX_PWR", &btnSelectTX_pwr}, // power transmitted by this station {OP_CALL, 30, "OPERATOR", &btnSelectOperator}, // Callsign of person logging the QSO {STA_CALL, 30, "STATION_CALLSIGN", &btnSelectStaCall}, // Callsign of transmitting station {MY_GRID, 8, "MY_GRIDSQUARE", &btnSelectStaGrid}, // Xmt station locator {MY_CITY, 60, "MY_CITY", &btnSelectStaCity}, // Xmt station location {SS_SEC, 20, "CWSS_SECTION", &btnSelect_cwss_section}, // CW sweepstakes {SS_SERNO, 20, "CWSS_SERNO", &btnSelect_cwss_serno}, {SS_PREC, 20, "CWSS_PREC", &btnSelect_cwss_prec}, {SS_CHK, 20, "CWSS_CHK", &btnSelect_cwss_check}, {AGE, 2, "AGE", &btnSelectAge}, // contacted operators age in years {TEN_TEN, 10, "TEN_TEN", &btnSelect_1010}, // ten ten # of other station {CHECK, 10, "CHECK", &btnSelectCheck}, // contest identifier {FD_CLASS, 20, "FD_CLASS", NULL}, // Field Day Rcvd {FD_SECTION, 20, "FD_SECTION", NULL}, // FD section received {TROOPS, 20, "TROOPS", NULL}, // JOTA troop number sent {TROOPR, 20, "TROOPR", NULL}, // JOTA troop number received {SCOUTS, 20, "SCOUTS", NULL}, {SCOUTR, 20, "SCOUTR", NULL}, {NUMFIELDS, 0, "", NULL} }; // This ADIF fields is in the fldigi QSO database, but not saved in the ADIF file /* {EXPORT, 0, "EXPORT", NULL}, // used to indicate record is to be exported */ // These ADIF fields are not in the fldigi QSO database /* {COMMENT, 256, "COMMENT", NULL}, // comment field for QSO {ADDRESS, 256, "ADDRESS", NULL}, // contacted stations mailing address {PFX, 20, "PFX", NULL}, // WPA prefix {PROP_MODE, 100, "PROP_MODE", NULL}, // propogation mode {QSL_MSG, 256, "QSL_MSG", NULL}, // personal message to appear on qsl card {QSL_RCVD, 4, "QSL_RCVD", NULL}, // QSL received status {QSL_SENT, 4, "QSL_SENT", NULL}, // QSL sent status {QSL_VIA, 20, "QSL_VIA", NULL}, // QSL via this person {RX_PWR, 8, "RX_PWR", NULL}, // power of other station in watts {SAT_MODE, 20, "SAT_MODE", NULL}, // satellite mode {SAT_NAME, 20, "SAT_NAME", NULL}, // satellite name }; */ static std::string read_errors; static int num_read_errors; static void write_rxtext(const char *s) { ReceiveText->addstr(s); } static char *fastlookup = 0; static unsigned int maxlen = 0; static void initfields() { if (fastlookup) return; // may have multiple instances using common code int i = 0; while (fields[i].type != NUMFIELDS) { if (strlen(fields[i].name) > maxlen) maxlen = strlen(fields[i].name); i++; } maxlen++; fastlookup = new char[maxlen * i + 1]; fastlookup[0] = 0; i = 0; while (fields[i].type != NUMFIELDS) { strcat(fastlookup, fields[i].name); unsigned int n = maxlen - strlen(fastlookup) % maxlen; if (n > 0 && n < maxlen) for (unsigned int j = 0; j < n; j++) strcat(fastlookup, " "); i++; } } static inline int findfield( char *p ) { if (strncasecmp (p, "EOR>", 4) == 0 || !maxlen) return -1; char *pos; char *p1 = strchr(p, ':'); char *p2 = strchr(p, '>'); if (p1 && p2) { if (p1 < p2) { pos = p; do { *pos = toupper(*pos); } while (++pos < p1); *p1 = 0; pos = strcasestr(fastlookup, p); *p1 = ':'; if (pos) { return fields[(pos - fastlookup) / maxlen].type; } } } return -2; //search key not found } int cAdifIO::instances = 0; cAdifIO::cAdifIO () { initfields(); instances++; } cAdifIO::~cAdifIO() { if (--instances == 0) { delete [] fastlookup; fastlookup = 0; } } char * cAdifIO::fillfield (int recnbr, int fieldnum, char *buff) { char *p1 = strchr(buff, ':'); char *p2 = strchr(buff, '>'); if (!p1 || !p2 || p2 < p1) { return 0; // bad ADIF specifier ---> no ':' after field name } p1++; int fldsize = 0; while (p1 != p2) { if (*p1 >= '0' && *p1 <= '9') { fldsize = fldsize * 10 + *p1 - '0'; } p1++; } std::string tmp = ""; tmp.assign(p2+1, fldsize); // added to disallow very large corrupted adif fields if (fldsize > fields[fieldnum].fsize) { std::string bfr = buff; tmp.erase(fields[fieldnum].fsize); static char szmsg[1000]; snprintf(szmsg, sizeof(szmsg), "In record # %d, <%s, too large, saving first %d characters\n", recnbr+1, bfr.substr(0, (int)(p2+1 - buff)).c_str(), fields[fieldnum].fsize ); read_errors.append(szmsg); num_read_errors++; } if ((fieldnum == TIME_ON || fieldnum == TIME_OFF) && fldsize < 6) while (tmp.length() < 6) tmp += '0'; adifqso->putField( fieldnum, tmp.c_str(), tmp.length() ); return p2 + fldsize + 1; } void cAdifIO::do_readfile(const char *fname, cQsoDb *db) { guard_lock lock(&logfile_mutex); int found; static char szmsg[500]; read_errors.clear(); num_read_errors = 0; // open the adif file FILE *adiFile = fl_fopen (fname, "rb"); if (adiFile == NULL) { LOG_ERROR("Could not open %s", fname); return; } /* struct timespec t0, t1, t2; #ifdef _POSIX_MONOTONIC_CLOCK clock_gettime(CLOCK_MONOTONIC, &t0); #else clock_gettime(CLOCK_REALTIME, &t0); #endif */ char buff[16384]; sbuff.clear(); memset(buff, 0, 16384); int retnbr = fread(buff, 1, 16384, adiFile); while (retnbr) { sbuff.append(buff, retnbr); retnbr = fread(buff, 1, 16384, adiFile); } fclose(adiFile); size_t p;//, ptr, ptr2; p = sbuff.find("<EOH>"); if (p == std::string::npos) p = sbuff.find("<eoh>"); if (p == std::string::npos) { LOG_ERROR("Could not find <EOH> in %s", fname); return; } if ((sbuff.find("<EOR>") == std::string::npos) && (sbuff.find("<eor>") == std::string::npos)) { LOG_ERROR("Empty log file %s", fname); return; } size_t recend; int recnbr = 0; p = sbuff.find('<', p + 1); while (p != std::string::npos) { recend = sbuff.find("<EOR>", p); if (recend == std::string::npos) recend = sbuff.find("<eor>", p); if (recend == std::string::npos) break; ptr = p; adifqso = 0; while (ptr != std::string::npos) { ptr2 = sbuff.find('<', ptr + 1); if (ptr2 == std::string::npos) break; found = findfield( &sbuff[ptr + 1] ); if (found > -1) { if (!adifqso) adifqso = db->newrec(); // need new record in db fillfield (recnbr, found, &sbuff[ptr + 1]); } else if (found == -1) { // <eor> reached; break; } ptr = ptr2; if (ptr == std::string::npos) break; // corrupt record } recnbr++; p = sbuff.find('<', recend + 1); } /* #ifdef _POSIX_MONOTONIC_CLOCK clock_gettime(CLOCK_MONOTONIC, &t2); #else clock_gettime(CLOCK_REALTIME, &t2); #endif float t = t1.tv_sec - t0.tv_sec + (t1.tv_nsec - t0.tv_nsec)/1e9; float tp = t2.tv_sec - t1.tv_sec + (t2.tv_nsec - t1.tv_nsec)/1e9; snprintf(szmsg, sizeof(szmsg), "\n\ ================================================\n\ Read Logbook: %s\n\ read %d records in %4.1f seconds\n\ parsed in %4.1f seconds\n\ ================================================\n", fname, db->nbrRecs(), t, tp); */ snprintf(szmsg, sizeof(szmsg), "\n\ ================================================\n\ Read Logbook: %s\n\ %d records\n\ ================================================\n", fname, db->nbrRecs()); if (progdefaults.DisplayLogbookRead && (db == &qsodb)) REQ(write_rxtext, szmsg); LOG_INFO("%s", szmsg); if (num_read_errors) { if (!read_errors.empty()) { read_errors.append("\n"); read_errors.append(szmsg); } else read_errors.assign(szmsg); snprintf(szmsg, sizeof(szmsg), "Corrected %d errors. Save logbook and then reload\n", num_read_errors); read_errors.append("\n\ ================================================\n").append(szmsg); read_errors.append("\ ================================================\n"); REQ(write_rxtext, read_errors.c_str()); } if (db == &qsodb) REQ(adif_read_OK); } static const char *adifmt = "<%s:%d>"; // write ALL or SELECTED records to the designated file int cAdifIO::writeFile (const char *fname, cQsoDb *db) { guard_lock lock(&logfile_mutex); std::string ADIFHEADER; ADIFHEADER = "File: %s"; ADIFHEADER.append(szEOL); ADIFHEADER.append("<ADIF_VER:%d>%s"); ADIFHEADER.append(szEOL); ADIFHEADER.append("<PROGRAMID:%d>%s"); ADIFHEADER.append(szEOL); ADIFHEADER.append("<PROGRAMVERSION:%d>%s"); ADIFHEADER.append(szEOL); ADIFHEADER.append("<EOH>"); ADIFHEADER.append(szEOL); // open the adif file cQsoRec *rec; std::string sFld; adiFile = fl_fopen (fname, "wb"); if (!adiFile) return 1; fprintf (adiFile, ADIFHEADER.c_str(), fl_filename_name(fname), strlen(ADIF_VERS), ADIF_VERS, strlen(PACKAGE_NAME), PACKAGE_NAME, strlen(PACKAGE_VERSION), PACKAGE_VERSION); std::string sName; int field_type; for (int i = 0; i < db->nbrRecs(); i++) { rec = db->getRec(i); if (rec->getField(EXPORT)[0] == 'E') { int j = 0; while (fields[j].type != NUMFIELDS) { if (strcmp(fields[j].name,"MYXCHG") == 0) { j++; continue; } if (strcmp(fields[j].name,"XCHG1") == 0) { j++; continue; } if (fields[j].btn != NULL) { if ((*fields[j].btn)->value()) { field_type = fields[j].type; sFld = rec->getField(field_type); sName = fields[j].name; if (field_type == ADIF_MODE && !sFld.empty()) { fprintf(adiFile, adifmt, "MODE", adif2export(sFld).length()); fprintf(adiFile, "%s", adif2export(sFld).c_str()); if (!adif2submode(sFld).empty()) { fprintf(adiFile, adifmt, "SUBMODE", adif2submode(sFld).length()); fprintf(adiFile, "%s", adif2submode(sFld).c_str()); } } else { if (!sFld.empty()) { fprintf(adiFile, adifmt, sName.c_str(), sFld.length()); //Exchange commas by dots in frequency for ADIF-conformity if (strcmp(fields[j].name,"FREQ") == 0) { char sfreq[20]; char* comma_position; memset(sfreq, 0, 20); strncpy (sfreq, sFld.c_str(), sizeof(sfreq) - 1); comma_position = strchr(sfreq,','); if (comma_position != NULL) { *comma_position = '.'; } fprintf(adiFile, "%s", sfreq); } else { fprintf(adiFile, "%s", sFld.c_str()); } } } } } j++; } rec->putField(EXPORT,""); db->qsoUpdRec(i, rec); fprintf(adiFile, "%s", szEOR); fprintf(adiFile, "%s", szEOL); } } fclose (adiFile); return 0; } // write ALL records to the common log //====================================================================== // thread support writing database //====================================================================== pthread_t* ADIF_RW_thread = 0; pthread_mutex_t ADIF_RW_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t ADIF_RW_cond = PTHREAD_COND_INITIALIZER; static void ADIF_RW_init(); static std::string adif_file_image; static std::string adif_file_name; static std::string records; static std::string record; static char recfield[200]; static bool ADIF_READ = false; static bool ADIF_WRITE = false; static cQsoDb *adif_db; static cAdifIO *adifIO = 0; void cAdifIO::readFile (const char *fname, cQsoDb *db) { ENSURE_THREAD(FLMAIN_TID); if (!ADIF_RW_thread) ADIF_RW_init(); pthread_mutex_lock(&ADIF_RW_mutex); adif_file_name = fname; adif_db = db; adifIO = this; ADIF_READ = true; pthread_cond_signal(&ADIF_RW_cond); pthread_mutex_unlock(&ADIF_RW_mutex); } static cQsoDb *adifdb = 0; static cQsoDb *wrdb = 0; static struct timespec t0, t1; std::string cAdifIO::adif_record(cQsoRec *rec) { static std::string record; static std::string sFld; record.clear(); for (int j = 0; fields[j].type != NUMFIELDS; j++) { if (strcmp(fields[j].name,"MYXCHG") == 0) continue; if (strcmp(fields[j].name,"XCHG1") == 0) continue; sFld = rec->getField(fields[j].type); if (!sFld.empty()) { snprintf(recfield, sizeof(recfield), adifmt, fields[j].name, sFld.length()); record.append(recfield).append(sFld); } } record.append(szEOR); record.append(szEOL); return record; } int cAdifIO::writeAdifRec (cQsoRec *rec, const char *fname) { std::string strRecord = adif_record(rec); FILE *adiFile = fl_fopen (fname, "ab"); if (!adiFile) { LOG_ERROR("Cannot write to %s", fname); return 1; } LOG_INFO("Write record to %s", fname); fprintf (adiFile, "%s", strRecord.c_str()); fclose (adiFile); return 0; } int cAdifIO::writeLog (const char *fname, cQsoDb *db, bool immediate) { ENSURE_THREAD(FLMAIN_TID); if (!ADIF_RW_thread) ADIF_RW_init(); #ifdef _POSIX_MONOTONIC_CLOCK clock_gettime(CLOCK_MONOTONIC, &t0); #else clock_gettime(CLOCK_REALTIME, &t0); #endif if (!immediate) { pthread_mutex_lock(&ADIF_RW_mutex); adif_file_name = fname; adifIO = this; ADIF_WRITE = true; if (wrdb) delete wrdb; wrdb = new cQsoDb(db); adifdb = wrdb; pthread_cond_signal(&ADIF_RW_cond); pthread_mutex_unlock(&ADIF_RW_mutex); } else { adif_file_name = fname; adifdb = db; do_writelog(); } return 1; } void cAdifIO::do_writelog() { guard_lock lock(&logfile_mutex); std::string ADIFHEADER; ADIFHEADER = "File: %s"; ADIFHEADER.append(szEOL); ADIFHEADER.append("<ADIF_VER:%d>%s"); ADIFHEADER.append(szEOL); ADIFHEADER.append("<PROGRAMID:%d>%s"); ADIFHEADER.append(szEOL); ADIFHEADER.append("<PROGRAMVERSION:%d>%s"); ADIFHEADER.append(szEOL); ADIFHEADER.append("<EOH>"); ADIFHEADER.append(szEOL); adiFile = fl_fopen (adif_file_name.c_str(), "wb"); if (!adiFile) { LOG_ERROR("Cannot write to %s", adif_file_name.c_str()); if (wrdb) delete wrdb; return; } LOG_INFO("Writing %s", adif_file_name.c_str()); cQsoRec *rec; fprintf ( adiFile, ADIFHEADER.c_str(), fl_filename_name(adif_file_name.c_str()), strlen(ADIF_VERS), ADIF_VERS, strlen(PACKAGE_NAME), PACKAGE_NAME, strlen(PACKAGE_VERSION), PACKAGE_VERSION ); for (int i = 0; i < adifdb->nbrRecs(); i++) { rec = adifdb->getRec(i); fprintf (adiFile, "%s", adif_record(rec).c_str()); if (wrdb) adifdb->qsoUpdRec(i, rec); } fflush (adiFile); fclose (adiFile); if (wrdb) delete wrdb; #ifdef _POSIX_MONOTONIC_CLOCK clock_gettime(CLOCK_MONOTONIC, &t1); #else clock_gettime(CLOCK_REALTIME, &t1); #endif t0 = t1 - t0; float t = (t0.tv_sec + t0.tv_nsec/1e9); static char szmsg[50]; snprintf(szmsg, sizeof(szmsg), "%d records in %4.2f seconds", adifdb->nbrRecs(), t); LOG_INFO("%s", szmsg); snprintf(szmsg, sizeof(szmsg), "Wrote log %d recs", adifdb->nbrRecs()); put_status(szmsg, 5.0); return; } //====================================================================== // thread to support writing database in a separate thread //====================================================================== static void *ADIF_RW_loop(void *args); static bool ADIF_RW_EXIT = false; static void *ADIF_RW_loop(void *args) { SET_THREAD_ID(ADIF_RW_TID); for (;;) { pthread_mutex_lock(&ADIF_RW_mutex); pthread_cond_wait(&ADIF_RW_cond, &ADIF_RW_mutex); pthread_mutex_unlock(&ADIF_RW_mutex); if (ADIF_RW_EXIT) return NULL; if (ADIF_WRITE && adifIO) { LOG_INFO("ADIF_WRITE: adifIO->do_writelog()"); adifIO->do_writelog(); ADIF_WRITE = false; } else if (ADIF_READ && adifIO) { LOG_INFO("ADIF_READ: adifIO->do_readfile(%s)", adif_file_name.c_str()); adifIO->do_readfile(adif_file_name.c_str(), adif_db); ADIF_READ = false; } } return NULL; } void ADIF_RW_close(void) { ENSURE_THREAD(FLMAIN_TID); if (!ADIF_RW_thread) return; pthread_mutex_lock(&ADIF_RW_mutex); ADIF_RW_EXIT = true; LOG_INFO("%s", "Exiting ADIF_RW_thread"); pthread_cond_signal(&ADIF_RW_cond); pthread_mutex_unlock(&ADIF_RW_mutex); pthread_join(*ADIF_RW_thread, NULL); delete ADIF_RW_thread; ADIF_RW_thread = 0; LOG_INFO("%s", "ADIF_RW_thread closed"); } static void ADIF_RW_init() { ENSURE_THREAD(FLMAIN_TID); if (ADIF_RW_thread) return; ADIF_RW_thread = new pthread_t; ADIF_RW_EXIT = false; if (pthread_create(ADIF_RW_thread, NULL, ADIF_RW_loop, NULL) != 0) { LOG_PERROR("pthread_create"); return; } #ifdef __WIN32__ MilliSleep(100); #else MilliSleep(10); #endif }
22,136
C++
.cxx
623
32.131621
111
0.581544
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,256
qso_db.cxx
w1hkj_fldigi/src/logbook/qso_db.cxx
// ---------------------------------------------------------------------------- // qso_db.cxx // // Copyright (C) 2006-2009 // Dave Freese, W1HKJ // Remi Chateauneu, 2011 // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <fstream> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <iostream> #include "qso_db.h" #include "field_def.h" #include "globals.h" #include "timeops.h" #include "debug.h" #include "pthread.h" static int compby = COMPDATE; static bool date_off = true; bool cQsoDb::reverse = false; cQsoRec::cQsoRec() { for (int i=0;i < NUMFIELDS; i++) { qsofield[i] = new std::string; qsofield[i]->clear(); } } cQsoRec::~cQsoRec () { for (int i = 0; i < NUMFIELDS; i++) delete qsofield[i]; } void cQsoRec::clearRec () { for (int i = 0; i < NUMFIELDS; i++) qsofield[i]->clear(); } int cQsoRec::validRec() { return 0; } void cQsoRec::checkBand() { size_t flen = qsofield[FREQ]->length(), blen = qsofield[BAND]->length(); if (flen == 0 && blen != 0) { for (size_t n = 0; n < blen; n++) (*qsofield[BAND])[n] = tolower((*qsofield[BAND])[n]); *qsofield[FREQ] = band_freq((*qsofield[BAND]).c_str()); } else if (blen == 0 && flen != 0) *qsofield[BAND] = band_name((*qsofield[FREQ]).c_str()); } void cQsoRec::checkDateTimes() { size_t len1 = qsofield[TIME_ON]->length(), len2 = qsofield[TIME_OFF]->length(); if (len1 == 0 && len2 != 0) *qsofield[TIME_ON] = *qsofield[TIME_OFF]; else if (len1 != 0 && len2 == 0) *qsofield[TIME_OFF] = *qsofield[TIME_ON]; len1 = qsofield[QSO_DATE]->length(); len2 = qsofield[QSO_DATE_OFF]->length(); if (len1 == 0 && len2 != 0) *qsofield[QSO_DATE] = *qsofield[QSO_DATE_OFF]; else if (len1 != 0 && len2 == 0) *qsofield[QSO_DATE_OFF] = *qsofield[QSO_DATE]; } // Sets the current time, with the right format. void cQsoRec::setDateTime(bool dtOn) { time_t tmp_time = time(NULL); struct tm tmp_tm ; if (localtime_r(&tmp_time, &tmp_tm)) { char buf_date[64] ; snprintf( buf_date, sizeof(buf_date), "%04d%02d%02d", 1900 + tmp_tm.tm_year, 1 + tmp_tm.tm_mon, tmp_tm.tm_mday ); char buf_time[64] ; snprintf( buf_time, sizeof(buf_time), "%02d%02d%02d", tmp_tm.tm_hour, tmp_tm.tm_min, tmp_tm.tm_sec ); if(dtOn) { putField(QSO_DATE, buf_date); putField(TIME_ON, buf_time); } else { putField(QSO_DATE_OFF, buf_date); putField(TIME_OFF, buf_time); } } } /// It must match a specific format. Input in Hertz. void cQsoRec::setFrequency(long long freq) { double freq_dbl = freq / 1000000.0 ; char buf_freq[64]; snprintf( buf_freq, sizeof(buf_freq), "%lf", freq_dbl ); putField(FREQ, buf_freq ); } void cQsoRec::putField (int n, const char *s){ if (n < 0 || n >= NUMFIELDS) return; qsofield[n]->assign(s);// = s; } void cQsoRec::putField (int n, const char *s, int len) { if (n < 0 || n >= NUMFIELDS) return; qsofield[n]->assign(s, len); } void cQsoRec::addtoField (int n, const char *s){ if (n < 0 || n >= NUMFIELDS) return; qsofield[n]->append(s); } void cQsoRec::trimFields () { size_t p; std::string s; for (int i = 0; i < NUMFIELDS; i++) { s = *qsofield[i]; //right trim string p = s.length(); while (p && s[p-1] == ' ') { s.erase(p - 1); p = s.length(); } //left trim string p = s.length(); while (p && s[0] == ' ') { s.erase(0,1); p = s.length(); } //make all upper case if Callsign or Mode if (i == CALL || i == ADIF_MODE) { for (p = 0; p < s.length(); p++) s[p] = toupper(s[p]); } *qsofield[i] = s; } } static const char *empty_field = ""; const char * cQsoRec::getField (int n) const { if (n < 0 || n >= NUMFIELDS) return empty_field; return (qsofield[n]->c_str()); } const cQsoRec &cQsoRec::operator=(const cQsoRec &right) { if (this != &right) { for (int i = 0; i < NUMFIELDS; i++) { (this->qsofield[i])->assign((right.qsofield[i])->c_str()); } } return *this; } int compareTimes (const cQsoRec &r1, const cQsoRec &r2) { if (date_off) return r1.qsofield[TIME_OFF]->compare(*r2.qsofield[TIME_OFF]); return r1.qsofield[TIME_ON]->compare(*r2.qsofield[TIME_ON]); } int compareDates (const cQsoRec &r1, const cQsoRec &r2) { if (date_off) return r1.qsofield[QSO_DATE_OFF]->compare(*r2.qsofield[QSO_DATE_OFF]); return r1.qsofield[QSO_DATE]->compare(*r2.qsofield[QSO_DATE]); } int compareCalls (const cQsoRec &r1, const cQsoRec &r2) { return (r1.qsofield[CALL])->compare( *r2.qsofield[CALL] ); } int compareModes (const cQsoRec &r1, const cQsoRec &r2) { return (r1.qsofield[ADIF_MODE])->compare( *r2.qsofield[ADIF_MODE] ); } int compareFreqs (const cQsoRec &r1, const cQsoRec &r2) { double f1, f2; f1 = atof(r1.qsofield[FREQ]->c_str()); f2 = atof(r2.qsofield[FREQ]->c_str()); return (f1 == f2 ? 0 : f1 < f2 ? -1 : 1); } int comparebydate(const void *p1, const void *p2) { cQsoRec *r1, *r2; if (cQsoDb::reverse) { r2 = (cQsoRec *)p1; r1 = (cQsoRec *)p2; } else { r1 = (cQsoRec *)p1; r2 = (cQsoRec *)p2; } int cmp; if ((cmp = compareDates(*r1, *r2))) return cmp; if ((cmp = compareTimes(*r1, *r2))) return cmp; if ((cmp = compareCalls(*r1, *r2))) return cmp; if ((cmp = compareModes(*r1, *r2))) return cmp; return compareFreqs(*r1, *r2); } int comparebymode(const void *p1, const void *p2) { cQsoRec *r1, *r2; if (cQsoDb::reverse) { r2 = (cQsoRec *)p1; r1 = (cQsoRec *)p2; } else { r1 = (cQsoRec *)p1; r2 = (cQsoRec *)p2; } int cmp; if ((cmp = compareModes(*r1, *r2)) != 0) return cmp; if ((cmp = compareDates(*r1, *r2)) != 0) return cmp; if ((cmp = compareTimes(*r1, *r2)) != 0) return cmp; if ((cmp = compareCalls(*r1, *r2)) != 0) return cmp; return compareFreqs(*r1, *r2); } int comparebycall(const void *p1, const void *p2) { cQsoRec *r1, *r2; if (cQsoDb::reverse) { r2 = (cQsoRec *)p1; r1 = (cQsoRec *)p2; } else { r1 = (cQsoRec *)p1; r2 = (cQsoRec *)p2; } int cmp; if ((cmp = compareCalls(*r1, *r2)) != 0) return cmp; if ((cmp = compareDates(*r1, *r2)) != 0) return cmp; if ((cmp = compareTimes(*r1, *r2)) != 0) return cmp; if ((cmp = compareModes(*r1, *r2)) != 0) return cmp; return compareFreqs(*r1, *r2); } int comparebyfreq(const void *p1, const void *p2) { cQsoRec *r1, *r2; if (cQsoDb::reverse) { r2 = (cQsoRec *)p1; r1 = (cQsoRec *)p2; } else { r1 = (cQsoRec *)p1; r2 = (cQsoRec *)p2; } int cmp; if ((cmp = compareFreqs(*r1, *r2)) != 0) return cmp; if ((cmp = compareDates(*r1, *r2)) != 0) return cmp; if ((cmp = compareTimes(*r1, *r2)) != 0) return cmp; if ((cmp = compareCalls(*r1, *r2)) != 0) return cmp; return compareModes(*r1, *r2); } bool cQsoRec::operator==(const cQsoRec &right) const { if (compareDates (*this, right) != 0) return false; if (compareTimes (*this, right) != 0) return false; if (compareCalls (*this, right) != 0) return false; if (compareFreqs (*this, right) != 0) return false; return true; } bool cQsoRec::operator<(const cQsoRec &right) const { if (compareDates (*this, right) > -1) return false; if (compareTimes (*this, right) > -1) return false; if (compareCalls (*this, right) > -1) return false; if (compareFreqs (*this, right) > -1) return false; return true; } static char delim_in = '\t'; static char delim_out = '\t'; static bool isVer3 = false; std::ostream &operator<< (std::ostream &output, const cQsoRec &rec) { for (int i = 0; i < EXPORT; i++) output << rec.qsofield[i]->c_str() << delim_out; return output; } std::istream &operator>> (std::istream &input, cQsoRec &rec ) { static char buf[1024]; // Must be big enough for a field. for (int i = 0; i < NUMFIELDS; i++) { input.getline( buf, sizeof(buf), delim_in ); *rec.qsofield[i] = buf ; } return input; } //====================================================================== // class cQsoDb #define MAXRECS 100000 #define INCRRECS 10000 cQsoDb::cQsoDb() { nbrrecs = 0; maxrecs = MAXRECS; qsorec = new cQsoRec[maxrecs]; compby = COMPDATE; dirty = 0; } cQsoDb::cQsoDb(cQsoDb *db) { nbrrecs = 0; maxrecs = db->nbrRecs(); qsorec = new cQsoRec[maxrecs]; for (int i = 0; i < maxrecs; i++) qsorec[i] = db->qsorec[i]; compby = COMPDATE; nbrrecs = maxrecs; dirty = 0; } cQsoDb::~cQsoDb() { delete [] qsorec; } void cQsoDb::deleteRecs() { delete [] qsorec; nbrrecs = 0; maxrecs = MAXRECS; qsorec = new cQsoRec[maxrecs]; dirty = 0; } void cQsoDb::clearDatabase() { deleteRecs(); } int cQsoDb::qsoFindRec(cQsoRec *rec) { for (int i = 0; i < nbrrecs; i++) if (qsorec[i] == *rec) return i; return -1; } void cQsoDb::qsoNewRec (cQsoRec *nurec) { if (nbrrecs == maxrecs) { maxrecs += INCRRECS; cQsoRec *atemp = new cQsoRec[maxrecs]; for (int i = 0; i < nbrrecs; i++) atemp[i] = qsorec[i]; delete [] qsorec; qsorec = atemp; } qsorec[nbrrecs] = *nurec; qsorec[nbrrecs].checkBand(); qsorec[nbrrecs].checkDateTimes(); nbrrecs++; } cQsoRec* cQsoDb::newrec() { if (nbrrecs == maxrecs) { maxrecs += INCRRECS; cQsoRec *atemp = new cQsoRec[maxrecs]; for (int i = 0; i < nbrrecs; i++) atemp[i] = qsorec[i]; delete [] qsorec; qsorec = atemp; } nbrrecs++; return &qsorec[nbrrecs - 1]; } void cQsoDb::qsoDelRec (int rnbr) { if (rnbr < 0 || rnbr > (nbrrecs - 1)) return; for (int i = rnbr; i < nbrrecs - 1; i++) qsorec[i] = qsorec[i+1]; nbrrecs--; qsorec[nbrrecs].clearRec(); } void cQsoDb::qsoUpdRec (int rnbr, cQsoRec *updrec) { if (rnbr < 0 || rnbr > (nbrrecs - 1)) return; qsorec[rnbr] = *updrec; qsorec[rnbr].checkBand(); return; } #if 1 void cQsoDb::SortByDate (bool how) { date_off = how; qsort (qsorec, nbrrecs, sizeof (cQsoRec), comparebydate); } void cQsoDb::SortByCall () { qsort (qsorec, nbrrecs, sizeof (cQsoRec), comparebycall); } void cQsoDb::SortByMode () { qsort (qsorec, nbrrecs, sizeof (cQsoRec), comparebymode); } void cQsoDb::SortByFreq () { qsort (qsorec, nbrrecs, sizeof (cQsoRec), comparebyfreq); } #else #include <chrono> using Clock = std::chrono::steady_clock; using std::chrono::time_point; using std::chrono::duration_cast; using std::chrono::milliseconds; void cQsoDb::SortByDate (bool how) { date_off = how; time_point<Clock> start = Clock::now(); qsort (qsorec, nbrrecs, sizeof (cQsoRec), comparebydate); time_point<Clock> end = Clock::now(); milliseconds diff = duration_cast<milliseconds>(end - start); LOG_VERBOSE("qsort in %.0f msec", 1.0* diff.count()); } void cQsoDb::SortByCall () { time_point<Clock> start = Clock::now(); qsort (qsorec, nbrrecs, sizeof (cQsoRec), comparebycall); time_point<Clock> end = Clock::now(); milliseconds diff = duration_cast<milliseconds>(end - start); LOG_VERBOSE("qsort in %.0f msec", 1.0* diff.count()); } void cQsoDb::SortByMode () { time_point<Clock> start = Clock::now(); qsort (qsorec, nbrrecs, sizeof (cQsoRec), comparebymode); time_point<Clock> end = Clock::now(); milliseconds diff = duration_cast<milliseconds>(end - start); LOG_VERBOSE("qsort in %.0f msec", 1.0* diff.count()); } void cQsoDb::SortByFreq () { time_point<Clock> start = Clock::now(); qsort (qsorec, nbrrecs, sizeof (cQsoRec), comparebyfreq); time_point<Clock> end = Clock::now(); milliseconds diff = duration_cast<milliseconds>(end - start); LOG_VERBOSE("qsort in %.0f msec", 1.0* diff.count()); } #endif bool cQsoDb::qsoIsValidFile(const char *fname) { char buff[256]; std::ifstream inQsoFile (fname, std::ios::in); if (!inQsoFile) return false; inQsoFile.getline (buff, 256); if (strstr (buff, "_LOGBODUP DB") == 0) { inQsoFile.close(); return false; } inQsoFile.close(); return true; } int cQsoDb::qsoReadFile (const char *fname) { char buff[256]; std::ifstream inQsoFile (fname, std::ios::in); if (!inQsoFile) return 1; inQsoFile.getline (buff, 256); if (strstr (buff, "_LOGBODUP DB") == 0) { inQsoFile.close(); return 2; } if (strstr (buff, "_LOGBODUP DBX") == 0) // new file format delim_in = '\n'; if (strstr (buff, "3.0") != 0) isVer3 = true; cQsoRec inprec; while (inQsoFile >> inprec) qsoNewRec (&inprec); inQsoFile.close(); SortByDate(date_off); return 0; } int cQsoDb::qsoWriteFile (const char *fname) { std::ofstream outQsoFile (fname, std::ios::out); if (!outQsoFile) { return 1; } outQsoFile << "_LOGBODUP DBX 3.0" << '\n'; for (int i = 0; i < nbrrecs; i++) outQsoFile << qsorec[i]; outQsoFile.close(); return 0; } const int cQsoDb::jdays[2][13] = { { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }, { 0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 } }; bool cQsoDb::isleapyear( int y ) const { if( y % 400 == 0 || ( y % 100 != 0 && y % 4 == 0 ) ) return true; return false; } int cQsoDb::dayofyear (int year, int mon, int mday) { return mday + jdays[isleapyear (year) ? 1 : 0][mon]; } unsigned long cQsoDb::epoch_dt (const char *szdate, const char *sztime) { unsigned long doe; int era, cent, quad, rest; int year, mon, mday; int secs; year = ((szdate[0]*10 + szdate[1])*10 + szdate[2])*10 + szdate[3]; mon = szdate[4]*10 + szdate[5]; mday = szdate[6]*10 + szdate[7]; secs = ((sztime[0]*10 + sztime[1])*60 + sztime[2]*10 + sztime[3])*60 + + sztime[4]*10 + sztime[5]; /* break down the year into 400, 100, 4, and 1 year multiples */ rest = year - 1; quad = rest / 4; rest %= 4; cent = quad / 25; quad %= 25; era = cent / 4; cent %= 4; /* set up doe */ doe = dayofyear (year, mon, mday); doe += era * (400 * 365 + 97); doe += cent * (100 * 365 + 24); doe += quad * (4 * 365 + 1); doe += rest * 365; return doe*60*60*24 + secs; } int cQsoDb::duplicate( const char *callsign, const char *szdate, const char *sztime, unsigned int interval, bool chkdatetime, const char *freq, bool chkfreq, const char *state, bool chkstate, const char *mode, bool chkmode, const char *xchg1, bool chkxchg1 ) { bool b_freqDUP = true, b_stateDUP = true, b_modeDUP = true, b_xchg1DUP = true, b_dtimeDUP = true; unsigned long datetime = 0L; unsigned long qsodatetime = 0L; int f1 = 0; int f2 = 0; int isdup = 0; if (freq) f1 = (int)(atof(freq)/1000.0); if (chkdatetime) datetime = epoch_dt(szdate, sztime); for (int i = 0; i < nbrrecs; i++) { if (strcasecmp(qsorec[i].getField(CALL), callsign) == 0) { // found callsign duplicate if (!chkdatetime && !chkfreq && !chkstate && !chkmode && !chkxchg1) isdup = 2; if (szdate == NULL) return isdup; b_freqDUP = b_stateDUP = b_modeDUP = b_xchg1DUP = b_dtimeDUP = false; if (chkfreq) { f2 = (int)atof(qsorec[i].getField(FREQ)); b_freqDUP = (f1 == f2); } if (chkstate) b_stateDUP = (qsorec[i].getField(STATE)[0] == 0 && state[0] == 0) || (strcasestr(qsorec[i].getField(STATE), state) != 0); if (chkmode) b_modeDUP = (qsorec[i].getField(ADIF_MODE)[0] == 0 && mode[0] == 0) || (strcasestr(qsorec[i].getField(ADIF_MODE), mode) != 0); if (chkxchg1) b_xchg1DUP = (qsorec[i].getField(XCHG1)[0] == 0 && xchg1[0] == 0) || (strcasestr(qsorec[i].getField(XCHG1), xchg1) != 0); if (chkdatetime) { qsodatetime = epoch_dt ( qsorec[i].getField(QSO_DATE), qsorec[i].getField(TIME_OFF)); if ((datetime - qsodatetime) < interval*60) b_dtimeDUP = true; } if ( (!chkfreq || (chkfreq && b_freqDUP)) && (!chkstate || (chkstate && b_stateDUP)) && (!chkmode || (chkmode && b_modeDUP)) && (!chkxchg1 || (chkxchg1 && b_xchg1DUP)) && (!chkdatetime || (chkdatetime && b_dtimeDUP))) { isdup = 1; } } } return isdup; } // set epoch interval test to 15 * 60 static inline const char *adifmode(const char *mode) { for (int i = 0; i < NUM_MODES; i++) { if (strcasecmp(mode_info[i].sname, mode) == 0) return (mode_info[i].adif_name); } return ""; } int cQsoDb::matched( cQsoRec *rec ) { bool match = false; bool test = false; int interval = 60 * 15; const char *callsign = rec->getField(CALL); const char *date = rec->getField(QSO_DATE); const char *time = rec->getField(TIME_ON); const char *mode = rec->getField(ADIF_MODE); const char *band = rec->getField(BAND); unsigned long qsodatetime, lotwdatetime = epoch_dt(date, time); int freq = (int)(atof(rec->getField(FREQ)) / 1000.0); int difftime; for (int i = 0; i < nbrrecs; i++) { // test CALL match = (strcasecmp(qsorec[i].getField(CALL), callsign) == 0); if (!match) continue; // test FREQ test = (freq == (int)(atof(qsorec[i].getField(FREQ)) / 1000.0)); // test BAND iff FREQ test fails if (!test) test = (strcasecmp(qsorec[i].getField(BAND), band) == 0); match = match && test; if (!match) continue; // test MODE test = (qsorec[i].getField(ADIF_MODE)[0] == 0 && mode[0] == 0) || (strcasestr(qsorec[i].getField(ADIF_MODE), mode) != 0); if (!test) test = (strcasecmp(mode, adifmode(qsorec[i].getField(ADIF_MODE))) == 0); if (!test) test = (strcasecmp(mode, "DATA") == 0); match = match && test; if (!match) continue; // test date/time (epoch) qsodatetime = epoch_dt ( qsorec[i].getField(QSO_DATE), qsorec[i].getField(TIME_ON)); difftime = (int)(lotwdatetime - qsodatetime); if (abs(difftime) < interval) test = true; else test = false; match = match && test; if (!match) continue; // found match // printf("%10s, %12s, %s, %s, %s\n%10s, %12s, %s, %s, %s\n", // rec->getField(CALL), rec->getField(FREQ), rec->getField(QSO_DATE), rec->getField(TIME_ON), rec->getField(ADIF_MODE), // qsorec[i].getField(CALL), qsorec[i].getField(FREQ), qsorec[i].getField(QSO_DATE), qsorec[i].getField(TIME_ON), qsorec[i].getField(ADIF_MODE) ); // printf("epoch test: %ud ~= %ud ==> %d\n", (uint)lotwdatetime, (uint)qsodatetime, difftime); return i; } return -1; }
18,554
C++
.cxx
614
27.604235
147
0.631204
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,257
waterfall.cxx
w1hkj_fldigi/src/waterfall/waterfall.cxx
// ---------------------------------------------------------------------------- // waterfall.cxx - Waterfall Spectrum Analyzer Widget // // Copyright (C) 2006-2010 // Dave Freese, W1HKJ // Copyright (C) 2007-2010 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- //#define USE_BLACKMAN //#define USE_HAMMING //#define USE_HANNING #include <config.h> #include <sstream> #include <vector> #include <queue> #include <algorithm> #include <map> #include <FL/Fl.H> #include <FL/fl_draw.H> #include <FL/Fl_Widget.H> #include <FL/Fl_Repeat_Button.H> #include <FL/Fl_Light_Button.H> #include <FL/Fl_Menu_Button.H> #include <FL/Fl_Group.H> #include <FL/Fl_Box.H> #include <FL/Fl_Counter.H> #include <FL/Enumerations.H> #include "fl_digi.h" #include "trx.h" #include "misc.h" #include "waterfall.h" #include "main.h" #include "modem.h" #include "qrunner.h" #include "threads.h" #if USE_HAMLIB #include "hamlib.h" #endif #include "rigio.h" #include "fldigi-config.h" #include "configuration.h" #include "status.h" #include "squelch_status.h" #include "Viewer.h" #include "macros.h" #include "arq_io.h" #include "confdialog.h" #include "flmisc.h" #include "gettext.h" #include "rtty.h" #include "flslider2.h" #include "debug.h" #include "rigsupport.h" #include "xmlrpc.h" #include "psm/psm.h" #include "kiss_io.h" #include "fmt_dialog.h" #include "spectrum_viewer.h" //pthread_mutex_t draw_mutex = PTHREAD_MUTEX_INITIALIZER; #define bwFFT 30 #define cwRef 50 #define bwX1 25 #define bwMov 18 #define bwRate 45 #define cwCnt 92 #define bwQsy 32 #define bwXmtLock 32 #define bwRev 32 #define bwMem 40 #define bwXmtRcv 40 #define wSpace 1 #define bwdths (wSpace + bwFFT + wSpace + cwRef + wSpace + cwRef + wSpace + bwX1 + \ wSpace + 3*bwMov + wSpace + bwRate + wSpace + \ cwCnt + wSpace + bwQsy + wSpace + bwMem + wSpace + \ bwXmtLock + wSpace + bwRev + wSpace + bwXmtRcv + wSpace) extern modem *active_modem; static RGB RGByellow = {254,254,0}; //static RGB RGBgreen = {0,254,0}; //static RGB RGBdkgreen = {0,128,0}; //static RGB RGBblue = {0,0,255}; static RGB RGBred = {254,0,0}; //static RGB RGBwhite = {254,254,254}; //static RGB RGBblack = {0,0,0}; //static RGB RGBmagenta = {196,0,196}; //static RGB RGBblack = {0,0,0}; // RGBI is a structure consisting of the values RED, GREEN, BLUE, INTENSITY // each value can range from 0 (extinguished) to 255 (full on) // the INTENSITY value is used for the grayscale waterfall display RGBI mag2RGBI[256]; RGB palette[9]; short int *tmp_fft_db; static pthread_mutex_t waterfall_mutex = PTHREAD_MUTEX_INITIALIZER; WFdisp::WFdisp (int x0, int y0, int w0, int h0, char *lbl) : Fl_Widget(x0,y0,w0,h0,"") { disp_width = w(); if (disp_width > progdefaults.HighFreqCutoff/4) disp_width = progdefaults.HighFreqCutoff/4; scale_width = IMAGE_WIDTH * 2; image_height = h() - WFTEXT - WFSCALE - WFMARKER; image_area = IMAGE_WIDTH * image_height; sig_image_area = IMAGE_WIDTH * h(); RGBsize = sizeof(RGB); RGBwidth = RGBsize * scale_width; fft_img = new RGBI[image_area]; markerimage = new RGB[scale_width * WFMARKER]; scaleimage = new uchar[scale_width * WFSCALE]; scline = new uchar[scale_width]; fft_sig_img = new uchar[image_area]; sig_img = new uchar[sig_image_area]; pwr = new wf_fft_type[IMAGE_WIDTH]; fft_db = new short int[image_area]; tmp_fft_db = new short int[image_area]; circbuff = new wf_fft_type[WF_FFTLEN]; wfbuf = new wf_cpx_type[WF_FFTLEN]; wfft = new g_fft<wf_fft_type>(WF_FFTLEN); fftwindow = new wf_fft_type[WF_FFTLEN]; setPrefilter(progdefaults.wfPreFilter); memset(circbuff, 0, WF_FFTLEN * sizeof(double)); mag = 1; step = 4; offset = 0; sigoffset = 0; ampspan = 75; // reflevel = -10; initmaps(); bandwidth = 32; RGBmarker = RGBred; RGBcursor = RGByellow; RGBInotch.I = progdefaults.notchRGBI.I; RGBInotch.R = progdefaults.notchRGBI.R; RGBInotch.G = progdefaults.notchRGBI.G; RGBInotch.B = progdefaults.notchRGBI.B; mode = WATERFALL; centercarrier = false; overload = false; rfc = 0L; usb = true; wfspeed = NORMAL; wfspdcnt = 0; dispcnt = 1.0 * WF_BLOCKSIZE / WF_SAMPLERATE; dispdec = 1.0 * WF_BLOCKSIZE / WF_SAMPLERATE; wantcursor = false; cursormoved = false; for (int i = 0; i < IMAGE_WIDTH; i++) pwr[i] = 0.0; carrier(1500); oldcarrier = newcarrier = 0; tmp_carrier = false; ptrCB = 0; ptrFFTbuff = 0; for (int i = 0; i < 256; i++) mag2RGBI[i].I = mag2RGBI[i].R = mag2RGBI[i].G = mag2RGBI[i].B = 0; int error = 0; // use fastest sync converter // SRC_SINC_BEST_QUALITY = 0, // SRC_SINC_MEDIUM_QUALITY = 1, // SRC_SINC_FASTEST = 2, // SRC_ZERO_ORDER_HOLD = 3, // SRC_LINEAR = 4, src_state = src_new(2, 1, &error); if (error) { LOG_ERROR("src_new error %d: %s", error, src_strerror(error)); abort(); } error = src_reset(src_state); if (error) LOG_ERROR("src_reset error %d: %s", error, src_strerror(error)); src_data.end_of_input = 0; src_data.src_ratio = 0.0; genptr = 0; } WFdisp::~WFdisp() { delete wfft; delete [] fft_img; delete [] scaleimage; delete [] markerimage; delete [] fft_sig_img; delete [] sig_img; delete [] pwr; delete [] scline; delete [] fft_db; delete [] tmp_fft_db; } void WFdisp::initMarkers() { memset(markerimage, 224, RGBwidth * WFMARKER); } // draw a marker of specified width and colour centred at freq and clrM inline void WFdisp::makeMarker_(int width, const RGB* color, int freq, const RGB* clrMin, RGB* clrM, const RGB* clrMax) { if (!active_modem) return; trx_mode marker_mode = active_modem->get_mode(); if (marker_mode == MODE_RTTY) { // rtty has two bandwidth indicators on the waterfall // upper and lower frequency int shift = static_cast<int>( (progdefaults.rtty_shift < rtty::numshifts ? rtty::SHIFT[progdefaults.rtty_shift] : progdefaults.rtty_custom_shift)); int bw_limit_hi = (int)(shift / 2 + progdefaults.RTTY_BW / 2.0); int bw_limit_lo = (int)(shift / 2 - progdefaults.RTTY_BW / 2.0); int bw_freq = static_cast<int>(freq + 0.5); int bw_lower1 = -bw_limit_hi; int bw_upper1 = -bw_limit_lo; int bw_lower2 = bw_limit_lo; int bw_upper2 = bw_limit_hi; if (bw_lower1 + bw_freq < 0) bw_lower1 -= bw_lower1 + bw_freq; if (bw_upper1 + bw_freq < 0) bw_lower2 -= bw_lower2 + bw_freq; if (bw_upper2 + bw_freq > scale_width) bw_upper2 -= bw_upper2 + bw_freq - scale_width; if (bw_lower2 + bw_freq > scale_width) bw_lower2 -= bw_lower2 + bw_freq - scale_width; // draw it RGB* clrPos; for (int y = 0; y < WFMARKER - 2; y++) { for (int x = bw_lower1; x < bw_upper1; x++) { clrPos = clrM + x + y * scale_width; if (clrPos > clrMin && clrPos < clrMax) *clrPos = *color; } for (int x = bw_lower2; x < bw_upper2; x++) { clrPos = clrM + x + y * scale_width; if (clrPos > clrMin && clrPos < clrMax) *clrPos = *color; } } return; } int bw_lower = -width, bw_upper = width; if (marker_mode >= MODE_MT63_500S && marker_mode <= MODE_MT63_2000L) bw_upper = (int)(width * 31 / 32); if (marker_mode == MODE_FSQ || marker_mode == MODE_IFKP) bw_upper = (int)(width * 32 / 33); if (bw_lower + static_cast<int>(freq+0.5) < 0) bw_lower -= bw_lower + static_cast<int>(freq+0.5); if (bw_upper + static_cast<int>(freq+0.5) > scale_width) bw_upper -= bw_upper + static_cast<int>(freq+0.5) - scale_width; // draw it RGB* clrPos; for (int y = 0; y < WFMARKER - 2; y++) { for (int x = bw_lower; x < bw_upper; x++) { clrPos = clrM + x + y * scale_width; if (clrPos > clrMin && clrPos < clrMax) *clrPos = *color; } } } void WFdisp::make_fmt_marker () { RGB unk_trk_color, ref_trk_color; memset(markerimage + scale_width, 0, RGBwidth * (WFMARKER - 2)); Fl::get_color(progdefaults.FMT_unk_color, unk_trk_color.R, unk_trk_color.G, unk_trk_color.B); Fl::get_color(progdefaults.FMT_ref_color, ref_trk_color.R, ref_trk_color.G, ref_trk_color.B); int fmt_bw = progdefaults.FMT_filter; RGB *mrkr_U = markerimage + scale_width + int(round(cnt_unk_freq->value())); RGB *mrkr_R = markerimage + scale_width + int(round(cnt_ref_freq->value())); // draw marker for (int y = 0; y < WFMARKER - 2; y++) { for (int x = -fmt_bw; x <= fmt_bw; x++) { *(mrkr_U + x + y * scale_width) = unk_trk_color; *(mrkr_R + x + y * scale_width) = ref_trk_color; } } } void WFdisp::makeMarker() { if (unlikely(!active_modem)) return; int mode = active_modem->get_mode(); RGB *clrMin, *clrMax, *clrM; int marker_width = bandwidth; if (mode == MODE_FMT) { make_fmt_marker (); marker_width = progdefaults.FMT_filter; } else { clrMin = markerimage + scale_width; clrMax = clrMin + (WFMARKER - 2) * scale_width; memset(clrMin, 0, RGBwidth * (WFMARKER - 2)); clrM = clrMin + (int)((double)carrierfreq + 0.5); if (mode >= MODE_PSK_FIRST && mode <= MODE_PSK_LAST) marker_width += mailserver ? progdefaults.ServerOffset : progdefaults.SearchRange; else if (mode >= MODE_FELDHELL && mode <= MODE_HELL80) marker_width = (int)progdefaults.HELL_BW; else if (mode == MODE_RTTY) marker_width = static_cast<int>((progdefaults.rtty_shift < rtty::numshifts ? rtty::SHIFT[progdefaults.rtty_shift] : progdefaults.rtty_custom_shift)); marker_width = (int)(marker_width / 2.0 + 1); RGBmarker.R = progdefaults.bwTrackRGBI.R; RGBmarker.G = progdefaults.bwTrackRGBI.G; RGBmarker.B = progdefaults.bwTrackRGBI.B; makeMarker_(marker_width, &RGBmarker, carrierfreq, clrMin, clrM, clrMax); if (unlikely(active_modem->freqlocked() || mode == MODE_FSQ)) { int txfreq = static_cast<int>(active_modem->get_txfreq()); adjust_color_inv(RGBmarker.R, RGBmarker.G, RGBmarker.B, FL_BLACK, FL_RED); makeMarker_( static_cast<int>(bandwidth / 2.0 + 1), &RGBmarker, txfreq, clrMin, clrMin + (int)((double)txfreq + 0.5), clrMax); } } if (!wantcursor) return; if (cursorpos > progdefaults.HighFreqCutoff - bandwidth / 2 / step) cursorpos = progdefaults.HighFreqCutoff - bandwidth / 2 / step; if (cursorpos >= (progdefaults.HighFreqCutoff - offset - bandwidth/2)/step) cursorpos = (progdefaults.HighFreqCutoff - offset - bandwidth/2)/step; if (cursorpos < (progdefaults.LowFreqCutoff + bandwidth / 2) / step) cursorpos = (progdefaults.LowFreqCutoff + bandwidth / 2) / step; // Create the cursor marker double xp = offset + step * cursorpos; if (xp < bandwidth / 2.0 || xp > (progdefaults.HighFreqCutoff - bandwidth / 2.0)) return; clrM = markerimage + scale_width + (int)(xp + 0.5); RGBcursor.R = progdefaults.cursorLineRGBI.R; RGBcursor.G = progdefaults.cursorLineRGBI.G; RGBcursor.B = progdefaults.cursorLineRGBI.B; int bw_lo = marker_width; int bw_hi = marker_width; if (mode >= MODE_MT63_500S && mode <= MODE_MT63_2000L) bw_hi = bw_hi * 31 / 32; if (mode == MODE_FSQ || mode == MODE_IFKP) bw_hi = bw_hi * 32 / 33; for (int y = 0; y < WFMARKER - 2; y++) { int incr = y * scale_width; int msize = (WFMARKER - 2 - y)*RGBsize*step/4; for (int m = -step; m < step; m++) *(clrM + incr + m) = RGBcursor; if (xp - (bw_lo + msize) > 0) for (int i = bw_lo - msize; i <= bw_lo + msize; i++) *(clrM - i + incr) = RGBcursor; if (xp + (bw_hi + msize) < scale_width) for (int i = bw_hi - msize; i <= bw_hi + msize; i++) *(clrM + i + incr) = RGBcursor; } } void WFdisp::makeScale() { uchar *gmap = scaleimage; memset(scline, 0, scale_width); for (int tic = 500; tic < scale_width; tic += 500) { scline[tic] = 255; for (int ticn = 1; ticn < step; ticn++) if (tic + ticn < scale_width) scline[tic + ticn] = 255; } for (int i = 0; i < WFSCALE - 5; i++) { memcpy(gmap, scline, scale_width); gmap += (scale_width); } for (int tic = 100; tic < scale_width ; tic += 100) { scline[tic] = 255; for (int ticn = 1; ticn < step; ticn++) if (tic + ticn < scale_width) scline[tic + ticn] = 255; } for (int i = 0; i < 5; i++) { memcpy(gmap, scline, scale_width); gmap += (scale_width); } } void WFdisp::setcolors() { double di; int r, g, b; for (int i = 0; i < 256; i++) { di = sqrt((double)i / 256.0); mag2RGBI[i].I = (uchar)(200*di); } for (int n = 0; n < 8; n++) { for (int i = 0; i < 32; i++) { r = palette[n].R + (int)(1.0 * i * (palette[n+1].R - palette[n].R) / 32.0); g = palette[n].G + (int)(1.0 * i * (palette[n+1].G - palette[n].G) / 32.0); b = palette[n].B + (int)(1.0 * i * (palette[n+1].B - palette[n].B) / 32.0); mag2RGBI[i + 32*n].R = r; mag2RGBI[i + 32*n].G = g; mag2RGBI[i + 32*n].B = b; } } } void WFdisp::initmaps() { for (int i = 0; i < image_area; i++) fft_db[i] = tmp_fft_db[i] = log2disp(-1000); memset (fft_img, 0, image_area * sizeof(RGBI) ); memset (scaleimage, 0, scale_width * WFSCALE); memset (markerimage, 0, RGBwidth * WFMARKER); memset (fft_sig_img, 0, image_area); memset (sig_img, 0, sig_image_area); memset (mag2RGBI, 0, sizeof(mag2RGBI)); initMarkers(); makeScale(); setcolors(); } int WFdisp::peakFreq(int f0, int delta) { guard_lock waterfall_lock(&waterfall_mutex); double threshold = 0.0; int f1, fmin = (int)((f0 - delta)), f2, fmax = (int)((f0 + delta)); f1 = fmin; f2 = fmax; if (fmin < 0 || fmax > IMAGE_WIDTH) return f0; for (int f = fmin; f <= fmax; f++) threshold += pwr[f]; threshold /= delta; for (int f = fmin; f <= fmax; f++) if (pwr[f] > threshold) { f2 = f; } for (int f = fmax; f >= fmin; f--) if (pwr[f] > threshold) { f1 = f; } return (f1 + f2) / 2; } double WFdisp::powerDensity(double f0, double bw) { double pwrdensity = 0.0; int flower = (int)((f0 - bw/2)), fupper = (int)((f0 + bw/2)); if (flower < 0 || fupper > IMAGE_WIDTH) return 0.0; { guard_lock waterfall_lock(&waterfall_mutex); for (int i = flower; i <= fupper; i++) pwrdensity += pwr[i]; } return pwrdensity/(bw+1); } /// Frequency of the maximum power for a given bandwidth. Used for AFC. double WFdisp::powerDensityMaximum(int bw_nb, const int (*bw)[2]) const { if (bw_nb < 1) return carrierfreq; int fmax[bw_nb]; double pnbw[bw_nb]; int f_lowest = carrierfreq; int f_highest = carrierfreq; double max_pwr = 0; for (int i = 0; i < bw_nb; i++) { fmax[i] = carrierfreq; pnbw[i] = 0; } { guard_lock waterfall_lock(&waterfall_mutex); for (int i = 0; i < bw_nb; i++) { f_lowest = carrierfreq + bw[i][0]; if (f_lowest <= 0) f_lowest = 0; f_highest = carrierfreq + bw[i][1]; if (f_highest > IMAGE_WIDTH) f_highest = IMAGE_WIDTH; max_pwr = 0; pnbw[i] = 0; for (int n = f_lowest; n < f_highest; n++) { if (pwr[n] > max_pwr) { max_pwr = pwr[n]; fmax[i] = n; } pnbw[i] += pwr[n]; } if (pnbw[i] == 0) return carrierfreq; } } int fmid = 0; double total_pwr = 0; for (int i = 0; i < bw_nb; i++) total_pwr += pnbw[i]; for (int i = 0; i < bw_nb; i++) fmid += fmax[i] * pnbw[i] / total_pwr; return fmid; } void WFdisp::setPrefilter(int v) { switch (v) { case WF_FFT_RECTANGULAR: RectWindow(fftwindow, WF_FFTLEN); break; case WF_FFT_BLACKMAN: BlackmanWindow(fftwindow, WF_FFTLEN); break; case WF_FFT_HAMMING: HammingWindow(fftwindow, WF_FFTLEN); break; case WF_FFT_HANNING: HanningWindow(fftwindow, WF_FFTLEN); break; case WF_FFT_TRIANGULAR: TriangularWindow(fftwindow, WF_FFTLEN); break; } // BlackmanWindow(fftwindow, WF_FFTLEN); prefilter = v; } int WFdisp::log2disp(int v) { double val = -255.0 * v / ampspan; if (val < 0) return 255; if (val > 255 ) return 0; return (int)(255 - val); } void WFdisp::processFFT() { if (prefilter != progdefaults.wfPreFilter) setPrefilter(progdefaults.wfPreFilter); wf_fft_type scale = WF_FFTLEN / 8000.0; if ((wfspeed != PAUSE) && ((dispcnt -= dispdec) <= 0)) { static const int log2disp100 = log2disp(-100); double vscale = 2.0 / WF_FFTLEN; for (int i = 0; i < WF_FFTLEN; i++) wfbuf[i] = 0; void *pv = static_cast<void*>(wfbuf); wf_fft_type *pbuf = static_cast<wf_fft_type*>(pv); int latency = progdefaults.wf_latency; if (latency < 1) latency = 1; if (latency > 16) latency = 16; int nsamples = WF_FFTLEN * latency / 16; vscale *= sqrt(16.0 / latency); for (int i = 0; i < nsamples; i++) pbuf[i] = fftwindow[i * 16 / latency] * circbuff[i] * vscale; for (int i = 0; i < WF_FFTLEN; i++) pbuf[i] = fftwindow[i] * circbuff[i] * vscale; wfft->RealFFT(wfbuf); memset(pwr, 0, progdefaults.LowFreqCutoff * sizeof(wf_fft_type)); memset(&fft_db[ptrFFTbuff * IMAGE_WIDTH], log2disp100, progdefaults.LowFreqCutoff * sizeof(*fft_db)); int n = 0; for (int i = progdefaults.LowFreqCutoff + 1; i < IMAGE_WIDTH; i++) { n = round(scale * i); pwr[i] = norm(wfbuf[n]); int ffth = round(10.0 * log10(pwr[i] + 1e-10) ); fft_db[ptrFFTbuff * IMAGE_WIDTH + i] = log2disp(ffth); } ptrFFTbuff--; if (ptrFFTbuff < 0) ptrFFTbuff += image_height; for (int i = 0; i < image_height; i++) { int j = (i + 1 + ptrFFTbuff) % image_height; memmove( (void *)(tmp_fft_db + i * IMAGE_WIDTH), (void *)(fft_db + j * IMAGE_WIDTH), IMAGE_WIDTH * sizeof(short int)); } dispdec = 1.0 * WF_BLOCKSIZE / WF_SAMPLERATE; dispcnt = 1.0 * WF_BLOCKSIZE / WF_SAMPLERATE; // FAST if (wfspeed == NORMAL) dispcnt *= NORMAL; if (wfspeed == SLOW) dispcnt *= progdefaults.drop_speed; } redraw(); } void WFdisp::process_analog (wf_fft_type *sig, int len) { int h1, h2, h3; int sigy, sigpixel, ynext, graylevel; h1 = h()/8 - 1; h2 = h()/2 - 1; h3 = h()*7/8 + 1; graylevel = 220; // clear the signal display area sigy = 0; sigpixel = IMAGE_WIDTH*h2; memset (sig_img, 0, sig_image_area); memset (&sig_img[h1*IMAGE_WIDTH], 160, IMAGE_WIDTH); memset (&sig_img[h2*IMAGE_WIDTH], 255, IMAGE_WIDTH); memset (&sig_img[h3*IMAGE_WIDTH], 160, IMAGE_WIDTH); int cbc = ptrCB; for (int c = 0; c < IMAGE_WIDTH; c++) { ynext = (int)(h2 * sig[cbc]); if (ynext < -h2) ynext = -h2; if (ynext > h2) ynext = h2; cbc = (cbc + 1) % (WF_FFTLEN); for (; sigy < ynext; sigy++) sig_img[sigpixel -= IMAGE_WIDTH] = graylevel; for (; sigy > ynext; sigy--) sig_img[sigpixel += IMAGE_WIDTH] = graylevel; sig_img[sigpixel++] = graylevel; } redraw(); } //---------------------------------------------------------------------- // queue audio_blocks used to separate audio stream process timing // from GUI processing and timing // mutex guards the audio_blocks data //---------------------------------------------------------------------- extern state_t trx_state; static pthread_mutex_t data_mutex = PTHREAD_MUTEX_INITIALIZER; struct AUDIO_BLOCK { wf_fft_type sig[WF_BLOCKSIZE]; }; bool clear_audio_blocks; std::queue<AUDIO_BLOCK> audio_blocks; void WFdisp::sig_data( double *sig, int len ) { double src_ratio = 1.0 * WF_SAMPLERATE / active_modem->get_samplerate(); if (audio_blocks.size() > 32) { //8) { clear_audio_blocks = true; // LOG_ERROR("%s", "audio_blocks overflow"); return; } if ((len * src_ratio) > WF_BLOCKSIZE * 2) { LOG_ERROR("%s", "len * src_ratio > WFBLOCKSIZE * 2"); return; } AUDIO_BLOCK audio_block; buf = insamples; srclen = len; int error; if (src_data.src_ratio != src_ratio) { src_data.src_ratio = src_ratio; src_set_ratio(src_state, src_data.src_ratio); LOG_INFO("Waterfall sample rate ratio %f", src_ratio); } for (int n = 0; n < len; n++) insamples[n] = sig[n]; while (srclen > 0) { src_data.data_in = insamples; src_data.input_frames = srclen; src_data.data_out = &outsamples[genptr]; src_data.output_frames = WF_BLOCKSIZE * 2 - genptr; src_data.input_frames_used = 0; if (unlikely(error = src_process(src_state, &src_data))) { LOG_ERROR("src_process error %d: %s", error, src_strerror(error)); return; } size_t gend = src_data.output_frames_gen; size_t used = src_data.input_frames_used; genptr += gend; buf += used; srclen -= used; while (genptr >= WF_BLOCKSIZE) { for (int n = 0; n < WF_BLOCKSIZE; n++) audio_block.sig[n] = outsamples[n]; { guard_lock data_lock (&data_mutex); audio_blocks.push(audio_block); } for (int n = 0; n < WF_BLOCKSIZE; n++) outsamples[n] = outsamples[n+WF_BLOCKSIZE]; genptr -= WF_BLOCKSIZE; } } return; } // this method must be called from main thread void WFdisp::handle_sig_data() { ENSURE_THREAD(FLMAIN_TID); double gain = pow(10, progdefaults.wfRefLevel / -20.0); AUDIO_BLOCK current; while (1) {//!audio_blocks.empty()) { if (clear_audio_blocks) { guard_lock data_lock(&data_mutex); while ( !audio_blocks.empty() ) audio_blocks.pop(); clear_audio_blocks = false; } if (audio_blocks.empty()) return; for (int n = 0; n < WF_FFTLEN - WF_BLOCKSIZE; n++) circbuff[n] = circbuff[n + WF_BLOCKSIZE]; { // this block guarded by data_mutex guard_lock data_lock(&data_mutex); current = audio_blocks.front(); audio_blocks.pop(); } for (int n = 0; n < WF_BLOCKSIZE; n++) circbuff[n + WF_FFTLEN - WF_BLOCKSIZE - 1] = current.sig[n]; overload = false; double overval = 0, peak = 0.0; for (int i = WF_FFTLEN - WF_BLOCKSIZE; i < WF_FFTLEN; i++) { overval = fabs(circbuff[i]); if (overval > peak) peak = overval; circbuff[i] *= gain; } if (mode == SCOPE) process_analog(circbuff, WF_FFTLEN); else processFFT(); put_WARNstatus(peak); static char szFrequency[14]; if (active_modem && rfc != 0) { int offset = 0; double afreq = active_modem->get_txfreq(); trx_mode mode = active_modem->get_mode(); std::string testmode = qso_opMODE->value(); bool xcvr_useFSK = ((testmode.find("RTTY") != std::string::npos) || (testmode.find("FSK") != std::string::npos) || ((testmode.find("DATA") != std::string::npos) && (use_nanoIO || progdefaults.PseudoFSK)) ); usb = !ModeIsLSB(testmode); if ((testmode.find("DATA") != std::string::npos) && xcvr_useFSK) usb = !usb; if (mode == MODE_RTTY && progdefaults.useMARKfreq && !xcvr_useFSK) { offset = (progdefaults.rtty_shift < rtty::numshifts ? rtty::SHIFT[progdefaults.rtty_shift] : progdefaults.rtty_custom_shift); offset /= 2; if (active_modem->get_reverse()) offset *= -1; } if (testmode.find("CW") != std::string::npos) afreq = 0; if (xcvr_useFSK) afreq = 0; if (mode == MODE_ANALYSIS) { dfreq = 0; } else { if (usb) dfreq = rfc + afreq + offset; else dfreq = rfc - afreq - offset; } snprintf(szFrequency, sizeof(szFrequency), "%-.3f", dfreq / 1000.0); } else { dfreq = active_modem->get_txfreq(); snprintf(szFrequency, sizeof(szFrequency), "%-.0f", dfreq); } inpFreq->value(szFrequency); } } // Check the display offset & limit to 0 to max IMAGE_WIDTH displayed void WFdisp::checkoffset() { if (mode == SCOPE) { if (sigoffset < 0) sigoffset = 0; if (sigoffset > (IMAGE_WIDTH - disp_width)) sigoffset = IMAGE_WIDTH - disp_width; } else { if (offset > (int)(progdefaults.HighFreqCutoff - step * disp_width)) offset = (int)(progdefaults.HighFreqCutoff - step * disp_width); if (offset < 0) offset = 0; } } void WFdisp::setOffset(int v) { offset = v; checkoffset(); } void WFdisp::slew(int dir) { if (mode == SCOPE) sigoffset += dir; else offset += dir; checkoffset(); } void WFdisp::movetocenter() { if (mode == SCOPE) { sigoffset = IMAGE_WIDTH / 2; } else if (active_modem->get_mode() == MODE_FMT) { if (progdefaults.fmt_center_on_unknown) offset = cnt_unk_freq->value() - (disp_width * step / 2); else if (progdefaults.fmt_center_on_reference) offset = cnt_ref_freq->value() - (disp_width * step / 2); else if (progdefaults.fmt_center_on_median) offset = (cnt_unk_freq->value() + cnt_ref_freq->value())/2 - (disp_width * step / 2); else offset = progdefaults.PSKsweetspot - (disp_width * step / 2); } else offset = carrierfreq - (disp_width * step / 2); checkoffset(); } void WFdisp::carrier(int cf) { if (cf >= bandwidth / 2 && cf < (IMAGE_WIDTH - bandwidth / 2)) { carrierfreq = cf; makeMarker(); } } int WFdisp::carrier() { return carrierfreq; } void WFdisp::checkWidth() { disp_width = w(); if (mag == MAG_1) step = 4; if (mag == MAG_1 && disp_width > progdefaults.HighFreqCutoff/4) disp_width = progdefaults.HighFreqCutoff/4; if (mag == MAG_2) step = 2; if (mag == MAG_2 && disp_width > progdefaults.HighFreqCutoff/2) disp_width = progdefaults.HighFreqCutoff/2; if (mag == MAG_4) step = 1; } int WFdisp::checkMag() { checkWidth(); makeScale(); return mag; } int WFdisp::setMag(int m) { int mid = offset + (disp_width * step / 2); mag = m; checkMag(); if (centercarrier || Fl::event_shift()) { offset = mid - (disp_width * step / 2); } else { movetocenter(); } return mag; } int WFdisp::wfmag() { int mid = offset + (disp_width * step / 2); if (mag == MAG_1) mag = MAG_2; else if (mag == MAG_2) mag = MAG_4; else mag = MAG_1; checkMag(); if (centercarrier || Fl::event_shift()) { offset = mid - (disp_width * step / 2); } else { movetocenter(); } return mag; } void WFdisp::drawScale() { int fw = 60, xoff; static char szFreq[20]; double fr; uchar *pixmap; if (progdefaults.wf_audioscale) { pixmap = (scaleimage + (int)offset); fl_draw_image_mono( pixmap, x(), y() + WFTEXT, w(), WFSCALE, step, scale_width); fl_color(0xFFFFFF00); fl_font(progdefaults.WaterfallFontnbr, progdefaults.WaterfallFontsize); for (int i = 1; ; i++) { fr = 500.0 * i; snprintf(szFreq, sizeof(szFreq), "%7.0f", fr); fw = (int)fl_width(szFreq); xoff = (int) (( (1000.0/step) * i - fw) / 2.0 - offset /step ); if (xoff > 0 && xoff < w() - fw) fl_draw(szFreq, x() + xoff, y() + 10 ); if (xoff > w() - fw) break; } return; } int mdoffset = 0; std::string testmode = qso_opMODE->value(); bool xcvr_useFSK = ((testmode.find("RTTY") != std::string::npos) || (testmode.find("FSK") != std::string::npos) || ((testmode.find("DATA") != std::string::npos) && (use_nanoIO ||progdefaults.PseudoFSK)) ); usb = !ModeIsLSB(testmode); if ((testmode.find("DATA") != std::string::npos) && xcvr_useFSK) usb = !usb; if (testmode.find("CW") != std::string::npos) mdoffset = progdefaults.CWsweetspot; if (xcvr_useFSK) { if (progdefaults.useFSK) { if (usb) mdoffset = progdefaults.RTTYsweetspot + 170 / 2; // 45.45 baud 170 Hz shift else mdoffset = progdefaults.RTTYsweetspot - 170 / 2; } else { if (usb) mdoffset = progdefaults.xcvr_FSK_MARK + rtty::SHIFT[progdefaults.rtty_baud] * 2; else mdoffset = progdefaults.xcvr_FSK_MARK; } } if (usb) pixmap = (scaleimage + (int)(((rfc - mdoffset) % 1000 + offset)) ); else pixmap = (scaleimage + (int)((1000 - (rfc + mdoffset) % 1000 + offset))); fl_draw_image_mono( pixmap, x(), y() + WFTEXT, w(), WFSCALE, step, scale_width); fl_color(0xFFFFFF00); fl_font(progdefaults.WaterfallFontnbr, progdefaults.WaterfallFontsize); for (int i = 1; ; i++) { if (usb) fr = (rfc - mdoffset - (rfc - mdoffset) % 500 + 500 * i)/1000.0; else fr = (rfc + mdoffset - (rfc + mdoffset) % 500 - 500 * i + 500)/1000.0; snprintf(szFreq, sizeof(szFreq), "%7.1f", fr); fw = (int)fl_width(szFreq); if (usb) xoff = (int) ( ( (1000.0/step) * i - fw) / 2.0 - (offset + (rfc - mdoffset) % 500) / step ); else xoff = (int) ( ( (1000.0/step) * i - fw) / 2.0 - (offset + 500 - (rfc + mdoffset) % 500) / step ); if (xoff > 0 && xoff < w() - fw) fl_draw(szFreq, x() + xoff, y() + 10 ); if (xoff > w() - fw) break; } } void WFdisp::drawMarker() { if (mode == SCOPE) return; int msize = RGBsize * scale_width; int psize = scale_width * WFMARKER; uchar *pixmap = (uchar *)(markerimage + (int)(offset)); uchar map[msize]; memset(map, 0, sizeof(map)); int y1 = y() + WFSCALE + WFTEXT; for (int yp = 0; yp < WFMARKER; yp++) { for (int xp = 0; xp < scale_width; xp++) { if ((RGBsize * xp + 2 < msize) && (RGBsize * (yp * scale_width + xp * step + 2) < psize)) { map[RGBsize * xp] = pixmap[RGBsize * (yp * scale_width + xp * step)]; map[RGBsize * xp + 1] = pixmap[RGBsize * (yp * scale_width + xp * step) + 1]; map[RGBsize * xp + 2] = pixmap[RGBsize * (yp * scale_width + xp * step) + 2]; } } fl_draw_image((const uchar *)map, x(), y1 + yp, w(), 1, RGBsize, 0); } return; } void WFdisp::update_waterfall() { // transfer the fft history data into the WF image short int * __restrict__ p1, * __restrict__ p2; RGBI * __restrict__ p3, * __restrict__ p4; p1 = tmp_fft_db + offset + step/2; p2 = p1; p3 = fft_img; p4 = p3; short* __restrict__ limit = tmp_fft_db + image_area - step + 1; #define UPD_LOOP( Step, Operation ) \ case Step: for (int row = 0; row < image_height; row++) { \ p2 = p1; \ p4 = p3; \ for ( const short * __restrict__ last_p2 = std::min( p2 + Step * disp_width, limit +1 ); p2 < last_p2; p2 += Step ) { \ *(p4++) = mag2RGBI[ Operation ]; \ } \ p1 += IMAGE_WIDTH; \ p3 += disp_width; \ }; break if (progdefaults.WFaveraging) { switch(step) { UPD_LOOP( 4, (*p2 + *(p2+1) + *(p2+2) + *(p2-1) + *(p2-1))/5 ); UPD_LOOP( 2, (*p2 + *(p2+1) + *(p2-1))/3 ); UPD_LOOP( 1, *p2 ); default:; } } else { switch(step) { UPD_LOOP( 4, MAX( MAX( MAX ( MAX ( *p2, *(p2+1) ), *(p2+2) ), *(p2-2) ), *(p2-1) ) ); UPD_LOOP( 2, MAX( MAX( *p2, *(p2+1) ), *(p2-1) ) ); UPD_LOOP( 1, *p2 ); default:; } } #undef UPD_LOOP if (active_modem && progdefaults.UseBWTracks) { trx_mode mode = active_modem->get_mode(); if (mode == MODE_FMT) { int bw =progdefaults.FMT_filter; int trk = int(round(cnt_unk_freq->value())); RGBI *pos1 = fft_img + (trk - offset - bw) / step; RGBI *pos2 = fft_img + (trk - offset + bw) / step; RGBI unk_trk_color, ref_trk_color; Fl::get_color(progdefaults.FMT_unk_color, unk_trk_color.R, unk_trk_color.G, unk_trk_color.B); Fl::get_color(progdefaults.FMT_ref_color, ref_trk_color.R, ref_trk_color.G, ref_trk_color.B); if (likely(pos1 >= fft_img && pos2 < fft_img + disp_width)) { if (progdefaults.UseWideTracks) { for (int y = 0; y < image_height; y ++) { *(pos1 + 1) = *pos1 = unk_trk_color; *(pos2 - 1) = *pos2 = unk_trk_color; pos1 += disp_width; pos2 += disp_width; } } else { for (int y = 0; y < image_height; y ++) { *pos1 = unk_trk_color; *pos2 = unk_trk_color; pos1 += disp_width; pos2 += disp_width; } } } trk = int(round(cnt_ref_freq->value())); pos1 = fft_img + (trk - offset - bw) / step; pos2 = fft_img + (trk - offset + bw) / step; if (likely(pos1 >= fft_img && pos2 < fft_img + disp_width)) { if (progdefaults.UseWideTracks) { for (int y = 0; y < image_height; y ++) { *(pos1 + 1) = *pos1 = ref_trk_color; *(pos2 - 1) = *pos2 = ref_trk_color; pos1 += disp_width; pos2 += disp_width; } } else { for (int y = 0; y < image_height; y ++) { *pos1 = ref_trk_color; *pos2 = ref_trk_color; pos1 += disp_width; pos2 += disp_width; } } } } else { int bw_lo = bandwidth / 2; int bw_hi = bandwidth / 2; trx_mode mode = active_modem->get_mode(); if (mode >= MODE_MT63_500S && mode <= MODE_MT63_2000L) bw_hi = bw_hi * 31 / 32; if (mode == MODE_FSQ || mode == MODE_IFKP) { bw_hi = bw_lo = 69 * bandwidth / 100; } RGBI *pos1 = fft_img + (carrierfreq - offset - bw_lo) / step; RGBI *pos2 = fft_img + (carrierfreq - offset + bw_hi) / step; if (unlikely(pos2 == fft_img + disp_width)) pos2--; if (likely(pos1 >= fft_img && pos2 < fft_img + disp_width)) { RGBI rgbi1, rgbi2 ; if (mode == MODE_RTTY && progdefaults.useMARKfreq) { if (active_modem->get_reverse()) { rgbi1 = progdefaults.rttymarkRGBI; rgbi2 = progdefaults.bwTrackRGBI; } else { rgbi1 = progdefaults.bwTrackRGBI; rgbi2 = progdefaults.rttymarkRGBI; } } else { rgbi1 = progdefaults.bwTrackRGBI; rgbi2 = progdefaults.bwTrackRGBI; } if (progdefaults.UseWideTracks) { for (int y = 0; y < image_height; y ++) { *(pos1 + 1) = *pos1 = rgbi1; *(pos2 - 1) = *pos2 = rgbi2; pos1 += disp_width; pos2 += disp_width; } } else { for (int y = 0; y < image_height; y ++) { *pos1 = rgbi1; *pos2 = rgbi2; pos1 += disp_width; pos2 += disp_width; } } } } } // draw notch if ((notch_frequency > 1) && (notch_frequency < progdefaults.HighFreqCutoff - 1)) { RGBInotch.I = progdefaults.notchRGBI.I; RGBInotch.R = progdefaults.notchRGBI.R; RGBInotch.G = progdefaults.notchRGBI.G; RGBInotch.B = progdefaults.notchRGBI.B; RGBI *notch = fft_img + (notch_frequency - offset) / step; int dash = 0; for (int y = 0; y < image_height; y++) { dash = (dash + 1) % 6; if (dash == 0 || dash == 1 || dash == 2) *(notch-1) = *notch = *(notch+1) = RGBInotch; notch += disp_width; } } if (progdefaults.show_psm_btn && progStatus.kpsql_enabled && (trx_state == STATE_RX)) signal_psm(); } void WFdisp::drawcolorWF() { uchar *pixmap = (uchar *)fft_img; update_waterfall(); if (active_modem && wantcursor && (progdefaults.UseCursorLines || progdefaults.UseCursorCenterLine) ) { trx_mode mode = active_modem->get_mode(); int bw_lo = bandwidth / 2; int bw_hi = bandwidth / 2; if (mode >= MODE_MT63_500S && mode <= MODE_MT63_2000L) bw_hi = bw_hi * 31 / 32; if (mode == MODE_FSQ || mode == MODE_IFKP) bw_hi = bw_hi * 32 / 33; if (mode == MODE_FMT) { bw_lo = bw_hi = progdefaults.FMT_filter; } RGBI *pos0 = (fft_img + cursorpos); RGBI *pos1 = (fft_img + cursorpos - bw_lo/step); RGBI *pos2 = (fft_img + cursorpos + bw_hi/step); if (pos1 >= fft_img && pos2 < fft_img + disp_width) { for (int y = 0; y < image_height; y ++) { if (progdefaults.UseCursorLines) { *pos1 = *pos2 = progdefaults.cursorLineRGBI; if (progdefaults.UseWideCursor) *(pos1 + 1) = *(pos2 - 1) = *pos1; } if (progdefaults.UseCursorCenterLine) { *pos0 = progdefaults.cursorCenterRGBI; if (progdefaults.UseWideCenter) *(pos0 - 1) = *(pos0 + 1) = *pos0; } pos0 += disp_width; pos1 += disp_width; pos2 += disp_width; } } } fl_color(FL_BLACK); fl_rectf(x(), y(), w(), WFSCALE + WFMARKER + WFTEXT); fl_color(fl_rgb_color(palette[0].R, palette[0].G, palette[0].B)); fl_rectf(x(), y() + WFSCALE + WFMARKER + WFTEXT, w(), image_height); fl_draw_image( pixmap, x(), y() + WFSCALE + WFMARKER + WFTEXT, disp_width, image_height, sizeof(RGBI), disp_width * sizeof(RGBI) ); drawScale(); } void WFdisp::drawspectrum() { int sig; long offset_idx = 0; long ynext, h1 = image_height - 1, ffty = 0, fftpixel = IMAGE_WIDTH * h1, graylevel = 220; uchar *pixmap = (uchar *)fft_sig_img + offset / step; memset (fft_sig_img, 0, image_area); fftpixel /= step; for (int c = 0; c < IMAGE_WIDTH; c += step) { sig = tmp_fft_db[c]; if (step == 1) sig = tmp_fft_db[c]; else if (step == 2) sig = MAX(tmp_fft_db[c], tmp_fft_db[c+1]); else sig = MAX( MAX ( MAX ( tmp_fft_db[c], tmp_fft_db[c+1] ), tmp_fft_db[c+2] ), tmp_fft_db[c+3]); ynext = h1 * sig / 256; offset_idx = (IMAGE_WIDTH/step); while ((ffty < ynext)) { fft_sig_img[fftpixel -= offset_idx] = graylevel; ffty++; if (fftpixel < offset_idx) { std::cout << "corrupt index 1\n"; break; } } while ((ffty > ynext)) { fft_sig_img[fftpixel += offset_idx] = graylevel; ffty--; if (fftpixel >= (image_area - 1)) { std::cout << "corrupt index 2\n"; break; } } if (fftpixel >= 0 && fftpixel <= image_area) fft_sig_img[fftpixel++] = graylevel; else std::cout << "fft_sig_image index out of bounds: " << fftpixel << std::endl; } if (progdefaults.UseBWTracks) { if (active_modem == fmt_modem) { uchar *pos1; uchar *pos2; int trk1 = int(round(cnt_unk_freq->value())); int trk2 = int(round(cnt_ref_freq->value())); int bw = int(round(progdefaults.FMT_filter)); pos1 = pixmap + (trk1 - offset - bw) / step; pos2 = pixmap + (trk1 - offset + bw) / step; if (pos1 >= pixmap && pos2 < pixmap + disp_width) for (int y = 0; y < image_height; y ++) { *pos1 = *pos2 = 255; if (progdefaults.UseWideTracks) { *(pos1 + 1) = *(pos2 - 1) = 255; } pos1 += IMAGE_WIDTH/step; pos2 += IMAGE_WIDTH/step; } pos1 = pixmap + (trk2 - offset - bw) / step; pos2 = pixmap + (trk2 - offset + bw) / step; if (pos1 >= pixmap && pos2 < pixmap + disp_width) { for (int y = 0; y < image_height; y ++) { *pos1 = *pos2 = 255; if (progdefaults.UseWideTracks) { *(pos1 + 1) = *(pos2 - 1) = 255; } pos1 += IMAGE_WIDTH/step; pos2 += IMAGE_WIDTH/step; } } } else { uchar *pos1 = pixmap + (carrierfreq - offset - bandwidth/2) / step; uchar *pos2 = pixmap + (carrierfreq - offset + bandwidth/2) / step; if (pos1 >= pixmap && pos2 < pixmap + disp_width) { for (int y = 0; y < image_height; y ++) { *pos1 = *pos2 = 255; if (progdefaults.UseWideTracks) { *(pos1 + 1) = 255; *(pos2 - 1) = 255; } pos1 += IMAGE_WIDTH/step; pos2 += IMAGE_WIDTH/step; } } } } if (active_modem && wantcursor && (progdefaults.UseCursorLines || progdefaults.UseCursorCenterLine)) { trx_mode mode = active_modem->get_mode(); int bw_lo = bandwidth / 2; int bw_hi = bandwidth / 2; if (mode >= MODE_MT63_500S && mode <= MODE_MT63_2000L) bw_hi = bw_hi * 31 / 32; if (mode == MODE_FSQ || mode == MODE_IFKP) bw_hi = bw_hi * 32 / 33; uchar *pos0 = pixmap + cursorpos; uchar *pos1 = (pixmap + cursorpos - bw_lo/step); uchar *pos2 = (pixmap + cursorpos + bw_hi/step); for (int y = 0; y < h1; y ++) { if (progdefaults.UseCursorLines) { *pos1 = *pos2 = 255; if (progdefaults.UseWideCursor) *(pos1 + 1) = *(pos2 - 1) = *pos1; } if (progdefaults.UseCursorCenterLine) { *pos0 = 255; if (progdefaults.UseWideCenter) *(pos0-1) = *(pos0+1) = *(pos0); } pos0 += IMAGE_WIDTH/step; pos1 += IMAGE_WIDTH/step; pos2 += IMAGE_WIDTH/step; } } // draw notch if ((notch_frequency > 1) && (notch_frequency < progdefaults.HighFreqCutoff - 1)) { uchar *notch = pixmap + (notch_frequency - offset) / step; int dash = 0; for (int y = 0; y < image_height; y++) { dash = (dash + 1) % 6; if (dash == 0 || dash == 1 || dash == 2) *(notch-1) = *notch = *(notch+1) = 255; notch += IMAGE_WIDTH/step; } } fl_color(FL_BLACK); fl_rectf(x(), y(), w(), WFSCALE + WFMARKER + WFTEXT + image_height); fl_draw_image_mono( pixmap, x(), y() + WFSCALE + WFMARKER + WFTEXT, disp_width, image_height, 1, IMAGE_WIDTH / step); drawScale(); } void WFdisp::drawsignal() { uchar *pixmap = (uchar *)(sig_img + sigoffset); fl_color(FL_BLACK); fl_rectf(x() + disp_width, y(), w() - disp_width, h()); fl_draw_image_mono(pixmap, x(), y(), disp_width, h(), 1, IMAGE_WIDTH); } void WFdisp::draw() { checkoffset(); checkWidth(); if (progdefaults.show_psm_btn && progStatus.kpsql_enabled) { drawcolorWF(); drawMarker(); return; } switch (mode) { case SPECTRUM : drawspectrum(); drawMarker(); break; case SCOPE : drawsignal(); break; case WATERFALL : default: drawcolorWF(); drawMarker(); } } //======================================================================= // waterfall //======================================================================= void x1_cb(Fl_Widget *w, void* v) { waterfall *wf = (waterfall *)w->parent(); int m = wf->wfdisp->wfmag(); if (m == MAG_1) w->label("x1"); if (m == MAG_2) w->label("x2"); if (m == MAG_4) w->label("x4"); restoreFocus(); } void slew_left(Fl_Widget *w, void * v) { waterfall *wf = (waterfall *)w->parent(); wf->wfdisp->slew(-100); restoreFocus(); } void slew_right(Fl_Widget *w, void * v) { waterfall *wf = (waterfall *)w->parent(); wf->wfdisp->slew(100); restoreFocus(); } void center_cb(Fl_Widget *w, void *v) { waterfall *wf = (waterfall *)w->parent(); wf->wfdisp->movetocenter(); restoreFocus(); } void killMacroTimer() { stopMacroTimer(); } void carrier_cb(Fl_Widget *w, void *v) { Fl_Counter *cntr = (Fl_Counter *)w; waterfall *wf = (waterfall *)w->parent(); int selfreq = (int) cntr->value(); if (selfreq > progdefaults.HighFreqCutoff) selfreq = progdefaults.HighFreqCutoff - wf->wfdisp->Bandwidth() / 2; killMacroTimer(); if (active_modem) active_modem->set_freq(selfreq); wf->wfdisp->carrier(selfreq); restoreFocus(); } void do_qsy(bool dir) { if (!active_modem) return; static std::vector<qrg_mode_t> qsy_stack; qrg_mode_t m; wf->xmtlock->value(0); wf->xmtlock->do_callback(); if (dir) { // store m.rfcarrier = wf->rfcarrier(); int wfc = m.carrier = active_modem->get_freq(); qsy_stack.push_back(m); m.rmode = qso_opMODE->value(); trx_mode md = active_modem->get_mode(); std::string testmode = qso_opMODE->value(); bool xcvr_useFSK = ((testmode.find("RTTY") != std::string::npos) || (testmode.find("FSK") != std::string::npos) || ((testmode.find("DATA") != std::string::npos) && (use_nanoIO)) ); // qsy to the sweet spot frequency that is the center of the PBF in the rig switch (md) { case MODE_CW: m.carrier = progdefaults.CWsweetspot; break; case MODE_RTTY: if (xcvr_useFSK) { // qsy operates on change in audio center track m.carrier = progdefaults.xcvr_FSK_MARK + rtty::SHIFT[progdefaults.rtty_shift]/2; } else m.carrier = progdefaults.RTTYsweetspot; break; case MODE_FMT: if (progdefaults.fmt_center_on_unknown) m.carrier = cnt_unk_freq->value(); else if (progdefaults.fmt_center_on_reference) m.carrier = cnt_ref_freq->value(); else if (progdefaults.fmt_center_on_median) m.carrier = (cnt_unk_freq->value() + cnt_ref_freq->value())/2; else m.carrier = progdefaults.PSKsweetspot; break; default: m.carrier = progdefaults.PSKsweetspot; break; } if (m.rmode.find("CW") != std::string::npos) { if (wf->USB()) m.rfcarrier += (wfc - m.carrier); else m.rfcarrier -= (wfc - m.carrier); } else if ( (md == MODE_RTTY) && xcvr_useFSK ) { if (wf->USB()) { m.rfcarrier += (wfc - m.carrier); } else { m.rfcarrier -= (wfc - m.carrier); } } else { if (wf->USB()) m.rfcarrier += (wf->carrier() - m.carrier); else m.rfcarrier -= (wf->carrier() - m.carrier); } } else { // qsy to top of stack if (qsy_stack.size()) { m = qsy_stack.back(); qsy_stack.pop_back(); } } if (m.carrier > 0) qsy(m.rfcarrier, m.carrier); } void qsy_cb(Fl_Widget *w, void *v) { if (Fl::event_button() != FL_RIGHT_MOUSE) do_qsy(true); else do_qsy(false); restoreFocus(); } void rate_cb(Fl_Widget *w, void *v) { waterfall* wf = static_cast<waterfall*>(w->parent()); WFspeed new_speed; switch (wf->wfdisp->Speed()) { case SLOW: new_speed = NORMAL; break; case NORMAL: default: new_speed = FAST; break; case FAST: new_speed = PAUSE; break; case PAUSE: new_speed = SLOW; break; } wf->Speed(new_speed); restoreFocus(); } //extern void reset_xmlchars(); void xmtrcv_cb(Fl_Widget *w, void *vi) { if (!active_modem) return; Fl_Light_Button *b = (Fl_Light_Button *)w; int v = b->value(); if (!(active_modem->get_cap() & modem::CAP_TX)) { b->value(0); restoreFocus(); return; } if (v == 1) { killMacroTimer(); active_modem->set_stopflag(false); if (progdefaults.show_psm_btn && progStatus.kpsql_enabled) set_xmtrcv_selection_color_pending(); trx_transmit(); } else { if (progdefaults.show_psm_btn && progStatus.kpsql_enabled) { psm_transmit_ended(PSM_ABORT); xmtrcv_selection_color(progdefaults.XmtColor); } if (btnTune->value()) { btnTune->value(0); btnTune->do_callback(); } else { TransmitText->clear(); if (active_modem->get_mode() == MODE_FSQ && fsq_tx_text) fsq_tx_text->clear(); else if (active_modem->get_mode() == MODE_IFKP && ifkp_tx_text) ifkp_tx_text->clear(); if (arq_text_available) AbortARQ(); if(xmltest_char_available) reset_xmlchars(); if(kiss_text_available) flush_kiss_tx_buffer(); if (progStatus.timer) { progStatus.timer = 0; } queue_reset(); active_modem->set_stopflag(true); } } restoreFocus(); } void xmtlock_cb(Fl_Widget *w, void *vi) { if (!active_modem) return; Fl_Light_Button *b = (Fl_Light_Button *)w; int v = b->value(); active_modem->set_freqlock(v ? true : false ); restoreFocus(); } void waterfall::set_XmtRcvBtn(bool val) { xmtrcv->value(val); if (!val && btnTune->value()) { btnTune->value(0); btnTune->labelcolor(FL_FOREGROUND_COLOR); } } void set_wf_mode(void) { static const char* names[NUM_WF_MODES] = { "WF", "FFT", "SIG" }; int m = 0; if (progdefaults.show_psm_btn && progStatus.kpsql_enabled) { if(wf->wfdisp->Mode() == WATERFALL) { return; } m = WATERFALL; } else { m = wf->wfdisp->Mode() + (Fl::event_button() == FL_LEFT_MOUSE ? 1 : -1); } m = WCLAMP(m, WATERFALL, NUM_WF_MODES-1); if (m == SCOPE) wf->x1->deactivate(); else wf->x1->activate(); wf->wfdisp->Mode(static_cast<WFmode>(m)); wf->mode->label(names[m]); restoreFocus(); } void mode_cb(Fl_Widget* w, void*) { set_wf_mode(); } void reflevel_cb(Fl_Widget *w, void *v) { waterfall *wf = (waterfall *)w->parent(); double val = wf->wfRefLevel->value(); progdefaults.wfRefLevel = val; restoreFocus(); } void ampspan_cb(Fl_Widget *w, void *v) { waterfall *wf = (waterfall *)w->parent(); double val = wf->wfAmpSpan->value(); wf->wfdisp->Ampspan(val); progdefaults.wfAmpSpan = val; restoreFocus(); } void btnRev_cb(Fl_Widget *w, void *v) { if (!active_modem) return; waterfall *wf = (waterfall *)w->parent(); Fl_Light_Button *b = (Fl_Light_Button *)w; wf->Reverse(b->value()); active_modem->set_reverse(wf->Reverse()); progdefaults.rtty_reverse = b->value(); set_mode_reverse(active_modem->get_mode(), progdefaults.rtty_reverse); progdefaults.changed = true; restoreFocus(); } void btnMem_cb(Fl_Widget *, void *menu_event) { if (!active_modem) return; static std::vector<qrg_mode_t> qrg_list; enum { SELECT, APPEND, REPLACE, REMOVE, CLEAR }; int op = SELECT, elem = 0; if (menu_event) { // event on popup menu elem = wf->mbtnMem->value(); switch (Fl::event_button()) { case FL_MIDDLE_MOUSE: op = REPLACE; break; case FL_LEFT_MOUSE: case FL_RIGHT_MOUSE: default: op = (Fl::event_state() & FL_SHIFT) ? REMOVE : SELECT; break; } } else { // button press switch (Fl::event_button()) { case FL_RIGHT_MOUSE: return; case FL_MIDDLE_MOUSE: // select last if ((elem = qrg_list.size() - 1) < 0) return; op = SELECT; break; case FL_LEFT_MOUSE: default: op = (Fl::event_state() & FL_SHIFT) ? CLEAR : APPEND; break; } } qrg_mode_t m; switch (op) { case SELECT: m = qrg_list[elem]; if (active_modem != *mode_info[m.mode].modem) { init_modem_sync(m.mode); } if (m.rfcarrier && m.rfcarrier != wf->rfcarrier()) qsy(m.rfcarrier, m.carrier); else active_modem->set_freq(m.carrier); break; case REMOVE: wf->mbtnMem->remove(elem); qrg_list.erase(qrg_list.begin() + elem); break; case CLEAR: wf->mbtnMem->clear(); qrg_list.clear(); break; case APPEND: case REPLACE: m.rfcarrier = wf->rfcarrier(); m.carrier = active_modem->get_freq(); m.mode = active_modem->get_mode(); if (op == APPEND) { if (find(qrg_list.begin(), qrg_list.end(), m) == qrg_list.end()) qrg_list.push_back(m); else break; } else qrg_list[elem] = m; // write the menu item text { std::ostringstream o; o << mode_info[m.mode].name << " @@ "; if (m.rfcarrier > 0) { // write 1000s separators char s[20], *p = s + sizeof(s) - 1; int i = 0; *p = '\0'; do { if (i % 3 == 0 && i) *--p = '.'; *--p = '0' + m.rfcarrier % 10; ++i; } while ((m.rfcarrier /= 10) && p > s); o << p << (wf->USB() ? " + " : " - "); } o << m.carrier; if (op == APPEND) { wf->mbtnMem->add(o.str().c_str()); } else { wf->mbtnMem->replace(elem, o.str().c_str()); } } break; } restoreFocus(); } void waterfall::opmode() { if (!active_modem) return; int val = (int)active_modem->get_bandwidth(); wfdisp->carrier((int)CLAMP( wfdisp->carrier(), progdefaults.LowFreqCutoff + val / 2, progdefaults.HighFreqCutoff - val / 2)); wfdisp->Bandwidth( val ); wfcarrier->range(progdefaults.LowFreqCutoff + val/2, progdefaults.HighFreqCutoff - val/2); } void waterfall::carrier(int f) { wfdisp->carrier(f); wfcarrier->value(f); wfcarrier->damage(FL_DAMAGE_ALL); } int waterfall::Speed() { return (int)wfdisp->Speed(); } void waterfall::Speed(int rate) { WFspeed speed = static_cast<WFspeed>(rate); wfdisp->Speed(speed); const char* label; switch (speed) { case SLOW: label = "SLOW"; break; case NORMAL: default: label = "NORM"; break; case FAST: label = "FAST"; break; case PAUSE: label = "PAUSE"; break; } wfrate->label(label); wfrate->redraw_label(); } int waterfall::Mag() { return wfdisp->Mag(); } void waterfall::Mag(int m) { wfdisp->Mag(m); if (m == MAG_1) x1->label("x1"); if (m == MAG_2) x1->label("x2"); if (m == MAG_4) x1->label("x4"); x1->redraw_label(); } int waterfall::Offset() { return wfdisp->Offset(); } void waterfall::Offset(int v) { wfdisp->Offset(v); } int waterfall::Carrier() { return wfdisp->carrier(); } void waterfall::Carrier(int f) { if (active_modem) active_modem->set_freq(f); } void waterfall::rfcarrier(long long cf) { wfdisp->rfcarrier(cf); } long long waterfall::rfcarrier() { return wfdisp->rfcarrier(); } void waterfall::setRefLevel() { wfRefLevel->value(progdefaults.wfRefLevel); } void waterfall::setAmpSpan() { wfAmpSpan->value(progdefaults.wfAmpSpan); wfdisp->Ampspan(progdefaults.wfAmpSpan); } void waterfall::USB(bool b) { if (wfdisp->USB() == b) return; wfdisp->USB(b); if (active_modem) active_modem->set_reverse(reverse); REQ(&viewer_redraw); } bool waterfall::USB() { return wfdisp->USB(); } void waterfall::show_scope(bool on) { if (on) { wfscope->show(); wfscope->position(wf->x() + wf->w() - wf_dim - BEZEL, wf->y()); wfdisp->size( wf->w() - 2 * BEZEL - wf_dim, wf_dim - 2 * BEZEL); rs1->init_sizes(); } else { wfscope->hide(); wfscope->position(wf->x() + wf->w(), wf->y()); wfdisp->size( wf->w() - 2 * BEZEL, wf_dim - 2 * BEZEL); rs1->init_sizes(); } wfscope->redraw(); } waterfall::waterfall(int x0, int y0, int w0, int h0, char *lbl) : Fl_Group(x0,y0,w0,h0,lbl) { int xpos; float ratio; ratio = w0 * 1.0 / bwdths; wf_dim = h() - BTN_HEIGHT - 4; buttonrow = h() + y() - BTN_HEIGHT - 1; rs1 = new Fl_Group(x(), y(), w(), wf_dim); rs1->box(FL_DOWN_BOX); wfdisp = new WFdisp( x() + BEZEL, y() + BEZEL, w() - 2 * BEZEL, wf_dim - 2 * BEZEL); wfscope = new Digiscope (x() + w(), y(), wf_dim, wf_dim); rs1->resizable(wfdisp); rs1->end(); wfscope->hide(); xpos = x() + wSpace; mode = new Fl_Button(xpos, buttonrow, (int)(bwFFT*ratio), BTN_HEIGHT, "WF"); mode->callback(mode_cb, 0); mode->tooltip(_("Waterfall / FFT / Scope")); xpos = xpos + (int)(bwFFT*ratio) + wSpace; wfRefLevel = new Fl_Counter2(xpos, buttonrow, (int)(cwRef*ratio), BTN_HEIGHT ); wfRefLevel->callback(reflevel_cb, 0); wfRefLevel->step(1.0); wfRefLevel->precision(0); wfRefLevel->range(-80.0, 0.0);//(-40.0, 0.0); wfRefLevel->value(0.0);//(-20.0); wfRefLevel->tooltip(_("Upper signal level (dB)")); wfRefLevel->type(FL_SIMPLE_COUNTER); xpos = xpos + (int)(cwRef*ratio) + wSpace; wfAmpSpan = new Fl_Counter2(xpos, buttonrow, (int)(cwRef*ratio), BTN_HEIGHT ); wfAmpSpan->callback(ampspan_cb, 0); wfAmpSpan->step(1.0); wfAmpSpan->precision(0); wfAmpSpan->range(6.0, 90.0); wfAmpSpan->value(70.0); wfdisp->Ampspan(70.0); wfAmpSpan->tooltip(_("Signal range (dB)")); wfAmpSpan->type(FL_SIMPLE_COUNTER); xpos = xpos + (int)(cwRef*ratio) + wSpace; x1 = new Fl_Button(xpos, buttonrow, (int)(bwX1*ratio), BTN_HEIGHT, "x1"); x1->callback(x1_cb, 0); x1->tooltip(_("Change waterfall scale")); xpos = xpos + (int)(bwX1*ratio) + wSpace; left = new Fl_Repeat_Button(xpos, buttonrow, (int)(bwMov*ratio), BTN_HEIGHT, "@<"); left->callback(slew_left, 0); left->tooltip(_("Slew display lower in frequency")); xpos = xpos + (int)(bwMov*ratio); center = new Fl_Button(xpos, buttonrow, (int)(bwMov*ratio), BTN_HEIGHT, "@||"); center->callback(center_cb, 0); center->tooltip(_("Center display on signal")); xpos = xpos + (int)(bwMov*ratio); right = new Fl_Repeat_Button(xpos, buttonrow, (int)(bwMov*ratio), BTN_HEIGHT, "@>"); right->callback(slew_right, 0); right->tooltip(_("Slew display higher in frequency")); xpos = xpos + (int)(bwMov*ratio) + wSpace; wfrate = new Fl_Button(xpos, buttonrow, (int)(bwRate*ratio), BTN_HEIGHT, "Norm"); wfrate->callback(rate_cb, 0); wfrate->tooltip(_("Waterfall drop speed")); xpos = xpos + (int)(bwRate*ratio) + wSpace; wfcarrier = new Fl_Counter2(xpos, buttonrow, (int)(cwCnt*ratio), BTN_HEIGHT ); wfcarrier->callback(carrier_cb, 0); wfcarrier->step(1.0); wfcarrier->lstep(10.0); wfcarrier->precision(0); wfcarrier->range(16.0, progdefaults.HighFreqCutoff - 16.0); wfcarrier->value(wfdisp->carrier()); wfcarrier->tooltip(_("Adjust cursor frequency")); xpos = xpos + (int)(cwCnt*ratio) + wSpace; qsy = new Fl_Button(xpos, buttonrow, (int)(bwQsy*ratio), BTN_HEIGHT, "QSY"); qsy->callback(qsy_cb, 0); qsy->tooltip(_("Center in passband\nRight click to undo")); qsy->deactivate(); xpos = xpos + (int)(bwQsy*ratio) + wSpace; btnMem = new Fl_Button(xpos, buttonrow, (int)(bwMem*ratio), BTN_HEIGHT, "Store"); btnMem->callback(btnMem_cb, 0); btnMem->tooltip(_("Store mode and frequency\nRight click for list")); mbtnMem = new Fl_Menu_Button(btnMem->x(), btnMem->y(), btnMem->w(), btnMem->h(), 0); mbtnMem->callback(btnMem->callback(), mbtnMem); mbtnMem->type(Fl_Menu_Button::POPUP3); xpos = xpos + (int)(bwMem*ratio) + wSpace; xmtlock = new Fl_Light_Button(xpos, buttonrow, (int)(bwXmtLock*ratio), BTN_HEIGHT, "Lk"); xmtlock->callback(xmtlock_cb, 0); xmtlock->value(0); xmtlock->selection_color(progdefaults.LkColor); xmtlock->tooltip(_("Lock transmit frequency")); /// We save this flag which is used by rtty decoding. xpos = xpos + (int)(bwXmtLock*ratio) + wSpace; btnRev = new Fl_Light_Button(xpos, buttonrow, (int)(bwRev*ratio), BTN_HEIGHT, "Rv"); btnRev->callback(btnRev_cb, 0); reverse = progdefaults.rtty_reverse; btnRev->value(reverse); btnRev->selection_color(progdefaults.RevColor); btnRev->tooltip(_("Reverse")); xpos = w() - (int)(bwXmtRcv*ratio) - wSpace; xmtrcv = new Fl_Light_Button(xpos, buttonrow, (int)(bwXmtRcv*ratio) - BEZEL, BTN_HEIGHT, "T/R"); xmtrcv->callback(xmtrcv_cb, 0); xmtrcv->selection_color(progdefaults.XmtColor); xmtrcv->value(0); xmtrcv->tooltip(_("Transmit/Receive")); end(); } void waterfall::UI_select(bool on) { if (on) { if (!progdefaults.WF_UIrev) btnRev->hide(); else btnRev->show(); if (!progdefaults.WF_UIwfcarrier) wfcarrier->hide(); else wfcarrier->show(); if (!progdefaults.WF_UIwfreflevel) wfRefLevel->hide(); else wfRefLevel->show(); if (!progdefaults.WF_UIwfampspan) wfAmpSpan->hide(); else wfAmpSpan->show(); if (!progdefaults.WF_UIxmtlock) xmtlock->hide(); else xmtlock->show(); if (!progdefaults.WF_UIqsy) qsy->hide(); else qsy->show(); if (!progdefaults.WF_UIwfmode) mode->hide(); else mode->show(); if (!progdefaults.WF_UIx1) x1->hide(); else x1->show(); if (!progdefaults.WF_UIwfshift) { left->hide(); center->hide(); right->hide(); } else { left->show(); center->show(); right->show(); } if (!progdefaults.WF_UIwfdrop) wfrate->hide(); else wfrate->show(); if (!progdefaults.WF_UIwfstore) { btnMem->hide(); mbtnMem->hide(); } else { btnMem->show(); mbtnMem->show(); } //if (noUI) xmtrcv->hide(); } else { // btnRev->show(); if (!progdefaults.WF_UIrev) btnRev->hide(); else btnRev->show(); wfcarrier->show(); wfRefLevel->show(); wfAmpSpan->show(); xmtlock->show(); qsy->show(); mode->show(); x1->show(); left->show(); center->show(); right->show(); wfrate->show(); btnMem->show(); mbtnMem->show(); } btnRev->redraw(); wfcarrier->redraw(); wfRefLevel->redraw(); wfAmpSpan->redraw(); xmtlock->redraw(); qsy->redraw(); mode->redraw(); x1->redraw(); left->redraw(); center->redraw(); right->redraw(); wfrate->redraw(); btnMem->redraw(); mbtnMem->redraw(); } int waterfall::handle(int event) { if (event != FL_MOUSEWHEEL || Fl::event_inside(wfdisp)) return Fl_Group::handle(event); int d; if ( !((d = Fl::event_dy()) || (d = Fl::event_dx())) ) return 1; // this does not belong here, but we don't have access to this widget's // handle method (or its parent's) if (active_modem && Fl::event_inside(MODEstatus)) { trx_mode mode = active_modem->get_mode(); for (;;) { mode = WCLAMP(mode + d, 0, NUM_MODES - 1); if ((mode >= NUM_RXTX_MODES && mode < NUM_MODES) || progdefaults.visible_modes.test(mode)) break; } init_modem(mode); return 1; } // as above; handle wheel events for the macro bar extern void altmacro_cb(Fl_Widget *w, void *v); if (progdefaults.macro_wheel) { if (progdefaults.mbar_scheme > MACRO_SINGLE_BAR_MAX) { if (Fl::event_inside(macroFrame2)) { altmacro_cb(btnAltMacros2, reinterpret_cast<void *>(d)); return 1; } } else { if (Fl::event_inside(macroFrame1)) { altmacro_cb(btnAltMacros1, reinterpret_cast<void *>(d)); return 1; } } } return Fl_Group::handle(event); } static Fl_Cursor cursor = FL_CURSOR_DEFAULT; static void hide_cursor(void *w) { if (cursor != FL_CURSOR_NONE) reinterpret_cast<Fl_Widget *>(w)->window()->cursor(cursor = FL_CURSOR_NONE); } void waterfall::insert_text(bool check) { if (active_modem && check) { qrg_mode_t m; m.rfcarrier = wf->rfcarrier(); m.carrier = active_modem->get_freq(); m.mode = active_modem->get_mode(); extern qrg_mode_t last_marked_qrg; if (last_marked_qrg.mode == m.mode && last_marked_qrg.rfcarrier == m.rfcarrier && abs(last_marked_qrg.carrier - m.carrier) <= 16) return; last_marked_qrg = m; } std::string::size_type i; if ((i = progdefaults.WaterfallClickText.find("<FREQ>")) != std::string::npos) { std::string s = progdefaults.WaterfallClickText; s[i] = '\0'; ReceiveText->addstr(s); note_qrg(false); // ReceiveText->addstr(s); // ReceiveText->addstr(s.c_str() + i + strlen("<FREQ>")); } else ReceiveText->addstr(progdefaults.WaterfallClickText, FTextView::SKIP); } static void find_signal_text(void) { if (!active_modem) return; int freq = active_modem->get_freq(); trx_mode mode = active_modem->get_mode(); extern std::map<std::string, qrg_mode_t> qrg_marks; std::map<std::string, qrg_mode_t>::const_iterator i; for (i = qrg_marks.begin(); i != qrg_marks.end(); ++i) if (i->second.mode == mode && abs(i->second.carrier - freq) <= 20) break; if (i != qrg_marks.end()) { // Search backward from the current text cursor position, then // try the other direction int pos = ReceiveText->insert_position(); if (ReceiveText->buffer()->search_backward(pos, i->first.c_str(), &pos, 1) || ReceiveText->buffer()->search_forward(pos, i->first.c_str(), &pos, 1)) { ReceiveText->insert_position(pos); ReceiveText->show_insert_position(); } } } int WFdisp::handle(int event) { static int pxpos, push; if (!(event == FL_LEAVE || Fl::event_inside(this))) { if (event == FL_RELEASE) push = 0; return 0; } if (trx_state != STATE_RX) return 1; int xpos = Fl::event_x() - x(); int ypos = Fl::event_y() - y(); int eb; if (active_modem == fmt_modem) { int nuf = cursorFreq(xpos); if ((Fl::event_state() & (FL_SHIFT)) == FL_SHIFT) { set_unk_freq_value(nuf); } else if ((Fl::event_state() & (FL_CTRL)) == FL_CTRL) { set_ref_freq_value(nuf); } return 1; } switch (event) { case FL_MOVE: if (progdefaults.WaterfallQSY && ypos < WFTEXT + WFSCALE) { Fl::remove_timeout(hide_cursor, this); if (cursor != FL_CURSOR_WE) window()->cursor(cursor = FL_CURSOR_WE); if (wantcursor) { wantcursor = false; makeMarker(); } break; } if (cursor != FL_CURSOR_DEFAULT) window()->cursor(cursor = FL_CURSOR_DEFAULT); if (!Fl::has_timeout(hide_cursor, this)) Fl::add_timeout(1, hide_cursor, this); wantcursor = true; cursorpos = xpos; makeMarker(); break; case FL_DRAG: case FL_PUSH: killMacroTimer(); switch (eb = Fl::event_button()) { case FL_RIGHT_MOUSE: wantcursor = false; if (event == FL_PUSH) { tmp_carrier = true; oldcarrier = carrier(); if (progdefaults.WaterfallHistoryDefault) bHistory = true; } goto lrclick; case FL_LEFT_MOUSE: if ((Fl::event_state() & (FL_ALT | FL_CTRL)) == (FL_ALT | FL_CTRL)) { if (notch_frequency) notch_off(); else notch_on(cursorFreq(xpos)); return 1; } if (event == FL_PUSH) { push = ypos; pxpos = xpos; if (Fl::event_clicks()) return 1; } if (progdefaults.WaterfallQSY && push < WFTEXT + WFSCALE) { long long newrfc = (pxpos - xpos) * step; if (!USB()) newrfc = -newrfc; newrfc += rfcarrier(); qsy(newrfc, active_modem ? active_modem->get_freq() : 1500); pxpos = xpos; return 1; } lrclick: if (Fl::event_state() & FL_CTRL) { if (event == FL_DRAG) break; if (!progdefaults.WaterfallHistoryDefault) bHistory = true; if (eb == FL_LEFT_MOUSE) { restoreFocus(); break; } } if (progdefaults.WaterfallHistoryDefault) bHistory = true; newcarrier = cursorFreq(xpos); if (active_modem) { newcarrier = (int)CLAMP( newcarrier, progdefaults.LowFreqCutoff + active_modem->get_bandwidth() / 2, progdefaults.HighFreqCutoff - active_modem->get_bandwidth() / 2); active_modem->set_freq(newcarrier); viewer_paste_freq(newcarrier); if (!(Fl::event_state() & FL_SHIFT)) active_modem->set_sigsearch(SIGSEARCH); } restoreFocus(); break; case FL_MIDDLE_MOUSE: if (event == FL_DRAG) break; btnAFC->value(!btnAFC->value()); btnAFC->do_callback(); } break; case FL_RELEASE: switch (eb = Fl::event_button()) { case FL_RIGHT_MOUSE: tmp_carrier = false; if (active_modem) active_modem->set_freq(oldcarrier); restoreFocus(); // fall through case FL_LEFT_MOUSE: push = 0; oldcarrier = newcarrier; if (eb != FL_LEFT_MOUSE || !ReceiveText->visible()) break; if (eb == FL_LEFT_MOUSE) recenter_spectrum_viewer(); if (!(Fl::event_state() & (FL_CTRL | FL_META | FL_ALT | FL_SHIFT))) { if (Fl::event_clicks() == 1) note_qrg(true, "\n", "\n"); else if (progdefaults.WaterfallClickInsert) wf->insert_text(true); } else if (Fl::event_state() & (FL_META | FL_ALT)) find_signal_text(); break; } break; case FL_MOUSEWHEEL: { killMacroTimer(); int d; if ( !((d = Fl::event_dy()) || (d = Fl::event_dx())) ) break; int state = Fl::event_state(); if (state & FL_CTRL) wf->handle_mouse_wheel(waterfall::WF_AFC_BW, d); else if (state & (FL_META | FL_ALT)) wf->handle_mouse_wheel(waterfall::WF_SIGNAL_SEARCH, d); else if (state & FL_SHIFT) wf->handle_mouse_wheel(waterfall::WF_SQUELCH, d); else { if (progdefaults.WaterfallQSY && Fl::event_inside(x(), y(), w(), WFTEXT+WFSCALE+WFMARKER)) qsy(wf->rfcarrier() - 500*d); else wf->handle_mouse_wheel(progdefaults.WaterfallWheelAction, d); } return handle(FL_MOVE); } case FL_SHORTCUT: if (Fl::event_inside(this)) take_focus(); break; case FL_KEYBOARD: { killMacroTimer(); int d = (Fl::event_state() & FL_CTRL) ? 10 : 1; int k = Fl::event_key(); switch (k) { case FL_Left: case FL_Right: if (k == FL_Left) d = -d; if (active_modem) { oldcarrier = newcarrier = (int)CLAMP( carrier() + d, progdefaults.LowFreqCutoff + active_modem->get_bandwidth() / 2, progdefaults.HighFreqCutoff - active_modem->get_bandwidth() / 2); active_modem->set_freq(newcarrier); } break; case FL_Tab: restoreFocus(); break; default: restoreFocus(); return TransmitText->handle(event); } break; } case FL_KEYUP: { if (Fl::event_inside(this)) { int k = Fl::event_key(); if (k == FL_Shift_L || k == FL_Shift_R || k == FL_Control_L || k == FL_Control_R || k == FL_Meta_L || k == FL_Meta_R || k == FL_Alt_L || k == FL_Alt_R) restoreFocus(); } break; } case FL_LEAVE: Fl::remove_timeout(hide_cursor, this); if (cursor != FL_CURSOR_DEFAULT) window()->cursor(cursor = FL_CURSOR_DEFAULT); wantcursor = false; makeMarker(); break; } return 1; } void waterfall::handle_mouse_wheel(int what, int d) { if (d == 0) return; Fl_Valuator *val = 0; const char* msg_fmt = 0, *msg_label = 0; switch (what) { case WF_NOP: return; case WF_AFC_BW: { if (active_modem) { trx_mode m = active_modem->get_mode(); if (m >= MODE_PSK_FIRST && m <= MODE_PSK_LAST) { val = mailserver ? cntServerOffset : cntSearchRange; msg_label = "Srch Rng"; } else if (m >= MODE_HELL_FIRST && m <= MODE_HELL_LAST) { val = sldrHellBW; msg_label = "BW"; } else if (m == MODE_CW) { val = sldrCWbandwidth; msg_label = "BW"; } else return; msg_fmt = "%s: %2.0f Hz"; } break; } case WF_SIGNAL_SEARCH: if (d > 0) { if (active_modem) active_modem->searchDown(); } else { if (active_modem) active_modem->searchUp(); } return; case WF_SQUELCH: val = sldrSquelch; d = -d; msg_fmt = "%s = %2.0f %%"; msg_label = "Squelch"; break; case WF_CARRIER: val = wfcarrier; break; case WF_MODEM: init_modem(d > 0 ? MODE_NEXT : MODE_PREV); return; case WF_SCROLL: (d > 0 ? right : left)->do_callback(); return; } val->value(val->clamp(val->increment(val->value(), -d))); bool changed_save = progdefaults.changed; val->do_callback(); progdefaults.changed = changed_save; if (val == cntServerOffset || val == cntSearchRange) { if (active_modem) active_modem->set_sigsearch(SIGSEARCH); } else if (val == sldrSquelch) { // sldrSquelch gives focus to TransmitText take_focus(); } if (msg_fmt) { char msg[60]; snprintf(msg, sizeof(msg), msg_fmt, msg_label, val->value()); put_status(msg, 2.0); } } const char* waterfall::wf_wheel_action[] = { _("None"), _("AFC range or BW"), _("Signal search"), _("Squelch level"), _("Modem carrier"), _("Modem"), _("Scroll") };
67,491
C++
.cxx
2,243
27.028087
122
0.630956
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,258
raster.cxx
w1hkj_fldigi/src/waterfall/raster.cxx
// ---------------------------------------------------------------------------- // raster.cxx, Raster scan Widget for display of fuzzy modes // // Copyright (C) 2006-2007 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <iostream> #include <FL/Fl.H> #include <FL/fl_draw.H> #include "raster.h" #include "modem.h" #include <cmath> #include <cstring> #include "raster.h" #include "qrunner.h" #include "threads.h" static pthread_mutex_t raster_mutex = PTHREAD_MUTEX_INITIALIZER; bool active = false; Raster::Raster (int X, int Y, int W, int H, int rh, bool rv) : Fl_Widget (X, Y, W, H) { width = W - 4; height = H - 4; space = 1; rowheight = 2 * rh; rhs = rowheight + space; Nrows = 0; while ((Nrows * rhs) < height) Nrows++; Nrows--; vidbuf = new unsigned char[width * height]; _reverse = rv; if (_reverse) memset(vidbuf, 0, width * height); else memset(vidbuf, 255, width * height); col = 0; box(FL_DOWN_BOX); marquee = false; } Raster::~Raster() { delete [] vidbuf; } int Raster::change_rowheight( int rh ) { guard_lock raster_lock(&raster_mutex); while ( (2*rh+space) > height) rh--; rowheight = 2 * rh; rhs = rowheight + space; Nrows = 0; while ((Nrows * rhs) < height) Nrows++; Nrows--; if (_reverse) memset(vidbuf, 0, width * height); else memset(vidbuf, 255, width * height); col = 0; REQ_DROP(&Raster::redraw, this); return rh; } void Raster::data(int data[], int len) { guard_lock raster_lock(&raster_mutex); if (data == NULL || len == 0 || (len > rowheight)) { return; } if (marquee) { for (int row = 0; row < Nrows; row++) { int rowstart = width * rhs * row; int nextrow = width * rhs * (row + 1); for (int i = 0; i < len; i++) { memmove(vidbuf + rowstart + i*width, vidbuf + rowstart + i*width + 1, width - 1); if (row < (Nrows - 1)) { vidbuf[rowstart + i*width + width - 1] = vidbuf[nextrow + i* width]; } } } int toppixel = width * (Nrows - 1) * rhs + width - 1; for (int i = 0; i < len; i++) { vidbuf[toppixel + width * (len - i)] = (unsigned char) data[i]; } } else { int pos = 0; int zeropos = (Nrows - 1) * rhs * width; for (int i = 0; i < len; i++) { pos = zeropos + width * (len - i - 1) + col; vidbuf[pos] = (unsigned char)data[i]; } if (++col >= width) { unsigned char *from = vidbuf + rhs * width; int numtocopy = (Nrows -1) * rhs * width; memmove(vidbuf, from, numtocopy); if (_reverse) memset(vidbuf + zeropos, 0, rhs * width); else memset(vidbuf + zeropos, 255, rhs * width); col = 0; } } REQ_DROP(&Raster::redraw, this); } void Raster::clear() { guard_lock raster_lock(&raster_mutex); if (_reverse) memset(vidbuf, 0, width * height); else memset(vidbuf, 255, width * height); col = 0; REQ_DROP(&Raster::redraw, this); } void Raster::resize(int x, int y, int w, int h) { guard_lock raster_lock(&raster_mutex); if (w < 14) w = 14; if (h < (4 + rhs)) h = 4 + rhs; int Wdest = w - 4; int Hdest = h - 4; int Ndest = 0; while ((Ndest * rhs) < Hdest) Ndest++; Ndest--; unsigned char *tempbuf = new unsigned char [Wdest * Hdest]; unsigned char *oldbuf = vidbuf; if (_reverse) memset(tempbuf, 0, Wdest * Hdest); else memset(tempbuf, 255, Wdest * Hdest); int Ato = Wdest * Hdest; int Afm = width * height; if (Ato >= Afm) { } else { } int xfrcols, xfrrows; int from, to; if (Wdest >= width) xfrcols = width; else xfrcols = Wdest; if (Ndest <= Nrows) { xfrrows = Ndest * rhs; from = (Nrows - Ndest) * rhs; to = 0; for (int r = 0; r < xfrrows; r++) for (int c = 0; c < xfrcols; c++) tempbuf[(to + r) * Wdest + c] = vidbuf[(from + r) * width + c]; } else { xfrrows = Nrows * rhs; from = 0; to = (Ndest - Nrows) * rhs; for (int r = 0; r < xfrrows; r++) for (int c = 0; c < xfrcols; c++) tempbuf[(to + r) * Wdest + c] = vidbuf[(from + r) * width + c]; } width = Wdest; height = Hdest; Nrows = Ndest; vidbuf = tempbuf; delete [] oldbuf; Fl_Widget::resize(x,y,w,h); redraw(); } void Raster::draw() { draw_box(); fl_draw_image_mono( vidbuf, x() + 2, y() + 2, width, height, 1); } int Raster::handle(int event) { if (Fl::event_inside( this )) { if (event == FL_PUSH) { if (Fl::event_button() == FL_RIGHT_MOUSE) { clear(); return 1; } } } return Fl_Widget::handle(event); }
5,133
C++
.cxx
199
23.261307
79
0.609327
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,259
digiscope.cxx
w1hkj_fldigi/src/waterfall/digiscope.cxx
// ---------------------------------------------------------------------------- // digiscope.cxx, Miniature Oscilloscope/Phasescope Widget // // Copyright (C) 2006-2009 // Dave Freese, W1HKJ // Copyright (C) 2008 // Stelios Bounanos, M0GLD // // This file is part of fldigi. Adapted from code contained in gmfsk source code // distribution. // gmfsk Copyright (C) 2001, 2002, 2003 // Tomi Manninen (oh2bns@sral.fi) // Copyright (C) 2004 // Lawrence Glaister (ve7it@shaw.ca) // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <iostream> #include <cmath> #include <cstring> #include <FL/Fl.H> #include <FL/fl_draw.H> #include "digiscope.h" #include "modem.h" #include "trx.h" #include "fl_digi.h" #include "qrunner.h" Digiscope::Digiscope (int X, int Y, int W, int H, const char *label) : Fl_Widget (X, Y, W, H, label) { _phase = _quality = _flo = _fhi = _amp = 0.0; box(FL_DOWN_BOX); vidbuf = new unsigned char[ 3 * (W-4) * (H-4)]; vidline = new unsigned char[ 3 * (W-4)]; memset(vidbuf, 0, 3*(W-4)*(H-4) * sizeof(unsigned char)); memset(vidline, 0, 3 * (W-4) * sizeof(unsigned char)); _highlight = false; _len = MAX_LEN; _zptr = 0; for (int i = 0; i < NUM_GRIDS; i++) _x[i] = _y[i] = 0; _y_user1 = _y_user2 = -1; _x_user1 = _x_user2 = -1; _x_graticule = _y_graticule = false; phase_mode = PHASE1; } Digiscope::~Digiscope() { if (vidbuf) delete [] vidbuf; if (vidline) delete [] vidline; } void Digiscope::video(double *data, int len , bool dir) { if (active_modem->HistoryON()) return; if (data == NULL || len == 0) return; int W = w() - 4; int H = h() - 4; for (int i = 0; i < W; i++) vidline[3*i] = vidline[3*i+1] = vidline[3*i+2] = (unsigned char)(data[i * len / W]); vidline[3*W/2] = 255; vidline[3*W/2+1] = 0; vidline[3*W/2+2] = 0; if (dir) { if (linecnt == H) { linecnt--; unsigned char *p = &vidbuf[3*W]; memmove (vidbuf, p, 3*(W * (H-1))*sizeof(unsigned char)); memcpy (&vidbuf[3*W*(H-1)], vidline, 3*W * sizeof (unsigned char)); } else memcpy (&vidbuf[3*W*linecnt], vidline, 3*W * sizeof(unsigned char)); linecnt++; } else { unsigned char *p = &vidbuf[3*W]; memmove (p, vidbuf, 3 * (W * (H-1)) * sizeof(unsigned char)); memcpy(vidbuf, vidline, 3 * W * sizeof(unsigned char)); } REQ_DROP(&Digiscope::redraw, this); } void Digiscope::zdata(cmplx *zarray, int len ) { if (active_modem->HistoryON()) return; if (zarray == NULL || len == 0) return; for (int i = 0; i < len; i++) { _zdata[_zptr++] = zarray[i]; if (_zptr == MAX_ZLEN) _zptr = 0; } REQ_DROP(&Digiscope::redraw, this); } void Digiscope::data(double *data, int len, bool scale) { if (active_modem->HistoryON()) return; if (data == 0) { memset(_buf, 0, MAX_LEN * sizeof(*_buf)); REQ_DROP(&Digiscope::redraw, this); return; } if (len == 0) return; if (len > MAX_LEN) _len = MAX_LEN; else _len = len; memcpy(_buf, data, len * sizeof(double)); if (scale) { double max = 1E-6; double min = 1E6; for (int i = 0; i < _len; i++) { max = MAX(max, _buf[i]); min = MIN(min, _buf[i]); } if (max == min) max *= 1.001; for (int i = 0; i < _len; i++) _buf[i] = (_buf[i] - min) / (max - min); } REQ_DROP(&Digiscope::redraw, this); } void Digiscope::phase(double ph, double ql, bool hl) { if (active_modem->HistoryON()) return; _phase = ph; _quality = ql; _highlight = hl; REQ_DROP(&Digiscope::redraw, this); } void Digiscope::rtty(double flo, double fhi, double amp) { if (active_modem->HistoryON()) return; _flo = flo; _fhi = fhi; _amp = amp; REQ_DROP(&Digiscope::redraw, this); } void Digiscope::mode(scope_mode md) { if (md == PHASE) { if (phase_mode >= PHASE1 && phase_mode <= PHASE3) md = phase_mode; else md = phase_mode = PHASE1; } int W = w() - 4; int H = h() - 4; _mode = md; memset(_buf, 0, MAX_LEN * sizeof(double)); linecnt = 0; memset(vidbuf, 0, 3*W*H * sizeof(unsigned char)); memset(vidline, 0, 3 * W * sizeof(unsigned char)); vidline[3*W/2] = 255; vidline[3*W/2+1] = 0; vidline[3*W/2+2] = 0; for (int i = 0; i < H; i++) memcpy(&vidbuf[3*W*i], vidline, 3*W*sizeof(unsigned char) ); REQ_DROP(&Digiscope::redraw, this); } void Digiscope::draw_phase() { // max number of shown vectors is first dimension static double pvecstack[8][2]; static const size_t psz = sizeof(pvecstack)/sizeof(*pvecstack); static unsigned pszn = 0; fl_clip(x()+2,y()+2,w()-4,h()-4); fl_color(FL_BLACK); fl_rectf(x()+2,y()+2,w()-4,h()-4); fl_push_matrix(); fl_translate(x() + w() / 2.0, y() + w() / 2.0); fl_scale( 0.9*w()/2, -0.9*w()/2); fl_color(FL_WHITE); fl_circle( 0.0, 0.0, 1.0); fl_begin_line(); fl_vertex(-1.0, 0.0); fl_vertex(-0.9, 0.0); fl_end_line(); fl_begin_line(); fl_vertex(1.0, 0.0); fl_vertex(0.9, 0.0); fl_end_line(); fl_begin_line(); fl_vertex(0.0, -1.0); fl_vertex(0.0, -0.9); fl_end_line(); fl_begin_line(); fl_vertex(0.0, 1.0); fl_vertex(0.0, 0.9); fl_end_line(); if (_highlight) { if (_mode > PHASE1) { if (pszn == psz - 1) memmove(pvecstack, pvecstack + 1, (psz - 1) * sizeof(*pvecstack)); else pszn++; pvecstack[pszn][0] = _phase; pvecstack[pszn][1] = _quality; // draw the stack in progressively brighter green for (unsigned i = 0; i <= pszn; i++) { // fl_color(fl_color_average(FL_GREEN, FL_BLACK, 1.0 - 0.8 * (n-i)/ pszn)); fl_color(fl_color_average(FL_GREEN, FL_BLACK, 0.2 + 0.8 * i / pszn)); fl_begin_line(); fl_vertex(0.0, 0.0); if (_mode == PHASE3) // scale length by quality fl_vertex(0.9 * cos(pvecstack[i][0] - M_PI / 2) * pvecstack[i][1], 0.9 * sin(pvecstack[i][0] - M_PI / 2) * pvecstack[i][1]); else fl_vertex(0.9 * cos(pvecstack[i][0] - M_PI / 2), 0.9 * sin(pvecstack[i][0] - M_PI / 2)); fl_end_line(); } } else { // original style fl_color(FL_GREEN); fl_begin_line(); fl_vertex(0.0, 0.0); fl_vertex(0.9 * cos(_phase - M_PI / 2), 0.9 * sin( _phase - M_PI / 2)); fl_end_line(); } } else { fl_color(FL_GREEN); fl_circle( 0.0, 0.0, 0.1); } fl_pop_matrix(); fl_pop_clip(); } void Digiscope::draw_scope() { int npts, np; fl_clip(x()+2,y()+2,w()-4,h()-4); fl_color(FL_BLACK); fl_rectf(x()+2,y()+2,w()-4,h()-4); fl_push_matrix(); npts = MIN(w(), _len); npts = MAX(1, npts); fl_translate(x()+2, y() + h() - 2); fl_scale ((w()-4), - (h() - 4)); fl_color(FL_GREEN); fl_begin_line(); for (int i = 0; i < npts; i++) { np = i * _len / npts; np = np < MAX_LEN ? np : MAX_LEN - 1; fl_vertex( (double)i / npts, _buf[np] ); } fl_end_line(); // x & y axis' for (int i = 0; i < NUM_GRIDS; i++) { if (_x[i]) { fl_color(FL_WHITE); fl_begin_line(); fl_vertex(_x[i], 0.0); fl_vertex(_x[i], 1.0); fl_end_line(); } if (_y[i]) { fl_color(FL_WHITE); fl_begin_line(); fl_vertex(0.0, _y[i]); fl_vertex(1.0, _y[i]); fl_end_line(); } } if (_x_graticule) { if (_y_user1 > 0 && _y_user1 < 1.0) { fl_color(FL_CYAN); fl_begin_line(); fl_vertex(0.0, 1.0 - _y_user1); fl_vertex(1.0, 1.0 - _y_user1); fl_end_line(); } if (_y_user2 > 0 && _y_user2 < 1.0) { fl_color(FL_MAGENTA); fl_begin_line(); fl_vertex(0.0, 1.0 - _y_user2); fl_vertex(1.0, 1.0 - _y_user2); fl_end_line(); } } if (_y_graticule) { if (_x_user1 > 0 && _x_user1 < 1.0) { fl_color(FL_CYAN); fl_begin_line(); fl_vertex(_x_user1, 0.0); fl_vertex(_x_user1, 1.0); fl_end_line(); } if (_x_user2 > 0 && _x_user2 < 1.0) { fl_color(FL_MAGENTA); fl_begin_line(); fl_vertex(_x_user2, 0.0); fl_vertex(_x_user2, 1.0); fl_end_line(); } } fl_pop_matrix(); fl_pop_clip(); } void Digiscope::draw_xy() { fl_clip(x()+2,y()+2,w()-4,h()-4); fl_color(FL_BLACK); fl_rectf(x()+2,y()+2,w()-4,h()-4); fl_push_matrix(); fl_translate(x() + w() / 2.0, y() + w() / 2.0); fl_scale( w()/2.0, -w()/2.0); // x & y axis fl_color(FL_LIGHT1); fl_begin_line(); fl_vertex(-0.6, 0.0); fl_vertex(-1.0, 0.0); fl_end_line(); fl_begin_line(); fl_vertex(0.6, 0.0); fl_vertex(1.0, 0.0); fl_end_line(); fl_begin_line(); fl_vertex(0.0, -0.6); fl_vertex(0.0, -1.0); fl_end_line(); fl_begin_line(); fl_vertex(0.0, 0.6); fl_vertex(0.0, 1.0); fl_end_line(); // data int W = w() / 2; int H = h() / 2; int X = x(); int Y = y(); int xp, yp, xp1, yp1; int j = _zptr; if (++j == MAX_ZLEN) j = 0; xp = X + (int)((_zdata[j].real() + 1.0) * W); yp = Y + (int)((_zdata[j].imag() + 1.0) * H); fl_color(fl_rgb_color(0, 230,0)); for (int i = 0; i < MAX_ZLEN; i++ ) { if (++j == MAX_ZLEN) j = 0; xp1 = X + (int)((_zdata[j].real() + 1.0) * W); yp1 = Y + (int)((_zdata[j].imag() + 1.0) * H); fl_line(xp, yp, xp1, yp1); xp = xp1; yp = yp1; } fl_pop_matrix(); fl_pop_clip(); } void Digiscope::draw_rtty() { int npts, np; fl_clip(x()+2,y()+2,w()-4,h()-4); fl_color(FL_BLACK); fl_rectf(x()+2,y()+2,w()-4,h()-4); fl_push_matrix(); npts = MIN(w(), _len); npts = MAX(1, npts); fl_translate(x()+2, y() + h() - 2); fl_scale ((w()-4), - (h() - 4)); fl_color(FL_YELLOW); fl_begin_line(); fl_vertex( 0.0, 0.9); fl_vertex( 1.0, 0.9); fl_end_line(); fl_begin_line(); fl_vertex( 0.0, 0.1); fl_vertex( 1.0, 0.1); fl_end_line(); fl_color(FL_WHITE); fl_begin_line(); fl_vertex( 0.0, 0.5); fl_vertex( 1.0, 0.5); fl_end_line(); fl_color(FL_GREEN); fl_begin_line(); double value = 0.0; for (int i = 0; i < npts; i++) { np = round(1.0 * i * _len / npts); if (np >= MAX_LEN) np = MAX_LEN - 1; value = _buf[np]; fl_vertex( 1.0 * i / (npts - 1), 0.5 + 0.75 * value ); } fl_end_line(); fl_pop_matrix(); fl_pop_clip(); } void Digiscope::draw_video() { fl_draw_image( vidbuf, x() + 2, y() + 2, w() - 4, h() - 4); } void Digiscope::draw() { draw_box(); if (_mode == WWV || _mode == DOMWF) draw_video(); else { switch (_mode) { case SCOPE : draw_scope(); break; case PHASE1: case PHASE2: case PHASE3: draw_phase(); break; case RTTY : draw_rtty(); break; case XHAIRS : draw_xy(); break; case DOMDATA : draw_scope(); break; case BLANK : default: fl_clip(x()+2,y()+2,w()-4,h()-4); fl_color(FL_BLACK); fl_rectf(x()+2,y()+2,w()-4,h()-4); fl_push_matrix(); fl_pop_matrix(); fl_pop_clip(); break; } } } int Digiscope::handle(int event) { if (!Fl::event_inside(this)) return 0; switch (event) { case FL_RELEASE: switch (_mode) { case PHASE1: case PHASE2: _mode = (scope_mode)((int)_mode + 1); phase_mode = _mode; redraw(); break; case PHASE3: _mode = PHASE1; phase_mode = _mode; redraw(); break; case RTTY: _mode = XHAIRS; redraw(); break; case XHAIRS: _mode = RTTY; redraw(); break; case DOMDATA: _mode = DOMWF; redraw(); break; case DOMWF: _mode = DOMDATA; redraw(); break; case WWV: event = Fl::event_button(); if (event == FL_LEFT_MOUSE) wwv_modem->set1(Fl::event_x() - x(), w()); else if (event == FL_RIGHT_MOUSE) wwv_modem->set2(Fl::event_x() - x(), Fl::event_y() - y()); break; default: break; } return 1; case FL_MOUSEWHEEL: if ((event = Fl::event_dy()) || (event = Fl::event_dx())) wf->handle_mouse_wheel(waterfall::WF_AFC_BW, event); break; default: break; } return 1; } void Digiscope::resize(int x, int y, int w, int h) { delete [] vidbuf; delete [] vidline; vidbuf = new unsigned char[ 3 * (w-4) * (h-4)]; vidline = new unsigned char[ 3 * (w-4)]; memset(vidbuf, 0, 3*(w-4)*(h-4) * sizeof(unsigned char)); memset(vidline, 0, 3*(w-4) * sizeof(unsigned char)); Fl_Widget::resize(x, y, w, h); }
12,350
C++
.cxx
486
22.668724
95
0.576653
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,260
colorbox.cxx
w1hkj_fldigi/src/waterfall/colorbox.cxx
// ---------------------------------------------------------------------------- // colorbox.cxx // // Copyright (C) 2007-2008 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <string> #include <FL/Fl_Color_Chooser.H> #include "gettext.h" #include "colorbox.h" #include "waterfall.h" #include "confdialog.h" #include "main.h" #include "fl_digi.h" #include "fileselect.h" #include "debug.h" void colorbox::draw() { int ypos = y() + 2; int xpos; int ht = h() - 4; int wd = w() - 4; draw_box(); for(int i = 0; i < wd; i++){ xpos = x() + 2 + i; int xc = i * 256 / wd; fl_rectf (xpos, ypos, 1, ht, mag2RGBI[xc].R, mag2RGBI[xc].G, mag2RGBI[xc].B); } } void setColorButtons() { for (int i = 0; i < 9; i++) { btnColor[i]->color( fl_rgb_color( palette[i].R, palette[i].G, palette[i].B ) ); btnColor[i]->redraw(); } } void selectColor(int n) { uchar r, g, b; r = palette[n].R; g = palette[n].G; b = palette[n].B; fl_color_chooser("Spectrum", r, g, b); palette[n].R = r; palette[n].G = g; palette[n].B = b; btnColor[n]->color( fl_rgb_color( palette[n].R, palette[n].G, palette[n].B ) ); btnColor[n]->redraw(); wf->setcolors(); WF_Palette->redraw(); } static std::string palfilename = ""; static std::string palLabelStr; void loadPalette() { int r,g,b; FILE *clrfile = NULL; if (palfilename.size() == 0) { palfilename = PalettesDir; palfilename.append ("fldigi.pal"); } const char *p = FSEL::select(_("Open palette"), _("Fldigi palette\t*.pal"), palfilename.c_str()); if (!p) return; if (!*p) return; if ((clrfile = fl_fopen(p, "r")) != NULL) { for (int i = 0; i < 9; i++) { if (fscanf(clrfile, "%d;%d;%d\n", &r, &g, &b) == EOF) { if (ferror(clrfile)) LOG_PERROR("fscanf"); else LOG_ERROR("unexpected EOF"); fclose(clrfile); return; } palette[i].R = r; palette[i].G = g; palette[i].B = b; } fclose(clrfile); wf->setcolors(); setColorButtons(); palfilename = p; palLabelStr = p; size_t pos = palLabelStr.find_last_of('/'); if (pos != std::string::npos) palLabelStr.erase(0, pos+1); palLabelStr = _("Palette: ") + palLabelStr; WF_Palette->label(palLabelStr.c_str()); WF_Palette->redraw(); progdefaults.PaletteName = palLabelStr; } } void savePalette() { FILE *clrfile = NULL; if (palfilename.size() == 0) { palfilename = PalettesDir; palfilename.append ("fldigi.pal"); } const char *p = FSEL::saveas(_("Save palette"), _("Fldigi palette\t*.pal"), palfilename.c_str()); if (!p) return; if ((clrfile = fl_fopen(p, "w")) != NULL) { for (int i = 0; i < 9; i++) { fprintf(clrfile, "%3d;%3d;%3d\n", palette[i].R, palette[i].G, palette[i].B ); } fclose(clrfile); palfilename = p; palLabelStr = p; size_t pos = palLabelStr.find_last_of('/'); if (pos != std::string::npos) palLabelStr.erase(0, pos+1); palLabelStr = _("Palette: ") + palLabelStr; WF_Palette->label(palLabelStr.c_str()); WF_Palette->redraw(); progdefaults.PaletteName = palLabelStr; } }
3,751
C++
.cxx
130
26.515385
101
0.620948
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,261
psm.cxx
w1hkj_fldigi/src/psm/psm.cxx
// ---------------------------------------------------------------------------- // psm/psm.cxx // // Support for Signal Montoring, CSMA, Transmit Inhibit (Busy Detection) // When enabled effects all transmission types, Keybord, ARQ, and KISS. // // Copyright (c) 2016 // Robert Stiles, KK5VD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include "config.h" #ifdef __MINGW32__ # include "compat.h" #endif #include <fstream> #include <sstream> #include <string> #include <cstdlib> #include <ctime> #include <errno.h> #include <float.h> #include <cstring> #include <sys/types.h> #include <sys/time.h> #if !defined(__WOE32__) && !defined(__APPLE__) # include <sys/ipc.h> # include <sys/msg.h> #endif #include <signal.h> #include <FL/Fl.H> #include <FL/fl_ask.H> #include <FL/Fl_Check_Button.H> #include "main.h" #include "fl_digi.h" #include "trx.h" #include "globals.h" #include "threads.h" #include "socket.h" #include "debug.h" #include "qrunner.h" #include "data_io.h" #include "configuration.h" #include "status.h" #include "confdialog.h" #include "psm/psm.h" #include "gettext.h" #include "timeops.h" #include "kiss_io.h" #include "xmlrpc.h" #include "arq_io.h" #define HISTO_COUNT 256 static int HISTO_THRESH_HOLD = 48; // In seconds #define HISTO_RESET_TIME 180 #define HISTO_RESET_TX_TIME_INHIBIT 3 #define DISABLE_TX_INHIBIT_DURATION 5 #define EST_STATE_CHANGE_MS 25 static int histogram[HISTO_COUNT]; //static bool init_hist_flag = true; static double threshold = 5.0; static int kpsql_pl = 0; static double kpsql_threshold = 0.0; time_t inhibit_tx_seconds = 0; // Used to scale the sensitivity of PSM // Values range from 1/(largest int value) to 1/1 #define FGD_DEFAULT 2 static double fractional_gain = (1.0 / (1.0 * FGD_DEFAULT)); static pthread_t psm_pthread; static pthread_cond_t psm_cond; static pthread_mutex_t psm_mutex; bool psm_thread_running = false; static bool psm_terminate_flag = false; static bool psm_thread_exit_flag = false; static bool request_transmit_flag = false; // A list of timers static double timer_tramit_buffer_timeout = 0; static double timer_slot_time = 0; static double timer_inhibit_tx_seconds = 0; static double timer_histrogram_reset_timer = 0; static double timer_temp_disable_tx_inhibit = 0; static double timer_sql_timer = 0; static pthread_mutex_t external_access_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t millisleep_mutex = PTHREAD_MUTEX_INITIALIZER; static void update_sql_display(void); static double detect_signal(int freq, int bw, double *low, double *high); static void flush_tx_buffer(void); static void process_psm(void); static void * psm_loop(void *args); static inline double current_double_time(void); static void psm_millisleep(int delay_time); bool csma_idling = 0; /********************************************************************************** * Use a local version of MilliSleep() **********************************************************************************/ static void psm_millisleep(int delay_time) { guard_lock _lock(&millisleep_mutex); size_t seconds = 0; size_t nano_seconds = 0; struct timespec timeout = {0}; double to_time = current_double_time(); to_time += (delay_time * 0.001); seconds = (size_t) to_time; nano_seconds = (size_t) ((to_time - seconds) * 1000000000.0); timeout.tv_sec = seconds; timeout.tv_nsec = nano_seconds; pthread_cond_timedwait(&psm_cond, &millisleep_mutex, &timeout); } /********************************************************************************** * Reset Histogram **********************************************************************************/ void psm_reset_histogram(void) { guard_lock _lock(&external_access_mutex); memset(histogram, 0, sizeof(histogram)); histogram[3] = 1; timer_inhibit_tx_seconds = current_double_time() + HISTO_RESET_TX_TIME_INHIBIT; } /********************************************************************************** * **********************************************************************************/ void update_kpsql_fractional_gain(int value) { guard_lock _lock(&external_access_mutex); if(value > 1) { progdefaults.kpsql_attenuation = value; fractional_gain = 1.0 / ((double) value); } else { progdefaults.kpsql_attenuation = FGD_DEFAULT; fractional_gain = 1.0 / ( 1.0 * FGD_DEFAULT); } } /********************************************************************************** * **********************************************************************************/ static void update_sql_display(void) { static int prev_power_level = 0; static double convert_scale = (1.0 / ((double)HISTO_COUNT)); if(progdefaults.show_psm_btn && progStatus.kpsql_enabled) { double high_limit = 0; double low_limit = 0; if(kpsql_pl != prev_power_level) { prev_power_level = kpsql_pl; high_limit = sldrSquelch->maximum(); low_limit = sldrSquelch->minimum(); if(kpsql_pl > HISTO_COUNT) { REQ(callback_set_metric, low_limit); } else { double diff = high_limit - low_limit; double scaled_value = kpsql_pl * convert_scale; double convert_value = scaled_value * diff; double results = high_limit - convert_value; REQ(callback_set_metric, results); } } } } /********************************************************************************** * To deal with the AGC from radios we create a ratio between * the high and low signal levels. **********************************************************************************/ static double detect_signal(int freq, int bw, double *low, double *high) { int freq_step = 10; int freq_pos = 0; int start_freq = freq - (bw >> 1); int end_freq = freq + (bw >> 1); int freq_half_step = freq_step >> 1; int i = 0; double low_value = FLT_MAX; double high_value = FLT_MIN; double ratio = 0.0; double pd = 0; double ratio_avg = 0.0; static double pratio0 = 0.0; static double pratio1 = 0.0; static double pratio2 = 0.0; static double pratio3 = 0.0; if(trx_state != STATE_RX) return ratio_avg; for(i = 0; start_freq <= end_freq; start_freq += freq_step, i++) { freq_pos = start_freq + freq_half_step; pd = wf->powerDensity((double) freq_pos, (double) freq_step); if(pd < low_value) low_value = pd; if(pd > high_value) high_value = pd; } if(low) *low = low_value; if(high) *high = high_value; ratio = high_value/low_value; ratio *= fractional_gain; kpsql_pl = ratio_avg = (ratio + pratio0 + pratio1 + pratio2 + pratio3) * 0.20; if((ratio_avg > 0.0) && (ratio_avg <= (double) HISTO_COUNT)) { i = (int) ratio_avg; i &= 0xFF; histogram[i]++; if(histogram[i] > HISTO_THRESH_HOLD) { for(i = 0; i < HISTO_COUNT; i++) { histogram[i] >>= 1; } return 0.0; } } pratio3 = pratio2; pratio2 = pratio1; pratio1 = pratio0; pratio0 = ratio; return ratio; } /********************************************************************************** * Clear all transmit buffers (ARQ/KISS/XMLRPC) **********************************************************************************/ static void flush_tx_buffer(void) { if(kiss_text_available) { flush_kiss_tx_buffer(); kiss_text_available = false; } if(arq_text_available) { flush_arq_tx_buffer(); arq_text_available = false; } if(xmltest_char_available) { reset_xmlchars(); xmltest_char_available = false; } } /********************************************************************************** * Set state for PSM transmit. **********************************************************************************/ void psm_transmit(void) { guard_lock extern_lock(&external_access_mutex); request_transmit_flag = true; } /********************************************************************************** * Clear state for PSM transmit. **********************************************************************************/ void psm_transmit_ended(int flag) { guard_lock extern_lock(&external_access_mutex); if(flag == PSM_ABORT) { flush_tx_buffer(); abort_tx(); } request_transmit_flag = false; REQ(set_xmtrcv_selection_color_transmitting); } /********************************************************************************** * Convert timespec difference to absolute double. **********************************************************************************/ #if 0 static double timespec_difference(timespec * ts_a, timespec * ts_b) { if(!ts_a) return 0.0; if(!ts_b) return 0.0; double a = ts_a->tv_sec + (ts_a->tv_nsec * 0.000000001); double b = ts_b->tv_sec + (ts_b->tv_nsec * 0.000000001); if(a > b) return (a - b); return (b - a); } #endif // 0 /********************************************************************************** * Convert timespec to double. **********************************************************************************/ static inline double current_double_time(void) { struct timespec current_timespec_time = {0}; clock_gettime(CLOCK_REALTIME, &current_timespec_time); double a = current_timespec_time.tv_sec + (current_timespec_time.tv_nsec * 0.000000001); return a; } /********************************************************************************** * PSM processing. Sync's with Waterfall Display Update **********************************************************************************/ static void process_psm(void) { if (!progdefaults.show_psm_btn) return; if (!progStatus.kpsql_enabled) return; guard_lock psm_lock(&psm_mutex); bool detected_signal = false; bool transmit_authorized = true; double busyChannelSeconds = 0; double current_time = 0; double level = 0.0; double random_number = 0; int bw = active_modem->get_bandwidth(); int bw_margin = progStatus.psm_minimum_bandwidth_margin; int freq = active_modem->get_txfreq(); static bool histrogram_reset_timer = true; static bool signal_recorded_flag = false; static double signal_hit_time = 0; static int delay_time = 0; current_time = current_double_time(); level = detect_signal(freq, bw + bw_margin, 0, 0); if(!progStatus.enableBusyChannel) { timer_inhibit_tx_seconds = temp_disable_tx_inhibit = 0; } // Enabled on valid packet reception. Currently only available // to checksum verified protocols (HDLC). if(temp_disable_tx_inhibit) { timer_temp_disable_tx_inhibit = current_time + DISABLE_TX_INHIBIT_DURATION; temp_disable_tx_inhibit = 0; } random_number = (rand() & 0xFF) * 0.00390625; // Reduce value to 0 - 1.0 if(current_time < timer_temp_disable_tx_inhibit) { busyChannelSeconds = 0.25 + (random_number * 0.75); // 0.25 - 1.0 Seconds } else { busyChannelSeconds = (double) progStatus.busyChannelSeconds + random_number; } if(timer_tramit_buffer_timeout == 0.0) { timer_tramit_buffer_timeout = current_time + (progStatus.psm_flush_buffer_timeout * 60); // Minutes to Seconds } // If busy for an extended time flush transmit buffer(s). if(progStatus.psm_flush_buffer_timeout) { // If set to zero no buffer flushing allowed. if(current_time > timer_tramit_buffer_timeout) { timer_tramit_buffer_timeout = current_time + (progStatus.psm_flush_buffer_timeout * 60); flush_tx_buffer(); return; } } if(histrogram_reset_timer) { timer_histrogram_reset_timer = current_time + HISTO_RESET_TIME; histrogram_reset_timer = false; } if(current_time > timer_histrogram_reset_timer) { psm_reset_histogram(); timer_histrogram_reset_timer = current_time + HISTO_RESET_TIME; timer_inhibit_tx_seconds = current_time + 2.0; // Time to rebuild the histogram table. return; } // Histogram keeps the threshold 'x' number of units above the noise level. if(progStatus.psm_use_histogram) { int idx = 0; int first_value = 0; int offset = progStatus.psm_histogram_offset_threshold; int index = 0; if(offset > HISTO_COUNT) offset = HISTO_COUNT; for(index = 0; index < HISTO_COUNT; index++) { if(histogram[index]) { if(idx == 0) { first_value = index; } if(idx >= offset) { threshold = (double) index; break; } idx++; } } if(index > HISTO_COUNT) { threshold = (double) (first_value + offset); } } else { threshold = (int) (progStatus.sldrPwrSquelchValue * 2.56); // Histogram scaled. } kpsql_threshold = threshold; if(level < threshold) { detected_signal = false; signal_recorded_flag = false; } else { detected_signal = true; if(!signal_recorded_flag) { signal_hit_time = current_double_time(); signal_recorded_flag = true; } } if(progStatus.enableBusyChannel && detected_signal) { double signal_hit_time_test = (progStatus.psm_hit_time_window * 0.001); // Milliseconds to seconds. double signal_hit_time_diff = (current_time - signal_hit_time); if(signal_hit_time_diff >= signal_hit_time_test) { timer_inhibit_tx_seconds = current_time + busyChannelSeconds; } } if(current_time < timer_inhibit_tx_seconds) { inhibit_tx_seconds = true; } else { inhibit_tx_seconds = false; } // Limit the number of times update_sql_display() is called per second. if(current_time > timer_sql_timer) { update_sql_display(); timer_sql_timer = current_time + 0.06; // Eyeball tested value. } if(inhibit_tx_seconds || !request_transmit_flag || detected_signal || (current_time < timer_slot_time)) return; delay_time = 0; if(progStatus.csma_enabled) { int rn_persistance = rand() & 0xFF; if(rn_persistance > progStatus.csma_persistance) { double _slot_time = ((progdefaults.csma_slot_time * 10) * 0.001); timer_slot_time = current_time + _slot_time; transmit_authorized = false; } if(progStatus.csma_transmit_delay > 0) { csma_idling = true; delay_time = progStatus.csma_transmit_delay * 10; } } if(transmit_authorized && (trx_state == STATE_RX)) { REQ(set_xmtrcv_selection_color_transmitting); trx_transmit_psm(); active_modem->set_stopflag(false); // Transmit idle time plus START_RX to STATE_TX state change // delay. if(delay_time > 0) { psm_millisleep(delay_time + EST_STATE_CHANGE_MS); delay_time = 0; csma_idling = false; } else { psm_millisleep(EST_STATE_CHANGE_MS); } timer_tramit_buffer_timeout = current_time + (progStatus.psm_flush_buffer_timeout * 60); timer_slot_time = current_time + ((progdefaults.csma_slot_time * 10) * 0.001); timer_slot_time += (((rand() & 0xFF) * 0.00390625) * 0.20); } } /********************************************************************************** * PSM processing loop. Sync's with Waterfall Display Update **********************************************************************************/ static void * psm_loop(void *args) { SET_THREAD_ID(PSM_TID); psm_thread_running = true; psm_terminate_flag = false; psm_thread_exit_flag = false; while(1) { pthread_mutex_lock(&psm_mutex); pthread_cond_wait(&psm_cond, &psm_mutex); pthread_mutex_unlock(&psm_mutex); if (psm_terminate_flag) break; if(trx_state == STATE_RX) { process_psm(); } } psm_thread_exit_flag = true; return (void *)0; } /********************************************************************************** * Start PSM Thread **********************************************************************************/ void start_psm_thread(void) { guard_lock extern_lock(&external_access_mutex); csma_idling = false; if(psm_thread_running) return; memset((void *) &psm_pthread, 0, sizeof(psm_pthread)); memset((void *) &psm_cond, 0, sizeof(psm_cond)); memset((void *) &psm_mutex, 0, sizeof(psm_mutex)); if(pthread_cond_init(&psm_cond, NULL)) { LOG_ERROR("PSM thread create fail (pthread_cond_init)"); return; } if(pthread_mutex_init(&psm_mutex, NULL)) { LOG_ERROR("PSM thread create fail (pthread_mutex_init)"); pthread_cond_destroy(&psm_cond); return; } memset((void *) &psm_pthread, 0, sizeof(psm_pthread)); if(!psm_thread_running) { if (pthread_create(&psm_pthread, NULL, psm_loop, NULL) < 0) { pthread_cond_destroy(&psm_cond); pthread_mutex_destroy(&psm_mutex); LOG_ERROR("PSM thread create fail (pthread_create)"); } } MilliSleep(10); // Give the CPU time to set 'psm_thread_running' } /********************************************************************************** * Stop PSM Thread **********************************************************************************/ void stop_psm_thread(void) { guard_lock extern_lock(&external_access_mutex); if(!psm_thread_running) return; psm_terminate_flag = true; pthread_cond_signal(&psm_cond); MilliSleep(10); if(psm_thread_exit_flag) { pthread_join(psm_pthread, NULL); LOG_INFO("%s", "psm thread - join"); } else { CANCEL_THREAD(psm_pthread); LOG_INFO("%s", "psm thread - cancel"); } pthread_cond_destroy(&psm_cond); pthread_mutex_destroy(&psm_mutex); memset((void *) &psm_pthread, 0, sizeof(psm_pthread)); memset((void *) &psm_cond, 0, sizeof(psm_cond)); memset((void *) &psm_mutex, 0, sizeof(psm_mutex)); psm_thread_running = false; psm_terminate_flag = false; psm_thread_exit_flag = false; csma_idling = false; } /********************************************************************************** * Signal PSM to process Waterfall power level information. **********************************************************************************/ void signal_psm(void) { if(psm_thread_running) { pthread_cond_signal(&psm_cond); } }
18,106
C++
.cxx
520
32.507692
112
0.599725
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,263
mfsk.cxx
w1hkj_fldigi/src/mfsk/mfsk.cxx
// ---------------------------------------------------------------------------- // mfsk.cxx -- mfsk modem // // Copyright (C) 2006-2009 // Dave Freese, W1HKJ // // This file is part of fldigi. Adapted from code contained in gmfsk source code // distribution. // gmfsk Copyright (C) 2001, 2002, 2003 // Tomi Manninen (oh2bns@sral.fi) // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include <cstdlib> #include <cstring> #include <libgen.h> #include <FL/Fl.H> #include "mfsk.h" #include "modem.h" #include "misc.h" #include "main.h" #include "fl_digi.h" #include "configuration.h" #include "status.h" #include "trx.h" #include "ascii.h" #include "fileselect.h" #include "qrunner.h" #include "debug.h" #define SOFTPROFILE false // MFSKpic receive start delay value based on a viterbi length of 45 // 44 nulls at 8 samples per pixel // 88 nulls at 4 samples per pixel // 176 nulls at 2 samples per pixel struct TRACEPAIR { int trace; int delay; TRACEPAIR( int a, int b) { trace = a; delay = b;} }; TRACEPAIR tracepair(45, 352); // enable to limit within band signal sidebands // not really needed static bool xmt_filter = false; //============================================================================= char mfskmsg[80]; //============================================================================= #include "mfsk-pic.cxx" void mfsk::tx_init() { txstate = TX_STATE_PREAMBLE; bitstate = 0; double factor = 1.5; double bw2 = factor*(numtones + 1) * samplerate / symlen / 2.0; double flo = (get_txfreq_woffset() - bw2);// / samplerate; if (flo <= 100) flo = 100; double fhi = (get_txfreq_woffset() + bw2);// / samplerate; if (fhi >= samplerate/2 - 100) fhi = samplerate/2 - 100; xmtfilt->init_bandpass (255, 1, flo/samplerate, fhi/samplerate); videoText(); } void mfsk::rx_init() { rxstate = RX_STATE_DATA; synccounter = 0; symcounter = 0; met1 = 0.0; met2 = 0.0; counter = 0; RXspp = 8; for (int i = 0; i < 2 * symlen; i++) { for (int j = 0; j < 32; j++) pipe[i].vector[j] = cmplx(0,0); } reset_afc(); s2n = 0.0; memset(picheader, ' ', PICHEADER - 1); picheader[PICHEADER -1] = 0; put_MODEstatus(mode); syncfilter->reset(); staticburst = false; s2n_valid = false; } void mfsk::init() { modem::init(); rx_init(); set_scope_mode(Digiscope::SCOPE); // picture mode init setpicture_link(this); TXspp = txSPP; RXspp = 8; if (progdefaults.StartAtSweetSpot) set_freq(progdefaults.PSKsweetspot); else if (progStatus.carrier != 0) { set_freq(progStatus.carrier); #if !BENCHMARK_MODE progStatus.carrier = 0; #endif } else set_freq(wf->Carrier()); } void mfsk::shutdown() { } mfsk::~mfsk() { stopflag = true; int msecs = 200; while(--msecs && txstate != TX_STATE_PREAMBLE) MilliSleep(1); // do not destroy picTxWin or picRxWin as there may be pending updates // in the UI request queue if (picTxWin) picTxWin->hide(); activate_mfsk_image_item(false); if (bpfilt) delete bpfilt; if (xmtfilt) delete xmtfilt; if (rxinlv) delete rxinlv; if (txinlv) delete txinlv; if (dec2) delete dec2; if (dec1) delete dec1; if (enc) delete enc; if (pipe) delete [] pipe; if (hbfilt) delete hbfilt; if (binsfft) delete binsfft; for (int i = 0; i < SCOPESIZE; i++) { if (vidfilter[i]) delete vidfilter[i]; } if (syncfilter) delete syncfilter; } mfsk::mfsk(trx_mode mfsk_mode) : modem() { cap |= CAP_AFC | CAP_REV; double bw, cf, flo, fhi; mode = mfsk_mode; depth = 10; // CAP_IMG is set in cap iff image transfer supported switch (mode) { case MODE_MFSK4: samplerate = 8000; symlen = 2048; symbits = 5; depth = 5; basetone = 256; numtones = 32; preamble = 107; // original mfsk modes break; case MODE_MFSK8: samplerate = 8000; symlen = 1024; symbits = 5; depth = 5; basetone = 128; numtones = 32; preamble = 107; // original mfsk modes break; case MODE_MFSK31: samplerate = 8000; symlen = 256; symbits = 3; depth = 10; basetone = 32; numtones = 8; preamble = 107; // original mfsk modes break; case MODE_MFSK32: samplerate = 8000; symlen = 256; symbits = 4; depth = 10; basetone = 32; numtones = 16; preamble = 107; // original mfsk modes cap |= CAP_IMG; break; case MODE_MFSK64: samplerate = 8000; symlen = 128; symbits = 4; depth = 10; basetone = 16; numtones = 16; preamble = 180; cap |= CAP_IMG; break; case MODE_MFSK128: samplerate = 8000; symlen = 64; symbits = 4; depth = 20; basetone = 8; numtones = 16; cap |= CAP_IMG; preamble = 214; break; case MODE_MFSK64L: samplerate = 8000; symlen = 128; symbits = 4; depth = 400; preamble = 2500; basetone = 16; numtones = 16; break; case MODE_MFSK128L: samplerate = 8000; symlen = 64; symbits = 4; depth = 800; preamble = 5000; basetone = 8; numtones = 16; break; case MODE_MFSK11: samplerate = 11025; symlen = 1024; symbits = 4; depth = 10; basetone = 93; numtones = 16; preamble = 107; break; case MODE_MFSK22: samplerate = 11025; symlen = 512; symbits = 4; depth = 10; basetone = 46; numtones = 16; preamble = 107; break; case MODE_MFSK16: default: samplerate = 8000; symlen = 512; symbits = 4; depth = 10; basetone = 64; numtones = 16; preamble = 107; cap |= CAP_IMG; break; } tonespacing = (double) samplerate / symlen; basefreq = 1.0 * samplerate * basetone / symlen; binsfft = new sfft (symlen, basetone, basetone + numtones ); hbfilt = new C_FIR_filter(); hbfilt->init_hilbert(37, 1); syncfilter = new Cmovavg(8); for (int i = 0; i < SCOPESIZE; i++) vidfilter[i] = new Cmovavg(16); pipe = new rxpipe[ 2 * symlen ]; enc = new encoder (NASA_K, POLY1, POLY2); dec1 = new viterbi (NASA_K, POLY1, POLY2); dec2 = new viterbi (NASA_K, POLY1, POLY2); dec1->settraceback (tracepair.trace); dec2->settraceback (tracepair.trace); dec1->setchunksize (1); dec2->setchunksize (1); txinlv = new interleave (symbits, depth, INTERLEAVE_FWD); rxinlv = new interleave (symbits, depth, INTERLEAVE_REV); bw = (numtones - 1) * tonespacing; cf = basefreq + bw / 2.0; flo = (cf - bw/2 - 2 * tonespacing) / samplerate; fhi = (cf + bw/2 + 2 * tonespacing) / samplerate; bpfilt = new C_FIR_filter(); bpfilt->init_bandpass (127, 1, flo, fhi); xmtfilt = new C_FIR_filter(); scopedata.alloc(symlen * 2); fragmentsize = symlen; bandwidth = (numtones - 1) * tonespacing; startpic = false; abortxmt = false; stopflag = false; bitshreg = 0; bitstate = 0; phaseacc = 0; pipeptr = 0; metric = 0; prev1symbol = prev2symbol = 0; symbolpair[0] = symbolpair[1] = 0; // picTxWin and picRxWin are created once to support all instances of mfsk if (!picTxWin) createTxViewer(); if (!picRxWin) createRxViewer(); activate_mfsk_image_item(true); afcmetric = 0.0; datashreg = 1; for (int i = 0; i < 128; i++) prepost[i] = 0; } //===================================================================== // receive processing //===================================================================== void mfsk::s2nreport(void) { modem::s2nreport(); s2n_valid = false; } bool mfsk::check_picture_header(char c) { char *p; if (c >= ' ' && c <= 'z') { memmove(picheader, picheader + 1, PICHEADER - 1); picheader[PICHEADER - 2] = c; } picW = 0; picH = 0; color = false; p = strstr(picheader, "Pic:"); if (p == NULL) return false; p += 4; if (*p == 0) return false; while ( *p && isdigit(*p)) picW = (picW * 10) + (*p++ - '0'); if (*p++ != 'x') return false; while ( *p && isdigit(*p)) picH = (picH * 10) + (*p++ - '0'); if (*p == 'C') { color = true; p++; } if (*p == ';') { if (picW == 0 || picH == 0 || picW > 4095 || picH > 4095) return false; RXspp = 8; return true; } if (*p == 'p') p++; else return false; if (!*p) return false; RXspp = 8; if (*p == '4') RXspp = 4; if (*p == '2') RXspp = 2; p++; if (!*p) return false; if (*p != ';') return false; if (picW == 0 || picH == 0 || picW > 4095 || picH > 4095) return false; return true; } void mfsk::recvpic(cmplx z) { int byte; picf += arg( conj(prevz) * z) * samplerate / TWOPI; prevz = z; if ((counter % RXspp) == 0) { picf = 256 * (picf / RXspp - basefreq) / bandwidth; byte = (int)CLAMP(picf, 0.0, 255.0); if (reverse) byte = 255 - byte; if (color) { pixelnbr = rgb + row + 3*col; REQ(updateRxPic, byte, pixelnbr); if (++col == picW) { col = 0; if (++rgb == 3) { rgb = 0; row += 3 * picW; } } } else { for (int i = 0; i < 3; i++) REQ(updateRxPic, byte, pixelnbr++); } picf = 0.0; int n = picW * picH * 3; if (pixelnbr % (picW * 3) == 0) { snprintf(mfskmsg, sizeof(mfskmsg), "Rx pic: %3.1f%%", (100.0f * pixelnbr) / n); put_status(mfskmsg); } } } void mfsk::recvchar(int c) { if (c == -1 || c == 0) return; put_rx_char(c); if (check_picture_header(c) == true) { counter = tracepair.delay; switch (mode) { case MODE_MFSK16: if (symbolbit == symbits) counter += symlen; break; case MODE_MFSK32: if (symbolbit == symbits) counter += symlen; break; case MODE_MFSK64: counter = 4956; if (symbolbit % 2 == 0) counter += symlen; break; case MODE_MFSK128: counter = 1824; if (symbolbit % 2 == 0) counter += symlen; break; case MODE_MFSK31: counter = 5216; if (symbolbit == symbits) counter += symlen; break; case MODE_MFSK4: case MODE_MFSK8: case MODE_MFSK11: case MODE_MFSK22: default: break; }; rxstate = RX_STATE_PICTURE_START; picturesize = RXspp * picW * picH * (color ? 3 : 1); pixelnbr = 0; col = 0; row = 0; rgb = 0; memset(picheader, ' ', PICHEADER - 1); picheader[PICHEADER -1] = 0; return; } else counter = 0; if (progdefaults.Pskmails2nreport && (mailserver || mailclient)) { if ((c == SOH) && !s2n_valid) { // starts collecting s2n from first SOH in stream (since start of RX) s2n_valid = true; s2n_sum = s2n_sum2 = s2n_ncount = 0.0; } if (s2n_valid) { s2n_sum += s2n_metric; s2n_sum2 += (s2n_metric * s2n_metric); s2n_ncount++; if (c == EOT) s2nreport(); } } return; } void mfsk::recvbit(int bit) { int c; datashreg = (datashreg << 1) | !!bit; if ((datashreg & 7) == 1) { c = varidec(datashreg >> 1); recvchar(c); datashreg = 1; } } void mfsk::decodesymbol(unsigned char symbol) { int c, met; symbolpair[0] = symbolpair[1]; symbolpair[1] = symbol; symcounter = symcounter ? 0 : 1; // only modes with odd number of symbits need a vote if (symbits == 5 || symbits == 3) { // could use symbits % 2 == 0 if (symcounter) { if ((c = dec1->decode(symbolpair, &met)) == -1) return; met1 = decayavg(met1, met, 50);//32); if (met1 < met2) return; metric = met1; } else { if ((c = dec2->decode(symbolpair, &met)) == -1) return; met2 = decayavg(met2, met, 50);//32); if (met2 < met1) return; metric = met2; } } else { if (symcounter) return; if ((c = dec2->decode(symbolpair, &met)) == -1) return; met2 = decayavg(met2, met, 50);//32); metric = met2; } if (progdefaults.Pskmails2nreport && (mailserver || mailclient)) { // s2n reporting: re-calibrate s2n_metric = metric * 4.5 - 42; s2n_metric = CLAMP(s2n_metric, 0.0, 100.0); } // Re-scale the metric and update main window metric -= 60.0; metric *= 0.5; metric = CLAMP(metric, 0.0, 100.0); display_metric(metric); if (progStatus.sqlonoff && metric < progStatus.sldrSquelchValue) return; recvbit(c); } void mfsk::softdecode(cmplx *bins) { double binmag, sum=0, avg=0, b[symbits]; unsigned char symbols[symbits]; int i, j, k, CWIsymbol; static int CWIcounter[MAX_SYMBOLS] = {0}; static const int CWI_MAXCOUNT=6; // this is the maximum number of repeated tones which is valid for the modem ( 0 excluded ) for (i = 0; i < symbits; i++) b[i] = 0.0; // Calculate the average signal, ignoring CWI tones for (i = 0; i < numtones; i++) { if ( CWIcounter[i] < CWI_MAXCOUNT ) sum += abs(bins[i]); } avg = sum / numtones; // avoid divide by zero later if ( sum < 1e-10 ) sum = 1e-10; // dynamic CWI avoidance: use harddecode() result (currsymbol) for CWI detection if (reverse) CWIsymbol = (numtones - 1) - currsymbol; else CWIsymbol = currsymbol; // Add or subtract the CWI counters based on harddecode result // avoiding tone #0 by starting at 1 for (i = 1; i < numtones ; i++) { if (reverse) k = (numtones - 1) - i; else k = i; if ( k == CWIsymbol) CWIcounter[k]++; else CWIcounter[k]--; // bounds-check the counts to keep the values sane if (CWIcounter[k] < 0) CWIcounter[k] = 0; if (CWIcounter[k] > CWI_MAXCOUNT) CWIcounter[k] = CWI_MAXCOUNT + 1; } // Grey decode and form soft decision samples for (i = 0; i < numtones; i++) { j = graydecode(i); if (reverse) k = (numtones - 1) - i; else k = i; // Avoid CWI. This never affects tone #0 if ( CWIcounter[k] > CWI_MAXCOUNT ) { binmag = avg; // soft-puncture to the average signal-level } else if ( CWIsymbol == k ) binmag = 2.0f * abs(bins[k]); // give harddecode() a vote in softdecode's decision. else binmag = abs(bins[k]); for (k = 0; k < symbits; k++) b[k] += (j & (1 << (symbits - k - 1))) ? binmag : -binmag; } #if SOFTPROFILE LOG_INFO("harddecode() symbol = %d", CWIsymbol ); #endif // shift to range 0...255 for (i = 0; i < symbits; i++) { unsigned char softbits; if (staticburst) softbits = 128; // puncturing else softbits = (unsigned char)clamp(128.0 + (b[i] / (sum) * 256.0), 0, 255); symbols[i] = softbits; #if SOFTPROFILE LOG_INFO("softbits = %3u", softbits); #endif } rxinlv->symbols(symbols); for (i = 0; i < symbits; i++) { symbolbit = i + 1; decodesymbol(symbols[i]); if (counter) return; } } cmplx mfsk::mixer(cmplx in, double f) { cmplx z; // Basetone is a nominal 1000 Hz f -= tonespacing * basetone + bandwidth / 2; z = in * cmplx( cos(phaseacc), sin(phaseacc) ); phaseacc -= TWOPI * f / samplerate; if (phaseacc < 0) phaseacc += TWOPI; return z; } // finds the tone bin with the largest signal level // assumes that will be the present tone received // with NO CW inteference int mfsk::harddecode(cmplx *in) { double x, max = 0.0, avg = 0.0; int i, symbol = 0; int burstcount = 0; for (int i = 0; i < numtones; i++) avg += abs(in[i]); avg /= numtones; if (avg < 1e-20) avg = 1e-20; for (i = 0; i < numtones; i++) { x = abs(in[i]); if ( x > max) { max = x; symbol = i; } if (x > 2.0 * avg) burstcount++; } staticburst = (burstcount == numtones); if (!staticburst) afcmetric = 0.95*afcmetric + 0.05 * (2 * max / avg); else afcmetric = 0.0; return symbol; } void mfsk::update_syncscope() { int j; int pipelen = 2 * symlen; memset(scopedata, 0, 2 * symlen * sizeof(double)); if (!progStatus.sqlonoff || metric >= progStatus.sldrSquelchValue) for (unsigned int i = 0; i < SCOPESIZE; i++) { j = (pipeptr + i * pipelen / SCOPESIZE + 1) % (pipelen); scopedata[i] = vidfilter[i]->run(abs(pipe[j].vector[prev1symbol])); } set_scope(scopedata, SCOPESIZE); scopedata.next(); // change buffers snprintf(mfskmsg, sizeof(mfskmsg), "s/n %3.0f dB", 20.0 * log10(s2n)); put_Status1(mfskmsg); } void mfsk::synchronize() { int i, j; double syn = -1; double val, max = 0.0; if (currsymbol == prev1symbol) return; if (prev1symbol == prev2symbol) return; j = pipeptr; for (i = 0; i < 2 * symlen; i++) { val = abs(pipe[j].vector[prev1symbol]); if (val > max) { max = val; syn = i; } j = (j + 1) % (2 * symlen); } syn = syncfilter->run(syn); synccounter += (int) floor((syn - symlen) / numtones + 0.5); update_syncscope(); } void mfsk::reset_afc() { freqerr = 0.0; syncfilter->reset(); return; } void mfsk::afc() { cmplx z; cmplx prevvector; double f, f1; double ts = tonespacing / 4; if (sigsearch) { reset_afc(); sigsearch = 0; } if (staticburst || !progStatus.afconoff) return; if (metric < progStatus.sldrSquelchValue) return; if (afcmetric < 3.0) return; if (currsymbol != prev1symbol) return; if (pipeptr == 0) prevvector = pipe[2*symlen - 1].vector[currsymbol]; else prevvector = pipe[pipeptr - 1].vector[currsymbol]; z = conj(prevvector) * currvector; f = arg(z) * samplerate / TWOPI; f1 = tonespacing * (basetone + currsymbol); if ( fabs(f1 - f) < ts) { freqerr = decayavg(freqerr, (f1 - f), 32); set_freq(frequency - freqerr); } } void mfsk::eval_s2n() { sig = abs(pipe[pipeptr].vector[currsymbol]); noise = (numtones -1) * abs(pipe[pipeptr].vector[prev2symbol]); if (noise > 0) s2n = decayavg ( s2n, sig / noise, 64 ); } int mfsk::rx_process(const double *buf, int len) { cmplx z; cmplx* bins = 0; while (len-- > 0) { // create analytic signal... z = cmplx( *buf, *buf ); buf++; hbfilt->run ( z, z ); // shift in frequency to the base freq z = mixer(z, frequency); // bandpass filter around the shifted center frequency // with required bandwidth bpfilt->run ( z, z ); // copy current vector to the pipe binsfft->run (z, pipe[pipeptr].vector, 1); bins = pipe[pipeptr].vector; if (rxstate == RX_STATE_PICTURE_START) { if (--counter == 0) { counter = picturesize; rxstate = RX_STATE_PICTURE; REQ( showRxViewer, picW, picH ); } } if (rxstate == RX_STATE_PICTURE) { if (--counter == 0) { rxstate = RX_STATE_DATA; put_status(""); std::string autosave_dir = PicsDir; picRx->save_png(autosave_dir.c_str()); rx_init(); } else recvpic(z); continue; } // copy current vector to the pipe // binsfft->run (z, pipe[pipeptr].vector, 1); // bins = pipe[pipeptr].vector; if (--synccounter <= 0) { synccounter = symlen; currsymbol = harddecode(bins); currvector = bins[currsymbol]; softdecode(bins); // symbol sync synchronize(); // frequency tracking afc(); eval_s2n(); prev2symbol = prev1symbol; prev2vector = prev1vector; prev1symbol = currsymbol; prev1vector = currvector; } pipeptr = (pipeptr + 1) % (2 * symlen); } return 0; } //===================================================================== // transmit processing //===================================================================== void mfsk::transmit(double *buf, int len) { if (xmt_filter) for (int i = 0; i < len; i++) xmtfilt->Irun(buf[i], buf[i]); ModulateXmtr(buf, len); } void mfsk::sendsymbol(int sym) { double f, phaseincr; f = get_txfreq_woffset() - bandwidth / 2; sym = grayencode(sym & (numtones - 1)); if (reverse) sym = (numtones - 1) - sym; phaseincr = TWOPI * (f + sym*tonespacing) / samplerate; for (int i = 0; i < symlen; i++) { outbuf[i] = cos(phaseacc); phaseacc -= phaseincr; if (phaseacc < 0) phaseacc += TWOPI; } transmit (outbuf, symlen); } void mfsk::sendbit(int bit) { int data = enc->encode(bit); for (int i = 0; i < 2; i++) { bitshreg = (bitshreg << 1) | ((data >> i) & 1); bitstate++; if (bitstate == symbits) { txinlv->bits(&bitshreg); sendsymbol(bitshreg); bitstate = 0; bitshreg = 0; } } } void mfsk::sendchar(unsigned char c) { const char *code = varienc(c); while (*code) sendbit(*code++ - '0'); put_echo_char(c); } void mfsk::sendidle() { sendchar(0); sendbit(1); // extended zero bit stream for (int i = 0; i < 32; i++) sendbit(0); } void mfsk::flushtx(int nbits) { // flush the varicode decoder at the other end sendbit(1); // flush the convolutional encoder and interleaver //VK2ETA high speed modes for (int i = 0; i < 107; i++) //W1HKJ for (int i = 0; i < preamble; i++) for (int i = 0; i < nbits; i++) sendbit(0); bitstate = 0; } void mfsk::sendpic(unsigned char *data, int len) { double *ptr; double f; int i, j; ptr = outbuf; for (i = 0; i < len; i++) { if (txstate == TX_STATE_PICTURE) REQ(updateTxPic, data[i]); if (reverse) f = get_txfreq_woffset() - bandwidth * (data[i] - 128) / 256.0; else f = get_txfreq_woffset() + bandwidth * (data[i] - 128) / 256.0; for (j = 0; j < TXspp; j++) { *ptr++ = cos(phaseacc); phaseacc += TWOPI * f / samplerate; if (phaseacc > TWOPI) phaseacc -= TWOPI; } } transmit (outbuf, TXspp * len); } // ----------------------------------------------------------------------------- // send prologue consisting of tracepair.delay 0's void mfsk::flush_xmt_filter(int n) { double f1 = get_txfreq_woffset() - bandwidth / 2.0; double f2 = get_txfreq_woffset() + bandwidth / 2.0; for (int i = 0; i < n; i++) { outbuf[i] = cos(phaseacc); phaseacc += TWOPI * (reverse ? f2 : f1) / samplerate; if (phaseacc > TWOPI) phaseacc -= TWOPI; } transmit (outbuf, tracepair.delay); } void mfsk::send_prologue() { flush_xmt_filter(tracepair.delay); } void mfsk::send_epilogue() { flush_xmt_filter(64); } static bool close_after_transmit = false; void mfsk::clearbits() { int data = enc->encode(0); for (int k = 0; k < preamble; k++) { for (int i = 0; i < 2; i++) { bitshreg = (bitshreg << 1) | ((data >> i) & 1); bitstate++; if (bitstate == symbits) { txinlv->bits(&bitshreg); bitstate = 0; bitshreg = 0; } } } } int mfsk::tx_process() { // filter test set to 1 #if 0 double *ptr; double f; char msg[100]; for (int i = 100; i < 3900; i++) { ptr = outbuf; f = 1.0 * i; snprintf(msg, sizeof(msg), "freq: %.0f", f); put_status(msg); for (int j = 0; j < 32; j++) { *ptr++ = cos(phaseacc); phaseacc += TWOPI * f / samplerate; if (phaseacc > TWOPI) phaseacc -= TWOPI; } transmit (outbuf, 32); } return -1; #endif int xmtbyte; switch (txstate) { case TX_STATE_PREAMBLE: clearbits(); sig_start = true; if (mode != MODE_MFSK64L && mode != MODE_MFSK128L ) for (int i = 0; i < preamble / 3; i++) sendbit(0); txstate = TX_STATE_START; break; case TX_STATE_START: sig_start = true; sendchar('\r'); sendchar(2); // STX sendchar('\r'); txstate = TX_STATE_DATA; break; case TX_STATE_DATA: xmtbyte = get_tx_char(); if(active_modem->XMLRPC_CPS_TEST) { if(startpic) startpic = false; if(xmtbyte == 0x05) { sendchar(0x04); // 0x4 has the same symbol count as 0x5 break; } } if (xmtbyte == 0x05 || startpic == true) { put_status("Tx pic: start"); int len = (int)strlen(picheader); for (int i = 0; i < len; i++) sendchar(picheader[i]); flushtx(preamble); startpic = false; txstate = TX_STATE_PICTURE_START; } else if ( xmtbyte == GET_TX_CHAR_ETX || stopflag) txstate = TX_STATE_FLUSH; else if (xmtbyte == GET_TX_CHAR_NODATA) sendidle(); else sendchar(xmtbyte); break; case TX_STATE_FLUSH: sendchar('\r'); sendchar(4); // EOT sig_stop = true; sendchar('\r'); flushtx(preamble); rxstate = RX_STATE_DATA; txstate = TX_STATE_PREAMBLE; stopflag = false; return -1; case TX_STATE_PICTURE_START: send_prologue(); txstate = TX_STATE_PICTURE; break; case TX_STATE_PICTURE: int i = 0; int blocklen = 128; stop_deadman(); while (i < xmtbytes) { if (stopflag || abortxmt) break; if (i + blocklen < xmtbytes) sendpic( &xmtpicbuff[i], blocklen); else sendpic( &xmtpicbuff[i], xmtbytes - i); if ( (100 * i / xmtbytes) % 2 == 0) { snprintf(mfskmsg, sizeof(mfskmsg), "Tx pic: %3.1f%%", (100.0f * i) / xmtbytes); put_status(mfskmsg); } i += blocklen; } flushtx(preamble); start_deadman(); REQ_FLUSH(GET_THREAD_ID()); txstate = TX_STATE_DATA; put_status("Tx pic: done"); btnpicTxSendAbort->hide(); btnpicTxSPP->show(); btnpicTxSendColor->show(); btnpicTxSendGrey->show(); btnpicTxLoad->show(); btnpicTxClose->show(); if (close_after_transmit) picTxWin->hide(); close_after_transmit = false; abortxmt = false; rxstate = RX_STATE_DATA; memset(picheader, ' ', PICHEADER - 1); picheader[PICHEADER -1] = 0; break; } return 0; } void mfsk::send_color_image(std::string s) { if (load_image(s.c_str())) { close_after_transmit = true; pic_TxSendColor(); } } void mfsk::send_Grey_image(std::string s) { if (load_image(s.c_str())) { close_after_transmit = true; pic_TxSendGrey(); } }
25,184
C++
.cxx
1,005
22.18806
125
0.619042
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,265
mfsk-pic.cxx
w1hkj_fldigi/src/mfsk/mfsk-pic.cxx
// ---------------------------------------------------------------------------- // mfsk-pic.cxx -- mfsk support functions // // Copyright (C) 2006-2008 // Dave Freese, W1HKJ // // This file is part of fldigi. Adapted from code contained in gmfsk source code // distribution. // gmfsk Copyright (C) 2001, 2002, 2003 // Tomi Manninen (oh2bns@sral.fi) // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include "gettext.h" Fl_Double_Window *picRxWin = (Fl_Double_Window *)0; picture *picRx = (picture *)0; Fl_Double_Window *picTxWin = (Fl_Double_Window *)0; picture *picTx = (picture *)0; picbox *picTxBox = 0; Fl_Button *btnpicTxSPP = (Fl_Button *)0; Fl_Button *btnpicTxSendColor = (Fl_Button *)0; Fl_Button *btnpicTxSendGrey = (Fl_Button *)0; Fl_Button *btnpicTxSendAbort = (Fl_Button *)0; Fl_Button *btnpicTxLoad = (Fl_Button *)0; Fl_Button *btnpicTxClose = (Fl_Button *)0; Fl_Shared_Image *TxImg = (Fl_Shared_Image *)0; unsigned char *xmtimg = (unsigned char *)0; unsigned char *xmtpicbuff = (unsigned char *)0; mfsk *serviceme = 0; int txSPP = 8; char txclr_tooltip[24]; char txgry_tooltip[24]; void updateRxPic(unsigned char data, int pos) { picRx->pixel(data, pos); } void createRxViewer() { picRxWin = new Fl_Double_Window(200, 140); picRxWin->xclass(PACKAGE_NAME); picRxWin->begin(); picRx = new picture(2, 2, 136, 104); picRxWin->end(); } void showRxViewer(int W, int H) { if (!picRxWin) createRxViewer(); int winW, winH; int picX, picY; winW = W < 136 ? 140 : W + 4; winH = H + 4; picX = (winW - W) / 2; picY = 2; picRxWin->size(winW, winH); picRx->resize(picX, picY, W, H); picRx->clear(); picRxWin->show(); } int load_image(const char *n) { if (serviceme != active_modem) { return 0; } int W, H, D; unsigned char *img_data; if (TxImg) { TxImg->release(); TxImg = 0; } TxImg = Fl_Shared_Image::get(n); if (!TxImg) return 0; if (TxImg->count() > 1) { TxImg->release(); TxImg = 0; return 0; } img_data = (unsigned char *)TxImg->data()[0]; W = TxImg->w(); H = TxImg->h(); D = TxImg->d(); if (xmtimg) delete [] xmtimg; xmtimg = new unsigned char [W * H * 3]; if (D == 3) memcpy(xmtimg, img_data, W*H*3); else if (D == 4) { int i, j, k; for (i = 0; i < W*H; i++) { j = i*3; k = i*4; xmtimg[j] = img_data[k]; xmtimg[j+1] = img_data[k+1]; xmtimg[j+2] = img_data[k+2]; } } else if (D == 1) { int i, j; for (i = 0; i < W*H; i++) { j = i * 3; xmtimg[j] = xmtimg[j+1] = xmtimg[j+2] = img_data[i]; } } else return 0; TxViewerResize(W, H); char* label = strdup(n); picTxWin->copy_label(basename(label)); free(label); picTxBox->label(0); // load the picture widget with the rgb image picTx->show(); picTx->clear(); picTxWin->redraw(); picTx->video(xmtimg, W * H * 3); if (print_time_left( (W * H * 3) * 0.000125 * serviceme->TXspp, txclr_tooltip, sizeof(txclr_tooltip), _("Time needed: ")) > 0) btnpicTxSendColor->tooltip(txclr_tooltip); btnpicTxSendColor->activate(); if (print_time_left( (W * H) * 0.000125 * serviceme->TXspp, txgry_tooltip, sizeof(txgry_tooltip), _("Time needed: ")) > 0) btnpicTxSendGrey->tooltip(txgry_tooltip); btnpicTxSendGrey->activate(); return 1; } void updateTxPic(unsigned char data) { if (serviceme != active_modem) return; if (serviceme->color) { serviceme->pixelnbr = serviceme->rgb + serviceme->row + 3*serviceme->col; picTx->pixel(data, serviceme->pixelnbr); if (++serviceme->col == TxImg->w()) { serviceme->col = 0; if (++serviceme->rgb == 3) { serviceme->rgb = 0; serviceme->row += 3 * TxImg->w(); } } } else { picTx->pixel( data, serviceme->pixelnbr++ ); picTx->pixel( data, serviceme->pixelnbr++ ); picTx->pixel( data, serviceme->pixelnbr++ ); } } void cb_picTxLoad(Fl_Widget *, void *) { const char *fn = FSEL::select(_("Load image file"), "Portable Network Graphics\t*.png\n" "Independent JPEG Group\t*.{jpg,jif,jpeg,jpe}\n" "Graphics Interchange Format\t*.gif", PicsDir.c_str()); if (!fn) return; if (!*fn) return; load_image(fn); } void cb_picTxClose( Fl_Widget *w, void *) { picTxWin->hide(); } void pic_TxSendColor() { int W, H, rowstart; W = TxImg->w(); H = TxImg->h(); if (xmtpicbuff) delete [] xmtpicbuff; xmtpicbuff = new unsigned char [W*H*3]; unsigned char *outbuf = xmtpicbuff; unsigned char *inbuf = xmtimg; int iy, ix, rgb; for (iy = 0; iy < H; iy++) { rowstart = iy * W * 3; for (rgb = 0; rgb < 3; rgb++) for (ix = 0; ix < W; ix++) outbuf[rowstart + rgb*W + ix] = inbuf[rowstart + rgb + ix*3]; } if (serviceme->TXspp == 8) snprintf(serviceme->picheader, PICHEADER, "\nSending Pic:%dx%dC;", W, H); else snprintf(serviceme->picheader, PICHEADER, "\nSending Pic:%dx%dCp%d;", W, H,serviceme->TXspp); serviceme->xmtbytes = W * H * 3; serviceme->color = true; serviceme->rgb = 0; serviceme->col = 0; serviceme->row = 0; serviceme->pixelnbr = 0; btnpicTxSPP->hide(); btnpicTxSendColor->hide(); btnpicTxSendGrey->hide(); btnpicTxLoad->hide(); btnpicTxClose->hide(); btnpicTxSendAbort->show(); picTx->clear(); if (!picTxWin->visible()) picTxWin->show(); // start the transmission start_tx(); serviceme->startpic = true; } void cb_picTxSendColor( Fl_Widget *w, void *) { if (serviceme != active_modem) return; pic_TxSendColor(); } void pic_TxSendGrey() { int W, H; W = TxImg->w(); H = TxImg->h(); if (xmtpicbuff) delete [] xmtpicbuff; xmtpicbuff = new unsigned char [W*H]; unsigned char *outbuf = xmtpicbuff; unsigned char *inbuf = xmtimg; for (int i = 0; i < W*H; i++) outbuf[i] = ( 31 * inbuf[i*3] + 61 * inbuf[i*3 + 1] + 8 * inbuf[i*3 + 2])/100; if (serviceme->TXspp == 8) snprintf(serviceme->picheader, PICHEADER, "\nSending Pic:%dx%d;", W, H); else snprintf(serviceme->picheader, PICHEADER, "\nSending Pic:%dx%dp%d;", W, H,serviceme->TXspp); serviceme->xmtbytes = W * H; serviceme->color = false; serviceme->col = 0; serviceme->row = 0; serviceme->pixelnbr = 0; btnpicTxSPP->hide(); btnpicTxSendColor->hide(); btnpicTxSendGrey->hide(); btnpicTxLoad->hide(); btnpicTxClose->hide(); btnpicTxSendAbort->show(); picTx->clear(); // start the transmission if (!picTxWin->visible()) picTxWin->show(); start_tx(); serviceme->startpic = true; } void cb_picTxSendGrey( Fl_Widget *w, void *) { if (serviceme != active_modem) return; pic_TxSendGrey(); } void cb_picTxSendAbort( Fl_Widget *w, void *) { if (serviceme != active_modem) return; serviceme->abortxmt = true; // reload the picture widget with the rgb image picTx->video(xmtimg, TxImg->w() * TxImg->h() * 3); } void cb_picTxSPP( Fl_Widget *w, void *) { if (serviceme != active_modem) return; Fl_Button *b = (Fl_Button *)w; if (serviceme->TXspp == 8) serviceme->TXspp = 4; else if (serviceme->TXspp == 4) serviceme->TXspp = 2; else serviceme->TXspp = 8; if (serviceme->TXspp == 8) b->label("X1"); else if (serviceme->TXspp == 4) b->label("X2"); else b->label("X4"); b->redraw_label(); txSPP = serviceme->TXspp; if (TxImg == 0) return; if (TxImg->w() > 0 && TxImg->h() > 0) { if (print_time_left( (TxImg->w() * TxImg->h() * 3) * 0.000125 * serviceme->TXspp, txclr_tooltip, sizeof(txclr_tooltip), _("Time needed: ")) > 0) btnpicTxSendColor->tooltip(txclr_tooltip); if (print_time_left( (TxImg->w() * TxImg->h()) * 0.000125 * serviceme->TXspp, txgry_tooltip, sizeof(txgry_tooltip), _("Time needed: ")) > 0) btnpicTxSendGrey->tooltip(txgry_tooltip); } } void createTxViewer() { picTxWin = new Fl_Double_Window(290, 180, _("Send image")); picTxWin->xclass(PACKAGE_NAME); picTxWin->begin(); picTx = new picture (2, 2, 286, 150); picTx->hide(); picTxBox = new picbox(picTxWin->x(), picTxWin->y(), picTxWin->w(), picTxWin->h(), _("Load or drop an image file\nSupported types: PNG, JPEG, BMP")); picTxBox->labelfont(FL_HELVETICA_ITALIC); btnpicTxSPP = new Fl_Button(5, 180 - 26, 40, 24, "X1"); btnpicTxSPP->tooltip(_("Transfer speed, X1-normal")); btnpicTxSPP->callback( cb_picTxSPP, 0); btnpicTxSendColor = new Fl_Button(45, 180 - 26, 60, 24, "XmtClr"); btnpicTxSendColor->callback(cb_picTxSendColor, 0); btnpicTxSendGrey = new Fl_Button(105, 180 - 26, 60, 24, "XmtGry"); btnpicTxSendGrey->callback( cb_picTxSendGrey, 0); btnpicTxSendAbort = new Fl_Button(84, 180 - 26, 122, 24, "Abort Xmt"); btnpicTxSendAbort->callback(cb_picTxSendAbort, 0); btnpicTxLoad = new Fl_Button(165, 180 - 26, 60, 24, _("Load")); btnpicTxLoad->callback(cb_picTxLoad, 0); btnpicTxClose = new Fl_Button(225, 180 - 26, 60, 24, _("Close")); btnpicTxClose->callback(cb_picTxClose, 0); btnpicTxSendAbort->hide(); btnpicTxSendColor->deactivate(); btnpicTxSendGrey->deactivate(); picTxWin->end(); } void TxViewerResize(int W, int H) { int winW, winH; int picX, picY; winW = W < 286 ? 290 : W + 4; winH = H < 180 ? 210 : H + 30; picX = (winW - W) / 2; picY = (winH - 26 - H) / 2; picTxWin->size(winW, winH); picTx->resize(picX, picY, W, H); picTx->clear(); picTxBox->size(winW, winH); btnpicTxSPP->resize(winW/2 - 140, winH - 26, 40, 24); btnpicTxSendColor->resize(winW/2 - 100, winH - 26, 60, 24); btnpicTxSendGrey->resize(winW/2 - 40, winH - 26, 60, 24); btnpicTxSendAbort->resize(winW/2 - 61, winH - 26, 122, 24); btnpicTxLoad->resize(winW/2 + 20, winH - 26, 60, 24); btnpicTxClose->resize(winW/2 + 80, winH - 26, 60, 24); } void showTxViewer(int W, int H) { if (picTxWin) { picTxWin->show(); return; } int winW, winH; int picX, picY; winW = W < 288 ? 290 : W + 4; winH = H < 180 ? 180 : H + 30; picX = (winW - W) / 2; picY = (winH - 26 - H) / 2; picTxWin->size(winW, winH); picTx->resize(picX, picY, W, H); btnpicTxSPP->resize(winW/2 - 140, winH - 26, 40, 24); btnpicTxSendColor->resize(winW/2 - 100, winH - 26, 60, 24); btnpicTxSendGrey->resize(winW/2 - 40, winH - 26, 60, 24); btnpicTxSendAbort->resize(winW/2 - 61, winH - 26, 122, 24); btnpicTxLoad->resize(winW/2 + 20, winH - 26, 60, 24); btnpicTxClose->resize(winW/2 + 80, winH - 26, 60, 24); btnpicTxSPP->show(); btnpicTxSendColor->show(); btnpicTxSendGrey->show(); btnpicTxLoad->show(); btnpicTxClose->show(); btnpicTxSendAbort->hide(); picTxWin->show(); } void deleteTxViewer() { picTxWin->hide(); if (picTx) delete picTx; delete [] xmtimg; xmtimg = 0; delete [] xmtpicbuff; xmtpicbuff = 0; delete picTxWin; picTxWin = 0; serviceme = 0; } void deleteRxViewer() { picRxWin->hide(); if (picRx) { delete picRx; picRx = 0; } delete picRxWin; picRxWin = 0; serviceme = 0; } int print_time_left(float time_sec, char *str, size_t len, const char *prefix, const char *suffix) { int time_min = (int)(time_sec / 60); time_sec -= time_min * 60; if (time_min) return snprintf(str, len, "%s %02dm %2.1fs%s", prefix, time_min, time_sec, suffix); else return snprintf(str, len, "%s %2.1fs%s", prefix, time_sec, suffix); } void setpicture_link(mfsk *me) { serviceme = me; }
11,596
C++
.cxx
388
27.713918
96
0.65704
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,266
kmlserver.cxx
w1hkj_fldigi/src/kml/kmlserver.cxx
// ---------------------------------------------------------------------------- // kmlserver.cxx -- KML Server // // Copyright (C) 2012 // Remi Chateauneu, F4ECW // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <string.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <math.h> #include <assert.h> #include <sys/stat.h> #include <string> #include <set> #include <map> #include <vector> #include <memory> #include <list> #include <stdexcept> #include <fstream> #include <sstream> #include "config.h" #include "kmlserver.h" #include "gettext.h" #include "debug.h" #include "threads.h" #include "strutil.h" #include "configuration.h" #include "fl_digi.h" #include "irrXML.h" #include "timeops.h" LOG_FILE_SOURCE(debug::LOG_KML); /** Some platforms have problems with condition variables apparently. * When cancelling a thread which waits in pthread_cond_timedwait, * the thread is stuck. * We replace it by an unconditional wait, and a test on a boolean * which indicates if data was saved in the internal buffers. * The consequence is that data are not immediately saved in KML files, * and the user has to wait until the end of the delay. */ #if !defined(__APPLE__) # define FLDIGI_KML_CONDITION_VARIABLE 1 #endif // ---------------------------------------------------------------------------- static const char * KmlSrvUnique = "Permanent"; /// This must follow a specific ISO format so it can be serialized in KML files. static void KmlTimestamp( std::ostream &ostrm, time_t tim ) { if(tim == KmlServer::UniqueEvent) { ostrm << KmlSrvUnique; return; } tm objTm = *gmtime(&tim); char bufTm[40]; // See http://www.w3.org/TR/xmlschema-2/#isoformats snprintf( bufTm, sizeof(bufTm), "%4d-%02d-%02dT%02d:%02dZ", objTm.tm_year + 1900, objTm.tm_mon + 1, objTm.tm_mday, objTm.tm_hour, objTm.tm_min ); ostrm << bufTm ; } /// For debugging purpose. static std::string KmlTimestamp( time_t tim ) { std::stringstream strm ; KmlTimestamp( strm, tim ); return strm.str(); } /// Deserialize a timestamp, inverse of KmlTimestamp. static time_t KmlFromTimestamp( const char * ts ) { if(ts == NULL ) throw std::runtime_error("Null timestamp"); if( 0 == strcmp( ts, KmlSrvUnique ) ) return KmlServer::UniqueEvent ; /// So all fields are initialised with correct default values. time_t timNow = time(NULL); tm objTm = *gmtime( &timNow ); int r = sscanf( ts, "%4d-%02d-%02dT%02d:%02dZ", &objTm.tm_year, &objTm.tm_mon, &objTm.tm_mday, &objTm.tm_hour, &objTm.tm_min ); if( r != 5 ) throw std::runtime_error("Cannot read timestamp from " + std::string(ts) ); objTm.tm_year -= 1900; objTm.tm_mon -= 1; objTm.tm_sec = 0; time_t res = mktime( &objTm ); if( res < 0 ) throw std::runtime_error("Cannot make timestamp from " + std::string(ts) ); return res; } // ---------------------------------------------------------------------------- /// Some chars are forbidden in HTML documents. This replaces them by HTML entities. // We do not need to create a temporary copy of the transformed string. // See Html entities here: http://www.w3schools.com/tags/ref_entities.asp static void StripHtmlTags( std::ostream & ostrm, const char * beg, bool newLines = false ) { const char * ptr = NULL; // TODO: Consider &nbsp; &cent; &pound; &yen; &euro; &sect; &copy; &reg; &trade; for( const char * it = beg ; ; ++it ) { /** Other characters are filtered: * U+0009, U+000A, U+000D: these are the only C0 controls accepted in XML 1.0; * U+0020–U+D7FF, U+E000–U+FFFD: */ char ch = *it ; switch( ch ) { case 0x01 ... 0x08 : // case 0x09 : // case 0x0A : case 0x0B ... 0x0C : // case 0x0D : case 0x0E ... 0x0F : ptr = " "; break; case '"' : ptr = "&quot;"; break; case '\'' : ptr = "&apos;"; break; case '&' : ptr = "&amp;" ; break; case '<' : ptr = "&lt;" ; break; case '>' : ptr = "&gt;" ; break; case '\0' : break ; case '\n' : if(newLines) // Should we replace new lines by "<BR>" ? { ptr = "<BR>" ; break; } // Otherwise we print the newline char like the other chars. default : continue ; } if( it != beg ) { ostrm.write( beg, it - beg ); } if( ch == '\0' ) break ; assert(ptr); ostrm << ptr ; beg = it + 1 ; } } /// Some values such as Navtex messages may contain newline chars. static void StripHtmlTagsNl( std::ostream & ostrm, const std::string & beg ) { StripHtmlTags( ostrm, beg.c_str(), true ); } static void StripHtmlTags( std::ostream & ostrm, const std::string & beg ) { StripHtmlTags( ostrm, beg.c_str() ); } // ---------------------------------------------------------------------------- /// Also used when reloading a KML file. void KmlServer::CustomDataT::Push( const char * k, const std::string & v ) { push_back( value_type( k, v ) ); } // ---------------------------------------------------------------------------- /// Different sorts of KML datas. This list is hardcoded but they are processed identically. static const char * categories[] = { "User", "Synop", "Navtex" }; static const size_t nb_categories = sizeof(categories) / sizeof(*categories); /// Written at the beginning of each KML document. static void KmlHeader( std::ostream & ostrm, const std::string & title ) { ostrm << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<kml xmlns=\"http://earth.google.com/kml/2.1\">\n" "<Document>\n" "<name>" << title << "</name>\n" ; } /// Appended at the end of each KML document. static const char KmlFooter[] = "</Document>\n" "</kml>\n" ; /// Contains for example GIF images, and all the styles. Can be customised by the user. static const std::string namStyles = "styles.kml"; /** Used to code the data for reloading. The description tag is too complicated * to parse and its serialization might not be reversible. * We use preprocessor constants instead of char arrays so they can be concatenated at compile-time. * The tags must be as short as possible but the values easy to deserialize. * */ #define FLDIGI_TAG_ITM "fldigi:itm" #define FLDIGI_TAG_EVT "fldigi:evt" #define FLDIGI_TAG_KEY "k" #define FLDIGI_TAG_VAL "v" #define FLDIGI_TIMESTAMP "ts" /// Global singleton of all KML-related things. class KmlSrvImpl : public KmlServer { volatile bool m_loaded ; /// Set when ready for operation. std::string m_kml_dir; /// Where kml files are saved. std::string m_command; /// Started each time KML files are saved. int m_pid_command; /// Process id of the running commend for KML files. double m_merge_dist; /// Below this, placemark with same name are merged. int m_retention_delay; /// Purge old data. int m_refresh_interval; /// In seconds, written in KML files. int m_balloon_style; /// Display style in KML balloons: Lines, matrices, plain text. pthread_t m_writer_thread ; /// Periodically woken up to write things to the KML file. /// Models a KML placemark. It contains events indexed my a timestamp. /// We need an ordered container in order to remove old data in one erase. class PlacemarkT : public std::multimap< time_t, CustomDataT > { CoordinateT::Pair m_coord; double m_altitude; std::string m_styleNam; // The icon. std::string m_kmlId ; // Unique KML id for the placemark. std::string m_descrTxt ;// KML snippet. /// Serialize the internal data to XML so they can be easily read. void SerializeForReading( std::ostream & ostrm ) const { /// Custom data elements for reading the content when restarting. ostrm << "<ExtendedData xmlns:fldigi=\"http://www.w1hkj.com\">\n"; /// Print from the most recent event, which is at the end. for( const_iterator itEvt = begin(), enEvt = end(); itEvt != enEvt; ++itEvt ) { ostrm << "<" FLDIGI_TAG_EVT " " FLDIGI_TIMESTAMP "=\""; KmlTimestamp(ostrm,itEvt->first); ostrm << "\">\n" ; const CustomDataT & refCust = itEvt->second; for( CustomDataT::const_iterator it = refCust.begin(), en = refCust.end(); it != en; ++it ) { ostrm << "<" FLDIGI_TAG_ITM " " FLDIGI_TAG_KEY "=\"" << it->first << "\" " FLDIGI_TAG_VAL "=\""; StripHtmlTags(ostrm,it->second); ostrm << "\" />"; } ostrm << "</" FLDIGI_TAG_EVT ">\n" ; } /// Dumps all events in natural order ostrm << "</ExtendedData>\n"; } public: /// Constructor called by "Broadcast", not from reading a KML file. PlacemarkT( const CoordinateT::Pair & refCoo, double altitude, const std::string & styleNam, const std::string & kmlNam ) : m_coord( refCoo ) , m_altitude( altitude ) , m_styleNam( styleNam ) { /// The unique key is indeed the name and the time, /// because an object such as a ship might move and come back to the same place. /// We add a counter because during tests, the timestamps are too close. static int dummyCnt = 0 ; std::stringstream strm ; /// No need to store the kml name because it is the multimap key. StripHtmlTags(strm,kmlNam); strm << ':' << Tm2Time() << ':' << ++dummyCnt ; m_kmlId = strm.str(); } /// Constructor for deserialization. Strings comes from the KML file. PlacemarkT() : m_altitude(0.0) {} void Clear() { m_styleNam.clear(); m_kmlId.clear(); m_descrTxt.clear(); clear(); } /// Used when reading a KML file. Read coordinates and altitude from a string when reloading a KML file. void SetCoordinates( const char * str ) { double lon, lat ; if( str == NULL ) { throw std::runtime_error("Null coordinates text"); } int r = sscanf( str, "%lf,%lf,%lf", &lon, &lat, &m_altitude ); if( r != 3 ) { static const std::string msg("Cannot read coordinates and altitude:"); throw std::runtime_error(msg+str); } m_coord = CoordinateT::Pair( lon, lat ); } /// Used when reading a KML file. HTML entities are already removed. "+1" is for the "#". void SetStyle( const char * str ) { if(str == NULL ) throw std::runtime_error("Null input style"); size_t sz = namStyles.size(); // If the strings are equal, then strlen(str) >= sz, and str[sz] == '\0' if equality. if( ( 0 == strncmp( str, namStyles.c_str(), sz ) ) && ( str[sz] == '#' ) ) { m_styleNam = str + sz + 1; } else { LOG_INFO("Inconsistent URL style:%s",str ); m_styleNam = str ; } } /// Used when reading a KML file. void SetKmlId( const char * str ) { std::stringstream strm ; // The KML deserializer irrXML transforms the HTML entities // into normal chars. We must do the reverse transformation. StripHtmlTags(strm,str); m_kmlId = strm.str(); } /// Just add the events without suppressing duplicate information. void AppendEvent( time_t evtTim, const std::string & descrTxt, const CustomDataT & custDat ) { if( m_descrTxt.empty() ) m_descrTxt = descrTxt ; else if( ! descrTxt.empty() ) { // We want to ensure that it is not a miscommunication. if( NULL == strstr( m_descrTxt.c_str(), descrTxt.c_str() ) ) { m_descrTxt += "," + descrTxt ; } } /// Default time is now. evtTim might have another special value. if(evtTim == 0) { evtTim = time(NULL); } insert( value_type( evtTim, custDat ) ); } const CoordinateT::Pair & coordinates() const { return m_coord;} double altitude(void) const { return m_altitude;} const std::string & style(void) const { return m_styleNam; } const std::string & KmlId(void) const { return m_kmlId; } /// When writing the style to the KML file. void styleToKml(std::ostream & ostrm) const { ostrm << namStyles << '#'; StripHtmlTags(ostrm,m_styleNam); } /// Used when several PlacemarkT with the same kmlNam but different styles. Keep the first only. void style(const std::string & styl) { m_styleNam = styl; } /// This is NOT the Euclidian distance but tries to reflect a position change on a 3D map. double distance_to( const PlacemarkT & refOther ) const { double delta_altitude_km = fabs( m_altitude - refOther.m_altitude ) * 0.001 ; // Big coefficient for the altitude, to show on the map what happens. double horiz_dist = m_coord.distance( refOther.m_coord ); return horiz_dist + 10 * delta_altitude_km ; } /// Adds the events of another placemark. Manages events enforced to be unique. void concatenate( const PlacemarkT & refOther ) { if( refOther.empty() ) return ; time_t firstTm = refOther.begin()->first ; if( firstTm == KmlServer::UniqueEvent ) { clear(); /// We keep this special time_t value to enforce unicity of CustomDataT. insert( *refOther.begin() ); } else { insert( refOther.begin(), refOther.end() ); } } // PlacemarkT::concatenate /// This transforms our coordinates into KML ones. void WriteCooSub( std::ostream & ostrm ) const { ostrm << m_coord.longitude().angle() << ',' << m_coord.latitude().angle() << ',' << m_altitude ; } /// Writes the placemark to a KML stream. void Serialize( std::ostream & ostrm, const std::string & kmlNam, int balloon_style ) const { // Range of events which occured at this place. const_reverse_iterator beEvt = rbegin(), enEvt = rend(); // There should be at least one event. if( beEvt == enEvt ) { LOG_WARN("Inconsistency: No event kmlId=%s",m_kmlId.c_str() ); return ; } // The unique key is indeed the name and the time, // because an object such as a ship might move and come back to the same place. // We add a counter because during tests, the timestamps are too close. ostrm << "<Placemark id=\"" << m_kmlId << "\">\n"; // Beware of the sign of longitude. ostrm << "<Point><coordinates>" ; WriteCooSub( ostrm ); ostrm << "</coordinates></Point>\n"; if( kmlNam.empty() ) ostrm << "<name>No name</name>\n"; else { // Looks like there is a bug in KML when displaying a placemark ID containing an hyphen. ostrm << "<name>"; StripHtmlTags(ostrm,kmlNam); ostrm << "</name>\n"; } ostrm << "<styleUrl>"; styleToKml(ostrm); ostrm << "</styleUrl>\n"; // More information here: http://freegeographytools.com/2007/putting-time-data-into-a-kml-file // 1944-06-06T06:00:00 See http://www.w3.org/TR/xmlschema-2/#isoformats // We do not add the timestamps because it is not very ergonomic. Should be added to the linestrings too. static const bool withTimestamp = false ; if( withTimestamp ) { // Last update time is last argument. ostrm << "<Timestamp><when>"; KmlTimestamp(ostrm,enEvt->first); ostrm << "</when></Timestamp>\n"; } /// Whats is displayed on the margin. Must be short. ostrm << "<Snippet maxLines=\"1\">"; StripHtmlTags(ostrm,m_descrTxt); ostrm << "</Snippet>\n"; /** * Unfortunately it is not possible to use CSS in Google-maps, due to "content scrubbing": * http://stackoverflow.com/questions/8421260/styling-kml-with-css-in-google-maps-v3 * Scrubbing the contents is a security measure to prevent malicious code from executing. * It removes JavaScript, CSS, iframe, embed and object tags. */ static const char * colorTime = "#0099CC"; static const char * colorKey = "#FF9933"; ostrm << "<description>"; /// Data can be displayed into one big matrix, or several tables, one per event. switch( balloon_style ) { case 0: /// Plain text, for example for GPX conversion. for( const_reverse_iterator itEvt = beEvt; itEvt != enEvt; ++itEvt ) { ostrm << "Timestamp:" << Tm2Time(itEvt->first) << "\n" ; const CustomDataT & refCust = itEvt->second; for( CustomDataT::const_iterator it = refCust.begin(), en = refCust.end(); it != en; ++it ) { StripHtmlTags(ostrm,it->first); ostrm << ":"; /// Do not insert <br> tags. StripHtmlTags(ostrm,it->second); ostrm << "\n" ; } ostrm << "\n" ; } break; case 1: // One distinct HTML table per event. ostrm << "<![CDATA[<table border=\"1\">"; // Print from the most recent event, which is at the end. for( const_reverse_iterator itEvt = beEvt; itEvt != enEvt; ++itEvt ) { ostrm << "<tr>"; ostrm << "<td bgcolor=" << colorTime << " colspan=\"2\">" << Tm2Time(itEvt->first) << "</td>" "</tr>" ; const CustomDataT & refCust = itEvt->second; for( CustomDataT::const_iterator it = refCust.begin(), en = refCust.end(); it != en; ++it ) { ostrm << "<tr>" "<td>"; StripHtmlTags(ostrm,it->first); ostrm << "</td>" "<td>"; StripHtmlTagsNl(ostrm,it->second); ostrm << "</td>" "</tr>" ; } } ostrm << "</table>]]>\n"; break; case 2 : { /// Transposition of the html matrix. typedef std::vector<time_t> TitleT ; TitleT titles ; typedef std::vector< std::string > RowT ; const_iterator beCol = begin(), enCol = end(); for( const_iterator itCol = beCol; itCol != enCol; ++itCol ) { titles.push_back( itCol->first ); } size_t nbCols = titles.size(); typedef std::map< std::string, RowT > MtxT; MtxT mtx ; size_t iCols = 0; for( const_iterator itCol = beCol; itCol != enCol; ++itCol, ++iCols ) { const CustomDataT & refCust = itCol->second; for( CustomDataT::const_iterator it = refCust.begin(), en = refCust.end(); it != en; ++it ) { MtxT::iterator itMtx = mtx.find( it->first ); if( itMtx == mtx.end() ) { itMtx = mtx.insert( mtx.end(), MtxT::value_type( it->first, RowT() ) ); itMtx->second.resize(nbCols); } itMtx->second[iCols] = it->second ; } } ostrm << "<![CDATA[<table border=\"1\">"; ostrm << "<tr><td></td>"; for( size_t iCols = 0; iCols < nbCols; ++iCols ) { ostrm << "<td bgcolor=" << colorTime << ">" << Tm2Time(titles[iCols]) << "</td>"; } ostrm << "</tr>" ; for( MtxT::const_iterator itMtx = mtx.begin(), enMtx = mtx.end(); itMtx != enMtx; ++itMtx ) { ostrm << "<tr>"; ostrm << "<td bgcolor=" << colorKey << ">"; StripHtmlTags(ostrm,itMtx->first); ostrm << "</td>"; // TODO: Do not write twice the same value if it is not numeric (Starting with a digit) // or longer than N characters. for( RowT::const_iterator itRow = itMtx->second.begin(), enRow = itMtx->second.end(); itRow != enRow; ++itRow ) { ostrm << "<td>"; StripHtmlTags(ostrm,*itRow); ostrm << "</td>"; } ostrm << "</tr>" ; } ostrm << "</table>]]>\n"; break; } } ostrm << "</description>\n"; // TODO: Other dsplay style: All elements on a one single table. Removal of duplicate text values etc... SerializeForReading( ostrm ); ostrm << "</Placemark>\n"; } // PlacemarkT::Serialize }; // PlacemarkT /** The placemark name is unique wrt to the application. It might map to several PlaceMark, each having distinct coordinates. It is not really possible to sort the different locations by coordinates, because it is a list created by the object trajectory. class PlacesMapT : public std::multimap< std::string, PlacemarkT > */ class PlacesMapT : public std::multimap< std::string, PlacemarkT > { /// Written to by the main thread with lock protection, read (and emptied) /// by the sub thread which is later in charge of writing things to disk. typedef std::list< value_type > PlacemarkListT ; /// A separate queue helps for performance because the insertion in the main container /// might take time and the main thread may lose data. PlacemarkListT m_queue_to_insert ; /// This is not set when inserting at load time, but when emptying /// the queue, and when data are ready for writing to disk. mutable bool m_must_save ; public: PlacesMapT() : m_must_save(false) {} /// Finds an object with the same name and close enough. /// If an object with the same name exists but is distant, creates a new one, /// plus a path between the two. /// Called by the main thread at startup when loading the previous KML files. Then later /// called by the subthread in charge of flushing PlacemarkT to the KML file. void DirectInsert( const value_type & refVL, double merge_dist ) { /// Not needed to use equal_range because we need the last placemark matching /// this key, and this iterator is forward_iterator only. iterator it = find( refVL.first ), en = end() ; if( it == en ) { LOG_INFO("Cannot find '%s'", refVL.first.c_str() ); it = insert( end(), refVL ); return; } /// Searches for the last element with the same key. iterator last = it, next = it ; ++next ; while( next != en && next->first == refVL.first ) { last = next; ++next ; } double dist = last->second.distance_to( refVL.second ); /// We can reuse the last element because it is not too far from our coordinates. if( 1000 * dist < merge_dist ) { /// LOG_INFO("Reusing '%s' merge_dist=%lf", refVL.first.c_str(), dist ); /** There will be one event only if adding a new received event, otherwise several if reloading from a file. The new events will be inserted based on their timestamp. */ // last->second.insert( refVL.second.begin(), refVL.second.end() ); last->second.concatenate( refVL.second ); return ; } LOG_INFO("Inserted '%s' merge_dist=%lf", refVL.first.c_str(), dist ); /// The object is inserted at the end of all elements with the same key. iterator ret = insert( next, refVL ); /// Runtime check of an assumption. { iterator tst = last ; ++tst ; if( tst != ret ) { LOG_WARN("Iterators assumption is wrong (1): %s", refVL.first.c_str() ); } ++tst ; if( tst != next ) { LOG_WARN("Iterators assumption is wrong (2): %s", refVL.first.c_str() ); } } /// They must have the same style otherwise they will be in different folders. if( refVL.second.style() != last->second.style() ) { LOG_WARN("Correcting style discrepancy %s: %s != %s", refVL.first.c_str(), refVL.second.style().c_str(), last->second.style().c_str() ); ret->second.style( last->second.style() ); } } // DirectInsert /// Enqueues a new placemark for insertion by the subthread. Called by the main thread /// each time a Broadcast of a new PlacemarkT is done. void Enqueue( const std::string & kmlNam, const PlacemarkT & refPM ) { /// So we will save to a file, because something changed. m_queue_to_insert.push_back( value_type( kmlNam, refPM ) ); } /// Called by the subthread. It can merge data of placemarks with the same name /// and different positions due to a move. This has to be very fast because under lock protection. void FlushQueue(double merge_dist) { LOG_INFO("FlushQueue nbelts %d sz=%d", static_cast<int>(m_queue_to_insert.size()), static_cast<int>(size()) ); if( m_queue_to_insert.empty() ) return ; for( PlacemarkListT::iterator itPL = m_queue_to_insert.begin(), enPL = m_queue_to_insert.end(); itPL != enPL; ++ itPL ) { DirectInsert( *itPL, merge_dist ); } LOG_INFO("Flushed into sz=%d", static_cast<int>(size()) ); // TODO: If lock contention problems, we might swap this list with another one owned by this // objet. This would later be merged into the container before saving data to disk. m_queue_to_insert.clear(); m_must_save = true ; } /// Removes obsolete data for one category only. void PruneKmlFile( int retention_delay ) { /// By convention, it means keeping all data. if( retention_delay <= 0 ) return ; /// Called only once per hour, instead of at every call. Saves CPU. static time_t prev_call_tm = 0 ; time_t now = time(NULL); static const int seconds_per_hour = 60 * 60 ; /// First call of this function, always do the processing. if( prev_call_tm != 0 ) { /// If this was called for less than one hour, then return. if( prev_call_tm > now - seconds_per_hour ) return ; } prev_call_tm = now ; /// Cleanup all data older than this. time_t limit_time = now - retention_delay * seconds_per_hour ; LOG_INFO("sz=%d retention=%d hours now=%s limit=%s", (int)size(), retention_delay, KmlTimestamp(now).c_str(), KmlTimestamp(limit_time).c_str() ); size_t nbFullErased = 0 ; size_t nbPartErased = 0 ; for( iterator itMap = begin(), nxtMap = itMap, enMap = end() ; itMap != enMap; itMap = nxtMap ) { PlacemarkT & refP = itMap->second ; ++nxtMap ; /// Erases all elements older than the limit, or the whole element. PlacemarkT::iterator itP = refP.upper_bound( limit_time ); if( itP == refP.end() ) { erase( itMap ); ++nbFullErased ; } else if( itP != refP.begin() ) { refP.erase( refP.begin(), itP ); ++nbPartErased ; } } // Maybe the container only lost data because of data expiration, so it must be saved. bool must_save_now = m_must_save || ( nbFullErased > 0 ) || ( nbPartErased > 0 ) ; LOG_INFO("Sz=%d FullyErased=%d PartialErased=%d m_must_save=%d must_save_now=%d", (int)size(), (int)nbFullErased, (int)nbPartErased, m_must_save, must_save_now ); m_must_save = must_save_now ; } /// This is not efficient because we reopen the file at each access, but it ensures /// that the file is consistent and accessible at any moment. bool RewriteKmlFileOneCategory( const std::string & category, const std::string & kmlFilNam, int balloon_style ) const { // Normally, it is stable when we insert an element with a duplicate key. typedef std::multiset< PlacesMapT::const_iterator, PlacesMapIterSortT > PlacesMapItrSetT ; PlacesMapItrSetT plcMapIterSet ; /// If there is nothing to save, not needed to create a file. if( false == m_must_save ) return false ; /// For safety purpose, we do not empty the file. It might be an error. if( empty() ) { LOG_INFO("Should empty KML file %s. Grace period.", kmlFilNam.c_str() ); return false ; } m_must_save = false ; for( const_iterator itPlcMap = begin(), en = end(); itPlcMap != en ; ++itPlcMap ) { plcMapIterSet.insert( itPlcMap ); } int nbPlacemarks = plcMapIterSet.size(); // This file must be atomic because it is periodically read. // TODO: Checks if another process has locked the ".tmp" file. // If so , we should reread the KML file and merge our data with it. // This would allow to have several fldigi sessions simultaneously running // on the same KML files. On the other hand, it should already work if these // processes are updating different categories, which is more probable. AtomicRenamer ar( kmlFilNam ); KmlHeader(ar, category) ; // This will easily allow hierarchical folders. std::string lastStyle ; for( PlacesMapItrSetT::const_iterator itStyl = plcMapIterSet.begin(), enStyl = plcMapIterSet.end(); itStyl != enStyl; ) { ar << "<Folder>"; // Hyphen: No idea why, but the string "10-meter discus buoy:W GULF 207 NM " just displays as "10-" ar << "<name>"; StripHtmlTags( ar,(*itStyl)->second.style() ); ar << "</name>"; // Several placemarks with the same name: A single object has moved. PlacesMapItrSetT::const_iterator itStylNext = itStyl ; for(;;) { // TODO: Objects with the same name and different coordinates must be signaled so. (*itStylNext)->second.Serialize( ar, (*itStylNext)->first, balloon_style); ++itStylNext ; if( itStylNext == enStyl ) break ; if( (*itStyl)->second.style() != (*itStylNext)->second.style() ) break ; } // Now, in the same loop, we draw the polylines between placemarks with the same name. for( PlacesMapItrSetT::const_iterator itNamBeg = itStyl, itNamLast = itNamBeg; itNamLast != itStylNext ; ) { PlacesMapItrSetT::const_iterator itNamNxt = itNamLast; ++itNamNxt ; if( ( itNamNxt == itStylNext ) || ( (*itNamNxt)->first != (*itNamLast)->first ) ) { // No point tracing a line with one point only. if( *itNamBeg != *itNamLast ) { DrawPolyline( ar, category, *itNamBeg, *itNamLast ); } itNamBeg = itNamNxt ; } itNamLast = itNamNxt ; } itStyl = itStylNext ; ar << "</Folder>"; } ar << KmlFooter ; LOG_INFO("Saved %s: %d placemarks to %s", category.c_str(), nbPlacemarks, kmlFilNam.c_str() ); return true ; } // KmlSrvImpl::PlacesMapT::RewriteKmlFileOneCategory }; // KmlSrvImpl::PlacesMapT /// There is a very small number of categories: Synop, Navtex etc... struct PlacemarksCacheT : public std::map< std::string, PlacesMapT > { const PlacesMapT * FindCategory( const std::string & category ) const { const_iterator it = find( category ); if( it == end() ) return NULL ; return &it->second; } PlacesMapT * FindCategory( const std::string & category ) { iterator it = find( category ); if( it == end() ) it = insert( end(), value_type( category, PlacesMapT() ) ); return &it->second ; } }; /// At startup, should be reloaded from the various KML files. PlacemarksCacheT m_placemarks ; /// Used for signaling errors. void close_throw( FILE * ofil, const std::string & msg ) const { if( ofil ) fclose( ofil ); throw std::runtime_error( strformat( "%s:%s", msg.c_str(), strerror(errno) ) ); } /// This points to the specific KML file of the category. void CategoryNetworkLink( std::ostream & strm, const std::string & category ) const { strm << "<NetworkLink>\n" " <name>" << category << "</name>\n" " <Link>\n" " <href>" << category << ".kml</href>\n" " <refreshMode>onInterval</refreshMode>\n" " <refreshInterval>" << m_refresh_interval << "</refreshInterval>\n" " </Link>\n" "</NetworkLink>\n"; } // KmlSrvImpl::CategoryNetworkLink /// This file copy does not need to be atomic because it happens once only. void CopyStyleFileIfNotExists(void) { /// Where the installed file is stored and never moved from. Used as default. std::string namSrc = PKGDATADIR "/kml/" + namStyles ; /// The use might customize its styles file: It will not be altered. std::string namDst = m_kml_dir + namStyles ; /// Used to copy the master file to the user copy if needed. FILE * filSrc = NULL; FILE * filDst = fl_fopen( namDst.c_str(), "r" ); /// If the file is there, leave as it is because it is maybe customize. if( filDst ) { LOG_INFO("Style file %s not altered", namDst.c_str() ); goto close_and_quit ; } filDst = fl_fopen( namDst.c_str(), "w" ); if( filDst == NULL ) { LOG_INFO("Cannot open destination style file %s", namDst.c_str() ); goto close_and_quit ; } filSrc = fl_fopen( namSrc.c_str(), "r" ); if( filSrc == NULL ) { LOG_INFO("Cannot open source style file %s", namSrc.c_str() ); goto close_and_quit ; } /// Transient buffer to copy the file. char buffer[BUFSIZ]; size_t n; while ((n = fread(buffer, sizeof(char), sizeof(buffer), filSrc)) > 0) { if (fwrite(buffer, sizeof(char), n, filDst) != n) { LOG_WARN("Error %s copying style file %s to %s", strerror(errno), namSrc.c_str(), namDst.c_str() ); goto close_and_quit ; } } LOG_INFO("Style file %s copied to %s", namSrc.c_str(), namDst.c_str() ); close_and_quit: if( filDst ) fclose(filDst); if( filSrc ) fclose(filSrc); } /// This creates a KML file with links to the categories such as Synop and Navtex. void CreateMainKmlFile(void) { // This is the file, that the user must click on. std::string baseFil = m_kml_dir + "fldigi.kml" ; LOG_INFO("Creating baseFil=%s", baseFil.c_str() ); /// We do not need to make this file atomic because it is read once only. AtomicRenamer ar( baseFil ); KmlHeader( ar, "Fldigi"); for( size_t i = 0; i < nb_categories; ++i ) CategoryNetworkLink( ar, categories[i] ); ar << KmlFooter ; } // TODO: Consider hierarchical categories: "Synop/buoy/Inmarsat" /// A specific name is chosen so we can later update this line. static void DrawPolyline( std::ostream & ostrm, const std::string & category, PlacesMapT::const_iterator beg, PlacesMapT::const_iterator last ) { /// The polyline gets an id based on the beginning of the path, which will never change. ostrm << "<Placemark id=\"" << beg->second.KmlId() << ":Path\">" "<name>" << beg->second.KmlId() << "</name>" "<LineString>" "<altitudeMode>clampToGround</altitudeMode><tessellate>1</tessellate>\n" "<coordinates>\n"; double dist = 0.0 ; int nbStops = 0 ; // "135.2, 35.4, 0. for(;;) { beg->second.WriteCooSub( ostrm ); ostrm << "\n"; if( beg == last ) break ; PlacesMapT::const_iterator next = beg ; ++next ; ++nbStops; dist += beg->second.coordinates().distance( next->second.coordinates() ); beg = next ; }; ostrm << "</coordinates>" "</LineString>" "<Snippet>" << dist << " " << _("kilometers") << " in " << nbStops << " " << _("stops") << "</Snippet>" "<Style>" "<LineStyle><color>#ff0000ff</color></LineStyle> " "</Style>" "</Placemark>\n"; } // DrawPolyline /// Similar to a std::ofstream but atomically updated by renaming a temp file. struct AtomicRenamer : public std::ofstream { /// Target file name. std::string m_filnam ; /// Temporary file name. Renamed to the target when closed. std::string m_filtmp ; public: /// This opens a temporary file when all the writing is done. AtomicRenamer( const std::string & filnam ) : m_filnam( filnam ) , m_filtmp( filnam + ".tmp" ) { LOG_INFO("AtomicRenamer opening tmp %s", filnam.c_str() ); open( m_filtmp.c_str() ); if( bad() ) { LOG_WARN("Cannot open %s", m_filtmp.c_str() ); } } /// Atomic because rename is an atomic too, and very fast if in same directory. ~AtomicRenamer() { close(); /// This is needed on Windows. int ret_rm = remove( m_filnam.c_str() ); if( ( ret_rm != 0 ) && ( errno != ENOENT ) ) { LOG_WARN("Cannot remove %s: %s", m_filnam.c_str(), strerror(errno) ); } int ret_mv = rename( m_filtmp.c_str(), m_filnam.c_str() ); if( ret_mv ) { LOG_WARN("Cannot rename %s to %s:%s", m_filtmp.c_str(), m_filnam.c_str(), strerror(errno) ); } } }; /// The KML filename associated to a category. std::string CategFile( const std::string & category ) const { return m_kml_dir + category + ".kml"; } /// Resets the files. Called from the test program and the GUI. void CreateNewKmlFile( const std::string & category ) const { // This file must be atomic because it is periodically read. AtomicRenamer ar( CategFile( category ) ); KmlHeader( ar, category); ar << KmlFooter ; } /// Template parameters should not be local types. struct PlacesMapIterSortT { // This sort iterators on placemarks, based on the style name then the placemark name. bool operator()( const PlacesMapT::const_iterator & it1, const PlacesMapT::const_iterator & it2 ) const { int res = it1->second.style().compare( it2->second.style() ); if( res == 0 ) res = it1->first.compare( it2->first ); return res < 0 ; } }; /// Various states of the KML reader. #define KMLRD_NONE 1 #define KMLRD_FOLDER 2 #define KMLRD_FOLDER_NAME 3 #define KMLRD_FOLDER_PLACEMARK 4 #define KMLRD_FOLDER_PLACEMARK_NAME 5 #define KMLRD_FOLDER_PLACEMARK_POINT 6 #define KMLRD_FOLDER_PLACEMARK_POINT_COORDINATES 7 #define KMLRD_FOLDER_PLACEMARK_STYLEURL 8 #define KMLRD_FOLDER_PLACEMARK_SNIPPET 9 #define KMLRD_FOLDER_PLACEMARK_EXTENDEDDATA 10 #define KMLRD_FOLDER_PLACEMARK_EXTENDEDDATA_FLDIGIEVENT 11 #define KMLRD_FOLDER_PLACEMARK_EXTENDEDDATA_FLDIGIEVENT_FLDIGIITEM 12 #define KMLRD_FOLDER_PLACEMARK_UNDEFINED 13 #define KMLRD_FOLDER_UNDEFINED 14 /// Debugging purpose only. static const char * KmlRdToStr( int kmlRd ) { #define KMLRD_CASE(k) case k : return #k ; switch(kmlRd) { KMLRD_CASE(KMLRD_NONE) KMLRD_CASE(KMLRD_FOLDER) KMLRD_CASE(KMLRD_FOLDER_NAME) KMLRD_CASE(KMLRD_FOLDER_PLACEMARK) KMLRD_CASE(KMLRD_FOLDER_PLACEMARK_NAME) KMLRD_CASE(KMLRD_FOLDER_PLACEMARK_POINT) KMLRD_CASE(KMLRD_FOLDER_PLACEMARK_POINT_COORDINATES) KMLRD_CASE(KMLRD_FOLDER_PLACEMARK_STYLEURL) KMLRD_CASE(KMLRD_FOLDER_PLACEMARK_SNIPPET) KMLRD_CASE(KMLRD_FOLDER_PLACEMARK_EXTENDEDDATA) KMLRD_CASE(KMLRD_FOLDER_PLACEMARK_EXTENDEDDATA_FLDIGIEVENT) KMLRD_CASE(KMLRD_FOLDER_PLACEMARK_UNDEFINED) KMLRD_CASE(KMLRD_FOLDER_UNDEFINED) default : return "Unknown KMLRD code"; } #undef KMLRD_CASE } /// Loads a file of a previous session. The mutex should be locked at this moment. void ReloadSingleKmlFile( const std::string & category ) { std::string kmlFilNam = CategFile( category ); LOG_INFO("kmlFilNam=%s m_merge_dist=%lf", kmlFilNam.c_str(), m_merge_dist ); PlacesMapT *ptrMap = m_placemarks.FindCategory( category ); FILE * filKml = fl_fopen( kmlFilNam.c_str(), "r" ); if( filKml == NULL ) { LOG_ERROR("Could not open %s. Creating one.", kmlFilNam.c_str() ); CreateNewKmlFile( category ); return ; } /// The destructor ensures the file will be closed if an exception is thrown. struct FilCloserT { FILE * m_file ; ~FilCloserT() { fclose(m_file); } } Closer = { filKml }; irr::io::IrrXMLReader * xml = irr::io::createIrrXMLReader( Closer.m_file ); if( xml == NULL ) { LOG_ERROR("Could not parse %s", kmlFilNam.c_str() ); return ; } using namespace irr::io ; int currState = KMLRD_NONE ; std::string currFolderName ; std::string currPlcmrkName ; time_t currTimestamp = 0; std::string currPlacemarkDescr ; CustomDataT currCustData ; PlacemarkT currPM; bool currIsPoint = false ; std::string avoidNode ; /// Stores the unique nodes which are misplaced. typedef std::set< std::string > UnexpectedNodesT ; UnexpectedNodesT unexpectedNodes ; // <Folder><name>ship</name><Placemark id="Ship:AUP06:2012-10-11 04:28:9"> // <Point><coordinates>146.8,-19.2,0</coordinates></Point> // <name>Ship:AUP06</name> // <styleUrl>styles.kml#ship</styleUrl> // <description><![CDATA[<table border="1"><tr><td bgcolor=#00FF00 colspan="2">2012-09-24 12:00</td></tr><tr while(xml->read()) { switch(xml->getNodeType()) { case EXN_TEXT: { if( ! avoidNode.empty() ) break ; const char * msgTxt = xml->getNodeData(); LOG_DEBUG( "getNodeData=%s currState=%s", msgTxt, KmlRdToStr(currState) ); switch(currState) { case KMLRD_FOLDER_NAME : currFolderName = msgTxt ? msgTxt : "NullFolder"; break; case KMLRD_FOLDER_PLACEMARK_POINT_COORDINATES : currPM.SetCoordinates(msgTxt); break; case KMLRD_FOLDER_PLACEMARK_NAME : currPlcmrkName = msgTxt ? msgTxt : "NullPlacemarkName"; break; case KMLRD_FOLDER_PLACEMARK_SNIPPET : currPlacemarkDescr = msgTxt ? msgTxt : "NullSnippet"; break; case KMLRD_FOLDER_PLACEMARK_STYLEURL : currPM.SetStyle(msgTxt); break; default: break; } break; } case EXN_ELEMENT: { if( ! avoidNode.empty() ) break ; const char *nodeName = xml->getNodeName(); LOG_INFO( "getNodeName=%s currState=%s", nodeName, KmlRdToStr(currState) ); // TODO: Have a hashmap for each case. switch(currState) { case KMLRD_NONE : if (!strcmp("Folder", nodeName)) { currState = KMLRD_FOLDER ; } else { /// These tags are not meaningful for us. if( strcmp( "kml", nodeName ) && strcmp( "Document", nodeName ) && strcmp( "name", nodeName ) ) LOG_INFO("Unexpected %s in document %s. currState=%s", nodeName, category.c_str(), KmlRdToStr(currState) ); } break; case KMLRD_FOLDER : if (!strcmp("name", nodeName)) { currState = KMLRD_FOLDER_NAME ; } else if (!strcmp("Placemark", nodeName)) { currState = KMLRD_FOLDER_PLACEMARK ; currPM.Clear(); const char * strId = xml->getAttributeValue("id"); currPM.SetKmlId( strId ); } else { avoidNode = nodeName ; currState = KMLRD_FOLDER_UNDEFINED ; LOG_INFO("Unexpected %s in folder %s. currState=%s", nodeName, currFolderName.c_str(), KmlRdToStr(currState) ); } break; case KMLRD_FOLDER_PLACEMARK : // There are different sorts of Placemark such as Point or LineString. if (!strcmp("Point", nodeName)) { currState = KMLRD_FOLDER_PLACEMARK_POINT ; currIsPoint = true ; } else if (!strcmp("name", nodeName)) { currState = KMLRD_FOLDER_PLACEMARK_NAME ; } else if (!strcmp("Snippet", nodeName)) { currState = KMLRD_FOLDER_PLACEMARK_SNIPPET ; } else if (!strcmp("styleUrl", nodeName)) { currState = KMLRD_FOLDER_PLACEMARK_STYLEURL ; } else if (!strcmp("ExtendedData", nodeName)) { currState = KMLRD_FOLDER_PLACEMARK_EXTENDEDDATA ; } else if (!strcmp("description", nodeName)) { // We do not care about this tag, but it is always here. currState = KMLRD_FOLDER_PLACEMARK_UNDEFINED ; } else { avoidNode = nodeName ; currState = KMLRD_FOLDER_PLACEMARK_UNDEFINED ; /// At the same time, it is detected and inserted. std::pair< UnexpectedNodesT::iterator, bool > pr = unexpectedNodes.insert( nodeName ); // Other occurences of the same nodes will not be signaled. if( pr.second ) { LOG_INFO("Unexpected %s in placemark id=%s name=%s. currState=%s", nodeName, currPM.KmlId().c_str(), currPlcmrkName.c_str(), KmlRdToStr(currState) ); } } break; case KMLRD_FOLDER_PLACEMARK_POINT : if (!strcmp("coordinates", nodeName)) { currState = KMLRD_FOLDER_PLACEMARK_POINT_COORDINATES ; } else { LOG_INFO("Unexpected %s in coordinates. currState=%s", nodeName, KmlRdToStr(currState) ); } break; case KMLRD_FOLDER_PLACEMARK_EXTENDEDDATA: if (!strcmp(FLDIGI_TAG_EVT, nodeName)) { currState = KMLRD_FOLDER_PLACEMARK_EXTENDEDDATA_FLDIGIEVENT ; currTimestamp = KmlFromTimestamp( xml->getAttributeValue(FLDIGI_TIMESTAMP) ); currCustData.clear(); } else LOG_INFO("Unexpected %s in extended data. currState=%s", nodeName, KmlRdToStr(currState) ); break; case KMLRD_FOLDER_PLACEMARK_EXTENDEDDATA_FLDIGIEVENT: // http://irrlicht.sourceforge.net/forum/viewtopic.php?t=10532 // The Parser irrXml will not call "EXN_ELEMENT_END" because the tag <fldigi:item/> // has a trailing slash. Therefore we stay in the same state. // We could call irr::io::IIrrXMLReader<...>::isEmptyElement() to check that. if (!strcmp(FLDIGI_TAG_ITM, nodeName)) { assert( xml->isEmptyElement() ); const char * strKey = xml->getAttributeValue(FLDIGI_TAG_KEY); if(strKey == NULL ) { LOG_INFO("Null item key"); break ; } const char * strVal = xml->getAttributeValue(FLDIGI_TAG_VAL); if(strVal == NULL ) { LOG_INFO("Null item value"); break ; } currCustData.Push( strKey, strVal ); } else LOG_INFO("Unexpected %s in event. currState=%s", nodeName, KmlRdToStr(currState) ); break; default: break; } break; } case EXN_ELEMENT_END: { if( ! avoidNode.empty() ) { const char * msgTxt = xml->getNodeData(); if( avoidNode == msgTxt ) { LOG_INFO("Leaving forbidden element %s. currState=%s", avoidNode.c_str(), KmlRdToStr(currState) ); // We can leave the quarantine. avoidNode.clear(); } else { LOG_INFO("Still in forbidden element %s, leaving %s. currState=%s", avoidNode.c_str(), msgTxt, KmlRdToStr(currState) ); break ; } } // We should check that this string matches wuth the state expects, but this is much // faster to use only integers. LOG_INFO("End of %s currState=%s", xml->getNodeData(), KmlRdToStr(currState) ); switch(currState) { case KMLRD_FOLDER : currState = KMLRD_NONE ; break; case KMLRD_FOLDER_PLACEMARK : // Loads only "Point" placemarks. Do not load "Linestring". if( ( ! currPlcmrkName.empty() ) && currIsPoint ) { ptrMap->DirectInsert( PlacesMapT::value_type( currPlcmrkName, currPM ), m_merge_dist ); } currTimestamp = -1 ; currPlacemarkDescr.clear(); currPlcmrkName.clear(); currIsPoint = false ; currState = KMLRD_FOLDER ; break; case KMLRD_FOLDER_NAME : case KMLRD_FOLDER_UNDEFINED : currState = KMLRD_FOLDER ; break; case KMLRD_FOLDER_PLACEMARK_NAME : case KMLRD_FOLDER_PLACEMARK_POINT : case KMLRD_FOLDER_PLACEMARK_STYLEURL : case KMLRD_FOLDER_PLACEMARK_SNIPPET : case KMLRD_FOLDER_PLACEMARK_EXTENDEDDATA : case KMLRD_FOLDER_PLACEMARK_UNDEFINED : currState = KMLRD_FOLDER_PLACEMARK ; break; case KMLRD_FOLDER_PLACEMARK_POINT_COORDINATES : currState = KMLRD_FOLDER_PLACEMARK_POINT ; break; case KMLRD_FOLDER_PLACEMARK_EXTENDEDDATA_FLDIGIEVENT : currState = KMLRD_FOLDER_PLACEMARK_EXTENDEDDATA ; // TODO: As soon as possible, use std::move for performance. currPM.AppendEvent( currTimestamp, currPlacemarkDescr, currCustData ); currCustData.clear(); break; case KMLRD_NONE: break; default: LOG_ERROR("Should not happen %s", KmlRdToStr(currState)); break; } LOG_INFO("currState=%s", KmlRdToStr(currState) ); break; } case EXN_NONE: case EXN_COMMENT: case EXN_CDATA: case EXN_UNKNOWN: break; default: // LOG_INFO( "Default NodeType=%d", xml->getNodeType()); break; } } // And of course delete it delete xml; LOG_INFO("kmlFilNam=%s loaded sz=%d", kmlFilNam.c_str(), (int)ptrMap->size() ); } // KmlSrvImpl::ReloadSingleKmlFile /// Rewrites only the categories which have changed. bool RewriteKmlFileFull(void) { bool wasSaved = false ; LOG_INFO("nb_categories=%d", static_cast<int>(nb_categories) ); for( size_t i = 0; i < nb_categories; ++i ) { const char * category = categories[i]; PlacesMapT *ptrMap = m_placemarks.FindCategory( category ); if( ptrMap == NULL ) { LOG_INFO("Category %s undefined", category ); continue; } ptrMap->PruneKmlFile( m_retention_delay ); wasSaved |= ptrMap->RewriteKmlFileOneCategory( category, CategFile( category ), m_balloon_style ); } return wasSaved ; } // KmlSrvImpl::RewriteKmlFileFull #ifdef FLDIGI_KML_CONDITION_VARIABLE /// This is signaled when geographic data is broadcasted. pthread_cond_t m_cond_queue ; #else /// This is set to true when geographic data is broadcasted. bool m_bool_queue ; /// This tells that the subthread must leave at the first opportunity. bool m_kml_must_leave; #endif pthread_mutex_t m_mutex_write ; typedef std::list< PlacemarkT > PlacemarkListT ; PlacemarkListT m_queues[ nb_categories ]; /// Called in a subthread. Woken up by a timed condition to save content to a KML file. void * ThreadFunc(void) { MilliSleep(2000); // Give time enough to load data. int r ; // This is normally the default behaviour. r = pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, NULL ); if( r != 0 ) { LOG_ERROR("pthread_setcancelstate %s", strerror(errno) ); return NULL; } r = pthread_setcanceltype( PTHREAD_CANCEL_DEFERRED, NULL ); if( r != 0 ) { LOG_ERROR("pthread_setcanceltype %s", strerror(errno) ); return NULL; } int refresh_delay = m_refresh_interval ; // Endless loop until end of program, which cancels this subthread. for(;;) { #ifdef FLDIGI_KML_CONDITION_VARIABLE struct timespec tmp_tim; { guard_lock myGuard( &m_mutex_write ); // It does not need to be very accurate. tmp_tim.tv_sec = time(NULL) + refresh_delay; tmp_tim.tv_nsec = 0 ; //LOG_INFO("About to wait %d seconds", refresh ); r = pthread_cond_timedwait( &m_cond_queue, &m_mutex_write, &tmp_tim ); if( ( r != ETIMEDOUT ) && ( r != 0 ) ) { LOG_ERROR("pthread_cond_timedwait %s d=%d", strerror(errno), m_refresh_interval ); return (void *)"Error in pthread_cond_timed_wait"; } #else /// On the platforms where pthread_cond_timedwait has problems, everything behaves // as if there was a timeout when data is saved. refresh_delay is never changed. for( int i = 0; i < refresh_delay; ++i ) { MilliSleep( 1000 ); if( m_kml_must_leave ) { LOG_INFO("Exit flag detected. Leaving"); return (void *)"Exit flag detected"; } } { guard_lock myGuard( &m_mutex_write ); r = m_bool_queue ? ETIMEDOUT : 0 ; m_bool_queue = false; #endif // Except if extremely slow init, the object should be ready now: Files loaded etc... if( ! m_loaded ) { static int nb_retries = 3 ; if( nb_retries == 0 ) { static const char * error_message = "KML server could not start. Leaving"; LOG_ERROR("%s", error_message ); return (void *)error_message ; } --nb_retries ; LOG_INFO("KML server not ready yet. Cnt=%d. Restarting.",nb_retries); MilliSleep(1000); // Give time to load data. continue ; } // We might have missed the condition signal so a quick check will not do any harm. for( size_t i = 0; i < nb_categories; ++i ) { PlacesMapT *ptrMap = m_placemarks.FindCategory( categories[i] ); if( ptrMap == NULL ) { LOG_INFO("Category %s undefined", categories[i] ); continue; } // TODO: If there are contention problems, internally swap the queue // with a fresh empty one. ptrMap->FlushQueue( m_merge_dist ); } LOG_INFO("Releasing lock" ); } if( r == ETIMEDOUT ) { //LOG_INFO("Saving after wait=%d", refresh ); bool wasSaved = RewriteKmlFileFull(); // Maybe a user process must be created to process these KML files. if(wasSaved) { SpawnCommand(); } // Reset the interval to the initial value. refresh_delay = m_refresh_interval ; #ifdef FLDIGI_KML_CONDITION_VARIABLE } else { refresh_delay = tmp_tim.tv_sec - time(NULL); if( refresh_delay <= 0 ) refresh_delay = 1 ; //LOG_INFO("Interrupted when waiting. Restart with wait=%d", refresh ); #endif } } // Endless loop. return NULL ; } // ThreadFunc /// The C-style function called by pthread. static void * ThreadFunc( void * ptr ) { return static_cast< KmlSrvImpl *>(ptr)->ThreadFunc(); }; public: /// When setting or changing core parameters. void InitParams( const std::string & kml_command, const std::string & kml_dir, double kml_merge_distance, int kml_retention_delay, int kml_refresh_interval, int kml_balloon_style) try { /// The thread should NOT access anything at this moment. guard_lock myGuard( &m_mutex_write ); /// If the string is empty, no command is executed. m_command = kml_command; strtrim( m_command ); m_merge_dist = kml_merge_distance ; m_retention_delay = kml_retention_delay ; static const int min_refresh = 10 ; if( kml_refresh_interval < min_refresh ) { LOG_WARN("Refresh interval too small %d minimum is %d", kml_refresh_interval, min_refresh ); kml_refresh_interval = min_refresh ; } m_refresh_interval = kml_refresh_interval ; m_balloon_style = kml_balloon_style ; LOG_INFO("dir=%s merge_distance=%lf retention_delay=%d refresh_interval=%d balloon_style=%d", kml_dir.c_str(), kml_merge_distance, kml_retention_delay, kml_refresh_interval, kml_balloon_style ); m_kml_dir = kml_dir ; /// This enforces that the directory name always ends with a slash. if( m_kml_dir[ m_kml_dir.size() - 1 ] != '/' ) m_kml_dir += '/' ; const char * resdir = create_directory( m_kml_dir.c_str() ); if ( resdir ) { throw std::runtime_error( strformat( "Cannot create %s:%s", m_kml_dir.c_str(), resdir ) ); } CreateMainKmlFile(); CopyStyleFileIfNotExists(); } catch (const std::exception & exc) { // We assume that the calling program has no try/catch handler. LOG_ERROR("Caught exception:%s", exc.what() ); } catch (...) { LOG_ERROR("Caught unknown exception"); } virtual void ReloadKmlFiles() { /// The thread should NOT access anything at this moment. guard_lock myGuard( &m_mutex_write ); // This loads placemarks without the subthread, because it is simpler. for( size_t i = 0; i < nb_categories; ++i ) { try { ReloadSingleKmlFile( categories[i] ); } catch( const std::exception & exc ) { LOG_ERROR("Category %s. Caught %s", categories[i], exc.what() ); } } // Now the object is usable. Theoretically should be protected by a mutex. LOG_DEBUG("Object ready"); /// Even if an exception was thrown when loading the previous file, it does not /// prevent to overwrite the old files with new and clean ones. m_loaded = true ; } /// Invalid values everywhere, intentionnaly. KmlSrvImpl() : m_loaded(false) , m_pid_command(-1) , m_merge_dist(-1.0) , m_retention_delay(-1) , m_refresh_interval(-1) , m_balloon_style(0) { LOG_DEBUG("Creation"); #ifdef FLDIGI_KML_CONDITION_VARIABLE pthread_cond_init( &m_cond_queue, NULL ); #else m_bool_queue = false; m_kml_must_leave = false; #endif pthread_mutex_init( &m_mutex_write, NULL ); /// TODO: Add this thread to the other fldigi threads stored in cbq[]. if( pthread_create( &m_writer_thread, NULL, ThreadFunc, this ) ) { /// It is not urgent because this does not interact with the main thread. LOG_ERROR("pthread_create %s", strerror(errno) ); } } /** We cannot use KML updates with a local file: * "I want to know if it exists any solution to put relative paths in a * targetHref to load upload files in a directory in my computer simply * without any server running." * "Unfortunately, no, the security restrictions around <Update> prevent * this explicitly." */ /// iconNam: wmo automated fixed other dart buoy oilrig tao void Broadcast( const std::string & category, time_t evtTim, const CoordinateT::Pair & refCoo, double altitude, const std::string & kmlNam, const std::string & styleNam, const std::string & descrTxt, const CustomDataT & custDat ) { /// Hyphen: No idea why, but the string "10-meter discus buoy:W GULF 207 NM " just displays as "10-" std::string tmpKmlNam = strreplace( kmlNam, "-", " "); PlacemarkT currPM( refCoo, altitude, styleNam, tmpKmlNam ); currPM.AppendEvent( evtTim, descrTxt, custDat ); guard_lock myGuard( &m_mutex_write ); ++KmlServer::m_nb_broadcasts; PlacesMapT *ptrMap = m_placemarks.FindCategory( category ); if(ptrMap == NULL ) { LOG_ERROR("Category %s undefined", category.c_str()); } ptrMap->Enqueue( tmpKmlNam, currPM ); #ifdef FLDIGI_KML_CONDITION_VARIABLE pthread_cond_signal( &m_cond_queue ); #else m_bool_queue = true; #endif LOG_INFO("'%s' sz=%d time=%s nb_broad=%d m_merge_dist=%lf", descrTxt.c_str(), (int)ptrMap->size(), KmlTimestamp(evtTim).c_str(), KmlServer::m_nb_broadcasts,m_merge_dist ); } /// It flushes the content to disk. ~KmlSrvImpl() { { /// This will not be killed in the middle of the writing. LOG_INFO("Cancelling writer thread"); guard_lock myGuard( &m_mutex_write ); #ifdef FLDIGI_KML_CONDITION_VARIABLE LOG_INFO("Cancelling subthread"); int r = pthread_cancel( m_writer_thread ); if( r ) { LOG_ERROR("pthread_cancel %s", strerror(errno) ); return ; } #else LOG_INFO("Setting exit flag."); m_kml_must_leave = true ; #endif } LOG_INFO("Joining subthread"); void * retPtr; int r = pthread_join( m_writer_thread, &retPtr ); if( r ) { LOG_ERROR("pthread_join %s", strerror(errno) ); return ; } const char * msg = (retPtr == NULL) ? "Null" : (retPtr == PTHREAD_CANCELED) ? "Canceled thread" : static_cast<const char *>(retPtr); LOG_INFO("Thread stopped. Message:%s", msg ); /// Here we are sure that the subthread is stopped. The subprocess is not called. RewriteKmlFileFull(); #ifdef FLDIGI_KML_CONDITION_VARIABLE pthread_cond_destroy( &m_cond_queue ); #endif pthread_mutex_destroy( &m_mutex_write ); } /// Empties the generated files. void Reset(void) { for( size_t i = 0; i < nb_categories; ++i ) { std::cout << "reset: " << categories[i] << std::endl; CreateNewKmlFile(categories[i]); } ResetCounter(); } /// This is called when KML files are saved, or on demand from the configuration tab. void SpawnCommand() { if( m_command.empty() ) return ; /** This stores the process id so the command is not restarted if still running. This allows to start for example Google Earth only once. But this allows also to run GPS_Babel for each new set of files, as soon as they are created. */ int is_proc_still_running = test_process( m_pid_command ); if( is_proc_still_running == -1 ) return ; if( ( m_pid_command <= 0 ) || ( is_proc_still_running == 0 ) ) { m_pid_command = fork_process( m_command.c_str() ); LOG_INFO("%s: Pid=%d Command=%s", __FUNCTION__, m_pid_command, m_command.c_str() ); } } }; // KmlSrvImpl /// Singleton. It must be destroyed at the end. static KmlServer * g_inst = NULL; static KmlSrvImpl * Pointer() { if( NULL == g_inst ) { g_inst = new KmlSrvImpl(); } KmlSrvImpl * p = dynamic_cast< KmlSrvImpl * >( g_inst ); if( p == NULL ) { LOG_ERROR("Null pointer"); throw std::runtime_error("KmlServer not initialised"); } return p ; } std::string KmlServer::Tm2Time( time_t tim ) { char bufTm[40]; tm tmpTm; gmtime_r( &tim, & tmpTm ); snprintf( bufTm, sizeof(bufTm), "%4d-%02d-%02d %02d:%02d", tmpTm.tm_year + 1900, tmpTm.tm_mon + 1, tmpTm.tm_mday, tmpTm.tm_hour, tmpTm.tm_min ); return bufTm; } /// Returns current time. std::string KmlServer::Tm2Time( ) { return Tm2Time( time(NULL) ); } /// One singleton for everyone. KmlServer * KmlServer::GetInstance(void) { return Pointer(); } /// This creates a process running the user command. void KmlServer::SpawnProcess() { Pointer()->SpawnCommand(); } /// Called by thr main program, clean exit. void KmlServer::Exit(void) { // We assume that the calling program has no try/catch handler. LOG_INFO("Exiting"); try { KmlServer * pKml = Pointer(); if( pKml ) { delete pKml; } } catch (const std::exception & exc) { LOG_ERROR("Caught exception:%s",exc.what() ); } catch (...) { LOG_ERROR("Caught unknown exception"); } }
60,030
C++
.cxx
1,562
34.266325
122
0.646891
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,267
ssb.cxx
w1hkj_fldigi/src/ssb/ssb.cxx
// ---------------------------------------------------------------------------- // ssb.cxx -- ssb modem // // Copyright (C) 2010 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <config.h> #include "ssb.h" #include "modem.h" #include "digiscope.h" #include "fl_digi.h" #include "debug.h" #define ssb_bw 4 void ssb::tx_init() { } void ssb::rx_init() { put_MODEstatus(mode); } void ssb::init() { modem::init(); rx_init(); set_scope_mode(Digiscope::BLANK); } ssb::~ssb() { } void ssb::restart() { set_bandwidth(ssb_bw); } ssb::ssb() { mode = MODE_SSB; samplerate = 44100; cap &= ~CAP_TX; restart(); } // dummy process int ssb::rx_process(const double *buf, int len) { return 0; } //===================================================================== // ssb transmit // dummy process //===================================================================== int ssb::tx_process() { return -1; }
1,654
C++
.cxx
68
22.970588
79
0.577241
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,268
XmlRpcSource.h
w1hkj_fldigi/src/xmlrpcpp/XmlRpcSource.h
// ---------------------------------------------------------------------------- // // flxmlrpc Copyright (c) 2015 by W1HKJ, Dave Freese <iam_w1hkj@w1hkj.com> // // XmlRpc++ Copyright (c) 2002-2008 by Chris Morley // // This file is part of fldigi // // flxmlrpc is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _XMLRPCSOURCE_H_ #define _XMLRPCSOURCE_H_ #if defined(_MSC_VER) # pragma warning(disable:4786) // identifier was truncated in debug info #endif #include "XmlRpcSocket.h" namespace XmlRpc { //! Proxy for Ssl data to avoid including headers here. struct SslProxy; //! An RPC source represents a file descriptor to monitor class XmlRpcSource { public: //! Constructor //! @param fd The socket file descriptor to monitor. //! @param deleteOnClose If true, the object deletes itself when close is called. XmlRpcSource(XmlRpcSocket::Socket fd = XmlRpcSocket::Invalid, bool deleteOnClose = false); //! Destructor virtual ~XmlRpcSource(); //! Return the file descriptor being monitored. XmlRpcSocket::Socket getfd() const { return _fd; } //! Specify the file descriptor to monitor. void setfd(XmlRpcSocket::Socket fd) { _fd = fd; } //! Return whether the file descriptor should be kept open if it is no longer monitored. bool getKeepOpen() const { return _keepOpen; } //! Specify whether the file descriptor should be kept open if it is no longer monitored. void setKeepOpen(bool b=true) { _keepOpen = b; } //! Return whether ssl is enabled. bool getSslEnabled() const { return _sslEnabled; } //! Specify whether to enable ssl. Use getSslEnabled() to verify that Ssl is available. void setSslEnabled(bool b=true); //! Close the owned fd. If deleteOnClose was specified at construction, the object is deleted. virtual void close(); //! Return true to continue monitoring this source virtual unsigned handleEvent(unsigned eventType) = 0; protected: // Execution processing helpers virtual bool doConnect(); //! Read text from the source. Returns false on error. bool nbRead(std::string& s, bool *eof); //! Write text to the source. Returns false on error. bool nbWrite(std::string const& s, int *bytesSoFar); private: // Socket. This is an int for linux/unix, and unsigned on win32, and unsigned __int64 on win64. // Casting to int/long/unsigned on win64 is a bad idea. XmlRpcSocket::Socket _fd; // In the server, a new source (XmlRpcServerConnection) is created // for each connected client. When each connection is closed, the // corresponding source object is deleted. bool _deleteOnClose; // In the client, keep connections open if you intend to make multiple calls. bool _keepOpen; // Enable use of SSL bool _sslEnabled; // SSL data SslProxy *_ssl; }; } // namespace XmlRpc #endif //_XMLRPCSOURCE_H_
3,346
C++
.h
74
41.405405
99
0.68319
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,272
XmlRpcClient.h
w1hkj_fldigi/src/xmlrpcpp/XmlRpcClient.h
// ---------------------------------------------------------------------------- // // flxmlrpc Copyright (c) 2015 by W1HKJ, Dave Freese <iam_w1hkj@w1hkj.com> // // XmlRpc++ Copyright (c) 2002-2008 by Chris Morley // // This file is part of fldigi // // flxmlrpc is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _XMLRPCCLIENT_H_ #define _XMLRPCCLIENT_H_ #if defined(_MSC_VER) # pragma warning(disable:4786) // identifier was truncated in debug info #endif #include <string> #include "XmlRpcDispatch.h" #include "XmlRpcSource.h" namespace XmlRpc { extern std::string pname; extern void set_pname(std::string pn); // Arguments and results are represented by XmlRpcValues class XmlRpcValue; //! A class to send XML RPC requests to a server and return the results. class XmlRpcClient : public XmlRpcSource { public: //! Construct a client to connect to the server at the specified host:port address //! @param host The name of the remote machine hosting the server, eg "myserver.mycompany.com" //! @param port The port on the remote machine where the server is listening //! @param uri An optional string to be sent as the URI in the HTTP GET header //! Note that the host is not a URL, do not prepend "http://" or other protocol specifiers. XmlRpcClient(const char* host, int port, const char* uri=0); //! Construct a client to connect to the server at the specified host:port address including HTTP authentication //! @param host The name of the remote machine hosting the server //! @param port The port on the remote machine where the server is listening //! @param login The username passed to the server //! @param pass The password passed to the server //! @param uri An optional string to be sent as the URI in the HTTP GET header XmlRpcClient(const char* host, int port, const char* login, const char* password, const char* uri=0); //! Destructor virtual ~XmlRpcClient(); //! Execute the named procedure on the remote server. //! @param method The name of the remote procedure to execute //! @param params An array of the arguments for the method //! @param result The result value to be returned to the client //! @param timeoutSeconds Seconds to wait for a response (defaults to forever) //! @return true if the request was sent and a result received //! (although the result might be a fault). //! //! Currently this is a synchronous (blocking) implementation (execute //! does not return until it receives a response or an error). Use isFault() //! to determine whether the result is a fault response. bool execute(const char* method, XmlRpcValue const& params, XmlRpcValue& result, double timeoutSeconds = -1); //! Returns true if the result of the last execute() was a fault response. bool isFault() const { return _isFault; } //! Return the host name of the server const char* const host() const { return _host.c_str(); } //! Return the port int port() const { return _port; } //! Return the URI const char* const uri() const { return _uri.c_str(); } // XmlRpcSource interface implementation //! Close the connection virtual void close(); //! Handle server responses. Called by the event dispatcher during execute. //! @param eventType The type of event that occurred. //! @see XmlRpcDispatch::EventType virtual unsigned handleEvent(unsigned eventType); protected: // Execution processing helpers virtual bool doConnect(); virtual bool setupConnection(); virtual bool generateRequest(const char* method, XmlRpcValue const& params); virtual std::string generateHeader(std::string const& body); virtual bool writeRequest(); virtual bool readHeader(); virtual bool parseHeader(); virtual bool readResponse(); virtual bool parseResponse(XmlRpcValue& result); // Possible IO states for the connection enum ClientConnectionState { NO_CONNECTION, CONNECTING, WRITE_REQUEST, READ_HEADER, READ_RESPONSE, IDLE }; ClientConnectionState _connectionState; // Server location std::string _host; std::string _uri; int _port; // Login information for HTTP authentication std::string _login; std::string _password; // The xml-encoded request, http header of response, and response xml std::string _request; std::string _header; std::string _response; // Number of times the client has attempted to send the request int _sendAttempts; // Number of bytes of the request that have been written to the socket so far int _bytesWritten; // True if we are currently executing a request. If you want to multithread, // each thread should have its own client. bool _executing; // True if the server closed the connection bool _eof; // True if a fault response was returned by the server bool _isFault; // Number of bytes expected in the response body (parsed from response header) int _contentLength; // Event dispatcher XmlRpcDispatch _disp; }; // class XmlRpcClient } // namespace XmlRpc #endif // _XMLRPCCLIENT_H_
5,641
C++
.h
117
43.91453
116
0.697229
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
751,274
XmlRpcSocket.h
w1hkj_fldigi/src/xmlrpcpp/XmlRpcSocket.h
// ---------------------------------------------------------------------------- // // flxmlrpc Copyright (c) 2015 by W1HKJ, Dave Freese <iam_w1hkj@w1hkj.com> // // XmlRpc++ Copyright (c) 2002-2008 by Chris Morley // // This file is part of fldigi // // flxmlrpc is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _XMLRPCSOCKET_H_ #define _XMLRPCSOCKET_H_ #if defined(_MSC_VER) # pragma warning(disable:4786) // identifier was truncated in debug info #endif #include <string> namespace XmlRpc { //! A platform-independent socket API. class XmlRpcSocket { public: // On windows, a socket is an unsigned int large enough to hold a ptr // This should match the definition of SOCKET in winsock2.h #if defined(_WINDOWS) # if defined(_WIN64) typedef unsigned __int64 Socket; # else typedef unsigned int Socket; # endif #else typedef int Socket; #endif //! An invalid socket constant. static const Socket Invalid = (Socket) -1; //! Creates a stream (TCP) socket. Returns XmlRpcSocket::Invalid on failure. static Socket socket(); //! Closes a socket. static void close(Socket socket); //! Sets a stream (TCP) socket to perform non-blocking IO. Returns false on failure. static bool setNonBlocking(Socket socket); // The next four methods are appropriate for servers. //! Allow the port the specified socket is bound to to be re-bound immediately so //! server re-starts are not delayed. Returns false on failure. static bool setReuseAddr(Socket socket); //! Bind to a specified port static bool bind(Socket socket, int port); //! Set socket in listen mode static bool listen(Socket socket, int backlog); //! Accept a client connection request static Socket accept(Socket socket); //! Connect a socket to a server (from a client) static bool connect(Socket socket, std::string& host, int port); //! Get the port of a bound socket static int getPort(Socket socket); //! Returns true if the last error was not a fatal one (eg, EWOULDBLOCK) static bool nonFatalError(); //! Returns last errno static int getError(); //! Returns message corresponding to last error static std::string getErrorMsg(); //! Returns message corresponding to error static std::string getErrorMsg(int error); }; } // namespace XmlRpc #endif
2,810
C++
.h
70
36.585714
88
0.67944
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
751,281
flarqenv.h
w1hkj_fldigi/src/flarq-src/include/flarqenv.h
#ifndef flarqenv_h_ #define flarqenv_h_ #include <string> extern std::string option_help, version_text, build_text; void generate_option_help(void); void generate_version_text(void); int parse_args(int argc, char** argv, int& idx); void set_platform_ui(void); void setup_signal_handlers(void); #endif // flarqenv_h_
320
C++
.h
10
30.6
57
0.771242
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,282
arqdialogs.h
w1hkj_fldigi/src/flarq-src/include/arqdialogs.h
// generated by Fast Light User Interface Designer (fluid) version 1.0305 #ifndef arqdialogs_h #define arqdialogs_h #include <FL/Fl.H> #include "flinput2.h" #include "flslider2.h" #include "combo.h" #include <FL/Fl_Double_Window.H> #include <FL/Fl_Menu_Bar.H> extern Fl_Menu_Bar *mnu; extern void ComposeMail(); extern void cbMenuConfig(); extern void cbMenuAbout(); #include <FL/Fl_Group.H> #include <FL/Fl_Button.H> extern Fl_Button *btnCONNECT; extern Fl_Input2 *txtURCALL; #include <FL/Fl_Light_Button.H> extern Fl_Light_Button *btnBEACON; extern Fl_Input2 *txtBeaconing; #include <FL/Fl_Box.H> extern Fl_Box *indCONNECT; extern Fl_Input2 *txtState; #include "FTextView.h" extern FTextView *txtARQ; extern Fl_Input2 *txtStatus; extern Fl_Input2 *txtStatus2; #include <FL/Fl_Progress.H> extern Fl_Progress *prgStatus; extern Fl_Button *btnClearText; extern FTextView *txtRX; extern Fl_Input2 *txtTX; extern Fl_Button *btnSendTalk; Fl_Double_Window* arq_dialog(); extern Fl_Menu_Item menu_mnu[]; #define mnu_nbems_files (menu_mnu+1) #define mnuExit (menu_mnu+2) #define mnuSend (menu_mnu+4) #define mnuSendEmail (menu_mnu+5) #define mnuSendText (menu_mnu+6) #define mnuSendImage (menu_mnu+7) #define mnuSendBinary (menu_mnu+8) #define mnuCompose (menu_mnu+10) #define mnuConfig (menu_mnu+11) #define mnuHelp (menu_mnu+12) #define mnuHowTo (menu_mnu+13) #define mnuAbout (menu_mnu+14) extern Fl_Input2 *txtMyCall; extern Fl_Input2 *txtBEACONTXT; extern Fl_Spinner2 *spnRetries; extern Fl_Spinner2 *spnWaitTime; extern Fl_Spinner2 *spnTimeout; extern Fl_Spinner2 *spnTxDelay; extern Fl_Spinner2 *spnBcnInterval; extern Fl_Spinner2 *spnIDtimer; extern Fl_ComboBox *choiceBlockSize; extern Fl_Button *btnOK; #include <FL/Fl_Check_Button.H> extern Fl_Check_Button *btn_restart_beacon; Fl_Double_Window* arq_configure(); #include "table.h" extern Table *tblOutgoing; extern void sendCancel(); extern Fl_Button *send_Cancel; #include <FL/Fl_Return_Button.H> extern void sendOK(); extern Fl_Return_Button *send_OK; Fl_Double_Window* arq_SendSelect(); extern Fl_Input2 *inpMailFrom; extern Fl_Input2 *inpMailTo; extern Fl_Input2 *inpMailSubj; #include "F_Edit.h" extern F_Edit *txtMailText; extern void cb_OpenComposeMail(); extern Fl_Button *btnOpenComposedMail; extern void cb_ClearComposer(); extern Fl_Button *btnClearComposer; extern void cb_UseTemplate(); extern Fl_Button *btnUseTemplate; extern void cb_CancelComposeMail(); extern Fl_Button *btnCancelComposedMail; extern void cb_SaveComposeMail(); extern Fl_Button *btnSaveComposedMail; Fl_Double_Window* arq_composer(); #endif
2,581
C++
.h
85
29.352941
73
0.798397
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,284
xml_server.h
w1hkj_fldigi/src/flarq-src/include/xml_server.h
// --------------------------------------------------------------------- // // xml_server.h, a part of flarq // // Copyflarqht (C) 2016 // Dave Freese, W1HKJ // // This library is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with the program; if not, write to the // // Free Software Foundation, Inc. // 51 Franklin Street, Fifth Floor // Boston, MA 02110-1301 USA. // // --------------------------------------------------------------------- #ifndef XML_SERVER_H #define XML_SERVER_H #include <fstream> #include <vector> #include <string> #include <math.h> #ifndef WIN32 #include <sys/ipc.h> #include <sys/msg.h> #include <sys/shm.h> #endif #include "status.h" #include <FL/fl_show_colormap.H> #include <FL/fl_ask.H> extern void start_xml_server(int port = 12345); extern void exit_server(); extern bool xml_rx_text_ready; #endif
1,379
C++
.h
43
30.883721
72
0.658886
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,285
flarq.h
w1hkj_fldigi/src/flarq-src/include/flarq.h
#ifndef FLARQ_H #define FLARQ_H #include <string> #define SOHCOUNT 10 extern void arqBEACON(); extern void arqCLOSE(); extern void arqCONNECT(); extern void cbMenuAbout(); extern void cbMenuConfig(); extern void cbSetConfig(); extern void closeConfig(); extern void sendCancel(); extern void sendOK(); extern void cb_SortByDate(); extern void cb_SortByTo(); extern void cb_SortBySubj(); extern void abortTransfer(); extern void cbAbort(); extern void cbClearText(); extern void testDirectory(std::string); extern void cbSendTalk(); extern void cbClearTalk(); extern void help_cb(); extern void open_nbems_file_folder(); extern void sendEmailFile(); extern void sendAsciiFile(); extern void sendImageFile(); extern void sendBinaryFile(); extern void changeMyCall(const char *); extern void changeBeaconText(const char *); extern std::string HomeDir; extern std::string NBEMS_dir; extern std::string ARQ_dir; extern std::string ARQ_files_dir; extern std::string ARQ_recv_dir; extern std::string ARQ_send_dir; extern std::string ARQ_mail_dir; extern std::string ARQ_mail_in_dir; extern std::string ARQ_mail_out_dir; extern std::string ARQ_mail_sent_dir; extern std::string WRAP_dir; extern std::string WRAP_recv_dir; extern std::string WRAP_send_dir; extern std::string WRAP_auto_dir; extern std::string ICS_dir; extern std::string ICS_msg_dir; extern std::string ICS_tmp_dir; extern std::string MyCall; extern std::string InFolder; extern std::string OutFolder; extern std::string MailInFolder; extern std::string MailOutFolder; extern std::string MailSentFolder; extern std::string Logfile; extern std::string beacontext; extern int exponent; extern int txdelay; extern int iretries; extern long iwaittime; extern long itimeout; extern int bcnInterval; extern int idtimer; extern bool restart_beacon; extern void cb_idtimer(); // used by xmlrpc interface extern int arqstate; extern bool sendingfile; extern bool rxTextReady; extern bool rxARQfile; extern std::string txtarqload; extern void cb_SaveComposeMail(); extern void cb_CancelComposeMail(); extern void cb_UseTemplate(); extern void cb_OpenComposeMail(); extern void ComposeMail(); extern void send_xml_text(std::string, std::string); #endif
2,228
C++
.h
77
27.792208
52
0.8
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,286
arq.h
w1hkj_fldigi/src/flarq-src/include/arq.h
#ifndef arq_H #define arq_H // ---------------------------------------------------------------------------- // arq module arq.h // Copyright (c) 2007-2009, Dave Freese, W1HKJ // // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // link layer spec for fldigi_arq // // generic Frame format: // <SOH>dcl[info])12EF<EOT|SOH> // | ||| | | | // | ||| | | +--ASCII <SOH> or <EOT> (0x04) character // | ||| | +-------checksum (4xAlphaNum) // | ||| +-------------Payload (1 ... 2^N chars, N 4, 5, 6, 7 8) // | ||+---------------Block type // | |+----------------Stream id // | +-----------------Protocol version number // +---------------------ASCII <SOH> (0x01) character // BLOCKSIZE = 2^n // #include <string> #include <stdio.h> #include <stdlib.h> #include <iostream> #include <vector> #include <list> #include <cctype> #include <FL/Fl.H> extern int idtimer; #define DEBUG #define arq_Version "arq 0.1" //===================================================================== // following Block Types are defined in K9PS ARQ Protocol specification #define IDENT 'i' #define CONREQ 'c' #define CONACK 'k' #define REFUSED 'r' #define DISREQ 'd' #define STATUS 's' #define POLL 'p' #define FMTFAIL 'f' // following Block Types are extensions to the K9PS specification #define _ABORT 'a' #define _ACKABORT 'o' #define _DISACK 'b' #define _UNPROTO 'u' #define _TALK 't' //===================================================================== #define SOH 0X01 #define STX 0X02 #define ACK 0X06 #define SUB 0X1A #define EOT 0X04 //===================================================================== //ARQ defaults #define MAXHEADERS 8 // Max. number of missing blocks #define MAXCOUNT 64 // DO NOT CHANGE THIS CONSTANT #define EXPONENT 7 // Bufferlength = 2 ^ EXPONENT = 128 //===================================================================== //link timing defaults #define RETRIES 5 #define RETRYTIME 10000 // # milliseconds between retries #define TXDELAY 500 // # milliseconds from xmt to rcv #define TIMEOUT 60000 // # milliseconds before TIMED OUT #define ARQLOOPTIME 100 // # msec for loop timing //===================================================================== //link states enum LINK_STATES { DOWN = 0, TIMEDOUT, ABORT, ARQ_CONNECTING, ARQ_CONNECTED, WAITING, WAITFORACK, DISCONNECT, DISCONNECTING, ABORTING, STOPPED }; //#define DOWN 0 //#define TIMEDOUT 1 //#define ABORT 3 //#define ARQ_CONNECTING 4 //#define ARQ_CONNECTED 5 //#define WAITING 6 //#define WAITFORACK 7 //#define DISCONNECT 8 //#define DISCONNECTING 9 //#define ABORTING 10 #define SENDING 0x80; //===================================================================== extern char *ARQASCII[]; // crc 16 cycle redundancy check sum for data block integrity class Ccrc16 { private: unsigned int crcval; char ss[5]; public: Ccrc16() { crcval = 0xFFFF; } ~Ccrc16() {}; void reset() { crcval = 0xFFFF;} unsigned int val() {return crcval;} std::string sval() { snprintf(ss, sizeof(ss), "%04X", crcval); return ss; } void update(char c) { crcval ^= c & 255; for (int i = 0; i < 8; ++i) { if (crcval & 1) crcval = (crcval >> 1) ^ 0xA001; else crcval = (crcval >> 1); } } unsigned int crc16(char c) { update(c); return crcval; } unsigned int crc16(std::string s) { reset(); for (size_t i = 0; i < s.length(); i++) update(s[i]); return crcval; } std::string scrc16(std::string s) { crc16(s); return sval(); } }; // text block; block # and std::string of text class cTxtBlk { private: int number; std::string txt; public: cTxtBlk() {number = -1; txt = "";} cTxtBlk(int n, std::string text) { number = n; txt = text; } ~cTxtBlk() {} void nbr(int n) { number = n;} int nbr() { return number; } std::string text() { return txt; } void text(std::string t) { txt = t;} bool operator <(const cTxtBlk &b)const { return number < b.number; } bool operator ==(const cTxtBlk b)const { return number == b.number; } }; class arq { private: bool arqstop; std::string MyCall; std::string UrCall; std::string Header; std::string Frame; std::string Payload; std::string rcvPayload; std::string logfile; char MyStreamID; char UrStreamID; char MyBlockLengthChar; char UrBlockLengthChar; char BlockNumberChar; char fID; int blknbr; // queues // std::string TxTextQueue; // Text out to mail engine std::string TxPlainTextQueue; // plain text transmit queu std::string RxTextQueue; // Text in from mail engine std::string RxFrameQueue; char lastRxChar; bool TXflag; int Bufferlength; int maxheaders; int exponent; // status variables int payloadlength; // Average length of payload received int totalRx; // total number of frames received int totalTx; // total number of frames transmitted int nbrbadRx; // number with crc errors int nbrbadTx; // total number of repeats required // int max_idle; // Dynamic timing slot initial value int SessionNumber; bool PollOK; // used for status handshake bool wrappedFlag; // set true if missing blocks bit count // has wrapped around int retrytime; int RetryTime; int retries; int Retries; int timeout; int Timeout; int tx2txdelay; int TxDelay; int loopcount; int _idtimer; int baseRetryTime; int baseTimeout; int baseRetries; bool immediate; bool primary; Ccrc16 framecrc; // My status int Firstsent; // First Header I sent last turn int LastHeader; // Last Header I sent last turn int Lastqueued; // Last Header in static send queue int EndHeader; // Last I received o.k. int GoodHeader; // Last Header received consecutively int blkcount; int Blocks2Send; // number of blocks at beginning of Tx std::vector<int> MyMissing; // missing Rx blocks std::string MissingRxBlocks; std::vector<cTxtBlk> RxPending; // RxPending Rx blocks (not consecutive) std::list<cTxtBlk> TxBlocks; // fifo of transmit buffers std::list<cTxtBlk> TxMissing; // fifo of sent; RxPending Status report std::list<cTxtBlk> TxPending; // fifo of transmitted buffers pending print // Ur status int UrGoodHeader; // Other station's Good Header int UrLastHeader; // Other station's Header last sent int UrEndHeader; // Other station's last received Header std::vector<int> UrMissing; // Other station's missing Headers int LinkState; // status of ARQ link int Sending; bool bABORT; // Link quality for sending *** used for testing only !! *** // double sendquality; void reset(); void resetTx(); void resetRx(); int rtry(); void setBufferlength(); void checkblocks(); std::string upcase(std::string s); void newblocknumber(); void newHeader(); void IdHeader(); void UnkHeader(); void connectFrame(); void disackFrame(); void ackFrame(); void ttyconnectFrame(); void ttyackFrame(); void pollFrame(); void identFrame(); void pingFrame(); void statFrame(); void disconnectFrame(); void abortFrame(); void ackAbortFrame(); void beaconFrame(std::string txt); void textFrame(cTxtBlk block); void talkFrame(std::string txt); void addToTxQue(std::string s); void sendblocks(); void transmitdata(); std::string frame() {return Frame;} bool isUrcall(); void parseIDENT(); void parseCONREQ(); void parseCONACK(); void parseREFUSED(); void parseDISREQ(); void parseDISACK(); void parseABORT(); void parseACKABORT(); void parseUNPROTO(); void parseSTATUS(); void parsePOLL(); void parseDATA(); void parseTALK(); int parseFrame(std::string txt); // external functions called by arq class void (*sendfnc)(const std::string& s); bool (*getc1)(char &); void (*rcvfnc)(); void (*printRX)(std::string s); void (*printTX)(std::string s); void (*printRX_DEBUG)(std::string s); void (*printTX_DEBUG)(std::string s); void (*printTALK)(std::string s); void (*abortfnc)(); void (*disconnectfnc)(); void (*rxUrCall)(std::string s); void (*qualityfnc)(std::string s); void (*printSTATUS)(std::string s, double disptime); public: arq(); ~arq() {}; friend void arqloop(void *me); void start_arq(); void restart_arq(); std::string checksum(std::string &s); void myCall(std::string s) { MyCall = upcase(s);} std::string myCall() { return MyCall;} void urCall(std::string s) { UrCall = s;} std::string urCall() { return UrCall;} void newsession(); void setSendFunc( void (*f)(const std::string& s)) { sendfnc = f;} void setGetCFunc( bool (*f)(char &)) { getc1 = f;} void setRcvFunc( void (*f)()) { rcvfnc = f;} void setPrintRX( void (*f)(std::string s)) { printRX = f;} void setPrintTX( void (*f)(std::string s)) { printTX = f;} void setPrintTALK (void (*f)(std::string s)) {printTALK = f;} void setPrintRX_DEBUG (void (*f)(std::string s)){printRX_DEBUG = f;} void setPrintTX_DEBUG (void (*f)(std::string s)) {printTX_DEBUG = f;} void setPrintSTATUS (void (*f)(std::string s, double disptime)) { printSTATUS = f;} void setMaxHeaders( int mh ) { maxheaders = mh; } void setExponent( int exp ) { exponent = exp; setBufferlength(); } int getExponent() { return (int) exponent;} void setWaitTime( int rtime ) { RetryTime = rtime; baseRetryTime = rtime; } int getWaitTime() { return (int) RetryTime; } void setRetries ( int rtries ) { retries = Retries = baseRetries = rtries; } int getRetries() { return (int) Retries; } void setTimeout ( int tout ) { Timeout = tout; baseTimeout = tout; } int getTimeout() { return (int) Timeout; } int getTimeLeft() { return (int) timeout * ARQLOOPTIME / 1000; } void setTxDelay ( int r2t ) { TxDelay = r2t; } int getTxDelay() { return (int) TxDelay; } int getRetryCount() { return (int)(Retries - retries + 1); } void set_idtimer() { if (idtimer) _idtimer = (idtimer * 60 - 10) * 1000 / ARQLOOPTIME; else _idtimer = (10 * 60 - 10) * 1000 / ARQLOOPTIME; } void setrxUrCall( void (*f)(std::string s)) { rxUrCall = f;} void setQualityValue( void (*f)(std::string s)) { qualityfnc = f;} void setAbortedTransfer( void (*f)()) { abortfnc = f;}; void setDisconnected( void (*f)()) { disconnectfnc = f;}; void rcvChar( char c ); void connect(std::string callsign);//, int blocksize = 6, int retries = 4); void sendblocks( std::string txt ); void sendBeacon (std::string txt); void sendPlainText( std::string txt ); std::string getText() { return RxTextQueue;} void sendText(std::string txt); bool connected() { return (LinkState == ARQ_CONNECTED); } void disconnect(); void abort(); int state() { return (LinkState + Sending);} int TXblocks() { return totalTx;} int TXbad() { return nbrbadTx;} int RXblocks() { return totalRx;} int RXbad() { return nbrbadRx;} double quality() { if (totalTx == 0) return 1.0; return ( 1.0 * (totalTx - nbrbadTx) / totalTx ); } float percentSent() { if (Blocks2Send == 0) return 0.0; if ((TxBlocks.empty() && TxMissing.empty())) return 1.0; return (1.0 * (Blocks2Send - TxBlocks.size() - TxMissing.size()) / Blocks2Send); } bool transferComplete() { if (TxMissing.empty() == false) return false; if (TxBlocks.empty() == false) return false; return true; } }; #endif
11,959
C++
.h
374
29.850267
84
0.652423
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,287
fqueue.h
w1hkj_fldigi/src/qrunner/fqueue.h
// ---------------------------------------------------------------------------- // fqueue.h // // Copyright (C) 2007-2008 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef FQUEUE_H_ #define FQUEUE_H_ #include <stdexcept> #include <cassert> #include "ringbuffer.h" #include "util.h" // #include <iostream> // #include <cstdio> // #include <stacktrace.h> #define FQUEUE_SIZE 2048 #define FIFO_SIZE (FQUEUE_SIZE * 4) class func_base { public: virtual void destroy(bool run) = 0; virtual ~func_base() { } }; template <typename F> class func_wrap : public func_base { public: explicit func_wrap(const F &f_) : f(f_) { } virtual void destroy(bool run) { if (run) f(); this->~func_wrap(); } private: F f; }; class fqueue { typedef ringbuffer<char> fqueue_ringbuffer_t; public: fqueue(size_t count = FQUEUE_SIZE, size_t blocksize_ = 128) : blocksize(blocksize_) { rb = new fqueue_ringbuffer_t(blocksize * count); } ~fqueue() { drop(); delete rb; } bool empty(void) { return rb->read_space() == 0; } bool full(void) { return rb->write_space() == 0; } size_t size(void) { return rb->read_space() / blocksize; } template <class T> bool push(const T& t) { // If we have any space left at all, it will be at least // a blocksize. It will not wrap around the end of the rb. if (unlikely(rb->get_wv(wvec, blocksize) < blocksize)) return false; assert(blocksize >= sizeof(func_wrap<T>)); // we assume a no-throw ctor! new (wvec[0].buf) func_wrap<T>(t); rb->write_advance(blocksize); return true; } bool pop(bool exec = false) { if (rb->get_rv(rvec, blocksize) < blocksize) return false; reinterpret_cast<func_base *>(rvec[0].buf)->destroy(exec); rb->read_advance(blocksize); return true; } bool execute(void) { return pop(true); } size_t drop(void) { size_t n = 0; while (pop(false)) ++n; return n; } protected: fqueue_ringbuffer_t* rb; fqueue_ringbuffer_t::vector_type rvec[2], wvec[2]; size_t blocksize; }; #endif // FQUEUE_H_ // Local Variables: // mode: c++ // c-file-style: "linux" // End:
3,274
C++
.h
107
24.401869
79
0.564168
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,288
blank.h
w1hkj_fldigi/src/blank/blank.h
// ---------------------------------------------------------------------------- // BLANK.h -- BASIS FOR ALL MODEMS // // Copyright (C) 2006 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _BLANK_H #define _BLANK_H #include "trx.h" #include "modem.h" #include "fft.h" #include "filters.h" #include "complex.h" #define BLANKSampleRate 8000 #define SYMLEN 512 #define BLANK_BW 100 #define BUFFLEN 4096 #define SCOPE_DATA_LEN 1024 // lp filter //#define DEC_1 8 //#define FIRLEN_1 256 //#define BW_1 10 // NASA coefficients for viterbi encode/decode algorithms //#define K 7 //#define POLY1 0x6d //#define POLY2 0x4f class BLANK : public modem { protected: double phaseacc; double phaseincr; C_FIR_filter *bandpass; C_FIR_filter *lowpass; C_FIR_filter *hilbert; Cmovavg *moving_avg; sfft *slidingfft; int symlen; // receive double *scope_data; double *inbuf; // transmit int txstate; double *outbuf; unsigned int buffptr; public: BLANK(); ~BLANK(); void init(); void rx_init(); void tx_init(SoundBase *sc); void restart(); int rx_process(const double *buf, int len); int tx_process(); void update_syncscope(); }; #endif
1,912
C++
.h
70
25.771429
79
0.670678
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,289
nanoIO.h
w1hkj_fldigi/src/include/nanoIO.h
// ---------------------------------------------------------------------------- // nanoIO.h -- Interface to Arduino Nano keyer // // Copyright (C) 2018 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _TINYIO_H #define _TINYIO_H #include <math.h> #include <string> #include <cstring> #include <stdio.h> #include <iostream> #include <fstream> #include <sstream> #include <cstdlib> #include <FL/Fl.H> #include "debug.h" #include "fl_digi.h" #include "confdialog.h" #include "status.h" #include "serial.h" #include "qrunner.h" #include "threads.h" #include "FTextRXTX.h" extern bool use_nanoIO; extern bool nanoIO_isCW; extern bool open_nanoIO(); extern void close_nanoIO(); extern bool open_nanoCW(); extern void close_nanoIO(); extern char nano_read_byte(int &); extern std::string nano_readString(); extern void nano_send_char(int c); extern void nano_sendString (const std::string &s); extern void nano_set_baud(int bd); extern void nano_mark_polarity(int v); extern void nano_PTT(int val); extern void nano_cancel_transmit(); extern std::string nano_serial_read(); extern int nano_serial_write(char c); extern void set_nanoIO(); extern void set_nanoCW(); extern void set_nanoWPM(int wpm); extern void set_nano_keyerWPM(int wpm); extern void set_nanoIO_keyer(int indx); extern void set_nano_dash2dot(float wt); extern void nano_CW_query(); extern void nano_help(); extern void nano_CW_save(); extern void nanoCW_tune(int val); extern void set_nanoIO_incr(); extern void nanoIO_set_cw_ptt(); extern void nanoIO_use_pot(); extern void set_nanoIO_min_max(); extern void nanoIO_read_pot(); extern void set_paddle_WPM(int); extern void nanoIO_correction(); extern void nano_serial_flush(); extern void nanoIO_wpm_cal(); #endif
2,474
C++
.h
76
31.289474
79
0.711102
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,290
analysis.h
w1hkj_fldigi/src/include/analysis.h
// ---------------------------------------------------------------------------- // anal.h -- frequency analysis modem // // Copyright (C) 2006 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Modified for data file creation / analysis JC Gibbons N8OBJ 5/14/19 // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _anal_H #define _anal_H #include <string> #include <ctime> #include <stdio.h> #include "complex.h" #include "filters.h" #include "fftfilt.h" #include "modem.h" #define ANAL_SAMPLERATE 8000 #define FILT_LEN 4 //seconds #define PIPE_LEN 120 #define DSP_CNT 1 //seconds #define ANAL_BW 4 class anal : public modem { private: double phaseacc; fftfilt *bpfilt; Cmovavg *ffilt; Cmovavg *afilt; double pipe[PIPE_LEN]; double prevsymbol; cmplx prevsmpl; double fout; double amp; long int wf_freq; double dspcnt; long int passno; int rxcorr; struct timespec start_time; struct tm File_Start_Date; double elapsed; void clear_syncscope(); inline cmplx mixer(cmplx in); int rx(bool bit); double nco(double freq); void writeFile(); void createfilename(); char FileDate [20]; char FileData [20]; public: anal(); ~anal(); void init(); void rx_init(); void tx_init(); void restart(); void start_csv(); void stop_csv(); int rx_process(const double *buf, int len); int tx_process(); std::string analysisFilename; std::string OpenAnalalysisFile; }; #endif
2,099
C++
.h
78
25.192308
79
0.684658
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,291
play.pa.h
w1hkj_fldigi/src/include/play.pa.h
// Pulse Audio header #ifndef PLAY_PA_H #define PLAY_PA_H #include <portaudio.h> #include <stdio.h> #include <string.h> #include <time.h> #include <math.h> #include <string> #include <iostream> #include <unistd.h> #include <sys/time.h> #include <string> #include <sndfile.h> #include <samplerate.h> #include "threads.h" #include "trx.h" #include "ringbuffer.h" #include "filters.h" class cPA_snd_exception : public std::exception { public: cPA_snd_exception(int err_ = 0) : err(err_), msg(std::string("Sound error: ") + err_to_str(err_)) { } cPA_snd_exception(const char* msg_) : err(1), msg(msg_) { } cPA_snd_exception(int err_, const std::string& msg_) : err(err_), msg(msg_) { } virtual ~cPA_snd_exception() throw() { } const char* what(void) const throw() { return msg.c_str(); } int error(void) const { return err; } protected: const char* err_to_str(int e) { return strerror(e); } int err; std::string msg; }; class cPA_exception : public cPA_snd_exception { public: cPA_exception(int err_ = 0) : cPA_snd_exception(err_, std::string("PortAudio error: ") + err_to_str(err_)) { } cPA_exception(const char* msg_) : cPA_snd_exception(msg_) { } protected: const char* err_to_str(int e) { return Pa_GetErrorText(e); } }; class c_portaudio { friend void process_alert(); friend void stream_process(); public: enum { ALERT, MONITOR }; int paError; float *data_frames; //[ MAX_FRAMES_PER_BUFFER * NUM_CHANNELS ]; int ptr; double sr; // sample rate of output sound codec int data_ptr; int num_frames; int state; SRC_STATE * rc; SRC_DATA rcdata; int rc_error; PaStream *stream; PaStreamParameters paStreamParameters; // sndfile interface SF_INFO playinfo; SNDFILE *playback; // transfer buffer from trx loop double *dbuffer; float *fbuffer; float *nubuffer; double b_sr; // sample rate of source monitor stream int b_len; // ringbuffer for streaming audio ringbuffer<float> * monitor_rb; // bandpass filter for streaming audio C_FIR_filter *bpfilt; double flo; double fhi; double gain; public: c_portaudio(); ~c_portaudio(); int open();//void *); void close(); int is_open() { return stream != 0; } void play_buffer(float *buffer, int len, int _sr, int src = ALERT); void play_sound(int *sndbuffer, int len, int _sr); void play_sound(float *sndbuffer, int len, int _sr); void silence(float secs, int _sr); void mon_write(double *buffer, int len, int _sr); void process_mon(); size_t mon_read(float *buffer, int len); void do_play_file(std::string fname); void play_file(std::string fname); void play_mp3(std::string fname); void play_wav(std::string fname); void init_filter(); }; void open_alert_port(c_portaudio *cpa); void close_alert_port(c_portaudio *cpa); #endif
2,783
C++
.h
102
25.352941
80
0.708192
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,292
serial.h
w1hkj_fldigi/src/include/serial.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef SERIAL_H #define SERIAL_H #include <string> void com_to_tty(std::string& port); void tty_to_com(std::string& port); #ifndef __MINGW32__ #include <termios.h> class Cserial { public: Cserial(); ~Cserial(); //Methods bool OpenPort(); bool IsOpen() { return fd < 0 ? 0 : 1; }; void ClosePort(); void Device (std::string dev) { device = dev;}; std::string Device() { return device;}; void Baud(int b) { baud = b;}; int Baud() { return baud;}; void Timeout(int tm) { timeout = tm;} int Timeout() { return timeout; } void Retries(int r) { retries = r;} int Retries() { return retries;} void RTS(bool r){rts = r;} bool RTS(){return rts;} void RTSptt(bool b){rtsptt = b;} bool RTSptt(){return rtsptt;} void DTR(bool d){dtr = d;} bool DTR(){return dtr;} void DTRptt(bool b){dtrptt = b;} bool DTRptt(){return dtrptt;} void SetDTR(bool b); void SetRTS(bool b); void RTSCTS(bool b){rtscts = b;} bool RTSCTS(){return rtscts;} void SetPTT(bool b); void RestoreTIO(bool b) { restore_tio = b; } bool RestoreTIO() { return restore_tio; } void Stopbits(int n) { stopbits = n; } int Stopbits() { return stopbits;} bool ReadByte(unsigned char &resp); int ReadBuffer (unsigned char *b, int nbr); int WriteBuffer(unsigned char *str, int nbr); void FlushBuffer(); private: //Members std::string device; int fd; int baud; int speed; struct termios oldtio, newtio; int timeout; int retries; int status, origstatus; bool dtr; bool dtrptt; bool rts; bool rtsptt; bool rtscts; bool restore_tio; int stopbits; //char bfr[2048]; //Methods bool IOselect(); }; #else //__MINGW32__ #include <windows.h> class Cserial { public: Cserial() { rts = dtr = false; rtsptt = dtrptt = false; rtscts = false; baud = CBR_9600; stopbits = 2; }; Cserial( std::string portname) { device = portname; Cserial(); // OpenPort(); }; virtual ~Cserial() {}; //Methods BOOL OpenPort(); void ClosePort(); BOOL ConfigurePort(DWORD BaudRate,BYTE ByteSize,DWORD fParity,BYTE Parity,BYTE StopBits); bool IsBusy() { return busyflag; }; void IsBusy(bool val) { busyflag = val; }; bool IsOpen() { return hComm == INVALID_HANDLE_VALUE ? 0 : 1; }; BOOL ReadByte(unsigned char &resp); int ReadData (unsigned char *b, int nbr); int ReadBuffer (unsigned char *b, int nbr) { return ReadData (b,nbr); } BOOL WriteByte(unsigned char bybyte); int WriteBuffer(unsigned char *str, int nbr); BOOL SetCommunicationTimeouts( DWORD ReadIntervalTimeout, DWORD ReadTotalTimeoutMultiplier, DWORD ReadTotalTimeoutConstant, DWORD WriteTotalTimeoutMultiplier, DWORD WriteTotalTimeoutConstant); BOOL SetCommTimeout(); void Timeout(int tm) { timeout = tm; return; }; int Timeout() { return timeout; }; void FlushBuffer(); void Device (std::string dev) { device = dev;}; std::string Device() { return device;}; void Baud(int b) { baud = b;}; int Baud() { return baud;}; void Retries(int r) { retries = r;} int Retries() { return retries;} void RTS(bool r){rts = r;} bool RTS(){return rts;} void RTSptt(bool b){rtsptt = b;} bool RTSptt(){return rtsptt;} void DTR(bool d){dtr = d;} bool DTR(){return dtr;} void DTRptt(bool b){dtrptt = b;} bool DTRptt(){return dtrptt;} void SetDTR(bool b); void SetRTS(bool b); void RTSCTS(bool b){rtscts = b;} bool RTSCTS(){return rtscts;} void SetPTT(bool b); void RestoreTIO(bool b) { restore_tio = b; } bool RestoreTIO() { return restore_tio; } void Stopbits(int n) { stopbits = n; } int Stopbits() { return stopbits;} //Members private: std::string device; //For use by CreateFile HANDLE hComm; //DCB Defined in WinBase.h DCB dcb; COMMTIMEOUTS CommTimeoutsSaved; COMMTIMEOUTS CommTimeouts; //Is the Port Ready? BOOL bPortReady; //Number of Bytes Written to port DWORD nBytesWritten; //Number of Bytes Read from port DWORD nBytesRead; //Number of bytes Transmitted in the cur session DWORD nBytesTxD; int timeout; bool busyflag; int baud; int retries; bool dtr; bool dtrptt; bool rts; bool rtsptt; bool rtscts; bool restore_tio; int stopbits; }; #endif // __MINGW32__ #endif // SERIAL_H
5,074
C++
.h
179
26.212291
91
0.686842
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,293
utf8file_io.h
w1hkj_fldigi/src/include/utf8file_io.h
// ---------------------------------------------------------------------------- // utf8file_io.h // // Copyright (C) 2012 // Dave Freese, W1HKJ // // This file is part of fldigi. // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef UTF8_FILE_IO #define UTF8_FILE_IO #include <string> int UTF8_readfile ( const char *file, std::string &textread ); int UTF8_writefile( const char *file, std::string &textwrite ); #endif
1,112
C++
.h
27
40.037037
79
0.629047
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,294
icons.h
w1hkj_fldigi/src/include/icons.h
// ---------------------------------------------------------------------------- // icons.h // // Copyright (C) 2008-2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef ICONS_H_ #define ICONS_H_ #define USE_IMAGE_LABELS 1 #include <FL/Fl_Widget.H> #include <FL/Fl_Menu_Item.H> #include <FL/fl_ask.H> #include "pixmaps.h" namespace icons { const char* make_icon_label(const char* text, const char** pixmap = 0); void set_icon_label(Fl_Menu_Item* item); void set_icon_label(Fl_Widget* w); void toggle_icon_labels(void); const char* get_icon_label_text(Fl_Menu_Item* item); const char* get_icon_label_text(Fl_Widget* w); void free_icon_label(Fl_Menu_Item* item); void free_icon_label(Fl_Widget* w); void set_active(Fl_Menu_Item* item, bool v); void set_active(Fl_Widget* w, bool v); // fltk message dialogs with nicer icons void set_message_icon(const char** pixmap); } #define fl_input2(...) ({ icons::set_message_icon(dialog_question_48_icon); fl_input(__VA_ARGS__); }) #define fl_choice2(...) ({ icons::set_message_icon(dialog_question_48_icon); fl_choice(__VA_ARGS__); }) #define fl_message2(...) ({ icons::set_message_icon(dialog_information_48_icon); fl_message(__VA_ARGS__); }) #define fl_warn_choice2(...) ({ icons::set_message_icon(dialog_warning_48_icon); fl_choice(__VA_ARGS__); }) #define fl_alert2(...) ({ icons::set_message_icon(dialog_warning_48_icon); fl_alert(__VA_ARGS__); }) #endif // ICONS_H_
2,158
C++
.h
48
43.666667
108
0.668893
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,295
record_loader.h
w1hkj_fldigi/src/include/record_loader.h
// ---------------------------------------------------------------------------- // record_loader.h // // Copyright (C) 2013 // Remi Chateauneu, F4ECW // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef RECORD_LOADER_H #define RECORD_LOADER_H #include <iosfwd> #include <string> class RecordLoaderInterface { RecordLoaderInterface & operator=( const RecordLoaderInterface & ); public: RecordLoaderInterface(); virtual void Clear() = 0 ; /// Reads just one record. virtual bool ReadRecord( std::istream & ) = 0 ; /// Loads a file and stores it for later lookup. Returns the number of records, or -1. int LoadAndRegister(); std::string ContentSize() const ; virtual ~RecordLoaderInterface(); /// Base name. In case the URL is not nice enough to build a clean data filename. virtual std::string base_filename() const ; /// The place where we store the data locally. std::pair< std::string, bool > storage_filename(bool create_dir = false) const ; virtual const char * Url() const { return NULL; } virtual const char * Description() const = 0 ; std::string Timestamp() const; static void SetDataDir( const std::string & data_dir ); }; // RecordLoaderInterface /// Loads records from a file or an Url. template< class Catalog > class RecordLoaderSingleton { static Catalog s_cata_inst ; public: static Catalog & InstCatalog() { return s_cata_inst ; } }; template<class Catalog> Catalog RecordLoaderSingleton< Catalog >::s_cata_inst = Catalog(); /// Loads tabular records from a file. template< class Catalog > struct RecordLoader : public RecordLoaderInterface, public RecordLoaderSingleton<Catalog> { }; // RecordLoader void createRecordLoader(); #endif // RECORD_LOADER_H
2,412
C++
.h
64
36.046875
90
0.704165
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,296
plot_xy.h
w1hkj_fldigi/src/include/plot_xy.h
// --------------------------------------------------------------------- // plot_xy.h // // Copyright (C) 2019 // David Freese, W1HKJ // // This is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This software is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // --------------------------------------------------------------------- #ifndef plot_xy_H #define plot_xy_H #include <FL/Fl.H> #include <FL/fl_draw.H> #include <FL/Fl_Widget.H> #include "threads.h" struct PLOT_XY {double x; double y;}; class plot_xy : public Fl_Widget { public: #define PLOT_XY_DEFAULT_WIDTH 100 #define PLOT_XY_DEFAULT_HEIGHT 100 #define PLOT_XY_MAX_LEN 8192 #define PLOT_XY_NUM_GRIDS 100 private: PLOT_XY *buf_1; PLOT_XY *buf_2; int _len_1; int _len_2; int linecnt; bool xreverse; bool x_legend; bool y_legend; std::string sx_legend; std::string sy_legend; bool _show_1; bool _show_2; bool _thick_lines; bool _plot_over_axis; protected: double xmin, xmax; double ymin, ymax; double x_graticule; double y_graticule; Fl_Color _bk_color; Fl_Color _axis_color; Fl_Color _color_1; Fl_Color _color_2; Fl_Color _legend_color; public: plot_xy(int, int, int, int, const char *); ~plot_xy(); int handle(int); void resize(int x, int y, int w, int h); void draw(); void data_1 (PLOT_XY *data_1, int len_1); void data_2 (PLOT_XY *data_2, int len_2); void x_scale( double _xmin, double _xmax, double _x_graticule) { xmin = _xmin; xmax = _xmax; x_graticule = _x_graticule; } void get_x_scale( double &_xmin, double &_xmax, double &_x_graticule) { _xmin = xmin; _xmax = xmax; _x_graticule = x_graticule; } void y_scale( double _ymin, double _ymax, double _y_graticule) { ymin = _ymin; ymax = _ymax; y_graticule = _y_graticule; } void get_y_scale( double _ymin, double _ymax, double _y_graticule) { _ymin = ymin; _ymax = ymax; _y_graticule = y_graticule; } void draw_x_legend(bool on = true) { x_legend = on; } void draw_y_legend(bool on = true) { y_legend = on; } void legends(bool on = true) { x_legend = on; y_legend = on; } void set_x_legend(std::string legend) { sx_legend = legend; } void set_y_legend(std::string legend) { sy_legend = legend; } void bk_color(Fl_Color c) { _bk_color = c; } Fl_Color bk_color() { return _bk_color; } void axis_color(Fl_Color c) { _axis_color = c; } Fl_Color axis_color() { return _axis_color; } void line_color_1(Fl_Color c) { _color_1 = c; } Fl_Color line_color_1() { return _color_1; } void line_color_2(Fl_Color c) { _color_2 = c; } Fl_Color line_color() { return _color_2; } void legend_color(Fl_Color c) { _legend_color = c; } Fl_Color legend_color() { return _legend_color; } void reverse_x(bool val) { xreverse = val; } void show_1(bool on) { _show_1 = on; } bool show_1() { return _show_1; } void show_2(bool on) { _show_2 = on; } bool show_2() { return _show_2; } void thick_lines(bool yes) { _thick_lines = yes; }; void plot_over_axis(bool yes) { _plot_over_axis = yes; }; }; #endif
3,531
C++
.h
112
29.455357
72
0.657016
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,297
benchmark.h
w1hkj_fldigi/src/include/benchmark.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef BENCHMARK_H_ #define BENCHMARK_H_ #include <string> #include <sys/types.h> #include "globals.h" struct benchmark_params { trx_mode modem; int freq; bool afc, sql; double sqlevel; double src_ratio; int src_type; std::string input, output, buffer; size_t samples; }; extern struct benchmark_params benchmark; int setup_benchmark(void); void do_benchmark(void); #endif
1,276
C++
.h
38
32.236842
79
0.656934
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,298
morse.h
w1hkj_fldigi/src/include/morse.h
/* * morse.h -- morse code tables * * Copyright (C) 2017 * * Fldigi is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Fldigi is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with fldigi. If not, see <http://www.gnu.org/licenses/>. * */ #ifndef _MORSE_H #define _MORSE_H #include <string> #define MorseTableSize 256 #define CW_DOT_REPRESENTATION '.' #define CW_DASH_REPRESENTATION '-' struct CWstruct { bool enabled; // true if character is active std::string chr; // utf-8 string representation of character std::string prt; // utf-8 printable representation std::string rpr; // Dot-dash code representation }; class cMorse { private: static CWstruct cw_table[]; std::string utf8; std::string toprint; int ptr; public: cMorse() { init(); } ~cMorse() { } void init(); void enable(std::string, bool); std::string rx_lookup(std::string); std::string tx_lookup(int); std::string tx_print() { return toprint; } int tx_length(int); }; #endif
1,478
C++
.h
51
27.039216
74
0.711064
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,299
F_Edit.h
w1hkj_fldigi/src/include/F_Edit.h
// ---------------------------------------------------------------------------- // FTextView.h // // Copyright (C) 2007-2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef F_EDIT_H_ #define F_EDIT_H_ #include <stddef.h> #include <string> #include <FL/Fl.H> #include <FL/Enumerations.H> #include <FL/Fl_Menu_Item.H> #include <FL/Fl_Tile.H> #include "FTextView.h" /// A FTextBase subclass to display and edit text class F_Edit : public FTextEdit { public: F_Edit(int x, int y, int w, int h, const char *l = 0); virtual int handle(int event); void clear(void); void add_text(std::string s); void setFont(Fl_Font f, int attr = NATTR); protected: enum { EDIT_MENU_CUT, EDIT_MENU_COPY, EDIT_MENU_PASTE, EDIT_MENU_CLEAR, EDIT_MENU_READ, EDIT_MENU_WRAP }; int handle_key(int key); int handle_dnd_drag(int pos); void handle_context_menu(void); void menu_cb(size_t item); void change_keybindings(void); static int kf_default(int c, Fl_Text_Editor_mod* e); static int kf_enter(int c, Fl_Text_Editor_mod* e); static int kf_delete(int c, Fl_Text_Editor_mod* e); static int kf_cut(int c, Fl_Text_Editor_mod* e); static int kf_paste(int c, Fl_Text_Editor_mod* e); private: F_Edit(); F_Edit(const F_Edit &t); protected: static Fl_Menu_Item menu[]; int editpos; int bkspaces; static int *p_editpos; }; #endif // F_EDIT_H_ // Local Variables: // mode: c++ // c-file-style: "linux" // End:
2,185
C++
.h
68
30.529412
79
0.661912
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,300
rigio.h
w1hkj_fldigi/src/include/rigio.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef RIGIO_H #define RIGIO_H #include <string> #include "threads.h" #include "serial.h" extern Cserial rigio; extern pthread_mutex_t rigCAT_mutex; extern bool hexout(const std::string&); extern bool sendCommand(std::string cmd, std::string catstr, int retnbr, int waitval); extern void add_to_cmdque( std::string cmd, std::string s, int retnbr, int waitval); extern long long rigCAT_getfreq(int retries, bool &failed, int waitval = 0); extern void rigCAT_setfreq(long long); extern std::string rigCAT_getmode(); extern void rigCAT_setmode(const std::string&); extern std::string rigCAT_getwidth(); extern void rigCAT_setwidth(const std::string&); extern void rigCAT_get_notch(); extern void rigCAT_set_notch(int val); extern void rigCAT_get_smeter(); extern void rigCAT_get_pwrmeter(); extern void rigCAT_set_pwrlevel(int); extern void rigCAT_get_pwrlevel(); extern void rigCAT_close(); extern bool rigCAT_init(); extern bool rigCAT_active(); extern void rigCAT_sendINIT(const std::string& icmd, int multiplier = 1); extern void rigCAT_set_ptt(int); extern void rigCAT_set_qsy(long long f); extern void rigCAT_defaults(); //extern void rigCAT_restore_defaults(); // no xcvr extern long long noCAT_getfreq(); extern void noCAT_setfreq(long long f); extern std::string noCAT_getmode(); extern void noCAT_setmode(const std::string &md); extern std::string noCAT_getwidth(); extern void noCAT_setwidth(const std::string &w); extern void noCAT_setPTT(bool val); extern void noCAT_init(); #endif
2,401
C++
.h
59
39.372881
86
0.714716
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,301
ptt.h
w1hkj_fldigi/src/include/ptt.h
// ---------------------------------------------------------------------------- // // ptt.h -- PTT control // // Copyright (C) 2006-2009 // Dave Freese, W1HKJ // Copyright (C) 2008-2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. Adapted from code contained in gmfsk source code // distribution. // gmfsk Copyright (C) 2001, 2002, 2003 // Tomi Manninen (oh2bns@sral.fi) // Copyright (C) 2004 // Lawrence Glaister (ve7it@shaw.ca) // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef PTT_H_ #define PTT_H_ #include <config.h> #if HAVE_LINUX_PPDEV_H || HAVE_DEV_PPBUS_PPI_H # define HAVE_PARPORT 1 #else # define HAVE_PARPORT 0 #endif #ifdef __APPLE__ # define HAVE_UHROUTER 1 # define UHROUTER_FIFO_PREFIX "/tmp/microHamRouter" #else # define HAVE_UHROUTER 0 #endif #if HAVE_TERMIOS_H # define HAVE_TTYPORT 1 #else # define HAVE_TTYPORT 0 #endif struct termios; //#ifdef __MINGW32__ # include "serial.h" //#endif class PTT { public: // The ptt_t enums must be defined even if the corresponding // code is not compiled. New tags go to the end of the list. enum ptt_t { PTT_INVALID = -1, PTT_NONE, PTT_HAMLIB, PTT_RIGCAT, PTT_TTY, PTT_PARPORT, PTT_UHROUTER, PTT_GPIO, PTT_CMEDIA }; PTT(ptt_t dev = PTT_NONE); ~PTT(); void set(bool on); void reset(ptt_t dev); Cserial serPort; private: ptt_t pttdev; // tty and parport int pttfd; struct termios* oldtio; #if HAVE_UHROUTER // uhrouter int uhkfd[2]; // keyer int uhfd[2]; // ptt #endif void close_all(void); void open_tty(void); void set_tty(bool ptt); void close_tty(void); void open_gpio(void); void set_gpio(bool ptt); void close_gpio(void); #if HAVE_PARPORT void open_parport(void); void set_parport(bool ptt); void close_parport(void); #endif #if HAVE_UHROUTER void open_uhrouter(void); void set_uhrouter(bool ptt); void close_uhrouter(void); #endif }; #endif // PTT_H_
2,610
C++
.h
96
25.645833
82
0.683093
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,302
wefax.h
w1hkj_fldigi/src/include/wefax.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // Remi Chateauneu // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _WEFAX_H #define _WEFAX_H #include "globals.h" #include "modem.h" #include "filters.h" #include "mbuffer.h" #include "logbook.h" /// Forward definition. class fax_implementation ; class wefax : public modem { fax_implementation * m_impl ; bool m_abortxmt; /// For updating the logbook when loading/saving an image file. cQsoRec m_qso_rec ; /// Non-copiable object. wefax (); wefax ( const wefax & ); wefax & operator=( const wefax & ); public: wefax (trx_mode md); virtual ~wefax (); void init(); void rx_init(); void tx_init(); void restart() {}; int rx_process(const double *buf, int len); int tx_process(); void shutdown(); int tx_time( int nb_bytes ) const ; bool is_tx_finished( int ix_sample, int nb_sample, const char * msg ) const; void skip_apt(void); void skip_phasing(bool auto_center); void end_reception(void); void set_tx_parameters( int the_lpm, const unsigned char * xmtpic_buffer, bool is_color, int img_w, int img_h ); void set_tx_abort_flag(void) { m_abortxmt = true ; } /// Whether reading without end, or apt/phasing/stop. void set_rx_manual_mode( bool manual_flag ); /// There are several possible input filter designated /// by a name, for displaying, and an index. static const char ** rx_filters(void); /// Set by the GUI. void set_rx_filter( int idx_filter ); void set_lpm( int the_lpm ); /// Restores the window label by taking into account wefax state mode. void update_rx_label(void) const ; /// Returns a filename matching current image properties. std::string suggested_filename(void) const ; cQsoRec & qso_rec(void) { return m_qso_rec ; } /// Called before loading/sending an image. void qso_rec_init(void); /// Called when transmitting/receiving is finished. void qso_rec_save(void); void set_freq(double); /// Helper string indicating the internal state of the wefax engine. std::string state_string(void) const; /// Maximum wait time when getting information about received and sent files. static const int max_delay = 3600 * 24 * 365 ; /// Called by the engine when a file is received. void put_received_file(const std::string & filnam); /// Used by XML-RPC to get the list of received files. std::string get_received_file(int max_seconds=max_delay); /// Called by XML-RPC to send a file which resides on the machine where fldigi runs. std::string send_file( const std::string & filnam, double max_seconds=max_delay); /// Called before sending a file. Transmitting is an exclusive process. bool transmit_lock_acquire( const std::string & filnam, double max_seconds=max_delay); /// Called after sending a file so another sending can take place. void transmit_lock_release( const std::string & err_msg ); }; #endif
3,685
C++
.h
100
34.81
87
0.696765
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,303
digiscope.h
w1hkj_fldigi/src/include/digiscope.h
// ---------------------------------------------------------------------------- // digiscope.h, Miniature Oscilloscope/Phasescope Widget // // Copyright (C) 2006 // Dave Freese, W1HKJ // // This file is part of fldigi. Adapted in part from code contained in // gmfsk source code distribution. // gmfsk Copyright (C) 2001, 2002, 2003 // Tomi Manninen (oh2bns@sral.fi) // Copyright (C) 2004 // Lawrence Glaister (ve7it@shaw.ca) // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef DIGISCOPE_H #define DIGISCOPE_H #include <FL/Fl_Widget.H> #include "complex.h" class Digiscope : public Fl_Widget { public: #define DEFAULT_WIDTH 100 #define DEFAULT_HEIGHT 100 #define MAX_LEN 4096 //1024 #define MAX_ZLEN 1024 #define NUM_GRIDS 100 enum scope_mode { SCOPE, PHASE, PHASE1, PHASE2, PHASE3, RTTY, XHAIRS, WWV, DOMDATA, DOMWF, BLANK }; private: scope_mode _mode; double _buf[MAX_LEN]; cmplx _zdata[MAX_ZLEN]; //int _zlen; int _zptr; unsigned char *vidbuf; unsigned char *vidline; int _len; int linecnt; double _phase; double _quality; double _flo, _fhi, _amp; double _x[NUM_GRIDS], _y[NUM_GRIDS]; bool _highlight; scope_mode phase_mode; protected: double _y_user1, _y_user2; double _x_user1, _x_user2; bool _x_graticule; bool _y_graticule; public: Digiscope(int, int, int, int, const char *label = ""); ~Digiscope(); int handle(int); void resize(int x, int y, int w, int h); void draw(); void draw_scope(); void draw_phase(); void draw_rtty(); void draw_xy(); void draw_video(); void data(double *data, int len, bool scale = true); void phase(double ph, double ql, bool hl); void video(double *data, int len, bool dir ); void zdata(cmplx *z, int len); void rtty(double flo, double fhi, double amp); void mode(scope_mode md); scope_mode mode() { return _mode;};\ void xaxis(int n, double y1) { if (n < NUM_GRIDS) _y[n] = y1; } void yaxis(int n, double x1) { if (n < NUM_GRIDS) _x[n] = x1; } void xaxis_1(double y1) { _y[1] = y1; } void xaxis_2(double y2) { _y[2] = y2; } void yaxis_1(double x1) { _x[1] = x1; } void yaxis_2(double x2) { _x[2] = x2; } void clear_axis() { for (int i = 0; i < NUM_GRIDS; i++) _x[i] = _y[i] = 0; } double x_user1() { return _x_user1; } void x_user1(double val) { _x_user1 = val; } double x_user2() { return _x_user2; } void x_user2(double val) { _x_user2 = val; } double y_user1() { return _y_user1; } void y_user1(double val) { _y_user1 = val; } double y_user2() { return _y_user2; } void y_user2(double val) { _y_user2 = val; } bool x_graticule() { return _x_graticule; } void x_graticule(bool b) { _x_graticule = b; } bool y_graticule() { return _y_graticule; } void y_graticule(bool b) { _y_graticule = b; } }; #endif
3,422
C++
.h
117
27.367521
79
0.655026
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,304
rigxml.h
w1hkj_fldigi/src/include/rigxml.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef XML_H #define XML_H #include <string> #include <list> #include <vector> struct MODE { std::string SYMBOL; std::string BYTES; MODE(std::string nm, std::string b) { SYMBOL = nm; BYTES = b;} MODE(std::string nm, char c) { SYMBOL = nm; BYTES += c;} }; struct BW { std::string SYMBOL; std::string BYTES; BW(std::string nm, std::string b) { SYMBOL = nm; BYTES = b;} BW(std::string nm, char c) { SYMBOL = nm; BYTES += c;} }; struct DATA { std::string dtype; int size; int max; int min; float resolution; bool reverse; int andmask; int shiftbits; void clear() { size = 0; dtype.clear(); max = 199999999; min = 0; resolution = 1.0; reverse = false; andmask = 0xFF; shiftbits = 0; } }; struct XMLIOS { std::string SYMBOL; int size; std::string str1; std::string str2; DATA data; int fill1; int fill2; std::string info; std::string ok; std::string bad; void clear() { SYMBOL.clear(); str1.clear(); str2.clear(); info.clear(); ok.clear(); bad.clear(); size = fill1 = fill2 = 0; data.clear(); } }; struct TAGS { const char *tag; void (*fp)(size_t &);}; struct PAIR { int val; int mtr; PAIR(int v, int s) { val = v; mtr = s; } void clear() {val = 0; mtr = 0; } }; struct XMLRIG { XMLRIG() { clear(); } std::string port; std::string rigTitle; int baud; int stopbits; bool dtr; bool dtrptt; bool rts; bool rtsptt; bool rtscts; bool restore_tio; int write_delay; int init_delay; int wait_for_device; int post_write_delay; int timeout; int retries; bool echo; bool cmdptt; bool vsp; bool logstr; int pollinterval; bool use_smeter; std::vector< PAIR > smeter; bool use_pwrmeter; std::vector< PAIR > pmeter; bool use_notch; std::vector< PAIR > notch; bool use_pwrlevel; std::vector< PAIR >pwrlevel; bool debug; bool noserial; bool ascii; bool xmlok; void clear() { port.clear(); baud = 1200; stopbits = 2; dtr = false; dtrptt = false; rts = false; rtsptt = false; rtscts = false; restore_tio = true; echo = false; cmdptt = false; vsp = false; logstr = false; write_delay = 0; init_delay = 0; wait_for_device = 0; post_write_delay = 50; timeout = 200; retries = 5; rigTitle = ""; pollinterval = 100; debug = false; noserial = false; ascii = false; xmlok = false; use_smeter = false; use_pwrmeter = false; use_pwrlevel = false; smeter.clear(); pmeter.clear(); pwrlevel.clear(); notch.clear(); } }; extern std::list<XMLIOS> commands; extern std::list<XMLIOS> reply; extern std::list<MODE> lmodes; extern std::list<MODE> lmodeCMD; extern std::list<MODE> lmodeREPLY; extern std::list<BW> lbws; extern std::list<BW> lbwCMD; extern std::list<BW> lbwREPLY; extern std::list<std::string> LSBmodes; extern XMLRIG xmlrig; extern bool readRigXML(); extern void selectRigXmlFilename(); extern void loadRigXmlFile(void); #endif
3,794
C++
.h
171
20.087719
79
0.662413
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,305
record_loader_gui.h
w1hkj_fldigi/src/include/record_loader_gui.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef RECORD_LOADER_GUI_H #define RECORD_LOADER_GUI_H #include <FL/Fl_Table.H> #include <FL/Fl_Double_Window.H> class RecordLoaderInterface ; class DerivedRecordLst : public Fl_Table { DerivedRecordLst(); DerivedRecordLst( const DerivedRecordLst & ); DerivedRecordLst & operator=( const DerivedRecordLst & ); public: DerivedRecordLst(int, int, int, int, const char * title = 0); virtual ~DerivedRecordLst(); static void cbGuiUpdate(); static void cbGuiReset(); void AddRow(int R); void DrawRow(int R); protected: void draw_cell(TableContext context, // table cell drawing int R=0, int C=0, int X=0, int Y=0, int W=0, int H=0); }; #endif // RECORD_LOADER_GUI_H
1,580
C++
.h
41
36.902439
79
0.665796
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,306
table.h
w1hkj_fldigi/src/include/table.h
/* Copyright (c) 2004 Markus Niemistö Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __TABLE_HH #define __TABLE_HH #include <FL/Enumerations.H> #include <FL/Fl_Widget.H> #include <FL/Fl_Scrollbar.H> #include <FL/Fl_Menu_Item.H> #include <FL/Fl_Group.H> #include <vector> #define TABLE_WHEN_DCLICK 16 enum SCROLLS {always, never, var}; struct ColumnInfo { bool hidden; const char *title; int width; Fl_Align align; Fl_Align hdr_align; int (*comparator)(const char*, const char*); void (*callback)(); }; int compareInt(const char *val1, const char *val2); class Table : public Fl_Group { private: // Scrollbars Fl_Scrollbar *hScroll, *vScroll; SCROLLS Vscroll; SCROLLS Hscroll; // Popup menu const Fl_Menu_Item *popupMenu; bool menuAlloc; // Column data std::vector<struct ColumnInfo> header; // Cell data std::vector<char**> data; bool (*highlighter)(int, char **, Fl_Color *); // Table dimensions int tableHeight, tableWidth; int oX, oY, oW, oH; // Outer dimensions (widget - box) int iX, iY, iW, iH; /* * Table area dimensions * (outer dimension - header - scrollbars) */ // For optimization int topRow, bottomRow, leftCol, rightCol; int topRowY, leftColX; int nCols, nRows; // Number of rows and columns int cPos; // Column where new entry is added. int resizing, dragX; int pushed; int sortColumn; // Object sizes int scrollbarSize; int headerHeight; int rowHeight; int selected; char **curRow; Fl_Font tbl_font; int tbl_fontsize; // Various flags bool ascent; bool canResize, canSort; bool noMoreColumns; bool toBeSorted; bool dimensionsChanged; bool headerEnabled; bool withGrid; void dSort(int start, int end, int (*compare)(const char *, const char*)); void aSort(int start, int end, int (*compare)(const char *, const char*)); protected: virtual int handle(int event); virtual void drawHeader(int x, int y); virtual void drawRow(int row, char *rowData[], int x, int y); virtual void draw(); void calcDimensions(); void scrolled(); void resized(); static void scrollCallback(Fl_Widget *widget, void *data); public: Table(int x, int y, int w, int h, char *label = NULL); ~Table(); bool headerOn() const; void headerOn(bool enabled); bool allowResize() const; void allowResize(bool allow); bool allowSort() const; void allowSort(bool allow); bool gridEnabled() const; void gridEnabled(bool enable); int headerSize() const; void headerSize(int height); int rowSize() const; void rowSize(int height); int scrollbSize() const; void scrollbSize(int size); virtual void resize(int x, int y, int w, int h); void font(Fl_Font fnt) { tbl_font = fnt; } Fl_Font font() { return tbl_font; } void fontsize(int fntsize) { tbl_fontsize = fntsize; headerHeight = tbl_fontsize + 4; rowHeight = tbl_fontsize + 4; } int fontsize() { return tbl_fontsize; } Fl_Align headerAlign(int column) const; void headerAlign(int column, Fl_Align align); Fl_Align columnAlign(int column) const; void columnAlign(int column, Fl_Align align); int columnWidth(int column) const; void columnWidth(int column, int width); const char *columnTitle(int column); void columnTitle(int column, const char *title); bool columnHidden(int column); void columnHidden(int column, bool hidden); void sort(); void sort(int column, bool ascent); void getSort(int &sortColumn, bool &ascent); void setHighlighter(bool (*highlighter)(int, char **, Fl_Color *)); void addColumn(const char *label, int width = 150, Fl_Align align = (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP), int (*comparator)(const char*, const char*) = NULL); void colcomparator (int column, int (*comparator)(const char*, const char*) = NULL); void colcallback (int column, void (*callback)() = NULL); void addHiddenColumn(const char *label); void addCell(char *data); void addRow(int cols, ...); void addFromTSV(const char *data); void removeRow(int row); void clear(bool removeColumns = false); void where(int x, int y, int &row, int &column, int &resize); void scrollTo(int pos); int scrollPos() const; int columns(); int rows(); void value(int selection); int value(); char *valueAt(int row, int column); int intValueAt(int row, int column); void valueAt(int row, int column, char *data); void valueAt(int row, int column, int data); const char **getRow(int row); const Fl_Menu_Item *menu(); void menu(const Fl_Menu_Item *m); void menuCopy(const Fl_Menu_Item *m); void menuClear(); void allowVscroll(SCROLLS when) {Vscroll = when;} void allowHscroll(SCROLLS when) {Hscroll = when;} void FirstRow (); void PrevRow (); void NextRow (); void LastRow (); void PrevPage (); void NextPage (); void GotoRow (int); int vScrollWidth() { return (vScroll->visible() ? vScroll->w() : 0);} bool search(int& row, int& col, bool rev, const char* re); }; #endif
5,932
C++
.h
179
30.608939
75
0.735872
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,307
spot.h
w1hkj_fldigi/src/include/spot.h
// ---------------------------------------------------------------------------- // spot.h // // Copyright (C) 2008-2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef SPOT_H_ #define SPOT_H_ #if HAVE_REGEX_H # include <regex.h> #else # include "compat/regex.h" #endif #include <sys/time.h> #include "globals.h" typedef void (*spot_recv_cb_t)(trx_mode mode, int afreq, const char* str, const regmatch_t* sub, size_t len, void* data); typedef void (*spot_log_cb_t)(const char* call, const char* loc, long long freq, trx_mode mode, time_t rtime, void* data); void spot_recv(char c, int decoder = -1, int afreq = 0, int md = 0); void spot_log(const char* callsign, const char* locator = "", long long freq = 0LL, trx_mode mode = NUM_MODES, time_t rtime = -1L); void spot_manual(const char* callsign, const char* locator = "", long long freq = 0LL, trx_mode mode = NUM_MODES, time_t rtime = -1L); void spot_register_log(spot_log_cb_t lcb, void* ldata); void spot_register_manual(spot_log_cb_t mcb, void* mdata); void spot_register_recv(spot_recv_cb_t rcb, void* rdata, const char* re, int reflags); void spot_unregister_log(spot_log_cb_t lcb, const void* ldata); void spot_unregister_manual(spot_log_cb_t mcb, const void* mdata); void spot_unregister_recv(spot_recv_cb_t rcb, const void* rdata); #endif // SPOT_H_
2,095
C++
.h
45
44.977778
121
0.662261
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,309
ssb.h
w1hkj_fldigi/src/include/ssb.h
// ---------------------------------------------------------------------------- // ssb.h -- ssb modem // // Copyright (C) 2010 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _SSB_H #define _SSB_H #include "modem.h" #define ssb_SampleRate 8000 class ssb : public modem { public: ssb(); ~ssb(); void init(); void rx_init(); void tx_init(); void restart(); int rx_process(const double *buf, int len); int tx_process(); }; #endif
1,171
C++
.h
38
29.473684
79
0.628546
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false