mmf maintenance data logging
* add environment variable to start logging
* MITL_BENCH_DEBUG_HARDWARE={"MmfLog":{"Motor":true, "Input":true, "Output":true}}
main
parent
2cbd860389
commit
b37fb36266
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
namespace nsMMF
|
||||
{
|
||||
// !!! Do Not change the order to support MMF use case
|
||||
using InputStatus = struct _InputStatus {
|
||||
char PtName[100]{};
|
||||
bool On{ false };
|
||||
|
||||
// Assignment operator overload
|
||||
_InputStatus& operator=(const _InputStatus& rhs)
|
||||
{
|
||||
//
|
||||
strcpy_s(PtName, rhs.PtName);
|
||||
|
||||
On = rhs.On;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace nsMMF
|
||||
{
|
||||
using namespace nlohmann;
|
||||
using namespace nsUtils;
|
||||
|
||||
void from_json(const json& j, InputStatus& x);
|
||||
void to_json(json& j, const InputStatus& x);
|
||||
|
||||
inline void from_json(const json& j, InputStatus& 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 InputStatus& x)
|
||||
{
|
||||
j = nlohmann::json{
|
||||
{ "PtName", x.PtName },
|
||||
{ "On", x.On }
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,107 @@
|
||||
#pragma once
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
namespace nsMMF
|
||||
{
|
||||
// !!! Do Not change the order to support MMF use case
|
||||
using MotorStatus = struct _MotorStatus {
|
||||
bool NegLimHit{ false }; // 0
|
||||
bool PosLimHit{ false }; // 1
|
||||
bool Homed{ false }; // 2
|
||||
bool ServoReady{ false }; // 3
|
||||
bool ServoAlarm{ false }; // 4
|
||||
bool InPosition{ false }; // 5
|
||||
bool MtrOn{ false }; // 6
|
||||
bool MtrCurOnOff{ false }; // 7 // array to store motor On/Off States before maintenance mode
|
||||
double MtrPos{ 0. }; // 8
|
||||
double PosErr{ 0. }; // 16
|
||||
unsigned short MotionStatus{ 0 }; // 24
|
||||
unsigned short Status{ 0 }; // 26
|
||||
int MtrNo{ 0 }; // 28 // motor no wrt the type of card used
|
||||
int MtrType{ 0 }; // 32 // servo or stepper, with or without encoder feedback
|
||||
int MtrCurPos{ 0 }; // 36 // array to store motor position before maintenance mode
|
||||
char MotorName[104]{ "AACC" }; // 40~ 144 (original size 4 bytes - but has to end on a 8-byte align address)
|
||||
|
||||
// Assignment operator overload
|
||||
_MotorStatus& operator=(const _MotorStatus& rhs)
|
||||
{
|
||||
NegLimHit = rhs.NegLimHit;
|
||||
PosLimHit = rhs.PosLimHit;
|
||||
Homed = rhs.Homed;
|
||||
ServoReady = rhs.ServoReady;
|
||||
ServoAlarm = rhs.ServoAlarm;
|
||||
InPosition = rhs.InPosition;
|
||||
MtrOn = rhs.MtrOn;
|
||||
MtrCurOnOff = rhs.MtrCurOnOff;
|
||||
MtrPos = rhs.MtrPos;
|
||||
PosErr = rhs.PosErr;
|
||||
MotionStatus = rhs.MotionStatus;
|
||||
Status = rhs.Status;
|
||||
MtrNo = rhs.MtrNo;
|
||||
MtrType = rhs.MtrType;
|
||||
MtrCurPos = rhs.MtrCurPos;
|
||||
//
|
||||
strcpy_s(MotorName, rhs.MotorName);
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace nsMMF
|
||||
{
|
||||
using namespace nlohmann;
|
||||
using namespace nsUtils;
|
||||
|
||||
void from_json(const json& j, MotorStatus& x);
|
||||
void to_json(json& j, const MotorStatus& x);
|
||||
|
||||
inline void from_json(const json& j, MotorStatus& x)
|
||||
{
|
||||
getValue(j, "NegLimHit", x.NegLimHit);
|
||||
getValue(j, "PosLimHit", x.PosLimHit);
|
||||
getValue(j, "Homed", x.Homed);
|
||||
getValue(j, "ServoReady", x.ServoReady);
|
||||
getValue(j, "ServoAlarm", x.ServoAlarm);
|
||||
getValue(j, "InPosition", x.InPosition);
|
||||
getValue(j, "MtrOn", x.MtrOn);
|
||||
getValue(j, "MtrCurOnOff", x.MtrCurOnOff);
|
||||
getValue(j, "MtrPos", x.MtrPos);
|
||||
getValue(j, "PosErr", x.PosErr);
|
||||
getValue(j, "MotionStatus", x.MotionStatus);
|
||||
getValue(j, "Status", x.Status);
|
||||
getValue(j, "MtrNo", x.MtrNo);
|
||||
getValue(j, "MtrType", x.MtrType);
|
||||
getValue(j, "MtrCurPos", x.MtrCurPos);
|
||||
//getValue(j, "MotorName", x.MotorName);
|
||||
|
||||
std::string name = j.at("MotorName").get<std::string>();
|
||||
strcpy_s(x.MotorName, name.c_str());
|
||||
}
|
||||
|
||||
inline void to_json(json& j, const MotorStatus& x)
|
||||
{
|
||||
j = nlohmann::json{
|
||||
{ "NegLimHit", x.NegLimHit },
|
||||
{ "PosLimHit", x.PosLimHit },
|
||||
{ "Homed", x.Homed },
|
||||
{ "ServoReady", x.ServoReady },
|
||||
{ "ServoAlarm", x.ServoAlarm },
|
||||
{ "InPosition", x.InPosition },
|
||||
{ "MtrOn", x.MtrOn },
|
||||
{ "MtrCurOnOff", x.MtrCurOnOff },
|
||||
{ "MtrPos", x.MtrPos },
|
||||
{ "PosErr", x.PosErr },
|
||||
{ "MotionStatus", x.MotionStatus },
|
||||
{ "Status", x.Status },
|
||||
{ "MtrNo", x.MtrNo },
|
||||
{ "MtrType", x.MtrType },
|
||||
{ "MtrCurPos", x.MtrCurPos },
|
||||
{ "MotorName", x.MotorName }
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
#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[100]{};
|
||||
bool On{ false };
|
||||
bool RequestChgState{ false };
|
||||
bool ChgStateOn{ false };
|
||||
|
||||
// Assignment operator overload
|
||||
_OutputStatus& operator=(const _OutputStatus& rhs)
|
||||
{
|
||||
//
|
||||
strcpy_s(PtName, rhs.PtName);
|
||||
|
||||
On = rhs.On;
|
||||
RequestChgState = rhs.RequestChgState;
|
||||
ChgStateOn = rhs.ChgStateOn;
|
||||
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 }
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue