📄 plcdlg.h
字号:
// PLCDlg.h : header file
//
#if !defined(AFX_PLCDLG_H__AA281520_BE8C_481F_BB53_21BB862A5418__INCLUDED_)
#define AFX_PLCDLG_H__AA281520_BE8C_481F_BB53_21BB862A5418__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "serialport.h"
#include "led.h"
#include "BitmapPicture.h"
#include "WinXPButtonST.h"
/////////////////////////////////////////////////////////////////////////////
// CPLCDlg dialog
class CPLCDlg : public CDialog
{
// Construction
public:
void InitBtn();
void InitLabel();
CPLCDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CPLCDlg)
enum { IDD = IDD_PLC_DIALOG };
CWinXPButtonST m_ShunXu;
CWinXPButtonST m_Run;
CWinXPButtonST m_Exit;
CWinXPButtonST m_CloseAll;
CWinXPButtonST m_OpenAll;
CBitmapPicture m_Y00;
CBitmapPicture m_Y01;
CBitmapPicture m_Y02;
CBitmapPicture m_Y03;
CBitmapPicture m_Y04;
CBitmapPicture m_Y05;
CBitmapPicture m_Y06;
CBitmapPicture m_Y07;
CBitmapPicture m_Y10;
CBitmapPicture m_Y11;
CBitmapPicture m_Y12;
CBitmapPicture m_Y13;
CBitmapPicture m_Y14;
CBitmapPicture m_Y15;
CBitmapPicture m_Y16;
CBitmapPicture m_Y17;
CBitmapPicture m_X00;
CBitmapPicture m_X01;
CBitmapPicture m_X02;
CBitmapPicture m_X03;
CBitmapPicture m_X04;
CBitmapPicture m_X05;
CBitmapPicture m_X06;
CBitmapPicture m_X07;
CBitmapPicture m_X10;
CBitmapPicture m_X11;
CBitmapPicture m_X12;
CBitmapPicture m_X13;
CBitmapPicture m_X14;
CBitmapPicture m_X15;
CBitmapPicture m_X16;
CBitmapPicture m_X17;
CBitmapPicture m_X20;
CBitmapPicture m_X21;
CBitmapPicture m_X22;
CBitmapPicture m_X23;
CBitmapPicture m_X24;
CBitmapPicture m_X25;
CBitmapPicture m_X26;
CBitmapPicture m_X27;
CLed m_Flag_Comm1;
CLed m_Flag_Comm2;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPLCDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
public:
CStringArray CommandArr[4]; //命令字符序列
CByteArray CommandLengthArr[4]; //命令长度序列
CByteArray CommandFlag[4]; //命令标志。用来表明是何种设备,以及发出的何种命令
CByteArray RecDataLengthArr[4]; //接收到数据的应有长度
CStringArray CommandArr_Cur[4]; //当前桢命令字符序列
CByteArray CommandLengthArr_Cur[4]; //当前桢命令长度序列
CByteArray CommandFlag_Cur[4]; //当前桢命令标志。
CByteArray RecDataLengthArr_Cur[4]; //当前桢接收到数据的应有长度
CStringArray CommandArr_Pre[4]; //前一桢命令字符序列
CByteArray CommandLengthArr_Pre[4]; //前一桢命令长度序列
CByteArray CommandFlag_Pre[4]; //前一桢命令标志。
CByteArray RecDataLengthArr_Pre[4]; //前一桢接收到数据的应有长度
CString PreCommand[4]; //前一个命令。
unsigned char PreFlag[4]; //前一个标志。
int ErrorNum_PlcRun;
int ErrorNum_PlcStp;
int ErrorNum_YOpen[32];
int ErrorNum_YClose[32];
int ErrorNum_PlcTT;
int ErrorNum_Status_Y;
int ErrorNum_Status_X;
bool Status_Plc; //PLC状态
unsigned char Status_Plc_X[24]; //plc输入状态
unsigned char Status_Plc_Y[32]; //plc输出状态
CString Status_PLCX;
CString Status_PLCY;
unsigned char RecData[4][256]; //用来存放接收到的原始数据,注意不要溢出
int iRecData[4]; //每帧中接收到的数目
long iFrame[4]; //帧的数目
int iCommand[4]; //发送命令的数目。
int RecData_Length; //当前桢应当接受的数据的所有长度
bool iRun;
public:
void DisplayLabel(unsigned char X[],unsigned char Y[]);//显示状态
int AddCommand(unsigned char CommandStr[],int CommandLength,
unsigned char RecDataLength,unsigned char Flag,int Style,int PortNo);//增加
int DelCommand(unsigned char CommandStr[],int CommandLength,int PortNo); //减少
int DealCommandArr(int PortNo); //预处理命令序列
int InitCommand(); //初始化命令代码
int SendCommand(int CommandNo,int PortNo); //发送代码
int DisposeData(unsigned char Org_Data[],
int length,CString str_Command,unsigned char Flag); //处理接受的数据
int CopyData(unsigned char Des[], unsigned char Src[], int Pos, int length);
int GetPlc_Status_Y(unsigned char data[], int length);
int GetPlc_Status_X(unsigned char data[], int length);
int TestPlc(unsigned char data[],int length);
int DetectPlcRun(unsigned char data[], int length);
int GetPlc_Data(unsigned char data[],int length);
// Implementation
protected:
HICON m_hIcon;
CSerialPort port1; //COM1串口类
// Generated message map functions
//{{AFX_MSG(CPLCDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg LONG OnCommunication(WPARAM ch, LPARAM port);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnCloseall();
afx_msg void OnOpenall();
afx_msg void OnRun();
afx_msg void OnBtnY00();
afx_msg void OnBtnY01();
afx_msg void OnBtnY02();
afx_msg void OnBtnY03();
afx_msg void OnBtnY04();
afx_msg void OnBtnY05();
afx_msg void OnBtnY06();
afx_msg void OnBtnY07();
afx_msg void OnBtnY10();
afx_msg void OnBtnY11();
afx_msg void OnBtnY12();
afx_msg void OnBtnY13();
afx_msg void OnBtnY14();
afx_msg void OnBtnY15();
afx_msg void OnBtnY16();
afx_msg void OnBtnY17();
afx_msg void OnShunxu();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PLCDLG_H__AA281520_BE8C_481F_BB53_21BB862A5418__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -