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 <SimPort>
Inherits: CDPPort

Reimplemented Public Functions

virtual void Configure(XMLElementEx *xml) override
virtual void FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const override

Additional Inherited Members

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 connection must specify whether they are inputs or outputs of the port.

Usage

To use SimPort:

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.