• 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
    • CDP Linux
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - CDP Core
  • CDPParameter
  • 5.1.0

CDPParameter Class

The CDPParameter class is used for persistent values (parameters) that seldom change. More...

Header: #include <CDPParameter>
Inherits: ValueNode<CDPObject>
Inherited By:

CDPParameterTimer and CDPParameterTimerMs

  • List of all members, including inherited members

Public Functions

CDPParameter()
virtual ~CDPParameter()
void Configure(const char *xml) override
void Configure(XMLElementEx *pParameterElement) override
virtual void ConnectTo(const char *pzRemotePropertyName)
void Create(const char *name, CDPComponent *pParent) override
void Destroy() override
virtual void Disconnect()
virtual const char *GetRouting() const
virtual CDPPropertyBase::RoutingStatus_e GetRoutingStatus() const
virtual bool IsReadyToActivate() override
double PreviousValue() const
void Save()
void SetProperty(std::string propertyName, std::string propertyValue) override
void SetPropertyHandler(CDPPropertyBase *pProp) override
virtual void SetValue(double newValue)
void SetVariantValue(const CDP::StudioAPI::CDPVariantValue &value) override
const std::string &Unit() const
bool ValidatePropertyHandler(CDP::StudioAPI::CDPVariantValue &newValue, CDPPropertyBase *property) override
double Value() const
operator double() const
CDPParameter &operator=(int newValue)
CDPParameter &operator=(float newValue)
CDPParameter &operator=(double newValue)
CDPParameter &operator=(const CDPParameter &p)
CDPParameter &operator=(const CDPPropertyBase &p)
  • 9 public functions inherited from ValueNode
  • 8 public functions inherited from CDP::StudioAPI::AbstractValueListener

Detailed Description

The CDPParameter class is used for persistent values (parameters) that seldom change.

CDPParmeters are typically set by a service-engineer on system commisioning, or occasionally, from code. Whenever something in a CDPParameter changes, it is automatically saved to the configuration file (typically the parent Component file).

The CDPParameter reads its value from the configuration on startup, effectively restoring the value that was last set.

Note: If you use CDPParameters for values that change frequently, be aware that each change to the CDPParameter causes a full rewrite of the configuration file of the CDPComponent that the CDPParameter is a member of.

To use a CDPParameter from code, go into your model in Configure mode (or Code mode) and add a CDPParameter to your model. Now the parameter can be used as a normal C++ variable (double).

It is possible to set a minimum (Min) and/or maximum (Max) value that a parameter can have; this limit is enforced whenever the CDPParameter Value is changed. If Min is changed to a value greater than the current Value, then the current Value is adjusted to the Min value. If Max is changed to a value less than the current Value, then the current Value is adjusted to the Max value.

To test if CDPParameter Mode is less than 1:

if (Mode<1)
  HandleMode0AndBelow();

To assign a value to Mode:

Mode = 1.0;

To get the previous value of Mode:

double prev = Mode.PreviousValue();

To get the time last changed and compare it with now-time:

double parameterTime = CDPTime::ConvertGivenTimeToDouble(Mode.GetProperty("TimeLastChanged").c_str(),true,CDP_UNIX_No_Ms);
if((CDPTime::GlobalClock()-parameterTime)<2.0)
  ParameterWasModifiedLessThanTwoSecondsAgo();

CDPParameters can route their property Value from other CDPProperties in the system. The Routing is typically set in the configuration, but can also be set using SetRouting(). Note that the Routing is the path to a CDPProperty, and that even when a CDPParameter is Routed, the Min/Max value limiting is still in effect.

if(condition1())
  Mode.SetProperty("Routing",m_strAlternateRouting);
else
  Mode.SetProperty("Routing",""); // no routing

Note: Any change of Routing, Value, Unit, Description, etc. will cause the CDPParameter configuration to be saved (in the parent CDPComponent file). Excessive writes (depending on hardware) may impact application performance.

Properties

Property nameDescription
UnitParameter value unit as presented in CDP Studio, such as 'kg', 'm', 'm/s'.
ValueParameter value, limited by Min and Max.
MinMinimum value limit. If Min is changed to a value greater than the current Value, then the current Value is adjusted to the Min value.
MaxMaximum value limit. If Max is changed to a value less than the current Value, then the current Value is adjusted to the Max value.
PreviousValueValue before last change.
TimeLastChangedTime when parameter was last changed, format 'day DD mon YYYY HH_MM_SS', as 'Sat 31 Jun 2004 23:10:00'.
RoutingRouting from where the parameter gets its value.

Member Function Documentation

CDPParameter::CDPParameter()

Constructs a CDPParameter.

[virtual] CDPParameter::~CDPParameter()

Destructs the instance.

void CDPParameter::Configure(const char *xml)

Reads parameter value from .xml buffer. Called from owner (parent) Configure(...).

void CDPParameter::Configure(XMLElementEx *pParameterElement)

Reads the parameter configuration and sets up the configured Min and Max limits for the parameter

If Min and Max are equal, Minimum and maximum limits are not enforced.

[virtual] void CDPParameter::ConnectTo(const char *pzRemotePropertyName)

Connects the value property to get values from a remote property

void CDPParameter::Create(const char *name, CDPComponent *pParent)

Creates parameter instance.

void CDPParameter::Destroy()

Does pre-destructor stuff, like signaling to other objects that the component is about to die.

This method should reverse what whas done in Create().

[virtual] void CDPParameter::Disconnect()

Disconnects the value property

[virtual] const char *CDPParameter::GetRouting() const

Returns the current routing of the value property

[virtual] CDPPropertyBase::RoutingStatus_e CDPParameter::GetRoutingStatus() const

Returns the routing status of the value property

[override virtual] bool CDPParameter::IsReadyToActivate()

double CDPParameter::PreviousValue() const

Returns the previous value.

void CDPParameter::Save()

Saves parameter value by doing a blocking call to the parent component to make it save the file.

Note: This function can potentially block for several seconds.

void CDPParameter::SetProperty(std::string propertyName, std::string propertyValue)

Sets a property of the object.

Called by MessageSetProperty after property name and value has been figured out.

void CDPParameter::SetPropertyHandler(CDPPropertyBase *pProp)

This is called whenever one of the following properties changes: value, routing, minLimit, maxLimit.

[virtual] void CDPParameter::SetValue(double newValue)

Sets new value.

Preferrably use the assignment operators below when setting value. Override this method to add custom functinality when parameter is changed.

void CDPParameter::SetVariantValue(const CDP::StudioAPI::CDPVariantValue &value)

Sets new value to the parameter.

const std::string &CDPParameter::Unit() const

Returns the unit of the parameter.

bool CDPParameter::ValidatePropertyHandler(CDP::StudioAPI::CDPVariantValue &newValue, CDPPropertyBase *property)

Makes sure that the newValue does not go outside the value limits set by Min and Max, and only allow change if the value actually changes.

double CDPParameter::Value() const

Returns the value of the property.

CDPParameter::operator double() const

Returns the current value of the parameter

CDPParameter &CDPParameter::operator=(int newValue)

Assigns new value to parameter and sets save flag if value is changed.

CDPParameter &CDPParameter::operator=(float newValue)

Assigns new value to parameter and sets save flag if value is changed.

CDPParameter &CDPParameter::operator=(double newValue)

Assigns new value to parameter and sets save flag if value is changed.

CDPParameter &CDPParameter::operator=(const CDPParameter &p)

Assigns new value to parameter and sets save flag if value is changed.

CDPParameter &CDPParameter::operator=(const CDPPropertyBase &p)

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 2026 CDP Technologies. Privacy and cookie policy.

Return to top