SimSignal Class
(CDPSim::SimSignal)The SimSignal is a light-weight version of CDPSignal optimized for CDP Simulator needs. More...
Header: | #include <SimSignal> |
Inherits: | CDP::StudioAPI::CDPNode |
Public Functions
SimSignal() | |
virtual void | ClockInPropertyValue() |
virtual void | ClockOutPropertyValue() |
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 IPortConnection::ConnectFlag | GetConnectFlags() const |
virtual std::string | GetRemoteName() const |
virtual double * | GetRoutedValuePointer() const |
virtual std::string | GetRouting() const |
virtual std::string | GetRoutingResolvedToFullName() const |
virtual std::string | GetRoutingStatusString() const |
virtual double | GetValue() const |
virtual double * | GetValuePointer() const |
virtual bool | HasRouting() const |
virtual bool | IsInput() const |
virtual bool | IsMandatory() const |
virtual void | SetPortConnectionPropertiesChangeHandler(const std::function<void( CDPPropertyBase * ) > &handler) |
virtual void | SetPropertyValue() |
virtual void | SetUpdatePropValueAfterSimRoutedValueIsUpdated(bool shouldUpdate) |
virtual void | SetValuePointer(double *value) |
virtual void | UpdateValueFromConfiguration() |
virtual void | UpdateValueFromSimRoutedValue() |
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 |
- 27 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.
- 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 (including the SimComponent meant for no-code simulation models).
Usage
The SimSignal can either be created in DynamicSimComponent C++ code or just dragged into any DynamicSimComponent or SimComponent from the CDP Studio Configure mode Resource tree. The latter can be useful to forward values between different simulator components or to create no-code logic in the SimComponent.
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.
Property | Description |
---|---|
Value | Value of the SimSignal. |
Unit | The 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. |
Input | When 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. |
Routing | Specifies remote CDP object where SimSignal pulls its value. |
Description | Used to explain the purpose of a SimSignal instance. |
Member Function Documentation
SimSignal::SimSignal()
Default constructs an instance of SimSignal.
[virtual]
void SimSignal::ClockInPropertyValue()
Called automatically by the framework every time step. For SimSignals routed from properties, this syncs the property value into the SimSignal.
[virtual]
void SimSignal::ClockOutPropertyValue()
Called automatically by the framework every time step. For SimSignals and StateVariables this publishes their current value to the operators routing from them.
[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.
[virtual]
IPortConnection::ConnectFlag SimSignal::GetConnectFlags() const
The port connection Upstream/Downstream connectivity flags (this method available only for SimSignals added into a SimPort).
Editing the connectivity flags is normally not needed unless partially taking values from port chain for processing and re-adding them later. Downstream flag can be cleared to prevent connection from being queried from routed port API-s. Upstream flag can be cleared to hide connection from this port API.
[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]
std::string SimSignal::GetRemoteName() const
RemoteName of the port connection (this method available only for SimSignals added into a SimPort).
Returns the RemoteName of the port connection - the name (or relative routing) of the remote object to connect to. If empty, it will automatically be set equal to Name - this allows easy connect when name is same on both local and remote side.
[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]
std::string SimSignal::GetRoutingStatusString() const
Shows whether connecting to the node specified by the Routing property was successful.
Valid values are: "Invalid Routing", "Routed", "No Routing".
[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.
[virtual]
bool SimSignal::IsMandatory() const
Indicates if connecting this SimSignal is mandatory for the SimPort to report itself Connected (this method is available only for SimSignals added into a SimPort).
[virtual]
void SimSignal::SetPortConnectionPropertiesChangeHandler(const std::function<void( CDPPropertyBase * ) > &handler)
Sets listener for the SimPort connection properties: RemoteName, Connect and Mandatory (this method available only for SimSignals added into a SimPort).
Called when any of the properties change. Note, each change will trigger a port reconnect sequence. For bulk modifications first call Disconnect() on the SimPort, then do modifications and finally call Reconnect() on the SimPort.
[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]
void SimSignal::UpdateValueFromSimRoutedValue()
Called automatically by the framework every time step. For input SimSignals routed from StateVariables or other SimSignals, this syncs the remote value into the SimSignal.
[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.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.