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 00049 #ifndef CCP5X11DEVICE_H 00050 #define CCP5X11DEVICE_H 00051 00052 #include "../Device/ProtocolDevice.h" 00053 #include "../Util/StopWatch.h" 00054 00055 class CCP5X11Device : public CProtocolDevice 00056 { 00057 private: 00058 00059 // ---- private data ---------------------------------------------------- ; 00060 00061 // ---- private auxiliary functions ------------------------------------- ; 00062 00063 protected: 00064 00065 // ---- protected data -------------------------------------------------- ; 00066 00067 unsigned char m_hDevice; 00068 unsigned char m_access; 00069 00070 unsigned long m_uiTimeOut; 00071 unsigned char m_teaser; 00072 CStopWatch m_clTimer; 00073 00074 // ---- protected auxiliary functions ----------------------------------- ; 00075 00076 int getDeviceError(int iErrorState); 00077 int setBaudRate(); 00078 int setMessageId(unsigned long uiMessageId); 00079 int clearReadQueue(); 00080 int reinit(unsigned char ucBaudRateId); 00081 int readDevice(CProtocolMessage& rclProtocolMessage); 00082 int writeDevice(CProtocolMessage& rclProtocolMessage); 00083 00084 public: 00085 00086 // ---- public data ----------------------------------------------------- ; 00087 00088 00089 00090 // ---- constructors / destructor --------------------------------------- ; 00091 00093 CCP5X11Device(); 00095 CCP5X11Device(const CCP5X11Device& rclCP5X11Device); 00097 virtual ~CCP5X11Device(); 00098 00099 // ---- operators ------------------------------------------------------- ; 00100 00101 // assignment operator 00102 CCP5X11Device& operator=(const CCP5X11Device& rclCP5X11Device); 00103 00104 // ---- query functions ------------------------------------------------- ; 00105 00106 // ---- modify functions ------------------------------------------------ ; 00107 00108 void setTimeOut(unsigned long uiTimeOut); 00109 00110 // ---- I/O functions --------------------------------------------------- ; 00111 00112 00113 // ---- exec functions -------------------------------------------------- ; 00114 00115 int init(); 00116 int init(const char* acInitString); 00117 int exit(); 00118 }; 00119 00120 #endif