RapidCode 2.x to 4.x Upgrade Guide

RapidCode 4.x Overview

RapidCode has undergone some constructive changes and refactoring which has slightly altered the API. The benefits of these changes should help create less error-prone user application code, better testing procedures at RSI, easier to maintain, modify, etc.

Short description of changes

RapidCode objects have been renamed. All RapidCode objects are now created and initialized using the MotionController object. Many RapidCode methods now require specific enumeration types for parameters, instead of “long” values. SqNode methods are now accessed from an SqNode object, which is contained in Axis and IO objects.

Objects Renamed

Most RapidCode objects have been renamed for 4.x:

Object Creation

Object creation and initialization is now handled internally by RapidCode. Previously you needed to use the “new” operator to instantiate RapidCode objects. In RapidCode 4.0, objects instantiated within the RapidCode library, so you cannot use the new operator. Axis, MultiAxis and IO objects are now created and initialized by the MotionController object.

MotionController
From this (2.x):

  RsiController *controller = new RsiController;
  controller->InitBoard(0);

To this (4.x):
  
  MotionController* controller = MotionController::CreateFromBoard(0);
Axis
From this (2.x):

  RsiAxis *axis = new RsiAxis;
  axis->Init(controller, 0);

To this (4.x):
  
  Axis* axis = controller->AxisGet(0);
MultiAxis
From this (2.x):

  RsiMultiAxis *multiAxisXY = new RsiMultiAxis;
  multiAxisXY->Init(controller, axisX);
  multiAxisXY->AxisAdd(axisY);

To this (4.x):
  
  MultiAxis* multiAxisXY = controller->MultiAxisGet(axisX);
  multiAxisXY->AxisAdd(axisY);
IO
From this (2.x):

  RsiIO *io = new RsiIO;
  io->Init(controller, 0);  // use Node 0

To this (4.x):
  
  IO* io = controller->IOGet(0);   // use Node 0

Many methods now require enumeration types

Previously, many methods accepted long integer values as parameters. Now any of these specialized parameters will accept RSI enumeration types as parameters. Your compiler should generate errors for methods which require these parameter type changes. Here’s an example of a typical change require with 4.x:

From this (2.x)
  
  axis->AmpFaultActionSet( (long) RSIActionABORT);

To this (4.x)
  
      axis->AmpFaultActionSet( RSIAction::RSIActionABORT );

SqNode object contained in Axis and IO objects

All Axis and IO objects share the common identity of being SynqNet Nodes. Access to SqNode methods has changed. An SqNode object is now contained inside Axis and IO objects. The SqNode object is created an initialized automatically. See example below.

From this (2.x):

  io->SqNodeSerialNumberGet();
  axis->SqNodeSerialNumberGet();

To this (4.x):

  io->SqNode->SerialNumberGet();
  axis->SqNode->SerialNumberGet();

Operating System (OS) object contained in MotionController

A few handy operating system methods are now contained in an operating system object in the MotionController. Many of these are used for internal RSI testing, such as Sleep() and KeyGet().

From this (2.x):
  controller->Sleep(10);  
  controller->KeyGet();

To this (4.x):

  controller->OS->Sleep(10);
  controller->OS->KeyGet();

Electronic Gearing method changed

The Axis::GearingEnable() method was changed to accept an Axis object instead of an integer axis number.

// Configure this Axis to follow AxisX Actual Position with a 3:1 ratio.
AxisY->GearingEnable(AxisX, RSIAxisMasterTypeAXIS_ACTUAL_POSITION, 3, 1);