#ifndef __OCPP16_CONFIGKEY_H__
#define __OCPP16_CONFIGKEY_H__
#include "msystem.h"
#include "ocpp16.h"


/***********************************************************************************************************************************/
typedef struct CoreProfile
{
    int AllowOfflineTxForUnknownId;//9.1.1      //离线时，允许无名卡自动认证，只要不被AuthorizationCache和LocalAuthorizationList标识为禁止
    int AuthorizationCacheEnabled;//9.1.2       //认证请求，需要保存结果到AuthorizationCache
    int AuthorizeRemoteTxRequests;//9.1.3       //remoteStartTramsation是否需要Authorize
    int BlinkRepeat;//9.1.4
    int ClockAlignedDataInterval;// unit = seconds  9.1.5
    int ConnectionTimeOut; //  unit = seconds  9.1.6

    uint8_t ConnectorPhaseRotation[512];//9.1.7
    int ConnectorPhaseRotationMaxLength;//9.1.8

    int GetConfigurationMaxKeys;//9.1.9
    int HeartbeatInterval;//9.1.10

    int LightIntensity;//9.1.11

    int LocalAuthorizeOffline;//9.1.12      //a Charge Point will authorize a user when offline using the Authorization Cache and/or the Local Authorization Lis

    int LocalPreAuthorize;//9.1.13      //允许CP略过CS使用AuthorizationCache和LocalAuthorizationList提前认证

    int MaxEnergyOnInvalidId;//9.1.14

    uint32_t MeterValuesAlignedData;//9.1.15
    int MeterValuesAlignedDataMaxLength;//9.1.16

    uint32_t MeterValuesSampledData;//9.1.17
    int MeterValuesSampledDataMaxLength;//9.1.18
    int MeterValueSampleInterval;//9.1.19

    int MinimumStatusDuration;//9.1.20
    int NumberOfConnectors;//9.1.21

    int ResetRetries;//9.1.22

    int StopTransactionOnEVSideDisconnect;//9.1.23
    int StopTransactionOnInvalidId;//9.1.24

    uint32_t StopTxnAlignedData;//9.1.25
    int StopTxnAlignedDataMaxLength;//9.1.26

    uint32_t StopTxnSampledData;//9.1.27
    int StopTxnSampledDataMaxLength;//9.1.28

    uint8_t SupportedFeatureProfiles[128];//9.1.29
    int SupportedFeatureProfilesMaxLength;//9.1.30

    int TransactionMessageAttempts;//9.1.31
    int TransactionMessageRetryInterval;//9.1.32

    int UnlockConnectorOnEVSideDisconnect;//9.1.33

    int WebSocketPingInterval;//9.1.34

    uint8_t AuthorizationKey[40];

    int AuthorizationCacheMaxLength;//extern 
}CoreProfile_t;

typedef struct LocalAuthListManagemenProfile
{
    int LocalAuthListEnabled;
    int LocalAuthListMaxLength;
    int SendLocalListMaxLength;
}LocalAuthListManagemenProfile_t;

typedef struct ReservationProfile
{
    int ReserveConnectorZeroSupported;
}ReservationProfile_t;

typedef struct SmartChargingProfile
{
    int ChargeProfileMaxStackLevel;
    uint32_t ChargingScheduleAllowedChargingRateUnit;
    int ChargingScheduleMaxPeriods;
    int ConnectorSwitch3to1PhaseSupported;
    int MaxChargingProfilesInstalled;
}SmartChargingProfile_t;


typedef struct ocpp16_configkeys
{
    CoreProfile_t  coreProfile;
    LocalAuthListManagemenProfile_t localAuthListManagemenProfile;
    ReservationProfile_t reservationProfile;
    SmartChargingProfile_t smartChargingProfile;
}ocpp16_configkeys_t;

/****************************************************************************************************/
uint32_t Measurand_fromString(char* namelist);
const char* Measurand_toString(char* stream, uint32_t measurand);

uint32_t ChargingScheduleAllowedChargingRateUnit_fromString(char* string);
char* ChargingScheduleAllowedChargingRateUnit_toString(char*stream, uint32_t type);

extern ocpp16_configkeys_t ocpp16_configkeys;

void ocpp16_configkey_load(ocpp16_configkeys_t* configkeys, const char* filename);
void ocpp16_configkey_save(ocpp16_configkeys_t* configkeys, const char* filename);

void ocpp16_configkey_init(void);
void ocpp16_configkey_exit(void);

#endif//__OCPP16_CONFIGKEY_H__
