You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.8 KiB
C++
72 lines
1.8 KiB
C++
#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 };
|
|
bool RequestChgState{ false };
|
|
bool ChgStateOn{ false };
|
|
// Padding
|
|
bool Padding1{ false };
|
|
bool Padding2{ false };
|
|
bool Padding3{ false };
|
|
bool Padding4{ false };
|
|
bool Padding5{ false };
|
|
|
|
// Assignment operator overload
|
|
_OutputStatus& operator=(const _OutputStatus& rhs)
|
|
{
|
|
//
|
|
strcpy_s(PtName, rhs.PtName);
|
|
|
|
On = rhs.On;
|
|
RequestChgState = rhs.RequestChgState;
|
|
ChgStateOn = rhs.ChgStateOn;
|
|
//
|
|
Padding1 = rhs.Padding1;
|
|
Padding2 = rhs.Padding2;
|
|
Padding3 = rhs.Padding3;
|
|
Padding4 = rhs.Padding4;
|
|
Padding5 = rhs.Padding5;
|
|
//
|
|
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);
|
|
getValue(j, "RequestChgState", x.RequestChgState);
|
|
getValue(j, "ChgStateOn", x.ChgStateOn);
|
|
}
|
|
|
|
inline void to_json(json& j, const OutputStatus& x)
|
|
{
|
|
j = nlohmann::json{
|
|
{ "PtName", x.PtName },
|
|
{ "On", x.On },
|
|
{ "RequestChgState", x.RequestChgState },
|
|
{ "ChgStateOn", x.ChgStateOn }
|
|
};
|
|
}
|
|
|
|
} |