openDAQ
Open data acquisition platform
IDataPacket Struct Referenceabstract

Packet that contains data sent by a signal. The data can be either explicit, or implicit. More...

+ Inheritance diagram for IDataPacket:
+ Collaboration diagram for IDataPacket:

Detailed Description

Packet that contains data sent by a signal. The data can be either explicit, or implicit.

Explicit data is contained within a signal's buffer, accessible through getRawData, while implicit packets do not carry any data. Their values are calculated given a rule, packet offset, and the index of a sample within the data buffer.

To obtain implicitly calculated, or scaled values, getData should be used. The data descriptor and sample count provide information about the type and amount of data available at the obtained address.

Public Member Functions

virtual ErrCode INTERFACE_FUNC getDataDescriptor (IDataDescriptor **descriptor)=0
 Gets the signal descriptor of the signal that sent the packet at the time of sending. More...
 
virtual ErrCode INTERFACE_FUNC getSampleCount (SizeT *sampleCount)=0
 Gets the number of samples in the packet. More...
 
virtual ErrCode INTERFACE_FUNC getOffset (INumber **offset)=0
 Gets current packet offset. This offset is later applied to the data rule used by a signal to calculate actual data value. This value is usually a time or other domain value. Packet offset is particularly useful when one wants to transfer a gap in otherwise equidistant samples. If we have a linear data rule, defined by equation f(x) = k*x + n, then the data value will be calculated by the equation g(x) = offset + f(x). More...
 
virtual ErrCode INTERFACE_FUNC getData (void **address)=0
 Gets the calculated/scaled data address of the packet. More...
 
virtual ErrCode INTERFACE_FUNC getRawData (void **address)=0
 Gets a pointer to the raw packet data. nullptr if the signal's data rule is implicit. More...
 
virtual ErrCode INTERFACE_FUNC getDataSize (SizeT *dataSize)=0
 Gets size of data buffer in bytes. More...
 
virtual ErrCode INTERFACE_FUNC getRawDataSize (SizeT *rawDataSize)=0
 Gets size of raw data buffer in bytes. More...
 
virtual ErrCode INTERFACE_FUNC getDomainPacket (IDataPacket **packet)=0
 Gets the associated domain Data packet. More...
 
virtual ErrCode INTERFACE_FUNC getPacketId (Int *packetId)=0
 Gets the unique packet id. More...
 
virtual ErrCode INTERFACE_FUNC getLastValue (IBaseObject **value, ITypeManager *typeManager=nullptr)=0
 Gets the data packet last value. More...
 
virtual ErrCode INTERFACE_FUNC getValueByIndex (IBaseObject **value, SizeT index, ITypeManager *typeManager=nullptr)=0
 Gets the data packet last value. More...
 
- Public Member Functions inherited from IPacket
virtual ErrCode INTERFACE_FUNC getType (PacketType *type)=0
 Gets the packet's type. More...
 
virtual ErrCode INTERFACE_FUNC subscribeForDestructNotification (IPacketDestructCallback *packetDestructCallback)=0
 Subscribes for notification when the packet is destroyed. More...
 
virtual ErrCode INTERFACE_FUNC getRefCount (SizeT *refCount)=0
 Gets the reference count of the packet. More...
 
- Public Member Functions inherited from IBaseObject
virtual ErrCode INTERFACE_FUNC borrowInterface (const IntfID &intfID, void **obj) const =0
 Returns another interface which is supported by the object without incrementing the reference count. More...
 
virtual ErrCode INTERFACE_FUNC dispose ()=0
 Disposes all references held by the object. More...
 
virtual ErrCode INTERFACE_FUNC getHashCode (SizeT *hashCode)=0
 Returns hash code of the object. More...
 
virtual ErrCode INTERFACE_FUNC equals (IBaseObject *other, Bool *equal) const =0
 Compares object to another object for equality. More...
 
virtual ErrCode INTERFACE_FUNC toString (CharPtr *str)=0
 Returns a string representation of the object. More...
 
- Public Member Functions inherited from IUnknown
virtual ErrCode INTERFACE_FUNC queryInterface (const IntfID &intfID, void **obj)=0
 Returns another interface which is supported by the object and increments the reference count. More...
 
virtual int INTERFACE_FUNC addRef ()=0
 Increments the reference count for an interface on an object. More...
 
virtual int INTERFACE_FUNC releaseRef ()=0
 Decrements the reference count for an interface on an object. More...
 

Member Function Documentation

◆ getData()

virtual ErrCode INTERFACE_FUNC getData ( void **  address)
pure virtual

