/*
 * Go2Api.h
 * 
 * Gocator system communication library
 * Copyright (C) 2010 by LMI Technologies Inc.
 * 
 * Licensed under The MIT License.
 * Redistributions of files must retain the above copyright notice.
 */
#ifndef LMITECH_GO2_API_H_INCLUDED
#define LMITECH_GO2_API_H_INCLUDED

/*
 * Compiler/architecure-dependent definitions of standard types, constants and decorators.
 */

#if defined(_MSC_VER)
#   define GO2_MSVC
#elif defined(__GNUC__)
#   define GO2_GCC
#endif

#if defined(GO2_MSVC)

#   if defined(_WIN64)
#       define GO2_64_BIT
#   else
#       define GO2_32_BIT
#   endif

#   if defined(GO2_INTERNAL) && !defined(NDEBUG)
#       define _CRTDBG_MAP_ALLOC
#       include <winsock2.h>
#       include <ws2tcpip.h>
#       include <stdlib.h>
#       include <crtdbg.h>
#   endif

#   define GO2_CALL                     __stdcall

#   if defined(GO2_STATIC)
#      define GO2_EXPORT(RETURN_TYPE) RETURN_TYPE GO2_CALL
#   elif defined(GO2_INTERNAL)
#      define GO2_EXPORT(RETURN_TYPE)   __declspec(dllexport) RETURN_TYPE GO2_CALL
#   else
#      define GO2_EXPORT(RETURN_TYPE)   __declspec(dllimport) RETURN_TYPE GO2_CALL
#   endif

    typedef unsigned char                       Go2UInt8;               // 8-bit unsigned integer.
    typedef unsigned short                      Go2UInt16;              // 16-bit unsigned integer.
    typedef unsigned int                        Go2UInt32;              // 32-bit unsigned integer.
    typedef unsigned long long                  Go2UInt64;              // 64-bit unsigned integer.
    typedef signed char                         Go2Int8;                // 8-bit signed integer.
    typedef signed short                        Go2Int16;               // 16-bit signed integer.
    typedef signed int                          Go2Int32;               // 32-bit signed integer.
    typedef signed long long                    Go2Int64;               // 64-bit signed integer.

#   define GO2_UINT64(CONSTANT)                 (CONSTANT##ui64)        // 64-bit unsigned integer literal.
#   define GO2_INT64(CONSTANT)                  (CONSTANT##i64)         // 64-bit signed integer literal.
    
#   if defined(GO2_64_BIT)

        typedef Go2UInt64                       Go2UIntPtr;             // Unsigned integer that can store a pointer address.
        typedef Go2Int64                        Go2IntPtr;              // Signed integer that can store a pointer address difference.

#   else

        typedef Go2UInt32                       Go2UIntPtr;             // Unsigned integer that can store a pointer address.
        typedef Go2Int32                        Go2IntPtr;              // Signed integer that can store a pointer address difference.

#   endif 

#else

#   if (__SIZEOF_POINTER__ == 8)
#       define GO2_64_BIT
#   elif (__SIZEOF_POINTER__ == 4)
#       define GO2_32_BIT
#   endif

#   define GO2_CALL           

#   if defined(GO2_INTERNAL)
#      define GO2_EXPORT(RETURN_TYPE)   __attribute__((visibility("default"))) RETURN_TYPE GO2_CALL
#   else
#      define GO2_EXPORT(RETURN_TYPE)  RETURN_TYPE GO2_CALL
#   endif

    typedef unsigned char                       Go2UInt8;               // 8-bit unsigned integer.
    typedef unsigned short                      Go2UInt16;              // 16-bit unsigned integer.
    typedef unsigned int                        Go2UInt32;              // 32-bit unsigned integer.
    typedef unsigned long long                  Go2UInt64;              // 64-bit unsigned integer.
    typedef signed char                         Go2Int8;                // 8-bit signed integer.
    typedef signed short                        Go2Int16;               // 16-bit signed integer.
    typedef signed int                          Go2Int32;               // 32-bit signed integer.
    typedef signed long long                    Go2Int64;               // 64-bit signed integer.

#   define GO2_UINT64(CONSTANT)                 (CONSTANT##LLU)         // 64-bit unsigned integer literal.
#   define GO2_INT64(CONSTANT)                  (CONSTANT##LL)          // 64-bit signed integer literal.

    typedef __SIZE_TYPE__                       Go2UIntPtr;             // Unsigned integer that can store a pointer address.
    typedef __PTRDIFF_TYPE__                    Go2IntPtr;              // Signed integer that can store a pointer address difference.

#endif 

#include <Go2ApiBegin.h>

/*
 * Compiler/architecure-independent definitions of standard types, constants and decorators.
 */

typedef void*                                   Go2Handle;              // Handle to an object instance.
typedef signed char                             Go2Char;                // 8-bit ASCII character.
typedef Go2Int8                                 Go2Byte;                // One Byte. 
typedef Go2Int32                                Go2Bool;                // Boolean value. 
typedef float                                   Go2Float;               // Single-precision floating-point number.
typedef double                                  Go2Double;              // Double-precision floating-point number.
typedef Go2Int32                                Go2Status;              // Represents an error code.
typedef Go2Int32                                Go2Type;                // Represents a type identifier.
typedef Go2UInt32                               Go2IPAddress;           // Represents an IPv4 Address.
typedef Go2UInt32                               Go2Version;             // Represents a version number.

#define GO2_NULL                                (0)                     // Null pointer value.
#define GO2_NIL                                 (0)                     // Null Go2Handle value.
#define GO2_FALSE                               (0)                     // False Go2Bool value.
#define GO2_TRUE                                (1)                     // True Go2Bool value.
#define GO2_INFINITE                            GO2_UINT64(0xFFFFFFFFFFFFFFFF)  // Infinity (can be used for timeouts).

#define GO2_INVALID_RANGE                       (0x8000)                // Value for ranges when they are considered invalid     

/*
 * Current configuration file name
 */

