The RMP Motion Controller APIs
HelperFunctions.h
#ifndef CPP_HELPER_FUNCTIONS
#define CPP_HELPER_FUNCTIONS
#include "rsi.h" // Import our RapidCode Library.
#include <iostream>
#include <cstdlib>
using namespace std;
using namespace RSI::RapidCode;
{
public:
static void CheckErrors(RapidCodeObject *rsiObject)
{
while (rsiObject->ErrorLogCountGet() > 0)
{
const RsiError* err = rsiObject->ErrorLogGet();
printf("%s\n", err->text);
}
}
static void StartTheNetwork(MotionController *controller)
{
// Initialize the Network
if (controller->NetworkStateGet() != RSINetworkState::RSINetworkStateOPERATIONAL) // Check if network is started already.
{
cout << "Starting Network.." << endl;
controller->NetworkStart(); // If not. Initialize The Network. (This can also be done from RapidSetup Tool)
}
if (controller->NetworkStateGet() != RSINetworkState::RSINetworkStateOPERATIONAL) // Check if network is started again.
{
int messagesToRead = controller->NetworkLogMessageCountGet(); // Some kind of error starting the network, read the network log messages
for (int i = 0; i < messagesToRead; i++)
{
cout << controller->NetworkLogMessageGet(i) << endl; // Print all the messages to help figure out the problem
}
cout << "Expected OPERATIONAL state but the network did not get there." << endl;
//throw new RsiError(); // Uncomment if you want your application to exit when the network isn't operational. (Comment when using phantom axis)
}
else // Else, of network is operational.
{
cout << "Network Started" << endl;
}
}
};
#endif
RSI::RapidCode::RsiError
The RsiError object contains information about any RapidCode API object's error/exception.
Definition: rsi.h:90
RSI::RapidCode::MotionController::NetworkStart
void NetworkStart()
Start the network with RSINetworkStartupMethodNORMAL.
RSI::RapidCode
RSI::RapidCode::MotionController::NetworkLogMessageGet
const char *const NetworkLogMessageGet(int32_t messageIndex)
RSI::RapidCode::RapidCodeObject
The RapidCode base class. All non-error objects are derived from this class.
Definition: rsi.h:145
RSI::RapidCode::RapidCodeObject::ErrorLogGet
const RsiError *const ErrorLogGet()
Get the next RsiError in the log.
RSI::RapidCode::MotionController
The MotionController object represents the RMP INtime soft motion controller.
Definition: rsi.h:743
RSI::RapidCode::RapidCodeObject::ErrorLogCountGet
int32_t ErrorLogCountGet()
Get the number of software errors in the error log.
RSI::RapidCode::MotionController::NetworkLogMessageCountGet
int32_t NetworkLogMessageCountGet()
HelperFunctions
Helper Functions for checking logged creation errors, starting the network, etc.
Definition: HelperFunctions.cs:50
RSI::RapidCode::MotionController::NetworkStateGet
RSINetworkState NetworkStateGet()