﻿#ifndef _JIDU_MACRO_H_
#define _JIDU_MACRO_H_

#include <vector>
#include <string>
#include <map>
#include "binary.h"
#include "vbf/VBFParserSmall.h"

using namespace std;

class EbocInfo
{
public:
	std::string creator;
	std::string featureCode;
	std::string featureName;
	std::string featureFamilyName;
	int64_t createTime;
	std::string featureFamilyCname;
	std::string vin;
	int32_t id;
	std::string featureFamilyCode;
	std::string featureCname;
};

typedef struct JD_ECU_SWPN_INFO
{
	string strPackageType;
	string strEcuSwpn;
}JD_ECU_SWPN_INFO_t;

typedef struct JD_ECU_SOFT_INFO
{
	string strSW;
	string strEcuHwpn;//硬件版本号//F1AA
	vector<string> vecEcuSwpn;//软件版本号//F1AE
	string strSN;//序列号 //F18C
	string strBaseNum;//整车基线版本号 F150
	string strFOTARecord;//FOTA 记录， F154
	string strDiagPartNo;//F1A0 诊断零件号
}JD_ECU_SOFT_INFO_t;

typedef struct JD_ECU_INFO
{
	unsigned int nEcuId;
	string strEcuName;
	string strEcuHwpn;
	string strEcuDn;
	vector<JD_ECU_SWPN_INFO_t> vecEcuSwpnList;
}JD_ECU_INFO_t;

typedef struct JD_VEHICLE_ORDER
{
	string strVin;
	string strMixNo;
	string strCCPCode;
	string strVehicleType; //"MarsOne"
	string strEBOC;
	string strBaseLine;
	string strDisplayVersion;
	string strSwpn;
	string strTpmsId;
	string strTpmsSupplierId;
	int iVehicleEnvironment;
	vector<JD_ECU_INFO_t> vecListEcu;
	vector<JD_ECU_INFO_t> vecListEcuNew;
}JD_VEHICLE_ORDER_t;


typedef struct JD_ECU_SAFETY_CONSTANT
{
	string keySwdl;
	string keyImmo;
	string keySal;
	string keyCommon;
}JD_ECU_SAFETY_CONSTANT_t;

typedef struct JD_OTA_CERT {
	string caCert;
	string clientCert;
}JD_OTA_CERT_t;


typedef struct JD_EOL_KEY {

	string immoKeyEcm;
	string immoKeyIem;
	string immoKeyMgm;
	string immoKeyRemote;
	string dkBncmBgm;
	string powerRootKey;
	string powerRootKeyId;
}JD_EOL_KEY_t;

typedef enum {
	App_Env_Dev = 1,
	App_Env_Test = 2,
	App_Env_Staging = 3,
	App_Env_Prod = 4,
	App_Env_ProdTest = 5,
	App_Env_ProdStaging = 6
}App_Env_t;

typedef struct
{
	std::string strFileName;
	std::string strFileType;
	std::string strVersion;
}JD_VSP_FLASH_INFO_t;

typedef struct JD_VSP_FLASH_CONFIG
{
	std::string strFileName;
	std::string strFileType;
	std::string strVersion;

	std::string strSoftName;
	std::string strkeyId;
	std::string strKeyInfo;
	std::string strSignature;
	std::string strLocalPath;
	uint64_t nFlashFileSize = 0;
	VBFParserSmall* pVBFParser = NULL;
}JD_VSP_FLASH_CONFIG_t;

typedef struct JD_MAPPING_CONFIG
{
	vector<std::string> vecAppList;
	vector<std::string> vecDataList;
	vector<std::string> vecSblList;
	vector<JD_VSP_FLASH_INFO_t> vecOderList;
	std::string strHwpn;
}JD_MAPPING_CONFIG_t;

typedef struct JD_FLASH_PRECONDITION
{
	unsigned int nEcuId = 0;
	std::string strEcuName;
	vector<std::string> vecHwPn;
}JD_FLASH_PRECONDITION_t;

typedef struct JD_ECU_CONFIG
{
	unsigned int nDoipAddr = 0;
	int nEcuGroup = 0;
	unsigned int nEcuId = 0;
	std::string strBoomEcuName;
	std::string strEcuName;
	int nEcuOrder = 0;
	vector<JD_MAPPING_CONFIG_t> vecMapping;
	vector<JD_FLASH_PRECONDITION_t> vecPreconditionList;
}JD_ECU_CONFIG_t;

//VSP config.json配置文件保存
typedef struct JD_VEHICLE_CONFIG
{
	std::string strBaseLine;
	std::string strDisplayBaseLine; // add by njb 20230206 用于ECOS Display_Baseline_Number_Check功能
	std::string strBaseLineVer; // add by njb 20230206 用于ECOS Display_Baseline_Number_Check功能

	vector<JD_ECU_CONFIG_t> vecListEcu;
}JD_VEHICLE_CONFIG_t;


