• 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

  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Product
    • Design UI
    • Develop
    • Analyze and test
    • Deploy
    • Framework and toolbox
    • Compatibility
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - Simulator
  • SimSignal
  • 4.11.14

SimSignal Class

(CDPSim::SimSignal)

The SimSignal is a light-weight version of CDPSignal optimized for CDP Simulator needs More...

Header: #include <DynamicSimComponent/SimSignal.h>
Inherits: CDP::StudioAPI::CDPNode
  • List of all members, including inherited members

Public Functions

SimSignal()
virtual void Configure(XMLElementEx *pSignalXML, bool isStateVariableSimSignal = false)
virtual void Create(const char *name, DynamicSimComponent *componentOwner, ICDPNode *nodeOwner = nullptr, bool isStateVariableSimSignal = false)
virtual void Create(const char *name, SimPort *owner)
virtual double *GetRoutedValuePointer() const
virtual std::string GetRouting() const
virtual std::string GetRoutingResolvedToFullName() const
virtual double GetValue() const
virtual double *GetValuePointer() const
virtual bool HasRouting() const
virtual bool IsInput() const
virtual void SetPropertyValue()
virtual void SetUpdatePropValueAfterSimRoutedValueIsUpdated(bool shouldUpdate)
virtual void SetValuePointer(double *value)
virtual void UpdateValueFromConfiguration()
virtual operator double() const
virtual SimSignal &operator*=(double rhs)
virtual SimSignal &operator+=(double rhs)
virtual SimSignal &operator-=(double rhs)
virtual SimSignal &operator/=(double rhs)
virtual SimSignal &operator=(const SimSignal &rhs)
virtual SimSignal &operator=(double rhs)

Reimplemented Public Functions

virtual void FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const override
virtual const std::string GetNodeName() const override
virtual std::string GetNodeTypeName() const override
virtual CDP::StudioAPI::CDPValueType GetNodeValueType() const override
virtual CDP::StudioAPI::CDPVariantValue GetVariantValue() const override
virtual void SetVariantValue(const CDP::StudioAPI::CDPVariantValue &value) override
  • 26 public functions inherited from CDP::StudioAPI::CDPNode
  • 22 public functions inherited from CDP::StudioAPI::ICDPNode

Additional Inherited Members

  • 1 protected function inherited from CDP::StudioAPI::CDPNode

Detailed Description

The SimSignal is a light-weight version of CDPSignal optimized for CDP Simulator needs

Description

Simulator components are often run with much higher frequency than regular CDP components to more accurately simulate real world processes using differential equations. To make this possible, a more lightweight version of CDPSignal was created.

SimSignal provides similar functionality to CDPSignal, including:

  • Ability to route values from other CDP objects.
  • Provides Value together with Unit and Description.

However, to make SimSignal more lightweight, there are following differences:

  • SimSignal has an internal value used for high performance calculations. Unlike CDPSignal, the value is only "published" to CDP routing system periodically, decided by the fs property of SimulatorManager.
  • There is no support for CDPOperators.
  • When one SimSignal routes another SimSignal or StateVariable in the same application, then the CDP routing system is bypassed and direct pointer to internal value is passed. In this way, routed values are updated every TimeStep (property of SimulatorManager). When CDP routing is used between CDPSignal and SimSignal/StateVariable, values are updated every ts (which is equal to 1/fs) of SimulatorManager.
  • SimSignal can only be added to a component inheriting from DynamicSimComponent.

Usage

SimSignal must be created in DynamicSimComponent C++ code but it will read configuration at startup.

Code

In the class declaration:

CDPSim::SimSignal a;

In the implementation file: In Create(...):

a.Create("a", this);

In EvaluateDiffEquations(...):

v.ddt = a; // Use as regular variable.

Configuration

Following properties can be used to configure a SimSignal instance.

PropertyDescription
ValueValue of the SimSignal.
UnitThe unit or dimension of the SimSignal Value, like 'kg' or 'm/s^2'. This can be anything as long as it is consistent. There is no automatic unit-conversion.
InputWhen true, the SimSignal will pull its value from a remote object specified by Routing attribute. When false, the SimSignal should be used to publish some internal calculation result of simulator, this makes the value visible to other CDP objects.
RoutingSpecifies remote CDP object where SimSignal pulls its value. Only valid if Input is set to true.
DescriptionUsed to explain the purpose of a SimSignal instance.

