source: flair-src/trunk/lib/FlairFilter/src/ControlLaw.cpp@ 7

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

filter and meta

File size: 1.6 KB
Line 
1// created: 2014/04/30
2// filename: ControlLaw.cpp
3//
4// author: Guillaume Sanahuja
5// Copyright Heudiasyc UMR UTC/CNRS 7253
6//
7// version: $Id: $
8//
9// purpose: Base class for control law
10//
11//
12/*********************************************************************/
13
14#include "ControlLaw.h"
15#include <cvmatrix.h>
16#include <cvmatrix_descriptor.h>
17#include <DataPlot1D.h>
18#include <sstream>
19
20using std::string;
21using namespace flair::core;
22using namespace flair::gui;
23
24namespace flair {
25namespace filter {
26
27ControlLaw::ControlLaw(const Object* parent,string name,uint32_t nb_out) : IODevice(parent,name) {
28 if(nb_out==1) {
29 output=new cvmatrix(this,nb_out,1,floatType,name);
30 } else {
31 cvmatrix_descriptor* desc=new cvmatrix_descriptor(nb_out,1);
32 for(int i=0;i<nb_out;i++) {
33 std::stringstream ss;
34 ss << i;
35 desc->SetElementName(i,0,ss.str());
36 }
37 output=new cvmatrix(this,desc,floatType,name);
38 }
39
40 input=NULL;
41 AddDataToLog(output);
42}
43
44ControlLaw::~ControlLaw(void) {
45
46}
47
48void ControlLaw::Update(Time time) {
49 input->SetDataTime(time);
50 UpdateFrom(input);
51}
52
53float ControlLaw::Output(uint32_t index) const {
54 return output->Value(index,0);
55}
56
57void ControlLaw::UseDefaultPlot(const LayoutPosition* position) {
58 if(output->Rows()!=1) Warn("Output size is different from 1. Plotting only Output(1,1).\n");
59
60 DataPlot1D *plot=new DataPlot1D(position,ObjectName(),-1,1);
61 plot->AddCurve(output->Element(0));
62}
63} // end namespace filter
64} // end namespace flair
Note: See TracBrowser for help on using the repository browser.