typedef enum JIDU_ECU_STATUS
{
	JIDU_ECU_STATUS_Not_Mounted = 0,//0:ECU未配置
	JIDU_ECU_STATUS_OffLine,//1:ECU离线
	JIDU_ECU_STATUS_OnLine,//2:ECU在线且不需要升级
	JIDU_ECU_STATUS_Update,//3:ECU升级失败，需要重新升级
	JIDU_ECU_STATUS_HW_NotMatch,//4: ecu硬件版本号不匹配
	JIDU_ECU_STATUS_SW_NotMatch,//5: ecu软件版本号不匹配
	JIDU_ECU_STATUS_Flash_Condition_NotMatch,//硬件依赖检查未通过;ecu刷写条件不满足;
	//JIDU_ECU_STATUS_F18C_ReadFail,
	//JIDU_ECU_STATUS_F1A0_ReadFail
}JIDU_ECU_STATUS_t;

typedef enum JIDU_ECU_FOTA_STATUS
{
	JIDU_ECU_FOTA_STATUS_No_Reulst = 0,//0:无结果
	JIDU_ECU_FOTA_STATUS_OffLine,//1:ECU离线未检测到ECU
	JIDU_ECU_FOTA_STATUS_HW_ERROR,//2:ECU硬件版本不匹配
	JIDU_ECU_FOTA_STATUS_UpdateFail,//3:ECU升级失败
	JIDU_ECU_FOTA_STATUS_UpdateOK,//4:Fota升级成功
	JIDU_ECU_FOTA_STATUS_Not_Mounted//5:选装件，不需要Fota
}JIDU_ECU_FOTA_STATUS_t;

typedef enum JIDU_ECU_CONFIG_STATUS
{
	//0:未安装； 1:高配; 2:低配
	JIDU_ECU_CONFIG_STATUS_Not_Mounted = 0,
	JIDU_ECU_CONFIG_STATUS_HIGH,
	JIDU_ECU_CONFIG_STATUS_LOW
}JIDU_ECU_CONFIG_STATUS_t;

typedef struct JIDU_DTC_INFO
{
	std::string strDTCNo;
	std::string strContent;
}JIDU_DTC_INFO_t;


typedef struct JD_VehicleEcuInfo
{
	//uint16_t ecuId;
	string ecuName;
	string pkiName;
	string ecuSn;
	string ecuSwpn;
	string ecuHwpn;
}JD_VehicleEcuInfo_t;

typedef struct JD_EcuStatusInfo
{
	JIDU_ECU_STATUS_t ecuStatus = JIDU_ECU_STATUS_OnLine;	//ECU状态,默认是在线状态
	JIDU_ECU_FOTA_STATUS_t ecuFotaStatus = JIDU_ECU_FOTA_STATUS_No_Reulst;	//ECU Fota状态,默认是无结果
	JIDU_ECU_CONFIG_STATUS_t EcuConfigStatus = JIDU_ECU_CONFIG_STATUS_HIGH;//ECU配置状态，默认高配
}JD_EcuStatusInfo_t;


typedef struct FUNCTION_CONDITION_ITEM
{
	unsigned int nEcuId = 0;
	unsigned int nDoipAddr = 0;
	std::string strEcuName;//ECU名称
}FUNCTION_CONDITION_ITEM_t;

typedef struct FUNCTION_CONDITION
{
	std::string strFunctionName;
	int nFunctionId = 0;
	std::string strDisplayName;

	vector<FUNCTION_CONDITION_ITEM_t> vecEcuInfo;
}FUNCTION_CONDITION_t;


typedef struct {
	string ecuName;
	string ecuAddress;
	string serverId;
	string did;
	string resultData;
	string value;
	string expectData;
	string number;
}JD_SummaryData_TestItem_t;

typedef struct {
	string testItemName;
	string testItemId;
	string testItemResult;
	vector<JD_SummaryData_TestItem_t> testItem;
}JD_SummaryData_TestItemList_t;

typedef struct {
	string testBlockName;
	string testBlockId;
	string testBlockResult;
	vector<JD_SummaryData_TestItemList_t> testItemList;
}JD_SummaryData_TestData_t;

typedef struct {
	string mixNo;
	string vehicleType;
	string vin;
	string station;
	string cell;
	string testTimeUtc;
	string executionTimeUtc;
	string overallResult;
	vector<JD_SummaryData_TestData_t> testData;
}JD_SummaryData_t;


typedef struct {
	string ecuType;

	//域控dvckey
	string cls_strDvcKey;

	//域控证书信息
	string cls_strP12;
	string cls_strP12Key;
	string cls_strAESKey;
	string cls_strSOAKey;
}JD_EcuCertItem_t;

typedef struct {
	map<string, JD_EcuCertItem_t> ecuCertInfo;
	string cls_strEcuCa;// ECU证书数据
	string cls_strVid; //车辆VID信息
}JD_EcuCertInfo_t;

typedef struct ecu_node {
	int ecuId = 0;
	string ecuName;
	int doIp = 0;
	int ccpPose = 0;
	bool isHighPwr = false;
}ecu_node_t;

typedef struct JD_ECU_BNCM_CommandInfo
{
	std::string commandKey;//指令key值
	string commandReq;//指令请求
	string commandRes;//指令应答
	std::string parseCommandRes; //指令计算值
}JD_ECU_CommandInfo_t;

typedef struct JD_ECU_DIAGNOSTIC_INFO
{
	std::string strEcuType;
	std::string strEcuId;

	vector<JD_ECU_CommandInfo_t> vecCommandInfo;
}JD_ECU_DIAGNOSTIC_INFO_t;

#endif