/*****************************************************************************
 *
 * MODULE:             Simple Metering Cluster
 *
 * COMPONENT:          SimpleMetering.h
 *
 * AUTHOR:             Lee Mitchell
 *
 * DESCRIPTION:        Header for Simple Metering Cluster
 *
 * $HeadURL: https://www.collabnet.nxp.com/svn/lprf_sware/Projects/Components/ZCL/Trunk/Clusters/SmartEnergy/Include/SimpleMetering.h $
 *
 * $Revision: 72260 $
 *
 * $LastChangedBy: nxp57621 $
 *
 * $LastChangedDate: 2015-08-26 09:12:34 +0200 (Wed, 26 Aug 2015) $
 *
 * $Id: SimpleMetering.h 72260 2015-08-26 07:12:34Z nxp57621 $
 *
 *****************************************************************************
 *
 * This software is owned by NXP B.V. and/or its supplier and is protected
 * under applicable copyright laws. All rights are reserved. We grant You,
 * and any third parties, a license to use this software solely and
 * exclusively on NXP products  [NXP Microcontrollers such as JN5168, JN5164,
* JN5161, JN5148, JN5142, JN5139].
 * You, and any third parties must reproduce the copyright and warranty notice
 * and any other legend of ownership on each  copy or partial copy of the software.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * Copyright NXP B.V. 2012. All rights reserved
 *
 ****************************************************************************/

#ifndef SIMPLE_METERING_H
#define SIMPLE_METERING_H

#include <jendefs.h>
#include "zcl.h"
#include "zcl_options.h"

#include "zcl_customcommand.h"
/****************************************************************************/
/***        Macro Definitions                                             ***/
/****************************************************************************/
#ifndef SE_CLUSTER_ID_SIMPLE_METERING
#define SE_CLUSTER_ID_SIMPLE_METERING                                             0x0702
#endif

#ifndef CLD_SM_ATTR_NO_TIER_BLOCK_CURRENT_SUMMATION_DELIVERED_MAX_COUNT
#define CLD_SM_ATTR_NO_TIER_BLOCK_CURRENT_SUMMATION_DELIVERED_MAX_COUNT           (0)
#endif

#ifndef CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED
#define CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED                      (0)
#endif

#ifndef CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED
#define CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED        (0)
#endif


#if (CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 15)||(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED > 16)
#error Number of Metering attributes are out of range
#endif

#if(CLD_SM_ATTR_NO_TIER_BLOCK_CURRENT_SUMMATION_DELIVERED_MAX_COUNT != 0)&&((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED != 0)||(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
#error  Simple metering attributes are conflicted
#endif

#if((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED != 0)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED == 0))
#error  Simple metering attributes are conflicted
#endif


#define SE_SM_SITE_ID_MAX_STRING_LENGTH                             32
#define SE_SM_METER_SERIAL_NUMBER_MAX_STRING_LENGTH                 24

/* Meter status attribute - bit definitions and bit masks */
#define E_CLD_SM_METER_STATUS_CHECK_METER_BIT                       0
#define E_CLD_SM_METER_STATUS_LOW_BATTERY_BIT                       1
#define E_CLD_SM_METER_STATUS_TAMPER_DETECT_BIT                     2
#define E_CLD_SM_METER_STATUS_POWER_FAILURE_BIT                     3
#define E_CLD_SM_METER_STATUS_POWER_QUALITY_BIT                     4
#define E_CLD_SM_METER_STATUS_LEAK_DETECT_BIT                       5
#define E_CLD_SM_METER_STATUS_SERVICE_DISCONNECT_OPEN_BIT           6

#define E_CLD_SM_METER_STATUS_CHECK_METER_MASK                      (1 << E_CLD_SM_METER_STATUS_CHECK_METER_BIT)
#define E_CLD_SM_METER_STATUS_LOW_BATTERY_MASK                      (1 << E_CLD_SM_METER_STATUS_LOW_BATTERY_BIT)
#define E_CLD_SM_METER_STATUS_TAMPER_DETECT_MASK                    (1 << E_CLD_SM_METER_STATUS_TAMPER_DETECT_BIT)
#define E_CLD_SM_METER_STATUS_POWER_FAILURE_MASK                    (1 << E_CLD_SM_METER_STATUS_POWER_FAILURE_BIT)
#define E_CLD_SM_METER_STATUS_POWER_QUALITY_MASK                    (1 << E_CLD_SM_METER_STATUS_POWER_QUALITY_BIT)
#define E_CLD_SM_METER_STATUS_LEAK_DETECT_MASK                      (1 << E_CLD_SM_METER_STATUS_LEAK_DETECT_BIT)
#define E_CLD_SM_METER_STATUS_SERVICE_DISCONNECT_OPEN_MASK          (1 << E_CLD_SM_METER_STATUS_SERVICE_DISCONNECT_OPEN_BIT)



/* Summation, demand and historical consumption formatting attributes */
#define E_CLD_SM_FORMATTING_DIGITS_TO_RIGHT_OF_DP_LS_BIT            0x0
#define E_CLD_SM_FORMATTING_DIGITS_TO_RIGHT_OF_DP_NUMBER_OF_BITS    0x03
#define E_CLD_SM_FORMATTING_DIGITS_TO_RIGHT_OF_DP_MASK              (0x7 << E_CLD_SM_FORMATTING_DIGITS_TO_RIGHT_OF_DP_LS_BIT)

#define E_CLD_SM_FORMATTING_DIGITS_TO_LEFT_OF_DP_LS_BIT             0x3
#define E_CLD_SM_FORMATTING_DIGITS_TO_LEFT_OF_DP_NUMBER_OF_BITS     0x04
#define E_CLD_SM_FORMATTING_DIGITS_TO_LEFT_OF_DP_MASK               (0xf << E_CLD_SM_FORMATTING_DIGITS_TO_LEFT_OF_DP_LS_BIT)

#define E_CLD_SM_FORMATTING_SUPPRESS_LEADING_ZEROS_BIT              0x07


#ifdef CLD_SM_SUPPORT_GET_PROFILE
#define CLD_SM_ATTR_CURRENT_PARTIAL_PROFILE_INTERVAL_VALUE_DELIVERED

#ifdef CLD_SM_ATTR_CURRENT_SUMMATION_RECEIVED
#define CLD_SM_ATTR_CURRENT_PARTIAL_PROFILE_INTERVAL_VALUE_RECEIVED
#endif

    /* Load Profile attribute set attribute ID's (D.3.2.2.6) */
    #define CLD_SM_ATTR_MAX_NUMBER_OF_PERIODS_DELIVERED

    #define CLD_SM_ATTR_PROFILE_INTERVAL_PERIOD

    #define CLD_SM_ATTR_INTERVAL_READ_REPORTING_PERIOD
#endif

/* Enumerations for Get Profile Status response */
typedef enum 
{
    E_CLD_SM_GP_SUCCESS                                 = 0x00,
    E_CLD_SM_GP_UNDEFINED_INTERVAL_CHANNEL_REQUESTED    = 0x01,
    E_CLD_SM_GP_INTERVAL_CHANNEL_NOT_SUPPORTED          = 0x02,
    E_CLD_SM_GP_INVALID_END_TIME                        = 0x03,
    E_CLD_SM_GP_MORE_REQUESTED                          = 0x04,
    E_CLD_SM_GP_NO_INTERVALS_AVAILABLE                  = 0x05
}teCLD_SM_GetProfileStatus;

/* Unit Of Measure enumerations (D.3.2.2.4.1) */
typedef enum 
{
    /* Binary values */
    E_CLD_SM_UOM_KILO_WATTS                = 0x00,
    E_CLD_SM_UOM_CUBIC_METER,
    E_CLD_SM_UOM_CUBIC_FEET,
    E_CLD_SM_UOM_100_CUBIC_FEET,           /* ccf & ccf/h */
    E_CLD_SM_UOM_US_GALLON,                /* USG & USG/h */
    E_CLD_SM_UOM_IMPERIAL_GALLON,          /* IMPG & IMPG/h */
    E_CLD_SM_UOM_BTU,                      /* BTU & BTU/h */
    E_CLD_SM_UOM_LITERS,                   /* Liters & Liters/h */
    E_CLD_SM_UOM_KPA_GAUGE,
    E_CLD_SM_UOM_KPA_ABSOLUTE,

    /* BCD values */
    E_CLD_SM_UOM_KILO_WATTS_BCD            = 0x80,
    E_CLD_SM_UOM_CUBIC_METER_BCD,
    E_CLD_SM_UOM_CUBIC_FEET_BCD,
    E_CLD_SM_UOM_100_CUBIC_FEET_BCD,       /* ccf & ccf/h */
    E_CLD_SM_UOM_US_GALLON_BCD,            /* USG & USG/h */
    E_CLD_SM_UOM_IMPERIAL_GALLON_BCD,      /* IMPG & IMPG/h */
    E_CLD_SM_UOM_BTU_BCD,                  /* BTU & BTU/h */
    E_CLD_SM_UOM_LITERS_BCD,               /* Liters & Liters/h */
    E_CLD_SM_UOM_KPA_GAUGE_BCD,
    E_CLD_SM_UOM_KPA_ABSOLUTE_BCD
} teCLD_SM_UnitOfMeasure;

/* Metering Device Type enumerations (D.3.2.2.4.7) */
typedef enum 
{
    E_CLD_SM_MDT_ELECTRIC                = 0x00,
    E_CLD_SM_MDT_GAS,
    E_CLD_SM_MDT_WATER,
    E_CLD_SM_MDT_THERMAL,                        /* Depreciated */
    E_CLD_SM_MDT_PRESSURE,
    E_CLD_SM_MDT_HEAT,
    E_CLD_SM_MDT_COOLING,
    E_CLD_SM_MDT_GAS_MIRRORED            = 0x80,
    E_CLD_SM_MDT_WATER_MIRRORED,
    E_CLD_SM_MDT_THERMAL_MIRRORED,
    E_CLD_SM_MDT_PRESSURE_MIRRORED,
    E_CLD_SM_MDT_HEAT_MIRRORED,
    E_CLD_SM_MDT_COOLING_MIRRORED,
} teCLD_SM_MeteringDeviceType;

/* Profile Interval Period Type Enumerations (D.3.2.3.1.1.1) */
typedef enum 
{
    E_CLD_SM_PIP_DAILY                    = 0x00,
    E_CLD_SM_PIP_60MINS,
    E_CLD_SM_PIP_30MINS,
    E_CLD_SM_PIP_15MINS,
    E_CLD_SM_PIP_10MINS,
    E_CLD_SM_PIP_7_5MINS,
    E_CLD_SM_PIP_5MINS,
    E_CLD_SM_PIP_2_5MINS,
}teCLD_SM_ProfileIntervalPeriodType;

/****************************************************************************/
/***        Type Definitions                                              ***/
/****************************************************************************/

