00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef CPROTOCOLDEVICE_H
00050 #define CPROTOCOLDEVICE_H
00051
00052 #include "../Device/Device.h"
00053 #include "../Device/ProtocolMessage.h"
00054 #include "../Util/Random.h"
00055 #include "../Util/StopWatch.h"
00056
00057 #define READ 1
00058 #define WRITE 0
00059
00060 class CProtocolDevice : public CDevice
00061 {
00062 private:
00063
00064
00065
00066
00067
00068 protected:
00069
00070
00071
00072 CRITICAL_SECTION m_csDevice;
00073 CStopWatch m_clTimer;
00074
00075
00076
00077 int getUnsignedLong(int iModuleId, unsigned long* puiData);
00078
00079 int readChar(int iModuleId, int iCommandId, int iParameterId, char* pcData);
00080 int readUnsignedChar(int iModuleId, int iCommandId, int iParameterId, unsigned char* pucData);
00081 int readShort(int iModuleId, int iCommandId, int iParameterId, short* piData);
00082 int readUnsignedShort(int iModuleId, int iCommandId, int iParameterId, unsigned short* puiData);
00083 int readLong(int iModuleId, int iCommandId, int iParameterId, long* piData);
00084 int readUnsignedLong(int iModuleId, int iCommandId, int iParameterId, unsigned long* puiData);
00085 int readFloat(int iModuleId, int iCommandId, int iParameterId, float* pfData);
00086
00087 int readLongUnsignedChars(int iModuleId, int iCommandId, int iParameterId, long* piData, unsigned char* pucData1, unsigned char* pucData2);
00088 int readFloatUnsignedChars(int iModuleId, int iCommandId, int iParameterId, float* pfData, unsigned char* pucData1, unsigned char* pucData2);
00089
00090 int write8Bytes(int iModuleId, bool bAck, void* pBytes);
00091
00092 int writeChar(int iModuleId, int iCommandId, int iParameterId, char cData);
00093 int writeUnsignedChar(int iModuleId, int iCommandId, int iParameterId, unsigned char ucData);
00094 int writeShort(int iModuleId, int iCommandId, int iParameterId, short iData);
00095 int writeUnsignedShort(int iModuleId, int iCommandId, int iParameterId, unsigned short uiData);
00096 int writeLong(int iModuleId, int iCommandId, int iParameterId, long iData);
00097 int writeUnsignedLong(int iModuleId, int iCommandId, int iParameterId, unsigned long uiData);
00098 int writeFloat(int iModuleId, int iCommandId, int iParameterId, float fData);
00099
00100 int writeAll(int iCommandId, int iParameterId);
00101 int writeCommand(int iModuleId, int iCommandId);
00102
00103 int writeLongShort(int iModuleId, int iCommandId, int iParameterId, long iData1, short iData2);
00104 int writeFloatShort(int iModuleId, int iCommandId, int iParameterId, float fData, short iData);
00105
00106 int writeShortReadLongUnsignedChars(int iModuleId, int iCommandId, int iParameterId, short iData, long* piData, unsigned char* pucData1, unsigned char* pucData2);
00107 int writeLongReadLongUnsignedChars(int iModuleId, int iCommandId, int iParameterId, long iData, long* piData, unsigned char* pucData1, unsigned char* pucData2);
00108 int writeLongShortReadLongUnsignedChars(int iModuleId, int iCommandId, int iParameterId, long iData1, short iData2, long* piData, unsigned char* pucData1, unsigned char* pucData2);
00109 int writeFloatReadFloatUnsignedChars(int iModuleId, int iCommandId, int iParameterId, float fData, float* pfData, unsigned char* pucData1, unsigned char* pucData2);
00110 int writeFloatShortReadFloatUnsignedChars(int iModuleId, int iCommandId, int iParameterId, float fData, short iData, float* pfData, unsigned char* pucData1, unsigned char* pucData2);
00111
00112 virtual int reinit(unsigned char ucBaudRateId) = 0;
00113 virtual int clearReadQueue() = 0;
00114 virtual int setMessageId(unsigned long uiMessageId) = 0;
00115 virtual int readDevice(CProtocolMessage& rclProtocolMessage) = 0;
00116 virtual int writeDevice(CProtocolMessage& rclProtocolMessage) = 0;
00117 int printMessage(CProtocolMessage & rclProtocolMessage, bool read);
00118
00119 public:
00120
00121
00122
00123
00124
00125
00127 CProtocolDevice();
00129 CProtocolDevice(const CProtocolDevice& rclProtocolDevice);
00131 virtual ~CProtocolDevice();
00132
00133
00134
00135
00136 CProtocolDevice& operator=(const CProtocolDevice& rclProtocolDevice);
00137
00138
00139
00140 int getDataDLR_FTS(std::vector<float>& rafData, long* piState);
00141 int getDataSCHUNK_FTC(int iModuleId, int iChannelTypeId, std::vector<float>& rafData, short* piState);
00142 int getDataMP55_IO(int iModuleId, float* pfData);
00143 int getDataMP55_IO_fast(int iModuleId, float* pfData);
00144 int getCanOpenRawAbsEnc(int iModuleId, short* piValue);
00145
00146
00147
00148 int setNullSCHUNK_FTC(int iModuleId, short* piState);
00149 int setTaraMP55_IO(int iModuleId, float fTara);
00150 int setInitMP55_IO_fast(int iModuleId);
00151
00152
00153
00154
00155
00156 int initDLR_FTS();
00157
00158 };
00159
00160 #endif