APIs, concepts, guides, and more

◆ StateGet()

RSIState StateGet ( )
Description:
StateGet returns the current state of the Axis or MultiAxis.
Returns
(::RSIState) The current state of the Axis or MultiAxis.

Part of the State and Status method group.

Sample Code:
Axis Status
/* This sample application demonstrates how to read the status of an axis using the RapidCode .NET API.
It checks the current state of the axis and identifies any error sources if the axis is not operating normally.
Additionally, it shows how to check specific status bits for conditions such as amplifier faults and limit switches.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Axis: Status");
// get rmp objects
try
{
Helpers.CheckErrors(controller);
Axis axis = controller.AxisGet(axisNumber: 0);
Helpers.CheckErrors(axis);
// get state
RSIState state = axis.StateGet();
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(); // get state source enum
Console.WriteLine($"The source of the axis error is: {axis.SourceNameGet(source)}"); // get first status bit set on this axis
break;
default:
Console.WriteLine("Axis is in an unexpected state.");
break;
}
// get some RSIEventTypes status bits
bool isAmpFaultActive = axis.StatusBitGet(RSIEventType.RSIEventTypeAMP_FAULT);
bool isPosErrLimActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_ERROR);
bool isHwNegLimActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_HW_NEG);
bool isHwPosLimActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_HW_POS);
Console.WriteLine($"Amp Fault Active: {isAmpFaultActive}");
Console.WriteLine($"Position Error Limit Active: {isPosErrLimActive}");
Console.WriteLine($"HW Negative Limit Active: {isHwNegLimActive}");
Console.WriteLine($"HW Positive Limit Active: {isHwPosLimActive}");
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5863
static MotionController * Get()
Get an already running RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
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.
RSIEventType
Event Types or Status Bits.
Definition rsienums.h:966
RSISource
Possible sources that have caused an Error state.
Definition rsienums.h:1014
Helpers namespace provides utility functions for common tasks in RMP applications.
Definition helpers.h:21
RapidSetup:
Go to the Axis or MultiAxis screen -> Status.
See also
StateGet, Abort, EStop, EStopModify, TriggeredModify, Stop, Resume, ClearFaults, MotionDoneGet
RSIState, SourceGet
Examples
SyncOutputWithMotion.cpp, UpdateBufferPoints.cpp, _helpers.cs, axis-status.cs, difference-of-position-user-limit.cpp, and mathblock-difference-of-position-userlimit.cs.