/* Simple Metering Cluster - Attribute ID's */
typedef enum 
{
    /* Reading information attribute set attribute ID's (D.3.2.2.1) */
    E_CLD_SM_ATTR_ID_CURRENT_SUMMATION_DELIVERED        =    0x0000,    /* Mandatory */
    E_CLD_SM_ATTR_ID_CURRENT_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_MAX_DEMAND_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_MAX_DEMAND_RECEIVED,
    E_CLD_SM_ATTR_ID_DFT_SUMMATION,
    E_CLD_SM_ATTR_ID_DAILY_FREEZE_TIME,
    E_CLD_SM_ATTR_ID_POWER_FACTOR,
    E_CLD_SM_ATTR_ID_READING_SNAPSHOT_TIME,
    E_CLD_SM_ATTR_ID_CURRENT_MAX_DEMAND_DELIVERED_TIME,
    E_CLD_SM_ATTR_ID_CURRENT_MAX_DEMAND_RECEIVED_TIME,
    E_CLD_SM_ATTR_ID_DEFAULT_UPDATE_PERIOD,
    E_CLD_SM_ATTR_ID_FAST_POLL_UPDATE_PERIOD,
    E_CLD_SM_ATTR_ID_CURRENT_BLOCK_PERIOD_CONSUMPTION_DELIVERED,
    E_CLD_SM_ATTR_ID_DAILY_CONSUMPTION_TARGET,
    E_CLD_SM_ATTR_ID_CURRENT_BLOCK,
    E_CLD_SM_ATTR_ID_PROFILE_INTERVAL_PERIOD,
    E_CLD_SM_ATTR_ID_INTERVAL_READ_REPORTING_PERIOD,
    E_CLD_SM_ATTR_ID_PRESET_READING_TIME,
    E_CLD_SM_ATTR_ID_VOLUME_PER_REPORT,
    E_CLD_SM_ATTR_ID_FLOW_RESTRICTION,
    E_CLD_SM_ATTR_ID_SUPPLY_STATUS,
    E_CLD_SM_ATTR_ID_CURRENT_INLET_ENERGY_CARRIER_SUMMATION,
    E_CLD_SM_ATTR_ID_CURRENT_OUTLET_ENERGY_CARRIER_SUMMATION,
    E_CLD_SM_ATTR_ID_INLET_TEMPERATURE,
    E_CLD_SM_ATTR_ID_OUTLET_TEMPERATURE,
    E_CLD_SM_ATTR_ID_CONTROL_TEMPERATURE,
    E_CLD_SM_ATTR_ID_CURRENT_INLET_ENERGY_CARRIER_DEMAND,
    E_CLD_SM_ATTR_ID_CURRENT_OUTLET_ENERGY_CARRIER_DEMAND,

    E_CLD_SM_ATTR_ID_PREVIOUS_BLOCK_PERIOD_CONSUMPTION_DELIVERED = 0x001c,

    /* Time Of Use Information attribute attribute ID's set (D.3.2.2.2) */
    E_CLD_SM_ATTR_ID_CURRENT_TIER_1_SUMMATION_DELIVERED    =    0x0100,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_1_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_2_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_3_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_4_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_5_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_6_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_7_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_8_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_9_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_10_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_11_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_12_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_13_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_14_SUMMATION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER_15_SUMMATION_RECEIVED,

    /* Meter status attribute set attribute ID's (D.3.2.2.3) */
    E_CLD_SM_ATTR_ID_STATUS                                =    0x0200, /* Mandatory */
    E_CLD_SM_ATTR_ID_REMAINING_BATTERY_LIFE,
    E_CLD_SM_ATTR_ID_HOURS_IN_OPERATION,
    E_CLD_SM_ATTR_ID_HOURS_IN_FAULT,

    /* Formatting attribute set attribute ID's (D.3.2.2.4) */
    E_CLD_SM_ATTR_ID_UNIT_OF_MEASURE                    =    0x0300, /* Mandatory */
    E_CLD_SM_ATTR_ID_MULTIPLIER,
    E_CLD_SM_ATTR_ID_DIVISOR,
    E_CLD_SM_ATTR_ID_SUMMATION_FORMATING,                            /* Mandatory */
    E_CLD_SM_ATTR_ID_DEMAND_FORMATING,
    E_CLD_SM_ATTR_ID_HISTORICAL_CONSUMPTION_FORMATTING,
    E_CLD_SM_ATTR_ID_METERING_DEVICE_TYPE,                             /* Mandatory */
    E_CLD_SM_ATTR_ID_SITE_ID,
    E_CLD_SM_ATTR_ID_METER_SERIAL_NUMBER,
    E_CLD_SM_ATTR_ID_ENERGY_CARRIER_UNIT_OF_MEASURE,
    E_CLD_SM_ATTR_ID_ENERGY_CARRIER_SUMMATION_FORMATTING,
    E_CLD_SM_ATTR_ID_ENERGY_CARRIER_DEMAND_FORMATTING,
    E_CLD_SM_ATTR_ID_TEMPERATURE_UNIT_OF_MEASURE,
    E_CLD_SM_ATTR_ID_TEMPERATURE_FORMATTING,

    /* ESP Historical Consumption set attribute ID's (D.3.2.2.5) */
    E_CLD_SM_ATTR_ID_INSTANTANEOUS_DEMAND                =    0x0400,
    E_CLD_SM_ATTR_ID_CURRENT_DAY_CONSUMPTION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_DAY_CONSUMPTION_RECEIVED,
    E_CLD_SM_ATTR_ID_PREVIOUS_DAY_CONSUMPTION_DELIVERED,
    E_CLD_SM_ATTR_ID_PREVIOUS_DAY_CONSUMPTION_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_PARTIAL_PROFILE_INTERVAL_START_TIME_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_PARTIAL_PROFILE_INTERVAL_START_TIME_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_PARTIAL_PROFILE_INTERVAL_VALUE_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_PARTIAL_PROFILE_INTERVAL_VALUE_RECEIVED,
    E_CLD_SM_ATTR_ID_CURRENT_DAY_MAXIMUM_PRESSURE,
    E_CLD_SM_ATTR_ID_CURRENT_DAY_MINIMUM_PRESSURE,
    E_CLD_SM_ATTR_ID_PREVIOUS_DAY_MAXIMUM_PRESSURE,
    E_CLD_SM_ATTR_ID_PREVIOUS_DAY_MINIMUM_PRESSURE,
    E_CLD_SM_ATTR_ID_CURRENT_DAY_MAXIMUM_DEMAND,
    E_CLD_SM_ATTR_ID_PREVIOUS_DAY_MAXIMUM_DEMAND,
    E_CLD_SM_ATTR_ID_CURRENT_MONTH_MAXIMUM_DEMAND,
    E_CLD_SM_ATTR_ID_CURRENT_YEAR_MAXIMUM_DEMAND,
    E_CLD_SM_ATTR_ID_CURRENT_DAY_MAXIMUM_ENERGY_CARRIER_DEMAND,
    E_CLD_SM_ATTR_ID_PREVIOUS_DAY_MAXIMUM_ENERGY_CARRIER_DEMAND,
    E_CLD_SM_ATTR_ID_CURRENT_MONTH_MAXIMUM_ENERGY_CARRIER_DEMAND,
    E_CLD_SM_ATTR_ID_CURRENT_MONTH_MINIMUM_ENERGY_CARRIER_DEMAND,
    E_CLD_SM_ATTR_ID_CURRENT_YEAR_MAXIMUM_ENERGY_CARRIER_DEMAND,
    E_CLD_SM_ATTR_ID_CURRENT_YEAR_MINIMUM_ENERGY_CARRIER_DEMAND,

    /* Load Profile attribute set attribute ID's (D.3.2.2.6) */
    E_CLD_SM_ATTR_ID_MAX_NUMBER_OF_PERIODS_DELIVERED    =    0x0500,

    /* Supply Limit attribute set attribute ID's (D.3.2.2.7) */
    E_CLD_SM_ATTR_ID_CURRENT_DEMAND_DELIVERED            =    0x0600,
    E_CLD_SM_ATTR_ID_DEMAND_LIMIT,
    E_CLD_SM_ATTR_ID_DEMAND_INTEGRATION_PERIOD,
    E_CLD_SM_ATTR_ID_NUMBER_OF_DEMAND_SUBINTERVALS,

    /* Block Information Attribute set attribute ID's (D.3.2.2.8) */
    /* Block Information Attribute set: No Tier Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK1_SUMMATION_DELIVERED    =    0x0700,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_NOTIER_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier1 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER1_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier2 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER2_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier5 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER3_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier4 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER4_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier5 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER5_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier6 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER6_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier8 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER7_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier8 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER8_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier9 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER9_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier10 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER10_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier11 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER11_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier12 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER12_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier13 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER13_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier14 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER14_BLOCK16_SUMMATION_DELIVERED,

    /* Block Information Attribute set: Tier15 Block Set */
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK1_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK2_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK3_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK4_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK5_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK6_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK7_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK8_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK9_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK10_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK11_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK12_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK13_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK14_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK15_SUMMATION_DELIVERED,
    E_CLD_SM_ATTR_ID_CURRENT_TIER15_BLOCK16_SUMMATION_DELIVERED,

    /* Alarm Attribute set attribute ID's (D.3.2.2.9) */
    E_CLD_SM_ATTR_ID_GENERIC_ALARM_MASK = 0x0800,
    E_CLD_SM_ATTR_ID_ELECTRICITY_ALARM_MASK,
    E_CLD_SM_ATTR_ID_PRESSURE_ALARM_MASK,
    E_CLD_SM_ATTR_ID_WATER_SPECIFIC_ALARM_MASK,
    E_CLD_SM_ATTR_ID_HEAT_AND_COOLING_SPECIFIC_ALARM_MASK,
    E_CLD_SM_ATTR_ID_GAS_ALARM_MASK,

    /* Manufacturer Specific Attributes: Measurements */
    E_CLD_SM_ATTR_ID_MAN_SPEC_AC_FREQUENCY = 0x1000,
    E_CLD_SM_ATTR_ID_MAN_SPEC_RMS_VOLTAGE,
    E_CLD_SM_ATTR_ID_MAN_SPEC_RMS_CURRENT,
    E_CLD_SM_ATTR_ID_MAN_SPEC_ACTIVE_POWER,
    /* Manufacturer Specific Attributes: Calibration */
    E_CLD_SM_ATTR_ID_MAN_SPEC_CALIBRATION_VPP = 0x2000,
    E_CLD_SM_ATTR_ID_MAN_SPEC_CALIBRATION_I1PP,
    E_CLD_SM_ATTR_ID_MAN_SPEC_CALIBRATION_I2PP,
    E_CLD_SM_ATTR_ID_MAN_SPEC_CALIBRATION_DELTAPHI1,
    E_CLD_SM_ATTR_ID_MAN_SPEC_CALIBRATION_DELTAPHI2,
    E_CLD_SM_ATTR_ID_MAN_SPEC_CALIBRATION_DIVISOR,
    E_CLD_SM_ATTR_ID_MAN_SPEC_POWER_THRESHOLD,
    E_CLD_SM_ATTR_ID_MAN_SPEC_UPDATE_INTERVAL,
    E_CLD_SM_ATTR_ID_MAN_SPEC_RF_POWER_CONFIG

} teCLD_SM_SimpleMeteringAttributeID;


