See ⚙️ Helpers📜 for a detailed explanation of this sample code.
Warning
This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.
The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.
thrownew Exception("USE_HARDWARE is set to true, but the network is not operational. " +
"Please properly configure your hardware or run _setup.cs.");
}
elseif (!USE_HARDWARE && networkIsOperational)
{
thrownew Exception("USE_HARDWARE is set to false, but the network is operational. " +
"Please ensure you are not connected to real hardware, or set USE_HARDWARE in _constants.cs to true.");
}
elseif (!USE_HARDWARE && !networkIsOperational)
{
Console.WriteLine("Running with phantom axes as expected.");
}
else
{
// State running with hardware and require 'y' input from user to continue or any other key to abort
Console.WriteLine("Caution: You are currently running with hardware. " +
"Do not continue unless you have configured your axes through _setup.cs or another tool!");
Console.Write("Press 'y' to continue: ");
var input = Console.ReadKey();
Console.WriteLine(); // Move to next line after key press
if (input.KeyChar != 'y' && input.KeyChar != 'Y')
{
thrownew Exception("User chose not to continue with hardware operation.");
}
}
}
/*
@brief Verifies that the AXIS_COUNT constant matches the controller's axis count, then validates minimum axis and MultiAxis requirements. Outputs comparison information to console.
@param controller The MotionController object to verify.
@param minRequiredSampleAxisCount Minimum number of axes required by the sample application (default: 1).
@param minRequiredSampleMultiAxisCount Minimum number of MultiAxis objects required by the sample application (default: 0).
@exception Exception Thrown if AXIS_COUNT doesn't match controller axis count, if minimum axis count is not met, or if minimum MultiAxis count (calculated as MotionCount minus AxisCount) is not met.
@par Code Snippet
@snippet _helpers.cs VerifyAxisCount
*/
publicstaticvoid VerifyAxisCount(MotionController controller, int minRequiredSampleAxisCount = 1, int minRequiredSampleMultiAxisCount = 0)
{
int controllerAxisCount = controller.AxisCountGet();