-
Notifications
You must be signed in to change notification settings - Fork 0
/
devicecan.cpp
87 lines (79 loc) · 2.18 KB
/
devicecan.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
#include "devicecan.h"
DeviceCan::DeviceCan()
{
baud_rate = 50;
show_enable = false;
update_status = false;
}
void DeviceCan::SetSignalStatus(bool status)
{
show_enable = status;
}
void DeviceCan::SetBaudRate(bool status)
{
if(status) baud_rate = 50;
else baud_rate = 25;
//qDebug()<<"baud_rate"<<device_id<<signal_id<<int(baud_rate);
}
bool DeviceCan::AddFilter(uint id, QColor color, QString name, QString express_str)
{
SignalData *message = new SignalData();
if(message->isExpreesionValue(express_str))
{
message->id = id;
message->SettingAttra( color, name, express_str);
filter_list.append(message);
qDebug()<<color<<name<<express_str;
update_status = true;
return true;
}
else
{
delete message;
return false;
}
}
void DeviceCan::RemoveFilter(QColor color, QString name, QString express_str)
{
for(int i=0;i<filter_list.size();i++)
{
// SignalData *message = filter_list.at(i);
// qDebug()<<"/===================================";
// qDebug()<<color<<name<<express_str;
// qDebug()<<filter_list.at(i)->color<<filter_list.at(i)->name<<filter_list.at(i)->express_str;
if(filter_list.at(i)->color == color && filter_list.at(i)->name == name && filter_list.at(i)->express_str == express_str)
{
//delete filter_list.at(i);
filter_list.at(i)->message_list.clear();
filter_list.at(i)->time_list.clear();
filter_list.at(i)->val_list.clear();
filter_list.removeAt(i);
update_status =true;
}
}
return;
}
void DeviceCan::AddFrameData(int id,double time, QByteArray data)
{
for(int i=0;i<filter_list.size();i++)
{
if(filter_list.at(i)->id == id)
filter_list.at(i)->AddData(time,data);
}
}
void DeviceCan::ClearReceiveData()
{
for(int i=0;i<filter_list.size();i++)
{
filter_list.at(i)->ClearAllData();
}
update_status =true;
}
void DeviceCan::SetMaxDataLen(int len)
{
for(int i=0;i<filter_list.size();i++)
{
filter_list.at(i)->SetMaxDataLen(len);
}
update_status =true;
}