GetAGroupPosition

GetGroupPosition gets the position of a group. You can use it to check where the group is. When you use this function, you may want to display the position or pass the value of the position to somewhere for other uses. In GetAGroupPosition we display the positions of each axis in a group so you know whether a group finish its move.

Notice that we use the variable LENGTH to control the length of the array, which represents how many axes in a group. If you change the number of the axes in your group, remember to change this value.

Copy
GetAGroupPosition
VOID GetAGroupPosition(int& Group)
{
    const int LENGTH = 3;   //Array length. It indicates how many axes in a group.
                            /*Remember to change this value when you change the number of the
                              axes in a group.*/
    int AxisIndex = 0;      //Receive the returned value from GetGroupConfiguration.
    int AxisInGroup[LENGTH] = { 0 };         /*The array that presents the indexes of the
                                               axes in a group.*/
    int OriginalIndex[LENGTH] = { 0 };       //The original indexes of axes.
    double setPosition[LENGTH] = { 0 };      //The set positions of axes.
    double actualPosition[LENGTH] = { 0 };   //The actual positions of axes.
    KsError nRet = errNoError;

    //Get the set position of a group.
    nRet = GetGroupPosition(Group, mcAxisCoordSystem, mcSetValue, LENGTH, setPosition);
    if (nRet != errNoError)
        RtPrintf("Unable to get the set position: %x\n", nRet);

    //Get the actual position of a group.
    nRet = GetGroupPosition(Group, mcAxisCoordSystem, mcActualValue, LENGTH, actualPosition);
    if (nRet != errNoError)
        RtPrintf("Unable to get the actual position: %x\n", nRet);

    //Initialize AxisInGroup using sequential numbers.
    for (int i = 0; i < LENGTH; i++)
        AxisInGroup[i] = i;

    for (int i = 0; i < LENGTH; i++)
    {
        //Check the axes in a group, and pass their original index to OriginalIndex.
        KsError nRet = GetGroupConfiguration(Group, AxisInGroup[i], mcAxisCoordSystem, &AxisIndex);
        OriginalIndex[i] = AxisIndex;
    }

    //Display the positions of the axes in a group.
    for (int i = 0; i < LENGTH; i++)
        printf("Axis %d Set position: %f, Actual position: %f\n", OriginalIndex[i],
            setPosition[i], actualPosition[i]);

    RtPrintf("\n");
}