source: flair-src/trunk/lib/FlairFilter/src/UavMultiplex_impl.cpp@ 10

Last change on this file since 10 was 10, checked in by Sanahuja Guillaume, 7 years ago

lic

File size: 2.4 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/04/11
6// filename: UavMultiplex_impl.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class defining uav multiplexing
14//
15//
16/*********************************************************************/
17
18#include "UavMultiplex_impl.h"
19#include "UavMultiplex.h"
20#include <cvmatrix.h>
21#include <FrameworkManager.h>
22#include <TabWidget.h>
23#include <Tab.h>
24#include <GridLayout.h>
25#include <ComboBox.h>
26#include <GroupBox.h>
27#include <sstream>
28
29using std::string;
30using std::ostringstream;
31using namespace flair::core;
32using namespace flair::gui;
33using namespace flair::filter;
34
35UavMultiplex_impl::UavMultiplex_impl(const FrameworkManager* parent,UavMultiplex* self,std::string name) {
36 input=new cvmatrix(self,7,1,floatType);
37 multiplexcombobox=NULL;
38 this->self=self;
39
40 //station sol
41 main_tab=new Tab(parent->GetTabWidget(),name);
42 tabwidget=new TabWidget(main_tab->NewRow(),"UavMultiplex");
43 setup_tab=new Tab(tabwidget,"Setup");
44}
45
46UavMultiplex_impl::~UavMultiplex_impl(void)
47{
48 delete main_tab;
49 if(multiplexcombobox!=NULL) free(multiplexcombobox);
50}
51
52void UavMultiplex_impl::SetMultiplexComboBox(string name,int index)
53{
54 //we do not know motorcount at constructor time, so allocation is done here
55 if(multiplexcombobox==NULL)
56 {
57 multiplexcombobox=(ComboBox**)malloc(self->MotorsCount()*sizeof(ComboBox*));
58 for(int i=0;i<self->MotorsCount();i++) multiplexcombobox[i]=NULL;
59 groupbox=new GroupBox(setup_tab->NewRow(),"motor attribution");
60 }
61 if(index>self->MotorsCount())
62 {
63 self->Err("index out of bound %i/%i\n",index,self->MotorsCount());
64 return;
65 }
66 if(multiplexcombobox[index]!=NULL)
67 {
68 self->Err("index already setup\n");
69 return;
70 }
71
72 multiplexcombobox[index]=new ComboBox(groupbox->At(index/4,index%4),name);
73
74 for(int i=0;i<self->MotorsCount();i++)
75 {
76 ostringstream oss;
77 oss << i;
78 multiplexcombobox[index]->AddItem(oss.str());
79 }
80}
81
82int UavMultiplex_impl::MultiplexValue(int index) const
83{
84 if(multiplexcombobox[index]!=NULL)
85 {
86 return multiplexcombobox[index]->CurrentIndex();
87 }
88 else
89 {
90 self->Err("multiplex not setup for motor %i\n",index);
91 return 0;
92 }
93
94}
Note: See TracBrowser for help on using the repository browser.