/* Simple Metering Cluster */
typedef struct
{

    /* Reading information attribute set attribute ID's (D.3.2.2.1) */
    zuint48                    u48CurrentSummationDelivered;        /* Mandatory */

#ifdef CLD_SM_ATTR_CURRENT_SUMMATION_RECEIVED
    zuint48                    u48CurrentSummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_MAX_DEMAND_DELIVERED
    zuint48                    u48CurrentMaxDemandDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_MAX_DEMAND_RECEIVED
    zuint48                    u48CurrentMaxDemandReceived;
#endif

#ifdef CLD_SM_ATTR_DFT_SUMMATION
    zuint48                    u48DFTSummation;
#endif

#ifdef CLD_SM_ATTR_DAILY_FREEZE_TIME
    zuint16                    u16DailyFreezeTime;
#endif

#ifdef CLD_SM_ATTR_POWER_FACTOR
    zint8                    i8PowerFactor;
#endif

#ifdef CLD_SM_ATTR_READING_SNAPSHOT_TIME
    zutctime                utctReadingSnapshotTime;
#endif

#ifdef CLD_SM_ATTR_CURRENT_MAX_DEMAND_DELIVERED_TIME
    zutctime                utctCurrentMaxDemandDeliveredTime;
#endif

#ifdef CLD_SM_ATTR_CURRENT_MAX_DEMAND_RECEIVED_TIME
    zutctime                utctCurrentMaxDemandReceivedTime;
#endif

#ifdef CLD_SM_ATTR_DEFAULT_UPDATE_PERIOD
    uint8                    u8DefaultUpdatePeriod;
#endif

#ifdef CLD_SM_ATTR_FAST_POLL_UPDATE_PERIOD
    uint8                    u8FastPollUpdatePeriod;
#endif

#ifdef CLD_SM_ATTR_CURRENT_BLOCK_PERIOD_CONSUMPTION_DELIVERED
    zuint48                u48CurrentBlockPeriodConsumptionDelivered;
#endif

#ifdef CLD_SM_ATTR_DAILY_CONSUMPTION_TARGET
    zuint24                u24DailyConsumptionTarget;
#endif

#ifdef CLD_SM_ATTR_CURRENT_BLOCK
    zenum8                e8CurrentBlock;
#endif

#ifdef CLD_SM_SUPPORT_GET_PROFILE

#ifdef CLD_SM_ATTR_PROFILE_INTERVAL_PERIOD
    zenum8                    eProfileIntervalPeriod;
#endif

#ifdef CLD_SM_ATTR_INTERVAL_READ_REPORTING_PERIOD
    uint16                    u16IntervalReadReportingPeriod;
#endif

#endif  // CLD_SM_SUPPORT_GET_PROFILE

#ifdef CLD_SM_ATTR_PRESET_READING_TIME
    uint16                    u16PresetReadingTime;
#endif

#ifdef CLD_SM_ATTR_VOLUME_PER_REPORT
    uint16                    u16VolumePerReport;
#endif

#ifdef CLD_SM_ATTR_FLOW_RESTRICTION
    uint8                    u8FlowRestriction;
#endif

#ifdef CLD_SM_ATTR_SUPPLY_STATUS
    zbmap8                    u8SupplyStatus;
#endif

#ifdef CLD_SM_ATTR_CURRENT_INLET_ENERGY_CARRIER_SUMMATION
    zuint48                    u48CurrentInletEnergyCarrierSummation;
#endif

#ifdef CLD_SM_ATTR_CURRENT_OUTLET_ENERGY_CARRIER_SUMMATION
    zuint48                    u48CurrentOutletEnergyCarrierSummation;
#endif

#ifdef CLD_SM_ATTR_INLET_TEMPERATURE
    zint24                    i24InletTemperature;
#endif

#ifdef CLD_SM_ATTR_OUTLET_TEMPERATURE
    zint24                    i24OutletTemperature;
#endif

#ifdef CLD_SM_ATTR_CONTROL_TEMPERATURE
    zint24                    i24ControlTemperature;
#endif

#ifdef CLD_SM_ATTR_CURRENT_INLET_ENERGY_CARRIER_DEMAND
    zint24                    i24CurrentInletEnergyCarrierDemand;
#endif

#ifdef CLD_SM_ATTR_CURRENT_OUTLET_ENERGY_CARRIER_DEMAND
    zint24                    i24CurrentOutletEnergyCarrierDemand;
#endif

#ifdef CLD_SM_ATTR_PREVIOUS_BLOCK_PERIOD_CONSUMPTION_DELIVERED
    zuint48                u48PreviousBlockPeriodConsumptionDelivered;
#endif

    /* Time Of Use Information attribute attribute ID's set (D.3.2.2.2) */
#ifdef CLD_SM_ATTR_CURRENT_TIER_1_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier1SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_1_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier1SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_2_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier2SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_2_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier2SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_3_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier3SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_3_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier3SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_4_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier4SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_4_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier4SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_5_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier5SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_5_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier5SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_6_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier6SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_6_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier6SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_7_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier7SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_7_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier7SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_8_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier8SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_8_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier8SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_9_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier9SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_9_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier9SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_10_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier10SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_10_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier10SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_11_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier11SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_11_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier11SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_12_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier12SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_12_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier12SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_13_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier13SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_13_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier13SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_14_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier14SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_14_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier14SummationReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_15_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier15SummationDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_TIER_15_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier15SummationReceived;
#endif

    /* Meter status attribute set attribute ID's (D.3.2.2.3) */
    zbmap8                    u8MeterStatus;                        /* Mandatory */

#ifdef CLD_SM_ATTR_REMAINING_BATTERY_LIFE
    uint8                    u8RemainingBatteryLife;
#endif

#ifdef CLD_SM_ATTR_HOURS_IN_OPERATION
    zuint24                    u24HoursInOperation;
#endif

#ifdef CLD_SM_ATTR_HOURS_IN_FAULT
    zuint24                    u24HoursInFault;
#endif

    /* Formatting attribute set attribute ID's (D.3.2.2.4) */
    zenum8                    eUnitOfMeasure;                        /* Mandatory */

#ifdef CLD_SM_ATTR_MULTIPLIER
    zuint24                    u24Multiplier;
#endif

#ifdef CLD_SM_ATTR_DIVISOR
    zuint24                    u24Divisor;
#endif

    zbmap8                   u8SummationFormatting;                /* Mandatory */

#ifdef CLD_SM_ATTR_DEMAND_FORMATING
    zbmap8                    u8DemandFormatting;
#endif

#ifdef CLD_SM_ATTR_HISTORICAL_CONSUMPTION_FORMATTING
    zbmap8                    u8HistoricalConsumptionFormatting;
#endif

    zbmap8                    eMeteringDeviceType;                /* Mandatory */

#ifdef CLD_SM_ATTR_SITE_ID
    tsZCL_OctetString     sSiteId;
    uint8                 au8SiteId[SE_SM_SITE_ID_MAX_STRING_LENGTH];
#endif

#ifdef CLD_SM_ATTR_METER_SERIAL_NUMBER
    tsZCL_OctetString     sMeterSerialNumber;
    uint8                 au8MeterSerialNumber[SE_SM_METER_SERIAL_NUMBER_MAX_STRING_LENGTH];
#endif

#ifdef CLD_SM_ATTR_ENERGY_CARRIER_UNIT_OF_MEASURE
    zenum8                    e8EnergyCarrierUnitOfMeasure;
#endif

#ifdef CLD_SM_ATTR_ENERGY_CARRIER_SUMMATION_FORMATTING
    zbmap8                    u8EnergyCarrierSummationFormatting;
#endif

#ifdef CLD_SM_ATTR_ENERGY_CARRIER_DEMAND_FORMATTING
    zbmap8                    u8EnergyCarrierDemandFormatting;
#endif

#ifdef CLD_SM_ATTR_TEMPERATURE_UNIT_OF_MEASURE
    zenum8                    e8TemperatureUnitOfMeasure;
#endif

#ifdef CLD_SM_ATTR_TEMPERATURE_FORMATTING
    zbmap8                    u8TemperatureFormatting;
#endif

    /* ESP Historical Consumption set attribute ID's (D.3.2.2.5) */
#ifdef CLD_SM_ATTR_INSTANTANEOUS_DEMAND
    zint24                  i24InstantaneousDemand;
#endif

#ifdef CLD_SM_ATTR_CURRENT_DAY_CONSUMPTION_DELIVERED
    zuint24                    u24CurrentDayConsumptionDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_DAY_CONSUMPTION_RECEIVED
    zuint24                    u24CurrentDayConsumptionReceived;
#endif

#ifdef CLD_SM_ATTR_PREVIOUS_DAY_CONSUMPTION_DELIVERED
    zuint24                    u24PreviousDayConsumptionDelivered;
#endif

#ifdef CLD_SM_ATTR_PREVIOUS_DAY_CONSUMPTION_RECEIVED
    zuint24                    u24PreviousDayConsumptionReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_PARTIAL_PROFILE_INTERVAL_START_TIME_DELIVERED
    zutctime                utctCurrentPartialProfileIntervalStartTimeDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_PARTIAL_PROFILE_INTERVAL_START_TIME_RECEIVED
    zutctime                utctCurrentPartialProfileIntervalStartTimeReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_PARTIAL_PROFILE_INTERVAL_VALUE_DELIVERED
    zuint24                    u24CurrentPartialProfileIntervalValueDelivered;
#endif

#ifdef CLD_SM_ATTR_CURRENT_PARTIAL_PROFILE_INTERVAL_VALUE_RECEIVED
    zuint24                    u24CurrentPartialProfileIntervalValueReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_DAY_MAXIMUM_PRESSURE
    zuint48                    u48CurrentDayMaxPressure;
#endif

#ifdef CLD_SM_ATTR_CURRENT_DAY_MINIMUM_PRESSURE
    zuint48                    u48CurrentDayMinPressure;
#endif

#ifdef CLD_SM_ATTR_PREVIOUS_DAY_MAXIMUM_PRESSURE
    zuint48                    u48PreviousDayMaxPressure;
#endif

#ifdef CLD_SM_ATTR_PREVIOUS_DAY_MINIMUM_PRESSURE
    zuint48                    u48PreviousDayMinPressure;
#endif

#ifdef CLD_SM_ATTR_CURRENT_DAY_MAXIMUM_DEMAND
    zint24                    i24CurrentDayMaxDemand;
#endif

#ifdef CLD_SM_ATTR_PREVIOUS_DAY_MAXIMUM_DEMAND
    zint24                    i24PreviousDayMaxDemand;
#endif

#ifdef CLD_SM_ATTR_CURRENT_MONTH_MAXIMUM_DEMAND
    zint24                    i24CurrentMonthMaxDemand;
#endif

#ifdef CLD_SM_ATTR_CURRENT_YEAR_MAXIMUM_DEMAND
    zint24                    i24CurrentYearMaxDemand;
#endif

#ifdef CLD_SM_ATTR_CURRENT_DAY_MAXIMUM_ENERGY_CARRIER_DEMAND
    zint24                    i24CurrentDayMaxEnergyCarrierDemand;
#endif

#ifdef CLD_SM_ATTR_PREVIOUS_DAY_MAXIMUM_ENERGY_CARRIER_DEMAND
    zint24                    i24PreviousDayMaxEnergyCarrierDemand;
#endif

#ifdef CLD_SM_ATTR_CURRENT_MONTH_MAXIMUM_ENERGY_CARRIER_DEMAND
    zint24                    i24CurrentMonthMaxEnergyCarrierDemand;
#endif

#ifdef CLD_SM_ATTR_CURRENT_MONTH_MINIMUM_ENERGY_CARRIER_DEMAND
    zint24                    i24CurrentMonthMinEnergyCarrierDemand;
#endif

#ifdef CLD_SM_ATTR_CURRENT_YEAR_MAXIMUM_ENERGY_CARRIER_DEMAND
    zint24                    i24CurrentYearMaxEnergyCarrierDemand;
#endif

#ifdef CLD_SM_ATTR_CURRENT_YEAR_MINIMUM_ENERGY_CARRIER_DEMAND
    zint24                    i24CurrentYearMinEnergyCarrierDemand;
#endif


    /* Load Profile attribute set attribute ID's (D.3.2.2.6) */
#ifdef CLD_SM_ATTR_MAX_NUMBER_OF_PERIODS_DELIVERED
    zuint8                    u8MaxNumberOfPeriodsDelivered;
#endif

    /* Supply Limit attribute set attribute ID's (D.3.2.2.7) */
#ifdef CLD_SM_ATTR_CURRENT_DEMAND_DELIVERED
    zuint24                    u24CurrentDemandDelivered;
#endif

#ifdef CLD_SM_ATTR_DEMAND_LIMIT
    zuint24                    u24DemandLimit;
#endif

#ifdef CLD_SM_ATTR_DEMAND_INTEGRATION_PERIOD
    zuint8                    u8DemandIntegrationPeriod;
#endif

#ifdef CLD_SM_ATTR_NUMBER_OF_DEMAND_SUBINTERVALS
    zuint8                    u8NumberOfDemandSubintervals;
#endif

    /* Block Information attribute set attribute ID's (D.3.2.2.8) */
    /* No Tier Block */
#if (CLD_SM_ATTR_NO_TIER_BLOCK_CURRENT_SUMMATION_DELIVERED_MAX_COUNT != 0)
    zuint48                    au48CurrentNoTierBlockSummationDelivered[CLD_SM_ATTR_NO_TIER_BLOCK_CURRENT_SUMMATION_DELIVERED_MAX_COUNT];
#endif

    /* Tier 1 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 0)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier1BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 2 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 1)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier2BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 3 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 2)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier3BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 4 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 3)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier4BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 5 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 4)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier5BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 6 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 5)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier6BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 7 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 6)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier7BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 8 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 7)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier8BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 9 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 8)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier9BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 10 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 9)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier10BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 11 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 10)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier11BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 12 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 11)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier12BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 13 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 12)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier13BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 14 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 13)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier14BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Tier 15 Block Set */
#if ((CLD_SM_ATTR_NUM_OF_TIERS_CURRENT_SUMMATION_DELIVERED > 14)&&(CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED != 0))
    zuint48                    au48CurrentTier15BlockSummationDelivered[CLD_SM_ATTR_NUM_OF_BLOCKS_IN_EACH_TIER_CURRENT_SUMMATION_DELIVERED];
#endif

    /* Alarm attribute set attribute ID's (D.3.2.2.9) */
#ifdef CLD_SM_ATTR_GENERIC_ALARM_MASK
    zbmap16                    u16GenericAlarmMask;
#endif

#ifdef CLD_SM_ATTR_ELECTRICITY_ALARM_MASK
    zbmap32                    u32ElectricityAlarmMask;
#endif

#ifdef CLD_SM_ATTR_PRESSURE_ALARM_MASK
    zbmap16                    u16PressureAlarmMask;
#endif

#ifdef CLD_SM_ATTR_WATER_SPECIFIC_ALARM_MASK
    zbmap16                    u16WaterSpecificAlarmMask;
#endif

#ifdef CLD_SM_ATTR_HEAT_AND_COOLING_ALARM_MASK
    zbmap16                    u16HeatAndCoolingSpecificAlarmMask;
#endif

#ifdef CLD_SM_ATTR_GAS_ALARM_MASK
    zbmap16                    u16GasAlarmMask;
#endif

    /* Manufacturer Specific Attributes: Measurements */
#ifdef CLD_SM_ATTR_MAN_SPEC_AC_FREQUENCY
    zuint8                    u8ManSpecACFrequency;
#endif
#ifdef CLD_SM_ATTR_MAN_SPEC_RMS_VOLTAGE
    zuint48                    u48ManSpecRMSVoltage;
#endif
#ifdef CLD_SM_ATTR_MAN_SPEC_RMS_CURRENT
    zuint48                    u48ManSpecRMSCurrent;
#endif
#ifdef CLD_SM_ATTR_MAN_SPEC_ACTIVE_POWER
    zuint48                    u48ManSpecActivePower;
#endif

    /* Manufacturer Specific Attribute: Calibration */
#ifdef CLD_SM_ATTR_MAN_SPEC_CALIBRATION_VPP
    zuint48                    u48ManSpecCalibrationVpp;
#endif
#ifdef CLD_SM_ATTR_MAN_SPEC_CALIBRATION_I1PP
   zuint48                    u48ManSpecCalibrationI1pp;
#endif
#ifdef CLD_SM_ATTR_MAN_SPEC_CALIBRATION_I2PP
    zuint48                    u48ManSpecCalibrationI2pp;
#endif
#ifdef CLD_SM_ATTR_MAN_SPEC_CALIBRATION_DELTAPHI1
    zuint48                    u48ManSpecCalibrationDeltaPhi1;
#endif
#ifdef CLD_SM_ATTR_MAN_SPEC_CALIBRATION_DELTAPHI2
    zuint48                    u48ManSpecCalibrationDeltaPhi2;
#endif
#ifdef CLD_SM_ATTR_MAN_SPEC_CALIBRATION_DIVISOR
    zuint24                    u24ManSpecCalibrationDivisor;
#endif
#ifdef CLD_SM_ATTR_MAN_SPEC_POWER_THRESHOLD
    zuint48                    u48ManSpecPowerThreshold;
#endif
#ifdef CLD_SM_ATTR_MAN_SPEC_UPDATE_INTERVAL
    zuint16                    u16ManSpecUpdateInterval;
#endif
#ifdef CLD_SM_ATTR_MAN_SPEC_RF_POWER_CONFIG
    zuint8                    u8ManSpecRfPowerConfig;
#endif

} tsCLD_SimpleMetering;

