-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcontrolpacket.cpp
125 lines (118 loc) · 2.49 KB
/
controlpacket.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
#include "controlpacket.h"
#include "ui_controlpacket.h"
ControlPacket::ControlPacket(QWidget *parent) :
QDialog(parent),
PackeManager(CONTROL_PACKET),
ui(new Ui::ControlPacket)
{
setWindowFlags(Qt::CustomizeWindowHint|Qt::FramelessWindowHint);
hide();
ui->setupUi(this);
}
ControlPacket::~ControlPacket()
{
delete ui;
}
/**
*函数名:根据界面选择返回obj
*函数参数:NULL
*函数作用:NULL
*函数返回值:NULL
*备注:NULL
*/
VCI_CAN_OBJ ControlPacket::getObj()
{
memset(&obj,0,sizeof(obj));
QByteArray ba;ba.resize(8);memset(ba.data(),0,ba.size());
char c = 0x00;
//除尘开关
if(0==ui->comboBox->currentIndex())
{
c = c | (0x01<<0);
}
else if(1==ui->comboBox->currentIndex())
{
c = c | (0x02<<0);
}
//门开关
if(0==ui->comboBox_2->currentIndex())
{
c = c | (0x01<<2);
}
else if(1==ui->comboBox_2->currentIndex())
{
c = c | (0x02<<2);
}
//本地远程
if(0==ui->comboBox_3->currentIndex())
{
c = c | (0x01<<4);
}
else if(1==ui->comboBox_3->currentIndex())
{
c = c | (0x02<<4);
}
//运行维护
if(0==ui->comboBox_4->currentIndex())
{
c = c | (0x01<<6);
}
else if(1==ui->comboBox_4->currentIndex())
{
c = c | (0x02<<6);
}
ba[0] = c;c=0x00;
//面阵开关
if(0==ui->comboBox_5->currentIndex())
{
c = c | (0x01<<0);
}
else if(1==ui->comboBox_5->currentIndex())
{
c = c | (0x02<<0);
}
//线阵开关
if(0==ui->comboBox_6->currentIndex())
{
c = c | (0x01<<2);
}
else if(1==ui->comboBox_6->currentIndex())
{
c = c | (0x02<<2);
}
//加热开关
if(0==ui->comboBox_7->currentIndex())
{
c = c | (0x01<<4);
}
else if(1==ui->comboBox_7->currentIndex())
{
c = c | (0x02<<4);
}
//散热开关
if(0==ui->comboBox_8->currentIndex())
{
c = c | (0x01<<6);
}
else if(1==ui->comboBox_8->currentIndex())
{
c = c | (0x02<<6);
}
ba[1] = c;c=0x00;
//模拟测试触发
if(0==ui->comboBox_9->currentIndex())
{
c = c | (0x01<<6);
}
else if(1==ui->comboBox_9->currentIndex())
{
c = c | (0x02<<6);
}
ba[2] = c;c=0x00;
//系统工作状态
c = (char)ui->comboBox_10->currentIndex();
ba[3] = c;c=0x00;
obj.DataLen = ba.size();
memcpy(obj.Data,ba.data(),ba.size());
return obj;
}