/*
 * Go2DataTypes.c
 * 
 * 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.
 */
#include <z/zGo2DataTypes.h>
#include <string.h>

/*
 * Go2VideoData Class 
 */

GO2_EXPORT(Go2Status) Go2VideoData_Construct(Go2VideoData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2VideoData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2VideoDataClass))); 

    if (!zSUCCESS(status = Go2VideoData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
    }

    *data = output; 

    return status; 
}

GO2_EXPORT(Go2Status) Go2VideoData_Init(Go2VideoData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2VideoDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_VIDEO_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_VIDEO_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2UInt32) Go2VideoData_Source(Go2VideoData data)
{
    Go2VideoDataClass* obj = zHANDLE_POINTER(data);
    return (Go2UInt32) obj->attributes[GO2_VIDEO_DATA_ATTRIBUTE_SOURCE]; 
}

GO2_EXPORT(Go2UInt32) Go2VideoData_Height(Go2VideoData data)
{
    Go2VideoDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemLength(obj->parent, obj->dataOffset, 0); 
}

GO2_EXPORT(Go2UInt32) Go2VideoData_Width(Go2VideoData data)
{
    Go2VideoDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemLength(obj->parent, obj->dataOffset, 1); 
}

GO2_EXPORT(Go2UInt32) Go2VideoData_CameraIndex(Go2VideoData data)
{
    Go2VideoDataClass* obj = zHANDLE_POINTER(data);
    return (Go2UInt32) obj->attributes[GO2_VIDEO_DATA_ATTRIBUTE_CAMERA_INDEX]; 
}

GO2_EXPORT(Go2UInt32) Go2VideoData_ExposureIndex(Go2VideoData data)
{
    Go2VideoDataClass* obj = zHANDLE_POINTER(data);
    return (Go2UInt32) obj->attributes[GO2_VIDEO_DATA_ATTRIBUTE_EXPOSURE_INDEX]; 
}

GO2_EXPORT(Go2Double) Go2VideoData_Exposure(Go2VideoData data)
{
    Go2VideoDataClass* obj = zHANDLE_POINTER(data);
    return (Go2Double)GO2_DATA_US_TO_MS(obj->attributes[GO2_VIDEO_DATA_ATTRIBUTE_EXPOSURE]); 
}

GO2_EXPORT(Go2UInt8*) Go2VideoData_PixelsAt(Go2VideoData data, Go2UInt32 rowIndex)
{
    Go2VideoDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemAt(obj->parent, obj->dataOffset, rowIndex, 0, 0); 
}


/*
 * Go2RangeData Class 
 */

GO2_EXPORT(Go2Status) Go2RangeData_Construct(Go2RangeData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2RangeData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2RangeDataClass))); 

    if (!zSUCCESS(status = Go2RangeData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2RangeData_Init(Go2RangeData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2RangeDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_RANGE_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_RANGE_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2DataSource) Go2RangeData_Source(Go2RangeData data)
{
    Go2RangeDataClass* obj = zHANDLE_POINTER(data);
    return (Go2DataSource) obj->attributes[GO2_RANGE_DATA_ATTRIBUTE_SOURCE]; 
}

GO2_EXPORT(Go2Double) Go2RangeData_ZResolution(Go2RangeData data)
{
    Go2RangeDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_RANGE_DATA_ATTRIBUTE_Z_RESOLUTION]); 
}

GO2_EXPORT(Go2Double) Go2RangeData_ZOffset(Go2RangeData data)
{
    Go2RangeDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_RANGE_DATA_ATTRIBUTE_Z_OFFSET]); 
}

GO2_EXPORT(Go2Double) Go2RangeData_Exposure(Go2RangeData data)
{
    Go2RangeDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_US_TO_MS(obj->attributes[GO2_RANGE_DATA_ATTRIBUTE_EXPOSURE]); 
}

GO2_EXPORT(Go2Int16) Go2RangeData_Range(Go2RangeData data)
{
    Go2RangeDataClass* obj = zHANDLE_POINTER(data);
    return *(Go2Int16*) zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0); 
}



/*
 * Go2RangeIntensityData Class 
 */