#define GO2_SYSTEM_LIVE_CONFIG_NAME                               "_live.cfg"

/*
 * Current transform file name
 */

#define GO2_SYSTEM_LIVE_TRANSFORM_NAME                            "_live.tfm"

/*
 * Current file bundle name
 */

#define GO2_SYSTEM_LIVE_BUNDLE_NAME                               "_live.set"


/* 
 * Network configuration defaults 
 */

#define GO2_DEFAULT_IP_ADDRESS                  (0xC0A8010A)            // Default sensor IP address ("192.168.1.10").
#define GO2_DEFAULT_IP_MASK                     (0xFFFFFF00)            // Default sensor IP mask ("255.255.255.0").
#define GO2_DEFAULT_IP_GATEWAY                  (0x00000000)            // Default sensor IP gateway ("0.0.0.0").
#define GO2_DEFAULT_DHCP                        (0)                     // Default sensor DHCP status (disabled).

/*
 * Network configuration limits
 */

#define GO2_RESERVED_HTTP_PORT                      (80)
#define GO2_RESERVED_FLASH_POLICY_PORT             (843)
#define GO2_RESERVED_RANGE_1_BEGIN                (2000)
#define GO2_RESERVED_RANGE_1_END                  (2100)
#define GO2_RESERVED_RANGE_2_BEGIN                (2500)
#define GO2_RESERVED_RANGE_2_END                  (2600)
#define GO2_RESERVED_RANGE_3_BEGIN                (3100)
#define GO2_RESERVED_RANGE_3_END                  (3250)



/*
 * Status codes.
 */

#define GO2_ERROR_STATE                         (-1000)                 // Invalid state.
#define GO2_ERROR_NOT_FOUND                     (-999)                  // Item is not found.
#define GO2_ERROR_COMMAND                       (-998)                  // Command not recognized.
#define GO2_ERROR_PARAMETER                     (-997)                  // Parameter is invalid.
#define GO2_ERROR_UNIMPLEMENTED                 (-996)                  // Feature not implemented.
#define GO2_ERROR_HANDLE                        (-995)                  // Handle is invalid.
#define GO2_ERROR_MEMORY                        (-994)                  // Out of memory.
#define GO2_ERROR_TIMEOUT                       (-993)                  // Action timed out.
#define GO2_ERROR_INCOMPLETE                    (-992)                  // Buffer not large enough for data.
#define GO2_ERROR_STREAM                        (-991)                  // Error in stream.
#define GO2_ERROR_CLOSED                        (-990)                  // Resource is no longer avaiable. 
#define GO2_ERROR_VERSION                       (-989)                  // Invalid version number.
#define GO2_ERROR_ABORT                         (-988)                  // Operation aborted.
#define GO2_ERROR_ALREADY_EXISTS                (-987)                  // Conflicts with existing item.
#define GO2_ERROR                               (0)                     // General error. 
#define GO2_OK                                  (1)                     // Operation successful. 

/*
 * Object type identifiers.
 */

#define GO2_TYPE_NONE                           (0)                     // No type (invalid type id).

#define GO2_TYPE_OBJECT                         (1)                     // Go2Object class type id.
#define GO2_TYPE_LOG                            (2)                     // Go2Log class type id.

#define GO2_TYPE_SYSTEM                         (100)                   // Go2System class type id.
#define GO2_TYPE_SENSOR                         (101)                   // Go2Sensor class type id.
#define GO2_TYPE_PART                           (102)                   // Go2Part class type id.
#define GO2_TYPE_PROFILE                        (103)                   // Go2Profile class type id.
#define GO2_TYPE_OUTPUT                         (104)                   // Go2Output class type id.
#define GO2_TYPE_RANGE                          (105)                   // Go2Range class type id.

#define GO2_TYPE_PROFILE_AREA                   (200)                   // Go2ProfileArea class type id.
#define GO2_TYPE_PROFILE_FEATURE                (201)                   // Go2ProfileFeature class type id.
#define GO2_TYPE_PROFILE_LINE                   (202)                   // Go2ProfileLine class type id.
#define GO2_TYPE_PROFILE_EDGE                   (202)                   // Go2ProfileEdge class type id.

#define GO2_TYPE_MEASUREMENT                    (300)                   // Go2Measurement class type id.
#define GO2_TYPE_SCRIPT                         (301)                   // Go2Script class type id.

