From 0c064c64a436fe9ef89d578c2f4c267a9cc6dc5a Mon Sep 17 00:00:00 2001 From: David Freese Date: Thu, 8 Dec 2011 08:02:34 -0600 Subject: [PATCH] WEFAX update * When changing wefax slant, prompts to save configuration on exit. * Changed wefaxNNN to wefaxNNN_modem * Changed sample rate initialization * Fixed prototype for wefax::getfile * Fixed logging of fax images. --- src/globals/globals.cxx | 4 +-- src/include/modem.h | 4 +-- src/include/wefax.h | 6 +--- src/trx/modem.cxx | 4 +-- src/wefax/wefax-pic.cxx | 5 ++- src/wefax/wefax.cxx | 67 ++++++++++------------------------------- 6 files changed, 27 insertions(+), 63 deletions(-) diff --git a/src/globals/globals.cxx b/src/globals/globals.cxx index 6925400c..74c8d3a3 100644 --- a/src/globals/globals.cxx +++ b/src/globals/globals.cxx @@ -76,8 +76,8 @@ const struct mode_info_t mode_info[NUM_MODES] = { { MODE_MFSK31, &mfsk31_modem, "MFSK31", "MFSK-31", "MFSK31", "MFSK31", "MK31" }, { MODE_MFSK64, &mfsk64_modem, "MFSK64", "MFSK-64", "MFSK64", "MFSK64", "MK64" }, - { MODE_WEFAX_576, &wefax576, "WEFAX576", "WEFAX-IOC576", "WEFAXIOC576", "FAX", "FX576" }, - { MODE_WEFAX_288, &wefax288, "WEFAX288", "WEFAX-IOC288", "WEFAXIOC288", "FAX", "FX288" }, + { MODE_WEFAX_576, &wefax576_modem, "WEFAX576", "WEFAX-IOC576", "WEFAXIOC576", "FAX", "FX576" }, + { MODE_WEFAX_288, &wefax288_modem, "WEFAX288", "WEFAX-IOC288", "WEFAXIOC288", "FAX", "FX288" }, { MODE_MT63_500, &mt63_500_modem, "MT63-500", "MT63-500", "MT63-500", "MT63", "MT63-500" }, { MODE_MT63_1000, &mt63_1000_modem, "MT63-1K", "MT63-1000", "MT63-1XX", "MT63", "MT63 1K" }, diff --git a/src/include/modem.h b/src/include/modem.h index 7d0a5c59..03589d78 100644 --- a/src/include/modem.h +++ b/src/include/modem.h @@ -197,8 +197,8 @@ extern modem *mfsk22_modem; extern modem *mfsk31_modem; extern modem *mfsk64_modem; -extern modem *wefax576; -extern modem *wefax288; +extern modem *wefax576_modem; +extern modem *wefax288_modem; extern modem *mt63_500_modem; extern modem *mt63_1000_modem; diff --git a/src/include/wefax.h b/src/include/wefax.h index 07d01f42..b33bfd3f 100644 --- a/src/include/wefax.h +++ b/src/include/wefax.h @@ -10,10 +10,6 @@ #include "mbuffer.h" #include "logbook.h" -#define WEFAXSampleRate 11025 -// #define WEFAXSampleRate 8000 - - /// Forward definition. class fax_implementation ; @@ -119,7 +115,7 @@ public: void put_received_file(const std::string & filnam); /// Used by XML-RPC to get the list of received files. - std::string get_received_file(double max_seconds=max_delay); + 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); diff --git a/src/trx/modem.cxx b/src/trx/modem.cxx index c4baf0cb..9d28bd88 100644 --- a/src/trx/modem.cxx +++ b/src/trx/modem.cxx @@ -55,8 +55,8 @@ modem *mfsk22_modem = 0; modem *mfsk31_modem = 0; modem *mfsk64_modem = 0; -modem *wefax576 = 0; -modem *wefax288 = 0; +modem *wefax576_modem = 0; +modem *wefax288_modem = 0; modem *mt63_500_modem = 0; modem *mt63_1000_modem = 0; diff --git a/src/wefax/wefax-pic.cxx b/src/wefax/wefax-pic.cxx index eafccfc1..386f13ee 100644 --- a/src/wefax/wefax-pic.cxx +++ b/src/wefax/wefax-pic.cxx @@ -726,6 +726,9 @@ static void wefax_cb_pic_ratio( Fl_Widget *, void * ) /// 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 picture. @@ -1041,7 +1044,7 @@ void wefax_pic::create_rx_viewer(void) wefax_cnt_rx_ratio->align(FL_ALIGN_LEFT); wefax_cnt_rx_ratio->type(FL_SIMPLE_COUNTER); wefax_cnt_rx_ratio->callback(wefax_cb_pic_ratio, 0); - wefax_cnt_rx_ratio->tooltip("Adjust imge slant to correct soundcard clock error."); + wefax_cnt_rx_ratio->tooltip("Adjust image slant to correct soundcard clock error."); static const char * title_center = "Center" ; wid_off_low += wid_btn_curr + fl_width( title_center ); diff --git a/src/wefax/wefax.cxx b/src/wefax/wefax.cxx index bf1a4cf9..bce1b7f7 100644 --- a/src/wefax/wefax.cxx +++ b/src/wefax/wefax.cxx @@ -764,11 +764,11 @@ public: } /// Returns a received file name, by chronological order. - std::string get_received_file( double max_seconds ) + std::string get_received_file( int max_seconds ) { guard_lock g( m_sync_rx.mtxp() ); - LOG_INFO(_("delay=%f"), max_seconds ); + LOG_INFO(_("delay=%d"), max_seconds ); if( m_received_files.empty() ) { if( ! m_sync_rx.wait(max_seconds) ) return std::string(); @@ -946,13 +946,10 @@ public: static size_t cnt_upd = 0 ; - if( cnt_upd == 0 ) { - if( m_correlation_buffer.size() != corr_buff_sz ) { - m_correlation_buffer.resize( corr_buff_sz, 0 ); - m_current_corr = 0.0 ; - m_curr_corr_avg = 0.0 ; - return ; - } + if( m_correlation_buffer.size() != corr_buff_sz ) { + m_correlation_buffer.resize( corr_buff_sz, 0 ); + m_current_corr = 0.0 ; + m_curr_corr_avg = 0.0 ; } if( ( cnt_upd % corr_samples_line ) == 0 ) { @@ -1839,7 +1836,7 @@ wefax::wefax(trx_mode wefax_mode) : modem() wefax::mode = wefax_mode; - modem::samplerate = WEFAXSampleRate ; + modem::samplerate = 11025; m_impl = new fax_implementation(wefax_mode, this); @@ -2104,34 +2101,10 @@ void wefax::qso_rec_init(void) /// 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.setDateTime(true); + m_qso_rec.setFrequency( wf->rfcarrier() ); - time_t tmp_time = time(NULL); - struct tm tmp_tm ; - 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 ); - m_qso_rec.putField(QSO_DATE, buf_date); - - char buf_timeon[64] ; - snprintf( buf_timeon, sizeof(buf_timeon), - "%02d%02d", - tmp_tm.tm_hour, - tmp_tm.tm_min ); - m_qso_rec.putField(TIME_ON, buf_timeon); - - long long tmp_fl = wf->rfcarrier() ; - double freq_dbl = tmp_fl / 1000000.0 ; - char buf_freq[64]; - snprintf( buf_freq, sizeof(buf_freq), "%lf", freq_dbl ); - m_qso_rec.putField(FREQ, buf_freq ); - - /// The method get_mode should be const. - m_qso_rec.putField(MODE, mode_info[ const_cast(this)->get_mode()].adif_name ); + m_qso_rec.putField(MODE, mode_info[get_mode()].adif_name ); // m_qso_rec.putField(QTH, inpQth_log->value()); // m_qso_rec.putField(STATE, inpState_log->value()); @@ -2161,21 +2134,13 @@ void wefax::qso_rec_save(void) return ; } - time_t tmp_time = time(NULL); - struct tm tmp_tm ; - localtime_r( &tmp_time, &tmp_tm ); - - char buf_timeoff[64] ; - snprintf( buf_timeoff, sizeof(buf_timeoff), - "%02d%02d", - tmp_tm.tm_hour, - tmp_tm.tm_min ); - m_qso_rec.putField(TIME_OFF, buf_timeoff); - - adifFile.writeLog (logbook_filename.c_str(), &qsodb); - qsodb.isdirty(0); + 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_INFO( _("Updating log book %s"), logbook_filename.c_str() ); } @@ -2201,7 +2166,7 @@ void wefax::put_received_file( const std::string &filnam ) } /// Returns a received file name, by chronological order. -std::string wefax::get_received_file( double max_seconds ) +std::string wefax::get_received_file( int max_seconds ) { return m_impl->get_received_file( max_seconds ); }