#pragma once

#include "nlohmann/json.hpp"

#include "GeneralUtils.h"

namespace nsMMF
{
    // !!! Do Not change the order to support MMF use case
    using OutputStatus = struct _OutputStatus {
        char PtName[80]{};
        bool On{ false };
        // Padding
        bool Padding1{ false };
        bool Padding2{ false };
        bool Padding3{ false };
        bool Padding4{ false };
        bool Padding5{ false };
        bool Padding6{ false };
        bool Padding7{ false };

        // Assignment operator overload
        _OutputStatus& operator=(const _OutputStatus& rhs)
        {
            //
            strcpy_s(PtName, rhs.PtName);

            On = rhs.On;
            //
            Padding1 = rhs.Padding1;
            Padding2 = rhs.Padding2;
            Padding3 = rhs.Padding3;
            Padding4 = rhs.Padding4;
            Padding5 = rhs.Padding5;
            Padding6 = rhs.Padding6;
            Padding7 = rhs.Padding7;
            //
            return *this;
        }
    };
}

namespace nsMMF
{
    using namespace nlohmann;
    using namespace nsUtils;

    void from_json(const json& j, OutputStatus& x);
    void to_json(json& j, const OutputStatus& x);


    inline void from_json(const json& j, OutputStatus& x)
    {
        std::string name = j.at("PtName").get<std::string>();
        strcpy_s(x.PtName, name.c_str());

        getValue(j, "On", x.On);
    }

    inline void to_json(json& j, const OutputStatus& x)
    {
        j = nlohmann::json{
        { "PtName", x.PtName },
        { "On", x.On }
        };
    }

}