00001 00002 /****************************************************************************** 00003 * 00004 * Copyright (c) 2012 00005 * 00006 * SCHUNK GmbH & Co. KG 00007 * 00008 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00009 * 00010 * Project name: Drivers for "Amtec M5 Protocol" Electronics V4 00011 * 00012 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00013 * 00014 * Email:robotics@schunk.com 00015 * 00016 * ToDo: 00017 * 00018 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00019 * 00020 * Redistribution and use in source and binary forms, with or without 00021 * modification, are permitted provided that the following conditions are met: 00022 * 00023 * * Redistributions of source code must retain the above copyright 00024 * notice, this list of conditions and the following disclaimer. 00025 * * Redistributions in binary form must reproduce the above copyright 00026 * notice, this list of conditions and the following disclaimer in the 00027 * documentation and/or other materials provided with the distribution. 00028 * * Neither the name of SCHUNK GmbH & Co. KG nor the names of its 00029 * contributors may be used to endorse or promote products derived from 00030 * this software without specific prior written permission. 00031 * 00032 * This program is free software: you can redistribute it and/or modify 00033 * it under the terms of the GNU Lesser General Public License LGPL as 00034 * published by the Free Software Foundation, either version 3 of the 00035 * License, or (at your option) any later version. 00036 * 00037 * This program is distributed in the hope that it will be useful, 00038 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00039 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00040 * GNU Lesser General Public License LGPL for more details. 00041 * 00042 * You should have received a copy of the GNU Lesser General Public 00043 * License LGPL along with this program. 00044 * If not, see <http://www.gnu.org/licenses/>. 00045 * 00046 ******************************************************************************/ 00047 00048 #ifndef CESDDEVICE_H 00049 #define CESDDEVICE_H 00050 00051 #include "../Device/ProtocolDevice.h" 00052 00053 class CESDDevice : public CProtocolDevice 00054 { 00055 private: 00056 00057 // ---- private data ---------------------------------------------------- ; 00058 00059 // ---- private auxiliary functions ------------------------------------- ; 00060 00061 protected: 00062 00063 // ---- protected data -------------------------------------------------- ; 00064 00065 #if defined (_WIN32) 00066 HANDLE m_hDevice; 00067 HANDLE m_hSyncDevice; 00068 #endif 00069 #if defined(__LINUX__) 00070 // HANDLE m_hDevice; 00071 // HANDLE m_hSyncDevice; 00072 int m_hDevice; 00073 int m_hSyncDevice; 00074 #endif 00075 #if defined (__QNX__) 00076 int m_hDevice; 00077 int m_hSyncDevice; 00078 #endif 00079 int m_iDeviceId; 00080 unsigned long m_uiBaudRate; 00081 unsigned short m_uiQueueSize; 00082 unsigned long m_uiTimeOut; 00083 00084 // ---- protected auxiliary functions ----------------------------------- ; 00085 00086 int getDeviceError(int iErrorState); 00087 int setBaudRate(); 00088 int setMessageId(unsigned long uiMessageId); 00089 int clearReadQueue(); 00090 int reinit(unsigned char ucBaudRateId); 00091 int readDevice(CProtocolMessage& rclProtocolMessage); 00092 int writeDevice(CProtocolMessage& rclProtocolMessage); 00093 00094 public: 00095 00096 // ---- public data ----------------------------------------------------- ; 00097 00098 00099 00100 // ---- constructors / destructor --------------------------------------- ; 00101 00103 CESDDevice(); 00105 CESDDevice(const CESDDevice& rclESDDevice); 00107 virtual ~CESDDevice(); 00108 00109 // ---- operators ------------------------------------------------------- ; 00110 00111 // assignment operator 00112 CESDDevice& operator=(const CESDDevice& rclESDDevice); 00113 00114 // ---- query functions ------------------------------------------------- ; 00115 00116 // ---- modify functions ------------------------------------------------ ; 00117 00118 void setQueueSize(unsigned short uiQueueSize); 00119 void setTimeOut(unsigned long uiTimeOut); 00120 00121 // ---- I/O functions --------------------------------------------------- ; 00122 00123 // ---- exec functions -------------------------------------------------- ; 00124 00125 int init(); 00126 int init(const char* acInitString); 00127 int exit(); 00128 int waitForStartMotionAll(); 00129 }; 00130 00131 #endif