⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 electromotordlg.h

📁 完成MOTOBUS通信
💻 H
字号:
// electromotorDlg.h : header file
//

#if !defined(AFX_ELECTROMOTORDLG_H__4EF6D963_1A90_44F1_9B4B_52D58FD4B1B5__INCLUDED_)
#define AFX_ELECTROMOTORDLG_H__4EF6D963_1A90_44F1_9B4B_52D58FD4B1B5__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "2DPushGraph.h"
#include "SerialPort.h"
#include "Label.h"

#include<math.h>
/////////////////////////////////////////////////////////////////////////////
// CElectromotorDlg dialog
typedef struct _value{
	float	volVal;
	float	curVal;
	float	freVal;
	float	tpqVal;
	float	tawVal;
	float   trwVal;
}testValue;

#define  VOLADDR   3    //电压地址
#define  CURADDR   10   //电流地址
#define  TPQADDR   44   //功率因数地址
#define  TAWADDR   14   //有功功率地址
#define  TRWADDR   16   //无功功率地址
#define  FREADDR   18  //频率地址

class CElectromotorDlg : public CDialog
{
// Construction
public:
	void ReadTableName();
	CString m_table;
	int m_offtimes;
	BOOL m_communicationSign;
	int m_deviceCount;
	BOOL m_lineNo3;
	BOOL m_lineNo2;
	BOOL m_lineNo1;
	void InitDataSource();
	BOOL DataSource();
	void AddLine();
	int Hex2Dec(CString data);
	BOOL m_start;//实时开始标志
	BOOL m_end;//实时停止标志
	void SaveData(float vol,float cur,float ys,float p,float yp,float wp,int no);
	void SendOrder(CString m_strSendData);
	void SendOrder(int Address,int FunCode,int StartAddress,int Length);
    void SendOrder();

	void InitChart();
	
	void DrawChart();

	USHORT MBCRC16( UCHAR * pucFrame, USHORT usLen );

	_ConnectionPtr m_Pconn;
	_RecordsetPtr m_Precord;
	
	CSerialPort m_Port;
	
	int m_nBaud;       //波特率
	int m_nCom;         //串口号
	char m_cParity;    //校验
	int m_nDatabits;    //数据位
	int m_nStopbits;    //停止位
	CString m_strReceiveData;
	int m_addr;
	int m_addrTemp;
	int m_readAddrCode;
	int m_fnCode;
	int m_lenCode;
	int m_datCode;

	COLORREF  m_color1;
    COLORREF  m_color2;
	COLORREF  m_color3;

	
	testValue m_value;
	float m_x;
	CElectromotorDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	//{{AFX_DATA(CElectromotorDlg)
	enum { IDD = IDD_ELECTROMOTOR_DIALOG };
	CComboBox	m_ctrTable;
	CComboBox	m_ctrDeviceCount;
	CComboBox	m_ctrDataSource;
	CButton	m_checkNo3;
	CButton	m_checkNo2;
	CButton	m_checkNo1;
	CLabel	m_no1;
	CLabel	m_no2;
	CLabel	m_no3;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CElectromotorDlg)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	int m_nCycleTime;
	CString	m_strSendData;
	int Str2Hex(CString str, char *data);
	char HexChar(char c);
	DWORD m_dwCommEvents;
	BOOL m_bOpenPort;

	BOOL m_line;//历史绘线标志,TRUE表示已经有曲线存在
	BOOL m_hisRecord;//历史绘线标志,TRUE表示已经有曲线正在画
	
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CElectromotorDlg)
	afx_msg LONG OnCommunication(WPARAM ch, LPARAM port);
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnBtnSta();
	afx_msg void OnBtnSto();
	afx_msg void OnClose();
	afx_msg void OnButtonHisRec();
	afx_msg void OnBtnClear();
	afx_msg void OnBtnHissto();
	afx_msg void OnSelendokDatsou();
	afx_msg void OnCheckNo1();
	afx_msg void OnCheckNo2();
	afx_msg void OnCheckNo3();
	afx_msg void OnSelendokDevicecount();
	afx_msg void OnSelendokComboTable();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
private:
	C2DPushGraph m_curPushGraph;
	C2DPushGraph m_volPushGraph;
	C2DPushGraph m_tawPushGraph;
	C2DPushGraph m_trwPushGraph;

};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_ELECTROMOTORDLG_H__4EF6D963_1A90_44F1_9B4B_52D58FD4B1B5__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -