/*
 * Go2PartPositionZ.c
 * 
 * Gocator system communication library
 * Copyright (C) 2013 by LMI Technologies Inc.
 * 
 * Licensed under The MIT License.
 * Redistributions of files must retain the above copyright notice.
 */

#include <z/Go2Measurements/zGo2PartPositionZ.h>
#include <z/zGo2PartTypes.h>
#include <z/zGo2System.h>
#include <string.h>

/*
 * Go2PartPositionZ Class 
 */

GO2_EXPORT(Go2Status) Go2PartPositionZ_Construct(Go2PartPositionZ* measurement, Go2UInt32 id, Go2Object system)
{
    Go2PartPositionZ output = zNIL; 
    Go2Status status = zOK; 

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

    if (!zSUCCESS(status = Go2PartPositionZ_Init(output, id, system)))
    {
        zCHECK(Go2Object_Destroy(output)); 
        return status; 
    }

    *measurement = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_Init(Go2PartPositionZ measurement, Go2UInt32 id, Go2Object system)
{
    Go2PartPositionZClass* obj = zHANDLE_POINTER(measurement);
    
    zCHECK(Go2PartMeasurement_Init(measurement, GO2_TYPE_PART_POSITION_Z, id, system)); 

    obj->Release = Go2PartPositionZ_VRelease;
    obj->Read = Go2PartPositionZ_VRead; 
    obj->Write = Go2PartPositionZ_VWrite; 

    zCHECK(Go2PartFeature3d_Construct(&obj->
        feature, system));
    
    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_VRelease(Go2PartPositionZ measurement)
{
    Go2PartPositionZClass* obj = zHANDLE_POINTER(measurement);

    zCHECK(Go2PartFeature3d_VRelease(obj->feature));
    zCHECK(Go2PartMeasurement_VRelease(measurement));  
        
    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_VRead(Go2PartPositionZ measurement, zXml xml, zXmlItem item)
{
    Go2PartPositionZClass* obj = zHANDLE_POINTER(measurement);
    zXmlItem featureItem = GO2_NULL;

    zCHECK(Go2PartMeasurement_VRead(measurement, xml, item)); 
    
    featureItem = zXml_Child(xml, item, "Feature"); 
    zCHECK(Go2PartFeature3d_Read(obj->feature, xml, featureItem));
    
    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_VWrite(Go2PartPositionZ  measurement, zXml xml, zXmlItem item)
{
    Go2PartPositionZClass* obj = zHANDLE_POINTER(measurement);
    zXmlItem featureItem = GO2_NULL;

    zCHECK(Go2PartMeasurement_VWrite(measurement, xml, item)); 
    zCHECK(zXml_AddItem(xml, item, "Feature", &featureItem));
    zCHECK(Go2PartFeature3d_Write(obj->feature, xml, featureItem));
    
    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_SetId(Go2PartPositionZ measurement, Go2UInt32 id)
{
    return Go2Measurement_SetId(measurement, id); 
}

GO2_EXPORT(Go2UInt32) Go2PartPositionZ_Id(Go2PartPositionZ measurement)
{
    return Go2Measurement_Id(measurement); 
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_SetName(Go2PartPositionZ measurement, const Go2Char* name)
{
    return Go2Measurement_SetName(measurement, name); 
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_Name(Go2PartPositionZ measurement, Go2Char* name, Go2UInt32 capacity)
{
    return Go2Measurement_Name(measurement, name, capacity); 
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_SetDecisionMin(Go2PartPositionZ measurement, Go2Double min)
{
    return Go2Measurement_SetDecisionMin(measurement, min); 
}

GO2_EXPORT(Go2Double) Go2PartPositionZ_DecisionMin(Go2PartPositionZ measurement)
{
    return Go2Measurement_DecisionMin(measurement); 
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_SetDecisionMax(Go2PartPositionZ measurement, Go2Double max)
{
    return Go2Measurement_SetDecisionMax(measurement, max); 
}

GO2_EXPORT(Go2Double) Go2PartPositionZ_DecisionMax(Go2PartPositionZ measurement)
{
    return Go2Measurement_DecisionMax(measurement); 
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_EnableHold(Go2PartPositionZ measurement, Go2Bool enable)
{
    return Go2Measurement_EnableHold(measurement, enable);  
} 

GO2_EXPORT(Go2Bool) Go2PartPositionZ_HoldEnabled(Go2PartPositionZ measurement)
{
    return Go2Measurement_HoldEnabled(measurement);  
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_EnableSmoothing(Go2PartPositionZ measurement, Go2Bool enable)
{
    return Go2Measurement_EnableSmoothing(measurement, enable);  
} 

GO2_EXPORT(Go2Bool) Go2PartPositionZ_SmoothingEnabled(Go2PartPositionZ measurement)
{
    return Go2Measurement_SmoothingEnabled(measurement);  
} 

GO2_EXPORT(Go2UInt32) Go2PartPositionZ_SmoothingWindowMin(Go2PartPositionZ measurement)
{
    return Go2Measurement_SmoothingWindowMin(measurement);  
} 

GO2_EXPORT(Go2UInt32) Go2PartPositionZ_SmoothingWindowMax(Go2PartPositionZ measurement)
{
    return Go2Measurement_SmoothingWindowMax(measurement);  
} 

GO2_EXPORT(Go2Status) Go2PartPositionZ_SetSmoothingWindow(Go2PartPositionZ measurement, Go2UInt32 window)
{
    return Go2Measurement_SetSmoothingWindow(measurement, window);  
} 

GO2_EXPORT(Go2UInt32) Go2PartPositionZ_SmoothingWindow(Go2PartPositionZ measurement)
{
    return Go2Measurement_SmoothingWindow(measurement);  
} 

GO2_EXPORT(Go2PartFeature3d) Go2PartPositionZ_Feature( Go2PartPositionZ measurement )
{
    Go2PartPositionZClass* obj = zHANDLE_POINTER(measurement); 
    return obj->feature;      
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_SetScale(Go2PartPositionZ measurement, Go2Double scale){
    return Go2Measurement_SetScale(measurement, scale);
}

GO2_EXPORT(Go2Double) Go2PartPositionZ_Scale(Go2PartPositionZ measurement){
    return Go2Measurement_Scale(measurement);
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_SetOffset(Go2PartPositionZ measurement, Go2Double offset){
    return Go2Measurement_SetOffset(measurement, offset);
}

GO2_EXPORT(Go2Double) Go2PartPositionZ_Offset(Go2PartPositionZ measurement){
    return Go2Measurement_Offset(measurement);
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_EnableLink(Go2PartPositionZ measurement, Go2Bool enable)  
{
    return Go2Measurement_EnableLink(measurement, enable);  
}

GO2_EXPORT(Go2Bool) Go2PartPositionZ_LinkEnabled(Go2PartPositionZ measurement)  
{
    return Go2Measurement_LinkEnabled(measurement);  
}

GO2_EXPORT(Go2Status) Go2PartPositionZ_SetLink(Go2PartPositionZ measurement, Go2UInt32 link) 
{
    return Go2Measurement_SetLink(measurement, link); 
}

GO2_EXPORT(Go2UInt32) Go2PartPositionZ_Link(Go2PartPositionZ measurement) 
{
    return Go2Measurement_Link(measurement); 
}

GO2_EXPORT(Go2UInt32) Go2PartPositionZ_LinkOptionCount(Go2PartPositionZ measurement)
{
    return Go2Measurement_LinkOptionCount(measurement);
}

GO2_EXPORT(Go2UInt32) Go2PartPositionZ_LinkOptionAt(Go2PartPositionZ measurement, Go2UInt32 index)
{
    return Go2Measurement_LinkOptionAt(measurement, index);
}
