The RMP Motion Controller APIs
AxisStatus.cs
1
24using RSI.RapidCode.dotNET; // Import our RapidCode Library.
25using NUnit.Framework;
26using System;
27
29[TestFixture]
30[Category("Software")]
31class AxisStatusSample : SampleAppTestBase
32 {
33 [Test, Timeout(Constants.MAX_TEST_TIME)]
34 public void AxisStatus()
35 {
36 //@[AxisStatus]
37
38
39 // CHECK AXIS STATE
40 RSIState state = axis.StateGet(); // StateGet will return RSIState enum name of the current state of the Axis or MultiAxis. (Ex: RSIStateERROR)
41 Console.WriteLine("Your Axis is in state: " + state);
42
43 switch (state)
44 {
45 case RSIState.RSIStateIDLE:
46 case RSIState.RSIStateMOVING:
47 break;
48 case RSIState.RSIStateERROR:
49 case RSIState.RSIStateSTOPPING_ERROR:
50 case RSIState.RSIStateSTOPPED:
51 case RSIState.RSIStateSTOPPING:
52 RSISource source = axis.SourceGet(); // SourceGet will return the RSISource enum name of the first status bit that is active. (Ex: RSISourceAMP_FAULT)
53 Console.WriteLine("Your Axis is in state: " + state);
54 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.
55 break;
56 default:
57 Console.WriteLine("");
58 break;
59 }
60
61 // or USE STATUS BIT GET
62
63 bool isAmpFault_Active = axis.StatusBitGet(RSIEventType.RSIEventTypeAMP_FAULT); // StatusBitGet returns the state of a status bit, true or false.
64 bool isPositionErrorLimitActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_ERROR);
65 bool isHWNegativeLimitActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_HW_NEG);
66 bool isHWPostiveLimitActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_HW_POS); // This can be done for all RSIEventTypes
67
68 //@[AxisStatus]
69 }
70 }
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.
RSIEventType
Event Types or Status Bits.
Definition rsienums.h:911
RSISource
Possible sources that have caused an Error state.
Definition rsienums.h:958