#pragma once

#include <string>
#include <vector>

#include "nlohmann/json.hpp"

#include "DllDefines.h"

constexpr char* PATH_SUBPOSITIONS = "d:/machine/interprocess/runtime/subpositions/";

using stSubPosition = struct _stSubPosition
{

    std::string SubPositionName;
    double      PositionValue;
    int         PositionIndex;

    NLOHMANN_DEFINE_TYPE_INTRUSIVE(_stSubPosition,
        SubPositionName,
        PositionValue,
        PositionIndex)
};

using stPosition = struct _stPosition
{

    std::string                PositionName;
    std::vector<stSubPosition> MotorSubPositions;

    NLOHMANN_DEFINE_TYPE_INTRUSIVE(_stPosition,
        PositionName,
        MotorSubPositions)
};

using stMotor = struct _stMotor
{

    std::string             MotorName;
    std::vector<stPosition> MotorPositions;

    NLOHMANN_DEFINE_TYPE_INTRUSIVE(_stMotor, MotorName, MotorPositions)
};

using stRuntimeMotorSubPosition = struct _stRuntimeMotorSubPoistion
{

    std::string          ModuleName;
    std::vector<stMotor> Motors;

    NLOHMANN_DEFINE_TYPE_INTRUSIVE(_stRuntimeMotorSubPoistion, ModuleName, Motors)
};

class MCCTRDLLCLASS CMotorSubPositionParser
{
public:
    bool Deserialize(const std::string& strFileName, stRuntimeMotorSubPosition& myOption);
    bool Serialize(const std::string& strFilename, const stRuntimeMotorSubPosition& _myOption);

    bool Deserialize(const std::string& strFileName, std::vector<stRuntimeMotorSubPosition>& myOption);
    bool Serialize(const std::string& strFilename, const std::vector<stRuntimeMotorSubPosition>& _myOption);
};
