• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - Simulator
  • SimPort
  • 5.0.0

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
  • List of all members, including inherited members

Reimplemented Public Functions

virtual void Configure(XMLElementEx *xml) override
virtual void FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const override
  • 30 public functions inherited from CDPPort
  • 39 public functions inherited from CDPObject
  • 49 public functions inherited from CDPBaseObject
  • 27 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
  • 15 protected functions inherited from CDPObject
  • 1 protected function inherited from CDP::StudioAPI::CDPNode

Additional Inherited Members

  • 30 public functions inherited from CDPPort
  • 39 public functions inherited from CDPObject
  • 49 public functions inherited from CDPBaseObject
  • 27 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
  • 15 protected functions inherited from CDPObject
  • 1 protected function inherited from CDP::StudioAPI::CDPNode
  • 9 protected variables inherited from CDPObject
  • 10 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.

Properties

The following properties are available for the SimPort:

PropertyDescription
InputSet true if the port is an input (routed). In Block Diagram, this will make the port appear on the left side of a block.
RoutingPath of a CDPNode this port communicates with - usually another SimPort.
ConnectedTrue if the port is communicating with a remote object and every SimSignal having the Mandatory property checked is connected.
DataConsistencyUsed only when connecting ports between different CDP applications. When enabled, values connected by this port are sent within the same data packet, meaning that a group of remote values always appears consistent. Otherwise when multiple values change, they may appear for a remote application in wrong order or one change might be delayed a little. This option can only be enabled when the port only connects values with periodic routing (not event-based).

PortSimSignal

A PortSimSignal is a CDPSim::SimSignal added to a SimPort. For that purpose, it includes a few additional properties compared to a regular CDPSim::SimSignal that allows customizing the connection options.

The following properties are available for the PortSimSignal:

PropertyDescription
InputSets the data flow direction. If false, data is sent from the source component to the target component. If true, data is sent from the target component to the source component.
RemoteNameA value within the remote object this signal will be connected by the parent SimPort. If empty, it will automatically be set equal to the SimSignal Name - this allows easy connect when the name is same on both local and remote side.
ConnectConnectivity flags (D - Downstream or U - Upstream) - normally not needed unless partially taking values from port chain for processing and re-adding them later. Downstream flag can be cleared to prevent the connection from being queried from routed port API-s. Upstream flag can be cleared to hide the connection from this port API.
MandatoryIndicates if this connection is mandatory to be connected for the Port to report overall successful Connected status.

Usage

The SimPort can be used in two ways:

  • As a code port meant to be used in C++ code by a DynamicSimComponent
  • As a configuration-only port meant to help structure the project and to make use of CDPOperators creating some simple no-code logic.

This class documentation describes the code port use case. For the configuration-only use case, see the SimPort Configuration Manual.

Note: Using SimPort with SimSignals instead of regular CDPPorts allows for faster data propagation within simulator components in the same application. See the Time Steps and Data Propagation section in the introduction manual for more information.

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.
  • 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.

Note: Unlike a regular CDPPort, it is not necessary to add mappings to the Connections table. The options like RemoteName, Connect and Mandatory are configured directly on the SimSignal.

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
}

Properties

The following properties are available for the SimPort:

PropertyDescription
InputSet true if the port is an input (routed). In Block Diagram, this will make the port appear on the left side of a block.
RoutingPath of a CDPNode this port communicates with - usually another SimPort.
ConnectedTrue if the port is communicating with a remote object and every SimSignal having the Mandatory property checked is connected.
DataConsistencyUsed only when connecting ports between different CDP applications. When enabled, values connected by this port are sent within the same data packet, meaning that a group of remote values always appears consistent. Otherwise when multiple values change, they may appear for a remote application in wrong order or one change might be delayed a little. This option can only be enabled when the port only connects values with periodic routing (not event-based).

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.

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top