[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"
|
---|
| 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 |
|
---|
[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);
|
---|
[7] | 35 | }
|
---|
| 36 |
|
---|
[15] | 37 | PidThrust::~PidThrust(void) { delete pimpl_; }
|
---|
[7] | 38 |
|
---|
[15] | 39 | void PidThrust::UseDefaultPlot(const flair::gui::LayoutPosition *position) {
|
---|
| 40 | pimpl_->UseDefaultPlot(position);
|
---|
[7] | 41 | }
|
---|
| 42 |
|
---|
| 43 | void PidThrust::Reset(void) {
|
---|
[15] | 44 | pimpl_->i = 0;
|
---|
| 45 | pimpl_->offset_g = 0;
|
---|
[7] | 46 | }
|
---|
| 47 |
|
---|
[15] | 48 | void PidThrust::ResetI(void) { pimpl_->i = 0; }
|
---|
[7] | 49 |
|
---|
[15] | 50 | float PidThrust::GetOffset(void) { return pimpl_->offset_g; }
|
---|
[7] | 51 |
|
---|
[15] | 52 | void PidThrust::UpdateFrom(const io_data *data) {
|
---|
| 53 | pimpl_->UpdateFrom(data);
|
---|
| 54 | ProcessUpdate(output);
|
---|
[7] | 55 | }
|
---|
| 56 |
|
---|
[15] | 57 | void PidThrust::SetValues(float p, float d) {
|
---|
| 58 | input->SetValue(0, 0, p);
|
---|
| 59 | input->SetValue(1, 0, d);
|
---|
[7] | 60 | }
|
---|
| 61 |
|
---|
[15] | 62 | void PidThrust::ResetOffset(void) { pimpl_->offset_g = 0; }
|
---|
[7] | 63 |
|
---|
[15] | 64 | void PidThrust::SetOffset(void) { pimpl_->offset_g = pimpl_->offset->Value(); }
|
---|
[7] | 65 |
|
---|
[15] | 66 | bool PidThrust::OffsetStepUp(void) {
|
---|
| 67 | pimpl_->offset_g += pimpl_->pas_offset->Value();
|
---|
| 68 | if (pimpl_->offset_g > 1) {
|
---|
| 69 | pimpl_->offset_g = 1;
|
---|
| 70 | return false;
|
---|
| 71 | } else {
|
---|
| 72 | return true;
|
---|
| 73 | }
|
---|
[7] | 74 | }
|
---|
| 75 |
|
---|
[15] | 76 | bool PidThrust::OffsetStepDown(void) {
|
---|
| 77 | pimpl_->offset_g -= pimpl_->pas_offset->Value();
|
---|
| 78 | if (pimpl_->offset_g < pimpl_->offset->Value()) {
|
---|
| 79 | pimpl_->offset_g = pimpl_->offset->Value();
|
---|
| 80 | return false;
|
---|
| 81 | } else {
|
---|
| 82 | return true;
|
---|
| 83 | }
|
---|
[7] | 84 | }
|
---|
| 85 |
|
---|
| 86 | } // end namespace filter
|
---|
| 87 | } // end namespace flair
|
---|