OpcUaCanOpen
CANopen OPC-UA server
stcan.h
Go to the documentation of this file.
1 /*
2  * stcan.h
3  *
4  * Created on: Feb 22, 2012
5  * Author: vfilimon
6  */
7 
8 #ifndef CCANSTSCAN_H_
9 #define CCANSTVCAN_H_
10 
11 #include "windows.h"
12 #include "tchar.h"
13 
14 #ifdef WIN32
15 #include "Winsock2.h"
16 #endif
17 
18 #include <string>
19 using namespace std;
20 
21 #include "usbcan32.h"
22 #include "CCanAccess.h"
23 
24 class STCanScan: public CCanAccess
25 {
26 public:
27  STCanScan();
28  virtual ~STCanScan();
29 
30  virtual bool createBUS(const char * ,const char *);
31  virtual bool sendMessage(short cobID, unsigned char len, unsigned char *message);
32  virtual bool sendRemoteRequest(short cobID);
33  virtual bool getErrorMessage(long error, char message[]);
34 
35 private:
36  int numModule;
39  tUcanHandle m_UcanHandle;
40 
41  string getNamePort() { return canName; }
42  bool sendErrorCode(long);
43 
45  bool run_can;
46 
47  string canName;
48 
49 #define Timeout 1000
50 
51  // The main control thread function for the CAN update scan manager.
52  // Handle for the CAN update scan manager thread.
53 
55 
56  // Thread ID for the CAN update scan manager thread.
58 
59  static DWORD WINAPI CanScanControlThread(LPVOID pCanScan);
60 
61  bool configureCanboard(char *,char *,tUcanHandle&);
62  static void setInUse(int n,bool t) { inUse[n] = t; }
63  static bool isInUse(int n) { return inUse[n]; }
64  static void setCanHandle(int n,tUcanHandle tU) { canHandle[n] = tU; }
65  static tUcanHandle getCanHandle(int n) { return canHandle[n]; }
66 
67  static tUcanHandle canHandle[256];
68  static bool inUse[256];
69 
70 
71 };
72 
73 #endif