SoDaRadio-5.0.3-master:8901fb5
CWTX.hxx
Go to the documentation of this file.
1 /*
2 Copyright (c) 2012,2013,2014 Matthew H. Reilly (kb1vc)
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
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 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF 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 "MultiMBox.hxx"
33 #include "Command.hxx"
34 #include "Params.hxx"
35 #include "UI.hxx"
36 #include "CWGenerator.hxx"
37 
38 #include <time.h>
39 #include <sys/time.h>
40 
41 namespace SoDa {
48  class CWTX : public SoDaThread {
49  public:
61  void run();
62  private:
67  void execGetCommand(Command * cmd);
72  void execSetCommand(Command * cmd);
77  void execRepCommand(Command * cmd);
78 
83  void enqueueText(const char * buf);
84 
88  void clearTextQueue();
89 
93  bool sendAvailChar();
94 
96 
98 
102  unsigned int cwtxt_subs;
103  unsigned int cmd_subs;
104 
107  bool tx_on;
108 
109  double rf_sample_rate;
110  unsigned int rf_buffer_size;
111 
112  float * beacon_envelope;
113 
114  std::queue<char> text_queue;
115  boost::mutex text_lock;
116 
117  std::queue<int> break_notification_id_queue;
118  boost::mutex break_id_lock;
119  };
120 }
121 
122 
123 #endif
The Baseclass for all SoDa objects, and useful commonly used classes.
The Thread baseclass for all SoDa thread objects.
Definition: SoDaBase.hxx:284
unsigned int cmd_subs
subscription for command stream
Definition: CWTX.hxx:103
float * beacon_envelope
the currently generated envelope
Definition: CWTX.hxx:112
CmdMBox * cmd_stream
stream of commands to modify radio state
Definition: CWTX.hxx:100
void execSetCommand(Command *cmd)
handle SET commands from the command channel
Definition: CWTX.cxx:156
This class handles command line parameters and built-ins.
Definition: Params.hxx:42
void run()
CWTX run loop: translate text to CW envelopes, handle incoming commands.
Definition: CWTX.cxx:60
void execGetCommand(Command *cmd)
execute GET commands from the command channel
Definition: CWTX.cxx:136
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:117
bool sendAvailChar()
if a character is available, encode it into an envelope
Definition: CWTX.cxx:97
CWTX(Params *params, CmdMBox *cwtxt_stream, DatMBox *cw_env_stream, CmdMBox *cmd_stream)
Constructor.
Definition: CWTX.cxx:32
The CW text-to-envelope converter run loop.
Definition: CWTX.hxx:48
std::queue< char > text_queue
characters waiting to be sent
Definition: CWTX.hxx:114
This is a list of all the commands that can "do something" to one or more components in the SoDa radi...
Definition: Command.hxx:47
double rf_sample_rate
samples/sec for generating the envelope
Definition: CWTX.hxx:109
void clearTextQueue()
forget all enqueued text
Definition: CWTX.cxx:222
void execRepCommand(Command *cmd)
handle Report commands from the command channel
Definition: CWTX.cxx:240
CmdMBox * cwtxt_stream
stream of characters to be encoded (from UI or elsewhere)
Definition: CWTX.hxx:99
unsigned int cwtxt_subs
subscription for text stream
Definition: CWTX.hxx:102
boost::mutex text_lock
lock for text_queue
Definition: CWTX.hxx:115
boost::mutex break_id_lock
lock for break_notification queue
Definition: CWTX.hxx:118
unsigned int rf_buffer_size
the size of the envelope buffer
Definition: CWTX.hxx:110
bool txmode_is_cw
if true, we&#39;re transmitting a CW stream
Definition: CWTX.hxx:105
CWGenerator * cwgen
Pointer to a text-to-morse translator.
Definition: CWTX.hxx:97
int sent_char_count
Definition: CWTX.hxx:95
bool tx_on
if true, we&#39;re transmitting a CW stream or a beacon
Definition: CWTX.hxx:107
void enqueueText(const char *buf)
add text to the outbound text queue
Definition: CWTX.cxx:208
DatMBox * cw_env_stream
stream carrying cw envelope buffers to USRPTX
Definition: CWTX.hxx:101
A text to morse envelope converter.
Definition: CWGenerator.hxx:44
bool old_txmode_is_cw
remember the mode we were in
Definition: CWTX.hxx:106