Loading include/Field.h +16 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,9 @@ namespace PacketLib { enum LogicalFieldDataType { UNKNOWN, UINT1, UINT2, UINT3, UINT4, UINT5, UINT6, UINT7, UINT8, UINT9, UINT10, UINT11, UINT12, UINT13, UINT14, UINT15, UINT16, INT16, UINT24, INT24, UINT32, INT32, UINT64, INT64, FLOAT, DOUBLE, BYTEARRAY }; class FieldType { Loading @@ -40,6 +43,9 @@ public: /// Name of the field. char* name; /// Logical type - NOT USED FOR NOW enum LogicalFieldDataType type; }; Loading Loading @@ -87,6 +93,16 @@ public: return progressiv; }; void print(); /// Get a description of the type (e.g. int32, 16, etc) and the number of bits of each single field ///\param type (input) the type read from configuration file ///\param outtype (output) the type as enum ///\param outtypenfields (output) the number of physical fields equivalent to this logical field ///\param outputfieldsbitsize (output) the number of bits of each single field static void getType(char* type, enum LogicalFieldDataType &outtype, int &outtypenfields, int &outputfieldsbitsize); protected: /// Index of packet in the list of packet. Loading include/PartOfPacket.h +93 −134 Original line number Diff line number Diff line Loading @@ -82,48 +82,49 @@ public: }; /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a unsigned integer of less of equal 16 bits dimension /// (depends by the size of the field in bits) /// \param index Represent the index in the list. virtual inline word getFieldValue(word index) { decode(); if(index < numberOfFields) return fields[index]->value; else return 0; }; virtual word getFieldValue(word index); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a real single precision (IEEE 754). /// The value returned is interpreted as a 16 bit signed integer. /// \param index Represent the index of the field. virtual signed short getFieldValue_16i(word index); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a 16 bit unsigned integer. /// \param index Represent the index of the field. virtual word getFieldValue_16ui(word index); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a 32 bit signed integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 32 bit real single precision. The layout foreseen is the following: /// the 32 bit signed integer. The layout foreseen is the following: /// --------------------------------- /// - float last 16 bits - the index passed as argument /// - 32 bit int MSB 16 bits - the index passed as argument /// --------------------------------- /// - float first 16 bits - the index + 1 /// - 32 bit int LSB 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=5, PFC = 1. /// This corresponds with the PTC=4, PFC = 14. /// \param index Represent the index of the field. virtual float getFieldValue_5_1(word index); virtual signed long getFieldValue_32i(word index); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a real double precision (IEEE 754). /// The index of the argument is the first 16 bit field of the 4 fields that compound /// the 64 bit real double precision. The layout foreseen is the following: /// --------------------------------- /// - float last 16 bits - the index passed as argument /// --------------------------------- /// - float third 16 bits - the index + 1 /// The value returned is interpreted as a 32 bit unsigned integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 32 bit unsigned long. The layout foreseen is the following: /// --------------------------------- /// - float second 16 bits - the index + 1 /// - 32 bit int MSB 16 bits - the index passed as argument /// --------------------------------- /// - float first 16 bits - the index + 1 /// - 32 bit int LSB 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=5, PFC = 2. /// This corresponds with the PTC=3, PFC = 14. /// \param index Represent the index of the field. virtual double getFieldValue_5_2(word index); virtual unsigned long getFieldValue_32ui(word index); /// Set the value of a field. The value is interpreted as a real single /// precision (IEEE 754). /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a real single precision (IEEE 754). /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 32 bit real single precision. The layout foreseen is the following: /// --------------------------------- Loading @@ -131,14 +132,12 @@ public: /// --------------------------------- /// - float first 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=5, PFC = 1. /// See setFieldValue(word index, word value) for general considerations. /// This corresponds with the PTC=5, PFC = 1 <=> float or 32f /// \param index Represent the index of the field. /// \param value The real single precision value virtual void setFieldValue_5_1(word index, float value); virtual float getFieldValue_32f(word index); /// Set the value of a field. The value is interpreted as a real double /// precision (IEEE 754). /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a real double precision (IEEE 754). /// The index of the argument is the first 16 bit field of the 4 fields that compound /// the 64 bit real double precision. The layout foreseen is the following: /// --------------------------------- Loading @@ -150,24 +149,27 @@ public: /// --------------------------------- /// - float first 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=5, PFC = 2. /// See setFieldValue(word index, word value) for general considerations. /// This corresponds with the PTC=5, PFC = 2. <=> double or 64f /// \param index Represent the index of the field. /// \param value The real double precision value virtual void setFieldValue_5_2(word index, double value); virtual double getFieldValue_64f(word index); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a 32 bit signed integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 32 bit signed integer. The layout foreseen is the following: /// --------------------------------- /// - 32 bit int MSB 16 bits - the index passed as argument /// --------------------------------- /// - 32 bit int LSB 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=4, PFC = 14. ///Documentation /// Sets the value of a field in the list of fields of this part of packet. Remember that /// if a predefined value is specified in the .stream, this method has not effect and the /// value contained in the .stream is used. /// \param index Represent the index in the list. /// \param value The value must be set. virtual void setFieldValue(word index, word value); /// Sets the value of a field. The value is interpreted as a 16 bit signed integer. /// \param index Represent the index of the field. /// \param value The 16 bit signed integer value. virtual void setFieldValue_16i(word index, signed short value); /// Sets the value of a field. The value is interpreted as a 16 bit unsigned integer (word). /// \param index Represent the index of the field. virtual signed long getFieldValue_4_14(word index); /// \param value The 16 bit unsigned integer value. virtual void setFieldValue_16ui(word index, word value); /// Sets the value of a field. The value is interpreted as a 32 bit signed integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound Loading @@ -181,49 +183,7 @@ public: /// See setFieldValue(word index, word value) for general considerations. /// \param index Represent the index of the field. /// \param value The 32 bit signed integer value. virtual void setFieldValue_4_14(word index, signed long value); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a 24 bit signed integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 24 bit signed integer. The layout foreseen is the following: /// --------------------------------- /// - 24 bit int MSB 16 bits - the index passed as argument /// --------------------------------- /// - 24 bit int LSB 8 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=4, PFC = 13. /// \param index Represent the index of the field. /// \return the 24 bit signed data converted in a long 32 bit virtual signed long getFieldValue_4_13(word index); /// Sets the value of a field. The value is interpreted as a 24 bit signed integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 24 bit signed integer. The layout foreseen is the following: /// --------------------------------- /// - 24 bit int MSB 16 bits - the index passed as argument /// --------------------------------- /// - 24 bit int LSB 8 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=4, PFC = 13. /// See setFieldValue(word index, word value) for general considerations. /// \param index Represent the index of the field. /// \param value The 24 bit signed integer value. The long value is converted in a /// 24 bit data format (bit0 with the sign became 24 bit) virtual void setFieldValue_4_13(word index, signed long value) throw(PacketException*); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a 32 bit unsigned integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 32 bit unsigned long. The layout foreseen is the following: /// --------------------------------- /// - 32 bit int MSB 16 bits - the index passed as argument /// --------------------------------- /// - 32 bit int LSB 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=3, PFC = 14. /// \param index Represent the index of the field. virtual unsigned long getFieldValue_3_14(word index); virtual void setFieldValue_32i(word index, signed long value); /// Sets the value of a field. The value is interpreted as a 32 bit unsigned integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound Loading @@ -237,42 +197,41 @@ public: /// See setFieldValue(word index, word value) for general considerations. /// \param index Represent the index of the field. /// \param value The 32 bit unsigned integer value. virtual void setFieldValue_3_14(word index, unsigned long value); virtual void setFieldValue_32ui(word index, unsigned long value); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a 24 bit unsigned integer. /// Set the value of a field. The value is interpreted as a real single /// precision (IEEE 754). /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 24 bit unsigned long. The layout foreseen is the following: /// the 32 bit real single precision. The layout foreseen is the following: /// --------------------------------- /// - 24 bit int MSB 16 bits - the index passed as argument /// - float last 16 bits - the index passed as argument /// --------------------------------- /// - 24 bit int LSB 8 bits - the index + 1 /// - float first 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=3, PFC = 13. /// This corresponds with the PTC=5, PFC = 1. /// See setFieldValue(word index, word value) for general considerations. /// \param index Represent the index of the field. virtual unsigned long getFieldValue_3_13(word index); /// \param value The real single precision value virtual void setFieldValue_32f(word index, float value); /// Sets the value of a field. The value is interpreted as a 24 bit unsigned integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 24 bit unsigned long. The layout foreseen is the following: /// Set the value of a field. The value is interpreted as a real double /// precision (IEEE 754). /// The index of the argument is the first 16 bit field of the 4 fields that compound /// the 64 bit real double precision. The layout foreseen is the following: /// --------------------------------- /// - 24 bit int MSB 16 bits - the index passed as argument /// - float last 16 bits - the index passed as argument /// --------------------------------- /// - float third 16 bits - the index + 1 /// --------------------------------- /// - float second 16 bits - the index + 1 /// --------------------------------- /// - 24 bit int LSB 8 bits - the index + 1 /// - float first 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=3, PFC = 13. /// This corresponds with the PTC=5, PFC = 2. /// See setFieldValue(word index, word value) for general considerations. /// \param index Represent the index of the field. /// \param value The 24 bit unsigned integer value. virtual void setFieldValue_3_13(word index, unsigned long value) throw(PacketException*); ///Documentation /// Sets the value of a field in the list of fields of this part of packet. Remember that /// if a predefined value is specified in the .stream, this method has not effect and the /// value contained in the .stream is used. /// \param index Represent the index in the list. /// \param value The value must be set. virtual void setFieldValue(word index, word value); /// \param value The real double precision value virtual void setFieldValue_64f(word index, double value); /// Returns the number of fields. virtual inline word getNumberOfFields() Loading src/Field.cpp +95 −0 Original line number Diff line number Diff line Loading @@ -77,3 +77,98 @@ Field::~Field() { } void Field::print() { cout << progressiv << " " << getName() << " " << size() << endl; } void Field::getType(char* type, enum LogicalFieldDataType &outtype, int &outtypenfields, int &outputfieldsbitsize) { outtype = UNKNOWN; outputfieldsbitsize = 0; outtypenfields = 0; int dim = atoi(type); if(dim == 0) { //>= 16bit outputfieldsbitsize = 16; if(strcmp(type, "int16") == 0) { outtypenfields = 1; outtype = INT16; } else if(strcmp(type, "uint16") == 0) { outtypenfields = 1; outtype = UINT16; } else if(strcmp(type, "int32") == 0) { outtypenfields = 2; outtype = INT32; } else if(strcmp(type, "uint32") == 0) { outtypenfields = 2; outtype = UINT32; } else if(strcmp(type, "float") == 0) { outtypenfields = 2; outtype = FLOAT; } else if(strcmp(type, "int64") == 0) { outtypenfields = 4; outtype = INT64; } else if(strcmp(type, "uint64") == 0) { outtypenfields = 4; outtype = UINT64; } else if(strcmp(type, "double") == 0) { outtypenfields = 4; outtype = DOUBLE; } } else { //<=16 bit (unsigned) outtypenfields = 1; outputfieldsbitsize = dim; switch(dim) { case 1: outtype = UINT1; break; case 2: outtype = UINT2; break; case 3: outtype = UINT3; break; case 4: outtype = UINT4; break; case 5: outtype = UINT5; break; case 6: outtype = UINT6; break; case 7: outtype = UINT7; break; case 8: outtype = UINT8; break; case 9: outtype = UINT9; break; case 10: outtype = UINT10; break; case 11: outtype = UINT11; break; case 12: outtype = UINT12; break; case 13: outtype = UINT13; break; case 14: outtype = UINT14; break; case 15: outtype = UINT15; break; case 16: outtype = UINT16; break; } } } src/Packet.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -460,6 +460,10 @@ void Packet::generateStream() header->generateStream(bigendian); dataField->generateStream(bigendian); //add compression here of the datafield //TODO //dataField->compress(); } Loading src/PartOfPacket.cpp +23 −61 Original line number Diff line number Diff line Loading @@ -473,7 +473,7 @@ void PartOfPacket::setFieldValue(word index, word value) fields[index]->value = (value & pattern[fields[index]->size()]); } float PartOfPacket::getFieldValue_5_1(word index) float PartOfPacket::getFieldValue_32f(word index) { union u_tag { Loading @@ -486,12 +486,11 @@ float PartOfPacket::getFieldValue_5_1(word index) return u.f; } double PartOfPacket::getFieldValue_5_2(word index) double PartOfPacket::getFieldValue_64f(word index) { if(sizeof(unsigned long) == 4) { //TODO cout << "this does not work in a 32 bit system" << endl; exit(0); throw new PacketException("The getFieldValue_64f() does not work in a 32 bit operating system"); } union u_tag Loading @@ -505,7 +504,7 @@ double PartOfPacket::getFieldValue_5_2(word index) return u.d; } void PartOfPacket::setFieldValue_5_1(word index, float value) void PartOfPacket::setFieldValue_32f(word index, float value) { union u_tag { Loading @@ -522,12 +521,11 @@ void PartOfPacket::setFieldValue_5_1(word index, float value) setFieldValue(index + 1, w); } void PartOfPacket::setFieldValue_5_2(word index, double value) void PartOfPacket::setFieldValue_64f(word index, double value) { if(sizeof(unsigned long) == 4) { //TODO cout << "this does not work in a 32 bit system" << endl; exit(0); throw new PacketException("The getFieldValue_64f() does not work in a 32 bit operating system"); } union u_tag Loading @@ -550,14 +548,14 @@ void PartOfPacket::setFieldValue_5_2(word index, double value) setFieldValue(index + 3, w); } signed long PartOfPacket::getFieldValue_4_14(word index) signed long PartOfPacket::getFieldValue_32i(word index) { long l; l = (long)(getFieldValue(index) << 16) | (long)getFieldValue(index + 1); return l; } void PartOfPacket::setFieldValue_4_14(word index, signed long value) void PartOfPacket::setFieldValue_32i(word index, signed long value) { word w; w = (word)(value >> 16); Loading @@ -566,14 +564,14 @@ void PartOfPacket::setFieldValue_4_14(word index, signed long value) setFieldValue(index + 1, w); } unsigned long PartOfPacket::getFieldValue_3_14(word index) unsigned long PartOfPacket::getFieldValue_32ui(word index) { dword l; l = (dword)(getFieldValue(index) << 16) | (dword)getFieldValue(index + 1); return l; } void PartOfPacket::setFieldValue_3_14(word index, unsigned long value) void PartOfPacket::setFieldValue_32ui(word index, unsigned long value) { word w; w = (word)(value >> 16); Loading @@ -582,67 +580,31 @@ void PartOfPacket::setFieldValue_3_14(word index, unsigned long value) setFieldValue(index + 1, w); } unsigned long PartOfPacket::getFieldValue_3_13(word index) word PartOfPacket::getFieldValue_16ui(word index) { word wh, wl; wh = getFieldValue(index); wl = getFieldValue(index + 1); return (dword)(wh << 8) | (dword)(wl & 0xFF); return getFieldValue(index); } void PartOfPacket::setFieldValue_3_13(word index, unsigned long value) throw(PacketException*) signed short PartOfPacket::getFieldValue_16i(word index) { word w; if(value > U24BITINTGEGERUNSIGNED_MAX) throw new PacketException("setFieldValue_3_13(): the max value of 24 bit unsigned integer should be 16777215"); w = (word)(value >> 8); setFieldValue(index, w); w = (word) (0xFF & value); setFieldValue(index + 1, w); signed short l; l = (signed short)getFieldValue(index); return l; } signed long PartOfPacket::getFieldValue_4_13(word index) void PartOfPacket::setFieldValue_16i(word index, signed short value) { union u_tag { /// 32 bit unsigned long u; signed long s; } us; us.u = getFieldValue_3_14(index); /// get the sign unsigned long sign = (us.u >> 23); unsigned long wh = us.u & 0x007FFFFF; /// get a long 32 bit if(sign == 1) us.u = 0x7F800000 + wh + (sign << 31); else us.u = wh + (sign << 31); return us.s; word w; w = (word)value; setFieldValue(index, w); } void PartOfPacket::setFieldValue_4_13(word index, signed long value) throw(PacketException*) void PartOfPacket::setFieldValue_16ui(word index, word value) { union u_tag { /// 32 bit unsigned long u; signed long s; } us; if(value > U24BITINTGEGERSIGNED_MAX) throw new PacketException("setFieldValue_4_13(): the max value of 24 bit signed integer should be 8388607"); if(value < U24BITINTGEGERSIGNED_MIN) throw new PacketException("setFieldValue_4_13(): the min value of 24 bit signed integer should be -8388607"); us.s = value; unsigned long sign = (us.u >> 31); /// 23 bit unsigned long wh = us.u & 0x007FFFFF; unsigned long value2 = 0; value2 = wh + (sign << 23); setFieldValue_3_14(index, value2); setFieldValue(index, value); } void PacketLib::PartOfPacket::memByteStream(ByteStreamPtr stream) { this->stream = stream; } Loading
include/Field.h +16 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,9 @@ namespace PacketLib { enum LogicalFieldDataType { UNKNOWN, UINT1, UINT2, UINT3, UINT4, UINT5, UINT6, UINT7, UINT8, UINT9, UINT10, UINT11, UINT12, UINT13, UINT14, UINT15, UINT16, INT16, UINT24, INT24, UINT32, INT32, UINT64, INT64, FLOAT, DOUBLE, BYTEARRAY }; class FieldType { Loading @@ -40,6 +43,9 @@ public: /// Name of the field. char* name; /// Logical type - NOT USED FOR NOW enum LogicalFieldDataType type; }; Loading Loading @@ -87,6 +93,16 @@ public: return progressiv; }; void print(); /// Get a description of the type (e.g. int32, 16, etc) and the number of bits of each single field ///\param type (input) the type read from configuration file ///\param outtype (output) the type as enum ///\param outtypenfields (output) the number of physical fields equivalent to this logical field ///\param outputfieldsbitsize (output) the number of bits of each single field static void getType(char* type, enum LogicalFieldDataType &outtype, int &outtypenfields, int &outputfieldsbitsize); protected: /// Index of packet in the list of packet. Loading
include/PartOfPacket.h +93 −134 Original line number Diff line number Diff line Loading @@ -82,48 +82,49 @@ public: }; /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a unsigned integer of less of equal 16 bits dimension /// (depends by the size of the field in bits) /// \param index Represent the index in the list. virtual inline word getFieldValue(word index) { decode(); if(index < numberOfFields) return fields[index]->value; else return 0; }; virtual word getFieldValue(word index); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a real single precision (IEEE 754). /// The value returned is interpreted as a 16 bit signed integer. /// \param index Represent the index of the field. virtual signed short getFieldValue_16i(word index); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a 16 bit unsigned integer. /// \param index Represent the index of the field. virtual word getFieldValue_16ui(word index); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a 32 bit signed integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 32 bit real single precision. The layout foreseen is the following: /// the 32 bit signed integer. The layout foreseen is the following: /// --------------------------------- /// - float last 16 bits - the index passed as argument /// - 32 bit int MSB 16 bits - the index passed as argument /// --------------------------------- /// - float first 16 bits - the index + 1 /// - 32 bit int LSB 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=5, PFC = 1. /// This corresponds with the PTC=4, PFC = 14. /// \param index Represent the index of the field. virtual float getFieldValue_5_1(word index); virtual signed long getFieldValue_32i(word index); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a real double precision (IEEE 754). /// The index of the argument is the first 16 bit field of the 4 fields that compound /// the 64 bit real double precision. The layout foreseen is the following: /// --------------------------------- /// - float last 16 bits - the index passed as argument /// --------------------------------- /// - float third 16 bits - the index + 1 /// The value returned is interpreted as a 32 bit unsigned integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 32 bit unsigned long. The layout foreseen is the following: /// --------------------------------- /// - float second 16 bits - the index + 1 /// - 32 bit int MSB 16 bits - the index passed as argument /// --------------------------------- /// - float first 16 bits - the index + 1 /// - 32 bit int LSB 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=5, PFC = 2. /// This corresponds with the PTC=3, PFC = 14. /// \param index Represent the index of the field. virtual double getFieldValue_5_2(word index); virtual unsigned long getFieldValue_32ui(word index); /// Set the value of a field. The value is interpreted as a real single /// precision (IEEE 754). /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a real single precision (IEEE 754). /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 32 bit real single precision. The layout foreseen is the following: /// --------------------------------- Loading @@ -131,14 +132,12 @@ public: /// --------------------------------- /// - float first 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=5, PFC = 1. /// See setFieldValue(word index, word value) for general considerations. /// This corresponds with the PTC=5, PFC = 1 <=> float or 32f /// \param index Represent the index of the field. /// \param value The real single precision value virtual void setFieldValue_5_1(word index, float value); virtual float getFieldValue_32f(word index); /// Set the value of a field. The value is interpreted as a real double /// precision (IEEE 754). /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a real double precision (IEEE 754). /// The index of the argument is the first 16 bit field of the 4 fields that compound /// the 64 bit real double precision. The layout foreseen is the following: /// --------------------------------- Loading @@ -150,24 +149,27 @@ public: /// --------------------------------- /// - float first 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=5, PFC = 2. /// See setFieldValue(word index, word value) for general considerations. /// This corresponds with the PTC=5, PFC = 2. <=> double or 64f /// \param index Represent the index of the field. /// \param value The real double precision value virtual void setFieldValue_5_2(word index, double value); virtual double getFieldValue_64f(word index); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a 32 bit signed integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 32 bit signed integer. The layout foreseen is the following: /// --------------------------------- /// - 32 bit int MSB 16 bits - the index passed as argument /// --------------------------------- /// - 32 bit int LSB 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=4, PFC = 14. ///Documentation /// Sets the value of a field in the list of fields of this part of packet. Remember that /// if a predefined value is specified in the .stream, this method has not effect and the /// value contained in the .stream is used. /// \param index Represent the index in the list. /// \param value The value must be set. virtual void setFieldValue(word index, word value); /// Sets the value of a field. The value is interpreted as a 16 bit signed integer. /// \param index Represent the index of the field. /// \param value The 16 bit signed integer value. virtual void setFieldValue_16i(word index, signed short value); /// Sets the value of a field. The value is interpreted as a 16 bit unsigned integer (word). /// \param index Represent the index of the field. virtual signed long getFieldValue_4_14(word index); /// \param value The 16 bit unsigned integer value. virtual void setFieldValue_16ui(word index, word value); /// Sets the value of a field. The value is interpreted as a 32 bit signed integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound Loading @@ -181,49 +183,7 @@ public: /// See setFieldValue(word index, word value) for general considerations. /// \param index Represent the index of the field. /// \param value The 32 bit signed integer value. virtual void setFieldValue_4_14(word index, signed long value); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a 24 bit signed integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 24 bit signed integer. The layout foreseen is the following: /// --------------------------------- /// - 24 bit int MSB 16 bits - the index passed as argument /// --------------------------------- /// - 24 bit int LSB 8 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=4, PFC = 13. /// \param index Represent the index of the field. /// \return the 24 bit signed data converted in a long 32 bit virtual signed long getFieldValue_4_13(word index); /// Sets the value of a field. The value is interpreted as a 24 bit signed integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 24 bit signed integer. The layout foreseen is the following: /// --------------------------------- /// - 24 bit int MSB 16 bits - the index passed as argument /// --------------------------------- /// - 24 bit int LSB 8 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=4, PFC = 13. /// See setFieldValue(word index, word value) for general considerations. /// \param index Represent the index of the field. /// \param value The 24 bit signed integer value. The long value is converted in a /// 24 bit data format (bit0 with the sign became 24 bit) virtual void setFieldValue_4_13(word index, signed long value) throw(PacketException*); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a 32 bit unsigned integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 32 bit unsigned long. The layout foreseen is the following: /// --------------------------------- /// - 32 bit int MSB 16 bits - the index passed as argument /// --------------------------------- /// - 32 bit int LSB 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=3, PFC = 14. /// \param index Represent the index of the field. virtual unsigned long getFieldValue_3_14(word index); virtual void setFieldValue_32i(word index, signed long value); /// Sets the value of a field. The value is interpreted as a 32 bit unsigned integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound Loading @@ -237,42 +197,41 @@ public: /// See setFieldValue(word index, word value) for general considerations. /// \param index Represent the index of the field. /// \param value The 32 bit unsigned integer value. virtual void setFieldValue_3_14(word index, unsigned long value); virtual void setFieldValue_32ui(word index, unsigned long value); /// Returns the value of a field in the list of fields of this part of packet. /// The value returned is interpreted as a 24 bit unsigned integer. /// Set the value of a field. The value is interpreted as a real single /// precision (IEEE 754). /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 24 bit unsigned long. The layout foreseen is the following: /// the 32 bit real single precision. The layout foreseen is the following: /// --------------------------------- /// - 24 bit int MSB 16 bits - the index passed as argument /// - float last 16 bits - the index passed as argument /// --------------------------------- /// - 24 bit int LSB 8 bits - the index + 1 /// - float first 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=3, PFC = 13. /// This corresponds with the PTC=5, PFC = 1. /// See setFieldValue(word index, word value) for general considerations. /// \param index Represent the index of the field. virtual unsigned long getFieldValue_3_13(word index); /// \param value The real single precision value virtual void setFieldValue_32f(word index, float value); /// Sets the value of a field. The value is interpreted as a 24 bit unsigned integer. /// The index of the argument is the first 16 bit field of the 2 fields that compound /// the 24 bit unsigned long. The layout foreseen is the following: /// Set the value of a field. The value is interpreted as a real double /// precision (IEEE 754). /// The index of the argument is the first 16 bit field of the 4 fields that compound /// the 64 bit real double precision. The layout foreseen is the following: /// --------------------------------- /// - 24 bit int MSB 16 bits - the index passed as argument /// - float last 16 bits - the index passed as argument /// --------------------------------- /// - float third 16 bits - the index + 1 /// --------------------------------- /// - float second 16 bits - the index + 1 /// --------------------------------- /// - 24 bit int LSB 8 bits - the index + 1 /// - float first 16 bits - the index + 1 /// --------------------------------- /// This corresponds with the PTC=3, PFC = 13. /// This corresponds with the PTC=5, PFC = 2. /// See setFieldValue(word index, word value) for general considerations. /// \param index Represent the index of the field. /// \param value The 24 bit unsigned integer value. virtual void setFieldValue_3_13(word index, unsigned long value) throw(PacketException*); ///Documentation /// Sets the value of a field in the list of fields of this part of packet. Remember that /// if a predefined value is specified in the .stream, this method has not effect and the /// value contained in the .stream is used. /// \param index Represent the index in the list. /// \param value The value must be set. virtual void setFieldValue(word index, word value); /// \param value The real double precision value virtual void setFieldValue_64f(word index, double value); /// Returns the number of fields. virtual inline word getNumberOfFields() Loading
src/Field.cpp +95 −0 Original line number Diff line number Diff line Loading @@ -77,3 +77,98 @@ Field::~Field() { } void Field::print() { cout << progressiv << " " << getName() << " " << size() << endl; } void Field::getType(char* type, enum LogicalFieldDataType &outtype, int &outtypenfields, int &outputfieldsbitsize) { outtype = UNKNOWN; outputfieldsbitsize = 0; outtypenfields = 0; int dim = atoi(type); if(dim == 0) { //>= 16bit outputfieldsbitsize = 16; if(strcmp(type, "int16") == 0) { outtypenfields = 1; outtype = INT16; } else if(strcmp(type, "uint16") == 0) { outtypenfields = 1; outtype = UINT16; } else if(strcmp(type, "int32") == 0) { outtypenfields = 2; outtype = INT32; } else if(strcmp(type, "uint32") == 0) { outtypenfields = 2; outtype = UINT32; } else if(strcmp(type, "float") == 0) { outtypenfields = 2; outtype = FLOAT; } else if(strcmp(type, "int64") == 0) { outtypenfields = 4; outtype = INT64; } else if(strcmp(type, "uint64") == 0) { outtypenfields = 4; outtype = UINT64; } else if(strcmp(type, "double") == 0) { outtypenfields = 4; outtype = DOUBLE; } } else { //<=16 bit (unsigned) outtypenfields = 1; outputfieldsbitsize = dim; switch(dim) { case 1: outtype = UINT1; break; case 2: outtype = UINT2; break; case 3: outtype = UINT3; break; case 4: outtype = UINT4; break; case 5: outtype = UINT5; break; case 6: outtype = UINT6; break; case 7: outtype = UINT7; break; case 8: outtype = UINT8; break; case 9: outtype = UINT9; break; case 10: outtype = UINT10; break; case 11: outtype = UINT11; break; case 12: outtype = UINT12; break; case 13: outtype = UINT13; break; case 14: outtype = UINT14; break; case 15: outtype = UINT15; break; case 16: outtype = UINT16; break; } } }
src/Packet.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -460,6 +460,10 @@ void Packet::generateStream() header->generateStream(bigendian); dataField->generateStream(bigendian); //add compression here of the datafield //TODO //dataField->compress(); } Loading
src/PartOfPacket.cpp +23 −61 Original line number Diff line number Diff line Loading @@ -473,7 +473,7 @@ void PartOfPacket::setFieldValue(word index, word value) fields[index]->value = (value & pattern[fields[index]->size()]); } float PartOfPacket::getFieldValue_5_1(word index) float PartOfPacket::getFieldValue_32f(word index) { union u_tag { Loading @@ -486,12 +486,11 @@ float PartOfPacket::getFieldValue_5_1(word index) return u.f; } double PartOfPacket::getFieldValue_5_2(word index) double PartOfPacket::getFieldValue_64f(word index) { if(sizeof(unsigned long) == 4) { //TODO cout << "this does not work in a 32 bit system" << endl; exit(0); throw new PacketException("The getFieldValue_64f() does not work in a 32 bit operating system"); } union u_tag Loading @@ -505,7 +504,7 @@ double PartOfPacket::getFieldValue_5_2(word index) return u.d; } void PartOfPacket::setFieldValue_5_1(word index, float value) void PartOfPacket::setFieldValue_32f(word index, float value) { union u_tag { Loading @@ -522,12 +521,11 @@ void PartOfPacket::setFieldValue_5_1(word index, float value) setFieldValue(index + 1, w); } void PartOfPacket::setFieldValue_5_2(word index, double value) void PartOfPacket::setFieldValue_64f(word index, double value) { if(sizeof(unsigned long) == 4) { //TODO cout << "this does not work in a 32 bit system" << endl; exit(0); throw new PacketException("The getFieldValue_64f() does not work in a 32 bit operating system"); } union u_tag Loading @@ -550,14 +548,14 @@ void PartOfPacket::setFieldValue_5_2(word index, double value) setFieldValue(index + 3, w); } signed long PartOfPacket::getFieldValue_4_14(word index) signed long PartOfPacket::getFieldValue_32i(word index) { long l; l = (long)(getFieldValue(index) << 16) | (long)getFieldValue(index + 1); return l; } void PartOfPacket::setFieldValue_4_14(word index, signed long value) void PartOfPacket::setFieldValue_32i(word index, signed long value) { word w; w = (word)(value >> 16); Loading @@ -566,14 +564,14 @@ void PartOfPacket::setFieldValue_4_14(word index, signed long value) setFieldValue(index + 1, w); } unsigned long PartOfPacket::getFieldValue_3_14(word index) unsigned long PartOfPacket::getFieldValue_32ui(word index) { dword l; l = (dword)(getFieldValue(index) << 16) | (dword)getFieldValue(index + 1); return l; } void PartOfPacket::setFieldValue_3_14(word index, unsigned long value) void PartOfPacket::setFieldValue_32ui(word index, unsigned long value) { word w; w = (word)(value >> 16); Loading @@ -582,67 +580,31 @@ void PartOfPacket::setFieldValue_3_14(word index, unsigned long value) setFieldValue(index + 1, w); } unsigned long PartOfPacket::getFieldValue_3_13(word index) word PartOfPacket::getFieldValue_16ui(word index) { word wh, wl; wh = getFieldValue(index); wl = getFieldValue(index + 1); return (dword)(wh << 8) | (dword)(wl & 0xFF); return getFieldValue(index); } void PartOfPacket::setFieldValue_3_13(word index, unsigned long value) throw(PacketException*) signed short PartOfPacket::getFieldValue_16i(word index) { word w; if(value > U24BITINTGEGERUNSIGNED_MAX) throw new PacketException("setFieldValue_3_13(): the max value of 24 bit unsigned integer should be 16777215"); w = (word)(value >> 8); setFieldValue(index, w); w = (word) (0xFF & value); setFieldValue(index + 1, w); signed short l; l = (signed short)getFieldValue(index); return l; } signed long PartOfPacket::getFieldValue_4_13(word index) void PartOfPacket::setFieldValue_16i(word index, signed short value) { union u_tag { /// 32 bit unsigned long u; signed long s; } us; us.u = getFieldValue_3_14(index); /// get the sign unsigned long sign = (us.u >> 23); unsigned long wh = us.u & 0x007FFFFF; /// get a long 32 bit if(sign == 1) us.u = 0x7F800000 + wh + (sign << 31); else us.u = wh + (sign << 31); return us.s; word w; w = (word)value; setFieldValue(index, w); } void PartOfPacket::setFieldValue_4_13(word index, signed long value) throw(PacketException*) void PartOfPacket::setFieldValue_16ui(word index, word value) { union u_tag { /// 32 bit unsigned long u; signed long s; } us; if(value > U24BITINTGEGERSIGNED_MAX) throw new PacketException("setFieldValue_4_13(): the max value of 24 bit signed integer should be 8388607"); if(value < U24BITINTGEGERSIGNED_MIN) throw new PacketException("setFieldValue_4_13(): the min value of 24 bit signed integer should be -8388607"); us.s = value; unsigned long sign = (us.u >> 31); /// 23 bit unsigned long wh = us.u & 0x007FFFFF; unsigned long value2 = 0; value2 = wh + (sign << 23); setFieldValue_3_14(index, value2); setFieldValue(index, value); } void PacketLib::PartOfPacket::memByteStream(ByteStreamPtr stream) { this->stream = stream; }