Last change
on this file since 18 was 2, checked in by DHERBOMEZ Gérald, 11 years ago |
correction of minor bugs (include and link). Build on Windows OK.
|
File size:
1.4 KB
|
Line | |
---|
1 | #include "Pacpus/kernel/ComponentManager.h"
|
---|
2 | #include "CanSubscription.h"
|
---|
3 |
|
---|
4 | #include <QDebug>
|
---|
5 |
|
---|
6 | using namespace pacpus;
|
---|
7 |
|
---|
8 | bool CanSubscription::subscribe(const CanDecoderBase* who, const QList<int>& canId )
|
---|
9 | {
|
---|
10 | qDebug() << subscribers_.isEmpty() << subscribers_.size();
|
---|
11 |
|
---|
12 | bool result = true;
|
---|
13 |
|
---|
14 | qDebug() << "CAN subscription request";
|
---|
15 | qDebug() << who;
|
---|
16 | qDebug() << canId;
|
---|
17 |
|
---|
18 | QListIterator<int> i(canId);
|
---|
19 | while (i.hasNext())
|
---|
20 | {
|
---|
21 | int id = i.next();
|
---|
22 | // check if subscription is already present
|
---|
23 | if (subscribers_.contains(id, const_cast<CanDecoderBase*>(who)) )
|
---|
24 | {
|
---|
25 | // the pair is already present in hash!
|
---|
26 | result = false;
|
---|
27 | }
|
---|
28 | else
|
---|
29 | {
|
---|
30 | subscribers_.insert(id, const_cast<CanDecoderBase*>(who));
|
---|
31 | }
|
---|
32 | }
|
---|
33 |
|
---|
34 | qDebug() << "state of CAN subscription";
|
---|
35 | qDebug() << subscribers_;
|
---|
36 |
|
---|
37 | return result;
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 | // return true if the unsubscription of the component to the specified can ID list succeeds, false else
|
---|
42 | bool CanSubscription::unsubscribe(const CanDecoderBase * who, const QList<int>& canId)
|
---|
43 | {
|
---|
44 | // TODO !!
|
---|
45 |
|
---|
46 | return true;
|
---|
47 | }
|
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
51 | bool CanSubscription::dispatchCanFrame(const TimestampedCanFrame & message)
|
---|
52 | {
|
---|
53 | QListIterator<CanDecoderBase*> it( subscribers_.values(message.frame.id) );
|
---|
54 | while (it.hasNext())
|
---|
55 | {
|
---|
56 | ((CanDecoderBase*)it.next())->setData(message);
|
---|
57 | }
|
---|
58 |
|
---|
59 | return true;
|
---|
60 |
|
---|
61 | }
|
---|
62 | |
---|
Note:
See
TracBrowser
for help on using the repository browser.