[3] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[3] | 4 | // %flair:license}
|
---|
| 5 | // created: 2014/07/08
|
---|
| 6 | // filename: RadioReceiver.cpp
|
---|
| 7 | //
|
---|
| 8 | // author: Guillaume Sanahuja
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
| 13 | // purpose: Base class for radio receiver
|
---|
| 14 | //
|
---|
| 15 | //
|
---|
| 16 | /*********************************************************************/
|
---|
| 17 |
|
---|
| 18 | #include "RadioReceiver.h"
|
---|
| 19 | #include <Tab.h>
|
---|
| 20 | #include <TabWidget.h>
|
---|
| 21 | #include <FrameworkManager.h>
|
---|
| 22 | #include <cvmatrix.h>
|
---|
| 23 | #include <sstream>
|
---|
| 24 |
|
---|
| 25 | using std::string;
|
---|
| 26 | using std::ostringstream;
|
---|
| 27 | using namespace flair::core;
|
---|
| 28 | using namespace flair::gui;
|
---|
| 29 |
|
---|
[15] | 30 | namespace flair {
|
---|
| 31 | namespace sensor {
|
---|
[3] | 32 |
|
---|
[15] | 33 | RadioReceiver::RadioReceiver(const FrameworkManager *parent, string name,
|
---|
| 34 | unsigned int nb_channels)
|
---|
| 35 | : IODevice(parent, name) {
|
---|
| 36 | is_connected = false;
|
---|
| 37 | this->nb_channels = nb_channels;
|
---|
[3] | 38 |
|
---|
[15] | 39 | // init matrix
|
---|
| 40 | cvmatrix_descriptor *desc = new cvmatrix_descriptor(nb_channels, 1);
|
---|
| 41 | for (int i = 0; i < nb_channels; i++) {
|
---|
| 42 | ostringstream channel_name;
|
---|
| 43 | channel_name << "channel " << i;
|
---|
| 44 | desc->SetElementName(i, 0, channel_name.str());
|
---|
| 45 | }
|
---|
| 46 | output = new cvmatrix(this, desc, floatType, name);
|
---|
[3] | 47 |
|
---|
[15] | 48 | // station sol
|
---|
| 49 | main_tab = new Tab(parent->GetTabWidget(), name);
|
---|
| 50 | tab = new TabWidget(main_tab->NewRow(), name);
|
---|
| 51 | setup_tab = new Tab(tab, "Setup");
|
---|
[3] | 52 |
|
---|
[15] | 53 | AddDataToLog(output);
|
---|
[3] | 54 | }
|
---|
| 55 |
|
---|
[15] | 56 | RadioReceiver::~RadioReceiver() { delete main_tab; }
|
---|
[3] | 57 |
|
---|
[15] | 58 | Layout *RadioReceiver::GetLayout(void) const { return setup_tab; }
|
---|
[3] | 59 |
|
---|
[15] | 60 | float RadioReceiver::ChannelValue(unsigned int id) const {
|
---|
| 61 | if (id < nb_channels) {
|
---|
| 62 | return output->Value(id, 0);
|
---|
| 63 | } else {
|
---|
| 64 | Err("channel %i/%i is out of bound\n", id, nb_channels);
|
---|
| 65 | return -1;
|
---|
| 66 | }
|
---|
[3] | 67 | }
|
---|
| 68 |
|
---|
[15] | 69 | bool RadioReceiver::IsConnected(void) const { return is_connected; }
|
---|
[3] | 70 |
|
---|
| 71 | } // end namespace sensor
|
---|
| 72 | } // end namespace flair
|
---|