HARDT - The Ham Radio DSP Toolkit
hstreamprocessor.h
1 #ifndef __HSTREAMPROCESSOR_H
2 #define __HSTREAMPROCESSOR_H
3 
4 #include "hreader.h"
5 #include "hwriter.h"
6 
10 template <class T>
11 class HStreamProcessor : public HProcessor<T>
12 {
13  public:
14 
16  HStreamProcessor(HWriter<T>* writer, HReader<T>* reader, int blocksize, bool* terminationToken);
17 
20  HStreamProcessor(HReader<T>* reader, int blocksize, bool* terminationToken);
21 
23  void Run(long unsigned int blocks = 0);
24 
26  bool Command(H_COMMAND_CLASS commandClass, H_COMMAND_OPCODE commandOpcode, int16_t length, HCommandData data)
27  {
28  HLog("Creating command with class %d and opcode %d with length %d", commandClass, commandOpcode, length);
29  HCommand cmd = {static_cast<int16_t>(commandClass), static_cast<int16_t>(commandOpcode), length, data};
30 
31  if( HProcessor<T>::_reader != nullptr )
32  {
33  HLog("Sending command to reader chain");
34  if( !HProcessor<T>::_reader->Command(&cmd) )
35  {
36  HError("Error when sending command to reader chain");
37  return false;
38  }
39  }
40  if( HProcessor<T>::_writer != nullptr )
41  {
42  HLog("Sending command to writer chain");
43  if( !HProcessor<T>::_writer->Command(&cmd) )
44  {
45  HError("Error when sending command to writer chain");
46  return false;
47  }
48  }
49 
50  HLog("Command sent successfully");
51  return true;
52  }
53 };
54 
55 #endif
HProcessor
Definition: hprocessor.h:24
HStreamProcessor::Command
bool Command(H_COMMAND_CLASS commandClass, H_COMMAND_OPCODE commandOpcode, int16_t length, HCommandData data)
Definition: hstreamprocessor.h:26
HStreamProcessor::Run
void Run(long unsigned int blocks=0)
Definition: hstreamprocessor.cpp:21
HWriter
Definition: hwriter.h:10
HReader
Definition: hreader.h:24
HStreamProcessor
Definition: hstreamprocessor.h:11
HCommand
Definition: hcommand.h:81
HCommandData
Definition: hcommand.h:68
HStreamProcessor::HStreamProcessor
HStreamProcessor(HWriter< T > *writer, HReader< T > *reader, int blocksize, bool *terminationToken)
Definition: hstreamprocessor.cpp:7