[215] | 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: 2018/02/08
|
---|
| 6 | // filename: PressureSensor.cpp
|
---|
| 7 | //
|
---|
| 8 | // author: Guillaume Sanahuja
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
| 13 | // purpose: Base class for PressureSensor
|
---|
| 14 | //
|
---|
| 15 | //
|
---|
| 16 | /*********************************************************************/
|
---|
| 17 |
|
---|
| 18 | #include "PressureSensor.h"
|
---|
| 19 | #include <FrameworkManager.h>
|
---|
| 20 | #include <Tab.h>
|
---|
| 21 | #include <TabWidget.h>
|
---|
| 22 | #include <GroupBox.h>
|
---|
| 23 | #include <Layout.h>
|
---|
| 24 | #include <DataPlot1D.h>
|
---|
| 25 | #include <Matrix.h>
|
---|
| 26 |
|
---|
| 27 | using std::string;
|
---|
| 28 | using namespace flair::core;
|
---|
| 29 | using namespace flair::gui;
|
---|
| 30 |
|
---|
| 31 | namespace flair {
|
---|
| 32 | namespace sensor {
|
---|
| 33 |
|
---|
| 34 | PressureSensor::PressureSensor(string name)
|
---|
| 35 | : IODevice(getFrameworkManager(), name) {
|
---|
| 36 | plot_tab = NULL;
|
---|
| 37 |
|
---|
| 38 | cvmatrix_descriptor *desc = new cvmatrix_descriptor(1, 1);
|
---|
| 39 | desc->SetElementName(0, 0, name);
|
---|
| 40 | output = new Matrix(this, desc, floatType);
|
---|
| 41 | delete desc;
|
---|
| 42 | AddDataToLog(output);
|
---|
| 43 |
|
---|
| 44 | main_tab = new Tab(getFrameworkManager()->GetTabWidget(), name);
|
---|
| 45 | tab = new TabWidget(main_tab->NewRow(), name);
|
---|
| 46 | sensor_tab = new Tab(tab, "Setup");
|
---|
| 47 | setup_groupbox = new GroupBox(sensor_tab->NewRow(), name);
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | PressureSensor::PressureSensor(const IODevice *parent, std::string name)
|
---|
| 51 | : IODevice(parent, name) {
|
---|
| 52 | plot_tab = NULL;
|
---|
| 53 | main_tab = NULL;
|
---|
| 54 | tab = NULL;
|
---|
| 55 | sensor_tab = NULL;
|
---|
| 56 | setup_groupbox = NULL;
|
---|
| 57 |
|
---|
| 58 | output = NULL;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | PressureSensor::~PressureSensor() {
|
---|
| 62 | if (main_tab != NULL)
|
---|
| 63 | delete main_tab;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | GroupBox *PressureSensor::GetGroupBox(void) const { return setup_groupbox; }
|
---|
| 67 |
|
---|
| 68 | Layout *PressureSensor::GetLayout(void) const { return sensor_tab; }
|
---|
| 69 |
|
---|
| 70 | DataPlot1D *PressureSensor::GetPlot(void) const { return plot; }
|
---|
| 71 |
|
---|
| 72 | Tab *PressureSensor::GetPlotTab(void) const { return plot_tab; }
|
---|
| 73 |
|
---|
| 74 | void PressureSensor::UseDefaultPlot(void) {
|
---|
| 75 | if (tab == NULL) {
|
---|
| 76 | Err("not applicable for simulation part.\n");
|
---|
| 77 | return;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | plot_tab = new Tab(tab, "Mesures");
|
---|
[216] | 81 | plot = new DataPlot1D(plot_tab->NewRow(), ObjectName(), 101000, 101500);
|
---|
[215] | 82 | plot->AddCurve(output->Element(0));
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | void PressureSensor::LockUserInterface(void) const {
|
---|
| 86 | setup_groupbox->setEnabled(false);
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | void PressureSensor::UnlockUserInterface(void) const {
|
---|
| 90 | setup_groupbox->setEnabled(true);
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | float PressureSensor::Value(void) const { return output->Value(0, 0); }
|
---|
| 94 |
|
---|
| 95 | } // end namespace sensor
|
---|
| 96 | } // end namespace flair
|
---|