#ifndef CCLINKIECONTROL_H
|
#define CCLINKIECONTROL_H
|
|
#include "PerformanceMelsec.h"
|
|
enum class CCLinkIEControlMode : short {
|
UNKNOWN = 0x0194, // δ֪
|
ONLINE = 0x0000, // ÔÚÏß
|
OFFLINE = 0x0002, // ÀëÏß
|
INTER_STATION_TEST = 0x0005, // Õ¾¼ä²âÊÔ
|
LINE_TEST = 0x0006, // Ïß·²âÊÔ
|
LOOPBACK_TEST = 0x0007, // ×Ô»ØËͲâÊÔ
|
HW_TEST = 0x0009, // H/W²âÊÔ
|
BUS_IF_TEST = 0x000E // ×ÜÏßI/F²âÊÔ
|
};
|
|
class CCCLinkIEControl final : public CPerformanceMelsec {
|
public:
|
CCCLinkIEControl();
|
~CCCLinkIEControl() override;
|
|
struct LedStatus {
|
bool bExtPw; // ÍⲿµçԴ״̬ (b15)
|
bool bRd; // Êý¾Ý½ÓÊÕ״̬ (b6)
|
bool bDLnk; // Êý¾ÝÁ´½Ó״̬ (b5)
|
bool bPrm; // ¹ÜÀí¹¦ÄÜ״̬ (b4)
|
bool bErr; // ´íÎó״̬ (b3)
|
bool bSd; // Êý¾Ý·¢ËÍ״̬ (b2)
|
bool bMode; // ¶¯×÷ģʽ (b1)
|
bool bRun; // ÔËÐÐ״̬ (b0)
|
|
// ת»»Îª×Ö·û´®£¬ÓÃÓÚµ÷ÊÔ
|
std::string ToString() const {
|
std::ostringstream oss;
|
oss << "CC-Link IE Control Network LED Status: {"
|
<< "\n Ext Power: " << (bExtPw ? "ON" : "OFF")
|
<< "\n Receive Data: " << (bRd ? "Receiving" : "Not Receiving")
|
<< "\n Data Link: " << (bDLnk ? "Linked" : "Not Linked")
|
<< "\n Management: " << (bPrm ? "Managing" : "Not Managing")
|
<< "\n Error: " << (bErr ? "Error Detected" : "No Error")
|
<< "\n Send Data: " << (bSd ? "Sending" : "Not Sending")
|
<< "\n Mode: " << (bMode ? "Executing" : "Not Executing")
|
<< "\n Run: " << (bRun ? "Running" : "Stopped")
|
<< "\n}";
|
return oss.str();
|
}
|
};
|
|
// ¶ÁȡĿ±êÕ¾µãCPUÀàÐÍ
|
// short ReadCPUCodeEx(const StationIdentifier& station, short& nCPUCode);
|
|
// °åģʽ»ñÈ¡/ÉèÖÃ
|
int SetBoardModeEx(CCLinkIEControlMode mode);
|
CCLinkIEControlMode GetBoardModeEx();
|
|
// »ñÈ¡°å״̬
|
int GetBoardStatusEx(BoardStatus& status);
|
|
// ¶ÁÈ¡LED״̬
|
int ReadLedStatus(LedStatus& outLedStatus);
|
|
int ReadData2(const StationIdentifier& station, short devType, short devNo, short size, void* pData);
|
|
private:
|
static CCLinkIEControlMode ConvertToCCLinkIEControlMode(short nMode);
|
static int ValidateBoardStatus(const BoardStatus& status);
|
};
|
|
|
#endif //CCLINKIECONTROL_H
|