SimPort Class
(CDPSim::SimPort)The SimPort is a CDPPort which is able to aggregate SimSignals. It can only be added to simulator components. To use it, inherit your class from SimPort and add some SimSignals. More...
Header: | #include <DynamicSimComponent/SimPort.h> |
Inherits: | CDPPort |
Reimplemented Public Functions
virtual void | Configure(XMLElementEx *xml) override |
virtual void | FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const override |
- 25 public functions inherited from CDPPort
- 37 public functions inherited from CDPObject
- 46 public functions inherited from CDPBaseObject
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
Reimplemented Protected Functions
virtual bool | HasNamedValueChild(const std::string &name) override |
virtual bool | IsInputConnection(XMLElementEx *connection) override |
- 5 protected functions inherited from CDPPort
- 13 protected functions inherited from CDPObject
- 1 protected function inherited from CDP::StudioAPI::CDPNode
Additional Inherited Members
- 25 public functions inherited from CDPPort
- 37 public functions inherited from CDPObject
- 46 public functions inherited from CDPBaseObject
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
- 6 static public members inherited from CDPObject
- 1 static public member inherited from CDPBaseObject
- 5 protected functions inherited from CDPPort
- 13 protected functions inherited from CDPObject
- 1 protected function inherited from CDP::StudioAPI::CDPNode
- 9 protected variables inherited from CDPObject
- 11 protected variables inherited from CDPBaseObject
Detailed Description
The SimPort is a CDPPort which is able to aggregate SimSignals. It can only be added to simulator components. To use it, inherit your class from SimPort and add some SimSignals.
Description
The SimPort is used to aggregate multiple SimSignals into a single data structure that can be connected to another SimPort by setting a single Routing. The port allows two-way connection, for that each SimSignal must specify whether they are inputs or outputs of the port.
Usage
To use SimPort:
- Create a new class and make it inherit from SimPort.
- Add your SimSignals and register them by calling SimSignal::Create.
- Make sure the SimSignals have been added to SimPort model in Configure mode and also listed as CDPPort Connections.
- Make sure the Input flag of every SimSignal is correctly set for each input and output signal.
- Build the library and use the SimPort from simulator component code as a regular CDPPort is used.
Code
In the class header:
#include <CDPSim/DynamicSimComponent/SimPort.h> namespace SimLib { class MySimPort : public CDPSim::SimPort { public: void Create(const char* shortName, CDPComponent* parent) override; CDPSim::SimSignal MySignal; }; }
In the implementation file:
#include "MySimPort.h" using namespace SimLib; void MySimPort::Create(const char* shortName, CDPComponent* parent) { CDPPort::Create(shortName, parent); // Always call base MySignal.Create("MySignal", this); }
To use the created MySimPort, add it to your simulator component.
class MySimComponent : public CDPSim::DynamicSimComponent { ... SimLib::MySimPort Port; }; void MySimComponent::Create(const char* fullName) { CDPSim::DynamicSimComponent::Create(fullName); // Always call base class. Port.Create("Port", this); } void MySimComponent::EvaluateDiffEquations(double t) { // Use Port.MySignal in your calculations }
Member Function Documentation
[override virtual]
void SimPort::Configure(XMLElementEx *xml)
Reimplemented from CDPObject::Configure().
[override virtual]
void SimPort::FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const
Reimplemented from CDPNode::FillNodeChildren().
Exposes child nodes of this node to StudioAPI.
[override virtual protected]
bool SimPort::HasNamedValueChild(const std::string &name)
Reimplemented from CDPPort::HasNamedValueChild().
[override virtual protected]
bool SimPort::IsInputConnection(XMLElementEx *connection)
Reimplemented from CDPPort::IsInputConnection().
Override to programmatically determine whether a Connection is input or output.
Base implementation matches Connection input with relevant SimSignal input.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.