CDPParameterTimerMs Class
CDPTimerMs with timeout specified as CDPParameter parameter. This object behaves as a CDPParameter and a CDPTimerMs at the same time. It should be used as a CDPTimerMs object except that the timeout value should be set in the configuration instead of being hardcoded. More...
Header: | #include <OSAPI/Timer/CDPTimerMs.h> |
Inherits: | CDPParameter |
Public Functions
CDPParameterTimerMs() | |
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
CDPTimerMs with timeout specified as CDPParameter parameter. This object behaves as a CDPParameter and a CDPTimerMs at the same time. It should be used as a CDPTimerMs 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 myCDPParameterTimerMs.Create("MyCDPParameterTimerMs",this)
, and in component's Destroy()
, call myCDPParameterTimerMs.Destroy()
.
Usage
Use as CDPTimerMs, but specify timeout in configuration as parameter.
The easiest way to add a CDPParameterTimerMs is to:
- Add a CDPParameter using the CodeGenerator
- Change the type in the header file from CDPParameter to CDPParameterTimerMs (and change the #include from CDPParameter.h to CDPTimerMs.h)
- Use the variable as a CDPTimerMs. The timeout value will be read from configuration.
Example
// In header file CDPParameterTimerMs myCDPParameterTimerMs; // In Create() myCDPParameterTimerMs.Create("MyCDPParameterTimerMs", this); // In end of Configure() or Activate() myCDPParameterTimerMs.Restart(); // Will start timing from now // In ProcessSomething() if (myCDPParameterTimerMs.TimedOut()) { myCDPParameterTimerMs.Restart(); // Start new timing cycle CDPMessage("Will be written every time the period specified in the parameter times out.\n") }
See also CDPTimerMs, CDPParameter, CDPParameterTimer, CDPTimer, OSAPIPeriodicTimer, OSAPIOneShotTimer, CDPTimerCounting, and CDPRampTimer.
Member Function Documentation
CDPParameterTimerMs::CDPParameterTimerMs()
Default constructs an instance of CDPParameterTimerMs.
[override virtual]
void CDPParameterTimerMs::Configure(const char *xml)
Reimplemented from CDPObject::Configure().
Configures CDPParameter from an xml-string and sets up the timer.
[override virtual]
void CDPParameterTimerMs::Configure(XMLElementEx *pParameterElement)
Reimplemented from CDPObject::Configure().
Configures CDPParameter from an xml element and sets up the timer.
[override virtual]
void CDPParameterTimerMs::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 CDPParameterTimerMs::Delay()
Returns the delay set by Reset(delay).
double CDPParameterTimerMs::DeltaTime()
Returns time [s] between last two TimedOut() calls.
[override virtual]
void CDPParameterTimerMs::Destroy()
Reimplemented from CDPBaseObject::Destroy().
Destroys the CDPParameter and timer instance.
[override virtual]
void CDPParameterTimerMs::FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const
Reimplemented from CDPNode::FillNodeChildren().
Writes its CDPSettings to stream.
double CDPParameterTimerMs::Frequency()
Returns frequency in Hz of time interval between last two TimedOut() calls (equals 1.0/DeltaTime()).
bool CDPParameterTimerMs::IsRunning()
Returns true
if timer is running.
double CDPParameterTimerMs::LastTime()
Returns time [s] (since application startup), as calculated by the previous TimedOut() call.
void CDPParameterTimerMs::Reset(double delay)
Resets and sets specified delay timeout in seconds.
Stores the parameter-value and resets the timer.
void CDPParameterTimerMs::Reset()
Resets and sets delay timeout in seconds with value from CDPParameter.
Will call m_cTimer.Reset(Value()).
void CDPParameterTimerMs::Restart()
Resets and starts the timer with value from CDPParameter
void CDPParameterTimerMs::Set()
Sets the timeout flag state to true
.
[override virtual]
void CDPParameterTimerMs::SetValue(double newValue)
Reimplemented from CDPParameter::SetValue().
Sets the parameter-value and resets the timer.
[virtual]
void CDPParameterTimerMs::Start()
Deprecated, use Restart() instead.
bool CDPParameterTimerMs::State()
Returns the state of the timeout flag as calculated by the previous TimedOut() call.
double CDPParameterTimerMs::TimeElapsed()
Returns time [s] elapsed since Start() or Restart() was called.
bool CDPParameterTimerMs::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.