huohuoh
Dependencies: NetServices mbed C027_Supports mbed-rpcx
AruFraming.h
00001 #ifndef ARUFRAMING_H 00002 #define ARUFRAMING_H 00003 00004 #include <vector> 00005 #include <queue> 00006 #include <string> 00007 00008 //------------------------------------------------------------------------------ 00009 class AruFrm; 00010 00011 //----------------------------------------------------- 00012 class AruFraming 00013 { 00014 public: 00015 AruFraming(); 00016 ~AruFraming(); 00017 00018 void ProcessFromAru(const std::vector<int> &stream); 00019 00020 static std::vector<int> CreateFrame(const AruFrm &f); 00021 00022 std::queue<AruFrm> RCV_QUE; 00023 private: 00024 static unsigned int auchCRCHi[]; 00025 static unsigned int auchCRCLo[]; 00026 00027 static unsigned int CRC16(const std::vector<int> &puchMsg); 00028 }; 00029 00030 //----------------------------------------------------- 00031 class AruFrm 00032 { 00033 public: 00034 int Identifier; 00035 std::vector<int> Data; 00036 }; 00037 00038 //----------------------------------------------------- 00039 class Ack : public AruFrm 00040 { 00041 public: 00042 Ack(int Identifier_) 00043 { 00044 Identifier = Identifier_; 00045 Data.clear(); 00046 } 00047 }; 00048 00049 //----------------------------------------------------- 00050 class Can : public AruFrm 00051 { 00052 public: 00053 Can(int Identifier_) 00054 { 00055 Identifier = Identifier_; 00056 Data.clear(); 00057 } 00058 }; 00059 00060 //----------------------------------------------------- 00061 class Tef : public AruFrm 00062 { 00063 public: 00064 Tef(int Identifier_) 00065 { 00066 Identifier = Identifier_; 00067 Data.clear(); 00068 } 00069 }; 00070 00071 //----------------------------------------------------- 00072 class Eot : public AruFrm 00073 { 00074 public: 00075 Eot(int Identifier_, std::string &data) 00076 { 00077 Identifier = Identifier_; 00078 std::copy(data.begin(), data.end(), back_inserter(Data)); 00079 } 00080 }; 00081 00082 //----------------------------------------------------- 00083 class Eor : public AruFrm 00084 { 00085 public: 00086 Eor(int Identifier_, std::string &data) 00087 { 00088 Identifier = Identifier_; 00089 std::copy(data.begin(), data.end(), Data.begin()); 00090 } 00091 }; 00092 00093 //----------------------------------------------------- 00094 #endif // ARUFRAMING_H
Generated on Thu Jul 14 2022 15:19:50 by 1.7.2