Upload the frequency that the rig is tuned to, if available

pull/2/head
Daniel Richman 2012-11-02 18:13:03 +00:00
rodzic aee14af900
commit 974dea091f
4 zmienionych plików z 59 dodań i 3 usunięć

@ -1 +1 @@
Subproject commit 9a02072c8e1e8aee5b62503afcb27745279b8eb6
Subproject commit ab15cf16f94abcc2804c5838dd66d2f11fba968a

Wyświetl plik

@ -3829,6 +3829,8 @@ void cb_qso_opBrowser(Fl_Browser*, void*)
void show_frequency(long long freq)
{
dl_fldigi::hbtint::rig_set_freq(freq);
qsoFreqDisp1->value(freq);
qsoFreqDisp2->value(freq);
qsoFreqDisp3->value(freq);
@ -3836,6 +3838,8 @@ void show_frequency(long long freq)
void show_mode(const string& sMode)
{
dl_fldigi::hbtint::rig_set_mode(sMode);
REQ_SYNC(&Fl_ComboBox::put_value, qso_opMODE, sMode.c_str());
}

Wyświetl plik

@ -35,6 +35,10 @@ DExtractorManager *extrmgr;
DUploaderThread *uthr;
static habitat::UKHASExtractor *ukhas;
static time_t rig_freq_updated, rig_mode_updated;
static long long rig_freq;
static string rig_mode;
void init()
{
cgl = new EZ::cURLGlobal();
@ -69,6 +73,20 @@ void cleanup()
cgl = 0;
}
void rig_set_freq(long long freq)
{
Fl_AutoLock lock;
rig_freq_updated = time(NULL);
rig_freq = freq;
}
void rig_set_mode(const string &mode)
{
Fl_AutoLock lock;
rig_mode_updated = time(NULL);
rig_mode = mode;
}
static void uthr_thread_death(void *what)
{
if (what != uthr)
@ -91,9 +109,11 @@ void *DUploaderThread::run()
return ret;
}
/* All these functions are called via a DUploaderThread pointer so
/* Some functions below are called via a DUploaderThread pointer so
* the fact that they are non virtual is OK. Having a different set of
* arguments even prevents the wrong function from being selected */
* arguments even prevents the wrong function from being selected.
* payload_telemetry() is actually virtual, so that the ExtractorManager
* can call it */
void DUploaderThread::settings()
{
@ -118,6 +138,30 @@ void DUploaderThread::settings()
progdefaults.habitat_db);
}
void DUploaderThread::payload_telemetry(const string &data,
const Json::Value &metadata, int time_created)
{
Fl_AutoLock lock;
/* If the frequency/mode from the rig is recent, upload it.
* null metadata is automatically converted to an object by jsoncpp */
Json::Value rig_info(Json::objectValue);
if (rig_freq_updated >= time(NULL) - 30)
rig_info["frequency"] = rig_freq;
if (rig_mode_updated >= time(NULL) - 30)
rig_info["mode"] = rig_mode;
Json::Value new_metadata = metadata;
if (rig_mode.size())
new_metadata["rig_info"] = rig_info;
UploaderThread::payload_telemetry(data, new_metadata, time_created);
}
/* This function is used for stationary listener telemetry only */
void DUploaderThread::listener_telemetry()

Wyświetl plik

@ -16,6 +16,9 @@ public:
/* These functions call super() functions, but with data grabbed from
* progdefaults and other globals. */
void settings();
void payload_telemetry(const string &data,
const Json::Value &metadata=Json::Value::null,
int time_created=-1);
void listener_telemetry();
void listener_telemetry(const Json::Value &data);
void listener_information();
@ -54,6 +57,11 @@ void init();
void start();
void cleanup();
/* Called by a line in dialog/fl-digi.cxx, which is called when any rig
* management gets the current frequency from the rig. */
void rig_set_freq(long long freq);
void rig_set_mode(const string &mode);
} /* namespace hbtint */
} /* namespace dl_fldigi */