#ifndef __OCPP21_DATATYPE_H__
#define __OCPP21_DATATYPE_H__
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
#include "cJSON.h"
#include "ocpp21_enum.h"

typedef char dateTime_t[64];

//2.1
typedef struct AbsolutePriceScheduleType
{
    dateTime_t      timeAnchor;
    int             priceScheduleID;

    char            priceScheduleDescription[164];
    int             priceScheduleDescription_isUsed;

    char            currency[4];
    int             currency_isUsed;

    char            language[12];
    int             language_isUsed;

    char            priceAlgorithm[2004];
    int             priceAlgorithm_isUsed;

}AbsolutePriceScheduleType_t;
int AbsolutePriceScheduleType_encode(cJSON *parent, const char* name, AbsolutePriceScheduleType_t *value);
int AbsolutePriceScheduleType_decode(cJSON *object, AbsolutePriceScheduleType_t *value);

//2.2
typedef struct ACChargingParametersType
{
    float           energyAmount;
    float           evMinCurrent;
    float           evMaxCurrent;
    float           evMaxVoltage;
}ACChargingParametersType_t;
int ACChargingParametersType_encode(cJSON *parent, const char* name, ACChargingParametersType_t *value);
int ACChargingParametersType_decode(cJSON *object, ACChargingParametersType_t *value);

//2.3
typedef struct AdditionalInfoType
{
    char            additionalIdToken[260];
    char            type[54];
}AdditionalInfoType_t;
int AdditionalInfoType_encode(cJSON *parent, const char* name, AdditionalInfoType_t *value);
int AdditionalInfoType_decode(cJSON *object, AdditionalInfoType_t *value);

//2.81
typedef struct RationalNumberType
{
    float           exponent;
    float           value;
}RationalNumberType_t;
int RationalNumberType_encode(cJSON *parent, const char* name, RationalNumberType_t *value);
int RationalNumberType_decode(cJSON *object, RationalNumberType_t *value);

//2.4
typedef struct AdditionalSelectedServicesType
{
    char            serviceName[84];
    RationalNumberType_t serviceFee;
}AdditionalSelectedServicesType_t;
int AdditionalSelectedServicesType_encode(cJSON *parent, const char* name, AdditionalSelectedServicesType_t *value);
int AdditionalSelectedServicesType_decode(cJSON *object, AdditionalSelectedServicesType_t *value);

//2.5
typedef struct AddressType
{
    char            name[54];
    char            address1[104];
    int             address2_isUsed;
    char            address2[104];
    char            city[104];
    int             postcode_isUsed;
    char            postcode[24];
    char            country[54];
}AddressType_t;
int AddressType_encode(cJSON *parent, const char* name, AddressType_t *value);

//2.6
typedef struct APNType
{
    char            apn[2004];
    int             anpUserName_isUsed;
    char            anpUserName[54];
    int             anpPassword_isUsed;
    char            anpPassword[54];
    int             simPin_isUsed;
    char            simPin[54];
    int             preferredNetwork_isUsed;
    char            preferredNetwork[54];
    int             useOnlyPreferredNetwork_isUsed;
    int             useOnlyPreferredNetwork;
    APNAuthenticationEnumType_t apnAuthentication;
}APNType_t;
int APNType_encode(cJSON *parent, const char* name, APNType_t *value);
int APNType_decode(cJSON *object, APNType_t *value);

//2.61
typedef struct IdTokenType
{
    char            type[24];
    AdditionalInfoType_t additionalInfo;
}IdTokenType_t;

//2.66
typedef struct MessageContentType
{
    MessageFormatEnumType_t         format;
    char                            language[12];
    char                            content[1028];
}MessageContentType_t;

//2.60
typedef struct IdTokenInfoType
{
    AuthorizationStatusEnumType_t   status;
    dateTime_t                      cacheExpiryDateTime;
    int                             cacheExpiryDateTime_isUsed;
    int                             chargingPriority;
    int                             chargingPriority_isUsed;
    char                            language1[12];
    int                             language1_isUsed;
    char                            language2[12];
    int                             language2_isUsed;
    int                             evseId;
    IdTokenType_t                   groupIdToken;
    MessageContentType_t            personalMessage;
}IdTokenInfoType_t;

