ProtocolDevice.h
Go to the documentation of this file.
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 CPROTOCOLDEVICE_H
00019 #define CPROTOCOLDEVICE_H
00020 
00021 #include "../Device/Device.h"
00022 #include "../Device/ProtocolMessage.h"
00023 #include "../Util/Random.h"
00024 #include "../Util/StopWatch.h"
00025 
00026 #define READ 1
00027 #define WRITE 0
00028 
00029 class CProtocolDevice : public CDevice  
00030 {
00031         private:
00032 
00033                 // ---- private data ---------------------------------------------------- ;
00034         
00035                 // ---- private auxiliary functions ------------------------------------- ;
00036 
00037         protected:
00038 
00039                 // ---- protected data -------------------------------------------------- ;
00040 
00041                         CRITICAL_SECTION m_csDevice;
00042                         CStopWatch m_clTimer;
00043 
00044                 // ---- protected auxiliary functions ----------------------------------- ;
00045 
00046                         int getUnsignedLong(int iModuleId, unsigned long* puiData);
00047 
00048                         int readChar(int iModuleId, int iCommandId, int iParameterId, char* pcData);
00049                         int readUnsignedChar(int iModuleId, int iCommandId, int iParameterId, unsigned char* pucData);
00050                         int readShort(int iModuleId, int iCommandId, int iParameterId, short* piData);
00051                         int readUnsignedShort(int iModuleId, int iCommandId, int iParameterId, unsigned short* puiData);
00052                         int readLong(int iModuleId, int iCommandId, int iParameterId, long* piData);
00053                         int readUnsignedLong(int iModuleId, int iCommandId, int iParameterId, unsigned long* puiData);
00054                         int readFloat(int iModuleId, int iCommandId, int iParameterId, float* pfData);
00055 
00056                         int readLongUnsignedChars(int iModuleId, int iCommandId, int iParameterId, long* piData, unsigned char* pucData1, unsigned char* pucData2);
00057                         int readFloatUnsignedChars(int iModuleId, int iCommandId, int iParameterId, float* pfData, unsigned char* pucData1, unsigned char* pucData2);
00058 
00059                         int write8Bytes(int iModuleId, bool bAck, void* pBytes); 
00060 
00061                         int writeChar(int iModuleId, int iCommandId, int iParameterId, char cData);
00062                         int writeUnsignedChar(int iModuleId, int iCommandId, int iParameterId, unsigned char ucData);
00063                         int writeShort(int iModuleId, int iCommandId, int iParameterId, short iData);
00064                         int writeUnsignedShort(int iModuleId, int iCommandId, int iParameterId, unsigned short uiData);
00065                         int writeLong(int iModuleId, int iCommandId, int iParameterId, long iData);
00066                         int writeUnsignedLong(int iModuleId, int iCommandId, int iParameterId, unsigned long uiData);
00067                         int writeFloat(int iModuleId, int iCommandId, int iParameterId, float fData);
00068 
00069                         int writeAll(int iCommandId, int iParameterId);
00070                         int writeCommand(int iModuleId, int iCommandId);
00071 
00072                         int writeLongShort(int iModuleId, int iCommandId, int iParameterId, long iData1, short iData2);
00073                         int writeFloatShort(int iModuleId, int iCommandId, int iParameterId, float fData, short iData);
00074 
00075                         int writeShortReadLongUnsignedChars(int iModuleId, int iCommandId, int iParameterId, short iData, long* piData, unsigned char* pucData1, unsigned char* pucData2);
00076                         int writeLongReadLongUnsignedChars(int iModuleId, int iCommandId, int iParameterId, long iData, long* piData, unsigned char* pucData1, unsigned char* pucData2);
00077                         int writeLongShortReadLongUnsignedChars(int iModuleId, int iCommandId, int iParameterId, long iData1, short iData2, long* piData, unsigned char* pucData1, unsigned char* pucData2);
00078                         int writeFloatReadFloatUnsignedChars(int iModuleId, int iCommandId, int iParameterId, float fData, float* pfData, unsigned char* pucData1, unsigned char* pucData2);
00079                         int writeFloatShortReadFloatUnsignedChars(int iModuleId, int iCommandId, int iParameterId, float fData, short iData, float* pfData, unsigned char* pucData1, unsigned char* pucData2);
00080 
00081                         virtual int reinit(unsigned char ucBaudRateId) = 0;
00082                         virtual int clearReadQueue() = 0;
00083                         virtual int setMessageId(unsigned long uiMessageId) = 0;
00084                         virtual int readDevice(CProtocolMessage& rclProtocolMessage) = 0;
00085                         virtual int writeDevice(CProtocolMessage& rclProtocolMessage) = 0;
00086                         int printMessage(CProtocolMessage & rclProtocolMessage, bool read);
00087 
00088         public:
00089 
00090                 // ---- public data ----------------------------------------------------- ;
00091 
00092         
00093                 // ---- constructors / destructor --------------------------------------- ;
00094 
00096                         CProtocolDevice();
00098                         CProtocolDevice(const CProtocolDevice& rclProtocolDevice);
00100                         virtual ~CProtocolDevice();
00101 
00102                 // ---- operators ------------------------------------------------------- ;
00103                 
00104                         // assignment operator
00105                         CProtocolDevice& operator=(const CProtocolDevice& rclProtocolDevice);
00106 
00107                 // ---- query functions ------------------------------------------------- ;
00108 
00109                         int getDataDLR_FTS(std::vector<float>& rafData, long* piState);
00110                         int getDataSCHUNK_FTC(int iModuleId, int iChannelTypeId, std::vector<float>& rafData, short* piState);
00111                         int getDataMP55_IO(int iModuleId, float* pfData);
00112                         int getDataMP55_IO_fast(int iModuleId, float* pfData);
00113                         int getCanOpenRawAbsEnc(int iModuleId, short* piValue);
00114 
00115                 // ---- modify functions ------------------------------------------------ ;
00116 
00117                         int setNullSCHUNK_FTC(int iModuleId, short* piState);
00118                         int setTaraMP55_IO(int iModuleId, float fTara);
00119                         int setInitMP55_IO_fast(int iModuleId);
00120 
00121                 // ---- I/O functions --------------------------------------------------- ;
00122 
00123                 // ---- exec functions -------------------------------------------------- ;
00124 
00125                         int initDLR_FTS();
00126 
00127 };
00128 
00129 #endif


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Sat Jun 8 2019 20:25:13