APIs, concepts, guides, and more
AxisStatus.cs
Attention
See the following Concept pages for a detailed explanation of this sample: Status & Faults.
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.
using RSI.RapidCode.dotNET; // Import our RapidCode Library.
using NUnit.Framework;
using System;
[TestFixture]
[Category("Software")]
class AxisStatusSample : SampleAppTestBase
{
[Test, Timeout(Constants.MAX_TEST_TIME)]
public void AxisStatus()
{
//@[AxisStatus]
// CHECK AXIS STATE
RSIState state = axis.StateGet(); // StateGet will return RSIState enum name of the current state of the Axis or MultiAxis. (Ex: RSIStateERROR)
Console.WriteLine("Your Axis is in state: " + state);
switch (state)
{
case RSIState.RSIStateIDLE:
case RSIState.RSIStateMOVING:
break;
case RSIState.RSIStateERROR:
case RSIState.RSIStateSTOPPING_ERROR:
case RSIState.RSIStateSTOPPED:
case RSIState.RSIStateSTOPPING:
RSISource source = axis.SourceGet(); // SourceGet will return the RSISource enum name of the first status bit that is active. (Ex: RSISourceAMP_FAULT)
Console.WriteLine("Your Axis is in state: " + state);
Console.WriteLine("The source of the axis error is: " + axis.SourceNameGet(source)); // SourceNameGet will return the first status bit which is set on an Axis or MultiAxis.
break;
default:
Console.WriteLine("");
break;
}
// or USE STATUS BIT GET
bool isAmpFault_Active = axis.StatusBitGet(RSIEventType.RSIEventTypeAMP_FAULT); // StatusBitGet returns the state of a status bit, true or false.
bool isPositionErrorLimitActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_ERROR);
bool isHWNegativeLimitActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_HW_NEG);
bool isHWPostiveLimitActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_HW_POS); // This can be done for all RSIEventTypes
//@[AxisStatus]
}
}
const char *const SourceNameGet(RSISource source)
Get the name (string) of the source of an error for an Axis or MultiAxis.
bool StatusBitGet(RSIEventType bitMask)
Return the state of a status bit.
RSIState StateGet()
Get the Axis or MultiAxis state.
RSISource SourceGet()
Get the source of an error state for an Axis or MultiAxis.