mmf maintenance data logging

* add environment variable to start logging
* MITL_BENCH_DEBUG_HARDWARE={"MmfLog":{"Motor":true, "Input":true, "Output":true}}
main
Yik Teng Hie 1 year ago
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.

@ -14,6 +14,7 @@ namespace nsDebug {
using stDebug = struct _stDebug {
stHardware Hardware;
stHardware InitController;
stHardware MmfLog;
};
}
@ -59,13 +60,15 @@ namespace nsDebug {
{
getValue(j, "Hardware", x.Hardware);
getValue(j, "InitController", x.InitController);
getValue(j, "MmfLog", x.MmfLog);
}
inline void to_json(json& j, const stDebug& x)
{
j = nlohmann::json{
{ "Hardware", x.Hardware },
{ "InitController", x.InitController }
{ "InitController", x.InitController },
{ "MmfLog", x.MmfLog }
};
}
}

@ -13,13 +13,6 @@
class CInputSetting;
class IODLLCLASS CIpStatus
{
public:
char m_cPtName[100];
bool m_bOn;
};
class IODLLCLASS CInputController : public CCard
{
public:

@ -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 }
};
}
}

@ -11,27 +11,6 @@
#include "DllDefines.h"
#include "HardwareCfgFactory.h"
class IODLLCLASS CMtrStatus
{
public:
bool m_bNegLimHit; // 0
bool m_bPosLimHit; // 1
bool m_bHomed; // 2
bool m_bServoReady; // 3
bool m_bServoAlarm; // 4
bool m_bInPosition; // 5
bool m_bMtrOn; // 6
bool m_bpMtrCurOnOff; // 7 // array to store motor On/Off States before maintenance mode
double m_dMtrPos; // 8
double m_dPosErr; // 16
unsigned short m_usMotionStatus; // 24
unsigned short m_usStatus; // 26
int m_iMtrNo; // 28 // motor no wrt the type of card used
int m_iMtrType; // 32 // servo or stepper, with or without encoder feedback
int m_ipMtrCurPos; // 36 // array to store motor position before maintenance mode
char m_cMotorName[104]; // 40~ 144 (original size 4 bytes - but has to end on a 8-byte align address)
};
class IODLLCLASS CMotionController : public CCard
{
public:

@ -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 }
};
}
}

@ -15,15 +15,6 @@
class COutputSetting;
class IODLLCLASS COpStatus
{
public:
char m_cPtName[100];
bool m_bOn;
bool m_bRequestChgState;
bool m_bChgStateOn;
};
class IODLLCLASS COutputController : public CCard
{
public:

@ -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…
Cancel
Save