/*****************************************************************************************
    Configure list of supported attributes and their status
*****************************************************************************************/

#ifdef CLD_SM_SUPPORT_MIRROR
/*****************************************************************************************
    Attribute definition for the mirroring
*****************************************************************************************/

/* Mirroring attribute list for Simple Metering Cluster */
typedef struct
{
   /* Reading information attribute set attribute ID's (D.3.2.2.1) */
    zuint48                    u48CurrentSummationDelivered;        /* Mandatory */

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_SUMMATION_RECEIVED
    zuint48                    u48CurrentSummationReceived;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_MAX_DEMAND_DELIVERED
    zuint48                    u48CurrentMaxDemandDelivered;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_MAX_DEMAND_RECEIVED
    zuint48                    u48CurrentMaxDemandReceived;
#endif

#ifdef CLD_SM_MIRROR_ATTR_DFT_SUMMATION
    zuint48                    u48DFTSummation;
#endif

#ifdef CLD_SM_MIRROR_ATTR_DAILY_FREEZE_TIME
    zuint16                    u16DailyFreezeTime;
#endif

#ifdef CLD_SM_MIRROR_ATTR_POWER_FACTOR
    zint8                    i8PowerFactor;
#endif

#ifdef CLD_SM_MIRROR_ATTR_READING_SNAPSHOT_TIME
    zutctime                utctReadingSnapshotTime;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_MAX_DEMAND_DELIVERED_TIME
    zutctime                utctCurrentMaxDemandDeliveredTime;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_MAX_DEMAND_RECEIVED_TIME
    zutctime                utctCurrentMaxDemandReceivedTime;
#endif

#ifdef CLD_SM_MIRROR_ATTR_PROFILE_INTERVAL_PERIOD
    zenum8                    eProfileIntervalPeriod;
#endif

#ifdef CLD_SM_MIRROR_ATTR_INTERVAL_READ_REPORTING_PERIOD
    uint32                    u32IntervalReadReportingPeriod;
#endif

    /* Time Of Use Information attribute attribute ID's set (D.3.2.2.2) */
#ifdef CLD_SM_MIRROR_ATTR_CURRENT_TIER_1_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier1SummationDelivered;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_TIER_1_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier1SummationReceived;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_TIER_2_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier2SummationDelivered;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_TIER_2_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier2SummationReceived;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_TIER_3_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier3SummationDelivered;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_TIER_3_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier3SummationReceived;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_TIER_4_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier4SummationDelivered;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_TIER_4_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier4SummationReceived;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_TIER_5_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier5SummationDelivered;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_TIER_5_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier5SummationReceived;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_TIER_6_SUMMATION_DELIVERED
    zuint48                    u48CurrentTier6SummationDelivered;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_TIER_6_SUMMATION_RECEIVED
    zuint48                    u48CurrentTier6SummationReceived;
#endif

    /* Meter status attribute set attribute ID's (D.3.2.2.3) */
    zbmap8                    u8MeterStatus;                        /* Mandatory */

    /* Formatting attribute set attribute ID's (D.3.2.2.4) */
    zenum8                    eUnitOfMeasure;                        /* Mandatory */

#ifdef CLD_SM_MIRROR_ATTR_MULTIPLIER
    zuint24                    u24Multiplier;
#endif

#ifdef CLD_SM_MIRROR_ATTR_DIVISOR
    zuint24                    u24Divisor;
#endif

    zbmap8                   u8SummationFormatting;                /* Mandatory */

#ifdef CLD_SM_MIRROR_ATTR_DEMAND_FORMATING
    zbmap8                    u8DemandFormatting;
#endif

#ifdef CLD_SM_MIRROR_ATTR_HISTORICAL_CONSUMPTION_FORMATTING
    zbmap8                    u8HistoricalConsumptionFormatting;
#endif

    zbmap8                    u8MeteringDeviceType;                /* Mandatory */
#ifdef CLD_SM_MIRROR_ATTR_METER_SERIAL_NUMBER
    tsZCL_OctetString         sMeterSerialNumber;
    uint8                     au8MeterSerialNumber[SE_SM_METER_SERIAL_NUMBER_MAX_STRING_LENGTH];
#endif

    /* ESP Historical Consumption set attribute ID's (D.3.2.2.5) */
#ifdef CLD_SM_MIRROR_ATTR_INSTANTANEOUS_DEMAND
    zint24                  i24InstantaneousDemand;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_DAY_CONSUMPTION_DELIVERED
    zuint24                    u24CurrentDayConsumptionDelivered;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_DAY_CONSUMPTION_RECEIVED
    zuint24                    u24CurrentDayConsumptionReceived;
#endif

#ifdef CLD_SM_MIRROR_ATTR_PREVIOUS_DAY_CONSUMPTION_DELIVERED
    zuint24                    u24PreviousDayConsumptionDelivered;
#endif

#ifdef CLD_SM_MIRROR_ATTR_PREVIOUS_DAY_CONSUMPTION_RECEIVED
    zuint24                    u24PreviousDayConsumptionReceived;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_PARTIAL_PROFILE_INTERVAL_START_TIME_DELIVERED
    zutctime                utctCurrentPartialProfileIntervalStartTimeDelivered;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_PARTIAL_PROFILE_INTERVAL_START_TIME_RECEIVED
    zutctime                utctCurrentPartialProfileIntervalStartTimeReceived;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_PARTIAL_PROFILE_INTERVAL_VALUE_DELIVERED
    zuint24                    u24CurrentPartialProfileIntervalValueDelivered;
#endif

#ifdef CLD_SM_MIRROR_ATTR_CURRENT_PARTIAL_PROFILE_INTERVAL_VALUE_RECEIVED
    zuint24                    u24CurrentPartialProfileIntervalValueReceived;
#endif

    /* Load Profile attribute set attribute ID's (D.3.2.2.6) */
#ifdef CLD_SM_MIRROR_ATTR_MAX_NUMBER_OF_PERIODS_DELIVERED
    zuint8                    u8MaxNumberOfPeriodsDelivered;
#endif


    /* Supply Limit attribute set attribute ID's (D.3.2.2.7) */
#ifdef CLD_SM_MIRROR_ATTR_CURRENT_DEMAND_DELIVERED
    zuint24                    u24CurrentDemandDelivered;
#endif

#ifdef CLD_SM_MIRROR_ATTR_DEMAND_LIMIT
    zuint24                    u24DemandLimit;
#endif

#ifdef CLD_SM_MIRROR_ATTR_DEMAND_INTEGRATION_PERIOD
    zuint8                    u8DemandIntegrationPeriod;
#endif

#ifdef CLD_SM_MIRROR_ATTR_NUMBER_OF_DEMAND_SUBINTERVALS
    zuint8                    u8NumberOfDemandSubintervals;
#endif

    /* Manufacturer Specific Attributes: Measurements */
#ifdef CLD_SM_MIRROR_ATTR_MAN_SPEC_AC_FREQUENCY
    zuint8                    u8ManSpecACFrequency;
#endif
#ifdef CLD_SM_MIRROR_ATTR_MAN_SPEC_RMS_VOLTAGE
    zuint48                    u48ManSpecRMSVoltage;
#endif
#ifdef CLD_SM_MIRROR_ATTR_MAN_SPEC_RMS_CURRENT
    zuint48                    u48ManSpecRMSCurrent;
#endif
#ifdef CLD_SM_MIRROR_ATTR_MAN_SPEC_ACTIVE_POWER
    zuint48                    u48ManSpecActivePower;
#endif
    /* Manufacturer Specific Attributes: Calibration */
#ifdef CLD_SM_MIRROR_ATTR_MAN_SPEC_CALIBRATION_VPP
    zuint48                    u48ManSpecCalibrationVpp;
#endif
#ifdef CLD_SM_MIRROR_ATTR_MAN_SPEC_CALIBRATION_I1PP
   zuint48                    u48ManSpecCalibrationI1pp;
#endif
#ifdef CLD_SM_MIRROR_ATTR_MAN_SPEC_CALIBRATION_I2PP
    zuint48                    u48ManSpecCalibrationI2pp;
#endif
#ifdef CLD_SM_MIRROR_ATTR_MAN_SPEC_CALIBRATION_DELTAPHI1
    zuint48                    u48ManSpecCalibrationDeltaPhi1;
#endif
#ifdef CLD_SM_MIRROR_ATTR_MAN_SPEC_CALIBRATION_DELTAPHI2
    zuint48                    u48ManSpecCalibrationDeltaPhi2;
#endif
} tsCLD_Mirror_SM;
#endif /*CLD_SM_SUPPORT_MIRROR*/
/*****************************************************************************************
    Attribute status definition for the mirroring
*****************************************************************************************/

