• 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
  • CDPParameterTimer
  • 5.1.0

CDPParameterTimer Class

CDPTimer with timeout specified as CDPParameter parameter This object behaves as a CDPParameter and a CDPTimer at the same time. It should be used as a CDPTimer object except that the timeout value should be set in the configuration instead of being hardcoded. More...

Header: #include <CDPParameterTimer>
Inherits: CDPParameter
  • List of all members, including inherited members

Public Functions

CDPParameterTimer()
void Configure(const char *xml) override
void Configure(XMLElementEx *pParameterElement) override
void Create(const char *shortName, CDPComponent *pParent) override
double Delay()
double DeltaTime()
void Destroy() override
virtual void FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const override
double Frequency()
bool IsRunning()
double LastTime()
void Reset(double delay)
void Reset()
void Restart()
void Set()
virtual void Start()
bool State()
double TimeElapsed()
bool TimedOut()

Reimplemented Public Functions

virtual void SetValue(double newValue) override
  • 24 public functions inherited from CDPParameter
  • 9 public functions inherited from ValueNode
  • 8 public functions inherited from CDP::StudioAPI::AbstractValueListener

Detailed Description

CDPTimer with timeout specified as CDPParameter parameter This object behaves as a CDPParameter and a CDPTimer at the same time. It should be used as a CDPTimer object except that the timeout value should be set in the configuration instead of being hardcoded.

If the timer is used in a CDPComponent based class, the timer and it's values may show up in CDP Studio under the component's Timers section if Create() is called. In component's Create(), call myCDPParameterTimer.Create("MyCDPParameterTimer",this), and in component's Destroy(), call myCDPParameterTimer.Destroy().

Usage

Use as CDPTimer, but specify timeout in configuration as parameter.

The easiest way to add a CDPParameterTimer is to:

  • Add a CDPParameter using the CodeGenerator
  • Change the type in the header file from CDPParameter to CDPParameterTimer (and change the #include from CDPParameter.h to CDPParameterTimer.h)
  • Use the variable as a CDPTimer. The timeout value will be read from configuration.

Example

// In header file
CDPParameterTimer myCDPParameterTimer;

// In Create()
myCDPParameterTimer.Create("MyCDPParameterTimer", this);

// In end of Configure() or Activate()
myCDPParameterTimer.Restart();      // Will start timing from now

// In ProcessSomething()
if (myCDPParameterTimer.TimedOut())
{
  myCDPParameterTimer.Restart();    // Start new timing cycle
  CDPMessage("Will be written every time the period specified in the parameter times out.\n")
}

See also CDPTimer, CDPParameter, CDPTimerMs, CDPParameterTimerMs, OSAPIPeriodicTimer, OSAPIOneShotTimer, CDPTimerCounting, and CDPRampTimer.

Member Function Documentation

CDPParameterTimer::CDPParameterTimer()

Default constructs an instance of CDPParameterTimer.

void CDPParameterTimer::Configure(const char *xml)

Configures CDPParameter from an xml-string and sets up the timer.

void CDPParameterTimer::Configure(XMLElementEx *pParameterElement)

Configures CDPParameter from an xml element and sets up the timer.

void CDPParameterTimer::Create(const char *shortName, CDPComponent *pParent)

Calls CDPParameter::Create(), m_cTimer.Create() and sets up callback when m_timeoutDelay changes.

CDPParameter::Create() will be called with shortName, while m_cTimer.Create() will be called with shortName+"Timer" (to avoid same name for these objects).

double CDPParameterTimer::Delay()

Returns the delay set by Reset(delay)

double CDPParameterTimer::DeltaTime()

Returns time [s] between last two TimedOut() calls.

void CDPParameterTimer::Destroy()

Destroys the CDPParameter and timer instance.

[override virtual] void CDPParameterTimer::FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const

Writes its CDPSettings to stream.

double CDPParameterTimer::Frequency()

Returns frequency in Hz of time interval between last two TimedOut() calls (equals 1.0/DeltaTime()).

bool CDPParameterTimer::IsRunning()

Returns true if timer is running.

double CDPParameterTimer::LastTime()

Returns time [s] between last TimedOut() called and the first CDPTimer initialized.

void CDPParameterTimer::Reset(double delay)

Resets and sets specified delay timeout in seconds.

Stores the parameter-value and resets the timer.

void CDPParameterTimer::Reset()

Resets and sets delay timeout in seconds with value from CDPParameter.

Will call m_cTimer.Reset(Value()).

void CDPParameterTimer::Restart()

Resets and starts the timer with value from CDPParameter

void CDPParameterTimer::Set()

Sets the timeout flag state to true.

[override virtual] void CDPParameterTimer::SetValue(double newValue)

Reimplemented from CDPParameter::SetValue().

Sets the parameter-value and resets the timer with the new timeout. If the timer was running, it is started again.

[virtual] void CDPParameterTimer::Start()

Deprecated, use Restart() instead.

bool CDPParameterTimer::State()

Returns the state of the timeout flag as calculated by the previous TimedOut() call.

double CDPParameterTimer::TimeElapsed()

Returns time [s] elapsed since Start() or Restart() was called.

bool CDPParameterTimer::TimedOut()

Updates delta time, checks if timeout and returns true if timeout.

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