//2.7
typedef struct AuthorizationData
{
    /* data */
}AuthorizationData_t;


//2.10
typedef struct CertificateHashDataType
{
    HashAlgorithmEnumType_t     hashAlgorithm;
    char                        issuerNameHash[132];
    char                        issuerKeyHash[132];
    char                        serialNumber[44];
}CertificateHashDataType_t;


//2.9
#define MAX_ChildCertificateHashData_Len 10
typedef struct CertificateHashDataChainType
{
    GetCertificateIdUseEnumType_t certificateType;
    CertificateHashDataType_t     certificateHashData;
    CertificateHashDataType_t     childCertificateHashData[MAX_ChildCertificateHashData_Len];
    int                           childCertificateHashData_Len;
    int                           childCertificateHashData_isUsed;
}CertificateHashDataChainType_t;

//-------------------------------------------------------------------------------


//-------------------------------------------------------------------------------

//2.115
typedef struct V2XSignalWattPointType
{
    int                     signal;
    float                   power;
}V2XSignalWattPointType_t;
int V2XSignalWattPointType_encode(cJSON *parent, const char* name, V2XSignalWattPointType_t *value);
int V2XSignalWattPointType_decode(cJSON *object, V2XSignalWattPointType_t *value);

//2.116
typedef struct VariableAttributeType
{
    AttributeEnumType_t     type;
    int                     type_isUsed;

    char                    value[2504];
    int                     value_isUsed;

    MutabilityEnumType_t    mutability;
    int                     mutability_isUsed;

    int                     persistent;
    int                     persistent_isUsed;

    int                     constant;
    int                     constant_isUsed;
}VariableAttributeType_t;
int VariableAttributeType_encode(cJSON *parent, const char* name, VariableAttributeType_t *value);
int VariableAttributeType_decode(cJSON *object, VariableAttributeType_t *value);

//2.117
typedef struct VariableCharacteristicsType
{
    char                    unit[20];
    int                     unit_isUsed;

    DataEnumType_t          dataType;

    float                   minLimit;
    int                     minLimit_isUsed;

    float                   maxLimit;
    int                     maxLimit_isUsed;

    int                     maxElements;
    int                     maxElements_isUsed;

    char                    valuesList[1004];
    int                     valuesList_isUsed;

    int                     supportsMonitoring;
}VariableCharacteristicsType_t;
int VariableCharacteristicsType_encode(cJSON *parent, const char* name, VariableCharacteristicsType_t *value);
int VariableCharacteristicsType_decode(cJSON *object, VariableCharacteristicsType_t *value);

//2.118
typedef struct VariableMonitoringType
{
    int                     id;
    int                     transaction;
    int                     value;
    MonitorEnumType_t       type;
    int                     severity;
    EventNotificationEnumType_t eventNotificationType;
}VariableMonitoringType_t;
int VariableMonitoringType_encode(cJSON *parent, const char* name, VariableMonitoringType_t *value);
int VariableMonitoringType_decode(cJSON *object, VariableMonitoringType_t *value);

//2.119
typedef struct VariableType
{
    char            name[54];
    int             instance_isUsed;
    char            instance[54];
}VariableType_t;
int VariableType_encode(cJSON *parent, const char* name, VariableType_t *value);
int VariableType_decode(cJSON *object, VariableType_t *value);

//2.120
typedef struct VoltageParamsType
{
    int             hv10MinMeanValue_isUsed;
    float           hv10MinMeanValue;
    int             hv10MinMeanTripDelay_isUsed;
    float           hv10MinMeanTripDelay;
    int             powerDuringCessation_isUsed;
    PowerDuringCessationEnumType_t powerDuringCessation;
}VoltageParamsType_t;
int VoltageParamsType_encode(cJSON *parent, const char* name, VoltageParamsType_t *value);
int VoltageParamsType_decode(cJSON *object, VoltageParamsType_t *value);

//2.121
typedef struct VPNType
{
    char            server[2004];
    char            user[54];
    int             group_isUsed;
    char            group[54];
    char            password[68];
    char            key[260];
    VPNEnumType_t   type;
}VPNType_t;
int VPNType_encode(cJSON *parent, const char* name, VPNType_t *value);
int VPNType_decode(cJSON *object, VPNType_t *value);


#endif//__OCPP21_DATATYPE_H__