xentara-cpp-control v1.1
The Xentara C++ Control Framework
Loading...
Searching...
No Matches
xentara::RunContext Class Referencefinal

An run context with execution information and is required for the read and write for Input and Output respectively. More...

#include <xentara/RunContext.hpp>

Public Member Functions

 RunContext ()=delete
 No default construction.
 
auto scheduledTimestamp () const -> std::chrono::system_clock::time_point
 Gets the time the pipeline was scheduled for.
 
auto currentStage () const -> Stage
 Gets the current stage of Xentara.
 
auto counter () const -> std::int64_t
 Gets the execution counter of the trigger.
 
auto xentaraSkillElement () const &noexcept -> const skill::Element &
 Gets the Xentara skill element.
 
auto reschedule (std::chrono::system_clock::time_point when) -> void
 Sets a timer that raises the “rescheduled” event of the Xentara control element.
 
 RunContext (const RunContext &)=delete
 Delete the copy constructor.
 
auto operator= (const RunContext &) -> RunContext &=delete
 Delete the assignment operator.
 
Error Handling
auto error () const -> std::error_code
 Gets the error that occurred during read or write operations.
 
auto setError (std::error_code error) -> void
 Sets the error code with the provided value.
 
auto resetError () -> void
 Resets the error code.
 

Detailed Description

An run context with execution information and is required for the read and write for Input and Output respectively.

An object of this class is passed to the callbacks of Control::step(), Control::enterPreOp(), Control::enterOperational(), Control::enterPostOp() and Control::final(). It provides information about the current execution, like the scheduled time, current stage and execution counter of the pipeline. This object is also passed to the Input::read() and Output::write() functions and provides errors information occurring during read and write operations. You never create objects of this class yourself. If you want to handle errors yourself, you can use the cleanRunContext() function to get your own RunContext for managing.

Constructor & Destructor Documentation

◆ RunContext() [1/2]

xentara::RunContext::RunContext ( )
delete

No default construction.

◆ RunContext() [2/2]

xentara::RunContext::RunContext ( const RunContext &  )
delete

Delete the copy constructor.

Member Function Documentation

◆ counter()

auto xentara::RunContext::counter ( ) const -> std::int64_t

Gets the execution counter of the trigger.

Returns
The number of times the trigger has been executed. On the first execution, 0 is returned.

◆ currentStage()

auto xentara::RunContext::currentStage ( ) const -> Stage

Gets the current stage of Xentara.

Returns
Stage from Stage enum

◆ error()

auto xentara::RunContext::error ( ) const -> std::error_code

Gets the error that occurred during read or write operations.

Returns
The corresponding error code

◆ operator=()

auto xentara::RunContext::operator= ( const RunContext &  ) -> RunContext &=delete
delete

Delete the assignment operator.

◆ reschedule()

auto xentara::RunContext::reschedule ( std::chrono::system_clock::time_point  when) -> void

Sets a timer that raises the “rescheduled” event of the Xentara control element.

This function can be used to reschedule the control to run at a specific time in the future. Once that time has arrived, the “rescheduled” event will be raised. In order for this to work as intended, the “rescheduled” event must be configured to trigger of an execution pipeline that contains the control’s “step” task.

The rescheduling timer is reset every time the control is executed. If the control runs before the scheduled time die to another timer or event, you must call reschedule() again.

Rescheduling a control can be useful to implement timers and delays.

Parameters
whenThe time at which the “rescheduled” event should be raised. If the time is in the past, then the “rescheduled” event will be raised immediately.

◆ resetError()

auto xentara::RunContext::resetError ( ) -> void

Resets the error code.

◆ scheduledTimestamp()

auto xentara::RunContext::scheduledTimestamp ( ) const -> std::chrono::system_clock::time_point

Gets the time the pipeline was scheduled for.

Returns
The time the pipeline was scheduled for. This is not the actual time at the time the function is called, but the time that the pipeline was initially intended to run. For timers, this is the time that the timer was scheduled to run, and for events, the time that the event occurred.

◆ setError()

auto xentara::RunContext::setError ( std::error_code  error) -> void

Sets the error code with the provided value.

Note
passing std::error_code() will reset the error code.

◆ xentaraSkillElement()

auto xentara::RunContext::xentaraSkillElement ( ) const & -> const skill::Element &
noexcept

Gets the Xentara skill element.

This function gives access to the underlying Xentara control skill element.

Returns
A reference to the skill element