////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS IS AUTO-GENERATED CODE.  PLEASE DO NOT EDIT (File bug reports against tools).
///
/// Auto-generated by: Parameter Parser V5.5.1 (2411131018)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  globalelements.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "globalelements.h"
#include "parametersetmanager.h"

GLOBALELEMENTS_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// SetValue/GetValue Functions
/// Gets or sets the requested value
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool trigger_pt_type_aec::GetValue(
    const CHAR* const __path,
    CHAR* const       __value,
    UINT32 const      __size)
{
    constexpr SIZE_T MAX_SIZE = 129;
    CHAR   __name[MAX_SIZE] = "";
    UINT32 __index          = MAX_UINT;
    bool   __result         = false;

    ParameterUtils::GetVariable(__path, __name, __index, MAX_SIZE);

    if (PARAMETER_STRCMP(__name, "lux_idx_start") == 0)
    {
        ParameterUtils::DoubleToString((double)lux_idx_start, __value, __size);
        __result = true;
    }
    else if (PARAMETER_STRCMP(__name, "lux_idx_end") == 0)
    {
        ParameterUtils::DoubleToString((double)lux_idx_end, __value, __size);
        __result = true;
    }
    else if (PARAMETER_STRCMP(__name, "gain_start") == 0)
    {
        ParameterUtils::DoubleToString((double)gain_start, __value, __size);
        __result = true;
    }
    else if (PARAMETER_STRCMP(__name, "gain_end") == 0)
    {
        ParameterUtils::DoubleToString((double)gain_end, __value, __size);
        __result = true;
    }

    return __result;
}

bool trigger_pt_type_aec::SetValue(
    const CHAR* const __path,
    const CHAR* const __value)
{
    constexpr SIZE_T MAX_SIZE = 129;
    CHAR   __name[MAX_SIZE] = "";
    UINT32 __index          = MAX_UINT;
    bool   __result         = false;

    ParameterUtils::GetVariable(__path, __name, __index, MAX_SIZE);

    if (PARAMETER_STRCMP(__name, "lux_idx_start") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            lux_idx_start = (float)dblValue; 
        }
    }
    else if (PARAMETER_STRCMP(__name, "lux_idx_end") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            lux_idx_end = (float)dblValue; 
        }
    }
    else if (PARAMETER_STRCMP(__name, "gain_start") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            gain_start = (float)dblValue; 
        }
    }
    else if (PARAMETER_STRCMP(__name, "gain_end") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            gain_end = (float)dblValue; 
        }
    }

    return __result;
}

bool trigger_pt_type_aec::GetInfo(
    const CHAR* const           __path,
    PList<ParameterParserInfo>& __info)
{
    constexpr SIZE_T MAX_SIZE = 129;
    CHAR   __name[MAX_SIZE] = "";
    UINT32 __index          = MAX_UINT;
    bool   __result         = false;

    ParameterUtils::GetVariable(__path, __name, __index, MAX_SIZE);

    // lux_idx_start
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("lux_idx_start", ParameterParserDataType::Float, (double)lux_idx_start));
    }
    else if (PARAMETER_STRCMP(__name, "lux_idx_start") == 0)
    {
        __result = true;
        __info.Add(ParameterParserInfo(nullptr, ParameterParserDataType::Float, (double)lux_idx_start));
    }

    // lux_idx_end
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("lux_idx_end", ParameterParserDataType::Float, (double)lux_idx_end));
    }
    else if (PARAMETER_STRCMP(__name, "lux_idx_end") == 0)
    {
        __result = true;
        __info.Add(ParameterParserInfo(nullptr, ParameterParserDataType::Float, (double)lux_idx_end));
    }

    // gain_start
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("gain_start", ParameterParserDataType::Float, (double)gain_start));
    }
    else if (PARAMETER_STRCMP(__name, "gain_start") == 0)
    {
        __result = true;
        __info.Add(ParameterParserInfo(nullptr, ParameterParserDataType::Float, (double)gain_start));
    }

    // gain_end
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("gain_end", ParameterParserDataType::Float, (double)gain_end));
    }
    else if (PARAMETER_STRCMP(__name, "gain_end") == 0)
    {
        __result = true;
        __info.Add(ParameterParserInfo(nullptr, ParameterParserDataType::Float, (double)gain_end));
    }

    return __result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Read enum value
/// @param entry [in] Symbol table entry
/// @param enumValue [out] Enum value to read
/// @param alignment [in] Symbol table byte alignment
/// @return true if successful
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool ReadEnum_tuning_level(
    ParameterFileSymbolTableEntry* const entry,
    tuning_level& enumValue,
    BYTE const alignment)
{
    bool result {false};

    UINT32 uintValue {entry->ReadEnum(&result, alignment)};

    if (result)
    {
        switch (uintValue)
        {
        case static_cast<UINT32>(tuning_level::must_tune):
            enumValue = tuning_level::must_tune;
            result    = true;
            break;
        case static_cast<UINT32>(tuning_level::often_tune):
            enumValue = tuning_level::often_tune;
            result    = true;
            break;
        case static_cast<UINT32>(tuning_level::rarely_tune):
            enumValue = tuning_level::rarely_tune;
            result    = true;
            break;
        case static_cast<UINT32>(tuning_level::never_tune):
            enumValue = tuning_level::never_tune;
            result    = true;
            break;
        case static_cast<UINT32>(tuning_level::default_tune):
            enumValue = tuning_level::default_tune;
            result    = true;
            break;
        default:
            PARAMETER_LOG_ERROR(entry->SetManager, "Invalid value(% u) converting UINT32 to tuning_level", uintValue);
            break;
        }
    }
    return result;
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load trigger_pt_type_aec
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool trigger_pt_type_aec::Load(
    ParameterFileSymbolTableEntry* const entry,
    BYTE const alignment)
{
    bool result = true;

    PARAMETER_INITIALIZE(lux_idx_start);
    PARAMETER_INITIALIZE(lux_idx_end);
    PARAMETER_INITIALIZE(gain_start);
    PARAMETER_INITIALIZE(gain_end);

    SYMBOL_TABLE_ENTRY_READ(entry, result, lux_idx_start, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, lux_idx_end, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, gain_start, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, gain_end, alignment)

    return result;
}
GLOBALELEMENTS_NAMESPACE_END
