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

« back to all changes in this revision

Viewing changes to src/K3_ui.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
 
// ----------------------------------------------------------------------------
2
 
// Copyright (C) 2014
3
 
//              David Freese, W1HKJ
4
 
//
5
 
// This file is part of flrig.
6
 
//
7
 
// flrig is free software; you can redistribute it and/or modify
8
 
// it under the terms of the GNU General Public License as published by
9
 
// the Free Software Foundation; either version 3 of the License, or
10
 
// (at your option) any later version.
11
 
//
12
 
// flrig is distributed in the hope that it will be useful,
13
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
// GNU General Public License for more details.
16
 
//
17
 
// You should have received a copy of the GNU General Public License
18
 
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 
// ----------------------------------------------------------------------------
20
 
 
21
 
#include <stdlib.h>
22
 
#include <iostream>
23
 
#include <fstream>
24
 
 
25
 
#include <vector>
26
 
#include <queue>
27
 
#include <sys/types.h>
28
 
#include <sys/stat.h>
29
 
#include <stdlib.h>
30
 
#include <stdio.h>
31
 
#include <fcntl.h>
32
 
#include <pthread.h>
33
 
 
34
 
#include "support.h"
35
 
#include "debug.h"
36
 
#include "gettext.h"
37
 
#include "rig_io.h"
38
 
#include "dialogs.h"
39
 
#include "rigbase.h"
40
 
#include "ptt.h"
41
 
#include "xml_io.h"
42
 
 
43
 
#include "rigs.h"
44
 
#include "K3_ui.h"
45
 
 
46
 
extern queue<FREQMODE> queA;
47
 
extern queue<FREQMODE> queB;
48
 
extern queue<bool> quePTT;
49
 
 
50
 
void read_K3()
51
 
{
52
 
        pthread_mutex_lock(&mutex_serial);
53
 
 
54
 
        if (progStatus.poll_frequency) {
55
 
                long  freq;
56
 
                freq = selrig->get_vfoA();
57
 
                if (freq != vfoA.freq) {
58
 
                        pthread_mutex_lock(&mutex_xmlrpc);
59
 
                        vfoA.freq = freq;
60
 
                        Fl::awake(setFreqDispA, (void *)vfoA.freq);
61
 
                        vfo = vfoA;
62
 
                        try {
63
 
                                send_xml_freq(vfo.freq);
64
 
                        } catch (...) {}
65
 
                        pthread_mutex_unlock(&mutex_xmlrpc);
66
 
                }
67
 
                freq = selrig->get_vfoB();
68
 
                if (freq != vfoB.freq) {
69
 
                        vfoB.freq = freq;
70
 
                        Fl::awake(setFreqDispB, (void *)vfoB.freq);
71
 
                }
72
 
        }
73
 
        if (!quePTT.empty()) goto exit_read;
74
 
 
75
 
        if (progStatus.poll_mode) {
76
 
                int nu_mode;
77
 
                nu_mode = selrig->get_modeA();
78
 
                if (nu_mode != vfoA.imode) {
79
 
                        pthread_mutex_lock(&mutex_xmlrpc);
80
 
                        vfoA.imode = vfo.imode = nu_mode;
81
 
                        selrig->set_bwA(vfo.iBW = selrig->adjust_bandwidth(nu_mode));
82
 
                        try {
83
 
                                send_bandwidths();
84
 
                                send_new_mode(nu_mode);
85
 
                                send_sideband();
86
 
                                send_new_bandwidth(vfo.iBW);
87
 
                        } catch (...) {}
88
 
                        pthread_mutex_unlock(&mutex_xmlrpc);
89
 
                        Fl::awake(setModeControl);
90
 
                        Fl::awake(updateBandwidthControl);
91
 
                }
92
 
                nu_mode = selrig->get_modeB();
93
 
                if (nu_mode != vfoB.imode) {
94
 
                        vfoB.imode = nu_mode;
95
 
                }
96
 
        }
97
 
        if (!quePTT.empty()) goto exit_read;
98
 
 
99
 
        if (progStatus.poll_bandwidth) {
100
 
                int nu_BW;
101
 
                nu_BW = selrig->get_bwA();
102
 
                if (nu_BW != vfoA.iBW) {
103
 
                        pthread_mutex_lock(&mutex_xmlrpc);
104
 
                        vfoA.iBW = vfo.iBW = nu_BW;
105
 
                        Fl::awake(setBWControl);
106
 
                        try {
107
 
                                send_new_bandwidth(vfo.iBW);
108
 
                        } catch (...) {}
109
 
                        pthread_mutex_unlock(&mutex_xmlrpc);
110
 
                }
111
 
                nu_BW = selrig->get_bwB();
112
 
                if (nu_BW != vfoB.iBW) {
113
 
                        vfoB.iBW = nu_BW;
114
 
                }
115
 
        }
116
 
 
117
 
exit_read:
118
 
        pthread_mutex_unlock(&mutex_serial);
119
 
}
120
 
 
121
 
void K3_set_split(int val)
122
 
{
123
 
        pthread_mutex_lock(&mutex_serial);
124
 
                selrig->set_split(val);
125
 
        pthread_mutex_unlock(&mutex_serial);
126
 
 
127
 
}
128
 
 
129
 
extern char *print(FREQMODE data);
130
 
 
131
 
void K3_A2B()
132
 
{
133
 
        pthread_mutex_lock(&mutex_serial);
134
 
        vfoB = vfoA;
135
 
        selrig->set_vfoB(vfoB.freq);
136
 
        selrig->set_bwB(vfoB.iBW);
137
 
        selrig->set_modeB(vfoB.imode);
138
 
        FreqDispB->value(vfoB.freq);
139
 
        pthread_mutex_unlock(&mutex_serial);
140
 
        Fl::focus(FreqDispA);
141
 
}
142
 
 
143
 
void cb_K3_swapAB()
144
 
{
145
 
        FREQMODE temp = vfoA;
146
 
        pthread_mutex_lock(&mutex_serial);
147
 
        vfoA = vfoB;
148
 
        vfoB = temp;
149
 
        vfo = vfoA;
150
 
 
151
 
        selrig->set_vfoB(vfoB.freq);
152
 
        selrig->set_bwB(vfoB.iBW);
153
 
        selrig->set_modeB(vfoB.imode);
154
 
 
155
 
        selrig->set_vfoA(vfoA.freq);
156
 
        selrig->set_bwA(vfoA.iBW);
157
 
        selrig->set_modeA(vfoA.imode);
158
 
 
159
 
        opBW->index(vfoA.iBW);
160
 
        opMODE->index(vfoA.imode);
161
 
        FreqDispA->value(vfoA.freq);
162
 
 
163
 
        FreqDispB->value(vfoB.freq);
164
 
 
165
 
        pthread_mutex_unlock(&mutex_serial);
166
 
 
167
 
        Fl::focus(FreqDispA);
168
 
}