[10] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[10] | 4 | // %flair:license}
|
---|
[7] | 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"
|
---|
[214] | 20 | #include <Matrix.h>
|
---|
[7] | 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 |
|
---|
[15] | 29 | namespace flair {
|
---|
| 30 | namespace filter {
|
---|
[7] | 31 |
|
---|
[15] | 32 | PidThrust::PidThrust(const LayoutPosition *position, string name)
|
---|
| 33 | : ControlLaw(position->getLayout(), name) {
|
---|
| 34 | pimpl_ = new PidThrust_impl(this, position, name);
|
---|
[157] | 35 |
|
---|
| 36 | SetIsReady(true);
|
---|
[7] | 37 | }
|
---|
| 38 |
|
---|
[15] | 39 | PidThrust::~PidThrust(void) { delete pimpl_; }
|
---|
[7] | 40 |
|
---|
[15] | 41 | void PidThrust::UseDefaultPlot(const flair::gui::LayoutPosition *position) {
|
---|
| 42 | pimpl_->UseDefaultPlot(position);
|
---|
[7] | 43 | }
|
---|
| 44 |
|
---|
[216] | 45 | void PidThrust::Reset(void) {
|
---|
| 46 | ResetI();
|
---|
| 47 | SetDefaultOffset();
|
---|
| 48 | SetValues(0,0);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
[15] | 51 | void PidThrust::ResetI(void) { pimpl_->i = 0; }
|
---|
[7] | 52 |
|
---|
[216] | 53 | float PidThrust::GetOffset(void) const { return pimpl_->offset_g; }
|
---|
[7] | 54 |
|
---|
[216] | 55 | float PidThrust::GetIntegral(void) const { return pimpl_->i; }
|
---|
| 56 |
|
---|
[15] | 57 | void PidThrust::UpdateFrom(const io_data *data) {
|
---|
| 58 | pimpl_->UpdateFrom(data);
|
---|
| 59 | ProcessUpdate(output);
|
---|
[7] | 60 | }
|
---|
| 61 |
|
---|
[15] | 62 | void PidThrust::SetValues(float p, float d) {
|
---|
| 63 | input->SetValue(0, 0, p);
|
---|
| 64 | input->SetValue(1, 0, d);
|
---|
[7] | 65 | }
|
---|
| 66 |
|
---|
[206] | 67 | void PidThrust::SetDefaultOffset(void) { pimpl_->offset_g = pimpl_->offset->Value(); }
|
---|
[7] | 68 |
|
---|
[206] | 69 | void PidThrust::SetOffset(float value) { pimpl_->offset_g = value; }
|
---|
[7] | 70 |
|
---|
[15] | 71 | bool PidThrust::OffsetStepUp(void) {
|
---|
| 72 | pimpl_->offset_g += pimpl_->pas_offset->Value();
|
---|
| 73 | if (pimpl_->offset_g > 1) {
|
---|
| 74 | pimpl_->offset_g = 1;
|
---|
| 75 | return false;
|
---|
| 76 | } else {
|
---|
| 77 | return true;
|
---|
| 78 | }
|
---|
[7] | 79 | }
|
---|
| 80 |
|
---|
[15] | 81 | bool PidThrust::OffsetStepDown(void) {
|
---|
| 82 | pimpl_->offset_g -= pimpl_->pas_offset->Value();
|
---|
| 83 | if (pimpl_->offset_g < pimpl_->offset->Value()) {
|
---|
| 84 | pimpl_->offset_g = pimpl_->offset->Value();
|
---|
| 85 | return false;
|
---|
| 86 | } else {
|
---|
| 87 | return true;
|
---|
| 88 | }
|
---|
[7] | 89 | }
|
---|
| 90 |
|
---|
| 91 | } // end namespace filter
|
---|
| 92 | } // end namespace flair
|
---|