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

Last change on this file since 4 was 3, checked in by Sanahuja Guillaume, 8 years ago

sensoractuator

File size: 1.9 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
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
25using std::string;
26using std::ostringstream;
27using namespace flair::core;
28using namespace flair::gui;
29
30namespace flair
31{
32namespace sensor
33{
34
35RadioReceiver::RadioReceiver(const FrameworkManager* parent,string name,unsigned int nb_channels) : IODevice(parent,name)
36{
37 is_connected=false;
38 this->nb_channels=nb_channels;
39
40 //init matrix
41 cvmatrix_descriptor* desc=new cvmatrix_descriptor(nb_channels,1);
42 for(int i=0;i<nb_channels;i++)
43 {
44 ostringstream channel_name;
45 channel_name << "channel " << i;
46 desc->SetElementName(i,0,channel_name.str());
47 }
48 output=new cvmatrix(this,desc,floatType,name);
49
50 //station sol
51 main_tab=new Tab(parent->GetTabWidget(),name);
52 tab=new TabWidget(main_tab->NewRow(),name);
53 setup_tab=new Tab(tab,"Setup");
54
55 AddDataToLog(output);
56}
57
58RadioReceiver::~RadioReceiver()
59{
60 delete main_tab;
61}
62
63Layout* RadioReceiver::GetLayout(void) const
64{
65 return setup_tab;
66}
67
68float RadioReceiver::ChannelValue(unsigned int id) const
69{
70 if(id<nb_channels)
71 {
72 return output->Value(id,0);
73 }
74 else
75 {
76 Err("channel %i/%i is out of bound\n",id,nb_channels);
77 return -1;
78 }
79}
80
81bool RadioReceiver::IsConnected(void) const
82{
83 return is_connected;
84}
85
86} // end namespace sensor
87} // end namespace flair
Note: See TracBrowser for help on using the repository browser.