GetAnAxisState

GetAxisState gets the state of an axis. When you use GetAxisState, it returns a number that represents the state your axis in, not a string. To know what this number means, you need to check the AxisState type. In GetAnAxisState we use an array to store the strings for each axis state, and convert the number to the string, so that you know what state an axis is in immediately.

Copy

GetAnAxisState

VOID GetAnAxisState(int& Index)
{
    //Display the state of an axis in string.

    string axisState[10] = { "axisOffline", "axisCommunicationError", "axisMotionError",
        "axisDisabled", "axisLocked", "axisStandStill", "axisHoming", "axisDiscreteMotion",
        "axisContinuousMotion", "axisSynchronizedMotion" };

    AxisState state = axisOffline;
    
    KsError nRet = GetAxisState(Index, &state);
    if (nRet != errNoError)
        RtPrintf("GetAxisState failed: %x\n", nRet);

    else if (nRet == errNoError)
    {
        for (int i = 0; i < 10; i++)
        {
            if (state == i)
            {
                RtPrintf("The current axis state is %s.\n\n", axisState[i].c_str());
                break;
            }
        }
    }
}