[1] | 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
|
---|
[4] | 22 | # define CAN_DRIVER_TYPE IGEP_CAN_DRIVER
|
---|
[1] | 23 | #endif
|
---|
| 24 |
|
---|
| 25 | #include <iostream>
|
---|
| 26 | #include <qsemaphore.h>
|
---|
| 27 | #include <qthread.h>
|
---|
| 28 |
|
---|
[2] | 29 | #include "CanDecoderBase.h"
|
---|
[1] | 30 |
|
---|
[2] | 31 | #include "driver/CanDriver.h"
|
---|
[4] | 32 | #include "structureCan.h"
|
---|
[2] | 33 |
|
---|
[1] | 34 | namespace pacpus {
|
---|
| 35 |
|
---|
| 36 | class ShMem;
|
---|
| 37 |
|
---|
| 38 | class Win32CanInterface
|
---|
| 39 | : public QThread
|
---|
| 40 | {
|
---|
| 41 | public:
|
---|
| 42 | Win32CanInterface();
|
---|
| 43 | ~Win32CanInterface();
|
---|
| 44 |
|
---|
[4] | 45 | enum DataSource {VectorCard, SharedMemory, PeakCard, XLVectorCard, igepCard};
|
---|
[1] | 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();
|
---|
[4] | 61 | void igepLoop();
|
---|
[1] | 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
|
---|