GO2_EXPORT(Go2Status) Go2RangeIntensityData_Construct(Go2RangeIntensityData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2RangeIntensityData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2RangeIntensityDataClass))); 

    if (!zSUCCESS(status = Go2RangeIntensityData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2RangeIntensityData_Init(Go2RangeIntensityData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2RangeIntensityDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_RANGE_INTENSITY_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_RANGE_INTENSITY_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2DataSource) Go2RangeIntensityData_Source(Go2RangeIntensityData data)
{
    Go2RangeIntensityDataClass* obj = zHANDLE_POINTER(data);
    return (Go2DataSource) obj->attributes[GO2_RANGE_INTENSITY_DATA_ATTRIBUTE_SOURCE]; 
}

GO2_EXPORT(Go2UInt8) Go2RangeIntensityData_Value(Go2RangeIntensityData data)
{
    Go2RangeIntensityDataClass* obj = zHANDLE_POINTER(data);
    return *(Go2UInt8*) zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0); 
}


/*
 * Go2ProfileData Class 
 */

GO2_EXPORT(Go2Status) Go2ProfileData_Construct(Go2ProfileData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2ProfileData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2ProfileDataClass))); 

    if (!zSUCCESS(status = Go2ProfileData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ProfileData_Init(Go2ProfileData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2ProfileDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_PROFILE_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_PROFILE_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2ProfileSource) Go2ProfileData_Source(Go2ProfileData data)
{
    Go2ProfileDataClass* obj = zHANDLE_POINTER(data);
    return (Go2ProfileSource) obj->attributes[GO2_PROFILE_DATA_ATTRIBUTE_SOURCE]; 
}

GO2_EXPORT(Go2Double) Go2ProfileData_XResolution(Go2ProfileData data)
{
    Go2ProfileDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_PROFILE_DATA_ATTRIBUTE_X_RESOLUTION]); 
}

GO2_EXPORT(Go2Double) Go2ProfileData_ZResolution(Go2ProfileData data)
{
    Go2ProfileDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_PROFILE_DATA_ATTRIBUTE_Z_RESOLUTION]); 
}

GO2_EXPORT(Go2Double) Go2ProfileData_XOffset(Go2ProfileData data)
{
    Go2ProfileDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_PROFILE_DATA_ATTRIBUTE_X_OFFSET]); 
}

GO2_EXPORT(Go2Double) Go2ProfileData_ZOffset(Go2ProfileData data)
{
    Go2ProfileDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_PROFILE_DATA_ATTRIBUTE_Z_OFFSET]); 
}

GO2_EXPORT(Go2Double) Go2ProfileData_Exposure(Go2ProfileData data)
{
    Go2ProfileDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_US_TO_MS(obj->attributes[GO2_PROFILE_DATA_ATTRIBUTE_EXPOSURE]); 
}

GO2_EXPORT(Go2UInt32) Go2ProfileData_Width(Go2ProfileData data)
{
    Go2ProfileDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemLength(obj->parent, obj->dataOffset, 0); 
}

GO2_EXPORT(Go2Int16*) Go2ProfileData_Ranges(Go2ProfileData data)
{
    Go2ProfileDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0); 
}



/*
 * Go2RawProfileData Class 
 */

GO2_EXPORT(Go2Status) Go2RawProfileData_Construct(Go2RawProfileData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2RawProfileData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2RawProfileDataClass))); 

    if (!zSUCCESS(status = Go2RawProfileData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2RawProfileData_Init(Go2RawProfileData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2RawProfileDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_RAW_PROFILE_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_RAW_PROFILE_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2ProfileSource) Go2RawProfileData_Source(Go2RawProfileData data)
{
    Go2RawProfileDataClass* obj = zHANDLE_POINTER(data);
    return (Go2ProfileSource) obj->attributes[GO2_RAW_PROFILE_DATA_ATTRIBUTE_SOURCE]; 
}

GO2_EXPORT(Go2Double) Go2RawProfileData_XResolution(Go2RawProfileData data)
{
    Go2RawProfileDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_RAW_PROFILE_DATA_ATTRIBUTE_X_RESOLUTION]); 
}