Gets the calculated/scaled data address of the packet.

Parameters
[out]addressThe address of the data.

getData uses the packet's data descriptor to calculate the values as follows:

  1. If the data rule is implicit, it uses the packet offset and sample count to calculate the data according to the rule.
  2. If the data rule is explicit:
    • If the data is a Struct, it returns a pointer to the raw data.
    • If no Post scaling is defined, it simply returns a pointer to the raw data.
    • If the Post scaling is defined, it scales the data and returns a pointer to the scaled data.

The data should be cast to the appropriate type, as defined by the data descriptor, and read while keeping the data dimensions in mind.

◆ getDataDescriptor()

virtual ErrCode INTERFACE_FUNC getDataDescriptor ( IDataDescriptor **  descriptor)
pure virtual

Gets the signal descriptor of the signal that sent the packet at the time of sending.

Parameters
[out]descriptorThe signal descriptor.

◆ getDataSize()

virtual ErrCode INTERFACE_FUNC getDataSize ( SizeT *  dataSize)
pure virtual

Gets size of data buffer in bytes.

Parameters
[out]dataSizethe size of data buffer in bytes.

◆ getDomainPacket()

virtual ErrCode INTERFACE_FUNC getDomainPacket ( IDataPacket **  packet)
pure virtual

Gets the associated domain Data packet.

Parameters
[out]packetThe domain data packet.

◆ getLastValue()

virtual ErrCode INTERFACE_FUNC getLastValue ( IBaseObject **  value,
ITypeManager typeManager = nullptr 
)
pure virtual

Gets the data packet last value.

Parameters
[out]valueThe IBaseObject value can be a nullptr if there is no value, or if the data type is not supported by the function.
typeManagerOptional ITypeManager value can be provided to enable getLastValue for IStruct.

If a value is assigned, it can be cast based on the signal description to IFloat if the type is Float32 or Float64, to IInteger if the type is Int8 through Int64 or UInt8 through UInt64, to IComplexNumber if the type is ComplexFloat32 or ComplexFloat64, to IRange if the type is RangeInt64, to IStruct if the type is Struct, and to IList of the forementioned types if there is exactly one dimension.

◆ getOffset()

virtual ErrCode INTERFACE_FUNC getOffset ( INumber **  offset)
pure virtual

Gets current packet offset. This offset is later applied to the data rule used by a signal to calculate actual data value. This value is usually a time or other domain value. Packet offset is particularly useful when one wants to transfer a gap in otherwise equidistant samples. If we have a linear data rule, defined by equation f(x) = k*x + n, then the data value will be calculated by the equation g(x) = offset + f(x).

Parameters
[out]offsetThe packet offset

◆ getPacketId()

virtual ErrCode INTERFACE_FUNC getPacketId ( Int *  packetId)
pure virtual

Gets the unique packet id.

Parameters
[out]packetIdThe packet unique id.

The packet id is automatically created on packet construction.

◆ getRawData()

virtual ErrCode INTERFACE_FUNC getRawData ( void **  address)
pure virtual

Gets a pointer to the raw packet data. nullptr if the signal's data rule is implicit.

Parameters
[out]addressPointer to the raw packet data.

◆ getRawDataSize()

virtual ErrCode INTERFACE_FUNC getRawDataSize ( SizeT *  rawDataSize)
pure virtual

Gets size of raw data buffer in bytes.

Parameters
[out]dataSizethe size of raw data buffer in bytes.

Raw data size is 0 if signal's data rule is implicit.

◆ getSampleCount()

virtual ErrCode INTERFACE_FUNC getSampleCount ( SizeT *  sampleCount)
pure virtual

Gets the number of samples in the packet.

Parameters
[out]sampleCountthe number of samples.

◆ getValueByIndex()

virtual ErrCode INTERFACE_FUNC getValueByIndex ( IBaseObject **  value,
SizeT  index,
ITypeManager typeManager = nullptr 
)
pure virtual

Gets the data packet last value.

Parameters
[out]valueThe IBaseObject value can be a nullptr if there is no value, or if the data type is not supported by the function.
[in]indexIndex of the sample to obtain.
typeManagerOptional ITypeManager value can be provided to enable getLastValue for IStruct.

If a value is assigned, it can be cast based on the signal description to IFloat if the type is Float32 or Float64, to IInteger if the type is Int8 through Int64 or UInt8 through UInt64, to IComplexNumber if the type is ComplexFloat32 or ComplexFloat64, to IRange if the type is RangeInt64, to IStruct if the type is Struct, and to IList of the forementioned types if there is exactly one dimension.