Commit 6a457c43 authored by Andrea Bulgarelli's avatar Andrea Bulgarelli
Browse files

added get-setFieldValue(string fieldname) in SourceDataField, SDFBlock, PartOfPacket

parent 3f0035ce
Loading
Loading
Loading
Loading
+97 −1
Original line number Diff line number Diff line
@@ -233,6 +233,102 @@ public:
    /// \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()
    {
+89 −0
Original line number Diff line number Diff line
@@ -287,6 +287,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();

+89 −0
Original line number Diff line number Diff line
@@ -122,6 +122,95 @@ public:
    /// \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.
    virtual word getNumberOfFields();
+118 −2
Original line number Diff line number Diff line
@@ -472,14 +472,19 @@ word PartOfPacket::getFieldValue(word index)
	decode();
	if(index < numberOfFields)
		return fields[index]->value;
	else
	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; i<numberOfFields; i++) {
		Field* f = fields[i];
		string fname = f->getName();
		if(fieldname == fname)
			return i;
	}
	throw new PacketException("getFieldIndex(fieldname) error: no field found in this section");
	return index;
}
+95 −0
Original line number Diff line number Diff line
@@ -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);
	
}

Loading