Program Listing for File CompensationApi.h

Return to documentation for file (common\include\CompensationApi.h)

//This header file is used to generate the Doxygen manual
//TO STRIP ALL DOXYGEN COMMENTS FROM THIS HEADER FILE, SEARCH FOR THE FOLLOWING REGULAR EXPRESSION AND REPLACE IT WITH BLANK
// (/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/\s+)|((//(/)<.*\s*)*(//(/)<.*))|(//(/)[^<].*\s*)

//==========================================DOCUMENTATION GUIDELINES (2017/3/30)=======================================================
//
// 1. References to constants, functions, classes, and class members should be linked using the @ref command. The format should be as
//   follows:
//
//   @ref [Full Path Including Namespaces] "[Name of Constant/Function/Class/Member]"
//
//   Examples: @ref Motion::StartPos "StartPos"
//             @ref Motion::StartPos(TriggerPosCommand *pPosCommand) "StartPos"
//
// 2. When documenting functions, @param should be used to document every function argument. @remarks should be used to explain the
//   function in further detail.
//
// 3. Try to follow the conventions of the existing documentation as much as possible.
//

#ifndef WMX3_COMPENSATION_API_H
#define WMX3_COMPENSATION_API_H
#include <windows.h>
#include "WMX3Api.h"

namespace wmx3Api{

    namespace constants {
        static const int maxPitchErrorCompPoints = 1024;
        static const int maxPitchErrorCompFreePositionRangeMultiplier = 40000;
        static const int max2dPitchErrorCompPoints = 512;
        static const int max2dPitchErrorCompChannel = 32;
        static const int max2dPitchErrorCompFreePositionRangeMultiplier = 40000;
        static const int maxSizeSet2dPitchErrorCompValue = 62;
    }

    class CompensationErrorCode : public ErrorCode{
    public:
        enum {
            PitchErrorCompensationIsEnabled = 0x00015000,
            PitchErrorCompensationIsDisabled,
            PitchErrorCompensationDataIsNotSet,
            BacklashCompensationIsEnabled,
            BacklashCompensationIsDisabled,
            PitchCountOutOfRange,
            PitchOriginIndexOutOfRange,
            PitchIntervalOutOfRange,
            EdgeDropoffDistanceOutOfRange,
            CompensationAxisNotPosMode,
            ReferenceAxisNotPosMode,
            NotUsingPitchIntervalMode,
            NotUsingFreePositionMode,
            PitchPositionRangeTooLarge,
            PitchPositionNotInAscendingOrder
        };
    };

    class PitchErrorCompensationOriginPositionType {
    public:
        enum T {
            Absolute,
            Relative
        };
    };

    class PitchErrorCompensationAlignmentType {
    public:
        enum T {
            AlignBeforeCompensation
        };
    };

    class PitchErrorCompensationOptions {
    public:
        PitchErrorCompensationOptions();
        double catchUpVelocity;
        double catchUpAcc;
        PitchErrorCompensationOriginPositionType::T originPositionType;
        PitchErrorCompensationAlignmentType::T alignmentType;
        bool preventCatchUpMotion;
    };

    class PitchErrorCompensationData{
    public:
        PitchErrorCompensationData();
        int enable;
        double pitchOriginPosition;
        int pitchOriginIndex;
        double pitchInterval;
        char pitchIntervalDirection;
        int pitchCount;
        double pitchCompensationValue[constants::maxPitchErrorCompPoints];
        double edgeDropoffDistance;
        PitchErrorCompensationOptions options;
    };

    class PitchErrorCompensationFreePositionData{
    public:
        PitchErrorCompensationFreePositionData();
        int enable;
        double pitchPosition[constants::maxPitchErrorCompPoints];
        int pitchCount;
        double pitchCompensationValue[constants::maxPitchErrorCompPoints];
        double edgeDropoffDistance;
        PitchErrorCompensationOptions options;
    };

    class TwoDPitchErrorCompensationData{
    public:
        TwoDPitchErrorCompensationData();
        int enable;
        int axis;
        int referenceAxis[2];
        double pitchOriginPosition[2];
        int pitchOriginIndex[2];
        double pitchInterval[2];
        char pitchIntervalDirection[2];
        int pitchCount[2];
        double pitchCompensationValue[constants::max2dPitchErrorCompPoints][constants::max2dPitchErrorCompPoints];
        double edgeDropoffDistance[2];
        PitchErrorCompensationOptions options;
    };