#define GO2_TYPE_PROFILE_WIDTH                  (401)                   // Go2ProfileWidth class type id.
#define GO2_TYPE_PROFILE_HEIGHT                 (402)                   // Go2ProfileHeight class type id.
#define GO2_TYPE_PROFILE_DISTANCE               (403)                   // Go2ProfileDistance class type id.
#define GO2_TYPE_PROFILE_POSITION_X             (404)                   // Go2ProfilePositionX class type id.
#define GO2_TYPE_PROFILE_POSITION_Z             (405)                   // Go2ProfilePositionZ class type id.
#define GO2_TYPE_PROFILE_CENTER_X               (406)                   // Go2ProfileCenterX class type id.
#define GO2_TYPE_PROFILE_CENTER_Z               (407)                   // Go2ProfileCenterZ class type id.
#define GO2_TYPE_PROFILE_ANGLE_X                (408)                   // Go2ProfileAngleX class type id.
#define GO2_TYPE_PROFILE_ISECT_X                (409)                   // Go2ProfileIsectX class type id.
#define GO2_TYPE_PROFILE_ISECT_Z                (410)                   // Go2ProfileIsectZ class type id.
#define GO2_TYPE_PROFILE_ISECT_ANGLE            (411)                   // Go2ProfileIsectAngle class type id.
#define GO2_TYPE_PROFILE_ISECT_AREA             (412)                   // Go2ProfileIsectArea class type id.
#define GO2_TYPE_PROFILE_BOX_AREA               (413)                   // Go2ProfileBoxArea class type id.
#define GO2_TYPE_PROFILE_DIFFERENCE_AREA        (414)                   // Go2ProfileDifferenceArea class type id.
#define GO2_TYPE_PROFILE_DIFFERENCE_PEAK        (415)                   // Go2ProfileDifferencePeak class type id.
#define GO2_TYPE_PROFILE_GAP                    (416)                   // Go2ProfileGap class type id.
#define GO2_TYPE_PROFILE_FLUSH                  (417)                   // Go2ProfileFlush class type id.
#define GO2_TYPE_PROFILE_CIRCLE_RADIUS          (418)                   // Go2ProfileCircleRadius class type id.
#define GO2_TYPE_PROFILE_CIRCLE_X               (419)                   // Go2ProfileCircleX class type id.
#define GO2_TYPE_PROFILE_CIRCLE_Z               (420)                   // Go2ProfileCircleZ class type id.
#define GO2_TYPE_PROFILE_LINE_STD_DEV           (421)                   // Go2ProfileLineStdDev class type id.
#define GO2_TYPE_PROFILE_LINE_ERROR_MIN         (422)                   // Go2ProfileLineErrorMin class type id.
#define GO2_TYPE_PROFILE_LINE_ERROR_MAX         (423)                   // Go2ProfileLineErrorMax class type id.
#define GO2_TYPE_PROFILE_LINE_PERCENTILE        (424)                   // Go2ProfileLinePercentile class type id.
#define GO2_TYPE_PROFILE_GROOVE_X               (425)                   // Go2ProfileGrooveX class type id.
#define GO2_TYPE_PROFILE_GROOVE_Z               (426)                   // Go2ProfileGrooveZ class type id.
#define GO2_TYPE_PROFILE_GROOVE_WIDTH           (427)                   // Go2ProfileGrooveWidth class type id.
#define GO2_TYPE_PROFILE_GROOVE_DEPTH           (428)                   // Go2ProfileGrooveDepth class type id.
#define GO2_TYPE_PROFILE_BRIDGE_VALUE           (429)                   // Go2ProfileBridgeValue class type id.
#define GO2_TYPE_PROFILE_STRIP_WIDTH            (430)                   // Go2ProfileStripWidth class type id.
#define GO2_TYPE_PROFILE_STRIP_HEIGHT           (431)                   // Go2ProfileStripHeight class type id.
#define GO2_TYPE_PROFILE_STRIP_X                (432)                   // Go2ProfileStripX class type id.
#define GO2_TYPE_PROFILE_STRIP_Z                (433)                   // Go2ProfileStripZ class type id.

#define GO2_TYPE_PART_CIRCLE_REGION             (250)                   // Go2PartCircleRegion class type id.
#define GO2_TYPE_PART_REGION_2D                 (251)                   // Go2PartRegion2d class type id.
#define GO2_TYPE_PART_REGION_3D                 (252)                   // Go2PartRegion3d class type id.
#define GO2_TYPE_PART_FEATURE_3D                (253)                   // Go2PartFeature3d class type id.
#define GO2_TYPE_PART_PLANE                     (254)                   // Go2PartPlane class type id.

#define GO2_TYPE_PART_AREA                      (501)                   // Go2PartArea class type id.
#define GO2_TYPE_PART_VOLUME                    (502)                   // Go2PartVolume class type id.
#define GO2_TYPE_PART_HEIGHT                    (503)                   // Go2PartHeight class type id.
#define GO2_TYPE_PART_ELLIPSE_MAJOR             (507)                   // Go2PartEllipseMajor class type id.
#define GO2_TYPE_PART_ELLIPSE_MINOR             (508)                   // Go2PartEllipseMinor class type id.
#define GO2_TYPE_PART_ELLIPSE_ANGLE             (509)                   // Go2PartEllipseAngle class type id.
#define GO2_TYPE_PART_ELLIPSE_RATIO             (510)                   // Go2PartEllipseRatio class type id.
#define GO2_TYPE_PART_BOUNDING_BOX_X            (511)                   // Go2PartBoundingBoxX class type id.
#define GO2_TYPE_PART_BOUNDING_BOX_Y            (512)                   // Go2PartBoundingBoxY class type id.
#define GO2_TYPE_PART_BOUNDING_BOX_WIDTH        (513)                   // Go2PartBoundingBoxWidth class type id.
#define GO2_TYPE_PART_BOUNDING_BOX_LENGTH       (514)                   // Go2PartBoundingBoxLength class type id.

#define GO2_TYPE_PART_HOLE_X                    (515)                   // Go2PartHoleX class type id.
#define GO2_TYPE_PART_HOLE_Y                    (516)                   // Go2PartHoleY class type id.
#define GO2_TYPE_PART_HOLE_Z                    (517)                   // Go2PartHoleZ class type id.
#define GO2_TYPE_PART_HOLE_RADIUS               (518)                   // Go2PartHoleRadius class type id.

#define GO2_TYPE_PART_STUD_TIP_X                (519)                   // Go2PartStudTipX class type id.
#define GO2_TYPE_PART_STUD_TIP_Y                (520)                   // Go2PartStudTipY class type id.
#define GO2_TYPE_PART_STUD_TIP_Z                (521)                   // Go2PartStudTipZ class type id.
#define GO2_TYPE_PART_STUD_BASE_X               (522)                   // Go2PartStudBaseX class type id.
#define GO2_TYPE_PART_STUD_BASE_Y               (523)                   // Go2PartStudBaseY class type id.
#define GO2_TYPE_PART_STUD_BASE_Z               (524)                   // Go2PartStudBaseZ class type id.
#define GO2_TYPE_PART_STUD_RADIUS               (525)                   // Go2PartStudRadius class type id.

#define GO2_TYPE_PART_POSITION_X                (526)                   // Go2PartPositionX class type id.
#define GO2_TYPE_PART_POSITION_Y                (527)                   // Go2PartPositionY class type id.
#define GO2_TYPE_PART_POSITION_Z                (528)                   // Go2PartPositionZ class type id.

