|
#pragma once
|
|
#include "../MyLib/StaticEx.h"
|
// CMTerm1CommDevView 窗体视图
|
class CMTerm1CommDevView : public CFormView
|
{
|
DECLARE_DYNCREATE(CMTerm1CommDevView)
|
// 构造
|
public:
|
protected:
|
CMTerm1CommDevView(); // 动态创建所使用的受保护的构造函数
|
virtual ~CMTerm1CommDevView();
|
|
#ifdef AFX_DESIGN_TIME
|
enum { IDD = IDD_MTerm1CommDevView2 };
|
#endif
|
/*
|
#ifdef _DEBUG
|
virtual void AssertValid() const;
|
CMTerm1Doc* CMTerm1CommDevView::GetDocument() const
|
{
|
return reinterpret_cast<CMTerm1Doc*>(m_pDocument);
|
}
|
|
#ifndef _WIN32_WCE
|
virtual void Dump(CDumpContext& dc) const;
|
#endif
|
#endif
|
*/
|
protected:
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
DECLARE_MESSAGE_MAP()
|
public:
|
CMFCStatusBar * m_pStatusBar;
|
enum StatusBarIndicators {
|
idxMachineType = 0,
|
idxProgPos = 1,
|
idxOnline = 2,
|
idxRunning = 3,
|
idxMonitor = 4,
|
idxAddress = 5,
|
idxInfoDisp = 6,
|
};
|
COLORREF OnlineColor = RGB(0, 255, 255);
|
COLORREF ProgColor = RGB(0, 255, 0);
|
COLORREF RunningColor = RGB(0, 255, 0);
|
COLORREF MonitorColor = RGB(0, 255, 255);
|
COLORREF AddressColor = RGB(0, 255, 255);
|
|
virtual void OnInitialUpdate();
|
|
// CStatusBar m_wndStatusBar;
|
// CToolBar m_wndToolBar;
|
// CImageList m_ColorTreeImages;
|
// CTreeCtrl m_treectrl1;
|
|
typedef struct tagWLStat
|
{
|
union {
|
uint32_t Status; //状态
|
struct {
|
uint32_t bMasterSent : 1;
|
uint32_t bMasterRecved : 1;
|
};
|
};
|
uint16_t curStat; //当前状态
|
uint16_t runStep; //工作步骤
|
uint16_t RunStat; //运行状态
|
uint16_t ErrStat; //错误状态
|
uint32_t RF_Freq; //运行频率
|
uint16_t nTimeOnAir;
|
uint16_t DeviceAddr;
|
|
uint8_t NetWorkAddr;
|
|
uint8_t Tx_Power; // dBm 5 - 22 dBm
|
uint8_t LoraBandWidth; // [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved ]
|
uint8_t LoRaFactor; // [SF5 .. SF 12]
|
uint8_t LoRaCodingRate; // [1 : 4/5, 2: 4/6, 3: 4/7, 4: 4/8 ]
|
|
uint8_t LoRaPreambleLen; // 2 - 12
|
|
uint8_t bEnableAddr;
|
uint8_t bEnableEncrypt;
|
uint8_t bEnableRelay;
|
uint8_t bAutoReSend; //自动重发
|
uint8_t nCurClient;
|
uint8_t nSeq;
|
|
uint32_t sentCount; //发送计数
|
uint32_t recvCount; //接收计数
|
uint32_t lastSendtime; //上次发送时间
|
uint32_t lastSenttime; //上次发送出时间
|
uint32_t lastRecvtime; //上次启动接收时间
|
uint32_t lastRecvdtime; //上次接收时间
|
uint32_t lastActTime; //上次动作时间
|
uint32_t lastAckTime; //上次应答时间
|
uint32_t lastErrTime; //上次错误时间
|
uint32_t latancy; //延迟
|
uint32_t cycleTime; //循环时间
|
uint16_t LostPackets; //丢包计数
|
uint16_t CtnLstPkts; //连续丢包计数
|
uint16_t MaxCtnLstPkts; //最大连续丢包计数
|
uint16_t TXErr; //发送错误计数
|
uint16_t RXErr; //接收错误计数
|
uint16_t CRCErr; //CRC错误计数
|
uint16_t PktErr; //包错误 ;
|
uint16_t ChnErr; //频道错误;
|
uint16_t nErrChn; //错误的频道号;
|
uint16_t CADDoneCount; //CAD 完成次数
|
uint16_t CADOkCount; //CAD 是次数
|
uint16_t CADNgCount; //CAD 否次数
|
uint16_t CADTimeOut; //CAD 超时次数
|
uint16_t StepErr1; //步骤错误1
|
uint16_t StepErr2; //步骤错误2
|
uint16_t Err1Count; //微闪报警次数
|
uint16_t Err2Count; //大闪报警次数
|
uint16_t Err3Count; //严重丢失信号次数
|
int8_t RSSI; //信号强度
|
int8_t SNR; //信噪比
|
int8_t tRSSI; //对方信号强度
|
int8_t tSNR; //对方信噪比
|
uint32_t targetSentCount; //对方发送数量
|
uint32_t targetRecvdCount; //对方接受数量
|
|
}stWLRunStat, * pstWLRunStat;
|
|
|
typedef struct tagWLStatV12
|
{
|
union {
|
uint32_t Status; //状态
|
struct {
|
uint32_t bMasterSent : 1;
|
uint32_t bMasterRecved : 1;
|
};
|
};
|
uint16_t curStat; //当前状态
|
uint16_t runStep; //工作步骤
|
uint16_t RunStat; //运行状态
|
uint16_t ErrStat; //错误状态
|
uint32_t RF_Freq; //运行频率
|
uint32_t nTimeOnAir;
|
uint32_t sentCount; //发送计数
|
uint32_t recvCount; //接收计数
|
uint32_t lastSendtime; //上次发送时间
|
uint32_t lastSenttime; //上次发送出时间
|
uint32_t lastRecvtime; //上次启动接收时间
|
uint32_t lastRecvdtime; //上次接收时间
|
uint32_t lastActTime; //上次动作时间
|
uint32_t lastAckTime; //上次应答时间
|
uint32_t lastErrTime; //上次错误时间
|
uint32_t latancy; //延迟
|
uint32_t cycleTime; //循环时间
|
uint16_t LostPackets; //丢包计数
|
uint16_t CtnLstPkts; //连续丢包计数
|
uint16_t MaxCtnLstPkts; //最大连续丢包计数
|
uint16_t TXErr; //发送错误计数
|
uint16_t RXErr; //接收错误计数
|
uint16_t CRCErr; //CRC错误计数
|
uint16_t ChnErr; //频道错误
|
uint16_t PktErr; //包错误
|
uint16_t CADDoneCount; //CAD 完成次数
|
uint16_t StepErr1; //步骤错误1
|
uint16_t StepErr2; //步骤错误2
|
uint16_t Err1Count; //微闪报警次数
|
uint16_t Err2Count; //大闪报警次数
|
uint16_t Err3Count; //严重丢失信号次数
|
int8_t RSSI; //信号强度
|
int8_t SNR; //信噪比
|
int8_t tRSSI; //对方信号强度
|
int8_t tSNR; //对方信噪比
|
uint32_t targetSentCount; //对方发送数量
|
uint32_t targetRecvdCount; //对方接受数量
|
|
}stWLRunStatV12, *pstWLRunStatV12;
|
|
typedef struct tagWLStatV1
|
{
|
union {
|
uint32_t Status; //状态
|
struct {
|
uint32_t bMasterSent : 1;
|
uint32_t bMasterRecved : 1;
|
};
|
};
|
uint16_t curStat; //当前状态
|
uint16_t runStep; //工作步骤
|
uint16_t RunStat; //运行状态
|
uint16_t ErrStat; //错误状态
|
// uint32_t RF_Freq; //运行频率
|
// uint32_t nTimeOnAir;
|
uint32_t sentCount; //发送计数
|
uint32_t recvCount; //接收计数
|
uint32_t lastSendtime; //上次发送时间
|
uint32_t lastSenttime; //上次发送出时间
|
uint32_t lastRecvtime; //上次启动接收时间
|
uint32_t lastRecvdtime; //上次接收时间
|
uint32_t lastActTime; //上次动作时间
|
uint32_t lastAckTime; //上次应答时间
|
uint32_t lastErrTime; //上次错误时间
|
uint32_t latancy; //延迟
|
uint32_t cycleTime; //循环时间
|
uint16_t LostPackets; //丢包计数
|
uint16_t CtnLstPkts; //连续丢包计数
|
uint16_t MaxCtnLstPkts; //最大连续丢包计数
|
uint16_t TXErr; //发送错误计数
|
uint16_t RXErr; //接收错误计数
|
uint16_t CRCErr; //CRC错误计数
|
// uint16_t ChnErr; //频道错误
|
// uint16_t PktErr; //包错误
|
uint16_t CADDoneCount; //CAD 完成次数
|
uint16_t StepErr1; //步骤错误1
|
uint16_t StepErr2; //步骤错误2
|
uint16_t Err1Count; //微闪报警次数
|
uint16_t Err2Count; //大闪报警次数
|
uint16_t Err3Count; //严重丢失信号次数
|
int8_t RSSI; //信号强度
|
int8_t SNR; //信噪比
|
int8_t tRSSI; //对方信号强度
|
int8_t tSNR; //对方信噪比
|
uint32_t targetSentCount; //对方发送数量
|
uint32_t targetRecvdCount; //对方接受数量
|
|
}stWLRunStatV1, * pstWLRunStatV1;
|
|
CString KWRunStatToString(pstWLRunStat pWLRunStat1);
|
CString KWRunStatToString(pstWLRunStatV1 pWLRunStat1);
|
CString KWRunStatToString(pstWLRunStatV12 pWLRunStat1);
|
|
afx_msg void OnClose();
|
afx_msg void OnSize(UINT nType, int cx, int cy);
|
afx_msg void OnTimer(UINT_PTR nIDEvent);
|
afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD_PTR dwData);
|
void FindComPort();
|
|
int BInited;
|
int m_bResourceOpened;
|
int m_bPause;
|
|
CString sComSelStr;
|
CString sBaudSelStr;
|
DWORD dComNum;
|
volatile int MyThreadProc1ToRun = 0;
|
volatile int MyThreadProc1Running = 0;
|
|
|
CRect MainClientRect;
|
CRect LeftRect;
|
CRect RightRect;
|
|
CRect ItemRect;
|
CRect OrgButtonRect;
|
CRect ButtonRect;
|
CRect PicRect;
|
CRect PicRectUp;
|
CRect PicRectDown;
|
|
CRect LogRect;
|
|
int calLayerOuts();
|
int DisplayParams();
|
int GetParams();
|
int DelayInit();
|
|
int LoadResourceList();
|
int SaveResourceList();
|
|
|
int LoadModel();
|
int SaveModel();
|
|
int OpenResource(CStringA ResourceStr);
|
int CloseResource();
|
|
int SaveData(CString sFilePathName);
|
int LoadData(CString sFilePathName);
|
|
int MonitorPLC();
|
|
int UpdateDataDisplay();
|
|
public:
|
static UINT MyJumper1(LPVOID pParam);
|
DWORD WINAPI MyThreadProc1(LPVOID pParam);
|
|
bool m_bOnline = false;
|
bool m_bRunning = false;
|
bool m_bMonitoring = false;
|
|
|
// Combo Com port select
|
CComboBox m_combo_comport;
|
// Combo Com Baud select
|
CComboBox m_combo_com_baud;
|
afx_msg void OnBnClickedButtonStart();
|
afx_msg void OnBnClickedButtonStop();
|
afx_msg void OnBnClickedButtonClrscr();
|
afx_msg void OnBnClickedButtonSend();
|
CEdit m_edit_display;
|
// Combo Input
|
CComboBox m_combo_input;
|
|
afx_msg void OnCbnEditchangeComboInput();
|
afx_msg void OnCbnSelchangeComboRes();
|
afx_msg void OnBnClickedButtonDo();
|
afx_msg void OnCbnSelchangeComboCmdType();
|
afx_msg void OnCbnSelchangeComboDcount();
|
afx_msg void OnBnClickedButtonStartBulkTest();
|
afx_msg void OnBnClickedButtonStopBulkTest();
|
afx_msg void OnMenuDownload();
|
afx_msg void OnMenuUpload();
|
afx_msg void OnMenuOnline();
|
afx_msg void OnMenuOffline();
|
afx_msg void OnMenuMonitor();
|
afx_msg void OnMenuRun();
|
afx_msg void OnUpdateMenuRun(CCmdUI *pCmdUI);
|
afx_msg void OnUpdateMenuMonitor(CCmdUI *pCmdUI);
|
afx_msg void OnUpdateMenuOffline(CCmdUI *pCmdUI);
|
afx_msg void OnUpdateMenuOnline(CCmdUI *pCmdUI);
|
CEdit m_edit_mon1;
|
CEdit m_edit_mon2;
|
afx_msg void OnMenuCommset();
|
afx_msg void OnMenuSysregSet();
|
afx_msg void OnMenuStatusShow();
|
afx_msg void OnMenuInfoDisplay();
|
afx_msg void OnMenuCoilMon();
|
afx_msg void OnMenuDataMon();
|
afx_msg void OnMenuCommTool();
|
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
|
afx_msg void OnBnClickedButtonClearStat();
|
int Clear_COM_Stats();
|
afx_msg void OnBnClickedButtonRead();
|
afx_msg void OnBnClickedButtonConnect();
|
afx_msg void OnMenuEventLog();
|
afx_msg void OnMenuCommTest();
|
afx_msg void OnMenuForceIo();
|
afx_msg void OnMenuDatetime();
|
CStaticEx m_static_connect;
|
afx_msg void OnBnClickedButtonDisconnect();
|
afx_msg void OnBnClickedButton11();
|
afx_msg void OnBnClickedButton12();
|
afx_msg void OnBnClickedButton13();
|
|
afx_msg void OnBnClickedButton31();
|
afx_msg void OnBnClickedButton2();
|
afx_msg void OnBnClickedButton3();
|
int UpdateLEDDisplay();
|
int UpdateStatusBar(int nIndex);
|
afx_msg void OnBnClickedButton5();
|
afx_msg void OnBnClickedButton9();
|
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
|
};
|