/*
 * Go2RangePositionZ.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/zGo2RangePositionZ.h>
#include <z/zGo2System.h>
#include <string.h>

/*
 * Go2RangePositionZ Class 
 */

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

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

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

    *measurement = output; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_Init(Go2RangePositionZ measurement, Go2UInt32 id, Go2Object system)
{
    Go2RangePositionZClass* obj = zHANDLE_POINTER(measurement);

    zCHECK(Go2Measurement_Init(measurement, GO2_TYPE_RANGE_POSITION_Z, id, system)); 

    obj->Read = Go2RangePositionZ_VRead; 
    obj->Write = Go2RangePositionZ_VWrite; 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_VRead(Go2RangePositionZ measurement, zXml xml, zXmlItem item)
{
    Go2RangePositionZClass* obj = zHANDLE_POINTER(measurement);
    zChar* text = zNULL;
    z32u textCapacity = GO2_MEASUREMENT_SOURCE_TEXT_CAPACITY; 

    zCHECK(Go2Measurement_VRead(measurement, xml, item)); 

    zCHECK(zCalloc(&text, textCapacity, sizeof(zChar)));
    zCHECK(zXml_ChildText(xml, item, "SourceOptions", text, textCapacity)); 
    zCHECK(Go2OptionList_ParseList(text, obj->sourceOptions));  

    zCHECK(zXml_Child32s(xml, item, "Source", &obj->source)); 

    zCHECK(zFree(text));

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_VWrite(Go2RangePositionZ  measurement, zXml xml, zXmlItem item)
{
    Go2RangePositionZClass* obj = zHANDLE_POINTER(measurement);

    zCHECK(Go2Measurement_VWrite(measurement, xml, item)); 

    zCHECK(zXml_SetChild32s(xml, item, "Source", obj->source)); 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_SetId(Go2RangePositionZ measurement, Go2UInt32 id)
{
    return Go2Measurement_SetId(measurement, id); 
}

GO2_EXPORT(Go2UInt32) Go2RangePositionZ_Id(Go2RangePositionZ measurement)
{
    return Go2Measurement_Id(measurement); 
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_SetName(Go2RangePositionZ measurement, const Go2Char* name)
{
    return Go2Measurement_SetName(measurement, name); 
}

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

GO2_EXPORT(Go2UInt32) Go2RangePositionZ_SourceOptionCount(Go2RangePositionZ measurement)
{
    return Go2Measurement_SourceOptionCount(measurement);     
}

GO2_EXPORT(Go2RangeSource) Go2RangePositionZ_SourceOptionAt(Go2RangePositionZ measurement, Go2UInt32 index)
{
    return Go2Measurement_SourceOptionAt(measurement, index);     
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_SetSource(Go2RangePositionZ measurement, Go2RangeSource source)
{
    return Go2Measurement_SetSource(measurement, source);     
}

GO2_EXPORT(Go2RangeSource) Go2RangePositionZ_Source(Go2RangePositionZ measurement)
{
    return Go2Measurement_Source(measurement);     
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_SetDecisionMin(Go2RangePositionZ measurement, Go2Double min)
{
    return Go2Measurement_SetDecisionMin(measurement, min); 
}

GO2_EXPORT(Go2Double) Go2RangePositionZ_DecisionMin(Go2RangePositionZ measurement)
{
    return Go2Measurement_DecisionMin(measurement); 
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_SetDecisionMax(Go2RangePositionZ measurement, Go2Double max)
{
    return Go2Measurement_SetDecisionMax(measurement, max); 
}

GO2_EXPORT(Go2Double) Go2RangePositionZ_DecisionMax(Go2RangePositionZ measurement)
{
    return Go2Measurement_DecisionMax(measurement); 
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_EnableHold(Go2RangePositionZ measurement, Go2Bool enable)
{
    return Go2Measurement_EnableHold(measurement, enable);  
} 

GO2_EXPORT(Go2Bool) Go2RangePositionZ_HoldEnabled(Go2RangePositionZ measurement)
{
    return Go2Measurement_HoldEnabled(measurement);  
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_EnableSmoothing(Go2RangePositionZ measurement, Go2Bool enable)
{
    return Go2Measurement_EnableSmoothing(measurement, enable);  
} 

GO2_EXPORT(Go2Bool) Go2RangePositionZ_SmoothingEnabled(Go2RangePositionZ measurement)
{
    return Go2Measurement_SmoothingEnabled(measurement);  
} 

GO2_EXPORT(Go2UInt32) Go2RangePositionZ_SmoothingWindowMin(Go2RangePositionZ measurement)
{
    return Go2Measurement_SmoothingWindowMin(measurement);  
} 

GO2_EXPORT(Go2UInt32) Go2RangePositionZ_SmoothingWindowMax(Go2RangePositionZ measurement)
{
    return Go2Measurement_SmoothingWindowMax(measurement);  
} 

GO2_EXPORT(Go2Status) Go2RangePositionZ_SetSmoothingWindow(Go2RangePositionZ measurement, Go2UInt32 window)
{
    return Go2Measurement_SetSmoothingWindow(measurement, window);  
} 

GO2_EXPORT(Go2UInt32) Go2RangePositionZ_SmoothingWindow(Go2RangePositionZ measurement)
{
    return Go2Measurement_SmoothingWindow(measurement);  
} 



GO2_EXPORT(Go2Status) Go2RangePositionZ_SetScale(Go2RangePositionZ measurement, Go2Double scale){
    return Go2Measurement_SetScale(measurement, scale);
}

GO2_EXPORT(Go2Double) Go2RangePositionZ_Scale(Go2RangePositionZ measurement){
    return Go2Measurement_Scale(measurement);
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_SetOffset(Go2RangePositionZ measurement, Go2Double offset){
    return Go2Measurement_SetOffset(measurement, offset);
}

GO2_EXPORT(Go2Double) Go2RangePositionZ_Offset(Go2RangePositionZ measurement){
    return Go2Measurement_Offset(measurement);
}

GO2_EXPORT(Go2UInt32) Go2RangePositionZ_LinkOptionCount(Go2RangePositionZ measurement)
{
    return Go2Measurement_LinkOptionCount(measurement);
}

GO2_EXPORT(Go2UInt32) Go2RangePositionZ_LinkOptionAt(Go2RangePositionZ measurement, Go2UInt32 index)
{
    return Go2Measurement_LinkOptionAt(measurement, index);
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_EnableLink(Go2RangePositionZ measurement, Go2Bool enable)  
{
    return Go2Measurement_EnableLink(measurement, enable);  
}

GO2_EXPORT(Go2Bool) Go2RangePositionZ_LinkEnabled(Go2RangePositionZ measurement)  
{
    return Go2Measurement_LinkEnabled(measurement);  
}

GO2_EXPORT(Go2Status) Go2RangePositionZ_SetLink(Go2RangePositionZ measurement, Go2UInt32 link) 
{
    return Go2Measurement_SetLink(measurement, link); 
}

GO2_EXPORT(Go2UInt32) Go2RangePositionZ_Link(Go2RangePositionZ measurement) 
{
    return Go2Measurement_Link(measurement); 
}