#define GO2_TYPE_PART_OPENING_X                 (529)                   // Go2PartOpeningX class type id.
#define GO2_TYPE_PART_OPENING_Y                 (530)                   // Go2PartOpeningY class type id.
#define GO2_TYPE_PART_OPENING_Z                 (531)                   // Go2PartOpeningZ class type id.
#define GO2_TYPE_PART_OPENING_LENGTH            (532)                   // Go2PartOpeningLength class type id.
#define GO2_TYPE_PART_OPENING_WIDTH             (533)                   // Go2PartOpeningWidth class type id.
#define GO2_TYPE_PART_OPENING_ANGLE             (534)                   // Go2PartOpeningAngle class type id.

#define GO2_TYPE_PART_PLANE_X_ANGLE             (535)                   // Go2PartPlaneXAngle class type id.
#define GO2_TYPE_PART_PLANE_Y_ANGLE             (536)                   // Go2PartPlaneYAngle class type id.
#define GO2_TYPE_PART_PLANE_Z_OFFSET            (537)                   // Go2PartPlaneZOffset class type id.

#define GO2_TYPE_PART_TEXTURE_ROUGHNESS         (538)                   // Go2PartTextureRoughness class type id.
#define GO2_TYPE_PART_TEXTURE_INVALID_COUNT         (539)                   // Go2PartTextureInvalidCount class type id.

#define GO2_TYPE_RANGE_POSITION_Z               (901)                   // Go2RangePositionZ class type id.
#define GO2_TYPE_RANGE_DIFFERENCE               (902)                   // Go2RangeDifference class type id.

#define GO2_TYPE_ETHERNET                       (600)                   // Go2Ethernet class type id.
#define GO2_TYPE_SERIAL                         (601)                   // Go2Serial class type id.
#define GO2_TYPE_DIGITAL                        (602)                   // Go2Digital class type id.
#define GO2_TYPE_ANALOG                         (603)                   // Go2Analog class type id.

#define GO2_TYPE_DATA                           (700)                   // Go2Data class type id.
#define GO2_TYPE_VIDEO_DATA                     (701)                   // Go2VideoData class type id.
#define GO2_TYPE_PROFILE_DATA                   (702)                   // Go2ProfileData class type id.
#define GO2_TYPE_PART_DATA                      (703)                   // Go2PartData class type id.
#define GO2_TYPE_EXPOSURE_DATA                  (704)                   // Go2ExposureData class type id.
#define GO2_TYPE_ALIGNMENT_DATA                 (705)                   // Go2AlignmentData class type id.
#define GO2_TYPE_TRAVEL_DATA                    (706)                   // Go2TravelData class type id.
#define GO2_TYPE_MEASUREMENT_DATA               (707)                   // Go2MeasurementData class type id.
#define GO2_TYPE_RAW_PROFILE_DATA               (708)                   // Go2RawProfileData class type id.
#define GO2_TYPE_PROFILE_INTENSITY_DATA         (709)                   // Go2ProfileIntensityData class type id.
#define GO2_TYPE_RAW_PROFILE_INTENSITY_DATA     (710)                   // Go2RawProfileIntensityData class type id.
#define GO2_TYPE_PART_INTENSITY_DATA            (711)                   // Go2PartIntensityData class type id.
#define GO2_TYPE_PROFILE_TEMPLATE_DATA          (712)                   // Go2ProfileTemplateData class type id.
#define GO2_TYPE_RANGE_DATA                     (713)                   // Go2RangeData class type id.
#define GO2_TYPE_RANGE_INTENSITY_DATA           (714)                   // Go2IntensityData class type id.
#define GO2_TYPE_REFERENCE_IMAGE_DATA           (716)                   // Go2ReferenceImageData class type id.

#define GO2_TYPE_HEALTH                         (800)                   // Go2Health class type id.

#define GO2_TYPE_CUSTOM_DATA                   (1000)                   // Go2CustomData class type id (multiple custom data types may exist and this is the lowest possible value for them)


/* 
 * Enumerations
 */

typedef enum Go2User
{
    GO2_USER_NONE                               = 0,                    // No user id.
    GO2_USER_ADMIN                              = 1,                    // Administrator user id.
    GO2_USER_TECHNICIAN                         = 2                     // Technician user id.
} Go2User;                                                              // Represents a user id.

typedef enum Go2SystemState
{
    GO2_SYSTEM_STATE_CONFLICT                   = 1,                    // System cannot run because of configuration conflicts.
    GO2_SYSTEM_STATE_READY                      = 2,                    // System is currently stopped, but is ready to run.
    GO2_SYSTEM_STATE_RUNNING                    = 3                     // System is running.
} Go2SystemState;                                                       // Represents the state of the sensor system.

typedef enum Go2StateIndex
{
    GO2_STATE_INDEX_SYSTEM                      = 0,                    // System state. Please refer to Go2SystemState for the represented values.
    GO2_STATE_INDEX_CALIBRATION                 = 1,                    // Calibration state. Please refer to Go2CalibrationState to decode the values.
    GO2_STATE_INDEX_RECORDING                   = 2,                    // Recording state. It will have a value of 0 if disabled and 1 if enabled.
    GO2_STATE_INDEX_DATA_SOURCE                 = 3                     // Playback data source. It will have a value of 0 if the data is live and 1 if the data is from a recording.
} Go2StateIndex;                                                        // Represents the index values for states contained within the array returned by Go2System_GetStates.

typedef enum Go2Changes
{
    GO2_CHANGES_NONE                            = 0x00,                 // No changes - client state is consistent with system state.
    GO2_CHANGES_DEVICE                          = 0x02,                 // One or more devices have come online or gone offline - refresh required.
    GO2_CHANGES_CONNECTION                      = 0x04                  // Client has been disconnected - refresh required.
} Go2Changes;                                                           // Represents changes in the sensor system that require a client refresh.

