#pragma once

#include <string>
#include <vector>

#include "nlohmann/json.hpp"


using stMotorSpeedValue = struct _stMotorSpeedValue {

	int64_t MotorSpeedValueId;
	int64_t PackageInfoId;
	std::string ModuleName;
	std::string MotorName;
	std::string SpeedName;
	int64_t Percentage;
	double StartSpeed;
	double MaxSpeed;
	double AccRate;
	double DecRate;
	double OverVelocity;
	int64_t LimitPercentage;
	double LimitStartSpeed;
	double LimitMaxSpeed;
	double LimitAccRate;
	double LimitDecRate;
	double LimitOverVelocity;


    NLOHMANN_DEFINE_TYPE_INTRUSIVE(_stMotorSpeedValue,
		MotorSpeedValueId,
		PackageInfoId,
		ModuleName,
		MotorName,
		SpeedName,
		Percentage,
		StartSpeed,
		MaxSpeed,
		AccRate,
		DecRate,
		OverVelocity,
		LimitPercentage,
		LimitStartSpeed,
		LimitMaxSpeed,
		LimitAccRate,
		LimitDecRate,
		LimitOverVelocity
	)

};

using stMotorSpeedModule = struct _stMotorSpeedModule {
	std::string ModuleName;
	std::vector<stMotorSpeedValue> MotorSpeedValues;

    NLOHMANN_DEFINE_TYPE_INTRUSIVE(_stMotorSpeedModule, ModuleName, MotorSpeedValues)
};

using stRuntimeMotorSpeed = struct _stRuntimeMotorSpeed {

	int64_t PackageInfoId;
	std::string PackageName;
	std::string RuntimeExportTimestamp;
    std::vector<stMotorSpeedModule> Modules;

	NLOHMANN_DEFINE_TYPE_INTRUSIVE(_stRuntimeMotorSpeed, PackageInfoId, PackageName, Modules)
};

class CMotorSpeedParser
{
public:
	bool Deserialize(const std::string& strFileName, stRuntimeMotorSpeed& myOption);
	bool Serialize(const std::string& strFilename, const stRuntimeMotorSpeed& _myOption);
};

