﻿#pragma once

#include "jidu_macro.h"

using namespace std;

//TODO 存储服务器端获取的信息
class OrderInfo
{
public:
	string strCCPCode;
	vector<string> m_vecEcuName;
};

//TODO 存储车辆信息
class VehicleInfo
{
public:
	CBinary binCCP;
	vector<string> vecEcuName;
	vector<uint16_t> vecEcuId;
	string baseLine;
	vector<string> vecEcuNameOrderByInitial;
	map<uint16_t, JD_VehicleEcuInfo_t> mapEcuInfo;
	string tpmsId;
	string batteryRemain = "未知";
	string vehicleType = "MarsOne";
	int sshStaus; //1:打开 0:关闭
	int chargingIsOpen; //1:成功 0:失败
	int gloveboxIsOpen;//1:成功 0:失败
	int powerType = 0;	//CCP#962 获取高压平台电压(0:400V 02:800V)
	int carType = 0;	//CCP#950 获取车型(1:MarsOne 02:Venus)
	int carTypeId = 0;	//获取车型(MarsOne:CCP#966  Venus:CCP#967)
	int empennage;		//CCP#564 （01:是低配无主动尾翼；02:是高配有尾翼）
};

class VehicleCfg
{
public:
	float iBatteryCapacity;	//电池容量
	string strMotor;		//驱动能力
	string strWpcEcuName;	//WpcEcuName
	string strBecmEcuName;	//BecmEcuName
	string strWpcConfig;	//手机无线充电
	uint8_t iEmpennage;		//是否有主动尾翼
	int iPlatformVoltage;	//高压平台(0:400V 02:800V)
	string strIemEcuName;	//IemEcuName
};

class CallServerRecord
{
public:
	string host;
	string uri;
	string method;
	string body;
	string response;
};

class DataCenter
{
public:
	DataCenter();
	void reset();
	static DataCenter* getInstance() {
		if (instance == NULL) {
			instance = new DataCenter();
		}

		return instance;
	}
	static JD_VEHICLE_ORDER_t m_VehicleOrderInfo;
	map<string, JD_ECU_SAFETY_CONSTANT_t> m_EcuSafetyConstant;
	static JD_EOL_KEY_t m_EolKey;
	static JD_OTA_CERT_t m_OtaCert;
	static map<string, string>m_aesKey;
	static JD_SummaryData_t m_summaryData;
	static JD_EcuCertInfo_t m_EcuCertInfo;
	static string m_deviceSN;
	static map<string, JD_EcuStatusInfo_t> m_EcuStatus;
	static string errMsg;
	static string factory;
	static string language;
	static VehicleInfo m_vehicleInfo;
	static JD_ECU_DIAGNOSTIC_INFO_t m_EcuBncmCloudInfo;
	static vector<JD_ECU_DIAGNOSTIC_INFO_t> m_vecEcuDiagnosticInfo;
	static map<string, vector<JIDU_DTC_INFO_t>> m_mapDtcDatabase;
	static map<int, CallServerRecord> m_callServerRecord;
	static std::vector<EbocInfo> m_vecEbocInfo;
private:
	static DataCenter* instance;

public:
	bool setEcuSafetyConstant(string ecuName, JD_ECU_SAFETY_CONSTANT_t safetyConstant);
	bool getEcuSafetyConstant(string ecuName, JD_ECU_SAFETY_CONSTANT_t& safetyConstant);

	bool getCarConfig(CBinary ccp, VehicleCfg& cfg);
	int getCarConfig(CBinary ccp);
	int getCarConfig(string ccp);
};