    class TwoDPitchErrorCompensationFreePositionData{
    public:
        TwoDPitchErrorCompensationFreePositionData();
        int enable;
        int axis;
        int referenceAxis[2];
        double pitchPosition[2][constants::max2dPitchErrorCompPoints];
        int pitchCount[2];
        double pitchCompensationValue[constants::max2dPitchErrorCompPoints][constants::max2dPitchErrorCompPoints];
        double edgeDropoffDistance[2];
        PitchErrorCompensationOptions options;
    };

    class BacklashCompensationData{
    public:
        BacklashCompensationData();
        int enable;
        char offsetDirection;
        double backlashHigh;
        double backlashLow;
        double distanceHigh;
        double distanceLow;
    };

    class Compensation {
    private:
        WMX3Api *wmx3Api;
        bool isSelfDev;
        void init(WMX3Api *f);
        void close();
    public:
        Compensation(WMX3Api *f);
        Compensation(const Compensation& src);
        Compensation& operator=(const Compensation& src);
        Compensation();
        ~Compensation();

        static WMX3APIFUNC ErrorToString(int errCode, char *pString, unsigned int size);
        static WMX3APIFUNC ErrorToString(int errCode, wchar_t *pString, unsigned int size);
        static WMX3APIFUNC ApiLogToString(unsigned char* pLogData, unsigned int logDataSize, char *pString, unsigned int size);
        static WMX3APIFUNC ApiLogToString(unsigned char* pLogData, unsigned int logDataSize, wchar_t *pString, unsigned int size);
        static WMX3APIFUNC GetLibVersion(int *pMajorVersion, int *pMinorVersion, int *pRevisionVersion, int *pFixVersion);

        bool IsDeviceValid();

        WMX3APIFUNC GetVersion(int *pMajorVersion, int *pMinorVersion, int *pRevisionVersion, int *pFixVersion);

        WMX3APIFUNC SetPitchErrorCompensation(int axis, PitchErrorCompensationData *pitchErrCompData);
        WMX3APIFUNC SetPitchErrorCompensation(int axis, PitchErrorCompensationFreePositionData *pitchErrCompData);
        WMX3APIFUNC GetPitchErrorCompensation(int axis, PitchErrorCompensationData *pitchErrCompData);
        WMX3APIFUNC GetPitchErrorCompensation(int axis, PitchErrorCompensationFreePositionData *pitchErrCompData);
        WMX3APIFUNC EnablePitchErrorCompensation(int axis);
        WMX3APIFUNC DisablePitchErrorCompensation(int axis);
        WMX3APIFUNC GetPitchErrorCompensationAtPosition(int axis, double pos, double *pCompensation);

        WMX3APIFUNC Set2DPitchErrorCompensation(unsigned int channel, TwoDPitchErrorCompensationData *pitchErrCompData2D);
        WMX3APIFUNC Set2DPitchErrorCompensation(unsigned int channel, TwoDPitchErrorCompensationFreePositionData *pitchErrCompData2D);
        WMX3APIFUNC Get2DPitchErrorCompensation(unsigned int channel, TwoDPitchErrorCompensationData *pitchErrCompData2D);
        WMX3APIFUNC Get2DPitchErrorCompensation(unsigned int channel, TwoDPitchErrorCompensationFreePositionData *pitchErrCompData2D);
        WMX3APIFUNC Enable2DPitchErrorCompensation(unsigned int channel);
        WMX3APIFUNC Disable2DPitchErrorCompensation(unsigned int channel);
        WMX3APIFUNC Get2DPitchErrorCompensationAtPosition(unsigned int channel, double refPos1, double refPos2, double *pCompensation);

        WMX3APIFUNC SetBacklashCompensation(int axis, BacklashCompensationData *pBacklashCompData);
        WMX3APIFUNC GetBacklashCompensation(int axis, BacklashCompensationData *pBacklashCompData);
        WMX3APIFUNC EnableBacklashCompensation(int axis);
        WMX3APIFUNC DisableBacklashCompensation(int axis);
    };


}

#endif