CDPTimerCounting Class
The CDPTimerCounting is a timer based on counting. More...
Header: | #include <OSAPI/Timer/Timer.h> |
Inherits: | CDP::StudioAPI::CDPNode |
Public Functions
CDPTimerCounting() | |
CDPTimerCounting(CDPTimerCounting &&other) = default | |
virtual void | Create(const char *shortName, CDPBaseObject *pParent) |
int | Delay() |
virtual void | Destroy() |
bool | IsRunning() |
void | Reset(int countDownVal) |
void | Reset() |
void | Restart() |
void | Set() |
virtual void | Start() |
bool | State() |
bool | TimedOut(bool decrCount = true, int *currentCountVal = nullptr) |
Reimplemented Public Functions
virtual void | FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const override |
virtual const std::string | GetNodeName() const override |
virtual std::string | GetNodeTypeName() const override |
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
Protected Variables
CDPSetting<int> | m_countDownValue |
CDPSetting<int> | m_currentCountDownValue |
CDPSetting<std::string> | m_model |
CDPSetting<bool> | m_running |
CDPSetting<bool> | m_timedout |
Additional Inherited Members
- 1 protected function inherited from CDP::StudioAPI::CDPNode
Detailed Description
The CDPTimerCounting is a timer based on counting.
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 myTimer.Create("MyTimer",this)
, and in component's Destroy()
, call myTimer.Destroy()
.
Usage
- Add a CDPTimerCounting member in your class.
- Init using Reset(int countDownVal).
- Call Start()(or Restart()) to enable timeout/countdown checking.
- Call TimedOut() to check if time/countdown has expired. m_currentCountDownValue will be decremented every time TimedOut() is called, typically from a Process()-function. If TimedOut() is needed to be called without decrementing counter, call TimedOut(false).
- Call Restart() to reset and start new timeout check when time/countdown has expired.
See also CDPTimer, CDPParameterTimer, CDPTimerMs, CDPParameterTimerMs, OSAPIPeriodicTimer, OSAPIOneShotTimer, CDPRampTimer, and CDPComponent::RunInComponentThread.
Member Function Documentation
CDPTimerCounting::CDPTimerCounting()
Constructs a CDPTimerCounting.
[default]
CDPTimerCounting::CDPTimerCounting(CDPTimerCounting &&other)
Move-copy constructor.
[virtual]
void CDPTimerCounting::Create(const char *shortName, CDPBaseObject *pParent)
Stores shortName, calls parent's RegisterCDPNode()
and sets up callback when m_countDownValue
changes.
int CDPTimerCounting::Delay()
Returns the delay [number of countdowns] set by Reset(countDownVal)
[virtual]
void CDPTimerCounting::Destroy()
Calls parent's UnRegisterCDPNode()
.
[override virtual]
void CDPTimerCounting::FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const
Reimplemented from CDPNode::FillNodeChildren().
Writes its CDPSettings to stream.
[override virtual]
const std::string CDPTimerCounting::GetNodeName() const
Reimplemented from ICDPNode::GetNodeName().
Returns m_timerName
[override virtual]
std::string CDPTimerCounting::GetNodeTypeName() const
Reimplemented from ICDPNode::GetNodeTypeName().
Returns "CDPTimerCounting"
bool CDPTimerCounting::IsRunning()
Returns true if timer is running.
void CDPTimerCounting::Reset(int countDownVal)
Resets and sets delay timeout in number of countdowns.
countDownVal: Timeout delay in number of countdowns.
void CDPTimerCounting::Reset()
Resets the timer.
Remember to call Start() to enable the timeout timer after a call to Reset().
void CDPTimerCounting::Restart()
Resets and starts the timer.
void CDPTimerCounting::Set()
Sets m_timedout to true
[virtual]
void CDPTimerCounting::Start()
Starts delay timeout timer.
bool CDPTimerCounting::State()
Returns flag state (m_timedout
), does not verify timeout.
Returns the state of the timeout flag as calculated by the previous TimedOut() call.
bool CDPTimerCounting::TimedOut(bool decrCount = true, int *currentCountVal = nullptr)
Returns true
if timed out (when m_currentCountDownValue <= 0).
decrCount is default true, causing m_currentCountDownValue to be decremented every time TimedOut() is called, typically from a Process()- function.
currentCountVal is default a nullptr. If not, currentCountVal will be updated with value of m_currentCountDownValue.
Member Variable Documentation
CDPSetting<int> CDPTimerCounting::m_countDownValue
This variable holds timeout delay in number of countdowns.
CDPSetting<int> CDPTimerCounting::m_currentCountDownValue
This variable holds current value of timeout delay in number of countdowns.
CDPSetting<std::string> CDPTimerCounting::m_model
This variable holds timer object's modelname ('CDPTimerCounting').
CDPSetting<bool> CDPTimerCounting::m_running
This variable holds set to true when timer is running.
CDPSetting<bool> CDPTimerCounting::m_timedout
This variable holds set to true when timer has timed out.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.