智能家居安防系统设计毕业论文-智能小区安防系统设计论文

内容发布更新时间 : 2024/12/23 4:06:42星期一 下面是文章的全部内容请认真阅读。

浙江理工大学信息电子学院本科毕业论文

GetDlgItem(IDC_BUTTON_OPEN)->EnableWindow(m_bSerialPortOpened); GetDlgItem(IDC_BUTTON_CLOSE)->EnableWindow(!m_bSerialPortOpened); }

void CSerialPortTestDlg::OnButtonSend() { if(!m_bSerialPortOpened) { ::MessageBox(NULL,\请先打开串口!\ return; } UpdateData(TRUE);

m_SerialPort.WriteToPort((LPCTSTR)m_strEditSendMsg); }

void CSerialPortTestDlg::OnButtonClear() { UpdateData(TRUE); m_strEditSendMsg=\ m_strEditReceiveMsg=\ UpdateData(FALSE); }

void CSerialPortTestDlg::OnCancel() { ::MessageBox(NULL,\制作:张东祥\\n学号:E04680130\\n班级:通信工程(1)班\\n学院:信息电子学院\\n学校:浙江理工大学\ 谢谢使用\ CDialog::OnCancel(); }

void CSerialPortTestDlg::OnRadioK() { zdx_ztr_choice+=\ FilePath=\ zdx_danwei=\ m_ctrlMultiColorPlot.SetTitle(\当前室内燃气浓度:\ ((CButton *)GetDlgItem(IDC_RADIO_zz))->SetCheck(TRUE);//初始复选框为柱状显示 ((CButton *)GetDlgItem(IDC_RADIO_xz))->SetCheck(FALSE); m_ctrlMultiColorPlot.SetUnit(\ m_ctrlMultiColorPlot.LockRang(0.00f,500.00f); m_ctrlMultiColorPlot.SetPlotGranulatrity(4); m_ctrlMultiColorPlot.SetGridResolutionX(15); m_ctrlMultiColorPlot.ShowTitle(4); m_ctrlMultiColorPlot.SetPlotType(BAR); }

void CSerialPortTestDlg::OnRadioW() { zdx_ztr_choice+=\ FilePath=\ zdx_danwei=\度\ m_ctrlMultiColorPlot.SetTitle(\当前室内温度:\ ((CButton *)GetDlgItem(IDC_RADIO_zz))->SetCheck(TRUE);//初始复选框为柱状显示 ((CButton *)GetDlgItem(IDC_RADIO_xz))->SetCheck(FALSE); m_ctrlMultiColorPlot.SetUnit(\度\ m_ctrlMultiColorPlot.LockRang(0.00f,60.00f); m_ctrlMultiColorPlot.SetPlotGranulatrity(4);

- 43 -

基于无线传感器网络的智能家居安防系统初步构建

m_ctrlMultiColorPlot.SetGridResolutionX(15); m_ctrlMultiColorPlot.ShowTitle(4); m_ctrlMultiColorPlot.SetPlotType(BAR); }

void CSerialPortTestDlg::OnRadioS() { zdx_ztr_choice+=\ FilePath=\ zdx_danwei=\ m_ctrlMultiColorPlot.SetTitle(\当前室内湿度:\ ((CButton *)GetDlgItem(IDC_RADIO_zz))->SetCheck(TRUE);//初始复选框为柱状显示 ((CButton *)GetDlgItem(IDC_RADIO_xz))->SetCheck(FALSE); m_ctrlMultiColorPlot.SetUnit(\ m_ctrlMultiColorPlot.LockRang(0.00f,70.00f); m_ctrlMultiColorPlot.SetPlotGranulatrity(4); m_ctrlMultiColorPlot.SetGridResolutionX(15); m_ctrlMultiColorPlot.ShowTitle(4); m_ctrlMultiColorPlot.SetPlotType(BAR); }

void CSerialPortTestDlg::Display() { if (NextTime <= 600 && stop==FALSE) { LineHight[NextTime/5] = LineHight[121]; } else { for (int i=0;i<120;i++) { LineHight[i] = LineHight[i+1]; } LineHight[120]=LineHight[121]; } NextTime = NextTime+5; this->Invalidate(); return; }

void CSerialPortTestDlg::OnTimer(UINT nIDEvent) { m_ctrlMultiColorPlot.SetData( ( float ) 50000/100 ) ; CDialog::OnTimer(nIDEvent); }

void CSerialPortTestDlg::OnRADIOzz() { m_ctrlMultiColorPlot.SetPlotType(BAR); }

void CSerialPortTestDlg::OnRADIOxz() { m_ctrlMultiColorPlot.SetPlotType(LINE); }

void CSerialPortTestDlg::OnBUTTONStop() {

- 44 -

浙江理工大学信息电子学院本科毕业论文

m_ctrlMultiColorPlot.zdx_bool=!m_ctrlMultiColorPlot.zdx_bool; if (m_ctrlMultiColorPlot.zdx_bool==TRUE) SetDlgItemText(IDC_BUTTON_Stop,\继续显示\ else SetDlgItemText(IDC_BUTTON_Stop,\停止显示\ }

void CSerialPortTestDlg::zdx_Open_Fan() {

DCB dcb;

dcb=m_SerialPort.GetDCB();

dcb.fDtrControl=DTR_CONTROL_ENABLE; }

void CSerialPortTestDlg::zdx_Close_Fan() {

DCB dcb;

dcb=m_SerialPort.GetDCB();

dcb.fDtrControl=DTR_CONTROL_ENABLE; }

int CSerialPortTestDlg::BtoD(WPARAM zdx) {

int a,i,num,len; CString str; a=zdx; a=a/10; num=0; if(a>=0&&a<10)len=1; if(a>=10&&a<100)len=2; if(a>=100&&a<1000)len=3; if(a>=1000&&a<100000)len=4; if(a>=100000&&a<1000000)len=5; if(a>=1000000&&a<10000000)len=6; if(a>=10000000&&a<100000000)len=7; for(i=0;i<=len;i++) { num=num+(a)*(int)pow(2,(double)i); a=a/10; }

return num; }

void CSerialPortTestDlg::OnButtonOpenfan() { CString str=\ if(!m_bSerialPortOpened) { ::MessageBox(NULL,\请先打开串口!\ return; } if(Isfanopen==TRUE) {

m_SerialPort.WriteToPort((LPCTSTR)str); } Isfanopen=FALSE; UpdateData(false);

- 45 -

基于无线传感器网络的智能家居安防系统初步构建

}

void CSerialPortTestDlg::OnButtonClosefan() { CString str=\ if(!m_bSerialPortOpened) { ::MessageBox(NULL,\请先打开串口!\ return; } if(Isfanopen==FALSE) {

m_SerialPort.WriteToPort((LPCTSTR)str); } Isfanopen=TRUE; UpdateData(false); }

//-----------------------串口操作类CZdx_Port.h------------------------------------ #ifndef __SERIALPORT_H__ #define __SERIALPORT_H__

#define WM_COMM_BREAK_DETECTED WM_USER+1 // A break was detected on input. #define WM_COMM_CTS_DETECTED WM_USER+2 // The CTS (clear-to-send) signal changed state.

#define WM_COMM_DSR_DETECTED WM_USER+3 // The DSR (data-set-ready) signal changed state.

#define WM_COMM_ERR_DETECTED WM_USER+4 // A line-status error occurred. Line-status errors are CE_FRAME, CE_OVERRUN, and CE_RXPARITY. #define WM_COMM_RING_DETECTED WM_USER+5 // A ring indicator was detected. #define WM_COMM_RLSD_DETECTED WM_USER+6 // The RLSD (receive-line-signal-detect) signal changed state.

#define WM_COMM_RXCHAR WM_USER+7 // A character was received and placed in the input buffer.

#define WM_COMM_RXFLAG_DETECTED WM_USER+8 // The event character was received and placed in the input buffer.

#define WM_COMM_TXEMPTY_DETECTED WM_USER+9 // The last character in the output buffer was sent. class CZdx_Port { public: void ClosePort(); int m_nWriteSize; // contruction and destruction CZdx_Port(); virtual ~CZdx_Port(); // port initialisation BOOL InitPort(CWnd* pPortOwner, UINT portnr = 1, UINT baud = 19200, char parity = 'N', UINT databits = 8, UINT stopbits = 1, DWORD dwCommEvents = EV_RXCHAR, UINT writebuffersize = 1024); HANDLE m_hComm;

- 46 -

浙江理工大学信息电子学院本科毕业论文

// start/stop comm watching BOOL StartMonitoring(); BOOL RestartMonitoring(); BOOL StopMonitoring(); DWORD GetWriteBufferSize(); DWORD GetCommEvents(); DCB GetDCB(); void WriteToPort(char* string); void WriteToPort(char* string,int n); void WriteToPort(LPCTSTR string); void WriteToPort(LPCTSTR string,int n); protected: // protected memberfunctions void ProcessErrorMessage(char* ErrorText); static UINT CommThread(LPVOID pParam); static void ReceiveChar(CZdx_Port* port, COMSTAT comstat); static void WriteChar(CZdx_Port* port); // thread CWinThread* m_Thread; // synchronisation objects CRITICAL_SECTION m_csCommunicationSync; BOOL m_bThreadAlive; // handles HANDLE m_hWriteEvent; HANDLE m_hShutdownEvent; // Event array. // One element is used for each event. There are two event handles for each port. // A Write event and a receive character event which is located in the overlapped structure (m_ov.hEvent). // There is a general shutdown when the port is closed. HANDLE m_hEventArray[3]; // structures OVERLAPPED m_ov; COMMTIMEOUTS m_CommTimeouts; DCB m_dcb; // owner window CWnd* m_pOwner; // misc UINT m_nPortNr; char* m_szWriteBuffer; DWORD m_dwCommEvents; DWORD m_nWriteBufferSize; };

#endif __SERIALPORT_H__

- 47 -

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4 ceshi