GO2_EXPORT(Go2Double) Go2RawProfileData_ZResolution(Go2RawProfileData data)
{
    Go2RawProfileDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_RAW_PROFILE_DATA_ATTRIBUTE_Z_RESOLUTION]); 
}

GO2_EXPORT(Go2Double) Go2RawProfileData_XOffset(Go2RawProfileData data)
{
    Go2RawProfileDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_RAW_PROFILE_DATA_ATTRIBUTE_X_OFFSET]); 
}

GO2_EXPORT(Go2Double) Go2RawProfileData_ZOffset(Go2RawProfileData data)
{
    Go2RawProfileDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_RAW_PROFILE_DATA_ATTRIBUTE_Z_OFFSET]); 
}

GO2_EXPORT(Go2Double) Go2RawProfileData_Exposure(Go2RawProfileData data)
{
    Go2RawProfileDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_US_TO_MS(obj->attributes[GO2_RAW_PROFILE_DATA_ATTRIBUTE_EXPOSURE]); 
}

GO2_EXPORT(Go2UInt32) Go2RawProfileData_Width(Go2RawProfileData data)
{
    Go2RawProfileDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemLength(obj->parent, obj->dataOffset, 0); 
}

GO2_EXPORT(Go2Int16*) Go2RawProfileData_Ranges(Go2RawProfileData data)
{
    Go2RawProfileDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0); 
}


/*
 * Go2ProfileIntensityData Class 
 */

GO2_EXPORT(Go2Status) Go2ProfileIntensityData_Construct(Go2ProfileIntensityData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2ProfileIntensityData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2ProfileIntensityDataClass))); 

    if (!zSUCCESS(status = Go2ProfileIntensityData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ProfileIntensityData_Init(Go2ProfileIntensityData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2ProfileIntensityDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_PROFILE_INTENSITY_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_PROFILE_INTENSITY_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2ProfileSource) Go2ProfileIntensityData_Source(Go2ProfileIntensityData data)
{
    Go2ProfileIntensityDataClass* obj = zHANDLE_POINTER(data);
    return (Go2ProfileSource) obj->attributes[GO2_PROFILE_INTENSITY_DATA_ATTRIBUTE_SOURCE]; 
}

GO2_EXPORT(Go2UInt32) Go2ProfileIntensityData_Width(Go2ProfileIntensityData data)
{
    Go2ProfileIntensityDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemLength(obj->parent, obj->dataOffset, 0); 
}

GO2_EXPORT(Go2UInt8*) Go2ProfileIntensityData_Values(Go2ProfileIntensityData data)
{
    Go2ProfileIntensityDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0); 
}


/*
 * Go2RawProfileIntensityData Class 
 */

GO2_EXPORT(Go2Status) Go2RawProfileIntensityData_Construct(Go2RawProfileIntensityData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2RawProfileIntensityData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2RawProfileIntensityDataClass))); 

    if (!zSUCCESS(status = Go2RawProfileIntensityData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2RawProfileIntensityData_Init(Go2RawProfileIntensityData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2RawProfileIntensityDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_RAW_PROFILE_INTENSITY_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_RAW_PROFILE_INTENSITY_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2ProfileSource) Go2RawProfileIntensityData_Source(Go2RawProfileIntensityData data)
{
    Go2RawProfileIntensityDataClass* obj = zHANDLE_POINTER(data);
    return (Go2ProfileSource) obj->attributes[GO2_RAW_PROFILE_INTENSITY_DATA_ATTRIBUTE_SOURCE]; 
}

GO2_EXPORT(Go2UInt32) Go2RawProfileIntensityData_Width(Go2RawProfileIntensityData data)
{
    Go2RawProfileIntensityDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemLength(obj->parent, obj->dataOffset, 0); 
}

GO2_EXPORT(Go2UInt8*) Go2RawProfileIntensityData_Values(Go2RawProfileIntensityData data)
{
    Go2RawProfileIntensityDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0); 
}


/*
 * Go2PartData Class 
 */

GO2_EXPORT(Go2Status) Go2PartData_Construct(Go2PartData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2PartData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2PartDataClass))); 

    if (!zSUCCESS(status = Go2PartData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2PartData_Init(Go2PartData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2PartDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_PART_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_PART_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2PartSource) Go2PartData_Source(Go2PartData data)
{
    Go2PartDataClass* obj = zHANDLE_POINTER(data);
    return (Go2PartSource) obj->attributes[GO2_PART_DATA_ATTRIBUTE_SOURCE]; 
}

GO2_EXPORT(Go2Double) Go2PartData_XResolution(Go2PartData data)
{
    Go2PartDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_PART_DATA_ATTRIBUTE_X_RESOLUTION]); 
}