typedef enum 
{
    E_CLD_SM_STATUS_SUCCESS,
    E_CLD_SM_STATUS_UNDEFINED_INTERVAL_CHANNEL,
    E_CLD_SM_STATUS_INTERVAL_NOT_SUPPORTED,
    E_CLD_SM_STATUS_INVALID_END_TIME,
    E_CLD_SM_STATUS_MORE_PERIODS_REQUESTED_THAN_SUPPORTED,
    E_CLD_SM_STATUS_NO_INTERVALS_AVAILABLE_FOR_REQUESTED_TIME,
    E_CLD_SM_STATUS_EP_NOT_AVAILABLE,
    E_CLD_SM_STATUS_MIRROR_EP_NOT_FOUND
}teSM_Status;


typedef enum 
{
    E_CLD_SM_TIME_FRAME_DAILY,
    E_CLD_SM_TIME_FRAME_60MINS,
    E_CLD_SM_TIME_FRAME_30MINS,
    E_CLD_SM_TIME_FRAME_15MINS,
    E_CLD_SM_TIME_FRAME_10MINS,
    E_CLD_SM_TIME_FRAME_7_5MINS,
    E_CLD_SM_TIME_FRAME_5MINS,
    E_CLD_SM_TIME_FRAME_2_5MINS
}teSM_TimeFrame;

