diff --git a/include/PartOfPacket.h b/include/PartOfPacket.h index 8bb91cce44e7a51ffae7035a37b1578093851b40..54ddf1e9286d842ff765fb8f3daa06c47fd64e1f 100644 --- a/include/PartOfPacket.h +++ b/include/PartOfPacket.h @@ -86,7 +86,7 @@ public: /// (depends by the size of the field in bits) /// \param index Represent the index in the list. 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 16 bit signed integer. /// \param index Represent the index of the field. @@ -232,6 +232,102 @@ public: /// \param index Represent the index of the field. /// \param value The real double precision value virtual void setFieldValue_64f(word index, double value); + + //-------------------------------- + + /// 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 fieldname Represent the name of the field. + virtual word getFieldValue(string fieldname); + + /// 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 signed integer. + /// \param fieldname Represent the name of the field. + virtual signed short getFieldValue_16i(string fieldname); + + /// 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 fieldname Represent the name of the field. + virtual word getFieldValue_16ui(string fieldname); + + /// 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. + /// This corresponds with the PTC=4, PFC = 14. + /// \param fieldname Represent the name of the field. + virtual signed long getFieldValue_32i(string fieldname); + + /// 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. + /// This corresponds with the PTC=3, PFC = 14. + /// \param fieldname Represent the name of the field. + virtual unsigned long getFieldValue_32ui(string fieldname); + + /// 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). + /// This corresponds with the PTC=5, PFC = 1 <=> float or 32f + /// \param fieldname Represent the name of the field. + virtual float getFieldValue_32f(string fieldname); + + /// 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). + /// This corresponds with the PTC=5, PFC = 2. <=> double or 64f + /// \param fieldname Represent the name of the field. + virtual double getFieldValue_64f(string fieldname); + + ///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 fieldname Represent the name of the field. + /// \param value The value must be set. + virtual void setFieldValue(string fieldname, word value); + + /// Sets the value of a field. The value is interpreted as a 16 bit signed integer. + /// \param fieldname Represent the name of the field. + /// \param value The 16 bit signed integer value. + virtual void setFieldValue_16i(string fieldname, signed short value); + + /// Sets the value of a field. The value is interpreted as a 16 bit unsigned integer (word). + /// \param fieldname Represent the name of the field. + /// \param value The 16 bit unsigned integer value. + virtual void setFieldValue_16ui(string fieldname, word value); + + /// Sets the value of a field. The value is interpreted as a 32 bit signed integer. + /// --------------------------------- + /// This corresponds with the PTC=4, PFC = 14. + /// See setFieldValue(word index, word value) for general considerations. + /// \param fieldname Represent the name of the field. + /// \param value The 32 bit signed integer value. + virtual void setFieldValue_32i(string fieldname, signed long value); + + /// Sets the value of a field. The value is interpreted as a 32 bit unsigned integer. + /// This corresponds with the PTC=3, PFC = 14. + /// See setFieldValue(word index, word value) for general considerations. + /// \param fieldname Represent the name of the field. + /// \param value The 32 bit unsigned integer value. + virtual void setFieldValue_32ui(string fieldname, unsigned long value); + + /// Set the value of a field. The value is interpreted as a real single + /// precision (IEEE 754). + /// This corresponds with the PTC=5, PFC = 1. + /// See setFieldValue(word index, word value) for general considerations. + /// \param fieldname Represent the name of the field. + /// \param value The real single precision value + virtual void setFieldValue_32f(string fieldname, float value); + + /// Set the value of a field. The value is interpreted as a real double + /// precision (IEEE 754). + /// This corresponds with the PTC=5, PFC = 2. + /// See setFieldValue(word index, word value) for general considerations. + /// \param fieldname Represent the name of the field. + /// \param value The real double precision value + virtual void setFieldValue_64f(string fieldname, double value); + + virtual word getFieldIndex(string fieldname); + + + //-------------------------------- /// Returns the number of fields. virtual inline word getNumberOfFields() diff --git a/include/SDFBlock.h b/include/SDFBlock.h index ed196798001cf5dec5e737af8044c8faec8892ab..58f938cff8146b499800e357824885b751b81cd8 100644 --- a/include/SDFBlock.h +++ b/include/SDFBlock.h @@ -286,6 +286,95 @@ public: { return getTotalNumberOfFields(); }; + + /// 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 fieldname Represent the name of the field. + virtual word getFieldValue(string fieldname); + + /// 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 signed integer. + /// \param fieldname Represent the name of the field. + virtual signed short getFieldValue_16i(string fieldname); + + /// 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 fieldname Represent the name of the field. + virtual word getFieldValue_16ui(string fieldname); + + /// 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. + /// This corresponds with the PTC=4, PFC = 14. + /// \param fieldname Represent the name of the field. + virtual signed long getFieldValue_32i(string fieldname); + + /// 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. + /// This corresponds with the PTC=3, PFC = 14. + /// \param fieldname Represent the name of the field. + virtual unsigned long getFieldValue_32ui(string fieldname); + + /// 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). + /// This corresponds with the PTC=5, PFC = 1 <=> float or 32f + /// \param fieldname Represent the name of the field. + virtual float getFieldValue_32f(string fieldname); + + /// 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). + /// This corresponds with the PTC=5, PFC = 2. <=> double or 64f + /// \param fieldname Represent the name of the field. + virtual double getFieldValue_64f(string fieldname); + + ///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 fieldname Represent the name of the field. + /// \param value The value must be set. + virtual void setFieldValue(string fieldname, word value); + + /// Sets the value of a field. The value is interpreted as a 16 bit signed integer. + /// \param fieldname Represent the name of the field. + /// \param value The 16 bit signed integer value. + virtual void setFieldValue_16i(string fieldname, signed short value); + + /// Sets the value of a field. The value is interpreted as a 16 bit unsigned integer (word). + /// \param fieldname Represent the name of the field. + /// \param value The 16 bit unsigned integer value. + virtual void setFieldValue_16ui(string fieldname, word value); + + /// Sets the value of a field. The value is interpreted as a 32 bit signed integer. + /// --------------------------------- + /// This corresponds with the PTC=4, PFC = 14. + /// See setFieldValue(word index, word value) for general considerations. + /// \param fieldname Represent the name of the field. + /// \param value The 32 bit signed integer value. + virtual void setFieldValue_32i(string fieldname, signed long value); + + /// Sets the value of a field. The value is interpreted as a 32 bit unsigned integer. + /// This corresponds with the PTC=3, PFC = 14. + /// See setFieldValue(word index, word value) for general considerations. + /// \param fieldname Represent the name of the field. + /// \param value The 32 bit unsigned integer value. + virtual void setFieldValue_32ui(string fieldname, unsigned long value); + + /// Set the value of a field. The value is interpreted as a real single + /// precision (IEEE 754). + /// This corresponds with the PTC=5, PFC = 1. + /// See setFieldValue(word index, word value) for general considerations. + /// \param fieldname Represent the name of the field. + /// \param value The real single precision value + virtual void setFieldValue_32f(string fieldname, float value); + + /// Set the value of a field. The value is interpreted as a real double + /// precision (IEEE 754). + /// This corresponds with the PTC=5, PFC = 2. + /// See setFieldValue(word index, word value) for general considerations. + /// \param fieldname Represent the name of the field. + /// \param value The real double precision value + virtual void setFieldValue_64f(string fieldname, double value); /// Returns the number of fields of the overall block virtual word getTotalNumberOfFields(); diff --git a/include/SourceDataField.h b/include/SourceDataField.h index edd84d0f720a9484416cf3f7598386649ce26b50..aa08086a0374ec550f84d9221fc136b8846722af 100644 --- a/include/SourceDataField.h +++ b/include/SourceDataField.h @@ -121,6 +121,95 @@ public: /// \param index Represent the index in the list. /// \param value The value must be set. virtual void setFieldValue_64f(word index, double value); + + /// 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 fieldname Represent the name of the field. + virtual word getFieldValue(string fieldname); + + /// 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 signed integer. + /// \param fieldname Represent the name of the field. + virtual signed short getFieldValue_16i(string fieldname); + + /// 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 fieldname Represent the name of the field. + virtual word getFieldValue_16ui(string fieldname); + + /// 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. + /// This corresponds with the PTC=4, PFC = 14. + /// \param fieldname Represent the name of the field. + virtual signed long getFieldValue_32i(string fieldname); + + /// 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. + /// This corresponds with the PTC=3, PFC = 14. + /// \param fieldname Represent the name of the field. + virtual unsigned long getFieldValue_32ui(string fieldname); + + /// 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). + /// This corresponds with the PTC=5, PFC = 1 <=> float or 32f + /// \param fieldname Represent the name of the field. + virtual float getFieldValue_32f(string fieldname); + + /// 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). + /// This corresponds with the PTC=5, PFC = 2. <=> double or 64f + /// \param fieldname Represent the name of the field. + virtual double getFieldValue_64f(string fieldname); + + ///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 fieldname Represent the name of the field. + /// \param value The value must be set. + virtual void setFieldValue(string fieldname, word value); + + /// Sets the value of a field. The value is interpreted as a 16 bit signed integer. + /// \param fieldname Represent the name of the field. + /// \param value The 16 bit signed integer value. + virtual void setFieldValue_16i(string fieldname, signed short value); + + /// Sets the value of a field. The value is interpreted as a 16 bit unsigned integer (word). + /// \param fieldname Represent the name of the field. + /// \param value The 16 bit unsigned integer value. + virtual void setFieldValue_16ui(string fieldname, word value); + + /// Sets the value of a field. The value is interpreted as a 32 bit signed integer. + /// --------------------------------- + /// This corresponds with the PTC=4, PFC = 14. + /// See setFieldValue(word index, word value) for general considerations. + /// \param fieldname Represent the name of the field. + /// \param value The 32 bit signed integer value. + virtual void setFieldValue_32i(string fieldname, signed long value); + + /// Sets the value of a field. The value is interpreted as a 32 bit unsigned integer. + /// This corresponds with the PTC=3, PFC = 14. + /// See setFieldValue(word index, word value) for general considerations. + /// \param fieldname Represent the name of the field. + /// \param value The 32 bit unsigned integer value. + virtual void setFieldValue_32ui(string fieldname, unsigned long value); + + /// Set the value of a field. The value is interpreted as a real single + /// precision (IEEE 754). + /// This corresponds with the PTC=5, PFC = 1. + /// See setFieldValue(word index, word value) for general considerations. + /// \param fieldname Represent the name of the field. + /// \param value The real single precision value + virtual void setFieldValue_32f(string fieldname, float value); + + /// Set the value of a field. The value is interpreted as a real double + /// precision (IEEE 754). + /// This corresponds with the PTC=5, PFC = 2. + /// See setFieldValue(word index, word value) for general considerations. + /// \param fieldname Represent the name of the field. + /// \param value The real double precision value + virtual void setFieldValue_64f(string fieldname, double value); /// Returns the number of fields. diff --git a/src/PartOfPacket.cpp b/src/PartOfPacket.cpp index 1180e3a47405c18677652457251ae9901d373747..5f1f6d8889581f576c6cdaa92f0d639d05e7fcff 100644 --- a/src/PartOfPacket.cpp +++ b/src/PartOfPacket.cpp @@ -472,14 +472,19 @@ word PartOfPacket::getFieldValue(word index) decode(); if(index < numberOfFields) return fields[index]->value; - else - return 0; + else { + throw new PacketException("getFieldValue(index) error: index out of range"); + } + return 0; + }; void PartOfPacket::setFieldValue(word index, word value) { if(index < numberOfFields) fields[index]->value = (value & pattern[fields[index]->size()]); + else + throw new PacketException("setFieldValue(index, value) error: index out of range"); } float PartOfPacket::getFieldValue_32f(word index) @@ -617,3 +622,114 @@ void PartOfPacket::setFieldValue_16ui(word index, word value) void PacketLib::PartOfPacket::memByteStream(ByteStreamPtr stream) { this->stream = stream; } + + + +word PartOfPacket::getFieldValue(string fieldname) { + word index = getFieldIndex(fieldname); + return getFieldValue(index); +} + + +signed short PartOfPacket::getFieldValue_16i(string fieldname) { + word index = getFieldIndex(fieldname); + return getFieldValue_16i(index); +} + + + +word PartOfPacket::getFieldValue_16ui(string fieldname) { + word index = getFieldIndex(fieldname); + return getFieldValue_16ui(index); +} + + + +signed long PartOfPacket::getFieldValue_32i(string fieldname){ + word index = getFieldIndex(fieldname); + return getFieldValue_32i(index); +} + + + +unsigned long PartOfPacket::getFieldValue_32ui(string fieldname){ + word index = getFieldIndex(fieldname); + return getFieldValue_32ui(index); +} + + + +float PartOfPacket::getFieldValue_32f(string fieldname){ + word index = getFieldIndex(fieldname); + return getFieldValue_32f(index); +} + + + +double PartOfPacket::getFieldValue_64f(string fieldname){ + word index = getFieldIndex(fieldname); + return getFieldValue_64f(index); +} + + + +void PartOfPacket::setFieldValue(string fieldname, word value){ + word index = getFieldIndex(fieldname); + setFieldValue(index, value); +} + + + +void PartOfPacket::setFieldValue_16i(string fieldname, signed short value){ + word index = getFieldIndex(fieldname); + setFieldValue_16i(index, value); +} + + + +void PartOfPacket::setFieldValue_16ui(string fieldname, word value){ + word index = getFieldIndex(fieldname); + setFieldValue_16ui(index, value); +} + + + +void PartOfPacket::setFieldValue_32i(string fieldname, signed long value){ + word index = getFieldIndex(fieldname); + setFieldValue_32i(index, value); +} + + + +void PartOfPacket::setFieldValue_32ui(string fieldname, unsigned long value){ + word index = getFieldIndex(fieldname); + setFieldValue_32ui(index, value); + +} + + + +void PartOfPacket::setFieldValue_32f(string fieldname, float value){ + word index = getFieldIndex(fieldname); + setFieldValue_32f(index, value); +} + + + +void PartOfPacket::setFieldValue_64f(string fieldname, double value){ + word index = getFieldIndex(fieldname); + setFieldValue_64f(index, value); +} + +word PartOfPacket::getFieldIndex(string fieldname) { + word index = 0; + for(word i=0; igetName(); + if(fieldname == fname) + return i; + } + throw new PacketException("getFieldIndex(fieldname) error: no field found in this section"); + return index; +} + diff --git a/src/SDFBlock.cpp b/src/SDFBlock.cpp index 1b4be7c7e57550323cddf94efe2808aa37dc9714..841a70f775fff7231aed93cde0c96adc6f6293ae 100644 --- a/src/SDFBlock.cpp +++ b/src/SDFBlock.cpp @@ -666,4 +666,99 @@ word SDFBlock::getTotalNumberOfFields() return dim; } +word SDFBlock::getFieldValue(string fieldname) { + return fixed.getFieldValue(fieldname); + +} + + +signed short SDFBlock::getFieldValue_16i(string fieldname) { + return fixed.getFieldValue_16i(fieldname); + +} + + + +word SDFBlock::getFieldValue_16ui(string fieldname) { + return fixed.getFieldValue_16ui(fieldname); + +} + + + +signed long SDFBlock::getFieldValue_32i(string fieldname){ + return fixed.getFieldValue_32i(fieldname); + +} + + + +unsigned long SDFBlock::getFieldValue_32ui(string fieldname){ + return fixed.getFieldValue_32ui(fieldname); + +} + + + +float SDFBlock::getFieldValue_32f(string fieldname){ + return fixed.getFieldValue_32f(fieldname); + +} + + + +double SDFBlock::getFieldValue_64f(string fieldname){ + return fixed.getFieldValue_64f(fieldname); + +} + + + +void SDFBlock::setFieldValue(string fieldname, word value){ + fixed.setFieldValue(fieldname, value); + +} + + + +void SDFBlock::setFieldValue_16i(string fieldname, signed short value){ + fixed.setFieldValue_16i(fieldname, value); + +} + + + +void SDFBlock::setFieldValue_16ui(string fieldname, word value){ + fixed.setFieldValue_16ui(fieldname, value); + +} + + + +void SDFBlock::setFieldValue_32i(string fieldname, signed long value){ + fixed.setFieldValue_32i(fieldname, value); + +} + + + +void SDFBlock::setFieldValue_32ui(string fieldname, unsigned long value){ + fixed.setFieldValue_32ui(fieldname, value); + +} + + + +void SDFBlock::setFieldValue_32f(string fieldname, float value){ + fixed.setFieldValue_32f(fieldname, value); + +} + + + +void SDFBlock::setFieldValue_64f(string fieldname, double value){ + fixed.setFieldValue_64f(fieldname, value); + +} + diff --git a/src/SourceDataField.cpp b/src/SourceDataField.cpp index e183231f269e0e06b37594499e99a803bb9cbb34..3dd6137a933426c3176b2166773e068c172c041d 100644 --- a/src/SourceDataField.cpp +++ b/src/SourceDataField.cpp @@ -246,4 +246,100 @@ double SourceDataField::getFieldValue_64f(word index) { return block[0].getFieldValue_64f(index); } +word SourceDataField::getFieldValue(string fieldname) { + return block[0].getFieldValue(fieldname); + +} + + +signed short SourceDataField::getFieldValue_16i(string fieldname) { + return block[0].getFieldValue_16i(fieldname); + +} + + + +word SourceDataField::getFieldValue_16ui(string fieldname) { + return block[0].getFieldValue_16ui(fieldname); + +} + + + +signed long SourceDataField::getFieldValue_32i(string fieldname){ + return block[0].getFieldValue_32i(fieldname); + +} + + + +unsigned long SourceDataField::getFieldValue_32ui(string fieldname){ + return block[0].getFieldValue_32ui(fieldname); + +} + + + +float SourceDataField::getFieldValue_32f(string fieldname){ + return block[0].getFieldValue_32f(fieldname); + +} + + + +double SourceDataField::getFieldValue_64f(string fieldname){ + return block[0].getFieldValue_64f(fieldname); + +} + + + +void SourceDataField::setFieldValue(string fieldname, word value){ + block[0].setFieldValue(fieldname, value); + +} + + + +void SourceDataField::setFieldValue_16i(string fieldname, signed short value){ + block[0].setFieldValue_16i(fieldname, value); + +} + + + +void SourceDataField::setFieldValue_16ui(string fieldname, word value){ + block[0].setFieldValue_16ui(fieldname, value); + +} + + + +void SourceDataField::setFieldValue_32i(string fieldname, signed long value){ + block[0].setFieldValue_32i(fieldname, value); + +} + + + +void SourceDataField::setFieldValue_32ui(string fieldname, unsigned long value){ + block[0].setFieldValue_32ui(fieldname, value); + +} + + + +void SourceDataField::setFieldValue_32f(string fieldname, float value){ + block[0].setFieldValue_32f(fieldname, value); + +} + + + +void SourceDataField::setFieldValue_64f(string fieldname, double value){ + block[0].setFieldValue_64f(fieldname, value); + +} + +