AGX Dynamics  2.35.0.1
ControllerHandler.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
20 #include <agxModel/Controller1D.h>
21 #include <agxModel/export.h>
22 
23 
24 namespace 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 
76  PlantRef getPlant() const;
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:248
#define AGXMODEL_EXPORT
A simple base class for a controller with a set point and an out signal.
Definition: Controller1D.h:36
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:114
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