1 | // *********************************************************************
|
---|
2 | // created: 2008/2/11 - 12:56
|
---|
3 | // filename: CanGateway.h
|
---|
4 | //
|
---|
5 | // author: Gerald Dherbomez
|
---|
6 | // Copyright Heudiasyc UMR UTC/CNRS 7239
|
---|
7 | //
|
---|
8 | // version: $Id: $
|
---|
9 | //
|
---|
10 | // purpose: Decoding of the CAN bus
|
---|
11 | //
|
---|
12 | // *********************************************************************
|
---|
13 |
|
---|
14 | #ifndef __CanGateway_h__
|
---|
15 | #define __CanGateway_h__
|
---|
16 |
|
---|
17 | #include <fstream>
|
---|
18 |
|
---|
19 | #include "CanGatewayConfig.h"
|
---|
20 | #include "CanSubscription.h"
|
---|
21 |
|
---|
22 | #include "Pacpus/kernel/ComponentBase.h"
|
---|
23 | #include "Pacpus/kernel/DbiteFile.h"
|
---|
24 | #include "Win32CanInterface.h"
|
---|
25 |
|
---|
26 | #define INCOMINGCANFRAMES_SIZE 100
|
---|
27 |
|
---|
28 | // forward declarations
|
---|
29 | class QSemaphore;
|
---|
30 |
|
---|
31 | namespace pacpus {
|
---|
32 |
|
---|
33 | class CANGATEWAY_API CanGateway
|
---|
34 | : public QThread
|
---|
35 | , public ComponentBase
|
---|
36 | , public CanSubscription
|
---|
37 | {
|
---|
38 | Q_OBJECT
|
---|
39 |
|
---|
40 | public:
|
---|
41 | CanGateway(QString name);
|
---|
42 | ~CanGateway();
|
---|
43 |
|
---|
44 | virtual void startActivity();
|
---|
45 | virtual void stopActivity();
|
---|
46 | virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
47 |
|
---|
48 | bool sendFrame(const CanFrame frame);
|
---|
49 |
|
---|
50 | //virtual Win32CanInterface* getCanIf()
|
---|
51 | //{
|
---|
52 | // return &canIf_;
|
---|
53 | //}
|
---|
54 |
|
---|
55 | protected:
|
---|
56 | void run();
|
---|
57 |
|
---|
58 |
|
---|
59 | private:
|
---|
60 | road_time_t tic_;
|
---|
61 | void tic() { tic_ = road_time(); }
|
---|
62 | void toc(char * text) { printf("duration = %d %s\n", (int)(road_time() - tic_), text ); }
|
---|
63 |
|
---|
64 | Win32CanInterface canIf_;
|
---|
65 | QSemaphore semaphore_;
|
---|
66 | TimestampedCanFrame incomingCanFrames_[INCOMINGCANFRAMES_SIZE];
|
---|
67 |
|
---|
68 | // Properties
|
---|
69 | int channel_;
|
---|
70 | int speed_;
|
---|
71 |
|
---|
72 | char port_[64];
|
---|
73 | char accessMode_[64];
|
---|
74 |
|
---|
75 | QString source_;
|
---|
76 |
|
---|
77 | int counter_;
|
---|
78 |
|
---|
79 | // dbt files
|
---|
80 | pacpus::DbiteFile rawCanFile_;
|
---|
81 |
|
---|
82 | bool THREAD_ALIVE;
|
---|
83 |
|
---|
84 | bool verbose_;
|
---|
85 |
|
---|
86 | };
|
---|
87 |
|
---|
88 | }
|
---|
89 |
|
---|
90 | #endif // __CanGateway_h__
|
---|