GO2_EXPORT(Go2Double) Go2PartData_YResolution(Go2PartData data)
{
    Go2PartDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_PART_DATA_ATTRIBUTE_Y_RESOLUTION]); 
}

GO2_EXPORT(Go2Double) Go2PartData_ZResolution(Go2PartData data)
{
    Go2PartDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_PART_DATA_ATTRIBUTE_Z_RESOLUTION]); 
}

GO2_EXPORT(Go2Double) Go2PartData_XOffset(Go2PartData data)
{
    Go2PartDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_PART_DATA_ATTRIBUTE_X_OFFSET]); 
}

GO2_EXPORT(Go2Double) Go2PartData_YOffset(Go2PartData data)
{
    Go2PartDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_PART_DATA_ATTRIBUTE_Y_OFFSET]); 
}

GO2_EXPORT(Go2Double) Go2PartData_ZOffset(Go2PartData data)
{
    Go2PartDataClass* obj = zHANDLE_POINTER(data);
    return GO2_DATA_NM_TO_MM(obj->attributes[GO2_PART_DATA_ATTRIBUTE_Z_OFFSET]); 
}

GO2_EXPORT(Go2UInt32) Go2PartData_Length(Go2PartData data)
{
    Go2PartDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemLength(obj->parent, obj->dataOffset, 0); 
}

GO2_EXPORT(Go2UInt32) Go2PartData_Width(Go2PartData data)
{
    Go2PartDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemLength(obj->parent, obj->dataOffset, 1); 
}

GO2_EXPORT(Go2Int16*) Go2PartData_RangesAt(Go2PartData data, Go2UInt32 rowIndex)
{
    Go2PartDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemAt(obj->parent, obj->dataOffset, rowIndex, 0, 0); 
}


/*
 * Go2PartIntensityData Class 
 */