typedef enum Go2SensorRole
{
    GO2_SENSOR_ROLE_INVALID                     = 0,                    // Invalid role; occurs when control connection is established to buddy. 
    GO2_SENSOR_ROLE_MAIN                        = 1,                    // Main sensor.
    GO2_SENSOR_ROLE_BUDDY                       = 2,                    // Buddy sensor.
    GO2_SENSOR_ROLE_UNASSIGNED                  = 3,                    // Potential buddy sensor, not yet assigned.
    GO2_SENSOR_ROLE_UNAVAILABLE                 = 4                     // Not a potential buddy, already assigned to another pair
} Go2SensorRole;                                                        // Represents the current role of a sensor within a sensor system.

typedef enum Go2SensorPairState
{
    GO2_SENSOR_PAIR_STATE_INVALID              = 0,                     // This sensor is not assigned, or control connection is established to this sensor.
    GO2_SENSOR_PAIR_STATE_CONNECTED            = 1,                     // Pair is connected 
    GO2_SENSOR_PAIR_STATE_MISSING              = 2,                     // Paired sensor is missing
    GO2_SENSOR_PAIR_STATE_ERROR                = 3                      // Error state - can't pair for some reason
} Go2SensorPairState;                                                   // Represents the pair state of a sensor

typedef enum Go2CalibrationState
{
    GO2_CALIBRATION_STATE_NONE                  = 0,                    // Not calibrated
    GO2_CALIBRATION_STATE_AUTO                  = 1,                    // Auto calibration has been completed
    GO2_CALIBRATION_STATE_MANUAL                = 2                     // The transformation file has been manually adjusted
} Go2CalibrationState;                                                  // Represents the calibration status of a sensor system.

typedef enum Go2PlaybackDataSource
{
    GO2_PLAYBACK_DATA_SOURCE_LIVE               = 0,                    // The data source is from a live target
    GO2_PLAYBACK_DATA_SOURCE_RECORDING          = 1                     // The data source is from a recording
} Go2PlaybackDataSource;

typedef enum Go2ReferenceImageState
{
    GO2_REFERENCE_IMAGE_STATE_NONE                  = 0,                // Not set.
    GO2_REFERENCE_IMAGE_STATE_SET                   = 1                 // Set.
} Go2ReferenceImageState;                                               // Represents whether a reference image has been set. Supported only on 2000 series sensors.

typedef enum Go2Mode
{
    GO2_MODE_UNKNOWN,                                                   // Unknown operation mode.
    GO2_MODE_VIDEO,                                                     // Video mode.
    GO2_MODE_RANGE_MEASUREMENT,                                         // Range measurement mode.  Supported only on 1x00 series sensors.
    GO2_MODE_PROFILE_TEMPLATE,                                          // Profile template registration mode.   Supported only on 2x00 series sensors.
    GO2_MODE_PROFILE_MEASUREMENT,                                       // Profile measurement mode.  Supported only on 2x00 series sensors.
    GO2_MODE_PART_TEMPLATE,                                             // Part template registration mode.  Supported only on 2x00 series sensors.
    GO2_MODE_PART_MEASUREMENT,                                          // Part measurement mode.  Supported only on 2x00 and 3x00 series sensors.
    GO2_MODE_RAW_PROFILE,                                               // Raw Profile mode.  Supported only on 2x00 series sensors.
    GO2_MODE_EXPOSURE_CAL,                                              // Exposure calibration mode.
    GO2_MODE_ALIGN_CAL,                                                 // Alignment calibration mode.
    GO2_MODE_TRAVEL_CAL,                                                // Travel calibration mode.
    GO2_MODE_ROLINE,                                                    // Roline mode.  Supported only on specialized sensors.
    GO2_MODE_REFERENCE_IMAGE,                                           // Reference Image mode.
    GO2_MODE_CUSTOM                                                     // Custom mode.  Supported only on sensors utilizing the Gocator Base Library.
} Go2Mode;                                                              /* Represents an operation mode.  
                                                                        */

typedef enum Go2TriggerSource
{   
    GO2_TRIGGER_SOURCE_TIME                     = 0,                    // Trigger on internal clock.
    GO2_TRIGGER_SOURCE_ENCODER                  = 1,                    // Trigger on encoder.
    GO2_TRIGGER_SOURCE_INPUT                    = 2,                    // Trigger on digital input.
    GO2_TRIGGER_SOURCE_SOFTWARE                 = 3                     // Trigger on software messages.
} Go2TriggerSource;                                                     // Represents a trigger source type.

typedef enum Go2EncoderTriggerMode
{   
    GO2_ENCODER_TRIGGER_MODE_TRACK_REVERSE      = 0,                    // Do not reverse trigger. Track reverse motion to prevent repeat forward triggers.
    GO2_ENCODER_TRIGGER_MODE_IGNORE_REVERSE     = 1,                    // Do not reverse trigger. Forward trigger unconditionally.
    GO2_ENCODER_TRIGGER_MODE_BIDIRECTIONAL      = 2                     // Forward and reverse trigger.
} Go2EncoderTriggerMode;                                                // Represents an encoders triggering behavior.

typedef enum Go2FrameRateMaxSource
{
    GO2_FRAME_RATE_MAX_SOURCE_IMAGER            = 0,                    // Limited by the imager's configuration.
    GO2_FRAME_RATE_MAX_SOURCE_PART_DETECTION    = 1                     // Limited by part detection logic.
} Go2FrameRateMaxSource;                                                // Determines what is currently limiting the maximum frame rate.

typedef enum Go2EncoderPeriodMinSource
{
    GO2_ENCODER_PERIOD_MIN_SOURCE_RESOLUTION    = 0,                    // Limited by encoder resolution.
    GO2_ENCODER_PERIOD_MIN_SOURCE_PART_DETECTION= 1                     // Limited by part detection logic.
} Go2EncoderPeriodMinSource;                                            // Determines what is currently limiting the minimum encoder period.

typedef enum Go2SystemDomain
{   
    GO2_SYSTEM_DOMAIN_TIME                      = 0,                    // Base the system on the internal clock.
    GO2_SYSTEM_DOMAIN_ENCODER                   = 1                     // Base the system on the encoder.
} Go2SystemDomain;                                                      // Represents the systems primary synchronization domain

