APIs, concepts, guides, and more
rttaskfunctions.cpp
1#include "rttaskglobals.h"
2
3#include <cstdlib>
4#include <ctime>
5
6#include <iostream>
7
8using namespace RSI::RapidCode;
10
12// initialize the global data and random number generator
13RSI_TASK(Initialize)
14{
15 data->counter = 0;
16 data->average = 0;
17
18 std::srand(std::time(nullptr));
19}
21
23// increment the counter in the global data
24RSI_TASK(Increment)
25{
26 data->counter += 1;
27}
29
31// randomly move the axis back and forth
32RSI_TASK(RandomWalk)
33{
34 int random = std::rand() % 2;
35 double step = random ? 0.05 : -0.025; // randomly increment or decrement the average
36 data->average += step;
37 data->counter += 1;
38
39 RTAxisGet(0)->MoveSCurve(data->average);
40}
The RealTimeTasks namespace.
Definition rttask.h:36