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 <OSAPI/Timer/CDPParameterTimer.h> |
Inherits: | CDPParameter |
Public Functions
CDPParameterTimer() | |
double | Delay() |
double | DeltaTime() |
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 | Configure(const char *xml) override |
virtual void | Configure(XMLElementEx *pParameterElement) override |
virtual void | Create(const char *shortName, CDPComponent *pParent) override |
virtual void | Destroy() override |
virtual void | FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const override |
virtual void | SetValue(double newValue) override |
- 25 public functions inherited from CDPParameter
- 37 public functions inherited from CDPObject
- 46 public functions inherited from CDPBaseObject
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
Additional Inherited Members
- 6 static public members inherited from CDPObject
- 1 static public member inherited from CDPBaseObject
- 13 protected functions inherited from CDPObject
- 1 protected function inherited from CDP::StudioAPI::CDPNode
- 7 protected variables inherited from CDPObject
- 9 protected variables inherited from CDPBaseObject
- 1 static protected member inherited from CDPObject
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.
[override virtual]
void CDPParameterTimer::Configure(const char *xml)
Reimplemented from CDPObject::Configure().
Configures CDPParameter from an xml-string and sets up the timer.
[override virtual]
void CDPParameterTimer::Configure(XMLElementEx *pParameterElement)
Reimplemented from CDPObject::Configure().
Configures CDPParameter from an xml element and sets up the timer.
[override virtual]
void CDPParameterTimer::Create(const char *shortName, CDPComponent *pParent)
Reimplemented from CDPObject::Create().
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.
[override virtual]
void CDPParameterTimer::Destroy()
Reimplemented from CDPBaseObject::Destroy().
Destroys the CDPParameter and timer instance.
[override virtual]
void CDPParameterTimer::FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const
Reimplemented from CDPNode::FillNodeChildren().
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.
[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.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.