source: flair-src/trunk/lib/FlairSensorActuator/src/RadioReceiver.cpp@ 330

Last change on this file since 330 was 318, checked in by Sanahuja Guillaume, 3 years ago
File size: 1.9 KB
RevLine 
[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>
[214]22#include <Matrix.h>
[3]23#include <sstream>
24
25using std::string;
26using std::ostringstream;
27using namespace flair::core;
28using namespace flair::gui;
29
[15]30namespace flair {
31namespace sensor {
[3]32
[137]33RadioReceiver::RadioReceiver(string name,
[15]34 unsigned int nb_channels)
[137]35 : IODevice(getFrameworkManager(), name) {
[15]36 is_connected = false;
37 this->nb_channels = nb_channels;
[3]38
[15]39 // init matrix
[318]40 MatrixDescriptor *desc = new MatrixDescriptor(nb_channels, 1);
[15]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 }
[214]46 output = new Matrix(this, desc, floatType, name);
[148]47 delete desc;
[3]48
[15]49 // station sol
[137]50 main_tab = new Tab(getFrameworkManager()->GetTabWidget(), name);
[15]51 tab = new TabWidget(main_tab->NewRow(), name);
52 setup_tab = new Tab(tab, "Setup");
[3]53
[15]54 AddDataToLog(output);
[157]55
56 SetIsReady(true);
[3]57}
58
[15]59RadioReceiver::~RadioReceiver() { delete main_tab; }
[3]60
[15]61Layout *RadioReceiver::GetLayout(void) const { return setup_tab; }
[3]62
[15]63float RadioReceiver::ChannelValue(unsigned int id) const {
64 if (id < nb_channels) {
65 return output->Value(id, 0);
66 } else {
67 Err("channel %i/%i is out of bound\n", id, nb_channels);
68 return -1;
69 }
[3]70}
71
[15]72bool RadioReceiver::IsConnected(void) const { return is_connected; }
[3]73
74} // end namespace sensor
75} // end namespace flair
Note: See TracBrowser for help on using the repository browser.