#include "helpers.h"
#include "config.h"
#include "rsi.h"
#include "rttasks-helpers.h"
#include "rttask.h"
#include <iostream>
#include <memory>
#include <optional>
#include <thread>
#include <chrono>
int main()
{
const std::string SAMPLE_APP_NAME = "📜 Real-Time Tasks: Hello RTTasks";
std::optional<RTTaskManager> manager;
int exitCode = -1;
try
{
std::cout << "Creating task manager..." << std::endl;
std::cout << "Submitting task..." << std::endl;
RTTask task = manager->TaskSubmit(params);
std::cout << "Getting counter global tag..." << std::endl;
{
exitCode = -1;
std::cout << "Counter is not greater than 0. The task did not run correctly." << std::endl;
}
else
{
exitCode = 0;
std::cout <<
"Counter: " << counter.
Int64 << std::endl;
}
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
}
if (manager.has_value())
{
manager->Shutdown();
}
controller->Delete();
return exitCode;
}
static MotionController * Create(CreationParameters *creationParameters)
Initialize and start the RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
int64_t ExecutionCountAbsoluteWait(int64_t count=ExecutionCountDefault, int32_t timeoutMs=ExecutionCountWaitTimeoutMillisecondsDefault)
Wait for the task to reach a specific execution count.
Interface for controlling and monitoring a single real-time task. See RTTaskManager::TaskSubmit and R...
static RTTaskManager Create(const RTTaskManagerCreationParameters ¶meters)
Create a new RTTaskManager instance.
void SetupController(MotionController *controller, int numAxes=0)
Setup the controller and check if the network is in the correct state for the configuration.
MotionController::CreationParameters GetCreationParameters()
Returns a MotionController::CreationParameters object with user-defined parameters.
void Cleanup(MotionController *controller)
[SetupController]
void CheckErrors(RapidCodeObject *rsiObject, const std::source_location &location=std::source_location::current())
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
void PrintHeader(std::string sampleAppName)
[NetworkShutdown]
void PrintFooter(std::string sampleAppName, int exitCode)
[PrintHeader]
The RealTimeTasks namespace.
CreationParameters for MotionController::Create.
RTTaskCreationParameters specifies all the information required to create and configure a real-time t...
static constexpr int32_t RepeatForever
Special value to indicate the task should repeat forever.
int32_t Repeats
Number of times the task should execute (RepeatForever for infinite, 0 for none (one-shot)).
RTTaskManagerCreationParameters specifies all the information required to create and configure an RTT...
Union representing a generic RMP firmware value with multiple data types, stored in 64-bits.
int64_t Int64
64-bit signed integer.