~ubuntu-branches/ubuntu/wily/flrig/wily

« back to all changes in this revision

Viewing changes to .pc/0001-License-Declaration.patch/src/support.cxx

  • Committer: Package Import Robot
  • Author(s): Kamal Mostafa
  • Date: 2014-10-25 11:17:10 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20141025111710-n32skgya3l9u1brw
Tags: 1.3.17-1
* New upstream release (Closes: #761839)
* Debian Standards-Version: 3.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdlib.h>
2
 
#include <iostream>
3
 
#include <fstream>
4
 
#include <vector>
5
 
#include <queue>
6
 
#include <sys/types.h>
7
 
#include <sys/stat.h>
8
 
#include <stdlib.h>
9
 
#include <stdio.h>
10
 
#include <fcntl.h>
11
 
#include <pthread.h>
12
 
 
13
 
#include "icons.h"
14
 
#include "support.h"
15
 
#include "debug.h"
16
 
#include "gettext.h"
17
 
#include "rig_io.h"
18
 
#include "dialogs.h"
19
 
#include "rigbase.h"
20
 
#include "ptt.h"
21
 
#include "xml_io.h"
22
 
 
23
 
#include "rigs.h"
24
 
#include "K3_ui.h"
25
 
 
26
 
using namespace std;
27
 
 
28
 
rigbase *selrig = rigs[0];
29
 
 
30
 
extern bool test;
31
 
 
32
 
bool flrig_abort = false;
33
 
 
34
 
int freqval = 0;
35
 
 
36
 
FREQMODE vfoA = {14070000, 0, 0, UI};
37
 
FREQMODE vfoB = {7070000, 0, 0, UI};
38
 
FREQMODE vfo = {0, 0, 0, UI};
39
 
FREQMODE transceiverA;
40
 
FREQMODE transceiverB;
41
 
FREQMODE xmlvfo = vfoA;
42
 
 
43
 
enum {VOL, MIC, PWR, SQL, IFSH, NOTCH, RFGAIN, NR };
44
 
 
45
 
struct SLIDER { 
46
 
        int  which;
47
 
        float value;
48
 
        int  button;
49
 
        SLIDER(int a, float f, int b = 0) {which = a; value = f; button = b;}
50
 
};
51
 
 
52
 
queue<SLIDER> sliders;
53
 
 
54
 
queue<FREQMODE> queA;
55
 
queue<FREQMODE> queB;
56
 
queue<bool> quePTT;
57
 
 
58
 
bool useB = false;
59
 
bool changed_vfo = false;
60
 
bool pushedB = false;
61
 
 
62
 
bool volume_changed = false;
63
 
bool mic_changed = false;
64
 
bool power_changed = false;
65
 
bool squelch_changed = false;
66
 
bool if_shift_changed = false;
67
 
bool notch_changed = false;
68
 
bool rfgain_changed = false;
69
 
bool noise_reduction_changed = false;
70
 
 
71
 
const char **old_bws = NULL;
72
 
 
73
 
// Add alpha-tag to FREQMODE;
74
 
struct ATAG_FREQMODE {
75
 
        long freq;
76
 
        int  imode;
77
 
        int  iBW;
78
 
        int  src;
79
 
        char alpha_tag[ATAGSIZE];
80
 
};
81
 
ATAG_FREQMODE oplist[LISTSIZE];
82
 
 
83
 
int  numinlist = 0;
84
 
vector<string> rigmodes_;
85
 
vector<string> rigbws_;
86
 
 
87
 
Cserial RigSerial;
88
 
Cserial AuxSerial;
89
 
Cserial SepSerial;
90
 
 
91
 
bool using_buttons = false;
92
 
 
93
 
enum { SWR_IMAGE, ALC_IMAGE };
94
 
int meter_image = SWR_IMAGE;
95
 
 
96
 
//=============================================================================
97
 
// loop for serial i/o thread
98
 
// runs continuously until program is closed
99
 
// only accesses the serial port if it has been successfully opened
100
 
//=============================================================================
101
 
 
102
 
bool bypass_serial_thread_loop = true;
103
 
bool run_serial_thread = true;
104
 
 
105
 
bool PTT = false;
106
 
int  powerlevel = 0;
107
 
 
108
 
char *print(FREQMODE data)
109
 
{
110
 
        static char str[100];
111
 
        const char **bwt = selrig->bwtable(data.imode);
112
 
        const char **dsplo = selrig->lotable(data.imode);
113
 
        const char **dsphi = selrig->hitable(data.imode);
114
 
        snprintf(str, sizeof(str), "%3s,%10ld, %4s, %x => %5s %5s",
115
 
                data.src == XML ? "xml" : "ui",
116
 
                data.freq,
117
 
                selrig->modes_ ? selrig->modes_[data.imode] : "modes n/a",
118
 
                data.iBW,
119
 
                (data.iBW > 256 && selrig->has_dsp_controls) ?
120
 
                        (dsplo ? dsplo[data.iBW & 0x7F] : "??") : (bwt ? bwt[data.iBW] : "lo n/a"),
121
 
                (data.iBW > 256 && selrig->has_dsp_controls) ?
122
 
                        (dsphi ? dsphi[(data.iBW >> 8) & 0x7F] : "??") : "hi n/a"
123
 
                );
124
 
        return str;
125
 
}
126
 
 
127
 
// the following functions are ONLY CALLED by the serial loop
128
 
// read any data stream sent by transceiver
129
 
 
130
 
// read current vfo frequency
131
 
 
132
 
void read_info()
133
 
{
134
 
        pthread_mutex_lock(&mutex_serial);
135
 
                selrig->get_info();
136
 
        pthread_mutex_unlock(&mutex_serial);
137
 
}
138
 
 
139
 
void read_vfo()
140
 
{
141
 
// transceiver changed ?
142
 
        pthread_mutex_lock(&mutex_serial);
143
 
        long  freq;
144
 
        if (!useB) { // vfo-A
145
 
                freq = selrig->get_vfoA();
146
 
                if (freq != vfoA.freq) {
147
 
                        vfoA.freq = freq;
148
 
                        Fl::awake(setFreqDispA, (void *)vfoA.freq);
149
 
                        vfo = vfoA;
150
 
                        send_xml_freq(vfo.freq);
151
 
                }
152
 
                if ( selrig->twovfos() ) {
153
 
                        freq = selrig->get_vfoB();
154
 
                        if (freq != vfoB.freq) {
155
 
                                vfoB.freq = freq;
156
 
                                Fl::awake(setFreqDispB, (void *)vfoB.freq);
157
 
                        }
158
 
                }
159
 
        } else { // vfo-B
160
 
                freq = selrig->get_vfoB();
161
 
                if (freq != vfoB.freq) {
162
 
                        vfoB.freq = freq;
163
 
                        Fl::awake(setFreqDispB, (void *)vfoB.freq);
164
 
                        vfo = vfoB;
165
 
                        send_xml_freq(vfo.freq);
166
 
                }
167
 
                if ( selrig->twovfos() ) {
168
 
                        freq = selrig->get_vfoA();
169
 
                        if (freq != vfoA.freq) {
170
 
                                vfoA.freq = freq;
171
 
                                Fl::awake(setFreqDispA, (void *)vfoA.freq);
172
 
                        }
173
 
                }
174
 
        }
175
 
        pthread_mutex_unlock(&mutex_serial);
176
 
}
177
 
 
178
 
void setModeControl(void *)
179
 
{
180
 
        opMODE->index(vfo.imode);
181
 
 
182
 
// enables/disables the IF shift control, depending on the mode.
183
 
// the IF Shift function, is ONLY valid in CW modes, with the 870S.
184
 
 
185
 
        if (rig_nbr == TS870S) {
186
 
                if (vfo.imode == RIG_TS870S::tsCW || vfo.imode == RIG_TS870S::tsCWR) {
187
 
                        btnIFsh->activate();
188
 
                        sldrIFSHIFT->activate();
189
 
                } else {
190
 
                        btnIFsh->deactivate();
191
 
                        sldrIFSHIFT->deactivate();
192
 
                }
193
 
        }
194
 
}
195
 
 
196
 
// mode and bandwidth
197
 
void read_mode()
198
 
{
199
 
        pthread_mutex_lock(&mutex_serial);
200
 
        int nu_mode;
201
 
        int nu_BW;
202
 
        if (!useB) {
203
 
                nu_mode = selrig->get_modeA();
204
 
                if (nu_mode != vfoA.imode) {
205
 
                        pthread_mutex_lock(&mutex_xmlrpc);
206
 
                        vfoA.imode = vfo.imode = nu_mode;
207
 
                        selrig->adjust_bandwidth(vfo.imode);
208
 
                        nu_BW = selrig->get_bwA();
209
 
                        vfoA.iBW = vfo.iBW = nu_BW;
210
 
                        try {
211
 
                                send_bandwidths();
212
 
                                send_new_mode(nu_mode);
213
 
                                send_sideband();
214
 
                                send_new_bandwidth(vfo.iBW);
215
 
                        } catch (...) {}
216
 
                        pthread_mutex_unlock(&mutex_xmlrpc);
217
 
                        Fl::awake(setModeControl);
218
 
                        set_bandwidth_control();
219
 
                }
220
 
        } else {
221
 
                nu_mode = selrig->get_modeB();
222
 
                if (nu_mode != vfoB.imode) {
223
 
                        pthread_mutex_lock(&mutex_xmlrpc);
224
 
                        vfoB.imode = vfo.imode = nu_mode;
225
 
                        selrig->adjust_bandwidth(vfo.imode);
226
 
                        nu_BW = selrig->get_bwB();
227
 
                        vfoB.iBW = vfo.iBW = nu_BW;
228
 
                        try {
229
 
                                send_bandwidths();
230
 
                                send_new_mode(nu_mode);
231
 
                                send_sideband();
232
 
                                send_new_bandwidth(vfo.iBW);
233
 
                        } catch (...) {}
234
 
                        pthread_mutex_unlock(&mutex_xmlrpc);
235
 
                        Fl::awake(setModeControl);
236
 
                        set_bandwidth_control();
237
 
                }
238
 
        }
239
 
        pthread_mutex_unlock(&mutex_serial);
240
 
}
241
 
 
242
 
void setBWControl(void *)
243
 
{
244
 
        if (selrig->has_dsp_controls) {
245
 
                if (vfo.iBW < 256) {
246
 
                        opDSP_lo->index(0);
247
 
                        opDSP_hi->index(0);
248
 
                        opDSP_lo->hide();
249
 
                        opDSP_hi->hide();
250
 
                        btnDSP->hide();
251
 
                        opBW->index(vfo.iBW);
252
 
                        opBW->show();
253
 
                } else {
254
 
                        opBW->index(0);
255
 
                        opBW->hide();
256
 
                        opDSP_lo->index(vfo.iBW & 0xFF);
257
 
                        opDSP_lo->hide();
258
 
                        opDSP_hi->index((vfo.iBW >> 8) & 0x7F);
259
 
                        opDSP_hi->show();
260
 
                        btnDSP->label(selrig->hi_label);
261
 
                        btnDSP->redraw_label();
262
 
                        btnDSP->show();
263
 
                }
264
 
        } else {
265
 
                opDSP_lo->hide();
266
 
                opDSP_hi->hide();
267
 
                btnDSP->hide();
268
 
                opBW->index(vfo.iBW);
269
 
                opBW->show();
270
 
        }
271
 
}
272
 
 
273
 
void read_bandwidth()
274
 
{
275
 
        pthread_mutex_lock(&mutex_serial);
276
 
        int nu_BW;
277
 
        if (!useB) {
278
 
                nu_BW = selrig->get_bwA();
279
 
                if (nu_BW != vfoA.iBW) {
280
 
                        pthread_mutex_lock(&mutex_xmlrpc);
281
 
                        vfoA.iBW = vfo.iBW = nu_BW;
282
 
                        Fl::awake(setBWControl);
283
 
                        try {
284
 
                                send_new_bandwidth(vfo.iBW);
285
 
                        } catch (...) {}
286
 
                        pthread_mutex_unlock(&mutex_xmlrpc);
287
 
                }
288
 
        } else {
289
 
                nu_BW = selrig->get_bwB();
290
 
                if (nu_BW != vfoB.iBW) {
291
 
                        vfoB.iBW = vfo.iBW = nu_BW;
292
 
                        pthread_mutex_lock(&mutex_xmlrpc);
293
 
                        Fl::awake(setBWControl);
294
 
                        try {
295
 
                                send_new_bandwidth(vfo.iBW);
296
 
                        } catch (...) {}
297
 
                        pthread_mutex_unlock(&mutex_xmlrpc);
298
 
                }
299
 
        }
300
 
        pthread_mutex_unlock(&mutex_serial);
301
 
}
302
 
 
303
 
// read current signal level
304
 
void read_smeter()
305
 
{
306
 
        if (!selrig->has_smeter) return;
307
 
        int  sig;
308
 
        pthread_mutex_lock(&mutex_serial);
309
 
        sig = selrig->get_smeter();
310
 
        pthread_mutex_unlock(&mutex_serial);
311
 
        if (sig == -1) return;
312
 
        Fl::awake(updateSmeter, reinterpret_cast<void*>(sig));
313
 
}
314
 
 
315
 
// read power out
316
 
void read_power_out()
317
 
{
318
 
        if (!selrig->has_power_out) return;
319
 
        int sig;
320
 
        pthread_mutex_lock(&mutex_serial);
321
 
        sig = selrig->get_power_out();
322
 
        pthread_mutex_unlock(&mutex_serial);
323
 
        if (sig > -1)
324
 
                Fl::awake(updateFwdPwr, reinterpret_cast<void*>(sig));
325
 
}
326
 
 
327
 
// read swr
328
 
void read_swr()
329
 
{
330
 
        if ((meter_image != SWR_IMAGE) ||
331
 
                !selrig->has_swr_control) return;
332
 
        int sig;
333
 
        pthread_mutex_lock(&mutex_serial);
334
 
        sig = selrig->get_swr();
335
 
        pthread_mutex_unlock(&mutex_serial);
336
 
        if (sig > -1)
337
 
                Fl::awake(updateSWR, reinterpret_cast<void*>(sig));
338
 
}
339
 
 
340
 
// alc
341
 
void read_alc()
342
 
{
343
 
        if ((meter_image != ALC_IMAGE) ||
344
 
                !selrig->has_alc_control) return;
345
 
        int sig;
346
 
        pthread_mutex_lock(&mutex_serial);
347
 
                sig = selrig->get_alc();
348
 
        pthread_mutex_unlock(&mutex_serial);
349
 
        if (sig > -1)
350
 
                Fl::awake(updateALC, reinterpret_cast<void*>(sig));
351
 
}
352
 
 
353
 
// notch
354
 
void update_auto_notch(void *d)
355
 
{
356
 
        btnAutoNotch->value(progStatus.auto_notch);
357
 
}
358
 
 
359
 
void read_auto_notch()
360
 
{
361
 
        if (!selrig->has_auto_notch || notch_changed) return;
362
 
        pthread_mutex_lock(&mutex_serial);
363
 
                progStatus.auto_notch = selrig->get_auto_notch();
364
 
        pthread_mutex_unlock(&mutex_serial);
365
 
        Fl::awake(update_auto_notch, (void*)0);
366
 
}
367
 
 
368
 
// NOISE blanker
369
 
void update_noise(void *d)
370
 
{
371
 
        btnNOISE->value(progStatus.noise);
372
 
}
373
 
 
374
 
void read_noise()
375
 
{
376
 
        pthread_mutex_lock(&mutex_serial);
377
 
                progStatus.noise = selrig->get_noise();
378
 
        pthread_mutex_unlock(&mutex_serial);
379
 
        Fl::awake(update_noise, (void*)0);
380
 
}
381
 
 
382
 
// preamp - attenuator
383
 
void update_preamp(void *d)
384
 
{
385
 
        btnPreamp->value(progStatus.preamp);
386
 
}
387
 
 
388
 
void update_attenuator(void *d)
389
 
{
390
 
        btnAttenuator->value(progStatus.attenuator);
391
 
}
392
 
 
393
 
void read_preamp_att()
394
 
{
395
 
        if (selrig->has_preamp_control) {
396
 
                pthread_mutex_lock(&mutex_serial);
397
 
                        progStatus.preamp = selrig->get_preamp();
398
 
                pthread_mutex_unlock(&mutex_serial);
399
 
                Fl::awake(update_preamp, (void*)0);
400
 
        }
401
 
        if (selrig->has_attenuator_control) {
402
 
                pthread_mutex_lock(&mutex_serial);
403
 
                        progStatus.attenuator = selrig->get_attenuator();
404
 
                pthread_mutex_unlock(&mutex_serial);
405
 
                Fl::awake(update_attenuator, (void*)0);
406
 
        }
407
 
}
408
 
 
409
 
// split
410
 
void update_split(void *d)
411
 
{
412
 
        if (rig_nbr == FT450 || rig_nbr == FT950 || rig_nbr == FTdx1200 ||
413
 
                rig_nbr == TS480SAT || rig_nbr == TS480HX ||
414
 
                rig_nbr == TS590S || rig_nbr == TS2000 || rig_nbr == TS990) {
415
 
                switch (progStatus.split) {
416
 
                        case 0: btnSplit->value(0);
417
 
                                        useB = false;
418
 
                                        highlight_vfo(NULL);
419
 
                                        break;
420
 
                        case 1: btnSplit->value(1);
421
 
                                        useB = true;
422
 
                                        highlight_vfo(NULL);
423
 
                                        break;
424
 
                        case 2: btnSplit->value(1);
425
 
                                        useB = false;
426
 
                                        highlight_vfo(NULL);
427
 
                                        break;
428
 
                        case 3: btnSplit->value(0);
429
 
                                        useB = true;
430
 
                                        highlight_vfo(NULL);
431
 
                                        break;
432
 
                }
433
 
        } else
434
 
                btnSplit->value(progStatus.split);
435
 
}
436
 
 
437
 
void read_split()
438
 
{
439
 
        int val;
440
 
        if (selrig->can_split()) {
441
 
                pthread_mutex_lock(&mutex_serial);
442
 
                        val = selrig->get_split();
443
 
                pthread_mutex_unlock(&mutex_serial);
444
 
                if (val != progStatus.split) {
445
 
                        progStatus.split = val;
446
 
                        Fl::awake(update_split, (void*)0);
447
 
                }
448
 
        }
449
 
}
450
 
 
451
 
// volume
452
 
void update_volume(void *d)
453
 
{
454
 
        long *nr = (long *)d;
455
 
        sldrVOLUME->value(progStatus.volume); // Set slider to last known value
456
 
        sldrVOLUME->activate();                           // activate it
457
 
        if (*nr) btnVol->value(1);                        // Button Lit
458
 
        else     btnVol->value(0);                        // Button Dark.
459
 
}
460
 
 
461
 
long nlzero = 0L;
462
 
long nlone = 1L;
463
 
 
464
 
void read_volume()
465
 
{
466
 
        if (!selrig->has_volume_control || volume_changed) return;
467
 
        int vol;
468
 
        pthread_mutex_lock(&mutex_serial);
469
 
                vol = selrig->get_volume_control();
470
 
        pthread_mutex_unlock(&mutex_serial);
471
 
        if (vol != progStatus.volume) {
472
 
                if (vol <= 1 && !btnVol->value()) return;
473
 
                progStatus.volume = vol;
474
 
                if (vol <= 1 && btnVol->value())
475
 
                        Fl::awake(update_volume, (void*)&nlzero);
476
 
                else
477
 
                        Fl::awake(update_volume, (void*)&nlone);
478
 
        }
479
 
}
480
 
 
481
 
// ifshift
482
 
void update_ifshift(void *d)
483
 
{
484
 
 
485
 
 
486
 
        btnIFsh->value(progStatus.shift);
487
 
//      if (progStatus.shift)
488
 
                sldrIFSHIFT->value(progStatus.shift_val);
489
 
}
490
 
 
491
 
void read_ifshift()
492
 
{
493
 
        if (!selrig->has_ifshift_control || if_shift_changed) return;
494
 
        pthread_mutex_lock(&mutex_serial);
495
 
                progStatus.shift = selrig->get_if_shift(progStatus.shift_val);
496
 
        pthread_mutex_unlock(&mutex_serial);
497
 
        Fl::awake(update_ifshift, (void*)0);
498
 
}
499
 
 
500
 
// noise reduction
501
 
void update_nr(void *d)
502
 
{
503
 
        btnNR->value(progStatus.noise_reduction);
504
 
        sldrNR->value(progStatus.noise_reduction_val);
505
 
}
506
 
 
507
 
void read_nr()
508
 
{
509
 
        if (!selrig->has_noise_reduction || noise_reduction_changed) return;
510
 
        pthread_mutex_lock(&mutex_serial);
511
 
                progStatus.noise_reduction = selrig->get_noise_reduction();
512
 
                progStatus.noise_reduction_val = selrig->get_noise_reduction_val();
513
 
        pthread_mutex_unlock(&mutex_serial);
514
 
        Fl::awake(update_nr, (void*)0);
515
 
}
516
 
 
517
 
// manual notch
518
 
bool rig_notch;
519
 
int  rig_notch_val;
520
 
void update_notch(void *d)
521
 
{
522
 
        btnNotch->value(progStatus.notch = rig_notch);
523
 
        sldrNOTCH->value(progStatus.notch_val = rig_notch_val);
524
 
        send_new_notch(progStatus.notch ? progStatus.notch_val : 0);
525
 
}
526
 
 
527
 
void read_notch()
528
 
{
529
 
        if (!selrig->has_notch_control || notch_changed) return;
530
 
        pthread_mutex_lock(&mutex_serial);
531
 
                rig_notch = selrig->get_notch(rig_notch_val);
532
 
        pthread_mutex_unlock(&mutex_serial);
533
 
        if (rig_notch != progStatus.notch || rig_notch_val != progStatus.notch_val)
534
 
                Fl::awake(update_notch, (void*)0);
535
 
}
536
 
 
537
 
// power_control
538
 
void update_power_control(void *d)
539
 
{
540
 
        set_power_controlImage(progStatus.power_level);
541
 
        sldrPOWER->value(progStatus.power_level);
542
 
        if (rig_nbr == K2) {
543
 
                double min, max, step;
544
 
                selrig->get_pc_min_max_step(min, max, step);
545
 
                sldrPOWER->minimum(min);
546
 
                sldrPOWER->maximum(max);
547
 
                sldrPOWER->step(step);
548
 
                sldrPOWER->redraw();
549
 
        }
550
 
}
551
 
 
552
 
void read_power_control()
553
 
{
554
 
        if (!selrig->has_power_control || power_changed) return;
555
 
        pthread_mutex_lock(&mutex_serial);
556
 
                progStatus.power_level = selrig->get_power_control();
557
 
        pthread_mutex_unlock(&mutex_serial);
558
 
        Fl::awake(update_power_control, (void*)0);
559
 
}
560
 
 
561
 
// mic gain
562
 
void update_mic_gain(void *d)
563
 
{
564
 
        sldrMICGAIN->value(progStatus.mic_gain);
565
 
}
566
 
 
567
 
void read_mic_gain()
568
 
{
569
 
        if (!selrig->has_micgain_control || mic_changed) return;
570
 
        pthread_mutex_lock(&mutex_serial);
571
 
                progStatus.mic_gain = selrig->get_mic_gain();
572
 
        pthread_mutex_unlock(&mutex_serial);
573
 
        Fl::awake(update_mic_gain, (void*)0);
574
 
}
575
 
 
576
 
// rf gain
577
 
void update_rfgain(void *d)
578
 
{
579
 
        sldrRFGAIN->value(progStatus.rfgain);
580
 
}
581
 
 
582
 
void read_rfgain()
583
 
{
584
 
        if (!selrig->has_rf_control || rfgain_changed) return;
585
 
        pthread_mutex_lock(&mutex_serial);
586
 
                progStatus.rfgain = selrig->get_rf_gain();
587
 
        pthread_mutex_unlock(&mutex_serial);
588
 
        Fl::awake(update_rfgain, (void*)0);
589
 
}
590
 
 
591
 
// squelch
592
 
void update_squelch(void *d)
593
 
{
594
 
        sldrSQUELCH->value(progStatus.squelch);
595
 
}
596
 
 
597
 
void read_squelch()
598
 
{
599
 
        if (!selrig->has_sql_control || squelch_changed) return;
600
 
        pthread_mutex_lock(&mutex_serial);
601
 
                progStatus.squelch = selrig->get_squelch();
602
 
        pthread_mutex_unlock(&mutex_serial);
603
 
        Fl::awake(update_squelch, (void*)0);
604
 
}
605
 
 
606
 
static bool resetrcv = true;
607
 
static bool resetxmt = true;
608
 
 
609
 
void serviceA()
610
 
{
611
 
        if (!selrig->can_change_alt_vfo && useB) return;
612
 
        if (queA.empty()) return;
613
 
 
614
 
        pthread_mutex_lock(&mutex_serial);
615
 
        pthread_mutex_lock(&mutex_xmlrpc);
616
 
        pthread_mutex_lock(&mutex_queA);
617
 
        while (!queA.empty()) {
618
 
                vfoA = queA.front();
619
 
                queA.pop();
620
 
        }
621
 
        pthread_mutex_unlock(&mutex_queA);
622
 
 
623
 
//printf("vfo is %s\n", print(vfo));
624
 
//printf("A   is %s\n", print(vfoA));
625
 
 
626
 
        if (RIG_DEBUG)
627
 
                LOG_INFO("%s", print(vfoA));
628
 
 
629
 
        if (changed_vfo && !useB) {
630
 
                selrig->selectA();
631
 
        }
632
 
 
633
 
// if TT550 etal and on the B vfo
634
 
        if (selrig->can_change_alt_vfo && useB) {
635
 
                selrig->set_vfoA(vfoA.freq);
636
 
                goto end_serviceA;
637
 
        }
638
 
 
639
 
        if (vfoA.freq != vfo.freq || changed_vfo) {
640
 
                selrig->set_vfoA(vfoA.freq);
641
 
                Fl::awake(setFreqDispA, (void *)vfoA.freq);
642
 
                vfo.freq = vfoA.freq;
643
 
                if (vfoA.src == UI) send_xml_freq(vfoA.freq);
644
 
        }
645
 
// adjust for change in bandwidths_
646
 
        if (vfoA.imode != vfo.imode || changed_vfo) {
647
 
                selrig->set_modeA(vfoA.imode);
648
 
                vfo.imode = vfoA.imode;
649
 
                Fl::awake(setModeControl);
650
 
//              if (!((vfoA.src == XML) && 
651
 
//                      (rig_nbr == TS2000 || rig_nbr == TS590S || rig_nbr == TS990) ) ) {
652
 
                        vfo.iBW = vfoA.iBW;
653
 
                        set_bandwidth_control();
654
 
                        Fl::awake(setBWControl);
655
 
                        selrig->set_bwA(vfo.iBW);
656
 
//              }
657
 
                try {
658
 
                        if (vfoA.src == UI)
659
 
                                send_new_mode(vfoA.imode);
660
 
                        send_sideband();
661
 
                        send_bandwidths();
662
 
                        send_new_bandwidth(vfo.iBW);
663
 
                } catch (...) {}
664
 
        } else if (vfoA.iBW != vfo.iBW) {
665
 
//              if ((vfoA.src == XML) && 
666
 
//                      (rig_nbr == TS2000 || rig_nbr == TS590S || rig_nbr == TS990) ) {
667
 
                        selrig->set_bwA(vfoA.iBW);
668
 
                        vfo.iBW = vfoA.iBW;
669
 
                        Fl::awake(setBWControl);
670
 
//              }
671
 
                if (vfoA.src == UI) {
672
 
                        try {
673
 
                                send_new_bandwidth(vfo.iBW);
674
 
                        } catch (...) {}
675
 
                }
676
 
        }
677
 
 
678
 
end_serviceA:
679
 
        changed_vfo = false;
680
 
 
681
 
        pthread_mutex_unlock(&mutex_xmlrpc);
682
 
        pthread_mutex_unlock(&mutex_serial);
683
 
}
684
 
 
685
 
void serviceB()
686
 
{
687
 
        if (!selrig->can_change_alt_vfo && !useB) return;
688
 
 
689
 
        if (queB.empty())
690
 
                return;
691
 
 
692
 
        pthread_mutex_lock(&mutex_serial);
693
 
        pthread_mutex_lock(&mutex_xmlrpc);
694
 
        pthread_mutex_lock(&mutex_queB);
695
 
        while (!queB.empty()) {
696
 
                vfoB = queB.front();
697
 
                queB.pop();
698
 
        }
699
 
        pthread_mutex_unlock(&mutex_queB);
700
 
 
701
 
//printf("vfo is %s\n", print(vfo));
702
 
//printf("B   is %s\n", print(vfoB));
703
 
 
704
 
        if (RIG_DEBUG)
705
 
                LOG_INFO("%s", print(vfoB));
706
 
 
707
 
        if (changed_vfo && useB) {
708
 
                selrig->selectB();
709
 
        }
710
 
 
711
 
// if TT550 or K3 and split or on vfoA just update the B vfo
712
 
        if (selrig->can_change_alt_vfo && !useB) {
713
 
                selrig->set_vfoB(vfoB.freq);
714
 
                goto end_serviceB;
715
 
        }
716
 
 
717
 
        if (vfoB.freq != vfo.freq || pushedB || changed_vfo) {
718
 
                selrig->set_vfoB(vfoB.freq);
719
 
                vfo.freq = vfoB.freq;
720
 
                Fl::awake(setFreqDispB, (void *)vfoB.freq);
721
 
                if (vfoB.src == UI) send_xml_freq(vfoB.freq);
722
 
        }
723
 
        if (vfoB.imode != vfo.imode || pushedB || changed_vfo) {
724
 
                selrig->set_modeB(vfoB.imode);
725
 
                vfo.imode = vfoB.imode;
726
 
                Fl::awake(setModeControl);
727
 
//              if (!((vfoB.src == XML) && 
728
 
//                      (rig_nbr == TS2000 || rig_nbr == TS590S || rig_nbr == TS990) ) ) {
729
 
                        vfo.iBW = vfoB.iBW;
730
 
                        set_bandwidth_control();
731
 
                        Fl::awake(setBWControl);
732
 
                        selrig->set_bwB(vfo.iBW);
733
 
//              }
734
 
                try {
735
 
                        if (vfoB.src == UI)
736
 
                                send_new_mode(vfoB.imode);
737
 
                        send_sideband();
738
 
                        send_bandwidths();
739
 
                        send_new_bandwidth(vfo.iBW);
740
 
                } catch (...) {}
741
 
        } else if (vfoB.iBW != vfo.iBW || pushedB) {
742
 
//              if (!((vfoB.src == XML) && 
743
 
//                      (rig_nbr == TS2000 || rig_nbr == TS590S || rig_nbr == TS990) ) ) {
744
 
                        selrig->set_bwB(vfoB.iBW);
745
 
                        vfo.iBW = vfoB.iBW;
746
 
                        Fl::awake(setBWControl);
747
 
//              }
748
 
                if (vfoB.src == UI) {
749
 
                        try {
750
 
                                send_new_bandwidth(vfo.iBW);
751
 
                        } catch (...) {}
752
 
                }
753
 
        }
754
 
        pushedB = false;
755
 
 
756
 
end_serviceB:
757
 
        changed_vfo = false;
758
 
        pthread_mutex_unlock(&mutex_xmlrpc);
759
 
        pthread_mutex_unlock(&mutex_serial);
760
 
}
761
 
 
762
 
void servicePTT()
763
 
{
764
 
        pthread_mutex_lock(&mutex_ptt);
765
 
        while (!quePTT.empty()) {
766
 
                PTT = quePTT.front();
767
 
                quePTT.pop();
768
 
                rigPTT(PTT);
769
 
                Fl::awake(update_UI_PTT);
770
 
        }
771
 
        pthread_mutex_unlock(&mutex_ptt);
772
 
}
773
 
 
774
 
void serviceSliders()
775
 
{
776
 
        SLIDER working(0,0);
777
 
        pthread_mutex_lock(&mutex_serial);
778
 
        while(!sliders.empty()) {
779
 
                working = sliders.front();
780
 
                sliders.pop();
781
 
                switch (working.which) {
782
 
                        case VOL:
783
 
                                selrig->set_volume_control(working.value);
784
 
                                progStatus.volume = working.value;
785
 
                                volume_changed = false;
786
 
                                break;
787
 
                        case MIC:
788
 
                                progStatus.mic_gain = working.value;
789
 
                                selrig->set_mic_gain(working.value);
790
 
                                mic_changed = false;
791
 
                                break;
792
 
                        case PWR:
793
 
                                selrig->set_power_control(working.value);
794
 
                                power_changed = false;
795
 
                                break;
796
 
                        case SQL:
797
 
                                progStatus.squelch = working.value;
798
 
                                selrig->set_squelch(working.value);
799
 
                                squelch_changed = false;
800
 
                                break;
801
 
                        case IFSH:
802
 
                                progStatus.shift = working.button;
803
 
                                progStatus.shift_val = working.value;
804
 
                                selrig->set_if_shift(working.value);
805
 
                                if_shift_changed = false;
806
 
                                break;
807
 
                        case NOTCH:
808
 
                                progStatus.notch = working.button;
809
 
                                progStatus.notch_val = working.value;
810
 
                                selrig->set_notch(working.button, working.value);
811
 
                                try {
812
 
                                        send_new_notch(working.button ? working.value : 0);
813
 
                                } catch (...) {}
814
 
                                notch_changed = false;
815
 
                                break;
816
 
                        case RFGAIN:
817
 
                                progStatus.rfgain = working.value;
818
 
                                selrig->set_rf_gain(working.value);
819
 
                                rfgain_changed = false;
820
 
                                break;
821
 
                        case NR:
822
 
                                if (rig_nbr == TS2000) {
823
 
                                        if (working.button != -1) { // pia
824
 
                                                if (selrig->noise_reduction_level() == 0) {
825
 
                                                        selrig->set_noise_reduction(1);
826
 
                                                        selrig->set_noise_reduction_val(selrig->nrval1());
827
 
                                                        progStatus.noise_reduction = 1;
828
 
                                                        progStatus.noise_reduction_val = selrig->nrval1();
829
 
                                                        Fl::awake(update_nr, (void*)0);
830
 
                                                } else if (selrig->currmode() != RIG_TS2000::FM &&
831
 
                                                                  selrig->noise_reduction_level() == 1) {
832
 
                                                        selrig->set_noise_reduction(2);
833
 
                                                        selrig->set_noise_reduction_val(selrig->nrval2());
834
 
                                                        progStatus.noise_reduction = 2;
835
 
                                                        progStatus.noise_reduction_val = selrig->nrval2();
836
 
                                                        Fl::awake(update_nr, (void*)0);
837
 
                                                } else
838
 
                                                        selrig->set_noise_reduction(0);
839
 
                                        } else {
840
 
                                                progStatus.noise_reduction_val = working.value;
841
 
                                                selrig->set_noise_reduction_val(working.value);
842
 
                                                Fl::awake(update_nr, (void*)0);
843
 
                                        }
844
 
                                } else { // not TS2000
845
 
                                        if (working.button != -1) {
846
 
                                                progStatus.noise_reduction = working.button;
847
 
                                                selrig->set_noise_reduction(working.button);
848
 
                                        }
849
 
                                        progStatus.noise_reduction_val = working.value;
850
 
                                        selrig->set_noise_reduction_val(working.value);
851
 
                                }
852
 
                                noise_reduction_changed = false;
853
 
                                break;
854
 
                        default :
855
 
                                break;
856
 
                }
857
 
        }
858
 
        pthread_mutex_unlock(&mutex_serial);
859
 
}
860
 
 
861
 
void * serial_thread_loop(void *d)
862
 
{
863
 
  static int  loopcount = progStatus.serloop_timing / 10;
864
 
  static int  poll_nbr = 0;
865
 
 
866
 
        for(;;) {
867
 
                if (!run_serial_thread) break;
868
 
 
869
 
                MilliSleep(10);
870
 
                serviceSliders();
871
 
                servicePTT();
872
 
 
873
 
                if (bypass_serial_thread_loop) goto serial_bypass_loop;
874
 
 
875
 
//send any freq/mode/bw changes in the queu
876
 
 
877
 
//              servicePTT();
878
 
 
879
 
                if (!PTT) {
880
 
                        serviceA();
881
 
                        if (!quePTT.empty()) continue;
882
 
                        serviceB();
883
 
                        if (!quePTT.empty()) continue;
884
 
 
885
 
                        if (resetrcv) {
886
 
                                Fl::awake(zeroXmtMeters, 0);
887
 
                                resetrcv = false;
888
 
                                loopcount = progStatus.serloop_timing / 10;
889
 
                                poll_nbr = 0;
890
 
                        }
891
 
                        resetxmt = true;
892
 
 
893
 
                        if (!loopcount--) {
894
 
                                loopcount = progStatus.serloop_timing / 10;
895
 
                                poll_nbr++;
896
 
 
897
 
                                if (rig_nbr == K3) read_K3();
898
 
                                else if ((rig_nbr == K2) ||
899
 
                                                 (selrig->has_get_info &&
900
 
                                                 (progStatus.poll_frequency || progStatus.poll_mode || progStatus.poll_bandwidth)))
901
 
                                        read_info();
902
 
 
903
 
                                if (progStatus.poll_frequency)
904
 
                                        if (!(poll_nbr % progStatus.poll_frequency)) read_vfo();
905
 
 
906
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
907
 
                                if (!quePTT.empty()) continue;
908
 
 
909
 
                                if (progStatus.poll_mode)
910
 
                                        if (!(poll_nbr % progStatus.poll_mode)) read_mode();
911
 
 
912
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
913
 
                                if (!quePTT.empty()) continue;
914
 
 
915
 
                                if (progStatus.poll_bandwidth)
916
 
                                        if (!(poll_nbr % progStatus.poll_bandwidth)) read_bandwidth();
917
 
 
918
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
919
 
                                if (!quePTT.empty()) continue;
920
 
 
921
 
                                if (progStatus.poll_smeter)
922
 
                                        if (!(poll_nbr % progStatus.poll_smeter)) read_smeter();
923
 
 
924
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
925
 
                                if (!quePTT.empty()) continue;
926
 
 
927
 
                                if (progStatus.poll_volume)
928
 
                                        if (!(poll_nbr % progStatus.poll_volume)) read_volume();
929
 
 
930
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
931
 
                                if (!quePTT.empty()) continue;
932
 
 
933
 
                                if (progStatus.poll_auto_notch)
934
 
                                        if (!(poll_nbr % progStatus.poll_auto_notch)) read_auto_notch();
935
 
 
936
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
937
 
                                if (!quePTT.empty()) continue;
938
 
 
939
 
                                if (progStatus.poll_notch)
940
 
                                        if (!(poll_nbr % progStatus.poll_notch)) read_notch();
941
 
 
942
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
943
 
                                if (!quePTT.empty()) continue;
944
 
 
945
 
                                if (progStatus.poll_ifshift)
946
 
                                        if (!(poll_nbr % progStatus.poll_ifshift)) read_ifshift();
947
 
 
948
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
949
 
                                if (!quePTT.empty()) continue;
950
 
 
951
 
                                if (progStatus.poll_power_control)
952
 
                                        if (!(poll_nbr % progStatus.poll_power_control)) read_power_control();
953
 
 
954
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
955
 
                                if (!quePTT.empty()) continue;
956
 
 
957
 
                                if (progStatus.poll_pre_att)
958
 
                                        if (!(poll_nbr % progStatus.poll_pre_att)) read_preamp_att();
959
 
 
960
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
961
 
                                if (!quePTT.empty()) continue;
962
 
 
963
 
                                if (progStatus.poll_micgain)
964
 
                                        if (!(poll_nbr % progStatus.poll_micgain)) read_mic_gain();
965
 
 
966
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
967
 
                                if (!quePTT.empty()) continue;
968
 
 
969
 
                                if (progStatus.poll_squelch)
970
 
                                        if (!(poll_nbr % progStatus.poll_squelch)) read_squelch();
971
 
 
972
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
973
 
                                if (!quePTT.empty()) continue;
974
 
 
975
 
                                if (progStatus.poll_rfgain)
976
 
                                        if (!(poll_nbr % progStatus.poll_rfgain)) read_rfgain();
977
 
 
978
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
979
 
                                if (!quePTT.empty()) continue;
980
 
 
981
 
                                if (progStatus.poll_split)
982
 
                                        if (!(poll_nbr % progStatus.poll_split)) read_split();
983
 
 
984
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
985
 
                                if (!quePTT.empty()) continue;
986
 
 
987
 
                                if (progStatus.poll_nr)
988
 
                                        if (!(poll_nbr % progStatus.poll_nr)) read_nr();
989
 
 
990
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
991
 
                                if (!quePTT.empty()) continue;
992
 
 
993
 
                                if (progStatus.poll_noise)
994
 
                                        if (!(poll_nbr % progStatus.poll_noise)) read_noise();
995
 
 
996
 
                                if (bypass_serial_thread_loop) goto serial_bypass_loop;
997
 
 
998
 
                        }
999
 
                } else {
1000
 
                        if (resetxmt) {
1001
 
                                Fl::awake(updateSmeter, (void *)(0));
1002
 
                                resetxmt = false;
1003
 
                                loopcount = progStatus.serloop_timing / 10;
1004
 
                                poll_nbr = 0;
1005
 
                        }
1006
 
                        resetrcv = true;
1007
 
                        if (!loopcount--) {
1008
 
                                loopcount = progStatus.serloop_timing / 10;
1009
 
                                poll_nbr++;
1010
 
                                if (progStatus.poll_pout)
1011
 
                                        if (!(poll_nbr % progStatus.poll_pout)) read_power_out();
1012
 
                                if (!quePTT.empty()) continue;
1013
 
                                if (progStatus.poll_swr)
1014
 
                                        if (!(poll_nbr % progStatus.poll_swr)) read_swr();
1015
 
                                if (!quePTT.empty()) continue;
1016
 
                                if (progStatus.poll_alc)
1017
 
                                        if (!(poll_nbr % progStatus.poll_alc)) read_alc();
1018
 
                        }
1019
 
                }
1020
 
serial_bypass_loop: ;
1021
 
        }
1022
 
        return NULL;
1023
 
}
1024
 
 
1025
 
//=============================================================================
1026
 
 
1027
 
void setBW()
1028
 
{
1029
 
        FREQMODE fm = vfo;
1030
 
        fm.src = UI;
1031
 
        fm.iBW = opBW->index();
1032
 
        if (useB) {
1033
 
                pthread_mutex_lock(&mutex_queB);
1034
 
//printf("pushed to B: %s\n", print(fm));
1035
 
                queB.push(fm);
1036
 
                pthread_mutex_unlock(&mutex_queB);
1037
 
        } else {
1038
 
                pthread_mutex_lock(&mutex_queA);
1039
 
//printf("pushed to A: %s\n", print(fm));
1040
 
                queA.push(fm);
1041
 
                pthread_mutex_unlock(&mutex_queA);
1042
 
        }
1043
 
}
1044
 
 
1045
 
void setDSP()
1046
 
{
1047
 
        FREQMODE fm = vfo;
1048
 
        fm.src = UI;
1049
 
        fm.iBW = ((opDSP_hi->index() << 8) | 0x8000) | (opDSP_lo->index() & 0xFF) ;
1050
 
        if (useB) {
1051
 
                pthread_mutex_lock(&mutex_queB);
1052
 
                queB.push(fm);
1053
 
                pthread_mutex_unlock(&mutex_queB);
1054
 
        } else {
1055
 
                pthread_mutex_lock(&mutex_queA);
1056
 
                queA.push(fm);
1057
 
                pthread_mutex_unlock(&mutex_queA);
1058
 
        }
1059
 
}
1060
 
 
1061
 
void selectDSP()
1062
 
{
1063
 
        if (btnDSP->label()[0] == selrig->lo_label[0]) {
1064
 
                btnDSP->label(selrig->hi_label);
1065
 
                btnDSP->redraw_label();
1066
 
                opDSP_hi->show();
1067
 
                opDSP_lo->hide();
1068
 
        } else {
1069
 
                btnDSP->label(selrig->lo_label);
1070
 
                btnDSP->redraw_label();
1071
 
                opDSP_lo->show();
1072
 
                opDSP_hi->hide();
1073
 
        }
1074
 
}
1075
 
 
1076
 
// set_bandwidth_control updates iBW and then posts the call for
1077
 
// the UI thread to updateBandwidthControl
1078
 
// changes to the UI cannot come from any thread other than the
1079
 
// main FL thread!  Doing otherwise can cause what appears to be
1080
 
// random program crashes.
1081
 
 
1082
 
void set_bandwidth_control()
1083
 
{
1084
 
        if (!selrig->has_bandwidth_control) return;
1085
 
 
1086
 
        selrig->adjust_bandwidth(vfo.imode);
1087
 
 
1088
 
        if (vfo.iBW < 256) {
1089
 
                int i = 0;
1090
 
                while (selrig->bandwidths_[i]) i++;
1091
 
                i--;
1092
 
                if (vfo.iBW > i) vfo.iBW = selrig->def_bandwidth(vfo.imode);
1093
 
        }
1094
 
        useB ? vfoB.iBW = vfo.iBW : vfoA.iBW = vfo.iBW;
1095
 
        Fl::awake(updateBandwidthControl);
1096
 
}
1097
 
 
1098
 
void updateBandwidthControl(void *d)
1099
 
{
1100
 
        if (selrig->has_bandwidth_control) {
1101
 
                if (selrig->adjust_bandwidth(vfo.imode) != -1) {
1102
 
                        opBW->clear();
1103
 
                        rigbws_.clear();
1104
 
                        for (int i = 0; selrig->bandwidths_[i] != NULL; i++) {
1105
 
                                rigbws_.push_back(selrig->bandwidths_[i]);
1106
 
                                opBW->add(selrig->bandwidths_[i]);
1107
 
                        }
1108
 
 
1109
 
                        if (selrig->has_dsp_controls) {
1110
 
                                opDSP_lo->clear();
1111
 
                                opDSP_hi->clear();
1112
 
                                for (int i = 0; selrig->dsp_lo[i] != NULL; i++)
1113
 
                                        opDSP_lo->add(selrig->dsp_lo[i]);
1114
 
                                for (int i = 0; selrig->dsp_hi[i] != NULL; i++)
1115
 
                                        opDSP_hi->add(selrig->dsp_hi[i]);
1116
 
                                if (vfo.iBW > 256) {
1117
 
                                        opBW->index(0);
1118
 
                                        opBW->hide();
1119
 
                                        opBW->hide();
1120
 
                                        opDSP_lo->index(vfo.iBW & 0xFF);
1121
 
                                        opDSP_lo->hide();
1122
 
                                        opDSP_hi->index((vfo.iBW >> 8) & 0x7F);
1123
 
                                        btnDSP->label(selrig->lo_label);
1124
 
                                        opDSP_lo->show();
1125
 
                                        btnDSP->show();
1126
 
                                } else {
1127
 
                                        opDSP_lo->hide();
1128
 
                                        opDSP_hi->hide();
1129
 
                                        btnDSP->hide();
1130
 
                                        opBW->index(vfo.iBW);
1131
 
                                        opBW->show();
1132
 
                                }
1133
 
                        } else {  // no DSP control so update BW control, hide DSP
1134
 
                                opDSP_lo->hide();
1135
 
                                opDSP_hi->hide();
1136
 
                                btnDSP->hide();
1137
 
                                opBW->index(vfo.iBW);
1138
 
                                opBW->show();
1139
 
                        }
1140
 
                }
1141
 
        } else { // no BW, no DSP controls
1142
 
                opBW->index(0);
1143
 
                opBW->hide();
1144
 
                opDSP_lo->index(0);
1145
 
                opDSP_hi->index(0);
1146
 
                btnDSP->hide();
1147
 
                opDSP_lo->hide();
1148
 
                opDSP_hi->hide();
1149
 
        }
1150
 
}
1151
 
 
1152
 
void setMode()
1153
 
{
1154
 
        FREQMODE fm = vfo;
1155
 
        fm.imode = opMODE->index();
1156
 
        fm.iBW = selrig->def_bandwidth(fm.imode);
1157
 
        fm.src = UI;
1158
 
 
1159
 
        if (useB) {
1160
 
                pthread_mutex_lock(&mutex_queB);
1161
 
                queB.push(fm);
1162
 
                pthread_mutex_unlock(&mutex_queB);
1163
 
        } else {
1164
 
                pthread_mutex_lock(&mutex_queA);
1165
 
                queA.push(fm);
1166
 
                pthread_mutex_unlock(&mutex_queA);
1167
 
        }
1168
 
}
1169
 
 
1170
 
void sortList() {
1171
 
        if (!numinlist) return;
1172
 
        ATAG_FREQMODE temp;
1173
 
        for (int i = 0; i < numinlist - 1; i++)
1174
 
                for (int j = i + 1; j < numinlist; j++)
1175
 
                        if (oplist[i].freq > oplist[j].freq) {
1176
 
                                        temp = oplist[i];
1177
 
                                        oplist[i] = oplist[j];
1178
 
                                        oplist[j] = temp;
1179
 
                        }
1180
 
}
1181
 
 
1182
 
void clearList() {
1183
 
        if (!numinlist) return;
1184
 
        for (int i = 0; i < LISTSIZE; i++) {
1185
 
                oplist[i].freq = 0;
1186
 
                oplist[i].imode = USB;
1187
 
                oplist[i].iBW = 0;
1188
 
                memset(oplist[i].alpha_tag, 0, ATAGSIZE);
1189
 
        }
1190
 
        FreqSelect->clear();
1191
 
        numinlist = 0;
1192
 
        inAlphaTag->value("");
1193
 
}
1194
 
 
1195
 
void updateSelect() {
1196
 
        char szline[80 + ATAGSIZE];
1197
 
        char szatag[ATAGSIZE];
1198
 
        int i;
1199
 
        if (!numinlist) return;
1200
 
        sortList();
1201
 
        FreqSelect->clear();
1202
 
// stripe lines
1203
 
        int bg1, bg2, bg_clr;
1204
 
        // bg1 = FL_WHITE; bg2 = FL_LIGHT3;
1205
 
        bg1 = FL_WHITE; bg2 = FL_LIGHT2;
1206
 
 
1207
 
        for (int n = 0; n < numinlist; n++) {
1208
 
                memset(szline, 0, sizeof(szline));
1209
 
                memset(szatag, 0, sizeof(szatag));
1210
 
                for (i = 0; i < ATAGSIZE - 1; i++) {
1211
 
                        szatag[i] = oplist[n].alpha_tag[i];
1212
 
                        if (szatag[i] == 0) szatag[i] = ' ';
1213
 
                }
1214
 
                bg_clr = (n % 2) ? bg1 : bg2;
1215
 
                snprintf(szline, sizeof(szline),
1216
 
                        "@B%d@r%.3f\t@B%d@r%s\t@B%d@r%s\t@B%d@r%s", bg_clr,
1217
 
                        oplist[n].freq / 1000.0, bg_clr,
1218
 
                        selrig->get_bwname_(oplist[n].iBW, oplist[n].imode), bg_clr,
1219
 
                        selrig->get_modename_(oplist[n].imode), bg_clr,
1220
 
                        szatag );
1221
 
                FreqSelect->add (szline);
1222
 
        }
1223
 
        inAlphaTag->value("");
1224
 
}
1225
 
 
1226
 
void addtoList(int val, int imode, int iBW) {
1227
 
        if (numinlist < LISTSIZE) {
1228
 
                oplist[numinlist].imode = imode;
1229
 
                oplist[numinlist].freq = val;
1230
 
                oplist[numinlist].iBW = iBW;
1231
 
                memset(oplist[numinlist].alpha_tag, 0, ATAGSIZE);
1232
 
                numinlist++;
1233
 
        }
1234
 
}
1235
 
 
1236
 
void readFile() {
1237
 
        ifstream iList(defFileName.c_str());
1238
 
        if (!iList) {
1239
 
                fl_message ("Could not open %s", defFileName.c_str());
1240
 
                return;
1241
 
        }
1242
 
        clearList();
1243
 
        int i = 0, mode, bw;
1244
 
        long freq;
1245
 
        while (!iList.eof()) {
1246
 
                freq = 0L; mode = -1;
1247
 
                iList >> freq >> mode >> bw;
1248
 
                if (freq && (mode > -1)) {
1249
 
                        oplist[i].freq = freq;
1250
 
                        oplist[i].imode = mode;
1251
 
                        oplist[i].iBW = (bw == -1 ? 0 : bw);
1252
 
                        memset(oplist[i].alpha_tag, 0, ATAGSIZE);
1253
 
                        i++;
1254
 
                }
1255
 
        }
1256
 
        iList.close();
1257
 
        numinlist = i;
1258
 
        updateSelect();
1259
 
}
1260
 
 
1261
 
void readTagFile() {
1262
 
        ifstream iList(defFileName.c_str());
1263
 
        if (!iList) {
1264
 
                fl_message ("Could not open %s", defFileName.c_str());
1265
 
                return;
1266
 
        }
1267
 
        clearList();
1268
 
        int i = 0, mode, bw;
1269
 
        long freq;
1270
 
        string atag;
1271
 
        char ca[ATAGSIZE + 60];
1272
 
        while (!iList.eof()) {
1273
 
                freq = 0L; mode = -1;
1274
 
                atag.clear();
1275
 
                memset(ca, 0, sizeof(ca));
1276
 
                iList >> freq >> mode >> bw;
1277
 
                iList.getline(ca, sizeof(ca) - 1);
1278
 
                atag = ca;
1279
 
                if (freq && (mode > -1)) {
1280
 
                        oplist[i].freq = freq;
1281
 
                        oplist[i].imode = mode;
1282
 
                        oplist[i].iBW = (bw == -1 ? 0 : bw);
1283
 
// trim leading, trailing spaces and double quotes
1284
 
                        atag = lt_trim(atag);
1285
 
                        snprintf(oplist[i].alpha_tag, ATAGSIZE, "%s", atag.c_str());
1286
 
                        i++;
1287
 
                }
1288
 
        }
1289
 
        iList.close();
1290
 
        numinlist = i;
1291
 
        updateSelect();
1292
 
}
1293
 
 
1294
 
void buildlist() {
1295
 
        string tmpFN, orgFN;
1296
 
// check for new Memory-Alpha-Tag file
1297
 
        defFileName = RigHomeDir;
1298
 
        defFileName.append(selrig->name_);
1299
 
        defFileName.append(".mat");
1300
 
        FILE *fh = fopen(defFileName.c_str(), "r");
1301
 
        if (fh != NULL) {
1302
 
                fclose (fh);
1303
 
                readTagFile();
1304
 
                return;
1305
 
        }
1306
 
// else only read original file to make new MAT file
1307
 
        orgFN = RigHomeDir;
1308
 
        orgFN.append(selrig->name_);
1309
 
        orgFN.append(".arv");
1310
 
        fh = fopen(orgFN.c_str(), "r");
1311
 
        if (fh != NULL) {
1312
 
                fclose (fh);
1313
 
                tmpFN = defFileName;
1314
 
                defFileName = orgFN;
1315
 
                readFile();
1316
 
                defFileName = tmpFN;
1317
 
                return;
1318
 
        }
1319
 
        clearList();
1320
 
}
1321
 
 
1322
 
// flrig front panel changed
1323
 
 
1324
 
int movFreqA() {
1325
 
        FREQMODE vfo = vfoA;
1326
 
        vfo.freq = FreqDispA->value();
1327
 
        vfo.src = UI;
1328
 
        pthread_mutex_lock(&mutex_queA);
1329
 
        queA.push(vfo);
1330
 
        pthread_mutex_unlock(&mutex_queA);
1331
 
        return 1;
1332
 
}
1333
 
 
1334
 
int movFreqB() {
1335
 
        if (progStatus.split && (!selrig->twovfos()))
1336
 
                return 0; // disallow for ICOM transceivers
1337
 
        FREQMODE vfo = vfoB;
1338
 
        vfo.freq = FreqDispB->value();
1339
 
        vfo.src = UI;
1340
 
        pthread_mutex_lock(&mutex_queB);
1341
 
        queB.push(vfo);
1342
 
        pthread_mutex_unlock(&mutex_queB);
1343
 
        return 1;
1344
 
}
1345
 
 
1346
 
void cbAswapB()
1347
 
{
1348
 
        if (selrig->canswap()) {
1349
 
                selrig->swapvfos();
1350
 
                return;
1351
 
        }
1352
 
        if (Fl::event_button() == FL_RIGHT_MOUSE) {
1353
 
                return cbA2B();
1354
 
        }
1355
 
        if (!selrig->twovfos()) {
1356
 
                vfoB.freq = FreqDispB->value();
1357
 
                FREQMODE temp = vfoB;
1358
 
                vfoB = vfoA;
1359
 
                vfoA = temp;
1360
 
                FreqDispB->value(vfoB.freq);
1361
 
                FreqDispB->redraw();
1362
 
 
1363
 
                pthread_mutex_lock(&mutex_queA);
1364
 
                        while (!queA.empty()) queA.pop();
1365
 
                        queA.push(vfoA);
1366
 
                pthread_mutex_unlock(&mutex_queA);
1367
 
        } else {
1368
 
                pthread_mutex_lock(&mutex_serial);
1369
 
                        bypass_serial_thread_loop = true;
1370
 
                pthread_mutex_unlock(&mutex_serial);
1371
 
 
1372
 
                vfoB.freq = FreqDispB->value();
1373
 
                FREQMODE temp = vfoB;
1374
 
                vfoB = vfoA;
1375
 
                vfoA = temp;
1376
 
 
1377
 
                pthread_mutex_lock(&mutex_queA);
1378
 
                        while (!queA.empty()) queA.pop();
1379
 
                        queA.push(vfoA);
1380
 
                pthread_mutex_unlock(&mutex_queA);
1381
 
                pthread_mutex_lock(&mutex_queB);
1382
 
                        while (!queB.empty()) queB.pop();
1383
 
                        queB.push(vfoB);
1384
 
                pthread_mutex_unlock(&mutex_queB);
1385
 
                FreqDispB->value(vfoB.freq);
1386
 
                FreqDispB->redraw();
1387
 
                pushedB = true;
1388
 
 
1389
 
                pthread_mutex_lock(&mutex_serial);
1390
 
                        bypass_serial_thread_loop = false;
1391
 
                pthread_mutex_unlock(&mutex_serial);
1392
 
        }
1393
 
}
1394
 
 
1395
 
void cbA2B()
1396
 
{
1397
 
        if (rig_nbr == K3) {
1398
 
                K3_A2B();
1399
 
                return;
1400
 
        }
1401
 
        if (rig_nbr == K2) {
1402
 
                pthread_mutex_lock(&mutex_serial);
1403
 
                vfoB = vfoA;
1404
 
                selrig->set_vfoB(vfoB.freq);
1405
 
                FreqDispB->value(vfoB.freq);
1406
 
                pthread_mutex_unlock(&mutex_serial);
1407
 
                        return;
1408
 
        }
1409
 
        if (selrig->has_a2b) {
1410
 
                pthread_mutex_lock(&mutex_serial);
1411
 
                        selrig->A2B();
1412
 
                pthread_mutex_unlock(&mutex_serial);
1413
 
        }
1414
 
        vfoB = vfoA;
1415
 
        pthread_mutex_lock(&mutex_queB);
1416
 
        queB.push(vfoB);
1417
 
        pthread_mutex_unlock(&mutex_queB);
1418
 
        FreqDispB->value(vfoB.freq);
1419
 
        FreqDispB->redraw();
1420
 
        pushedB = true;
1421
 
}
1422
 
 
1423
 
void cb_set_split(int val)
1424
 
{
1425
 
        progStatus.split = val;
1426
 
 
1427
 
        if (selrig->has_split_AB) {
1428
 
                pthread_mutex_lock(&mutex_serial);
1429
 
                        selrig->set_split(val);
1430
 
                pthread_mutex_unlock(&mutex_serial);
1431
 
        } else if (val) {
1432
 
                if (useB) {
1433
 
                        if (vfoB.freq != FreqDispB->value()) {
1434
 
                                vfoB.freq = FreqDispB->value();
1435
 
                                pthread_mutex_lock(&mutex_serial);
1436
 
                                        selrig->selectB();
1437
 
                                        selrig->set_vfoB(vfoB.freq);
1438
 
                                        selrig->selectA();
1439
 
                                pthread_mutex_unlock(&mutex_serial);
1440
 
                        }
1441
 
                        btnA->value(1);
1442
 
                        btnB->value(0);
1443
 
                        cb_selectA();
1444
 
                }
1445
 
        } else
1446
 
                cb_selectA();
1447
 
 
1448
 
}
1449
 
 
1450
 
void highlight_vfo(void *d)
1451
 
{
1452
 
        Fl_Color norm_fg = fl_rgb_color(progStatus.fg_red, progStatus.fg_green, progStatus.fg_blue);
1453
 
        Fl_Color norm_bg = fl_rgb_color(progStatus.bg_red, progStatus.bg_green, progStatus.bg_blue);
1454
 
        Fl_Color dim_bg = fl_color_average( norm_bg, FL_BLACK, 0.75);
1455
 
        if (useB) {
1456
 
                FreqDispA->SetONOFFCOLOR( norm_fg, dim_bg );
1457
 
                FreqDispB->SetONOFFCOLOR( norm_fg, norm_bg );
1458
 
                btnA->value(0);
1459
 
                btnB->value(1);
1460
 
        } else {
1461
 
                FreqDispA->SetONOFFCOLOR( norm_fg, norm_bg );
1462
 
                FreqDispB->SetONOFFCOLOR( norm_fg, dim_bg);
1463
 
                btnA->value(1);
1464
 
                btnB->value(0);
1465
 
        }
1466
 
        FreqDispA->redraw();
1467
 
        FreqDispB->redraw();
1468
 
        btnA->redraw();
1469
 
        btnB->redraw();
1470
 
        Fl::flush();
1471
 
}
1472
 
 
1473
 
void cb_selectA() {
1474
 
        if (progStatus.split) {
1475
 
                btnSplit->value(0);
1476
 
                if (!selrig->has_split_AB)
1477
 
                        cb_set_split(0);
1478
 
        }
1479
 
        pthread_mutex_lock(&mutex_serial);
1480
 
        changed_vfo = true;
1481
 
        vfoA.src = UI;
1482
 
        vfoA.freq = FreqDispA->value();
1483
 
        pthread_mutex_lock(&mutex_queA);
1484
 
        queA.push(vfoA);
1485
 
        useB = false;
1486
 
        pthread_mutex_unlock(&mutex_queA);
1487
 
        pthread_mutex_unlock(&mutex_serial);
1488
 
        highlight_vfo((void *)0);
1489
 
}
1490
 
 
1491
 
void cb_selectB() {
1492
 
        if (progStatus.split) {
1493
 
                btnSplit->value(0);
1494
 
                if (!selrig->has_split_AB)
1495
 
                        cb_set_split(0);
1496
 
        }
1497
 
        pthread_mutex_lock(&mutex_serial);
1498
 
        changed_vfo = true;
1499
 
        vfoB.src = UI;
1500
 
        vfoB.freq = FreqDispB->value();
1501
 
        pthread_mutex_lock(&mutex_queB);
1502
 
        queB.push(vfoB);
1503
 
        useB = true;
1504
 
        pthread_mutex_unlock(&mutex_queB);
1505
 
        pthread_mutex_unlock(&mutex_serial);
1506
 
        highlight_vfo((void *)0);
1507
 
}
1508
 
 
1509
 
void setLower()
1510
 
{
1511
 
}
1512
 
 
1513
 
void setUpper()
1514
 
{
1515
 
}
1516
 
 
1517
 
void selectFreq() {
1518
 
        long n = FreqSelect->value();
1519
 
        if (!n) return;
1520
 
 
1521
 
        n--;
1522
 
        FREQMODE fm;
1523
 
        fm.freq  = oplist[n].freq;
1524
 
        fm.imode = oplist[n].imode;
1525
 
        fm.iBW   = oplist[n].iBW;
1526
 
        fm.src   = UI;
1527
 
        if (!useB) {
1528
 
                FreqDispA->value(fm.freq);
1529
 
                pthread_mutex_lock(&mutex_queA);
1530
 
                queA.push(fm);
1531
 
                pthread_mutex_unlock(&mutex_queA);
1532
 
        } else {
1533
 
                FreqDispB->value(fm.freq);
1534
 
                pthread_mutex_lock(&mutex_queB);
1535
 
                queB.push(fm);
1536
 
                pthread_mutex_unlock(&mutex_queB);
1537
 
        }
1538
 
}
1539
 
 
1540
 
void select_and_close()
1541
 
{
1542
 
        switch (Fl::event_button()) {
1543
 
                case FL_LEFT_MOUSE:
1544
 
                        if (FreqSelect->value() > 0)
1545
 
                                inAlphaTag->value(oplist[FreqSelect->value() - 1].alpha_tag);
1546
 
                        if (Fl::event_clicks()) { // double click
1547
 
                                selectFreq();
1548
 
                                cbCloseMemory();
1549
 
                        }
1550
 
                        break;
1551
 
                case FL_RIGHT_MOUSE:
1552
 
                        if (FreqSelect->value() > 0)
1553
 
                                inAlphaTag->value(oplist[FreqSelect->value() - 1].alpha_tag);
1554
 
                        selectFreq();
1555
 
                        break;
1556
 
                default:
1557
 
                        break;
1558
 
        }
1559
 
 
1560
 
// update Alpha Tag field when keyboard scrolling
1561
 
        switch (Fl::event_key()) {
1562
 
                case FL_Up:
1563
 
                case FL_Down:
1564
 
                        if (FreqSelect->value() > 0)
1565
 
                                inAlphaTag->value(oplist[FreqSelect->value() - 1].alpha_tag);
1566
 
                        break;
1567
 
                default:
1568
 
                        break;
1569
 
        }
1570
 
}
1571
 
 
1572
 
void delFreq() {
1573
 
        if (FreqSelect->value()) {
1574
 
                long n = FreqSelect->value() - 1;
1575
 
                for (int i = n; i < numinlist; i ++)
1576
 
                        oplist[i] = oplist[i+1];
1577
 
                oplist[numinlist - 1].imode = USB;
1578
 
                oplist[numinlist - 1].freq = 0;
1579
 
                oplist[numinlist - 1].iBW = 0;
1580
 
                memset(oplist[numinlist - 1].alpha_tag, 0, ATAGSIZE);
1581
 
                numinlist--;
1582
 
                updateSelect();
1583
 
        }
1584
 
}
1585
 
 
1586
 
void addFreq() {
1587
 
        if (useB) {
1588
 
                long freq = FreqDispB->value();
1589
 
                if (!freq) return;
1590
 
                int mode = opMODE->index();
1591
 
                int bw;
1592
 
                if (btnDSP->visible())
1593
 
                        bw = ((opDSP_hi->index() << 8) | 0x8000) | (opDSP_lo->index() & 0xFF) ;
1594
 
                else
1595
 
                        bw = opBW->index();
1596
 
                for (int n = 0; n < numinlist; n++)
1597
 
                        if (freq == oplist[n].freq && mode == oplist[n].imode) {
1598
 
                                oplist[n].iBW = bw;
1599
 
                                updateSelect(); // update list
1600
 
                                return;
1601
 
                        }
1602
 
                addtoList(freq, mode, bw);
1603
 
                updateSelect();
1604
 
                FreqDispB->visual_beep();
1605
 
                } else {
1606
 
                long freq = FreqDispA->value();
1607
 
                if (!freq) return;
1608
 
                int mode = opMODE->index();
1609
 
                int bw;
1610
 
                if (btnDSP->visible())
1611
 
                        bw = ((opDSP_hi->index() << 8) | 0x8000) | (opDSP_lo->index() & 0xFF) ;
1612
 
                else
1613
 
                        bw = opBW->index();
1614
 
                for (int n = 0; n < numinlist; n++)
1615
 
                        if (freq == oplist[n].freq && mode == oplist[n].imode) {
1616
 
                                oplist[n].iBW = bw;
1617
 
                                updateSelect(); // update list
1618
 
                                return;
1619
 
                        }
1620
 
                addtoList(freq, mode, bw);
1621
 
                updateSelect();
1622
 
                FreqDispA->visual_beep();
1623
 
                }
1624
 
}
1625
 
 
1626
 
void cbRIT()
1627
 
{
1628
 
        pthread_mutex_lock(&mutex_serial);
1629
 
        if (selrig->has_rit)
1630
 
                selrig->setRit((int)cntRIT->value());
1631
 
        pthread_mutex_unlock(&mutex_serial);
1632
 
}
1633
 
 
1634
 
void cbXIT()
1635
 
{
1636
 
        pthread_mutex_lock(&mutex_serial);
1637
 
        selrig->setXit((int)cntXIT->value());
1638
 
        pthread_mutex_unlock(&mutex_serial);
1639
 
}
1640
 
 
1641
 
void cbBFO()
1642
 
{
1643
 
        if (selrig->has_bfo)
1644
 
        pthread_mutex_lock(&mutex_serial);
1645
 
                selrig->setBfo((int)cntBFO->value());
1646
 
        pthread_mutex_unlock(&mutex_serial);
1647
 
}
1648
 
 
1649
 
void cbAttenuator()
1650
 
{
1651
 
        pthread_mutex_lock(&mutex_serial);
1652
 
                progStatus.attenuator = btnAttenuator->value();
1653
 
                selrig->set_attenuator(progStatus.attenuator);
1654
 
        pthread_mutex_unlock(&mutex_serial);
1655
 
}
1656
 
 
1657
 
void setAttControl(void *d)
1658
 
{
1659
 
        int val = (long)d;
1660
 
        btnAttenuator->value(val);
1661
 
}
1662
 
 
1663
 
void cbPreamp()
1664
 
{
1665
 
        pthread_mutex_lock(&mutex_serial);
1666
 
                progStatus.preamp = btnPreamp->value();
1667
 
                selrig->set_preamp(progStatus.preamp);
1668
 
        pthread_mutex_unlock(&mutex_serial);
1669
 
}
1670
 
 
1671
 
void setPreampControl(void *d)
1672
 
{
1673
 
        int val = (long)d;
1674
 
        btnPreamp->value(val);
1675
 
}
1676
 
 
1677
 
void cbNoise()
1678
 
{
1679
 
        progStatus.noise = btnNOISE->value();
1680
 
        pthread_mutex_lock(&mutex_serial);
1681
 
                selrig->set_noise(progStatus.noise);
1682
 
        pthread_mutex_unlock(&mutex_serial);
1683
 
}
1684
 
 
1685
 
void cbNR()
1686
 
{
1687
 
        if (!selrig->has_noise_reduction_control) return;
1688
 
        noise_reduction_changed = true;
1689
 
        sliders.push(SLIDER(NR, sldrNR->value(), btnNR->value() ) );
1690
 
 
1691
 
}
1692
 
 
1693
 
void setNR()
1694
 
{
1695
 
        if (!selrig->has_noise_reduction_control) return;
1696
 
        noise_reduction_changed = true;
1697
 
        if (rig_nbr == TS2000 || rig_nbr == TS590S || rig_nbr == TS990)
1698
 
                sliders.push(SLIDER(NR, sldrNR->value(), -1 ) );
1699
 
        else
1700
 
                sliders.push(SLIDER(NR, sldrNR->value(), btnNR->value() ) );
1701
 
}
1702
 
 
1703
 
void cbAN()
1704
 
{
1705
 
        progStatus.auto_notch = btnAutoNotch->value();
1706
 
        pthread_mutex_lock(&mutex_serial);
1707
 
                selrig->set_auto_notch(progStatus.auto_notch);
1708
 
        pthread_mutex_unlock(&mutex_serial);
1709
 
}
1710
 
 
1711
 
void cbbtnNotch()
1712
 
{
1713
 
        if (!selrig->has_notch_control) return;
1714
 
        notch_changed = true;
1715
 
        sliders.push(SLIDER(NOTCH, sldrNOTCH->value(), btnNotch->value() ));
1716
 
}
1717
 
 
1718
 
void setNotch()
1719
 
{
1720
 
        if (!selrig->has_notch_control) return;
1721
 
        notch_changed = true;
1722
 
        sliders.push(SLIDER(NOTCH, sldrNOTCH->value(), btnNotch->value() ));
1723
 
}
1724
 
 
1725
 
// called from xml_io thread
1726
 
void setNotchControl(void *d)
1727
 
{
1728
 
        int val = (long)d;
1729
 
        if (val) {
1730
 
                progStatus.notch_val = val;
1731
 
                progStatus.notch = true;
1732
 
        } else
1733
 
                progStatus.notch = false;
1734
 
 
1735
 
        pthread_mutex_lock(&mutex_serial);
1736
 
                selrig->set_notch(progStatus.notch, progStatus.notch_val);
1737
 
        pthread_mutex_unlock(&mutex_serial);
1738
 
 
1739
 
        sldrNOTCH->value(progStatus.notch_val);
1740
 
        btnNotch->value(progStatus.notch);
1741
 
}
1742
 
 
1743
 
void adjust_if_shift_control(void *d)
1744
 
{
1745
 
        sldrIFSHIFT->minimum(selrig->if_shift_min);
1746
 
        sldrIFSHIFT->maximum(selrig->if_shift_max);
1747
 
        sldrIFSHIFT->step(selrig->if_shift_step);
1748
 
        sldrIFSHIFT->value(selrig->if_shift_mid);
1749
 
        sldrIFSHIFT->redraw();
1750
 
        btnIFsh->value(0);
1751
 
        btnIFsh->redraw();
1752
 
}
1753
 
 
1754
 
void setIFshiftButton(void *d)
1755
 
{
1756
 
        bool b = (bool)d;
1757
 
        if (b && !btnIFsh->value()) {
1758
 
                btnIFsh->value(1);
1759
 
        }
1760
 
        else if (!b && btnIFsh->value()) {
1761
 
                btnIFsh->value(0);
1762
 
                sldrIFSHIFT->value( selrig->if_shift_mid );
1763
 
        }
1764
 
}
1765
 
 
1766
 
void setIFshiftControl(void *d)
1767
 
{
1768
 
        int val = (long)d;
1769
 
        if (sldrIFSHIFT->value() != val)
1770
 
                sldrIFSHIFT->value(val);
1771
 
        btnIFsh->value( val != selrig->if_shift_mid );
1772
 
}
1773
 
 
1774
 
void setIFshift()
1775
 
{
1776
 
        if_shift_changed = true;
1777
 
        sliders.push(SLIDER(IFSH, sldrIFSHIFT->value(), btnIFsh->value()));
1778
 
}
1779
 
 
1780
 
void cbIFsh()
1781
 
{
1782
 
        if_shift_changed = true;
1783
 
        sliders.push(SLIDER(IFSH, sldrIFSHIFT->value(), btnIFsh->value()));
1784
 
}
1785
 
 
1786
 
void cbEventLog()
1787
 
{
1788
 
        debug::show();
1789
 
}
1790
 
 
1791
 
void setVolume()
1792
 
{
1793
 
        volume_changed = true;
1794
 
        sliders.push(SLIDER(VOL, sldrVOLUME->value()));
1795
 
}
1796
 
 
1797
 
void cbMute()
1798
 
{
1799
 
        volume_changed = true;
1800
 
        if (btnVol->value() == 0) {
1801
 
                sldrVOLUME->deactivate();
1802
 
                sliders.push(SLIDER(VOL, 0));
1803
 
        } else {
1804
 
                sldrVOLUME->activate();
1805
 
                sliders.push(SLIDER(VOL, sldrVOLUME->value()));
1806
 
        }
1807
 
}
1808
 
 
1809
 
void setMicGain()
1810
 
{
1811
 
        mic_changed = true;
1812
 
        sliders.push(SLIDER(MIC, sldrMICGAIN->value()));
1813
 
}
1814
 
 
1815
 
void setMicGainControl(void* d)
1816
 
{
1817
 
        int val = (long)d;
1818
 
        sldrMICGAIN->value(val);
1819
 
}
1820
 
 
1821
 
static int img = -1;
1822
 
 
1823
 
void set_power_controlImage(double pwr)
1824
 
{
1825
 
        if (progStatus.pwr_scale == 0 || (progStatus.pwr_scale == 4 && pwr < 26.0)) {
1826
 
                if (img != 1) {
1827
 
                        img = 1;
1828
 
                        scalePower->image(image_p25);
1829
 
                        sldrFwdPwr->maximum(25.0);
1830
 
                        sldrFwdPwr->minimum(0.0);
1831
 
                        scalePower->redraw();
1832
 
                }
1833
 
        }
1834
 
        else if (progStatus.pwr_scale == 1 || (progStatus.pwr_scale == 4 && pwr < 51.0)) {
1835
 
                if (img != 2) {
1836
 
                        img = 2;
1837
 
                        scalePower->image(image_p50);
1838
 
                        sldrFwdPwr->maximum(50.0);
1839
 
                        sldrFwdPwr->minimum(0.0);
1840
 
                        scalePower->redraw();
1841
 
                }
1842
 
        }
1843
 
        else if (progStatus.pwr_scale == 2 || (progStatus.pwr_scale == 4 && pwr < 101.0)) {
1844
 
                if (img != 3) {
1845
 
                        img = 3;
1846
 
                        scalePower->image(image_p100);
1847
 
                        sldrFwdPwr->maximum(100.0);
1848
 
                        sldrFwdPwr->minimum(0.0);
1849
 
                        scalePower->redraw();
1850
 
                }
1851
 
        }
1852
 
        else if (progStatus.pwr_scale >= 3) {
1853
 
                if (img != 4) {
1854
 
                        img = 4;
1855
 
                        scalePower->image(image_p200);
1856
 
                        sldrFwdPwr->maximum(200.0);
1857
 
                        sldrFwdPwr->minimum(0.0);
1858
 
                        scalePower->redraw();
1859
 
                }
1860
 
        }
1861
 
        return;
1862
 
}
1863
 
 
1864
 
void setPower()
1865
 
{
1866
 
        float pwr = progStatus.power_level = sldrPOWER->value();
1867
 
        power_changed = true;
1868
 
        sliders.push(SLIDER(PWR, progStatus.power_level));
1869
 
 
1870
 
        if (rig_nbr == K2) {
1871
 
                double min, max, step;
1872
 
                selrig->get_pc_min_max_step(min, max, step);
1873
 
                sldrPOWER->minimum(min);
1874
 
                sldrPOWER->maximum(max);
1875
 
                sldrPOWER->step(step);
1876
 
                sldrPOWER->value(progStatus.power_level);
1877
 
                sldrPOWER->redraw();
1878
 
        }
1879
 
        set_power_controlImage(pwr);
1880
 
}
1881
 
 
1882
 
void cbTune()
1883
 
{
1884
 
        pthread_mutex_lock(&mutex_serial);
1885
 
                selrig->tune_rig();
1886
 
        pthread_mutex_unlock(&mutex_serial);
1887
 
}
1888
 
 
1889
 
void cbPTT()
1890
 
{
1891
 
        if (fldigi_online && progStatus.key_fldigi)
1892
 
                send_ptt_changed(btnPTT->value());
1893
 
        else {
1894
 
                pthread_mutex_lock(&mutex_ptt);
1895
 
                quePTT.push(btnPTT->value());
1896
 
                pthread_mutex_unlock(&mutex_ptt);
1897
 
        }
1898
 
}
1899
 
 
1900
 
void setSQUELCH()
1901
 
{
1902
 
        squelch_changed = true;
1903
 
        sliders.push(SLIDER(SQL, sldrSQUELCH->value() ));
1904
 
}
1905
 
 
1906
 
void setRFGAIN()
1907
 
{
1908
 
        rfgain_changed = true;
1909
 
        sliders.push(SLIDER(RFGAIN, sldrRFGAIN->value() ));
1910
 
}
1911
 
 
1912
 
 
1913
 
void updateALC(void * d)
1914
 
{
1915
 
        if (meter_image != ALC_IMAGE) return;
1916
 
        double data = (long)d;
1917
 
        sldrRcvSignal->hide();
1918
 
        sldrSWR->hide();
1919
 
        sldrALC->value(data);
1920
 
        sldrALC->redraw();
1921
 
}
1922
 
 
1923
 
void updateSWR(void * d)
1924
 
{
1925
 
        if (meter_image != SWR_IMAGE) return;
1926
 
        double data = (long)d;
1927
 
        if (selrig->has_swr_control) {
1928
 
                sldrRcvSignal->hide();
1929
 
                sldrALC->hide();
1930
 
                sldrSWR->show();
1931
 
        }
1932
 
        sldrSWR->value(data);
1933
 
        sldrSWR->redraw();
1934
 
}
1935
 
 
1936
 
void updateFwdPwr(void *d)
1937
 
{
1938
 
        double power = (long)d;
1939
 
        if (!sldrFwdPwr->visible()) {
1940
 
                sldrFwdPwr->show();
1941
 
        }
1942
 
        sldrFwdPwr->value(power);
1943
 
        sldrFwdPwr->redraw();
1944
 
        if (!selrig->has_power_control)
1945
 
                set_power_controlImage(sldrFwdPwr->peak());
1946
 
}
1947
 
 
1948
 
void updateSquelch(void *d)
1949
 
{
1950
 
        sldrSQUELCH->value((long)d);
1951
 
        sldrSQUELCH->redraw();
1952
 
}
1953
 
 
1954
 
void updateRFgain(void *d)
1955
 
{
1956
 
        sldrRFGAIN->value((long)d);
1957
 
        sldrRFGAIN->redraw();
1958
 
}
1959
 
 
1960
 
void zeroXmtMeters(void *d)
1961
 
{
1962
 
        sldrFwdPwr->clear();
1963
 
        sldrALC->clear();
1964
 
        sldrSWR->clear();
1965
 
        updateFwdPwr(0);
1966
 
        updateALC(0);
1967
 
        updateSWR(0);
1968
 
}
1969
 
 
1970
 
void setFreqDispA(void *d)
1971
 
{
1972
 
        long f = (long)d;
1973
 
        FreqDispA->value(f);
1974
 
        FreqDispA->redraw();
1975
 
}
1976
 
 
1977
 
void setFreqDispB(void *d)
1978
 
{
1979
 
        long f = (long)d;
1980
 
        FreqDispB->value(f);
1981
 
        FreqDispB->redraw();
1982
 
}
1983
 
 
1984
 
void updateSmeter(void *d) // 0 to 100;
1985
 
{
1986
 
        double smeter = (long)d;
1987
 
        if (!sldrRcvSignal->visible()) {
1988
 
                sldrRcvSignal->show();
1989
 
                sldrFwdPwr->hide();
1990
 
                sldrALC->hide();
1991
 
                sldrSWR->hide();
1992
 
        }
1993
 
        sldrRcvSignal->value(smeter);
1994
 
        sldrRcvSignal->redraw();
1995
 
}
1996
 
 
1997
 
void saveFreqList()
1998
 
{
1999
 
        string atag;
2000
 
        if (!numinlist) {
2001
 
                remove(defFileName.c_str());
2002
 
                return;
2003
 
        }
2004
 
        ofstream oList(defFileName.c_str());
2005
 
        if (!oList) {
2006
 
                fl_message ("Could not write to %s", defFileName.c_str());
2007
 
                return;
2008
 
        }
2009
 
        for (int i = 0; i < numinlist; i++) {
2010
 
                atag = oplist[i].alpha_tag;
2011
 
                oList << oplist[i].freq << " " << oplist[i].imode << " " << oplist[i].iBW << " \"" << atag.c_str() << "\"" << endl;
2012
 
 
2013
 
        }
2014
 
        oList.close();
2015
 
}
2016
 
 
2017
 
void setPTT( void *d)
2018
 
{
2019
 
        int val = (long)d;
2020
 
        pthread_mutex_lock(&mutex_ptt);
2021
 
        quePTT.push(val);
2022
 
        pthread_mutex_unlock(&mutex_ptt);
2023
 
}
2024
 
 
2025
 
 
2026
 
void closeRig()
2027
 
{
2028
 
        // restore initial rig settings
2029
 
        pthread_mutex_lock(&mutex_serial);
2030
 
        selrig->set_vfoA(transceiverA.freq);
2031
 
        selrig->set_modeA(transceiverA.imode);
2032
 
        selrig->set_bwA(transceiverA.iBW);
2033
 
        selrig->set_vfoB(transceiverB.freq);
2034
 
        selrig->set_modeB(transceiverB.imode);
2035
 
        selrig->set_bwB(transceiverB.iBW);
2036
 
        pthread_mutex_unlock(&mutex_serial);
2037
 
}
2038
 
 
2039
 
 
2040
 
void cbExit()
2041
 
{
2042
 
        // shutdown xmlrpc thread
2043
 
        close_rig_xmlrpc();
2044
 
 
2045
 
        pthread_mutex_lock(&mutex_xmlrpc);
2046
 
        run_digi_loop = false;
2047
 
        pthread_mutex_unlock(&mutex_xmlrpc);
2048
 
        pthread_join(*digi_thread, NULL);
2049
 
 
2050
 
        progStatus.rig_nbr = rig_nbr;
2051
 
 
2052
 
        progStatus.freq_A = vfoA.freq;
2053
 
        progStatus.imode_A = vfoA.imode;
2054
 
        progStatus.iBW_A = vfoA.iBW;
2055
 
 
2056
 
        progStatus.freq_B = vfoB.freq;
2057
 
        progStatus.imode_B = vfoB.imode;
2058
 
        progStatus.iBW_B = vfoB.iBW;
2059
 
 
2060
 
        progStatus.spkr_on = btnVol->value();
2061
 
        progStatus.volume = sldrVOLUME->value();
2062
 
        progStatus.power_level = sldrPOWER->value();
2063
 
        progStatus.rfgain = sldrRFGAIN->value();
2064
 
        progStatus.mic_gain = sldrMICGAIN->value();
2065
 
        progStatus.notch = btnNotch->value();
2066
 
        progStatus.notch_val = sldrNOTCH->value();
2067
 
        progStatus.shift = btnIFsh->value();
2068
 
        progStatus.shift_val = sldrIFSHIFT->value();
2069
 
        progStatus.noise_reduction = btnNR->value();
2070
 
        progStatus.noise_reduction_val = sldrNR->value();
2071
 
        progStatus.noise = btnNOISE->value();
2072
 
        progStatus.attenuator = btnAttenuator->value();
2073
 
        progStatus.preamp = btnPreamp->value();
2074
 
        progStatus.auto_notch = btnAutoNotch->value();
2075
 
        progStatus.saveLastState();
2076
 
 
2077
 
        saveFreqList();
2078
 
 
2079
 
// shutdown serial thread
2080
 
 
2081
 
        pthread_mutex_lock(&mutex_serial);
2082
 
                run_serial_thread = false;
2083
 
        pthread_mutex_unlock(&mutex_serial);
2084
 
        pthread_join(*serial_thread, NULL);
2085
 
 
2086
 
        if (progStatus.restore_rig_data){
2087
 
                selrig->set_vfoA(transceiverA.freq);
2088
 
                selrig->set_modeA(transceiverA.imode);
2089
 
                selrig->set_bwA(transceiverA.iBW);
2090
 
                selrig->set_vfoB(transceiverB.freq);
2091
 
                selrig->set_modeB(transceiverB.imode);
2092
 
                selrig->set_bwB(transceiverB.iBW);
2093
 
        }
2094
 
 
2095
 
        selrig->shutdown();
2096
 
 
2097
 
        // xcvr auto off
2098
 
        if (selrig->has_xcvr_auto_on_off)
2099
 
                selrig->set_xcvr_auto_off();
2100
 
 
2101
 
        // close down the serial port
2102
 
        RigSerial.ClosePort();
2103
 
 
2104
 
        // restore fldigi to its no-rig state
2105
 
        try {
2106
 
                send_no_rig();
2107
 
        } catch (...) { }
2108
 
 
2109
 
        if (dlgDisplayConfig && dlgDisplayConfig->visible())
2110
 
                dlgDisplayConfig->hide();
2111
 
        if (dlgXcvrConfig && dlgXcvrConfig->visible())
2112
 
                dlgXcvrConfig->hide();
2113
 
        if (dlgMemoryDialog && dlgMemoryDialog->visible())
2114
 
                dlgMemoryDialog->hide();
2115
 
        debug::stop();
2116
 
 
2117
 
        exit(0);
2118
 
}
2119
 
 
2120
 
void cbALC_SWR()
2121
 
{
2122
 
        if (!selrig->has_alc_control) return;
2123
 
        if (meter_image == SWR_IMAGE) {
2124
 
                btnALC_SWR->image(image_alc);
2125
 
                meter_image = ALC_IMAGE;
2126
 
                sldrALC->show();
2127
 
                pthread_mutex_lock(&mutex_serial);
2128
 
                        selrig->select_alc();
2129
 
                pthread_mutex_unlock(&mutex_serial);
2130
 
        } else {
2131
 
                btnALC_SWR->image(image_swr);
2132
 
                meter_image = SWR_IMAGE;
2133
 
                sldrSWR->show();
2134
 
                pthread_mutex_lock(&mutex_serial);
2135
 
                        selrig->select_swr();
2136
 
                pthread_mutex_unlock(&mutex_serial);
2137
 
        }
2138
 
        btnALC_SWR->redraw();
2139
 
}
2140
 
 
2141
 
void update_UI_PTT(void *d)
2142
 
{
2143
 
        btnPTT->value(PTT);
2144
 
        if (!PTT) {
2145
 
                btnALC_SWR->hide();
2146
 
                scaleSmeter->show();
2147
 
                sldrRcvSignal->clear();
2148
 
        } else {
2149
 
                btnALC_SWR->show();
2150
 
                scaleSmeter->hide();
2151
 
                sldrFwdPwr->clear();
2152
 
                sldrALC->clear();
2153
 
                sldrSWR->clear();
2154
 
        }
2155
 
}
2156
 
 
2157
 
void adjust_control_positions()
2158
 
{
2159
 
// small_ui (ORIGINAL) USER INTERFACE
2160
 
if (progStatus.UIsize == small_ui)
2161
 
{
2162
 
        int y = 0;
2163
 
 
2164
 
        btnVol->hide();
2165
 
        sldrVOLUME->hide();
2166
 
        sldrRFGAIN->hide();
2167
 
        btnIFsh->hide();
2168
 
        sldrIFSHIFT->hide();
2169
 
        btnNotch->hide();
2170
 
        sldrNOTCH->hide();
2171
 
        sldrMICGAIN->hide();
2172
 
        sldrPOWER->hide();
2173
 
        sldrSQUELCH->hide();
2174
 
        btnNR->hide();
2175
 
        sldrNR->hide();
2176
 
 
2177
 
        if (progStatus.schema == 1 && selrig->widgets[0].W != NULL) {
2178
 
                int i = 0;
2179
 
                while (selrig->widgets[i].W != NULL) {
2180
 
                        selrig->widgets[i].W->resize(
2181
 
                                selrig->widgets[i].x, selrig->widgets[i].y,
2182
 
                                selrig->widgets[i].w, selrig->widgets[i].W->h() );
2183
 
                        selrig->widgets[i].W->show();
2184
 
                        selrig->widgets[i].W->redraw();
2185
 
                        if (selrig->widgets[i].y > y) y = selrig->widgets[i].y;
2186
 
                        i++;
2187
 
                }
2188
 
                if (selrig->has_data_port) {
2189
 
                        sldrMICGAIN->label("");
2190
 
                        sldrMICGAIN->redraw_label();
2191
 
                }
2192
 
        } else {
2193
 
                y = cntRIT->y() + 2;
2194
 
                if (selrig->has_volume_control) {
2195
 
                        y += 20;
2196
 
                        btnVol->position( 2, y);
2197
 
                        btnVol->show();
2198
 
                        btnVol->redraw();
2199
 
                        sldrVOLUME->resize( 54, y, 368, 18 );
2200
 
                        sldrVOLUME->show();
2201
 
                        sldrVOLUME->redraw();
2202
 
                }
2203
 
                if (selrig->has_rf_control) {
2204
 
                        y += 20;
2205
 
                        sldrRFGAIN->resize( 54, y, 368, 18 );
2206
 
                        sldrRFGAIN->show();
2207
 
                        sldrRFGAIN->redraw();
2208
 
                }
2209
 
                if (selrig->has_sql_control) {
2210
 
                        y += 20;
2211
 
                        sldrSQUELCH->resize( 54, y, 368, 18 );
2212
 
                        sldrSQUELCH->show();
2213
 
                        sldrSQUELCH->redraw();
2214
 
                }
2215
 
                if (selrig->has_noise_reduction_control) {
2216
 
                        y += 20;
2217
 
                        btnNR->position( 2, y);
2218
 
                        btnNR->show();
2219
 
                        btnNR->redraw();
2220
 
                        sldrNR->resize( 54, y, 368, 18 );
2221
 
                        sldrNR->show();
2222
 
                        sldrNR->redraw();
2223
 
                }
2224
 
                if (selrig->has_ifshift_control) {
2225
 
                        y += 20;
2226
 
                        btnIFsh->position( 2, y);
2227
 
                        btnIFsh->show();
2228
 
                        btnIFsh->redraw();
2229
 
                        sldrIFSHIFT->resize( 54, y, 368, 18 );
2230
 
                        sldrIFSHIFT->show();
2231
 
                        sldrIFSHIFT->redraw();
2232
 
                }
2233
 
                if (selrig->has_notch_control) {
2234
 
                        y += 20;
2235
 
                        btnNotch->position( 2, y);
2236
 
                        btnNotch->show();
2237
 
                        btnNotch->redraw();
2238
 
                        sldrNOTCH->resize( 54, y, 368, 18 );
2239
 
                        sldrNOTCH->show();
2240
 
                        sldrNOTCH->redraw();
2241
 
                }
2242
 
                if (selrig->has_micgain_control) {
2243
 
                        y += 20;
2244
 
                        if (selrig->has_data_port) {
2245
 
                                sldrMICGAIN->label("");
2246
 
                                sldrMICGAIN->redraw_label();
2247
 
                                btnDataPort->position( 2, y);
2248
 
                                btnDataPort->show();
2249
 
                                btnDataPort->redraw();
2250
 
                        }
2251
 
                        sldrMICGAIN->resize( 54, y, 368, 18 );
2252
 
                        sldrMICGAIN->show();
2253
 
                        sldrMICGAIN->redraw();
2254
 
                }
2255
 
                if (selrig->has_power_control) {
2256
 
                        y += 20;
2257
 
                        sldrPOWER->resize( 54, y, 368, 18 );
2258
 
                        sldrPOWER->show();
2259
 
                        sldrPOWER->redraw();
2260
 
                }
2261
 
        }
2262
 
        y += 20;
2263
 
        btn_show_controls->position( btn_show_controls->x(), y );
2264
 
        btnAttenuator->position( btnAttenuator->x(), y);
2265
 
        btnAttenuator->redraw();
2266
 
        btnPreamp->position( btnPreamp->x(), y);
2267
 
        btnPreamp->redraw();
2268
 
        btnNOISE->position( btnNOISE->x(), y);
2269
 
        btnNOISE->redraw();
2270
 
        btnAutoNotch->position( btnAutoNotch->x(), y);
2271
 
        btnAutoNotch->redraw();
2272
 
        btnTune->position( btnTune->x(), y);
2273
 
        btnTune->redraw();
2274
 
 
2275
 
        if (rig_nbr == FT1000MP) {
2276
 
                y -= 20;
2277
 
                btnTune->position( btnTune->x(), y);
2278
 
                btnTune->redraw();
2279
 
                btnAutoNotch->position( btnAutoNotch->x(), y);
2280
 
                btnAutoNotch->redraw();
2281
 
                btnPTT->position( btnPTT->x(), y);
2282
 
                btnPTT->redraw();
2283
 
        }
2284
 
 
2285
 
        if (    rig_nbr == FT100D ||
2286
 
                        rig_nbr == FT767  ||
2287
 
                        rig_nbr == FT817  ||
2288
 
                        rig_nbr == FT847  ||
2289
 
                        rig_nbr == FT857D ||
2290
 
                        rig_nbr == FT890  ||
2291
 
                        rig_nbr == FT897D ||
2292
 
                        rig_nbr == FT920 ) {
2293
 
                y -= 20;
2294
 
                btnPTT->position( btnPTT->x(), y);
2295
 
                btnPTT->redraw();
2296
 
        }
2297
 
 
2298
 
        int use_AuxPort = (progStatus.aux_serial_port != "NONE");
2299
 
        if (use_AuxPort) {
2300
 
                btnPTT->resize(btnPTT->x(), y, btnPTT->w(), 38);
2301
 
                btnPTT->redraw();
2302
 
                y += 20;
2303
 
                boxControl->position(boxControl->x(), y);
2304
 
                btnAuxRTS->position(btnAuxRTS->x(), y);
2305
 
                btnAuxDTR->position(btnAuxDTR->x(), y);
2306
 
                btnAuxRTS->value(progStatus.aux_rts);
2307
 
                btnAuxDTR->value(progStatus.aux_dtr);
2308
 
                boxControl->show();
2309
 
                btnAuxRTS->show();
2310
 
                btnAuxDTR->show();
2311
 
        } else {
2312
 
                boxControl->hide();
2313
 
                btnAuxRTS->hide();
2314
 
                btnAuxDTR->hide();
2315
 
                btnPTT->resize(btnPTT->x(), y, btnPTT->w(), 18);
2316
 
                btnPTT->redraw();
2317
 
        }
2318
 
 
2319
 
        btnInitializing->hide();
2320
 
 
2321
 
        tabs550->resize(tabs550->x(), y + 20, tabs550->w(), tabs550->h());
2322
 
        tabs550->hide();
2323
 
 
2324
 
        tabsGeneric->resize(tabsGeneric->x(), y + 20, tabsGeneric->w(), tabsGeneric->h());
2325
 
        tabsGeneric->hide();
2326
 
 
2327
 
        btn_show_controls->label("@-22->");
2328
 
        btn_show_controls->redraw_label();
2329
 
 
2330
 
        if (selrig->has_extras)
2331
 
                btn_show_controls->show();
2332
 
        else
2333
 
                btn_show_controls->hide();
2334
 
 
2335
 
        y += 20;
2336
 
 
2337
 
        mainwindow->size( mainwindow->w(), y);
2338
 
        mainwindow->init_sizes();
2339
 
        mainwindow->redraw();
2340
 
 
2341
 
        if (progStatus.tooltips) {
2342
 
                Fl_Tooltip::enable(1);
2343
 
                mnuTooltips->set();
2344
 
        } else {
2345
 
                mnuTooltips->clear();
2346
 
                Fl_Tooltip::enable(0);
2347
 
        }
2348
 
        if (progStatus.schema)
2349
 
                mnuSchema->set();
2350
 
        else
2351
 
                mnuSchema->clear();
2352
 
 
2353
 
} else {
2354
 
// wide_ui USER INTERFACE
2355
 
        mainwindow->resize( mainwindow->x(), mainwindow->y(), mainwindow->w(), 218);
2356
 
 
2357
 
        btnVol->show();
2358
 
        sldrVOLUME->show();
2359
 
        sldrRFGAIN->show();
2360
 
        btnIFsh->show();
2361
 
        sldrIFSHIFT->show();
2362
 
        btnNotch->show();
2363
 
        sldrNOTCH->show();
2364
 
        sldrMICGAIN->show();
2365
 
        sldrPOWER->show();
2366
 
        sldrSQUELCH->show();
2367
 
        btnNR->show();
2368
 
        sldrNR->show();
2369
 
 
2370
 
 
2371
 
        if (rig_nbr == TT550) {
2372
 
                tabs550->show();
2373
 
                tabsGeneric->hide();
2374
 
        } else {
2375
 
                tabs550->hide();
2376
 
                tabsGeneric->remove(genericAux);
2377
 
                if (progStatus.aux_serial_port != "NONE" || selrig->has_data_port) {
2378
 
                        if (progStatus.aux_serial_port != "NONE") {
2379
 
                                btnAuxRTS->activate();
2380
 
                                btnAuxDTR->activate();
2381
 
                        } else {
2382
 
                                btnAuxRTS->deactivate();
2383
 
                                btnAuxDTR->deactivate();
2384
 
                        }
2385
 
                        if (selrig->has_data_port)
2386
 
                                btnDataPort->activate();
2387
 
                        else
2388
 
                                btnDataPort->deactivate();
2389
 
                        tabsGeneric->add(genericAux);
2390
 
                }
2391
 
                tabsGeneric->remove(genericRXB);
2392
 
                if (selrig->has_rit || selrig->has_xit || selrig->has_bfo)
2393
 
                        tabsGeneric->add(genericRXB);
2394
 
                tabsGeneric->show();
2395
 
        }
2396
 
 
2397
 
        btnInitializing->hide();
2398
 
 
2399
 
        mainwindow->init_sizes();
2400
 
 
2401
 
        mainwindow->redraw();
2402
 
 
2403
 
        if (progStatus.tooltips) {
2404
 
                Fl_Tooltip::enable(1);
2405
 
                mnuTooltips->set();
2406
 
        } else {
2407
 
                mnuTooltips->clear();
2408
 
                Fl_Tooltip::enable(0);
2409
 
        }
2410
 
}
2411
 
 
2412
 
}
2413
 
 
2414
 
void initXcvrTab()
2415
 
{
2416
 
        if (rig_nbr == TT550) {
2417
 
                cnt_tt550_line_out->value(progStatus.tt550_line_out);
2418
 
                cbo_tt550_agc_level->index(progStatus.tt550_agc_level);
2419
 
                cnt_tt550_cw_wpm->value(progStatus.tt550_cw_wpm);
2420
 
                cnt_tt550_cw_vol->value(progStatus.tt550_cw_vol);
2421
 
                cnt_tt550_cw_spot->value(progStatus.tt550_cw_spot);
2422
 
                cnt_tt550_cw_weight->value(progStatus.tt550_cw_weight);
2423
 
                cnt_tt550_cw_qsk->value(progStatus.tt550_cw_qsk);
2424
 
                btn_tt550_enable_keyer->value(progStatus.tt550_enable_keyer);
2425
 
                btn_tt550_vox->value(progStatus.tt550_vox_onoff);
2426
 
                cnt_tt550_vox_gain->value(progStatus.tt550_vox_gain);
2427
 
                cnt_tt550_anti_vox->value(progStatus.tt550_vox_anti);
2428
 
                cnt_tt550_vox_hang->value(progStatus.tt550_vox_hang);
2429
 
                btn_tt550_CompON->value(progStatus.tt550_compON);
2430
 
                cnt_tt550_compression->value(progStatus.tt550_compression);
2431
 
                cnt_tt550_mon_vol->value(progStatus.tt550_mon_vol);
2432
 
                btn_tt550_enable_xmtr->value(progStatus.tt550_enable_xmtr);
2433
 
                btn_tt550_enable_tloop->value(progStatus.tt550_enable_tloop);
2434
 
                btn_tt550_tuner_bypass->value(progStatus.tt550_tuner_bypass);
2435
 
                btn_tt550_use_xmt_bw->value(progStatus.tt550_use_xmt_bw);
2436
 
                sel_tt550_encoder_step->value(progStatus.tt550_encoder_step);
2437
 
                cnt_tt550_encoder_sensitivity->value(progStatus.tt550_encoder_sensitivity);
2438
 
                sel_tt550_F1_func->value(progStatus.tt550_F1_func);
2439
 
                sel_tt550_F2_func->value(progStatus.tt550_F2_func);
2440
 
                sel_tt550_F3_func->value(progStatus.tt550_F3_func);
2441
 
                mnuRestoreData->clear();
2442
 
                mnuRestoreData->hide();
2443
 
                mnuKeepData->clear();
2444
 
                mnuKeepData->hide();
2445
 
                progStatus.restore_rig_data = false;
2446
 
                progStatus.use_rig_data = false;
2447
 
                op_tt550_XmtBW->clear();
2448
 
                for (int i = 0; TT550_xmt_widths[i] != NULL; i++) {
2449
 
                        op_tt550_XmtBW->add(TT550_xmt_widths[i]);
2450
 
                }
2451
 
                op_tt550_XmtBW->activate();
2452
 
                op_tt550_XmtBW->index(progStatus.tt550_xmt_bw);
2453
 
 
2454
 
                poll_smeter->activate(); poll_smeter->value(progStatus.poll_smeter);
2455
 
                poll_pout->activate(); poll_pout->value(progStatus.poll_pout);
2456
 
                poll_swr->activate(); poll_swr->value(progStatus.poll_swr);
2457
 
                poll_alc->activate(); poll_alc->value(progStatus.poll_alc);
2458
 
                poll_frequency->deactivate(); poll_frequency->value(0);
2459
 
                poll_mode->deactivate(); poll_mode->value(0);
2460
 
                poll_bandwidth->deactivate(); poll_bandwidth->value(0);
2461
 
                poll_volume->deactivate(); poll_volume->value(0);
2462
 
                poll_notch->deactivate(); poll_notch->value(0);
2463
 
                poll_auto_notch->deactivate(); poll_auto_notch->value(0);
2464
 
                poll_ifshift->deactivate(); poll_ifshift->value(0);
2465
 
                poll_power_control->deactivate(); poll_power_control->value(0);
2466
 
                poll_pre_att->deactivate(); poll_pre_att->value(0);
2467
 
                poll_squelch->deactivate(); poll_squelch->value(0);
2468
 
                poll_micgain->deactivate(); poll_micgain->value(0);
2469
 
                poll_rfgain->deactivate(); poll_rfgain->value(0);
2470
 
                poll_split->deactivate(); poll_split->value(0);
2471
 
                poll_nr->deactivate(); poll_nr->value(0);
2472
 
                poll_noise->deactivate(); poll_noise->value(0);
2473
 
                poll_all->deactivate(); poll_all->value(0);
2474
 
 
2475
 
        } else {
2476
 
 
2477
 
                tabsGeneric->remove(*genericBands);
2478
 
                tabsGeneric->remove(*genericCW);
2479
 
                tabsGeneric->remove(*genericVOX);
2480
 
                tabsGeneric->remove(*genericSpeech);
2481
 
                tabsGeneric->remove(*genericRx);
2482
 
                tabsGeneric->remove(*genericMisc);
2483
 
 
2484
 
                if (selrig->has_band_selection) {
2485
 
                        genericBands->resize(
2486
 
                                tabsGeneric->x() + 2,
2487
 
                                tabsGeneric->y() + 19,
2488
 
                                tabsGeneric->w() - 4,
2489
 
                                tabsGeneric->h() - 21);
2490
 
                        tabsGeneric->insert(*genericBands, 0);
2491
 
                }
2492
 
 
2493
 
                poll_all->activate();
2494
 
                poll_all->value(progStatus.poll_all);
2495
 
 
2496
 
                if (selrig->has_cw_wpm || selrig->has_cw_qsk || selrig->has_cw_weight ||
2497
 
                        selrig->has_cw_keyer || selrig->has_cw_spot || selrig->has_cw_spot_tone) {
2498
 
                        genericCW->resize(
2499
 
                                tabsGeneric->x() + 2,
2500
 
                                tabsGeneric->y() + 19,
2501
 
                                tabsGeneric->w() - 4,
2502
 
                                tabsGeneric->h() - 21);
2503
 
                        tabsGeneric->insert(*genericCW, 6);
2504
 
                        if (selrig->has_cw_wpm) {
2505
 
                                int min, max;
2506
 
                                selrig->get_cw_wpm_min_max(min, max);
2507
 
                                cnt_cw_wpm->minimum(min);
2508
 
                                cnt_cw_wpm->maximum(max);
2509
 
                                cnt_cw_wpm->value(progStatus.cw_wpm);
2510
 
                                cnt_cw_wpm->show();
2511
 
                                selrig->set_cw_wpm();
2512
 
                        } else cnt_cw_wpm->hide();
2513
 
                        if (selrig->has_cw_qsk) {
2514
 
                                double min, max, step;
2515
 
                                selrig->get_cw_qsk_min_max_step(min, max, step);
2516
 
                                cnt_cw_qsk->minimum(min);
2517
 
                                cnt_cw_qsk->maximum(max);
2518
 
                                cnt_cw_qsk->step(step);
2519
 
                                cnt_cw_qsk->value(progStatus.cw_qsk);
2520
 
                                cnt_cw_qsk->show();
2521
 
                                selrig->set_cw_qsk();
2522
 
                        } else cnt_cw_qsk->hide();
2523
 
                        if (selrig->has_cw_weight) {
2524
 
                                double min, max, step;
2525
 
                                selrig->get_cw_weight_min_max_step( min, max, step );
2526
 
                                cnt_cw_weight->minimum(min);
2527
 
                                cnt_cw_weight->maximum(max);
2528
 
                                cnt_cw_weight->step(step);
2529
 
                                cnt_cw_weight->value(progStatus.cw_weight);
2530
 
                                cnt_cw_weight->show();
2531
 
                                selrig->set_cw_weight();
2532
 
                        } else cnt_cw_weight->hide();
2533
 
                        if (selrig->has_cw_keyer) {
2534
 
                                btn_enable_keyer->show();
2535
 
                                btn_enable_keyer->value(progStatus.enable_keyer);
2536
 
                                selrig->enable_keyer();
2537
 
                        } else btn_enable_keyer->hide();
2538
 
                        if (selrig->has_cw_spot) {
2539
 
                                btnSpot->value(progStatus.cw_spot);
2540
 
                                selrig->set_cw_spot();
2541
 
                                btnSpot->show();
2542
 
                        } else btnSpot->hide();
2543
 
                        if (selrig->has_cw_spot_tone) {
2544
 
                                cnt_cw_spot_tone->show();
2545
 
                                int min, max, step;
2546
 
                                selrig->get_cw_spot_tone_min_max_step(min, max, step);
2547
 
                                cnt_cw_spot_tone->minimum(min);
2548
 
                                cnt_cw_spot_tone->maximum(max);
2549
 
                                cnt_cw_spot_tone->step(step);
2550
 
                                cnt_cw_spot_tone->value(progStatus.cw_spot_tone);
2551
 
                                selrig->set_cw_spot_tone();
2552
 
                        } else cnt_cw_spot_tone->hide();
2553
 
                }
2554
 
 
2555
 
                if (selrig->has_vox_onoff || selrig->has_vox_gain || selrig->has_vox_anti ||
2556
 
                        selrig->has_vox_hang || selrig->has_vox_on_dataport || selrig->has_cw_spot_tone) {
2557
 
                        genericVOX->resize(
2558
 
                                tabsGeneric->x() + 2,
2559
 
                                tabsGeneric->y() + 19,
2560
 
                                tabsGeneric->w() - 4,
2561
 
                                tabsGeneric->h() - 21);
2562
 
                        tabsGeneric->insert(*genericVOX, 6);
2563
 
                        if (selrig->has_vox_onoff) {
2564
 
                                btn_vox->show();
2565
 
                                btn_vox->value(progStatus.vox_onoff);
2566
 
                                selrig->set_vox_onoff();
2567
 
                        } else btn_vox->hide();
2568
 
                        if (selrig->has_vox_gain) {
2569
 
                                cnt_vox_gain->show();
2570
 
                                int min, max, step;
2571
 
                                selrig->get_vox_gain_min_max_step(min, max, step);
2572
 
                                cnt_vox_gain->minimum(min);
2573
 
                                cnt_vox_gain->maximum(max);
2574
 
                                cnt_vox_gain->step(step);
2575
 
                                cnt_vox_gain->value(progStatus.vox_gain);
2576
 
                                selrig->set_vox_gain();
2577
 
                        } else cnt_vox_gain->hide();
2578
 
                        if (selrig->has_vox_anti) {
2579
 
                                cnt_anti_vox->show();
2580
 
                                int min, max, step;
2581
 
                                selrig->get_vox_anti_min_max_step(min, max, step);
2582
 
                                cnt_anti_vox->minimum(min);
2583
 
                                cnt_anti_vox->maximum(max);
2584
 
                                cnt_anti_vox->step(step);
2585
 
                                cnt_anti_vox->value(progStatus.vox_anti);
2586
 
                                selrig->set_vox_anti();
2587
 
                        } else cnt_anti_vox->hide();
2588
 
                        if (selrig->has_vox_hang) {
2589
 
                                cnt_vox_hang->show();
2590
 
                                int min, max, step;
2591
 
                                selrig->get_vox_hang_min_max_step(min, max, step);
2592
 
                                cnt_vox_hang->minimum(min);
2593
 
                                cnt_vox_hang->maximum(max);
2594
 
                                cnt_vox_hang->step(step);
2595
 
                                cnt_vox_hang->value(progStatus.vox_hang);
2596
 
                                selrig->set_vox_hang();
2597
 
                        } else cnt_vox_hang->hide();
2598
 
                        if (selrig->has_vox_on_dataport) {
2599
 
                                btn_vox_on_dataport->show();
2600
 
                                btn_vox_on_dataport->value(progStatus.vox_on_dataport);
2601
 
                                selrig->set_vox_on_dataport();
2602
 
                        } else btn_vox_on_dataport->hide();
2603
 
                }
2604
 
 
2605
 
                if (selrig->has_compON || selrig->has_compression) {
2606
 
                        genericSpeech->resize(
2607
 
                                tabsGeneric->x() + 2,
2608
 
                                tabsGeneric->y() + 19,
2609
 
                                tabsGeneric->w() - 4,
2610
 
                                tabsGeneric->h() - 21);
2611
 
                        tabsGeneric->insert(*genericSpeech, 6);
2612
 
                        if (selrig->has_compON) {
2613
 
                                btnCompON->show();
2614
 
                                btnCompON->value(progStatus.compON);
2615
 
                        } else
2616
 
                                btnCompON->hide();
2617
 
                        if (selrig->has_compression) {
2618
 
                                int min, max, step;
2619
 
                                selrig->get_comp_min_max_step(min, max, step);
2620
 
                                cnt_compression->minimum(min);
2621
 
                                cnt_compression->maximum(max);
2622
 
                                cnt_compression->step(step);
2623
 
                                cnt_compression->show();
2624
 
                                cnt_compression->value(progStatus.compression);
2625
 
                                selrig->set_compression();
2626
 
                        } else
2627
 
                                cnt_compression->hide();
2628
 
                }
2629
 
                if (selrig->has_agc_level || selrig->has_nb_level || selrig->has_bpf_center) {
2630
 
                        genericRx->resize(
2631
 
                                tabsGeneric->x() + 2,
2632
 
                                tabsGeneric->y() + 19,
2633
 
                                tabsGeneric->w() - 4,
2634
 
                                tabsGeneric->h() - 21);
2635
 
                        tabsGeneric->insert(*genericRx, 6);
2636
 
                        if (selrig->has_agc_level) cbo_agc_level->activate(); else cbo_agc_level->deactivate();
2637
 
                        if (selrig->has_nb_level) cbo_nb_level->activate(); else cbo_nb_level->deactivate();
2638
 
                        if (selrig->has_bpf_center) {
2639
 
                                cnt_bpf_center->value(progStatus.bpf_center);
2640
 
                                cnt_bpf_center->show();
2641
 
                                btn_use_bpf_center->show();
2642
 
                        } else {
2643
 
                                cnt_bpf_center->hide();
2644
 
                                btn_use_bpf_center->hide();
2645
 
                        }
2646
 
                }
2647
 
 
2648
 
                if (selrig->has_vfo_adj || selrig->has_xcvr_auto_on_off) {
2649
 
                        genericMisc->resize(
2650
 
                                tabsGeneric->x() + 2,
2651
 
                                tabsGeneric->y() + 19,
2652
 
                                tabsGeneric->w() - 4,
2653
 
                                tabsGeneric->h() - 21);
2654
 
                        tabsGeneric->insert(*genericMisc, 6);
2655
 
                        if (selrig->has_vfo_adj) {
2656
 
                                int min, max, step;
2657
 
                                selrig->get_vfoadj_min_max_step(min, max, step);
2658
 
                                cnt_vfo_adj->minimum(min);
2659
 
                                cnt_vfo_adj->maximum(max);
2660
 
                                cnt_vfo_adj->step(step);
2661
 
                                progStatus.vfo_adj = selrig->getVfoAdj();
2662
 
                                cnt_vfo_adj->value(progStatus.vfo_adj);
2663
 
                                cnt_vfo_adj->show();
2664
 
                        } else
2665
 
                                cnt_vfo_adj->hide();
2666
 
                        cnt_line_out->hide(); // enable if a lineout control is used by any transceiver
2667
 
 
2668
 
                        if (selrig->has_xcvr_auto_on_off) {
2669
 
                                btn_xcvr_auto_on->value(progStatus.xcvr_auto_on);
2670
 
                                btn_xcvr_auto_off->value(progStatus.xcvr_auto_off);
2671
 
                                btn_xcvr_auto_on->show();
2672
 
                                btn_xcvr_auto_off->show();
2673
 
                        } else {
2674
 
                                btn_xcvr_auto_on->hide();
2675
 
                                btn_xcvr_auto_off->hide();
2676
 
                        }
2677
 
 
2678
 
                }
2679
 
 
2680
 
                tabsGeneric->redraw();
2681
 
 
2682
 
                mnuRestoreData->show();
2683
 
                mnuKeepData->show();
2684
 
 
2685
 
                poll_frequency->activate(); poll_frequency->value(progStatus.poll_frequency);
2686
 
                poll_mode->activate(); poll_mode->value(progStatus.poll_mode);
2687
 
                poll_bandwidth->activate(); poll_bandwidth->value(progStatus.poll_bandwidth);
2688
 
 
2689
 
                poll_smeter->activate(); poll_smeter->value(progStatus.poll_smeter);
2690
 
                poll_pout->activate(); poll_pout->value(progStatus.poll_pout);
2691
 
                poll_swr->activate(); poll_swr->value(progStatus.poll_swr);
2692
 
                poll_alc->activate(); poll_alc->value(progStatus.poll_alc);
2693
 
                poll_volume->activate(); poll_volume->value(progStatus.poll_volume);
2694
 
                poll_notch->activate(); poll_notch->value(progStatus.poll_notch);
2695
 
                poll_auto_notch->activate(); poll_auto_notch->value(progStatus.poll_auto_notch);
2696
 
                poll_ifshift->activate(); poll_ifshift->value(progStatus.poll_ifshift);
2697
 
                poll_power_control->activate(); poll_power_control->value(progStatus.poll_power_control);
2698
 
                poll_pre_att->activate(); poll_pre_att->value(progStatus.poll_pre_att);
2699
 
                poll_squelch->activate(); poll_squelch->value(progStatus.poll_squelch);
2700
 
                poll_micgain->activate(); poll_micgain->value(progStatus.poll_micgain);
2701
 
                poll_rfgain->activate(); poll_rfgain->value(progStatus.poll_rfgain);
2702
 
                poll_split->activate(); poll_split->value(progStatus.poll_split);
2703
 
                poll_noise->activate(); poll_noise->value(progStatus.poll_noise);
2704
 
                poll_nr->activate(); poll_nr->value(progStatus.poll_nr);
2705
 
 
2706
 
                if (!selrig->has_bandwidth_control) { poll_bandwidth->deactivate(); poll_bandwidth->value(0); }
2707
 
                if (!selrig->has_smeter) { poll_smeter->deactivate(); poll_smeter->value(0); }
2708
 
                if (!selrig->has_power_out) { poll_pout->deactivate(); poll_pout->value(0); }
2709
 
                if (!selrig->has_swr_control) { poll_swr->deactivate(); poll_swr->value(0); }
2710
 
                if (!selrig->has_alc_control) { poll_alc->deactivate(); poll_alc->value(0); }
2711
 
                if (!selrig->has_volume_control) { poll_volume->deactivate(); poll_volume->value(0); }
2712
 
                if (!selrig->has_notch_control) { poll_notch->deactivate(); poll_notch->value(0); }
2713
 
                if (!selrig->has_auto_notch || rig_nbr == FT1000MP)
2714
 
                        { poll_auto_notch->deactivate(); poll_auto_notch->value(0); }
2715
 
                if (!selrig->has_ifshift_control) { poll_ifshift->deactivate(); poll_ifshift->value(0); }
2716
 
                if (!selrig->has_power_control) { poll_power_control->deactivate(); poll_power_control->value(0); }
2717
 
                if (!selrig->has_preamp_control && !selrig->has_attenuator_control)
2718
 
                        { poll_pre_att->deactivate(); poll_pre_att->value(0); }
2719
 
                if (!selrig->has_sql_control) { poll_squelch->deactivate(); poll_squelch->value(0); }
2720
 
                if (!selrig->has_micgain_control) { poll_micgain->deactivate(); poll_micgain->value(0); }
2721
 
                if (!selrig->has_rf_control) { poll_rfgain->deactivate(); poll_rfgain->value(0); }
2722
 
                if (!selrig->has_split) { poll_split->deactivate(); poll_split->value(0); }
2723
 
                if (!selrig->has_noise_control) {poll_noise->deactivate(); poll_noise->value(0);}
2724
 
                if (!selrig->has_noise_reduction) {poll_nr->deactivate(); poll_nr->value(0);}
2725
 
 
2726
 
        }
2727
 
 
2728
 
}
2729
 
 
2730
 
void initRig()
2731
 
{
2732
 
        flrig_abort = false;
2733
 
 
2734
 
        sldrRcvSignal->aging(progStatus.rx_peak);
2735
 
        sldrRcvSignal->avg(progStatus.rx_avg);
2736
 
        sldrFwdPwr->aging(progStatus.pwr_peak);
2737
 
        sldrFwdPwr->avg(progStatus.pwr_avg);
2738
 
 
2739
 
//      wait_query = true;
2740
 
 
2741
 
// disable xml loop
2742
 
        pthread_mutex_lock(&mutex_xmlrpc);
2743
 
 
2744
 
// disable the serial thread
2745
 
        pthread_mutex_lock(&mutex_serial);
2746
 
 
2747
 
// Xcvr Auto Power on as soon as possible
2748
 
        if (selrig->has_xcvr_auto_on_off)
2749
 
                selrig->set_xcvr_auto_on();
2750
 
 
2751
 
        selrig->initialize();
2752
 
        if (flrig_abort) goto failed;
2753
 
 
2754
 
        FreqDispA->set_precision(selrig->precision);
2755
 
        FreqDispA->set_ndigits(selrig->ndigits);
2756
 
        FreqDispB->set_precision(selrig->precision);
2757
 
        FreqDispB->set_ndigits(selrig->ndigits);
2758
 
 
2759
 
        if (rig_nbr == TT550) {
2760
 
                selrig->selectA();
2761
 
 
2762
 
                vfoB.freq = progStatus.freq_B;
2763
 
                vfoB.imode = progStatus.imode_B;
2764
 
                vfoB.iBW = progStatus.iBW_B;
2765
 
                FreqDispB->value(vfoB.freq);
2766
 
                selrig->set_vfoB(vfoB.freq);
2767
 
                selrig->set_modeB(vfoB.imode);
2768
 
                selrig->set_bwB(vfoB.iBW);
2769
 
 
2770
 
                vfo.freq = vfoA.freq = progStatus.freq_A;
2771
 
                vfo.imode = vfoA.imode = progStatus.imode_A;
2772
 
                vfo.iBW = vfoA.iBW = progStatus.iBW_A;
2773
 
                FreqDispA->value( vfoA.freq );
2774
 
                selrig->set_vfoA(vfoA.freq);
2775
 
                selrig->set_modeA(vfoA.imode);
2776
 
 
2777
 
                if (vfoA.iBW == -1) vfoA.iBW = selrig->def_bandwidth(vfoA.imode);
2778
 
                selrig->set_bwA(vfoA.iBW);
2779
 
 
2780
 
                rigmodes_.clear();
2781
 
                opMODE->clear();
2782
 
                for (int i = 0; selrig->modes_[i] != NULL; i++) {
2783
 
                        rigmodes_.push_back(selrig->modes_[i]);
2784
 
                        opMODE->add(selrig->modes_[i]);
2785
 
                }
2786
 
                opMODE->activate();
2787
 
                opMODE->index(vfoA.imode);
2788
 
 
2789
 
                rigbws_.clear();
2790
 
                opBW->show();
2791
 
                opBW->clear();
2792
 
                old_bws = selrig->bandwidths_;
2793
 
                for (int i = 0; selrig->bandwidths_[i] != NULL; i++) {
2794
 
                        rigbws_.push_back(selrig->bandwidths_[i]);
2795
 
                                opBW->add(selrig->bandwidths_[i]);
2796
 
                        }
2797
 
                opBW->activate();
2798
 
                opBW->index(vfoA.iBW);
2799
 
 
2800
 
        } else { // !TT550
2801
 
                if (progStatus.CIV > 0)
2802
 
                        selrig->adjustCIV(progStatus.CIV);
2803
 
                if (progStatus.use_rig_data) {
2804
 
                        selrig->selectA();
2805
 
                        if (selrig->has_get_info)
2806
 
                                selrig->get_info();
2807
 
                        transceiverA.freq = selrig->get_vfoA();
2808
 
                        transceiverA.imode = selrig->get_modeA();
2809
 
                        selrig->adjust_bandwidth(transceiverA.imode);
2810
 
                        transceiverA.iBW = selrig->get_bwA();
2811
 
                        selrig->selectB();
2812
 
                        if (selrig->has_get_info)
2813
 
                                selrig->get_info();
2814
 
                        transceiverB.freq = selrig->get_vfoB();
2815
 
                        transceiverB.imode = selrig->get_modeB();
2816
 
                        selrig->adjust_bandwidth(transceiverB.imode);
2817
 
                        transceiverB.iBW = selrig->get_bwB();
2818
 
                        progStatus.freq_A = transceiverA.freq;
2819
 
                        progStatus.imode_A = transceiverA.imode;
2820
 
                        progStatus.iBW_A = transceiverA.iBW;
2821
 
                        progStatus.freq_B = transceiverB.freq;
2822
 
                        progStatus.imode_B = transceiverB.imode;
2823
 
                        progStatus.iBW_B = transceiverB.iBW;
2824
 
                        mnuKeepData->set();
2825
 
                        if (selrig->restore_mbw) selrig->last_bw = transceiverA.iBW;
2826
 
                } else
2827
 
                        mnuKeepData->clear();
2828
 
 
2829
 
                rigmodes_.clear();
2830
 
                opMODE->clear();
2831
 
                if (selrig->has_mode_control) {
2832
 
                        for (int i = 0; selrig->modes_[i] != NULL; i++) {
2833
 
                                rigmodes_.push_back(selrig->modes_[i]);
2834
 
                                opMODE->add(selrig->modes_[i]);
2835
 
                        }
2836
 
                        opMODE->activate();
2837
 
                        opMODE->index(progStatus.imode_A);
2838
 
                } else {
2839
 
                        opMODE->add(" ");
2840
 
                        opMODE->index(0);
2841
 
                        opMODE->deactivate();
2842
 
                }
2843
 
 
2844
 
                rigbws_.clear();
2845
 
                opBW->show();
2846
 
                opBW->clear();
2847
 
                if (selrig->has_bandwidth_control) {
2848
 
                        old_bws = selrig->bandwidths_;
2849
 
                        for (int i = 0; selrig->bandwidths_[i] != NULL; i++) {
2850
 
                                rigbws_.push_back(selrig->bandwidths_[i]);
2851
 
                                        opBW->add(selrig->bandwidths_[i]);
2852
 
                                }
2853
 
                        opBW->activate();
2854
 
                        if (progStatus.iBW_A == -1) progStatus.iBW_A = selrig->def_bandwidth(vfoA.imode);
2855
 
                        if (progStatus.iBW_B == -1) progStatus.iBW_B = selrig->def_bandwidth(vfoB.imode);
2856
 
                        opBW->index(progStatus.iBW_A);
2857
 
                } else {
2858
 
                        opBW->add(" ");
2859
 
                        opBW->index(0);
2860
 
                        opBW->deactivate();
2861
 
                }
2862
 
        } // !TT550
2863
 
 
2864
 
        if (selrig->has_special)
2865
 
                btnSpecial->show();
2866
 
//              btnSpecial->activate();
2867
 
        else
2868
 
                btnSpecial->hide();
2869
 
//              btnSpecial->deactivate();
2870
 
 
2871
 
        if (selrig->has_rit) {
2872
 
                int min, max, step;
2873
 
                selrig->get_RIT_min_max_step(min, max, step);
2874
 
                cntRIT->minimum(min);
2875
 
                cntRIT->maximum(max);
2876
 
                cntRIT->step(step);
2877
 
                if (progStatus.UIsize == small_ui)
2878
 
                        cntRIT->show();
2879
 
                else
2880
 
                        cntRIT->activate();
2881
 
                cntRIT->value(progStatus.rit_freq);
2882
 
        } else {
2883
 
                if (progStatus.UIsize == small_ui)
2884
 
                        cntRIT->hide();
2885
 
                else
2886
 
                        cntRIT->deactivate();
2887
 
        }
2888
 
 
2889
 
        if (selrig->has_xit) {
2890
 
                int min, max, step;
2891
 
                selrig->get_XIT_min_max_step(min, max, step);
2892
 
                cntXIT->minimum(min);
2893
 
                cntXIT->maximum(max);
2894
 
                cntXIT->step(step);
2895
 
                cntXIT->value(progStatus.xit_freq);
2896
 
                if (progStatus.UIsize == small_ui)
2897
 
                        cntXIT->show();
2898
 
                else
2899
 
                        cntXIT->activate();
2900
 
        } else {
2901
 
                if (progStatus.UIsize == small_ui)
2902
 
                        cntXIT->hide();
2903
 
                else
2904
 
                        cntXIT->deactivate();
2905
 
        }
2906
 
 
2907
 
        if (selrig->has_bfo) {
2908
 
                int min, max, step;
2909
 
                selrig->get_BFO_min_max_step(min, max, step);
2910
 
                cntBFO->minimum(min);
2911
 
                cntBFO->maximum(max);
2912
 
                cntBFO->step(step);
2913
 
                cntBFO->value(progStatus.bfo_freq);
2914
 
                if (progStatus.UIsize == small_ui)
2915
 
                        cntBFO->show();
2916
 
                else
2917
 
                        cntBFO->activate();
2918
 
        } else {
2919
 
                if (progStatus.UIsize == small_ui)
2920
 
                        cntBFO->hide();
2921
 
                else
2922
 
                        cntBFO->deactivate();
2923
 
        }
2924
 
 
2925
 
        if (selrig->has_dsp_controls) {
2926
 
                opDSP_lo->clear();
2927
 
                opDSP_hi->clear();
2928
 
                btnDSP->label(selrig->lo_label);
2929
 
                btnDSP->redraw_label();
2930
 
                for (int i = 0; selrig->dsp_lo[i] != NULL; i++)
2931
 
                        opDSP_lo->add(selrig->dsp_lo[i]);
2932
 
                opDSP_lo->tooltip(selrig->lo_tooltip);
2933
 
                for (int i = 0; selrig->dsp_hi[i] != NULL; i++)
2934
 
                        opDSP_hi->add(selrig->dsp_hi[i]);
2935
 
                opDSP_hi->tooltip(selrig->hi_tooltip);
2936
 
                if (vfo.iBW > 256) {
2937
 
                        opDSP_lo->index(vfo.iBW & 0xFF);
2938
 
                        opDSP_hi->index((vfo.iBW >> 8) & 0x7F);
2939
 
                        btnDSP->show();
2940
 
                        opDSP_hi->show();
2941
 
                        opDSP_lo->hide();
2942
 
                        opBW->hide();
2943
 
                        opBW->index(0);
2944
 
                } else {
2945
 
                        opDSP_lo->index(0);
2946
 
                        opDSP_hi->index(0);
2947
 
                        btnDSP->hide();
2948
 
                        opDSP_lo->hide();
2949
 
                        opDSP_hi->hide();
2950
 
                        opBW->show();
2951
 
                }
2952
 
        } else {
2953
 
                btnDSP->hide();
2954
 
                opDSP_lo->hide();
2955
 
                opDSP_hi->hide();
2956
 
                opBW->show();
2957
 
        }
2958
 
 
2959
 
        if (selrig->has_volume_control) {
2960
 
                int min, max, step;
2961
 
                selrig->get_vol_min_max_step(min, max, step);
2962
 
                sldrVOLUME->minimum(min);
2963
 
                sldrVOLUME->maximum(max);
2964
 
                sldrVOLUME->step(step);
2965
 
                sldrVOLUME->redraw();
2966
 
                if (progStatus.use_rig_data) {
2967
 
                        progStatus.volume = selrig->get_volume_control();
2968
 
                        sldrVOLUME->value(progStatus.volume);
2969
 
                        btnVol->value(1);
2970
 
                        sldrVOLUME->activate();
2971
 
                } else {
2972
 
                        sldrVOLUME->value(progStatus.volume);
2973
 
                        if (progStatus.spkr_on == 0) {
2974
 
                                btnVol->value(0);
2975
 
                                sldrVOLUME->deactivate();
2976
 
                                selrig->set_volume_control(0);
2977
 
                        } else {
2978
 
                                btnVol->value(1);
2979
 
                                sldrVOLUME->activate();
2980
 
                                selrig->set_volume_control(progStatus.volume);
2981
 
                        }
2982
 
                }
2983
 
                if (progStatus.UIsize == small_ui) {
2984
 
                        btnVol->show();
2985
 
                        sldrVOLUME->show();
2986
 
                } else {
2987
 
                        btnVol->activate();
2988
 
                        sldrVOLUME->activate();
2989
 
                }
2990
 
        } else {
2991
 
                if (progStatus.UIsize == small_ui) {
2992
 
                        btnVol->hide();
2993
 
                        sldrVOLUME->hide();
2994
 
                } else {
2995
 
                        btnVol->deactivate();
2996
 
                        sldrVOLUME->deactivate();
2997
 
                }
2998
 
        }
2999
 
 
3000
 
        if (selrig->has_rf_control) {
3001
 
                int min, max, step;
3002
 
                selrig->get_rf_min_max_step(min, max, step);
3003
 
                sldrRFGAIN->minimum(min);
3004
 
                sldrRFGAIN->maximum(max);
3005
 
                sldrRFGAIN->step(step);
3006
 
                sldrRFGAIN->redraw();
3007
 
                if (progStatus.use_rig_data) {
3008
 
                        progStatus.rfgain = selrig->get_rf_gain();
3009
 
                        sldrRFGAIN->value(progStatus.rfgain);
3010
 
                        if (progStatus.UIsize == small_ui)
3011
 
                                sldrRFGAIN->show();
3012
 
                        else
3013
 
                                sldrRFGAIN->activate();
3014
 
                } else {
3015
 
                        sldrRFGAIN->value(progStatus.rfgain);
3016
 
                        selrig->set_rf_gain(progStatus.rfgain);
3017
 
                        if (progStatus.UIsize == small_ui)
3018
 
                                sldrRFGAIN->show();
3019
 
                        else
3020
 
                                sldrRFGAIN->activate();
3021
 
                }
3022
 
        } else {
3023
 
                if (progStatus.UIsize == small_ui)
3024
 
                        sldrRFGAIN->hide();
3025
 
                else
3026
 
                        sldrRFGAIN->deactivate();
3027
 
        }
3028
 
 
3029
 
        if (selrig->has_sql_control) {
3030
 
                int min, max, step;
3031
 
                selrig->get_squelch_min_max_step(min, max, step);
3032
 
                sldrSQUELCH->minimum(min);
3033
 
                sldrSQUELCH->maximum(max);
3034
 
                sldrSQUELCH->step(step);
3035
 
                sldrSQUELCH->redraw();
3036
 
                if (progStatus.use_rig_data) {
3037
 
                        progStatus.squelch = selrig->get_squelch();
3038
 
                        sldrSQUELCH->value(progStatus.squelch);
3039
 
                        if (progStatus.UIsize == small_ui)
3040
 
                                sldrSQUELCH->show();
3041
 
                        else
3042
 
                                sldrSQUELCH->activate();
3043
 
                } else {
3044
 
                        sldrSQUELCH->value(progStatus.squelch);
3045
 
                        selrig->set_squelch(progStatus.squelch);
3046
 
                        if (progStatus.UIsize == small_ui)
3047
 
                                sldrSQUELCH->show();
3048
 
                        else
3049
 
                                sldrSQUELCH->activate();
3050
 
                }
3051
 
        } else {
3052
 
                if (progStatus.UIsize == small_ui)
3053
 
                        sldrSQUELCH->hide();
3054
 
                else
3055
 
                        sldrSQUELCH->deactivate();
3056
 
        }
3057
 
 
3058
 
        if (selrig->has_noise_reduction_control) {
3059
 
                int min, max, step;
3060
 
                selrig->get_nr_min_max_step(min, max, step);
3061
 
                sldrNR->minimum(min);
3062
 
                sldrNR->maximum(max);
3063
 
                sldrNR->step(step);
3064
 
                sldrNR->redraw();
3065
 
                if (progStatus.UIsize == small_ui) {
3066
 
                        btnNR->show();
3067
 
                        sldrNR->show();
3068
 
                } else {
3069
 
                        btnNR->activate();
3070
 
                        sldrNR->activate();
3071
 
                }
3072
 
                if (progStatus.use_rig_data) {
3073
 
                        progStatus.noise_reduction = selrig->get_noise_reduction();
3074
 
                        progStatus.noise_reduction_val = selrig->get_noise_reduction_val();
3075
 
                        btnNR->value(progStatus.noise_reduction);
3076
 
                        sldrNR->value(progStatus.noise_reduction_val);
3077
 
                } else {
3078
 
                        btnNR->value(progStatus.noise_reduction);
3079
 
                        sldrNR->value(progStatus.noise_reduction_val);
3080
 
                        selrig->set_noise_reduction(progStatus.noise_reduction);
3081
 
                        selrig->set_noise_reduction_val(progStatus.noise_reduction_val);
3082
 
                }
3083
 
        } else {
3084
 
                if (progStatus.UIsize == small_ui) {
3085
 
                        btnNR->hide();
3086
 
                        sldrNR->hide();
3087
 
                } else {
3088
 
                        btnNR->deactivate();
3089
 
                        sldrNR->deactivate();
3090
 
                }
3091
 
        }
3092
 
 
3093
 
        if (selrig->has_ifshift_control) {
3094
 
 
3095
 
 
3096
 
 
3097
 
                int min, max, step;
3098
 
                selrig->get_if_min_max_step(min, max, step);
3099
 
                sldrIFSHIFT->minimum(min);
3100
 
                sldrIFSHIFT->maximum(max);
3101
 
                sldrIFSHIFT->step(step);
3102
 
                sldrIFSHIFT->redraw();
3103
 
                if (progStatus.use_rig_data) {
3104
 
                        progStatus.shift = selrig->get_if_shift(progStatus.shift_val);
3105
 
                        btnIFsh->value(progStatus.shift);
3106
 
                        sldrIFSHIFT->value(progStatus.shift_val);
3107
 
                } else {
3108
 
                        if (progStatus.shift) {
3109
 
                                btnIFsh->value(1);
3110
 
                                sldrIFSHIFT->value(progStatus.shift_val);
3111
 
                                selrig->set_if_shift(progStatus.shift_val);
3112
 
                        } else {
3113
 
                                btnIFsh->value(0);
3114
 
                                sldrIFSHIFT->value(selrig->if_shift_mid);
3115
 
                                selrig->set_if_shift(selrig->if_shift_mid);
3116
 
                        }
3117
 
                }
3118
 
                if (progStatus.UIsize == small_ui) {
3119
 
                        btnIFsh->show();
3120
 
                        sldrIFSHIFT->show();
3121
 
                } else {
3122
 
                        btnIFsh->activate();
3123
 
                        sldrIFSHIFT->activate();
3124
 
                }
3125
 
        } else {
3126
 
                if (progStatus.UIsize == small_ui) {
3127
 
                        btnIFsh->hide();
3128
 
                        sldrIFSHIFT->hide();
3129
 
                } else {
3130
 
                        btnIFsh->deactivate();
3131
 
                        sldrIFSHIFT->deactivate();
3132
 
                }
3133
 
        }
3134
 
        if (rig_nbr == TS870S) {
3135
 
                if (progStatus.imode_A == RIG_TS870S::tsCW ||
3136
 
                        progStatus.imode_A == RIG_TS870S::tsCWR) {
3137
 
                        btnIFsh->activate();
3138
 
                        sldrIFSHIFT->activate();
3139
 
                } else {
3140
 
                        btnIFsh->deactivate();
3141
 
                        sldrIFSHIFT->deactivate();
3142
 
                }
3143
 
 
3144
 
 
3145
 
        }
3146
 
 
3147
 
        if (selrig->has_notch_control) {
3148
 
                int min, max, step;
3149
 
                selrig->get_notch_min_max_step(min, max, step);
3150
 
                sldrNOTCH->minimum(min);
3151
 
                sldrNOTCH->maximum(max);
3152
 
                sldrNOTCH->step(step);
3153
 
                sldrNOTCH->redraw();
3154
 
                if (progStatus.use_rig_data) {
3155
 
                        progStatus.notch = selrig->get_notch(progStatus.notch_val);
3156
 
                        btnNotch->value(progStatus.notch);
3157
 
                        sldrNOTCH->value(progStatus.notch_val);
3158
 
                } else {
3159
 
                        btnNotch->value(progStatus.notch);
3160
 
                        sldrNOTCH->value(progStatus.notch_val);
3161
 
                        selrig->set_notch(progStatus.notch, progStatus.notch_val);
3162
 
                }
3163
 
                if (progStatus.UIsize == small_ui) {
3164
 
                        btnNotch->show();
3165
 
                        sldrNOTCH->show();
3166
 
                } else {
3167
 
                        btnNotch->activate();
3168
 
                        sldrNOTCH->activate();
3169
 
                }
3170
 
        } else {
3171
 
                if (progStatus.UIsize == small_ui) {
3172
 
                        btnNotch->hide();
3173
 
                        sldrNOTCH->hide();
3174
 
                } else {
3175
 
                        btnNotch->deactivate();
3176
 
                        sldrNOTCH->deactivate();
3177
 
                }
3178
 
        }
3179
 
 
3180
 
        if (selrig->has_micgain_control) {
3181
 
                int min = 0, max = 0, step = 0;
3182
 
                selrig->get_mic_min_max_step(min, max, step);
3183
 
                sldrMICGAIN->minimum(min);
3184
 
                sldrMICGAIN->maximum(max);
3185
 
                sldrMICGAIN->step(step);
3186
 
                if (progStatus.use_rig_data)
3187
 
                        progStatus.mic_gain = selrig->get_mic_gain();
3188
 
                else
3189
 
                        selrig->set_mic_gain(progStatus.mic_gain);
3190
 
                sldrMICGAIN->value(progStatus.mic_gain);
3191
 
                if (progStatus.UIsize == small_ui)
3192
 
                        sldrMICGAIN->show();
3193
 
                else
3194
 
                        sldrMICGAIN->activate();
3195
 
                if (selrig->has_data_port) {
3196
 
                        btnDataPort->show();
3197
 
                        btnDataPort->value(progStatus.data_port);
3198
 
                        btnDataPort->label(progStatus.data_port ? "Data" : "Mic");
3199
 
                        btnDataPort->redraw_label();
3200
 
                } else btnDataPort->hide();
3201
 
        } else {
3202
 
                if (progStatus.UIsize == small_ui)
3203
 
                        sldrMICGAIN->hide();
3204
 
                else
3205
 
                        sldrMICGAIN->deactivate();
3206
 
        }
3207
 
 
3208
 
        if (selrig->has_power_control) {
3209
 
                double min, max, step;
3210
 
                if (progStatus.use_rig_data)
3211
 
                        progStatus.power_level = selrig->get_power_control();
3212
 
                else
3213
 
                        selrig->set_power_control(progStatus.power_level);
3214
 
                selrig->get_pc_min_max_step(min, max, step);
3215
 
                sldrPOWER->minimum(min);
3216
 
                sldrPOWER->maximum(max);
3217
 
                sldrPOWER->step(step);
3218
 
                sldrPOWER->value(progStatus.power_level);
3219
 
                sldrPOWER->redraw();
3220
 
                if (progStatus.UIsize == small_ui)
3221
 
                        sldrPOWER->show();
3222
 
                else
3223
 
                        sldrPOWER->activate();
3224
 
        } else {
3225
 
                if (progStatus.UIsize == small_ui)
3226
 
                        sldrPOWER->hide();
3227
 
                else
3228
 
                        sldrPOWER->deactivate();
3229
 
        }
3230
 
        set_power_controlImage(progStatus.power_level);
3231
 
 
3232
 
        if (selrig->has_attenuator_control) {
3233
 
                if (progStatus.use_rig_data)
3234
 
                        progStatus.attenuator = selrig->get_attenuator();
3235
 
                else
3236
 
                        selrig->set_attenuator(progStatus.attenuator);
3237
 
                if (progStatus.UIsize == small_ui)
3238
 
                        btnAttenuator->show();
3239
 
                else
3240
 
                        btnAttenuator->activate();
3241
 
        } else {
3242
 
                if (progStatus.UIsize == small_ui)
3243
 
                        btnAttenuator->hide();
3244
 
                else
3245
 
                        btnAttenuator->deactivate();
3246
 
        }
3247
 
 
3248
 
// hijack the preamp control for a SPOT button on the TT550 Pegasus
3249
 
        if (rig_nbr == TT550) {
3250
 
                btnPreamp->label("Spot");
3251
 
                btnPreamp->value(progStatus.tt550_spot_onoff);
3252
 
                if (progStatus.UIsize == small_ui)
3253
 
                        btnPreamp->show();
3254
 
                else
3255
 
                        btnPreamp->activate();
3256
 
        } else {
3257
 
                if (selrig->has_preamp_control) {
3258
 
                        if (progStatus.use_rig_data)
3259
 
                                progStatus.preamp = selrig->get_preamp();
3260
 
                        else
3261
 
                                selrig->set_preamp(progStatus.preamp);
3262
 
                        if (progStatus.UIsize == small_ui)
3263
 
                                btnPreamp->show();
3264
 
                        else
3265
 
                        btnPreamp->activate();
3266
 
                } else {
3267
 
                        if (progStatus.UIsize == small_ui)
3268
 
                                btnPreamp->hide();
3269
 
                        else
3270
 
                                btnPreamp->deactivate();
3271
 
                }
3272
 
        }
3273
 
 
3274
 
        if (selrig->has_noise_control) {
3275
 
                if (rig_nbr == TS990) {
3276
 
                        btnNOISE->label("AGC"); //Set TS990 AGC Label
3277
 
                        btnNR->label("NR1"); //Set TS990 NR Button
3278
 
                }
3279
 
                if (progStatus.use_rig_data)
3280
 
                        progStatus.noise = selrig->get_noise();
3281
 
                else
3282
 
                        selrig->set_noise(progStatus.noise);
3283
 
                btnNOISE->value(progStatus.noise);
3284
 
                if (progStatus.UIsize == small_ui)
3285
 
                        btnNOISE->show();
3286
 
                else
3287
 
                        btnNOISE->activate();
3288
 
        }
3289
 
        else {
3290
 
                if (progStatus.UIsize == small_ui)
3291
 
                        btnNOISE->hide();
3292
 
                else
3293
 
                        btnNOISE->deactivate();
3294
 
        }
3295
 
 
3296
 
        if (selrig->has_tune_control) {
3297
 
                if (progStatus.UIsize == small_ui)
3298
 
                        btnTune->show();
3299
 
                else
3300
 
                        btnTune->activate();
3301
 
        } else {
3302
 
                if (progStatus.UIsize == small_ui)
3303
 
                        btnTune->hide();
3304
 
                else
3305
 
                        btnTune->deactivate();
3306
 
        }
3307
 
 
3308
 
        if (selrig->has_ptt_control ||
3309
 
                progStatus.comm_dtrptt || progStatus.comm_rtsptt ||
3310
 
                progStatus.sep_dtrptt || progStatus.sep_rtsptt) {
3311
 
                btnPTT->activate();
3312
 
        } else {
3313
 
                btnPTT->deactivate();
3314
 
        }
3315
 
 
3316
 
        if (selrig->has_auto_notch) {
3317
 
 
3318
 
                if (rig_nbr == RAY152) {
3319
 
                        btnAutoNotch->label("AGC");
3320
 
                        btnAutoNotch->tooltip("AGC on/off");
3321
 
                } else if (rig_nbr == FT1000MP) {
3322
 
                        btnAutoNotch->label("Tuner");
3323
 
                        btnAutoNotch->tooltip("Tuner on/off");
3324
 
                } else {
3325
 
                        btnAutoNotch->label("AN");
3326
 
                        btnAutoNotch->tooltip("Auto notch on/off");
3327
 
                }
3328
 
                if (progStatus.use_rig_data)
3329
 
                        progStatus.auto_notch = selrig->get_auto_notch();
3330
 
                else
3331
 
                        selrig->set_auto_notch(progStatus.auto_notch);
3332
 
                btnAutoNotch->value(progStatus.auto_notch);
3333
 
                if (progStatus.UIsize == small_ui)
3334
 
                        btnAutoNotch->show();
3335
 
                else
3336
 
                        btnAutoNotch->activate();
3337
 
        } else {
3338
 
                if (progStatus.UIsize == small_ui)
3339
 
                        btnAutoNotch->hide();
3340
 
                else
3341
 
                        btnAutoNotch->deactivate();
3342
 
        }
3343
 
 
3344
 
        if (selrig->has_swr_control)
3345
 
                btnALC_SWR->activate();
3346
 
        else {
3347
 
                btnALC_SWR->deactivate();
3348
 
        }
3349
 
 
3350
 
        if (selrig->has_compON || selrig->has_compression)
3351
 
                selrig->set_compression();
3352
 
 
3353
 
        adjust_control_positions();
3354
 
        initXcvrTab();
3355
 
 
3356
 
        buildlist();
3357
 
 
3358
 
        if (selrig->CIV) {
3359
 
                char hexstr[8];
3360
 
                snprintf(hexstr, sizeof(hexstr), "0x%2X", selrig->CIV);
3361
 
                txtCIV->value(hexstr);
3362
 
                txtCIV->activate();
3363
 
                btnCIVdefault->activate();
3364
 
                if (strstr(selrig->name_, "IC-7200") || strstr(selrig->name_, "IC-7600")) {
3365
 
                        btnUSBaudio->value(progStatus.USBaudio = true);
3366
 
                        btnUSBaudio->activate();
3367
 
                } else
3368
 
                        btnUSBaudio->deactivate();
3369
 
        } else {
3370
 
                txtCIV->value("");
3371
 
                txtCIV->deactivate();
3372
 
                btnCIVdefault->deactivate();
3373
 
                btnUSBaudio->value(false);
3374
 
                btnUSBaudio->deactivate();
3375
 
        }
3376
 
 
3377
 
        if (rig_nbr != TT550) {
3378
 
                vfoA.freq = progStatus.freq_A;
3379
 
                vfoA.imode = progStatus.imode_A;
3380
 
                vfoA.iBW = progStatus.iBW_A;
3381
 
 
3382
 
                if (vfoA.iBW == -1) vfoA.iBW = selrig->def_bandwidth(vfoA.imode);
3383
 
                FreqDispA->value( vfoA.freq );
3384
 
 
3385
 
                vfoB.freq = progStatus.freq_B;
3386
 
                vfoB.imode = progStatus.imode_B;
3387
 
                vfoB.iBW = progStatus.iBW_B;
3388
 
 
3389
 
                if (vfoB.iBW == -1) vfoB.iBW = selrig->def_bandwidth(vfoB.imode);
3390
 
                FreqDispB->value(vfoB.freq);
3391
 
 
3392
 
                selrig->selectB();
3393
 
                selrig->set_vfoB(vfoB.freq);
3394
 
                selrig->set_modeB(vfoB.imode);
3395
 
                selrig->set_bwB(vfoB.iBW);
3396
 
 
3397
 
                selrig->selectA();
3398
 
                selrig->set_vfoA(vfoA.freq);
3399
 
                selrig->set_modeA(vfoA.imode);
3400
 
                selrig->set_bwA(vfoA.iBW);
3401
 
 
3402
 
                vfo = vfoA;
3403
 
                updateBandwidthControl();
3404
 
 
3405
 
                useB = false;
3406
 
                highlight_vfo((void *)0);
3407
 
 
3408
 
        }
3409
 
 
3410
 
// enable buttons, change labels
3411
 
 
3412
 
        if (rig_nbr == TS990) { // Setup TS990 Mon Button
3413
 
                btnIFsh->label("MON");
3414
 
        }
3415
 
        selrig->post_initialize();
3416
 
 
3417
 
// enable the serial thread
3418
 
 
3419
 
        pthread_mutex_unlock(&mutex_serial);
3420
 
 
3421
 
        fldigi_online = false;
3422
 
        rig_reset = true;
3423
 
 
3424
 
// initialize fldigi
3425
 
        try {
3426
 
                send_modes();
3427
 
                send_bandwidths();
3428
 
                send_new_freq(vfoA.freq);
3429
 
                send_new_mode(vfoA.imode);
3430
 
                send_sideband();
3431
 
                send_new_bandwidth(vfoA.iBW & 0x7F);
3432
 
        } catch (...) {}
3433
 
 
3434
 
// enable xml loop
3435
 
        pthread_mutex_unlock(&mutex_xmlrpc);
3436
 
 
3437
 
        if (rig_nbr == K3) {
3438
 
                btnB->hide();
3439
 
                btnA->hide();
3440
 
                btn_K3_swapAB->show();
3441
 
        } else {
3442
 
                btn_K3_swapAB->hide();
3443
 
                btnB->show();
3444
 
                btnA->show();
3445
 
        }
3446
 
 
3447
 
        btnAswapB->show();
3448
 
 
3449
 
        bypass_serial_thread_loop = false;
3450
 
        return;
3451
 
 
3452
 
failed:
3453
 
        bypass_serial_thread_loop = true;
3454
 
        pthread_mutex_unlock(&mutex_serial);
3455
 
        pthread_mutex_unlock(&mutex_xmlrpc);
3456
 
        btnInitializing->hide();
3457
 
        fl_alert2(_("Transceiver not responding"));
3458
 
        return;
3459
 
}
3460
 
 
3461
 
void init_title()
3462
 
{
3463
 
        title = PACKAGE;
3464
 
        title += " ";
3465
 
        title.append(selrig->name_);
3466
 
        mainwindow->label(title.c_str());
3467
 
}
3468
 
 
3469
 
void initConfigDialog()
3470
 
{
3471
 
        int picked = selectRig->index();
3472
 
        rigbase *srig = rigs[picked];
3473
 
        selectCommPort->index(0);
3474
 
 
3475
 
        progStatus.loadXcvrState(selrig->name_);
3476
 
 
3477
 
        selectCommPort->value(progStatus.xcvr_serial_port.c_str());
3478
 
        btnOneStopBit->value( progStatus.stopbits == 1 );
3479
 
        btnTwoStopBit->value( progStatus.stopbits == 2 );
3480
 
 
3481
 
        mnuBaudrate->index( srig->comm_baudrate );
3482
 
        btnOneStopBit->value( srig->stopbits == 1 );
3483
 
        btnTwoStopBit->value( srig->stopbits == 2 );
3484
 
        cntRigCatRetries->value( srig->comm_retries );
3485
 
        cntRigCatTimeout->value( srig->comm_timeout );
3486
 
        cntRigCatWait->value( srig->comm_wait );
3487
 
        btnRigCatEcho->value( srig->comm_echo );
3488
 
        btncatptt->value( srig->comm_catptt );
3489
 
        btnrtsptt->value( srig->comm_rtsptt );
3490
 
        btndtrptt->value( srig->comm_dtrptt );
3491
 
        chkrtscts->value( srig->comm_rtscts );
3492
 
        btnrtsplus->value( srig->comm_rtsplus );
3493
 
        btndtrplus->value( srig->comm_dtrplus );
3494
 
 
3495
 
        if (picked >= IC703 && picked <= IC910H) {
3496
 
                char hexstr[8];
3497
 
                snprintf(hexstr, sizeof(hexstr), "0x%2X", srig->CIV);
3498
 
                txtCIV->value(hexstr);
3499
 
                txtCIV->activate();
3500
 
                btnCIVdefault->activate();
3501
 
                if (picked == IC7200 || picked == IC7600) {
3502
 
                        btnUSBaudio->value(progStatus.USBaudio = true);
3503
 
                        btnUSBaudio->activate();
3504
 
                } else
3505
 
                        btnUSBaudio->deactivate();
3506
 
        } else {
3507
 
                txtCIV->value("");
3508
 
                txtCIV->deactivate();
3509
 
                btnCIVdefault->deactivate();
3510
 
                btnUSBaudio->value(false);
3511
 
                btnUSBaudio->deactivate();
3512
 
        }
3513
 
}
3514
 
 
3515
 
void initStatusConfigDialog()
3516
 
{
3517
 
        rig_nbr = progStatus.rig_nbr;
3518
 
        selrig = rigs[rig_nbr];
3519
 
 
3520
 
        if (rig_nbr >= IC703 && rig_nbr <= IC910H)
3521
 
                if (progStatus.CIV) selrig->adjustCIV(progStatus.CIV);
3522
 
 
3523
 
        selectRig->index(rig_nbr);
3524
 
        mnuBaudrate->index( progStatus.comm_baudrate );
3525
 
 
3526
 
        selectCommPort->value( progStatus.xcvr_serial_port.c_str() );
3527
 
        selectAuxPort->value( progStatus.aux_serial_port.c_str() );
3528
 
        selectSepPTTPort->value( progStatus.sep_serial_port.c_str() );
3529
 
        btnOneStopBit->value( progStatus.stopbits == 1 );
3530
 
        btnTwoStopBit->value( progStatus.stopbits == 2 );
3531
 
 
3532
 
        cntRigCatRetries->value( progStatus.comm_retries );
3533
 
        cntRigCatTimeout->value( progStatus.comm_timeout );
3534
 
        cntRigCatWait->value( progStatus.comm_wait );
3535
 
        btnRigCatEcho->value( progStatus.comm_echo );
3536
 
 
3537
 
        btncatptt->value( progStatus.comm_catptt );
3538
 
        btnrtsptt->value( progStatus.comm_rtsptt );
3539
 
        btndtrptt->value( progStatus.comm_dtrptt );
3540
 
        chkrtscts->value( progStatus.comm_rtscts );
3541
 
        btnrtsplus->value( progStatus.comm_rtsplus );
3542
 
        btndtrplus->value( progStatus.comm_dtrplus );
3543
 
 
3544
 
        btnSepDTRplus->value(progStatus.sep_dtrplus);
3545
 
        btnSepDTRptt->value(progStatus.sep_dtrptt);
3546
 
        btnSepRTSplus->value(progStatus.sep_rtsplus);
3547
 
        btnSepRTSptt->value(progStatus.sep_rtsptt);
3548
 
 
3549
 
        init_title();
3550
 
 
3551
 
        if (!startXcvrSerial()) {
3552
 
                if (progStatus.xcvr_serial_port.compare("NONE") == 0) {
3553
 
                        LOG_WARN("No comm port ... test mode");
3554
 
                } else {
3555
 
                        LOG_WARN("%s cannot be accessed", progStatus.xcvr_serial_port.c_str());
3556
 
                        progStatus.xcvr_serial_port = "NONE";
3557
 
                        selectCommPort->value(progStatus.xcvr_serial_port.c_str());
3558
 
                }
3559
 
                box_xcvr_connect->color(FL_BACKGROUND2_COLOR);
3560
 
                box_xcvr_connect->redraw();
3561
 
        } else {
3562
 
                selectCommPort->value(progStatus.xcvr_serial_port.c_str());
3563
 
                box_xcvr_connect->color(FL_GREEN);
3564
 
                box_xcvr_connect->redraw();
3565
 
        }
3566
 
        if (!startAuxSerial()) {
3567
 
                if (progStatus.aux_serial_port.compare("NONE") != 0) {
3568
 
                        LOG_WARN("%s cannot be accessed", progStatus.aux_serial_port.c_str());
3569
 
                        progStatus.aux_serial_port = "NONE";
3570
 
                        selectAuxPort->value(progStatus.aux_serial_port.c_str());
3571
 
                }
3572
 
        }
3573
 
        if (!startSepSerial()) {
3574
 
                if (progStatus.sep_serial_port.compare("NONE") != 0) {
3575
 
                        LOG_WARN("%s cannot be accessed", progStatus.sep_serial_port.c_str());
3576
 
                        progStatus.sep_serial_port = "NONE";
3577
 
                        selectSepPTTPort->value(progStatus.sep_serial_port.c_str());
3578
 
                }
3579
 
        }
3580
 
 
3581
 
        initRig();
3582
 
 
3583
 
}
3584
 
 
3585
 
void initRigCombo()
3586
 
{
3587
 
        selectRig->clear();
3588
 
        int i = 0;
3589
 
        while (rigs[i] != NULL)
3590
 
                selectRig->add(rigs[i++]->name_);
3591
 
 
3592
 
        selectRig->index(rig_nbr = 0);
3593
 
}
3594
 
 
3595
 
void nr_label(const char *l, bool on = false)
3596
 
{
3597
 
        btnNR->value(on ? 1 : 0);
3598
 
        btnNR->label(l);
3599
 
        btnNR->redraw_label();
3600
 
}
3601
 
 
3602
 
void nb_label(const char * l, bool on = false)
3603
 
{
3604
 
        btnNOISE->value(on ? 1 : 0);
3605
 
        btnNOISE->label(l);
3606
 
        btnNOISE->redraw_label();
3607
 
}
3608
 
 
3609
 
void preamp_label(const char * l, bool on = false)
3610
 
{
3611
 
        btnPreamp->value(on ? 1 : 0);
3612
 
        btnPreamp->label(l);
3613
 
        btnPreamp->redraw_label();
3614
 
}
3615
 
 
3616
 
void atten_label(const char * l, bool on = false)
3617
 
{
3618
 
        btnAttenuator->value(on ? 1 : 0);
3619
 
        btnAttenuator->label(l);
3620
 
        btnAttenuator->redraw_label();
3621
 
}
3622
 
 
3623
 
void auto_notch_label(const char * l, bool on = false)
3624
 
{
3625
 
        btnAutoNotch->value(on ? 1 : 0);
3626
 
        btnAutoNotch->label(l);
3627
 
        btnAutoNotch->redraw_label();
3628
 
}
3629
 
 
3630
 
void cbAuxPort()
3631
 
{
3632
 
        AuxSerial.setRTS(progStatus.aux_rts);
3633
 
        AuxSerial.setDTR(progStatus.aux_dtr);
3634
 
}
3635
 
 
3636
 
void cb_agc_level()
3637
 
{
3638
 
        pthread_mutex_lock(&mutex_serial);
3639
 
                selrig->set_agc_level();
3640
 
        pthread_mutex_unlock(&mutex_serial);
3641
 
}
3642
 
 
3643
 
void cb_cw_wpm()
3644
 
{
3645
 
        pthread_mutex_lock(&mutex_serial);
3646
 
                selrig->set_cw_wpm();
3647
 
        pthread_mutex_unlock(&mutex_serial);
3648
 
}
3649
 
 
3650
 
void cb_cw_vol()
3651
 
{
3652
 
//      pthread_mutex_lock(&mutex_serial);
3653
 
//              selrig->set_cw_vol();
3654
 
//      pthread_mutex_unlock(&mutex_serial);
3655
 
}
3656
 
 
3657
 
void cb_cw_spot()
3658
 
{
3659
 
        int ret;
3660
 
        pthread_mutex_lock(&mutex_serial);
3661
 
                ret = selrig->set_cw_spot();
3662
 
        pthread_mutex_unlock(&mutex_serial);
3663
 
        if (!ret) btnSpot->value(0);
3664
 
}
3665
 
 
3666
 
void cb_cw_spot_tone()
3667
 
{
3668
 
        pthread_mutex_lock(&mutex_serial);
3669
 
                selrig->set_cw_spot_tone();
3670
 
        pthread_mutex_unlock(&mutex_serial);
3671
 
}
3672
 
 
3673
 
 
3674
 
void cb_vox_gain()
3675
 
{
3676
 
        pthread_mutex_lock(&mutex_serial);
3677
 
                selrig->set_vox_gain();
3678
 
        pthread_mutex_unlock(&mutex_serial);
3679
 
}
3680
 
 
3681
 
void cb_vox_anti()
3682
 
{
3683
 
        pthread_mutex_lock(&mutex_serial);
3684
 
                selrig->set_vox_anti();
3685
 
        pthread_mutex_unlock(&mutex_serial);
3686
 
}
3687
 
 
3688
 
void cb_vox_hang()
3689
 
{
3690
 
        pthread_mutex_lock(&mutex_serial);
3691
 
                selrig->set_vox_hang();
3692
 
        pthread_mutex_unlock(&mutex_serial);
3693
 
}
3694
 
 
3695
 
void cb_vox_onoff()
3696
 
{
3697
 
        pthread_mutex_lock(&mutex_serial);
3698
 
                selrig->set_vox_onoff();
3699
 
        pthread_mutex_unlock(&mutex_serial);
3700
 
}
3701
 
 
3702
 
void cb_vox_on_dataport()
3703
 
{
3704
 
        pthread_mutex_lock(&mutex_serial);
3705
 
                selrig->set_vox_on_dataport();
3706
 
        pthread_mutex_unlock(&mutex_serial);
3707
 
}
3708
 
 
3709
 
void cb_compression()
3710
 
{
3711
 
        pthread_mutex_lock(&mutex_serial);
3712
 
                selrig->set_compression();
3713
 
        pthread_mutex_unlock(&mutex_serial);
3714
 
}
3715
 
 
3716
 
void cb_auto_notch()
3717
 
{
3718
 
        progStatus.auto_notch = btnAutoNotch->value();
3719
 
        pthread_mutex_lock(&mutex_serial);
3720
 
                selrig->set_auto_notch(progStatus.auto_notch);
3721
 
        pthread_mutex_unlock(&mutex_serial);
3722
 
}
3723
 
 
3724
 
void cb_vfo_adj()
3725
 
{
3726
 
        pthread_mutex_lock(&mutex_serial);
3727
 
                selrig->setVfoAdj(progStatus.vfo_adj);
3728
 
        pthread_mutex_unlock(&mutex_serial);
3729
 
}
3730
 
 
3731
 
void cb_line_out()
3732
 
{
3733
 
}
3734
 
 
3735
 
void cb_bpf_center()
3736
 
{
3737
 
        pthread_mutex_lock(&mutex_serial);
3738
 
                selrig->set_if_shift(selrig->pbt);
3739
 
        pthread_mutex_unlock(&mutex_serial);
3740
 
}
3741
 
 
3742
 
void cb_special()
3743
 
{
3744
 
        pthread_mutex_lock(&mutex_serial);
3745
 
                selrig->set_special(btnSpecial->value());
3746
 
        pthread_mutex_unlock(&mutex_serial);
3747
 
}
3748
 
 
3749
 
void cb_nb_level()
3750
 
{
3751
 
        pthread_mutex_lock(&mutex_serial);
3752
 
        progStatus.nb_level = cbo_nb_level->index();
3753
 
        selrig->set_nb_level();
3754
 
        pthread_mutex_unlock(&mutex_serial);
3755
 
}
3756
 
 
3757
 
void cb_spot()
3758
 
{
3759
 
        pthread_mutex_lock(&mutex_serial);
3760
 
        selrig->set_cw_spot();
3761
 
        pthread_mutex_unlock(&mutex_serial);
3762
 
}
3763
 
 
3764
 
void cb_enable_keyer()
3765
 
{
3766
 
        pthread_mutex_lock(&mutex_serial);
3767
 
        selrig->enable_keyer();
3768
 
        pthread_mutex_unlock(&mutex_serial);
3769
 
}
3770
 
 
3771
 
void cb_cw_weight()
3772
 
{
3773
 
        pthread_mutex_lock(&mutex_serial);
3774
 
        selrig->set_cw_weight();
3775
 
        pthread_mutex_unlock(&mutex_serial);
3776
 
}
3777
 
 
3778
 
void cb_cw_qsk()
3779
 
{
3780
 
        pthread_mutex_lock(&mutex_serial);
3781
 
        selrig->set_cw_qsk();
3782
 
        pthread_mutex_unlock(&mutex_serial);
3783
 
}
3784
 
 
3785
 
void cbBandSelect(int band)
3786
 
{
3787
 
// bypass local
3788
 
        pthread_mutex_lock(&mutex_serial);
3789
 
                bypass_serial_thread_loop = true;
3790
 
        pthread_mutex_unlock(&mutex_serial);
3791
 
 
3792
 
        pthread_mutex_lock(&mutex_serial);
3793
 
        pthread_mutex_lock(&mutex_xmlrpc);
3794
 
        selrig->set_band_selection(band);
3795
 
        MilliSleep(100);        // rig sync-up
3796
 
// get freqmdbw
3797
 
        if (!useB) {
3798
 
                vfoA.freq = selrig->get_vfoA();
3799
 
                if (selrig->has_mode_control)
3800
 
                        vfoA.imode = selrig->get_modeA();
3801
 
                if (selrig->has_bandwidth_control) {
3802
 
                        selrig->adjust_bandwidth(vfoA.imode);
3803
 
                        vfoA.iBW = selrig->get_bwA();
3804
 
                }
3805
 
                vfo = vfoA;
3806
 
        } else {
3807
 
                vfoB.freq = selrig->get_vfoB();
3808
 
                if (selrig->has_mode_control)
3809
 
                        vfoB.imode = selrig->get_modeB();
3810
 
                if (selrig->has_bandwidth_control) {
3811
 
                        selrig->adjust_bandwidth(vfoB.imode);
3812
 
                        vfoB.iBW = selrig->get_bwB();
3813
 
                }
3814
 
                vfo = vfoB;
3815
 
        }
3816
 
// local display freqmdbw
3817
 
        if (selrig->has_mode_control)
3818
 
                Fl::awake(setModeControl);
3819
 
        if (selrig->has_bandwidth_control) {
3820
 
                set_bandwidth_control();
3821
 
                Fl::awake(setBWControl);
3822
 
        }
3823
 
        if (!useB) Fl::awake(setFreqDispA, (void *)vfo.freq);
3824
 
        else Fl::awake(setFreqDispB, (void *)vfo.freq);
3825
 
 
3826
 
        MilliSleep(100);        // local sync-up
3827
 
// remote send freqmdbw
3828
 
        if (fldigi_online) {
3829
 
                send_xml_freq(vfo.freq);
3830
 
                if (selrig->has_mode_control) {
3831
 
                        try {
3832
 
                                send_new_mode(vfo.imode);
3833
 
                                send_sideband();
3834
 
                        } catch (...) {}
3835
 
                }
3836
 
                if (selrig->has_bandwidth_control) {
3837
 
                        try {
3838
 
                                send_bandwidths();
3839
 
                                send_new_bandwidth(vfo.iBW & 0x7F);
3840
 
                        } catch (...) {}
3841
 
                }
3842
 
                MilliSleep(100);        // remote sync-up
3843
 
        }
3844
 
 
3845
 
        pthread_mutex_unlock(&mutex_xmlrpc);
3846
 
        pthread_mutex_unlock(&mutex_serial);
3847
 
 
3848
 
// enable local
3849
 
        pthread_mutex_lock(&mutex_serial);
3850
 
                bypass_serial_thread_loop = false;
3851
 
        pthread_mutex_unlock(&mutex_serial);
3852
 
}
3853
 
 
3854
 
void enable_bandselect_btn(int btn_num, bool enable)
3855
 
{
3856
 
        switch (btn_num) {
3857
 
                case 1:
3858
 
                case 9:
3859
 
                        break;
3860
 
                case 10:        // 6m
3861
 
                        if (enable) btnBandSelect_10->show();
3862
 
                        else btnBandSelect_10->hide();
3863
 
                        break;
3864
 
                case 11:        // GEN
3865
 
                        if (enable) btnBandSelect_11->show();
3866
 
                        else btnBandSelect_11->hide();
3867
 
                        break;
3868
 
                case 13:
3869
 
                        if (enable) opSelect60->show();
3870
 
                        else opSelect60->hide();
3871
 
                        break;
3872
 
                default:
3873
 
                        break;
3874
 
        }
3875
 
}
3876
 
 
3877
 
// trim leading and trailing whitspace and double quote
3878
 
const string lt_trim(const string& pString, const string& pWhitespace)
3879
 
{
3880
 
    size_t beginStr, endStr, range;
3881
 
        beginStr = pString.find_first_not_of(pWhitespace);
3882
 
    if (beginStr == string::npos) return "";    // no content
3883
 
    endStr = pString.find_last_not_of(pWhitespace);
3884
 
    range = endStr - beginStr + 1;
3885
 
 
3886
 
    return pString.substr(beginStr, range);
3887
 
}
3888
 
 
3889
 
void editAlphaTag()
3890
 
{
3891
 
        int indx;
3892
 
        string atag;
3893
 
        if (FreqSelect->value() < 1) {
3894
 
                inAlphaTag->value("");
3895
 
                return; // no memory selected
3896
 
        }
3897
 
        indx = FreqSelect->value() - 1;
3898
 
        atag = inAlphaTag->value();
3899
 
// delete leading, trailing spaces
3900
 
        atag = lt_trim(atag);
3901
 
        memset(oplist[indx].alpha_tag, 0, ATAGSIZE);
3902
 
        snprintf(oplist[indx].alpha_tag, ATAGSIZE, "%s", atag.c_str());
3903
 
// update browser list
3904
 
        updateSelect();
3905
 
        FreqSelect->value(indx + 1);
3906
 
        inAlphaTag->value(oplist[indx].alpha_tag);
3907
 
}
3908