SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
CWTX.hxx
Go to the documentation of this file.
1/*
2Copyright (c) 2012,2013,2014, 2025 Matthew H. Reilly (kb1vc)
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are
7met:
8
9 Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in
13 the documentation and/or other materials provided with the
14 distribution.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29#ifndef CWTX_HDR
30#define CWTX_HDR
31#include "SoDaBase.hxx"
32#include "SoDaThread.hxx"
33
34#include "Command.hxx"
35#include "Params.hxx"
36#include "UI.hxx"
37#include "CWGenerator.hxx"
38
39#include <SoDa/MailBox.hxx>
40
41#include <time.h>
42#include <sys/time.h>
43#include <mutex>
44#include <memory>
45
46namespace SoDa {
53 class CWTX;
54 typedef std::shared_ptr<CWTX> CWTXPtr;
55
56
57 class CWTX : public SoDa::Thread {
58 protected:
63 CWTX(ParamsPtr params);
64
65 public:
66 static CWTXPtr make(ParamsPtr params)
67 {
68 auto ret = std::shared_ptr<CWTX>(new CWTX(params));
69 ret->registerThread(ret);
70 return ret;
71 }
72
74 void subscribeToMailBoxes(const std::vector<MailBoxBasePtr> & mailboxes);
75
79 void run();
80 private:
96
101 void enqueueText(const char * buf);
102
107
112
114
115 std::shared_ptr<CWGenerator> cwgen;
116
120 CmdMBox::Subscription cwtxt_subs;
121 CmdMBox::Subscription cmd_subs;
122
125 bool tx_on;
126
128 unsigned int rf_buffer_size;
129
130 std::queue<char> text_queue;
131 std::mutex text_mutex;
132
134 std::mutex break_id_mutex;
135 };
136}
137
138
139#endif
The Baseclass for all SoDa objects, and useful commonly used classes.
The Baseclass for all SoDa thread objects.
FDatMBoxPtr cw_env_stream
stream carrying cw envelope buffers to USRPTX
Definition CWTX.hxx:119
CmdMBox::Subscription cmd_subs
subscription for command stream
Definition CWTX.hxx:121
bool old_txmode_is_cw
remember the mode we were in
Definition CWTX.hxx:124
void clearTextQueue()
forget all enqueued text
CmdMBoxPtr cmd_stream
stream of commands to modify radio state
Definition CWTX.hxx:118
std::mutex break_id_mutex
mutex for break_notification queue
Definition CWTX.hxx:134
void execGetCommand(CommandPtr cmd)
execute GET commands from the command channel
static CWTXPtr make(ParamsPtr params)
Definition CWTX.hxx:66
CmdMBoxPtr cwtxt_stream
stream of characters to be encoded (from UI or elsewhere)
Definition CWTX.hxx:117
bool tx_on
if true, we're transmitting a CW stream or a beacon
Definition CWTX.hxx:125
void subscribeToMailBoxes(const std::vector< MailBoxBasePtr > &mailboxes)
implement the subscription method
void execRepCommand(CommandPtr cmd)
handle Report commands from the command channel
unsigned int rf_buffer_size
the size of the envelope buffer
Definition CWTX.hxx:128
double rf_sample_rate
samples/sec for generating the envelope
Definition CWTX.hxx:127
int sent_char_count
Definition CWTX.hxx:113
std::mutex text_mutex
mutex for text_queue
Definition CWTX.hxx:131
void enqueueText(const char *buf)
add text to the outbound text queue
std::queue< char > text_queue
characters waiting to be sent
Definition CWTX.hxx:130
CWTX(ParamsPtr params)
Constructor.
bool sendAvailChar()
if a character is available, encode it into an envelope
void run()
CWTX run loop: translate text to CW envelopes, handle incoming commands.
std::queue< int > break_notification_id_queue
tags inserted into text stream – send tag when the CW envelope generator gets to this character.
Definition CWTX.hxx:133
bool txmode_is_cw
if true, we're transmitting a CW stream
Definition CWTX.hxx:123
CmdMBox::Subscription cwtxt_subs
subscription for text stream
Definition CWTX.hxx:120
void execSetCommand(CommandPtr cmd)
handle SET commands from the command channel
std::shared_ptr< CWGenerator > cwgen
Pointer to a text-to-morse translator.
Definition CWTX.hxx:115
The Thread baseclass for all SoDa thread objects.
std::shared_ptr< CWTX > CWTXPtr
Definition CWTX.hxx:54
std::shared_ptr< Params > ParamsPtr
Definition Params.hxx:42
std::shared_ptr< Command > CommandPtr
Definition Command.hxx:41
std::shared_ptr< CmdMBox > CmdMBoxPtr
Definition SoDaBase.hxx:79
std::shared_ptr< FDatMBox > FDatMBoxPtr
Definition SoDaBase.hxx:85