Template.cpp
#include "rsi.h" // Import our RapidCode Library.
#include "HelperFunctions.h" // Import our SampleApp helper functions.
using namespace RSI::RapidCode;
const int AXIS_X = (0);
const int AXIS_Y = (1);
const int IO_NODE = (7);
void templateMain(int argc, char *argv[])
{
Axis *axisX;
Axis *axisY;
MultiAxis *multiAxisXY;
IO *io;
// Create and initialize RsiController class
SampleAppsCPP::HelperFunctions::CheckErrors(controller);
try
{
// enable one MotionSupervisor for the MultiAxis
controller->MotionCountSet(controller->AxisCountGet() + 1);
// Get Axis X and Y respectively.
axisX = controller->AxisGet(AXIS_X);
SampleAppsCPP::HelperFunctions::CheckErrors(axisX);
axisY = controller->AxisGet(AXIS_Y);
SampleAppsCPP::HelperFunctions::CheckErrors(axisY);
// Initialize a MultiAxis, using the last MotionSupervisor.
multiAxisXY = controller->MultiAxisGet(controller->MotionCountGet() - 1);
SampleAppsCPP::HelperFunctions::CheckErrors(multiAxisXY);
multiAxisXY->AxisAdd(axisX);
multiAxisXY->AxisAdd(axisY);
// Initialize an IO.
io = controller->IOGet(IO_NODE);
// Insert your application code here.
}
catch (RsiError const& err)
{
printf("\n%s\n", err.text);
}
controller->Delete(); // Delete the controller as the program exits to ensure memory is deallocated in the correct order.
system("pause"); // Allow time to read Console.
}