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/11/07
|
---|
6 | // filename: PidThrust.cpp
|
---|
7 | //
|
---|
8 | // author: Guillaume Sanahuja
|
---|
9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
10 | //
|
---|
11 | // version: $Id: $
|
---|
12 | //
|
---|
13 | // purpose: Class defining a PidThrust
|
---|
14 | //
|
---|
15 | //
|
---|
16 | /*********************************************************************/
|
---|
17 |
|
---|
18 | #include "PidThrust.h"
|
---|
19 | #include "PidThrust_impl.h"
|
---|
20 | #include <cvmatrix.h>
|
---|
21 | #include <Layout.h>
|
---|
22 | #include <LayoutPosition.h>
|
---|
23 | #include <DoubleSpinBox.h>
|
---|
24 |
|
---|
25 | using std::string;
|
---|
26 | using namespace flair::core;
|
---|
27 | using namespace flair::gui;
|
---|
28 |
|
---|
29 | namespace flair
|
---|
30 | {
|
---|
31 | namespace filter
|
---|
32 | {
|
---|
33 |
|
---|
34 | PidThrust::PidThrust(const LayoutPosition* position,string name) : ControlLaw(position->getLayout(),name)
|
---|
35 | {
|
---|
36 | pimpl_=new PidThrust_impl(this,position,name);
|
---|
37 | }
|
---|
38 |
|
---|
39 | PidThrust::~PidThrust(void)
|
---|
40 | {
|
---|
41 | delete pimpl_;
|
---|
42 | }
|
---|
43 |
|
---|
44 | void PidThrust::UseDefaultPlot(const flair::gui::LayoutPosition* position)
|
---|
45 | {
|
---|
46 | pimpl_->UseDefaultPlot(position);
|
---|
47 | }
|
---|
48 |
|
---|
49 | void PidThrust::Reset(void) {
|
---|
50 | pimpl_->i=0;
|
---|
51 | pimpl_->offset_g=0;
|
---|
52 | }
|
---|
53 |
|
---|
54 | void PidThrust::ResetI(void)
|
---|
55 | {
|
---|
56 | pimpl_->i=0;
|
---|
57 | }
|
---|
58 |
|
---|
59 | float PidThrust::GetOffset(void) {
|
---|
60 | return pimpl_->offset_g;
|
---|
61 | }
|
---|
62 |
|
---|
63 | void PidThrust::UpdateFrom(const io_data *data)
|
---|
64 | {
|
---|
65 | pimpl_->UpdateFrom(data);
|
---|
66 | ProcessUpdate(output);
|
---|
67 | }
|
---|
68 |
|
---|
69 | void PidThrust::SetValues(float p,float d)
|
---|
70 | {
|
---|
71 | input->SetValue(0,0,p);
|
---|
72 | input->SetValue(1,0,d);
|
---|
73 | }
|
---|
74 |
|
---|
75 | void PidThrust::ResetOffset(void)
|
---|
76 | {
|
---|
77 | pimpl_->offset_g=0;
|
---|
78 | }
|
---|
79 |
|
---|
80 | void PidThrust::SetOffset(void)
|
---|
81 | {
|
---|
82 | pimpl_->offset_g=pimpl_->offset->Value();
|
---|
83 | }
|
---|
84 |
|
---|
85 | bool PidThrust::OffsetStepUp(void)
|
---|
86 | {
|
---|
87 | pimpl_->offset_g+=pimpl_->pas_offset->Value();
|
---|
88 | if(pimpl_->offset_g>1)
|
---|
89 | {
|
---|
90 | pimpl_->offset_g=1;
|
---|
91 | return false;
|
---|
92 | }
|
---|
93 | else
|
---|
94 | {
|
---|
95 | return true;
|
---|
96 | }
|
---|
97 | }
|
---|
98 |
|
---|
99 | bool PidThrust::OffsetStepDown(void)
|
---|
100 | {
|
---|
101 | pimpl_->offset_g-=pimpl_->pas_offset->Value();
|
---|
102 | if(pimpl_->offset_g<pimpl_->offset->Value())
|
---|
103 | {
|
---|
104 | pimpl_->offset_g=pimpl_->offset->Value();
|
---|
105 | return false;
|
---|
106 | }
|
---|
107 | else
|
---|
108 | {
|
---|
109 | return true;
|
---|
110 | }
|
---|
111 | }
|
---|
112 |
|
---|
113 | } // end namespace filter
|
---|
114 | } // end namespace flair
|
---|