typedef enum Go2Axis
{
    GO2_AXIS_X     = 0,                                                 // X axis.
    GO2_AXIS_Y     = 1,                                                 // Y axis.
    GO2_AXIS_Z     = 2                                                  // Z axis.
} Go2Axis;                                                              // Represents a coordinate axis (X, Y, or Z).

typedef enum Go2Orientation
{
    GO2_ORIENTATION_ISOLATED                    = 0,                    // Isolated sensor orientation.
    GO2_ORIENTATION_WIDE                        = 1,                    // Wide sensor orientation.
    GO2_ORIENTATION_STAGGERED                   = 2,                    // Staggered sensor orientation. Deprecated, sensor will fail to start
    GO2_ORIENTATION_OPPOSITE                    = 3                     // Opposite sensor orientation.
} Go2Orientation;                                                       // Represents a sensor orientation type.

typedef enum Go2CalibrationTarget
{
    GO2_CALIBRATION_TARGET_NONE                 = 0,                    // No calibration target.
    GO2_CALIBRATION_TARGET_DISK                 = 1,                    // Calibration disk.
    GO2_CALIBRATION_TARGET_BAR                  = 2,                    // Calibration bar.
    GO2_CALIBRATION_TARGET_PLATE                = 3                     // Calibration plate.
} Go2CalibrationTarget;                                                 // Represents a calibration target type.

typedef enum Go2CalibrationSource
{
    GO2_CALIBRATION_SOURCE_GLOBAL               = 0,                    // Transformation data is loaded from and saved to a private transformation file.
    GO2_CALIBRATION_SOURCE_LOCAL                = 1                     // Transformation data can be loaded from and saved to pubically downloadable file.
} Go2CalibrationSource;                                                 // Represents the current calibration source/destination.

typedef enum Go2DataSource
{
    GO2_DATA_SOURCE_MAIN                        = 0,                    // Data from Main sensor.
    GO2_DATA_SOURCE_BUDDY                       = 1                     // Data from Buddy sensor.
} Go2DataSource;                                                        // Represents a data source. 

typedef enum Go2PartSource                                           
{
    GO2_PART_SOURCE_TOP                         = 0,                    // Profile data from Top sensor.
    GO2_PART_SOURCE_BOTTOM                      = 1                     // Profile data from Bottom sensor.
} Go2PartSource;                                                        // Represents a part data source.

typedef enum Go2ProfileSource                                           
{
    GO2_PROFILE_SOURCE_MAIN                     = GO2_DATA_SOURCE_MAIN, // Profile data from Main sensor.
    GO2_PROFILE_SOURCE_BUDDY                    = GO2_DATA_SOURCE_BUDDY,// Profile data from Buddy sensor.
    GO2_PROFILE_SOURCE_COMBINED                 = 100                   // Combined data set, dependent on layout.
} Go2ProfileSource;                                                     // Represents a profile data source.

typedef enum Go2RangeSource                                           
{
    GO2_RANGE_SOURCE_MAIN                     = GO2_DATA_SOURCE_MAIN,   // Range data from Main sensor.
    GO2_RANGE_SOURCE_BUDDY                    = GO2_DATA_SOURCE_BUDDY,  // Range data from Buddy sensor.
    GO2_RANGE_SOURCE_BOTH                     = 100                     // Special source option to configure measurements with both ranges
} Go2RangeSource;                                                       // Represents a range data source.

typedef enum Go2VideoSource                                              
{
    GO2_VIDEO_SOURCE_MAIN                       = GO2_DATA_SOURCE_MAIN, // Video data from Main sensor.
    GO2_VIDEO_SOURCE_BUDDY                      = GO2_DATA_SOURCE_BUDDY // Video data from Buddy sensor.
} Go2VideoSource;                                                       // Represents a video data source.

typedef enum Go2DigitalPassMode
{
    GO2_DIGITAL_PASS_MODE_TRUE                  = 0,                    // Digital output is asserted on decision pass.
    GO2_DIGITAL_PASS_MODE_FALSE                 = 1,                    // Digital output is asserted on decision fail.
    GO2_DIGITAL_PASS_MODE_ALWAYS                = 2                     // Digital output is asserted on decision pass or fail.
} Go2DigitalPassMode;                                                   // Represents digital output triggering behavior.

typedef enum Go2AnalogTriggerMode
{
    GO2_ANALOG_TRIGGER_MODE_MEASUREMENT         = 0,                    // Analog output is set based on measurment selected.
    GO2_ANALOG_TRIGGER_MODE_SOFTWARE            = 1                     // Analog output is software controlled
} Go2AnalogTriggerMode;                                                 // Represents Analog output triggering behavior.

typedef enum Go2DigitalSignalType
{
    GO2_DIGITAL_SIGNAL_TYPE_PULSED              = 0,                    // Digital output is pulsed.
    GO2_DIGITAL_SIGNAL_TYPE_CONTINUOUS          = 1                     // Digital output is latched continuously until driven low.
} Go2DigitalSignalType;                                                 // Type of output. Only applies when output is based on measurements.

typedef enum Go2DigitalEvent
{
    GO2_DIGITAL_CONTROL_EVENT_NONE              = 0,                    // Output is disabled.
    GO2_DIGITAL_CONTROL_EVENT_MEASUREMENT       = 1,                    // Output is measurement driven.
    GO2_DIGITAL_CONTROL_EVENT_SOFTWARE          = 2,                    // Output is software driven.
    GO2_DIGITAL_CONTROL_EVENT_CALIBRATION       = 3,                    // Output represents the calibration state. Scheduling is disabled.
    GO2_DIGITAL_CONTROL_EVENT_EXPOSURE          = 4                     // Output triggers on exposure.
} Go2DigitalEvent;                                                      // Represents the event which triggers this output.