/*Following set of commands received at Client*/
typedef enum 
{
    E_CLD_SM_GET_PROFILE_RESPONSE,
    E_CLD_SM_REQUEST_MIRROR,
    E_CLD_SM_REMOVE_MIRROR,
    E_CLD_SM_REQUEST_FAST_POLL_MODE_RESPONSE,
    E_CLD_SM_CLIENT_ERROR,
    E_CLD_SM_NUM_CLIENT_EVENTS
}teSM_ClusterServerCommands;

typedef enum 
{
    E_CLD_SM_CLIENT_RECEIVED_COMMAND,        /*Received command at SM Client*/
    E_CLD_SM_SERVER_RECEIVED_COMMAND,        /*Received command at SM Server*/
    E_CLD_SM_FAST_POLLING_TIMER_EXPIRED,     /*fast polling timer expired*/
}teSM_CallBackEventType;

/*Following set of commands received at Server*/
typedef enum 
{
    E_CLD_SM_GET_PROFILE,
    E_CLD_SM_REQUEST_MIRROR_RESPONSE,
    E_CLD_SM_MIRROR_REMOVED,
    E_CLD_SM_REQUEST_FAST_POLL_MODE,
    E_CLD_SM_SERVER_ERROR,
    E_CLD_SM_NUM_SERVER_EVENTS
}teSM_ClusterClientCommands;

typedef enum 
{
    E_CLD_SM_CONSUMPTION_DELIVERED,
    E_CLD_SM_CONSUMPTION_RECEIVED
}teSM_IntervalChannel;

typedef struct
{
    uint32              u32Endtime;
    teSM_Status         eStatus;
    teSM_TimeFrame      u8ProfileIntervalPeriod;
    uint8               u8NumberOfPeriodsDelivered;
    zuint24             *pau24Intervals;
}tsSM_GetProfileResponseCommand;

typedef struct
{
    uint32  u32FastPollEndTime;
    uint8   u8AppliedUpdatePeriod;
}tsSM_RequestFastPollResponseCommand;

typedef struct
{
    teSM_IntervalChannel    eIntervalChannel;
    uint32                  u32EndTime;
    uint8                   u8NumberOfPeriods;
}tsSM_GetProfileCommand;

// Reordered for SE1.7
typedef struct
{
    teSM_IntervalChannel    eIntervalChannel;
    uint8                   u8NumberOfPeriods;
    uint8                   u8SourceEndPoint;
    uint8                   u8DestinationEndPoint;
    uint32                  u32EndTime;
    tsZCL_Address           sSourceAddress;

}tsSM_GetProfileRequestCommand;

typedef struct
{
    uint16 u16Endpoint;
}tsSM_RequestMirrorResponseCommand;

typedef struct
{
    uint16 u16Endpoint;
}tsSM_MirrorRemovedResponseCommand;

typedef struct
{
    uint8   u8FastPollUpdatePeriod;
    uint8   u8Duration;
    uint8   u8AppliedUpdatePeriod;
    bool    bReadyToPoll;
    uint32  u32FastPollEndTime;
}tsSM_RequestFastPollCommand;

typedef struct
{
    uint8 u8Endpoint;
    uint8 u8Status;
}tsSM_Error;

typedef struct
{
    teSM_CallBackEventType  eEventType;
    uint8                   u8CommandId;

    union
    {
        tsSM_GetProfileResponseCommand       sGetProfileResponseCommand;
        tsSM_RequestFastPollResponseCommand  sRequestFastPollResponseCommand;
        tsSM_GetProfileRequestCommand        sGetProfileCommand;
        tsSM_RequestMirrorResponseCommand    sRequestMirrorResponseCommand;
        tsSM_MirrorRemovedResponseCommand    sMirrorRemovedResponseCommand;
        tsSM_RequestFastPollCommand          sRequestFastPollCommand;
        tsSM_Error                           sError;
    }uMessage;

}tsSM_CallBackMessage;

typedef struct
{
    tsZCL_ReceiveEventAddress  sReceiveEventAddress;
    tsZCL_CallBackEvent        sSMCustomCallBackEvent;
    tsSM_CallBackMessage       sSMCallBackMessage;
} tsSM_CustomStruct;

#ifdef CLD_SM_SUPPORT_MIRROR
typedef struct
{
   /*Basic Cluster Instance*/
    tsZCL_ClusterInstance sBasicCluster;

    /* SM Cluster Instance */
    tsZCL_ClusterInstance sSM_Cluster;

}tsSE_MirrorClusterInstances;

