00001 /* 00002 * Copyright (c) 2012 SCHUNK GmbH & Co. KG 00003 * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA) 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef CPCANDEVICE_H 00019 #define CPCANDEVICE_H 00020 00021 #include "../Device/ProtocolDevice.h" 00022 #include <libpcan/libpcan.h> 00023 00024 class CPCanDevice : public CProtocolDevice 00025 { 00026 private: 00027 00028 // ---- private data ---------------------------------------------------- ; 00029 00030 // ---- private auxiliary functions ------------------------------------- ; 00031 00032 protected: 00033 00034 // ---- protected data -------------------------------------------------- ; 00035 00036 HANDLE m_handle; 00037 int m_hDevice; 00038 int m_hSyncDevice; 00039 int m_iDeviceId; 00040 bool m_bInitialized; 00041 unsigned long m_uiBaudRate; 00042 unsigned short m_uiQueueSize; 00043 unsigned long m_uiTimeOut; 00044 int m_iNoOfRetries; 00045 00046 // ---- protected auxiliary functions ----------------------------------- ; 00047 00048 int getDeviceError(int iErrorState); 00049 int setBaudRate(); 00050 int setBaudRate(unsigned char iBaudRate); 00051 int setMessageId(unsigned long uiMessageId); 00052 int clearReadQueue(); 00053 int reinit(unsigned char ucBaudRateId); 00054 int readDevice(CProtocolMessage& rclProtocolMessage); 00055 int writeDevice(CProtocolMessage& rclProtocolMessage); 00056 char * m_DeviceName; 00057 00058 public: 00059 00060 // ---- public data ----------------------------------------------------- ; 00061 00062 00063 00064 // ---- constructors / destructor --------------------------------------- ; 00065 00067 CPCanDevice(); 00069 CPCanDevice(const CPCanDevice& rclPCanDevice); 00071 virtual ~CPCanDevice(); 00072 00073 // ---- operators ------------------------------------------------------- ; 00074 00075 // assignment operator 00076 CPCanDevice& operator=(const CPCanDevice& rclPCanDevice); 00077 00078 // ---- query functions ------------------------------------------------- ; 00079 00080 // ---- modify functions ------------------------------------------------ ; 00081 00082 void setQueueSize(unsigned short uiQueueSize); 00083 void setTimeOut(unsigned long uiTimeOut); 00084 00085 // ---- I/O functions --------------------------------------------------- ; 00086 00087 // ---- exec functions -------------------------------------------------- ; 00088 00089 int init(); 00090 int init(unsigned long baudRate); 00091 int init(const char* acInitString); 00092 int exit(); 00093 int waitForStartMotionAll(); 00094 }; 00095 00096 #endif