00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00034
00035
00036
00037 protected:
00038
00039
00040
00041 CRITICAL_SECTION m_csDevice;
00042 CStopWatch m_clTimer;
00043
00044
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
00091
00092
00093
00094
00096 CProtocolDevice();
00098 CProtocolDevice(const CProtocolDevice& rclProtocolDevice);
00100 virtual ~CProtocolDevice();
00101
00102
00103
00104
00105 CProtocolDevice& operator=(const CProtocolDevice& rclProtocolDevice);
00106
00107
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
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
00122
00123
00124
00125 int initDLR_FTS();
00126
00127 };
00128
00129 #endif