GO2_EXPORT(Go2Status) Go2PartIntensityData_Construct(Go2PartIntensityData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2PartIntensityData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2PartIntensityDataClass))); 

    if (!zSUCCESS(status = Go2PartIntensityData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2PartIntensityData_Init(Go2PartIntensityData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2PartIntensityDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_PART_INTENSITY_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_PART_INTENSITY_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2PartSource) Go2PartIntensityData_Source(Go2PartIntensityData data)
{
    Go2PartIntensityDataClass* obj = zHANDLE_POINTER(data);
    return (Go2ProfileSource) obj->attributes[GO2_RAW_PROFILE_INTENSITY_DATA_ATTRIBUTE_SOURCE]; 
}

GO2_EXPORT(Go2UInt32) Go2PartIntensityData_Width(Go2PartIntensityData data)
{
    Go2PartIntensityDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemLength(obj->parent, obj->dataOffset, 1); 
}

GO2_EXPORT(Go2UInt32) Go2PartIntensityData_Length(Go2PartIntensityData data)
{
    Go2PartIntensityDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemLength(obj->parent, obj->dataOffset, 0); 
}

GO2_EXPORT(Go2UInt8*) Go2PartIntensityData_ValuesAt(Go2PartIntensityData data, Go2UInt32 rowIndex)
{
    Go2PartIntensityDataClass* obj = zHANDLE_POINTER(data);
    return zResult_ItemAt(obj->parent, obj->dataOffset, rowIndex, 0, 0); 
}


/*
 * Go2AlignmentData Class 
 */

GO2_EXPORT(Go2Status) Go2AlignmentData_Construct(Go2AlignmentData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2AlignmentData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2AlignmentDataClass))); 

    if (!zSUCCESS(status = Go2AlignmentData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2AlignmentData_Init(Go2AlignmentData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2AlignmentDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_ALIGNMENT_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_ALIGNMENT_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2AlignmentData_Status(Go2AlignmentData data)
{
    Go2AlignmentDataClass* obj = zHANDLE_POINTER(data);
    z64s* result = zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0); 
    return zIS_NULL(result) ? zERROR : (Go2Status) *result; 
}

/*
 * Go2TravelData Class 
 */

GO2_EXPORT(Go2Status) Go2TravelData_Construct(Go2TravelData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2TravelData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2TravelDataClass))); 

    if (!zSUCCESS(status = Go2TravelData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2TravelData_Init(Go2TravelData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2TravelDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_TRAVEL_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_TRAVEL_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2TravelData_Status(Go2TravelData data)
{
    Go2TravelDataClass* obj = zHANDLE_POINTER(data);
    z64s* result = zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0); 
    return zIS_NULL(result) ? zERROR : (Go2Status) *result; 
}


/*
 * Go2ReferenceImageData Class 
 */

GO2_EXPORT(Go2Status) Go2ReferenceImageData_Construct(Go2ReferenceImageData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2ReferenceImageData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2ReferenceImageDataClass))); 

    if (!zSUCCESS(status = Go2ReferenceImageData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ReferenceImageData_Init(Go2ReferenceImageData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2ReferenceImageDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_REFERENCE_IMAGE_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_REFERENCE_IMAGE_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ReferenceImage_State(Go2ReferenceImageData data)
{
    Go2ReferenceImageDataClass* obj = zHANDLE_POINTER(data);
    z64s* result = zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0); 
    return zIS_NULL(result) ? zERROR : (Go2Status) *result; 
}

/*
 * Go2ProfileTemplateData Class 
 */

GO2_EXPORT(Go2Status) Go2ProfileTemplateData_Construct(Go2ProfileTemplateData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2ProfileTemplateData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2ProfileTemplateDataClass))); 

    if (!zSUCCESS(status = Go2ProfileTemplateData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ProfileTemplateData_Init(Go2ProfileTemplateData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2ProfileTemplateDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_PROFILE_TEMPLATE_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_PROFILE_TEMPLATE_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ProfileTemplateData_Status(Go2ProfileTemplateData data)
{
    Go2ProfileTemplateDataClass* obj = zHANDLE_POINTER(data);
    z64s* result = zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0); 
    return zIS_NULL(result) ? zERROR : (Go2Status) *result; 
}


/*
 * Go2ExposureData Class 
 */

GO2_EXPORT(Go2Status) Go2ExposureData_Construct(Go2ExposureData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2ExposureData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2ExposureDataClass))); 

    if (!zSUCCESS(status = Go2ExposureData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ExposureData_Init(Go2ExposureData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2ExposureDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_EXPOSURE_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_EXPOSURE_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ExposureData_Status(Go2ExposureData data)
{
    Go2ExposureDataClass* obj = zHANDLE_POINTER(data);
    z64s* result = zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0); 
    return zIS_NULL(result) ? zERROR : (Go2Status) *result; 
}

GO2_EXPORT(Go2Double) Go2ExposureData_Value(Go2ExposureData data)
{
    Go2ExposureDataClass* obj = zHANDLE_POINTER(data);
    Go2UInt32* result = zResult_ItemAt(obj->parent, obj->dataOffset, 1, 0, 0); 
    return GO2_DATA_NS_TO_US(*result); 
}

/*
 * Go2MeasurementData Class 
 */

GO2_EXPORT(Go2Status) Go2MeasurementData_Construct(Go2MeasurementData* data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2MeasurementData output = zNIL; 
    Go2Status status = zOK; 

    zCHECK(zCalloc(&output, 1, sizeof(Go2MeasurementDataClass))); 

    if (!zSUCCESS(status = Go2MeasurementData_Init(output, parent, attrOffset, dataOffset)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *data = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2MeasurementData_Init(Go2MeasurementData data, zResult parent, z32u attrOffset, z32u dataOffset)
{
    Go2MeasurementDataClass* obj = zHANDLE_POINTER(data);
    
    zCHECK(Go2Object_Init(data, GO2_TYPE_MEASUREMENT_DATA)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_MEASUREMENT_DATA_ATTRIBUTE_COUNT); 
    zCHECK(zResult_ItemLength(parent, dataOffset, 0) >= GO2_MEASUREMENT_DATA_ITEM_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2MeasurementType) Go2MeasurementData_Type(Go2MeasurementData data)
{
    Go2MeasurementDataClass* obj = zHANDLE_POINTER(data);
    return (Go2MeasurementType) obj->attributes[GO2_MEASUREMENT_DATA_ATTRIBUTE_MEASUREMENT_TYPE]; 
}

GO2_EXPORT(Go2UInt32) Go2MeasurementData_Source(Go2MeasurementData data)
{
    Go2MeasurementDataClass* obj = zHANDLE_POINTER(data);
    return (Go2MeasurementType) obj->attributes[GO2_MEASUREMENT_DATA_ATTRIBUTE_MEASUREMENT_ID]; 
}

GO2_EXPORT(Go2Bool) Go2MeasurementData_IsValid(Go2MeasurementData data)
{
    Go2MeasurementDataClass* obj = zHANDLE_POINTER(data);
    Go2MeasurementType type = Go2MeasurementData_Type(data); 
    Go2Int64 value = *(z64s*) zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0);    
    return value != z64S_NULL;
}

GO2_EXPORT(Go2Double) Go2MeasurementData_Value(Go2MeasurementData data)
{
    Go2MeasurementDataClass* obj = zHANDLE_POINTER(data);
    Go2MeasurementType type = Go2MeasurementData_Type(data); 
    Go2Int64 value = *(z64s*) zResult_ItemAt(obj->parent, obj->dataOffset, 0, 0, 0); 
    Go2Double scaledValue = 0; 

    switch(type)
    {
    case GO2_MEASUREMENT_TYPE_RANGE_POSITION_Z:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;  
    case GO2_MEASUREMENT_TYPE_RANGE_DIFFERENCE:             scaledValue = GO2_DATA_UM_TO_MM(value);             break; 

    case GO2_MEASUREMENT_TYPE_PROFILE_WIDTH:                scaledValue = GO2_DATA_UM_TO_MM(value);             break;
    case GO2_MEASUREMENT_TYPE_PROFILE_HEIGHT:               scaledValue = GO2_DATA_UM_TO_MM(value);             break;
    case GO2_MEASUREMENT_TYPE_PROFILE_DISTANCE:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;
    case GO2_MEASUREMENT_TYPE_PROFILE_CENTER_X:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_CENTER_Z:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_ANGLE_X:              scaledValue = GO2_DATA_MILLI_DEG_TO_DEG(value);     break;    
    case GO2_MEASUREMENT_TYPE_PROFILE_ISECT_X:              scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_ISECT_Z:              scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_ISECT_ANGLE:          scaledValue = GO2_DATA_MILLI_DEG_TO_DEG(value);     break;    
    case GO2_MEASUREMENT_TYPE_PROFILE_ISECT_AREA:           scaledValue = GO2_DATA_AREA_UNIT_TO_MM2(value);     break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_BOX_AREA:             scaledValue = GO2_DATA_AREA_UNIT_TO_MM2(value);     break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_POSITION_X:           scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_POSITION_Z:           scaledValue = GO2_DATA_UM_TO_MM(value);             break;
    case GO2_MEASUREMENT_TYPE_PROFILE_DIFF_AREA:            scaledValue = GO2_DATA_AREA_UNIT_TO_MM2(value);     break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_DIFF_PEAK:            scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_GAP:                  scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_FLUSH:                scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_CIRCLE_RADIUS:        scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_CIRCLE_X:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_CIRCLE_Z:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;
    case GO2_MEASUREMENT_TYPE_PROFILE_GROOVE_WIDTH:         scaledValue = GO2_DATA_UM_TO_MM(value);             break;  
    case GO2_MEASUREMENT_TYPE_PROFILE_GROOVE_DEPTH:         scaledValue = GO2_DATA_UM_TO_MM(value);             break;  
    case GO2_MEASUREMENT_TYPE_PROFILE_GROOVE_X:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;  
    case GO2_MEASUREMENT_TYPE_PROFILE_GROOVE_Z:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;  
    case GO2_MEASUREMENT_TYPE_PROFILE_LINE_STD_DEV:         scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_LINE_ERROR_MIN:       scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_LINE_ERROR_MAX:       scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PROFILE_LINE_PERCENTILE:      scaledValue = GO2_DATA_UM_TO_MM(value);             break; 
    case GO2_MEASUREMENT_TYPE_PROFILE_BRIDGE_VALUE:         scaledValue = GO2_DATA_UM_TO_MM(value);             break; 
    case GO2_MEASUREMENT_TYPE_PROFILE_STRIP_WIDTH:          scaledValue = GO2_DATA_UM_TO_MM(value);             break; 
    case GO2_MEASUREMENT_TYPE_PROFILE_STRIP_HEIGHT:         scaledValue = GO2_DATA_UM_TO_MM(value);             break; 
    case GO2_MEASUREMENT_TYPE_PROFILE_STRIP_X:              scaledValue = GO2_DATA_UM_TO_MM(value);             break; 
    case GO2_MEASUREMENT_TYPE_PROFILE_STRIP_Z:              scaledValue = GO2_DATA_UM_TO_MM(value);             break; 

    case GO2_MEASUREMENT_TYPE_PART_AREA:                    scaledValue = GO2_DATA_AREA_UNIT_TO_MM2(value);     break; 
    case GO2_MEASUREMENT_TYPE_PART_VOLUME:                  scaledValue = GO2_DATA_VOLUME_UNIT_TO_MM3(value);   break; 
    case GO2_MEASUREMENT_TYPE_PART_HEIGHT:                  scaledValue = GO2_DATA_UM_TO_MM(value);             break;  
    case GO2_MEASUREMENT_TYPE_PART_ELLIPSE_MAJOR:           scaledValue = GO2_DATA_UM_TO_MM(value);             break;  
    case GO2_MEASUREMENT_TYPE_PART_ELLIPSE_MINOR:           scaledValue = GO2_DATA_UM_TO_MM(value);             break;  
    case GO2_MEASUREMENT_TYPE_PART_ELLIPSE_ANGLE:           scaledValue = GO2_DATA_MILLI_DEG_TO_DEG(value);     break;   
    case GO2_MEASUREMENT_TYPE_PART_ELLIPSE_RATIO:           scaledValue = GO2_DATA_MILLI_TO_UNIT(value);        break;  
    case GO2_MEASUREMENT_TYPE_PART_BOUNDING_BOX_X:          scaledValue = GO2_DATA_MILLI_DEG_TO_DEG(value);     break;   
    case GO2_MEASUREMENT_TYPE_PART_BOUNDING_BOX_Y:          scaledValue = GO2_DATA_UM_TO_MM(value);             break;  
    case GO2_MEASUREMENT_TYPE_PART_BOUNDING_BOX_WIDTH:      scaledValue = GO2_DATA_UM_TO_MM(value);             break;  
    case GO2_MEASUREMENT_TYPE_PART_BOUNDING_BOX_LENGTH:     scaledValue = GO2_DATA_MILLI_TO_UNIT(value);        break;  

    case GO2_MEASUREMENT_TYPE_PART_HOLE_X:                  scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_HOLE_Y:                  scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_HOLE_Z:                  scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_HOLE_RADIUS:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_OPENING_X:               scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_OPENING_Y:               scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_OPENING_Z:               scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_OPENING_ANGLE:           scaledValue = GO2_DATA_MILLI_DEG_TO_DEG(value);     break;   
    case GO2_MEASUREMENT_TYPE_PART_OPENING_LENGTH:          scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_OPENING_WIDTH:           scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_PLANE_X_ANGLE:           scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_PLANE_Y_ANGLE:           scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_PLANE_Z_OFFSET:          scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_POSITION_X:              scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_POSITION_Y:              scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_POSITION_Z:              scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_STUD_BASE_X:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_STUD_BASE_Y:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_STUD_BASE_Z:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_STUD_RADIUS:             scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_STUD_TIP_X:              scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_STUD_TIP_Y:              scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_STUD_TIP_Z:              scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_TEXTURE_ROUGHNESS:       scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    case GO2_MEASUREMENT_TYPE_PART_TEXTURE_INVALID_COUNT:   scaledValue = GO2_DATA_UM_TO_MM(value);             break;     
    
    case GO2_MEASUREMENT_TYPE_SCRIPT:                   scaledValue = (Go2Double)value;                     break; 

    default:                                            scaledValue = (Go2Double)value;                     break;
    }

    return scaledValue; 
}

GO2_EXPORT(Go2Bool) Go2MeasurementData_Decision(Go2MeasurementData data)
{
    Go2MeasurementDataClass* obj = zHANDLE_POINTER(data);
    Go2MeasurementType type = Go2MeasurementData_Type(data); 
    Go2Int64 decision = *(z64s*) zResult_ItemAt(obj->parent, obj->dataOffset, 1, 0, 0); 
    return (Go2Bool) decision;  
}

GO2_EXPORT(Go2Status) Go2CustomData_Construct( Go2CustomData* data, zResult parent, z32u attrOffset, z32u dataOffset, z32u customTypeId )
{
    Go2CustomData output = zNIL; 
    Go2Status status = zOK; 

    if (customTypeId < GO2_TYPE_CUSTOM_DATA)
    {
        return GO2_ERROR_PARAMETER;
    }

    zCHECK(zCalloc(&output, 1, sizeof(Go2CustomDataClass))); 

    if (!zSUCCESS(status = Go2CustomData_Init(output, parent, attrOffset, dataOffset, customTypeId)))
    {
        zCHECK(Go2Object_Destroy(output)); 
    }

    *data = output; 

    return status; 
}

GO2_EXPORT(Go2Status) Go2CustomData_Init( Go2CustomData data, zResult parent, z32u attrOffset, z32u dataOffset, z32u customTypeId )
{
    Go2CustomDataClass* obj = zHANDLE_POINTER(data);

    zCHECK(Go2Object_Init(data, customTypeId)); 

    zCHECK(zResult_ItemType(parent, attrOffset) == zTYPE_64S); 
    zCHECK(zResult_ItemLength(parent, attrOffset, 0) >= GO2_CUSTOM_DATA_ATTRIBUTE_COUNT); 

    obj->parent = parent; 
    obj->attrOffset = attrOffset; 
    obj->dataOffset = dataOffset; 
    obj->attributes = zResult_ItemData(parent, attrOffset); 

    return GO2_OK; 
}

GO2_EXPORT(Go2UInt32) Go2CustomData_Width(Go2CustomData data, Go2UInt32 dimension)
{
    Go2CustomDataClass* obj = zHANDLE_POINTER(data);

    return zResult_ItemLength(obj->parent, obj->dataOffset, dimension); 
}

GO2_EXPORT(const Go2Int64*) Go2CustomData_Attributes(Go2CustomData data)
{
    Go2CustomDataClass* obj = zHANDLE_POINTER(data);

    return obj->attributes;
}

GO2_EXPORT(Go2UInt32) Go2CustomData_ItemDimensions(Go2CustomData data, Go2UInt32 itemIndex)
{
    Go2CustomDataClass* obj = zHANDLE_POINTER(data);

    if (zResult_ItemLength(obj->parent, itemIndex, 0) == 0)
    {
        return 0;
    }
    else
    {
        if (zResult_ItemLength(obj->parent, itemIndex, 1) == 0)
        {
            return 1;
        }
        else
        {
            if (zResult_ItemLength(obj->parent, itemIndex, 2) == 0)
            {
                return 2;
            }
            else
            {
                return 3;
            }
        }
    }

    return 0;
}
