/*
 * Go2ProfileCircleX.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/zGo2ProfileCircleX.h>
#include <z/zGo2ProfileTypes.h>
#include <z/zGo2System.h>
#include <string.h>

/*
 * Go2ProfileCircleX Class 
 */

GO2_EXPORT(Go2Status) Go2ProfileCircleX_Construct(Go2ProfileCircleX* measurement, Go2UInt32 id, Go2Object system)
{
    Go2ProfileCircleX output = zNIL; 
    Go2Status status = GO2_OK; 

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

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

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_Init(Go2ProfileCircleX measurement, Go2UInt32 id, Go2Object system)
{
    Go2ProfileCircleXClass* obj = zHANDLE_POINTER(measurement);

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

    obj->Release = Go2ProfileCircleX_VRelease; 
    obj->Read = Go2ProfileCircleX_VRead; 
    obj->Write = Go2ProfileCircleX_VWrite; 

    zCHECK(Go2ProfileArea_Construct(&obj->area, system));       

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_VRelease(Go2ProfileCircleX measurement)
{
    Go2ProfileCircleXClass* obj = zHANDLE_POINTER(measurement);

    zCHECK(Go2Object_Destroy(obj->area)); 

    zCHECK(Go2Measurement_VRelease(measurement));  
        
    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_VRead(Go2ProfileCircleX measurement, zXml xml, zXmlItem item)
{
    Go2ProfileCircleXClass* obj = zHANDLE_POINTER(measurement); 
    zChar* text = zNULL;
    z32u textCapacity = GO2_MEASUREMENT_SOURCE_TEXT_CAPACITY; 

    zXmlItem areaItem = zNIL; 

    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_Child32u(xml, item, "Source", &obj->source)); 
    

    zCHECK(!zIS_NIL(areaItem = zXml_Child(xml, item, "Area"))); 
    zCHECK(Go2ProfileArea_Read(obj->area, xml, areaItem)); 

    zCHECK(zFree(text)); 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_VWrite(Go2ProfileCircleX measurement, zXml xml, zXmlItem item)
{
    Go2ProfileCircleXClass* obj = zHANDLE_POINTER(measurement); 
    zXmlItem areaItem = zNIL; 

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

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

    zCHECK(zXml_AddItem(xml, item, "Area", &areaItem)); 
    zCHECK(Go2ProfileArea_Write(obj->area, xml, areaItem)); 

    return GO2_OK; 
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_SetId(Go2ProfileCircleX measurement, Go2UInt32 id)
{
    return Go2Measurement_SetId(measurement, id);     
}

GO2_EXPORT(Go2UInt32) Go2ProfileCircleX_Id(Go2ProfileCircleX measurement)
{
    return Go2Measurement_Id(measurement);     
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_SetName(Go2ProfileCircleX measurement, const Go2Char* name)
{
    return Go2Measurement_SetName(measurement, name);     
}

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

GO2_EXPORT(Go2UInt32) Go2ProfileCircleX_SourceOptionCount(Go2ProfileCircleX measurement)
{
    return Go2Measurement_SourceOptionCount(measurement);     
}

GO2_EXPORT(Go2ProfileSource) Go2ProfileCircleX_SourceOptionAt(Go2ProfileCircleX measurement, Go2UInt32 index)
{
    return Go2Measurement_SourceOptionAt(measurement, index);     
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_SetSource(Go2ProfileCircleX measurement, Go2ProfileSource source)
{
    return Go2Measurement_SetSource(measurement, source);     
}

GO2_EXPORT(Go2ProfileSource) Go2ProfileCircleX_Source(Go2ProfileCircleX measurement)
{
    return Go2Measurement_Source(measurement);     
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_SetDecisionMin(Go2ProfileCircleX measurement, Go2Double min)
{
    return Go2Measurement_SetDecisionMin(measurement, min);     
}

GO2_EXPORT(Go2Double) Go2ProfileCircleX_DecisionMin(Go2ProfileCircleX measurement)
{
    return Go2Measurement_DecisionMin(measurement);     
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_SetDecisionMax(Go2ProfileCircleX measurement, Go2Double max)
{
    return Go2Measurement_SetDecisionMax(measurement, max);     
}

GO2_EXPORT(Go2Double) Go2ProfileCircleX_DecisionMax(Go2ProfileCircleX measurement)
{
    return Go2Measurement_DecisionMax(measurement);     
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_EnableHold(Go2ProfileCircleX measurement, Go2Bool enable)
{
    return Go2Measurement_EnableHold(measurement, enable);  
} 

GO2_EXPORT(Go2Bool) Go2ProfileCircleX_HoldEnabled(Go2ProfileCircleX measurement)
{
    return Go2Measurement_HoldEnabled(measurement);  
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_EnableSmoothing(Go2ProfileCircleX measurement, Go2Bool enable)
{
    return Go2Measurement_EnableSmoothing(measurement, enable);  
} 

GO2_EXPORT(Go2Bool) Go2ProfileCircleX_SmoothingEnabled(Go2ProfileCircleX measurement)
{
    return Go2Measurement_SmoothingEnabled(measurement);  
} 

GO2_EXPORT(Go2UInt32) Go2ProfileCircleX_SmoothingWindowMin(Go2ProfileCircleX measurement)
{
    return Go2Measurement_SmoothingWindowMin(measurement);  
} 

GO2_EXPORT(Go2UInt32) Go2ProfileCircleX_SmoothingWindowMax(Go2ProfileCircleX measurement)
{
    return Go2Measurement_SmoothingWindowMax(measurement);  
} 

GO2_EXPORT(Go2Status) Go2ProfileCircleX_SetSmoothingWindow(Go2ProfileCircleX measurement, Go2UInt32 window)
{
    return Go2Measurement_SetSmoothingWindow(measurement, window);  
} 

GO2_EXPORT(Go2UInt32) Go2ProfileCircleX_SmoothingWindow(Go2ProfileCircleX measurement)
{
    return Go2Measurement_SmoothingWindow(measurement);  
} 

GO2_EXPORT(Go2ProfileArea) Go2ProfileCircleX_Area(Go2ProfileCircleX measurement)
{
    Go2ProfileCircleXClass* obj = zHANDLE_POINTER(measurement); 
    return obj->area;  
}




GO2_EXPORT(Go2Status) Go2ProfileCircleX_SetScale(Go2ProfileCircleX measurement, Go2Double scale){
    return Go2Measurement_SetScale(measurement, scale);
}

GO2_EXPORT(Go2Double) Go2ProfileCircleX_Scale(Go2ProfileCircleX measurement){
    return Go2Measurement_Scale(measurement);
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_SetOffset(Go2ProfileCircleX measurement, Go2Double offset){
    return Go2Measurement_SetOffset(measurement, offset);
}

GO2_EXPORT(Go2Double) Go2ProfileCircleX_Offset(Go2ProfileCircleX measurement){
    return Go2Measurement_Offset(measurement);
}

GO2_EXPORT(Go2UInt32) Go2ProfileCircleX_LinkOptionCount(Go2ProfileCircleX measurement)
{
    return Go2Measurement_LinkOptionCount(measurement);
}

GO2_EXPORT(Go2UInt32) Go2ProfileCircleX_LinkOptionAt(Go2ProfileCircleX measurement, Go2UInt32 index)
{
    return Go2Measurement_LinkOptionAt(measurement, index);
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_EnableLink(Go2ProfileCircleX measurement, Go2Bool enable)  
{
    return Go2Measurement_EnableLink(measurement, enable);  
}

GO2_EXPORT(Go2Bool) Go2ProfileCircleX_LinkEnabled(Go2ProfileCircleX measurement)  
{
    return Go2Measurement_LinkEnabled(measurement);  
}

GO2_EXPORT(Go2Status) Go2ProfileCircleX_SetLink(Go2ProfileCircleX measurement, Go2UInt32 link) 
{
    return Go2Measurement_SetLink(measurement, link); 
}

GO2_EXPORT(Go2UInt32) Go2ProfileCircleX_Link(Go2ProfileCircleX measurement) 
{
    return Go2Measurement_Link(measurement); 
}
