-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAutocleanView.cpp
164 lines (136 loc) · 4.02 KB
/
AutocleanView.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// AutocleanView.cpp : 实现文件
//
#include "stdafx.h"
#include "BCGPChartExample.h"
#include "AutocleanView.h"
//#include "afxdialogex.h"
//#include "Includes_app.h"
// CAutocleanView 对话框
IMPLEMENT_DYNAMIC(CAutocleanView, CDialogEx)
CAutocleanView::CAutocleanView(CWnd* pParent /*=NULL*/)
: CDialogEx(CAutocleanView::IDD, pParent)
{
VERIFY(m_Font.CreateFont(
20, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
GB2312_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
L"宋体")); // lpszFacename
}
CAutocleanView::~CAutocleanView()
{
}
void CAutocleanView::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAutocleanView, CDialogEx)
ON_WM_CTLCOLOR()
ON_WM_PAINT()
ON_BN_CLICKED(IDM_MIAN_HYDR_AUTOCLEAN, &CAutocleanView::OnBnClickedMianHydrAutoclean)
ON_WM_TIMER()
ON_MESSAGE(WM_ACKSPI, &CAutocleanView::OnAckspi)
END_MESSAGE_MAP()
// CAutocleanView 消息处理程序
HBRUSH CAutocleanView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: 在此更改 DC 的任何特性
if (nCtlColor == CTLCOLOR_STATIC)
{
pDC->SetTextColor(RGB(0, 0, 0));
pDC->SelectObject(&m_Font);
pDC->SetBkColor(RGB(255, 255, 255));//文字背景色
HBRUSH b = CreateSolidBrush(RGB(255, 255, 255));//控件背景色
return b;
}
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
return hbr;
}
void CAutocleanView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用 CDialogEx::OnPaint()
CRect rect;
GetClientRect(rect);
dc.FillSolidRect(rect, RGB(255, 255, 255)); //设置为白色背景
dc.Rectangle(40, 20, rect.right - 40, rect.bottom - 30);
}
void CAutocleanView::OnBnClickedMianHydrAutoclean()
{
// TODO: 在此添加控件通知处理程序代码
if (DSP_status == Free)
{
//////////////////////////////////////
if (timeFrKd >= 60 * systemcfg.sleeptime)
{
timeFrKd = 0;
fprintf(stderr, "..........active in the function activatescreen..............\n");
sdata_cmd[0] = SPI_CMD_STANDBY_OVER;
PC_SEND_FRAME(sdata_cmd, SPI_TYPE_CMD);
}
//////////////////////////////////////
fprintf(stderr, "..........active in the function autoclean_mainwnd..............\n");
NumFromBoot = 0;
TRACE("IDM_MIAN_HYDR_AUTOCLEAN---------#\n");
key_status = FALSE;
sdata_cmd[0] = SPI_CMD_AUTOCLEAN;
PC_SEND_FRAME(sdata_cmd, SPI_TYPE_CMD, 0);
if (PC_SEND_FRAME(sdata_cmd, SPI_TYPE_CMD) == -1)
MessageBox(L"命令发送不成功!", L"ERROR", MB_OKCANCEL);
else{
GetDlgItem(IDC_AUTOCLEAN)->SetWindowText(L"正在执行自动清洗!");
DSP_status = Busy;
SetTimer(POLLTIME, SPI_POLL_TIME3000, 0);
statusShowMess = 4;
}
}
}
void CAutocleanView::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
switch (nIDEvent)
{
case POLLTIME:
//DEBUG_PRINT1("MSG_TIMER:POLLTIME is due -------------#\n");
sdata_cmd[0] = SPI_CMD_REQDSP_STATUS;
PC_SEND_FRAME(sdata_cmd, SPI_TYPE_CMD);
PC_RECEIVE_FRAME(rdata_state, SPI_TYPE_STATE);
SendMessage(WM_ACKSPI, rdata_state[0], 0);
break;
default:
break;
}
CDialogEx::OnTimer(nIDEvent);
}
afx_msg LRESULT CAutocleanView::OnAckspi(WPARAM wParam, LPARAM lParam)
{
//处理SPI消息
switch (wParam)
{
case SPI_STATE_INFO_END:
TRACE(_T("SPI_STATE_INFO_END"));
KillTimer(POLLTIME);
DSP_status = Free;
statusShowMess = 0;
//InvalidateRect(hDlg, &STATUS, TRUE);
key_status = TRUE;
//Standby_EN = TRUE;
GetDlgItem(IDC_AUTOCLEAN)->SetWindowText(L"自动清洗完成!");
break;
}
////////////////////////
//自动清洗完成的动作
////////////////////////
return 0;
}