1 | // created: 2013/06/26
|
---|
2 | // filename: Sinus.h
|
---|
3 | //
|
---|
4 | // author: Guillaume Sanahuja
|
---|
5 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
6 | //
|
---|
7 | // version: $Id: $
|
---|
8 | //
|
---|
9 | // purpose: class generating a sinus signal
|
---|
10 | //
|
---|
11 | //
|
---|
12 | /*********************************************************************/
|
---|
13 |
|
---|
14 | #ifndef SINUS_H
|
---|
15 | #define SINUS_H
|
---|
16 |
|
---|
17 | // necessary includes, as IODevice and Thread are bases of our class
|
---|
18 | #include <IODevice.h>
|
---|
19 | #include <Thread.h>
|
---|
20 |
|
---|
21 | // forward declaration for other classes
|
---|
22 | namespace flair {
|
---|
23 | namespace core {
|
---|
24 | class FrameworkManager;
|
---|
25 | class Matrix;
|
---|
26 | }
|
---|
27 | namespace gui {
|
---|
28 | class Tab;
|
---|
29 | class TabWidget;
|
---|
30 | class GridLayout;
|
---|
31 | class DoubleSpinBox;
|
---|
32 | class SpinBox;
|
---|
33 | class DataPlot1D;
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | // sinus is a class generating a sinus signal
|
---|
38 | // in this example, it emulates a sensonr, so we extend the namespace sensor
|
---|
39 | // it derives frome
|
---|
40 | // IODevice: as it has an ouput
|
---|
41 | // Thread: is it a thread
|
---|
42 | namespace flair {
|
---|
43 | namespace sensor {
|
---|
44 | class Sinus : public core::IODevice, public core::Thread {
|
---|
45 | public:
|
---|
46 | /*!
|
---|
47 | * \brief Constructor
|
---|
48 | *
|
---|
49 | * Builds a sinus generator
|
---|
50 | *
|
---|
51 | * \param parent the FrameworkManager to use
|
---|
52 | * \param name object name
|
---|
53 | * \param priority Thread priority, 50 by default (1:mini, 99:maxi)
|
---|
54 | */
|
---|
55 | Sinus(const core::FrameworkManager *parent, std::string name,
|
---|
56 | int priority = 50);
|
---|
57 |
|
---|
58 | /*!
|
---|
59 | * \brief Destructor
|
---|
60 | */
|
---|
61 | ~Sinus();
|
---|
62 |
|
---|
63 | /*!
|
---|
64 | * \brief Output matrix
|
---|
65 | *
|
---|
66 | * allows to access output matrix, to get signal value or to put it in a graph.
|
---|
67 | *\n
|
---|
68 | *
|
---|
69 | * \return un pointeur vers la matrice de sortie
|
---|
70 | */
|
---|
71 | core::Matrix *GetMatrix(void) const;
|
---|
72 |
|
---|
73 | /*!
|
---|
74 | * \brief Value
|
---|
75 | *
|
---|
76 | * this method is equivalent to GetMatrix()->Value(0,0)
|
---|
77 | *
|
---|
78 | * \return actual signal value
|
---|
79 | */
|
---|
80 | float GetValue(void) const;
|
---|
81 |
|
---|
82 | /*!
|
---|
83 | * \brief Use defautl plot
|
---|
84 | *
|
---|
85 | * this method put a graph in a specific tab
|
---|
86 | *
|
---|
87 | */
|
---|
88 | void UseDefaultPlot(void);
|
---|
89 |
|
---|
90 | /*!
|
---|
91 | * \brief SetupLayout
|
---|
92 | *
|
---|
93 | * this method allows to add other widgets in the sinus tab.
|
---|
94 | *
|
---|
95 | * \return the GridLayout
|
---|
96 | */
|
---|
97 | gui::GridLayout *GetSetupLayout(void) const;
|
---|
98 |
|
---|
99 | /*!
|
---|
100 | * \brief Plot
|
---|
101 | *
|
---|
102 | * this method allows to add other curves in the graph
|
---|
103 | *
|
---|
104 | * \return the DataPlot1D
|
---|
105 | */
|
---|
106 | gui::DataPlot1D *GetPlot(void) const;
|
---|
107 |
|
---|
108 | private:
|
---|
109 | // UpdateFrom method from base class IODevice
|
---|
110 | // sinus is like a sensor, so it does not have input; we define an empty
|
---|
111 | // method
|
---|
112 | void UpdateFrom(const core::io_data *data){};
|
---|
113 | void Run(void);
|
---|
114 |
|
---|
115 | core::Matrix *output;
|
---|
116 | gui::Tab *mainTab;
|
---|
117 | gui::TabWidget *tabWidget;
|
---|
118 | gui::DataPlot1D *plot;
|
---|
119 | gui::DoubleSpinBox *frequency, *amplitude, *offset;
|
---|
120 | gui::SpinBox *period;
|
---|
121 | gui::GridLayout *setupLayout;
|
---|
122 | };
|
---|
123 | } // end namespace sensor
|
---|
124 | } // end namespace flair
|
---|
125 | #endif // SINUS_H
|
---|