Member Function Documentation

SimSignal::SimSignal()

Default constructs an instance of SimSignal.

[virtual] void SimSignal::Configure(XMLElementEx *pSignalXML, bool isStateVariableSimSignal = false)

Reads configuration from XML. Called automatically by parent.

[virtual] void SimSignal::Create(const char *name, DynamicSimComponent *componentOwner, ICDPNode *nodeOwner = nullptr, bool isStateVariableSimSignal = false)

Creates the instance, binds it to name and registers to componentOwner.

[virtual] void SimSignal::Create(const char *name, SimPort *owner)

Creates the instance, binds it to name and registers to owner.

[override virtual] void SimSignal::FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const

Reimplemented from CDPNode::FillNodeChildren().

Exposes child nodes of this node to StudioAPI.

[override virtual] const std::string SimSignal::GetNodeName() const

Reimplemented from ICDPNode::GetNodeName().

Returns node's unique name.

[override virtual] std::string SimSignal::GetNodeTypeName() const

Reimplemented from ICDPNode::GetNodeTypeName().

Returns node's model name.

[override virtual] CDP::StudioAPI::CDPValueType SimSignal::GetNodeValueType() const

Reimplemented from ICDPNode::GetNodeValueType().

Returns node's value type which is double.

[virtual] double *SimSignal::GetRoutedValuePointer() const

Returns pointer to where this node gets routed values from. May return nullptr.

[virtual] std::string SimSignal::GetRouting() const

Returns Routing set to this SimSignal.

Might be absolute or relative Routing.

See also GetRoutingResolvedToFullName().

[virtual] std::string SimSignal::GetRoutingResolvedToFullName() const

Returns Routing set to this SimSignal. Relative Routing is converted to absolute.

See also GetRouting().

[virtual] double SimSignal::GetValue() const

Returns node's value.

[virtual] double *SimSignal::GetValuePointer() const

Returns pointer to node's value.

[override virtual] CDP::StudioAPI::CDPVariantValue SimSignal::GetVariantValue() const

Reimplemented from ICDPNode::GetVariantValue().

Returns node's value.

[virtual] bool SimSignal::HasRouting() const

Returns true if the SimSignal has Routing set.

Routed SimSignals can be used to retrieve values from other CDP objects to use in a simulator component.

[virtual] bool SimSignal::IsInput() const

Returns true if the SimSignal has Input flag set.

Input signals are allowed to contain Routings. Therefore they can be used to retrieve values from other CDP objects to use in a simulator component.

[virtual] void SimSignal::SetPropertyValue()

Publishes internal value to a CDPProperty that can be routed by other objects in CDP system.

[virtual] void SimSignal::SetUpdatePropValueAfterSimRoutedValueIsUpdated(bool shouldUpdate)

Sets a flag which decides if m_pValue-property should be updated after the internal sim-routed value has been updated

[virtual] void SimSignal::SetValuePointer(double *value)

Set location of internal value that will be used and updated by SimSignal.

[override virtual] void SimSignal::SetVariantValue(const CDP::StudioAPI::CDPVariantValue &value)

Reimplemented from CDPNode::SetVariantValue().

Sets node's value.

[virtual] void SimSignal::UpdateValueFromConfiguration()

Resets value to initial value read from configuration.

[virtual] SimSignal::operator double() const

Returns node's value. Same as GetValue()

[virtual] SimSignal &SimSignal::operator*=(double rhs)

Multiples internal value by rhs.

[virtual] SimSignal &SimSignal::operator+=(double rhs)

Adds rhs to internal value.

[virtual] SimSignal &SimSignal::operator-=(double rhs)

Subtracts rhs from internal value.

[virtual] SimSignal &SimSignal::operator/=(double rhs)

Divedes internal value by rhs.

[virtual] SimSignal &SimSignal::operator=(const SimSignal &rhs)

Assigns rhs to internal value.

[virtual] SimSignal &SimSignal::operator=(double rhs)

Assigns rhs to internal value.

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

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

    © Copyright 2022 CDP Technologies. Privacy and cookie policy.

    Return to top