AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
ControllerHandler.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
21#include <agxModel/export.h>
22
23
24namespace agxModel {
25
27
33 {
34 public:
44 class AGXMODEL_EXPORT Plant : public virtual agx::Referenced
45 {
46 public:
47 Plant() = default;
48
50 Plant(std::function<agx::Real(const agx::TimeStamp&)> getProcessVariable, std::function<void(agx::Real)>setManipulatedVariable)
51 {
52 m_getProcessVariable = getProcessVariable;
53 m_setManipulatedVariable = setManipulatedVariable;
54 };
55
57 virtual agx::Real getProcessVariable(const agx::TimeStamp& time) { return m_getProcessVariable ? m_getProcessVariable(time) : 0; };
58
63 virtual void setManipulatedVariable(agx::Real manipulatedVariable) { if (m_setManipulatedVariable) m_setManipulatedVariable(manipulatedVariable); };
64
65 private:
66 std::function<agx::Real(const agx::TimeStamp&)> m_getProcessVariable;
67 std::function<void(agx::Real)> m_setManipulatedVariable;
68 };
69
70 public:
71
72 ControllerHandler(Controller1D* controller, Plant* plant);
73
75
77
83 virtual void post(const agx::TimeStamp& time) override;
84
85 private:
86 Controller1DRef m_controller;
87 PlantRef m_plant;
88
89 };
90
91}
92
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXMODEL_EXPORT
A simple base class for a controller with a set point and an out signal.
The Plant (aka the Physical System) is added to the ControllHandler in the Control System.
virtual agx::Real getProcessVariable(const agx::TimeStamp &time)
virtual void setManipulatedVariable(agx::Real manipulatedVariable)
Set the Manipulated Variable(MV) controlling the Plant, also known as Control Variable.
Plant(std::function< agx::Real(const agx::TimeStamp &)> getProcessVariable, std::function< void(agx::Real)>setManipulatedVariable)
Create a plant.
This is a PID handler that collects the Plant measured Process Variable (PV) and execute PID update()...
virtual void post(const agx::TimeStamp &time) override
Read Plant measured Process Variable (PV) and execute PID update to get an updated Manipulated Variab...
ControllerHandler(Controller1D *controller, Plant *plant)
PlantRef getPlant() const
Controller1DRef getController() const
Derive from this class to implement a listener for simulation step events.
Base class providing referencing counted objects.
Definition Referenced.h:120
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition FlowUnit.h:37
double Real
Definition Real.h:42
agx::Real TimeStamp
Definition TimeStamp.h:26