typedef enum Go2AnalogEvent
{
    GO2_ANALOG_CONTROL_EVENT_MEASURMENT         = 1,                    // Output is measurement driven.
    GO2_ANALOG_CONTROL_EVENT_SOFTWARE           = 2                     // Output is software driven.
} Go2AnalogEvent;                                                       // Represents the event which triggers this output.

typedef enum Go2EthernetProtocol
{
    GO2_ETHERNET_PROTOCOL_GOCATOR               = 0,                    // Ethernet follows Gocator protocol
    GO2_ETHERNET_PROTOCOL_MODBUS                = 1,                    // Ethernet follows modbus protocol
    GO2_ETHERNET_PROTOCOL_ETHERNET_IP           = 2,                    // Ethernet follows EtherNet/IP protocol
    GO2_ETHERNET_PROTOCOL_ASCII                 = 3                     // Ethernet follows ASCII protocol
} Go2EthernetProtocol;                                                  // Represents the protocol followed on the ethernet

typedef enum Go2SerialProtocol
{
    GO2_SERIAL_PROTOCOL_GOCATOR                 = 0,                    // Serial follows Gocator protocol. Deprecated.
    GO2_SERIAL_PROTOCOL_SELCOM                  = 1,                    // Serial follows Selcom protocol. Supported only on 1x00 and 2300 series sensors.
    GO2_SERIAL_PROTOCOL_ASCII                   = 2                     // Serial follows ASCII protocol.
} Go2SerialProtocol;                                                    // Represents the protocol followed on the serial output

typedef enum Go2SelcomFormat
{
    GO2_SELCOM_FORMAT_SLS                       = 0,                    // Selcom uses the SLS format
    GO2_SELCOM_FORMAT_12BIT_ST                  = 1,                    // Selcom uses the 12-Bit Search/Track format
    GO2_SELCOM_FORMAT_14BIT                     = 2,                    // Selcom uses the 14-Bit format
    GO2_SELCOM_FORMAT_14BIT_ST                  = 3                     // Selcom uses the 14-Bit Search/Track format
} Go2SelcomFormat;                                                      // Represents the selcom format followed on the serial output

typedef enum Go2AsciiOperation
{
    GO2_ASCII_ASYNCHRONOUS                      = 0,                    // ASCII protocol sends data asynchronously
    GO2_ASCII_POLLING                           = 1                     // ASCII protocol requires polling
} Go2AsciiOperation;                                                    // Represents the operation used by ASCII protocol

typedef enum Go2OutputDataSourceType
{
    GO2_OUTPUT_DATA_SOURCE_TYPE_NONE                    = 0,            // No output source.
    GO2_OUTPUT_DATA_SOURCE_TYPE_PROFILE                 = 1,            // Output source is profile data.  Supported only on 2x00 series sensors.
    GO2_OUTPUT_DATA_SOURCE_TYPE_PART                    = 2,            // Output source is part data.  Supported only on 2x00 and 3x00 series sensors.
    GO2_OUTPUT_DATA_SOURCE_TYPE_VIDEO                   = 3,            // Output source is video data.
    GO2_OUTPUT_DATA_SOURCE_TYPE_VALUE                   = 4,            // Output source is measurement value data.
    GO2_OUTPUT_DATA_SOURCE_TYPE_DECISION                = 5,            // Output source is measurement decision data.
    GO2_OUTPUT_DATA_SOURCE_TYPE_RAW_PROFILE             = 6,            // Output source is raw profile data.  Supported only on 2x00 series sensors.
    GO2_OUTPUT_DATA_SOURCE_TYPE_PROFILE_INTENSITY       = 7,            // Output source is profile intensity data.  Supported only on 2x00 series sensors.
    GO2_OUTPUT_DATA_SOURCE_TYPE_RAW_PROFILE_INTENSITY   = 8,            // Output source is raw profile intensity data.  Supported only on 2x00 series sensors.
    GO2_OUTPUT_DATA_SOURCE_TYPE_PART_INTENSITY          = 9,            // Output source is part intensity data.  Supported only on 2x00 series sensors.
    GO2_OUTPUT_DATA_SOURCE_TYPE_RANGE                   = 10,           // Output source is range data.  Supported only on 1x00 series sensors.
    GO2_OUTPUT_DATA_SOURCE_TYPE_RANGE_INTENSITY         = 11            // Output source is range intensity data.  Supported only on 1x00 series sensors.
} Go2OutputDataSourceType;                                              // Represents the type of output data source.

typedef enum Go2ConnectionType
{
    GO2_CONNECTION_TYPE_STANDALONE              = 0,                    // No Master (open wire).
    GO2_CONNECTION_TYPE_MASTER_100              = 1,                    // Master 100.
    GO2_CONNECTION_TYPE_MASTER_200              = 2,                    // Master 200.
    GO2_CONNECTION_TYPE_MASTER_400              = 3,                    // Master 400.
    GO2_CONNECTION_TYPE_MASTER_800              = 4,                    // Master 800.
    GO2_CONNECTION_TYPE_MASTER_1200             = 5,                    // Master 1200.
    GO2_CONNECTION_TYPE_MASTER_2400             = 6                     // Master 2400.
} Go2ConnectionType;                                                    // Represents the type of system interconnection. 

typedef enum Go2ResamplingType
{
    GO2_RESAMPLING_TYPE_MAX_RES                 = 0,                    // Resample with the smallest spacing.
    GO2_RESAMPLING_TYPE_BALANCED                = 1,                    // Resample with the mean of the smallest and largest spacing.
    GO2_RESAMPLING_TYPE_MAX_SPEED               = 2                     // Resample with the largest spacing.
} Go2ResamplingType;                                                    // Represents resampling behavior

typedef enum Go2Side
{
    GO2_SIDE_LEFT                               = 0,                    // Left side
    GO2_SIDE_RIGHT                              = 1                     // Right Side
} Go2Side;                                                              // Abstract representation of sides

