#include "SampleAppsHelper.h"
#include "rsi.h"
#include "RTTasksHelpers.h"
#include "rttask.h"
#include <iostream>
#include <memory>
#include <thread>
#include <chrono>
using namespace RSI::RapidCode::RealTimeTasks;
int main()
{
const std::string SAMPLE_APP_NAME = "Real-Time Tasks: Random Walk";
const int NUM_AXES = 1;
const int TIMEOUT_MS = 5000;
std::unique_ptr<RTTaskManager> manager = nullptr;
int exitCode = -1;
try
{
std::cout << "Creating task manager..." << std::endl;
manager.reset(RTTaskManager::Create(parameters));
RTTaskHelper::InitializeRTTaskObjects(manager);
std::cout << "Submitting task..." << std::endl;
params.
Repeats = RTTaskCreationParameters::RepeatForever;
std::unique_ptr<RTTask> task(manager->TaskSubmit(params));
task->ExecutionCountAbsoluteWait(50, 500);
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;
}
std::cout <<
"Average: " << average.
Double << std::endl;
task->Stop();
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
}
if (manager != nullptr)
{
manager->Shutdown();
}
return exitCode;
}
double CommandPositionGet()
Get the current command position.
void PositionSet(double position)
Set the Command and Actual positions.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
void Delete(void)
Delete the MotionController and all its objects.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
void AmpEnableSet(bool enable)
Enable all amplifiers.
int32_t MotionDoneWait()
Waits for a move to complete.
static void PrintFooter(std::string sampleAppName, int exitCode)
Print a message to indicate the sample app has finished and if it was successful or not.
static void CheckErrors(RapidCodeObject *rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
static void PrintHeader(std::string sampleAppName)
Print a start message to indicate that the sample app has started.
static void Cleanup(MotionController *controller)
Cleanup the controller and restore the object counts to the original values.
static MotionController::CreationParameters GetCreationParameters()
Returns a MotionController::CreationParameters object with user-defined parameters.
static void SetupController(MotionController *controller, int numAxes=0)
Setup the controller with user defined axis counts and configuration.
CreationParameters for MotionController::Create.
RTTaskCreationParameters specifies all the information required to create and configure a real-time t...
int32_t Repeats
Number of times the task should execute (RepeatForever for infinite, 0 for none (one-shot)).
int32_t Period
Execution period of the task in RMP sample periods.
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.
double Double
Double precision (64-bit) floating-point.