1 | /*********************************************************************
|
---|
2 | // created: 2008/2/11 - 12:01
|
---|
3 | // filename: Win32CanInterface.h
|
---|
4 | //
|
---|
5 | // author: Gerald Dherbomez
|
---|
6 | // Copyright Heudiasyc UMR UTC/CNRS 6599
|
---|
7 | //
|
---|
8 | // version: $Id: $
|
---|
9 | //
|
---|
10 | // purpose: Windows specific management of the Can Interface
|
---|
11 | //
|
---|
12 | *********************************************************************/
|
---|
13 |
|
---|
14 | #ifndef WIN32CANINTERFACE_H
|
---|
15 | #define WIN32CANINTERFACE_H
|
---|
16 |
|
---|
17 | // we use the Vector driver
|
---|
18 | #ifdef WIN32
|
---|
19 | //# define CAN_DRIVER_TYPE VECTOR_CAN_DRIVER
|
---|
20 | # define CAN_DRIVER_TYPE VECTOR_CANXL_DRIVER
|
---|
21 | #else
|
---|
22 | # define CAN_DRIVER_TYPE IGEP_CAN_DRIVER
|
---|
23 | #endif
|
---|
24 |
|
---|
25 | #include <iostream>
|
---|
26 | #include <qsemaphore.h>
|
---|
27 | #include <qthread.h>
|
---|
28 |
|
---|
29 | #include "CanDecoderBase.h"
|
---|
30 |
|
---|
31 | #include "driver/CanDriver.h"
|
---|
32 | #include "structureCan.h"
|
---|
33 |
|
---|
34 | namespace pacpus {
|
---|
35 |
|
---|
36 | class ShMem;
|
---|
37 |
|
---|
38 | class Win32CanInterface
|
---|
39 | : public QThread
|
---|
40 | {
|
---|
41 | public:
|
---|
42 | Win32CanInterface();
|
---|
43 | ~Win32CanInterface();
|
---|
44 |
|
---|
45 | enum DataSource {VectorCard, SharedMemory, PeakCard, XLVectorCard, igepCard};
|
---|
46 |
|
---|
47 | bool openInterface(const int number, const unsigned int speed);
|
---|
48 | bool openInterface(char* port, char* accessMode);
|
---|
49 | bool closeInterface(const int number);
|
---|
50 | void stop();
|
---|
51 |
|
---|
52 | void setSignalSempahore(QSemaphore * semaphore) { semaphore_ = semaphore;};
|
---|
53 | void setExchangeBuffer(TimestampedCanFrame * framesArray, const int framesArraySize);
|
---|
54 | void setSource(DataSource source);
|
---|
55 | CanDriver * canDriver_;
|
---|
56 | protected:
|
---|
57 | void run();
|
---|
58 | void vectorLoop();
|
---|
59 | void shMemLoop();
|
---|
60 | void peakLoop();
|
---|
61 | void igepLoop();
|
---|
62 | void vectorXlLoop();
|
---|
63 |
|
---|
64 | private:
|
---|
65 | CanFrame frame_;
|
---|
66 | bool continue_;
|
---|
67 | DataSource source_;
|
---|
68 |
|
---|
69 | QSemaphore *semaphore_;
|
---|
70 | TimestampedCanFrame * receivedFrames_;
|
---|
71 | int receivedFramesArraySize_;
|
---|
72 |
|
---|
73 | ShMem * shMem_;
|
---|
74 |
|
---|
75 | int counter_;
|
---|
76 | };
|
---|
77 |
|
---|
78 | } // namespace pacpus
|
---|
79 |
|
---|
80 | #endif // WIN32CANINTERFACE_H
|
---|