typedef enum Go2SpotDetectionType
{
    GO2_SPOT_SELECTION_TYPE_NORMAL              = 0,                    // Detect spots using the normal spot detection algorithm
    GO2_SPOT_SELECTION_TYPE_XLINE               = 1                     // Detect spots using the XLine algorithm
} Go2SpotDetectionType;                                                 // Represents the algorithm used to detect spots

typedef enum Go2SpotSelectionType
{
    GO2_SPOT_SELECTION_TYPE_INTENSITY           = 0,                    // Select the most intense spot
    GO2_SPOT_SELECTION_TYPE_MIN_ROW             = 1,                    // Select the spot at the minimum imager row
    GO2_SPOT_SELECTION_TYPE_MAX_ROW             = 2                     // Select the spot at the maximum imager row
} Go2SpotSelectionType;                                                 // Represents the algorithm used to select spots

/*
 * Maximum number of multiple exposure steps
 */
#define GO2_MAX_EXPOSURES       (5)

/* 
 * Structures
 */

typedef struct Go2AddressInfo
{   
    Go2Bool useDhcp;                                                    // Gocator sensor uses DHCP?
    Go2IPAddress address;                                               // Gocator sensor IP address setting.
    Go2IPAddress mask;                                                  // Gocator sensor IP mask setting.
    Go2IPAddress gateway;                                               // Gocator sensor IP gateway setting.
} Go2AddressInfo;                                                       // Network address settings for a sensor.

/* 
 * Macros
 */

#define GO2_SUCCESS(EXPRESSION)                zGO2_SUCCESS(EXPRESSION) //
//Converts a Go2Status value to a Go2Bool value (GO2_OK becomes GO2_TRUE, otherwise GO2_FALSE).

#define GO2_CHECK(EXPRESSION)                  zGO2_CHECK(EXPRESSION) // 
//If the expression result is not GO2_OK, the current function will return the expression result.

#define GO2_COUNT(ARRAY)                       zGO2_COUNT(ARRAY) //
// Reports number of elements in a C array.

/* 
 * Functions
 */

GO2_EXPORT(Go2Status) Go2Api_Initialize(); //
//
//  Description:
//      Initializes the Go2 library. 
//  Returns: 
//       Operation status.
//  Remarks:
//      This function must be called prior to calling any other Go2 API functions. If Go2_Initialize 
//      is successful, then Go2_Terminate should be called at a later point to shutdown the Go2 API.

GO2_EXPORT(Go2Status) Go2Api_Terminate(); //
//
//  Description:
//      Uninitializes the Go2 library. 
//  Returns: 
//      Operation status. 
//  Remarks:
//      If Go2_Initialize was successful, then Go2_Terminate should be called at a later point to 
//      shutdown the Go2 API.  

GO2_EXPORT(Go2Version) Go2Api_Version(); //
//
//  Description:
//      Gets the version of the Go2 library. 
//  Returns: 
//      Version number.

GO2_EXPORT(Go2Version) Go2Version_Create(Go2UInt32 major, Go2UInt32 minor, Go2UInt32 release, Go2UInt32 build); //
//
//  Description:
//      Creates a version number from its components.
//  Arguments:
//      major - Major component of version number. 
//      minor - Minor component of version number. 
//      release - Release component of version number. 
//      build - Build component of version number. 
//  Returns: 
//      Version number.

GO2_EXPORT(Go2UInt8) Go2Version_Major(Go2Version version); //
//
//  Description:
//      Gets the major part of a version number.
//  Arguments:
//      version - Version number. 
//  Returns: 
//      Major component of version number.

GO2_EXPORT(Go2UInt8) Go2Version_Minor(Go2Version version); //
//
//  Description:
//      Gets the minor part of a version number.
//  Arguments:
//      version - Version number. 
//  Returns: 
//      Minor component of version number.

GO2_EXPORT(Go2UInt8) Go2Version_Release(Go2Version version); //
//
//  Description:
//      Gets the release part of a version number.
//  Arguments:
//      version - Version number. 
//  Returns: 
//      Release component of version number.

GO2_EXPORT(Go2UInt8) Go2Version_Build(Go2Version version); //
//
//  Description:
//      Gets the build part of a version number.
//  Arguments:
//      version - Version number. 
//  Returns: 
//      Build component of version number.

GO2_EXPORT(Go2Status) Go2IPAddress_Parse(const Go2Char* text, Go2IPAddress* address); //
//
//  Description:
//      Parses a string in dotted-quad format (e.g. "90.0.0.10") to extract an IPv4 address. 
//  Arguments:
//      text - A string in dotted-quad format. 
//      address - Returns an IP address. 
//  Returns: 
//      Operation status.

GO2_EXPORT(Go2Status) Go2IPAddress_Format(Go2IPAddress address, Go2Char* text, Go2UInt32 capacity); //
//
//  Description:
//      Formats an IPv4 address as a string in dotted-quad format. 
//  Arguments:
//      address - An IP address. 
//      text - Returns a formatted string.
//  Returns: 
//      Operation status.

GO2_EXPORT(Go2Status) Go2Free(void* memory); //
//
//  Description:
//      Frees a block of memory that was allocated and returned by the Go2 library.
//  Arguments:
//      memory - The block of memory to be freed, or GO2_NULL.
//  Returns: 
//      Operation status. 


/*
 * Macro implementation details.
 */

#define zGO2_SUCCESS(EXPRESSION)                                        \
    ((Go2Status)(EXPRESSION) > 0)

#define zGO2_CHECK(EXPRESSION)                                          \
    do                                                                  \
    {                                                                   \
        Go2Status Go2Status_VAR = (Go2Status)(EXPRESSION);              \
        if (!zGO2_SUCCESS(Go2Status_VAR))                               \
        {                                                               \
            return Go2Status_VAR;                                       \
        }                                                               \
    } while(0)


#define zGO2_COUNT(ARRAY)                                               \
    (sizeof(ARRAY)/sizeof(ARRAY[0]))  


#include <Go2ApiEnd.h>

#endif          /* #ifndef LMITECH_GO2_API_H_INCLUDED */

