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