JS8Call-Improved master
Loading...
Searching...
No Matches
DXLabSuiteCommanderTransceiver.h
1#ifndef DX_LAB_SUITE_COMMANDER_TRANSCEIVER_HPP__
2#define DX_LAB_SUITE_COMMANDER_TRANSCEIVER_HPP__
3
4#include "PollingTransceiver.h"
5#include "TransceiverFactory.h"
6
7#include <memory>
8
9class QTcpSocket;
10class QByteArray;
11class QString;
12
13//
14// DX Lab Suite Commander Interface
15//
16// Implemented as a Transceiver decorator because we may want the PTT
17// services of another Transceiver type such as the HamlibTransceiver
18// which can be enabled by wrapping a HamlibTransceiver instantiated
19// as a "Hamlib Dummy" transceiver in the Transceiver factory method.
20//
21class DXLabSuiteCommanderTransceiver final : public PollingTransceiver {
22 Q_OBJECT; // for translation context
23
24 public:
25 static void register_transceivers(TransceiverFactory::Transceivers *,
26 int id);
27
28 // takes ownership of wrapped Transceiver
29 explicit DXLabSuiteCommanderTransceiver(
30 std::unique_ptr<TransceiverBase> wrapped, QString const &address,
31 bool use_for_ptt, int poll_interval, QObject *parent = nullptr);
32
33 protected:
34 int do_start() override;
35 void do_stop() override;
36 void do_frequency(Frequency, MODE, bool no_ignore) override;
37 void do_tx_frequency(Frequency, MODE, bool no_ignore) override;
38 void do_mode(MODE) override;
39 void do_ptt(bool on) override;
40
41 void poll() override;
42
43 private:
44 MODE get_mode(bool no_debug = false);
45 void simple_command(QString const &, bool no_debug = false);
46 QString command_with_reply(QString const &, bool no_debug = false);
47 bool write_to_port(QString const &);
48 QString frequency_to_string(Frequency) const;
49 Frequency string_to_frequency(QString) const;
50
51 std::unique_ptr<TransceiverBase> wrapped_; // may be null
52 bool use_for_ptt_;
53 QString server_;
54 QTcpSocket *commander_;
55 QLocale locale_;
56};
57
58#endif