M1M3 Support System
Loading...
Searching...
No Matches
PID.h
1/*
2 * This file is part of LSST M1M3 support system package.
3 *
4 * Developed for the Vera C. Rubin Telescope and Site System.
5 * This product includes software developed by the LSST Project
6 * (https://www.lsst.org).
7 * See the COPYRIGHT file at the top-level directory of this distribution
8 * for details of code ownership.
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#ifndef PID_H_
25#define PID_H_
26
27#include <atomic>
28
29#include <SAL_MTM1M3C.h>
30
31#include <M1M3SSPublisher.h>
32#include <PIDParameters.h>
33
34namespace LSST {
35namespace M1M3 {
36namespace SS {
37
50class PID {
51public:
59 PID(int id, PIDParameters parameters);
60
64 void updateParameters(PIDParameters parameters);
65 void restoreInitialParameters();
66 void resetPreviousValues();
67
71 double process(double setpoint, double measurement);
72
76 void freeze();
77
81 void thaw() { _frozen = false; }
82
83 double getOffset(bool *changed);
84
85 void publishTelemetry();
86
87private:
88 int _id;
89
90 //* initial parameters passed in constructor
91 PIDParameters _initialParameters;
92 MTM1M3_logevent_pidInfoC *_pidInfo;
93 MTM1M3_pidDataC *_pidData;
94
95 void _calculateIntermediateValues();
96 void _publishInfo();
97
98 std::atomic_bool _frozen;
99 double _offset;
100};
101
102} /* namespace SS */
103} /* namespace M1M3 */
104} /* namespace LSST */
105
106#endif /* PID_H_ */
Implements PID discrete time controller.
Definition PID.h:50
void thaw()
Remove PID freeze flag.
Definition PID.h:81
double process(double setpoint, double measurement)
Run PID calculations, produce output.
Definition PID.cpp:69
PID(int id, PIDParameters parameters)
Constructs PID.
Definition PID.cpp:30
void updateParameters(PIDParameters parameters)
Update PID parameters.
Definition PID.cpp:39
void freeze()
Keep constant PID output.
Definition PID.cpp:91
Parameters for PID calculations.
Definition PIDParameters.h:36