/*
 * Go2PartPositionX.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/zGo2PartPositionX.h>
#include <z/zGo2PartTypes.h>
#include <z/zGo2System.h>
#include <string.h>

/*
 * Go2PartPositionX Class 
 */

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

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

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

    *measurement = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2PartPositionX_Init(Go2PartPositionX measurement, Go2UInt32 id, Go2Object system)
{
    Go2PartPositionXClass* obj = zHANDLE_POINTER(measurement);
    
    zCHECK(Go2PartMeasurement_Init(measurement, GO2_TYPE_PART_POSITION_X, id, system)); 

    obj->Release = Go2PartPositionX_VRelease;
    obj->Read = Go2PartPositionX_VRead; 
    obj->Write = Go2PartPositionX_VWrite; 
    
    zCHECK(Go2PartFeature3d_Construct(&obj->feature, system));
    
    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2PartPositionX_VRelease(Go2PartPositionX measurement)
{
    Go2PartPositionXClass* obj = zHANDLE_POINTER(measurement);

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

GO2_EXPORT(Go2Status) Go2PartPositionX_VRead(Go2PartPositionX measurement, zXml xml, zXmlItem item)
{
    Go2PartPositionXClass* 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) Go2PartPositionX_VWrite(Go2PartPositionX  measurement, zXml xml, zXmlItem item)
{
    Go2PartPositionXClass* 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) Go2PartPositionX_SetId(Go2PartPositionX measurement, Go2UInt32 id)
{
    return Go2Measurement_SetId(measurement, id); 
}

GO2_EXPORT(Go2UInt32) Go2PartPositionX_Id(Go2PartPositionX measurement)
{
    return Go2Measurement_Id(measurement); 
}

GO2_EXPORT(Go2Status) Go2PartPositionX_SetName(Go2PartPositionX measurement, const Go2Char* name)
{
    return Go2Measurement_SetName(measurement, name); 
}

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

GO2_EXPORT(Go2Status) Go2PartPositionX_SetDecisionMin(Go2PartPositionX measurement, Go2Double min)
{
    return Go2Measurement_SetDecisionMin(measurement, min); 
}

GO2_EXPORT(Go2Double) Go2PartPositionX_DecisionMin(Go2PartPositionX measurement)
{
    return Go2Measurement_DecisionMin(measurement); 
}

GO2_EXPORT(Go2Status) Go2PartPositionX_SetDecisionMax(Go2PartPositionX measurement, Go2Double max)
{
    return Go2Measurement_SetDecisionMax(measurement, max); 
}

GO2_EXPORT(Go2Double) Go2PartPositionX_DecisionMax(Go2PartPositionX measurement)
{
    return Go2Measurement_DecisionMax(measurement); 
}

GO2_EXPORT(Go2Status) Go2PartPositionX_EnableHold(Go2PartPositionX measurement, Go2Bool enable)
{
    return Go2Measurement_EnableHold(measurement, enable);  
} 

GO2_EXPORT(Go2Bool) Go2PartPositionX_HoldEnabled(Go2PartPositionX measurement)
{
    return Go2Measurement_HoldEnabled(measurement);  
}

GO2_EXPORT(Go2Status) Go2PartPositionX_EnableSmoothing(Go2PartPositionX measurement, Go2Bool enable)
{
    return Go2Measurement_EnableSmoothing(measurement, enable);  
} 

GO2_EXPORT(Go2Bool) Go2PartPositionX_SmoothingEnabled(Go2PartPositionX measurement)
{
    return Go2Measurement_SmoothingEnabled(measurement);  
} 

GO2_EXPORT(Go2UInt32) Go2PartPositionX_SmoothingWindowMin(Go2PartPositionX measurement)
{
    return Go2Measurement_SmoothingWindowMin(measurement);  
} 

GO2_EXPORT(Go2UInt32) Go2PartPositionX_SmoothingWindowMax(Go2PartPositionX measurement)
{
    return Go2Measurement_SmoothingWindowMax(measurement);  
} 

GO2_EXPORT(Go2Status) Go2PartPositionX_SetSmoothingWindow(Go2PartPositionX measurement, Go2UInt32 window)
{
    return Go2Measurement_SetSmoothingWindow(measurement, window);  
} 

GO2_EXPORT(Go2UInt32) Go2PartPositionX_SmoothingWindow(Go2PartPositionX measurement)
{
    return Go2Measurement_SmoothingWindow(measurement);  
} 

GO2_EXPORT(Go2PartFeature3d) Go2PartPositionX_Feature( Go2PartPositionX measurement )
{
    Go2PartPositionXClass* obj = zHANDLE_POINTER(measurement); 
    return obj->feature;      
}

GO2_EXPORT(Go2Status) Go2PartPositionX_SetScale(Go2PartPositionX measurement, Go2Double scale){
    return Go2Measurement_SetScale(measurement, scale);
}

GO2_EXPORT(Go2Double) Go2PartPositionX_Scale(Go2PartPositionX measurement){
    return Go2Measurement_Scale(measurement);
}

GO2_EXPORT(Go2Status) Go2PartPositionX_SetOffset(Go2PartPositionX measurement, Go2Double offset){
    return Go2Measurement_SetOffset(measurement, offset);
}

GO2_EXPORT(Go2Double) Go2PartPositionX_Offset(Go2PartPositionX measurement){
    return Go2Measurement_Offset(measurement);
}

GO2_EXPORT(Go2Status) Go2PartPositionX_EnableLink(Go2PartPositionX measurement, Go2Bool enable)  
{
    return Go2Measurement_EnableLink(measurement, enable);  
}

GO2_EXPORT(Go2Bool) Go2PartPositionX_LinkEnabled(Go2PartPositionX measurement)  
{
    return Go2Measurement_LinkEnabled(measurement);  
}

GO2_EXPORT(Go2Status) Go2PartPositionX_SetLink(Go2PartPositionX measurement, Go2UInt32 link) 
{
    return Go2Measurement_SetLink(measurement, link); 
}

GO2_EXPORT(Go2UInt32) Go2PartPositionX_Link(Go2PartPositionX measurement) 
{
    return Go2Measurement_Link(measurement); 
}

GO2_EXPORT(Go2UInt32) Go2PartPositionX_LinkOptionCount(Go2PartPositionX measurement)
{
    return Go2Measurement_LinkOptionCount(measurement);
}

GO2_EXPORT(Go2UInt32) Go2PartPositionX_LinkOptionAt(Go2PartPositionX measurement, Go2UInt32 index)
{
    return Go2Measurement_LinkOptionAt(measurement, index);
}