/* Holds EP and its associated details required to create an instance of a Mirror */
typedef struct
{
    /*Mirrored EndPoint*/
    tsZCL_EndPointDefinition        sEndPoint;

    /*Mirror Requester address*/
    uint64                          u64SourceAddress;

    /*Mirror cluster instances*/
    tsSE_MirrorClusterInstances     sSEMirrorClusterInstances;

    /*Event Address, Custom call back event, Custom call back message*/
    tsSM_CustomStruct               sSMMirrorCustomDataStruct;

}tsSE_Mirror;

#endif /*CLD_SM_SUPPORT_MIRROR*/

#ifdef CLD_SM_SUPPORT_GET_PROFILE
#define CLD_SM_PROFILE_INTERVAL_VALUE_DELIVERED  0x00
#define CLD_SM_PROFILE_INTERVAL_VALUE_RECEIVED   0x01
#ifdef SM_SERVER
typedef struct
{
    uint32 u32UtcTime;
#ifdef CLD_SM_ATTR_CURRENT_PARTIAL_PROFILE_INTERVAL_VALUE_RECEIVED
    zuint24 u24ConsumptionReceived;
#endif

#ifdef CLD_SM_ATTR_CURRENT_PARTIAL_PROFILE_INTERVAL_VALUE_DELIVERED
    zuint24 u24ConsumptionDelivered;
#endif
}tsSEGetProfile;

uint8               u8GetProfileCntr;
uint8               b8SupportedChannels;
tsSEGetProfile      sSEGetProfile[CLD_SM_GETPROFILE_MAX_NO_INTERVALS];
#endif /*SM_SERVER*/

#endif/*CLD_SM_SUPPORT_GET_PROFILE*/

#ifdef CLD_SM_SUPPORT_FAST_POLL_MODE

#ifdef SM_SERVER
//Required for maintaining fast polling update.
typedef struct
{
    bool        bFastPollModeEnabled;
    uint32      u32FastPollEndTime;
    uint32      u32MaxFastPollDuration;
}tsSE_FastPollModeStatus;

#endif /*SM_SERVER*/

#endif /*CLD_SM_SUPPORT_FAST_POLL_MODE*/

/****************************************************************************/
/***        Exported Functions                                            ***/
/****************************************************************************/
#ifdef CLD_SM_SUPPORT_GET_PROFILE
#ifdef SM_CLIENT
PUBLIC teZCL_Status eSM_ClientGetProfileCommand(
                    uint8           u8SourceEndpoint,
                    uint8           u8DestinationEndpoint,
                    tsZCL_Address   *psDestinationAddress,
                    uint8           u8IntervalChannel,
                    uint32          u32EndTime,
                    uint8           u8NumberOfPeriods);

PUBLIC uint32 u32SM_GetReceivedProfileData(
                    tsSM_GetProfileResponseCommand *psSMGetProfileResponseCommand);

#endif

#ifdef SM_SERVER
PUBLIC teZCL_Status eSM_ServerUpdateConsumption (
                    uint8   u8SourceEndPointId,
                    uint32  u32UtcTime);

PUBLIC teZCL_Status vSM_GetProfileBufferedData(
                    uint8           u8SourceEndPointId,
                    tsSEGetProfile  *psSEGetProfile);

PUBLIC teZCL_Status vSM_SetProfileBufferedData(
                    uint8           u8SourceEndPointId,
                    tsSEGetProfile  *psSEGetProfile);

#endif

#endif/*CLD_SM_SUPPORT_GET_PROFILE*/


#ifdef CLD_SM_SUPPORT_MIRROR

PUBLIC teZCL_Status eSM_ClientRequestMirrorResponseCommand(
                    uint8               u8SourceEndpoint,
                    uint8               u8DestinationEndpoint,
                    tsZCL_Address       *psDestinationAddress,
                    uint16              u16MirroredEP);

PUBLIC teZCL_Status eSM_ClientMirrorRemovedCommand(
                    uint8           u8SourceEndpoint,
                    uint8           u8DestinationEndpoint,
                    tsZCL_Address   *psDestinationAddress);



PUBLIC teZCL_Status eSE_RegisterMirroredSMClusters(
                    uint8                   u8MirrorNum,
                    uint8                   u8MirrorStartEndPoint,
                    tsZCL_ClusterInstance   *psClusterInstance,
                    void                    *pvEndPointSharedStructPtr,
                    tsSM_CustomStruct       *psCustomDataStruct);

PUBLIC teZCL_Status eSM_GetFreeMirrorEndPoint(uint16 *pu16FreeEP);

PUBLIC teZCL_ReportAttributeStatus eSM_IsMirrorSourceAddressValid (
                    tsZCL_ReportAttributeMirror *sZCL_ReportAttributeMirror);

PUBLIC teSM_Status eSM_CreateMirror(
                    uint8   u8MirrorEndPoint,
                    uint64  u64RemoteIeeeAddress);

PUBLIC teSM_Status eSM_RemoveMirror(
                    uint8  u8MirrorEndpoint,
                    uint64 u64RemoteIeeeAddress);

#endif
PUBLIC teZCL_Status eSM_ServerRequestMirrorCommand(
                    uint8           u8SourceEndpoint,
                    uint8           u8DestinationEndpoint,
                    tsZCL_Address   *psDestinationAddress);

PUBLIC teZCL_Status eSM_ServerRemoveMirrorCommand(
                    uint8           u8SourceEndpoint,
                    uint8           u8DestinationEndpoint,
                    tsZCL_Address   *psDestinationAddress);

#ifdef CLD_SM_SUPPORT_FAST_POLL_MODE
PUBLIC teZCL_Status eSM_ClientRequestFastPollCommand(
                    uint8           u8SourceEndpoint,
                    uint8           u8DestinationEndpoint,
                    tsZCL_Address   *psDestinationAddress,
                    uint8           u8FastPollUpdatePeriod,
                    uint8           u8Duration);
#endif

PUBLIC teZCL_Status eSimpleMeteringCommandHandler(
                    ZPS_tsAfEvent               *pZPSevent,
                    tsZCL_EndPointDefinition    *psEndPointDefinition,
                    tsZCL_ClusterInstance       *psClusterInstance);

PUBLIC teZCL_Status eSE_SMCreate(
                    uint8                               u8Endpoint,
                    bool_t                              bIsServer,
                    uint8                               *pu8AttributeControlBits,
                    tsZCL_ClusterInstance               *psClusterInstance,
                    tsZCL_ClusterDefinition             *psClusterDefinition,
                    tsSM_CustomStruct                   *psCustomDataStruct,
                    void                                *pvEndPointSharedStructPtr);

PUBLIC teZCL_Status eSM_RegisterTimeServer(void);

PUBLIC teZCL_Status eSE_FindSimpleMeteringCluster(
                    uint8                           u8SourceEndPointId,
                    bool_t                          bIsServer,
                    tsZCL_EndPointDefinition        **ppsEndPointDefinition,
                    tsZCL_ClusterInstance           **ppsClusterInstance,
                    tsSM_CustomStruct               **ppsSM_CustomStruct);

/****************************************************************************/
/***        External Variables                                            ***/
/****************************************************************************/

extern const tsZCL_AttributeDefinition asCLD_SimpleMeteringClusterAttributeDefinitions[];
extern tsZCL_ClusterDefinition sCLD_SimpleMetering;
extern tsZCL_ClusterDefinition sCLD_SMClientNoAttribute;
extern uint8 au8SimpleMeteringServerAttributeControlBits[];

#ifdef CLD_SM_SUPPORT_MIRROR

tsZCL_ClusterDefinition sCLD_SM_Mirror[CLD_SM_NUMBER_OF_MIRRORS];

/*Holding Mirror details, for SE Sub modules */
tsSE_Mirror             *psSE_Mirror;
#endif

/* Include attribute count file here so that all macros are defined */
#include "SimpleMeteringAttributeCount.h"
/****************************************************************************/
/***        END OF FILE                                                   ***/
/****************************************************************************/

#endif /* SIMPLE_METERING_H */

