MeVisLab Toolbox Reference
mlWaterColumnStructures.h
Go to the documentation of this file.
1// Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2// **InsertLicense** code
3//----------------------------------------------------------------------------------
5
12//----------------------------------------------------------------------------------
13#pragma once
14
15// Local includes
17
18// ML includes
19#include <mlModuleIncludes.h>
21#include <mlByteDataReader.h>
22
23#include <list>
24
26
27// The loader class these classes are used by.
28class PCLR2SonicWCLoader;
29
30namespace R2SonicWC {
31
32// Forward needed for boost shared pointer definition.
33class R2SonicWCLoader;
34
38 size_t numChars,
39 bool revert);
40
41// The water column data contains real-time beamformer 16-bit magnitude data
42// (beam amplitude) and optional 16-bit split-array phase data (intra-beam
43// direction). Maximum data rate is about 70 megabytes per second (assuming
44// 256 beams, 68.4 kHz sample rate, and phase data enabled). The sample rate
45// (and signal bandwidth) varies with transmit pulse width and range setting.
46// Maximum ping data size is about 32 megabytes (assuming 256 beams of 32768
47// samples, and phase data enabled), but max size may change in the future.
48// The number of beamformed data samples normally extends somewhat further
49// than the user's range setting.
50// When the operator enables water column mode, each sonar ping outputs
51// numerous 'WCD0' packets containing: one H0 header section, one A1 beam
52// angle section, and many M1 or M2 data sections. The section order may
53// change in the future, so plan for that in your data acquisition.
54// Each M1 or M2 section contains a subset of the ping data. Its header
55// indicates its size position to help you assemble the full ping array.
56// You may wish to detect missing M1 or M2 data sections (perhaps a lost
57// DP packet), and then fill the gap with zeros or perhaps data from the
58// previous ping (to reduce visual disturbances), and then increment an
59// error counter for network health monitoring purposes.
60// The water column data is basically in polar coordinates, so you may
61// wish to geometrically warp it into the familiar wedge shape for display.
62// Consider using OpenGL or Direct3D texture mapping.
63
64//-----------------------------------------------------------------------------------------------
66//-----------------------------------------------------------------------------------------------
85
86//-----------------------------------------------------------------------------------------------
88//-----------------------------------------------------------------------------------------------
144
145//-----------------------------------------------------------------------------------------------
148//-----------------------------------------------------------------------------------------------
150public:
153
155 ~WaterColumnA1() override;
156
158 std::string getSectionName() const override;
159
161 void reset() override;
162
165
167 std::string getAsString(std::string prefix,
168 const std::string &sep=" ",
169 const MLint maxBeams=-1) const;
170
171 std::vector<MLfloat> A1_BeamAngle;
174 MLfloat A1_MoreInfo[6];
175};
176
177//-----------------------------------------------------------------------------------------------
179//-----------------------------------------------------------------------------------------------
213
214//-----------------------------------------------------------------------------------------------
216//-----------------------------------------------------------------------------------------------
218public:
223
226
229
234 mutable std::vector<MLuint16> magnitudeData;
235
237 typedef struct {
240 }
242
246 mutable std::vector<DoubleMLint16> magnitudePhaseData;
247
250
254protected:
256
257public:
259 std::string getSectionName() const override;
260
262 void reset() override;
263
265 void mapMxSectionData() const;
266
268 void clearMxSectionData() const;
269
273
276
278 std::string getAsString(const MLint maxBeams=-1,
279 const MLint maxSamplesPerBeam=-1,
280 std::string prefix="",
281 const std::string &sep=" ") const;
282};
283
284//-----------------------------------------------------------------------------------------------
286//-----------------------------------------------------------------------------------------------
288public:
291
294
296 std::string getSectionName() const override;
297
299 void reset() override;
300
303
305 std::string getAsString(std::string prefix="") const;
306
310};
311
312//-----------------------------------------------------------------------------------------------
314//-----------------------------------------------------------------------------------------------
337
338//-----------------------------------------------------------------------------------------------
340//-----------------------------------------------------------------------------------------------
342public:
345
348
351
354
357 bool isValid() const;
358
360 std::list<WaterColumnSectionBase*> sectionList;
361
363 std::string unknownSection;
364
375
377
387
389 std::map<MLuint32, WaterColumnDataSetPing> allPingSections;
390
393 std::map<MLuint32, WaterColumnDataSetPing> validPingSections;
394
397 std::vector<MLuint32> allPingNumbers;
398
399protected:
402
403public:
404
406 virtual void reset();
407
413 PCLR2SonicWCLoader &updateObject);
414
433 std::string getAsString(const MLint maxSections=-1,
434 const MLint maxBeams=-1,
435 const MLint maxSamplesPerBeam=-1,
436 std::string prefix="",
437 const std::string &sep=" ",
438 const bool showFirstOfEachPacketTypeOnly=false) const;
439
440};
441
442}
443
Project global and OS specific declarations.
#define MLPCLR2SonicWCLoader_EXPORT
DLL export macro definition.
Base class to implement raw data loaders which need byte swapping and basic file access on byte or ra...
ML Module class to load a point cloud from the Point Cloud Library from a file.
Class to read R2Sonic water column sonar data.
A structure describing the A1 section of a WaterColumn data package containing float beam angles,...
MLuint64 read(ByteDataReader &reader, MLuint64 &fileReadPos, size_t numH0Beams)
Read section from a file with help of ByteDataReader reader and increase fileReadPos appropriately.
std::string getAsString(std::string prefix, const std::string &sep=" ", const MLint maxBeams=-1) const
See WaterColumnDataSet.getAsString for documentation.
std::vector< MLfloat > A1_BeamAngle
size=[H0_Beams]; [radians] angle of beam relative to array centerline, ordered from port to starboard...
void reset() override
Resets all members to construction state.
~WaterColumnA1() override
Default destructor.
std::string getSectionName() const override
Get name of section as std::string.
MLuint16 A1_SectionSize
[bytes] size of this entire section
WaterColumnA1()
Default constructor.
Class managing all sections belonging to the same ping.
virtual ~WaterColumnDataSetPing()
Default destructor.
MLuint32 pingNumber
The number of the ping the sections belong to.
WaterColumnDataSetPing()
Default constructor.
virtual void reset()
Resets all members to construction state.
const WaterColumnH0 * h0Section
Pointer to H0 section for the ping.
const WaterColumnA1 * a1Section
Pointer to A1 section for the ping.
std::list< const WaterColumnM1OrM2 * > mSectionPointers
List of M sections belonging to the ping (unsorted).
bool isValid() const
Returns true if the ping data structure contain all what is needed for a full and valid ping.
const WaterColumnPacket * wcd0Section
Pointer to WCD0 section for the ping.
Class describing the common data header of a WaterColumn data package.
std::string mostRecentSectionIntro
The first two chars of the most recently read section or "" otherwise.
WaterColumnSectionBase * mostRecentSection
Set most recently read section or nullptr otherwise.
WaterColumnM1OrM2 * firstM1Section
Set to the first found M1 section, nullptr otherwise.
WaterColumnA1 * firstA1Section
Set to the first found A1 section, nullptr otherwise.
std::string unknownSection
Intro of first found unknown section.
size_t numH0Sections
Set to number of found H0 sections after initialization, otherwise 0.
size_t numM1Sections
Set to number of found M1 sections after initialization, otherwise 0.
std::map< MLuint32, WaterColumnDataSetPing > validPingSections
The subset of pings of allPingSections which contains only those ones where WCD0, H0,...
size_t numA1Sections
Set to number of found A1 sections after initialization, otherwise 0.
WaterColumnM1OrM2 * firstMxSection
Set to the first found M1 or M2 section, nullptr otherwise.
std::map< MLuint32, WaterColumnDataSetPing > allPingSections
A map allowing the direct access to all sections belonging to a specific ping number.
size_t numWCD0Sections
Set to number of found WCD0 sections after initialization, otherwise 0.
WaterColumnPacket * firstWaterColumnPacket
Set to the first found waterColumnPacket, nullptr otherwise.
size_t numM2Sections
Set to number of found M2 sections after initialization, otherwise 0.
size_t numUnknownSections
Set to number of found unknown sections after initialization, otherwise 0.
WaterColumnH0 * firstH0Section
Set to the first found H0 section, nullptr otherwise.
std::vector< MLuint32 > allPingNumbers
An array containing all ping numbers found in file, and sorted.
MLuint64 getWorkingMemoryHint() const
Set working memory hints in bytes.
size_t numValidPingNumbers
Set to the number of different ping numbers in file which have valid H0, A1, WCD0,...
virtual void reset()
Resets all members to construction state.
void setWorkingMemoryHint(MLuint64 numBytes)
Set working memory hints in bytes.
WaterColumnM1OrM2 * firstM2Section
Set to the first found M2 section, nullptr otherwise.
MLuint64 read(R2SonicWCLoader &reader, MLuint64 &fileReadPos, PCLR2SonicWCLoader &updateObject)
Read all data section from a file with help of ByteDataReader reader and increase fileReadPos appropr...
size_t numOrphanedMSections
Set to number of found M sections where no WCD0, H0 or A1 section is found, otherwise 0.
std::string getAsString(const MLint maxSections=-1, const MLint maxBeams=-1, const MLint maxSamplesPerBeam=-1, std::string prefix="", const std::string &sep=" ", const bool showFirstOfEachPacketTypeOnly=false) const
Convert content to a human readable string with the prefix prefix before all lines and separator sep ...
virtual ~WaterColumnDataSet()
Default destructor.
MLuint64 _workingMemoryHint
Working memory hint in bytes.
WaterColumnDataSet()
Default constructor.
size_t numSamplesInFile
Set to number of samples in entire file, otherwise 0.
size_t numTotalPingNumbers
Set to the number of different ping numbers in file including those which have missing or invalid H0,...
std::list< WaterColumnSectionBase * > sectionList
List of all packets, must be deallocated.
bool isValid() const
Returns true if the file looks valid, otherwise false.
A structure describing the H0 section of a WaterColumn data package (only one per ping).
MLfloat H0_RxSampleRate
[hertz] sample rate of data acquisition and signal processing
MLuint32 H0_PingNumber
pings since power-up or reboot
MLuint16 H0_TxMiscInfo
reserved for future use
std::string getAsString(std::string prefix) const
See WaterColumnDataSet.getAsString for documentation.
std::string getSectionName() const override
Get name of section as std::string.
MLfloat H0_RxAbsorption
[dB per kilometer]
MLint16 H0_VTX_Plus_Offset
[hundredths of a dB] transmit voltage offset at time of ping (divide value by 100 to get dB)
MLfloat H0_TxPower
[dB re 1 uPa at 1 meter]
MLuint32 H0_RxMiscInfo
reserved for future use
MLfloat H0_PingPeriod
[seconds] time between most recent two pings
MLuint16 H0_SectionSize
[bytes] size of this entire section
MLuint16 H0_reserved
reserved for future use
MLfloat H0_RxSpreading
[dB (times log range in meters)]
MLuint32 H0_TimeSeconds
[seconds] ping time relative to 0000 hours 1-Jan-1970, integer part
~WaterColumnH0() override
Default destructor.
MLfloat H0_Frequency
[hertz] sonar center frequency
MLfloat H0_RxRange
[meters] sonar range setting
WaterColumnH0()
Default constructor.
MLuint32 H0_TimeNanoseconds
[nanoseconds] ping time relative to 0000 hours 1-Jan-1970, fraction part
std::string getModelNumber() const
Get model number as std::string.
MLuint64 read(ByteDataReader &reader, MLuint64 &fileReadPos)
Read section from a file with help of ByteDataReader reader and increase fileReadPos appropriately.
std::string getSerialNumber() const
Get serial number as std::string.
MLfloat H0_RxGain
[multiply by two for relative dB]
MLfloat H0_SoundSpeed
[meters per second]
void reset() override
Resets all members to construction state.
A structure describing the common data header of an M1_Data and an M2_Data section of a WaterColumn d...
virtual std::string getSectionName() const
Get name of section as std::string.
MLuint16 M1OrM2_SectionSize
[bytes] size of this entire section
std::string getAsString(std::string prefix) const
See WaterColumnDataSet.getAsString for documentation.
MLuint16 M1OrM2_TotalBeams
beams (always a multiple of 2) (typically columns in your memory buffer)
MLuint32 M1OrM2_TotalSamples
range samples in entire ping, sample rate is H0_RxSampleRate
MLuint32 M1OrM2_reserved0
reserved for future use
MLuint16 M1OrM2_Samples
number of samples in this section
MLuint32 M1OrM2_PingNumber
pings since power-up or reboot
MLuint16 M1OrM2_Beams
number of beams in this section (always a multiple of 2)
virtual ~WaterColumnM1AndM2Header()
Default destructor.
MLuint64 read(ByteDataReader &reader, MLuint64 &fileReadPos)
Read section from a file with help of ByteDataReader reader and increase fileReadPos appropriately.
MLuint32 M1OrM2_reserved1
reserved for future use
MLuint16 M1OrM2_FirstBeam
first beam of this section (always a multiple of 2)
MLfloat M1OrM2_ScalingFactor
reserved for future use
virtual void reset()
Resets all members to construction state.
WaterColumnM1AndM2Header()
Default constructor.
MLuint32 M1OrM2_FirstSample
first sample of this section
A structure describing the common data header of an M1_Data and an M2_Data section of a WaterColumn d...
MLuint64 read(R2SonicWCLoader &reader, MLuint64 &fileReadPos)
Read section from a file with help of ByteDataReader reader and increase fileReadPos appropriately.
MLuint64 fileDataReadPos
Location of M1/M2 data in file.
void mapMxSectionData() const
Actually load the M1/M2 section data.
void reset() override
Resets all members to construction state.
std::vector< MLuint16 > magnitudeData
Values 0 to 65535 map non-linearly (due to TVG scaling and possible gain compression) to signal ampli...
WaterColumnM1OrM2()
Default constructor.
std::vector< DoubleMLint16 > magnitudePhaseData
Magnitude and phase data (typical example: 256 beams each containing 36 four-byte structs,...
std::string getSectionName() const override
Get name of section as std::string.
std::string getAsString(const MLint maxBeams=-1, const MLint maxSamplesPerBeam=-1, std::string prefix="", const std::string &sep=" ") const
See WaterColumnDataSet.getAsString for documentation.
void clearMxSectionData() const
Unload magnitude and/or phase data from arrays and really try to unmap the array memory.
R2SonicWCLoader * _reader
Pointer to the reader which loaded this file; it must (and must be valid during entire life time) to ...
void unmapMxSectionDataHint() const
If memory saving mode is enabled then unload magnitude and/or phase data from arrays; may be ignored ...
WaterColumnM1AndM2Header m1OrM2CommonHeader
Common part of M1 and M2 section data.
bool saveMemory
Flag to indicate whether memory save mode is enabled or not.
~WaterColumnM1OrM2() override
Default destructor.
Class describing a introducing data packet of a WaterColumn data package.
MLuint32 PacketSize
[bytes] size of this entire packet
std::string getAsString(std::string prefix="") const
See WaterColumnDataSet.getAsString for documentation.
~WaterColumnPacket() override
Default destructor.
std::string getSectionName() const override
Get name of section as std::string.
void reset() override
Resets all members to construction state.
MLuint32 DataStreamID
reserved for future use
MLuint64 read(ByteDataReader &reader, MLuint64 &fileReadPos)
Read section from a file with help of ByteDataReader reader and increase fileReadPos appropriately.
WaterColumnPacket()
Default constructor.
A base class for all WaterColumn section formats.
MLuint16 sectionName
'WC', 'H0', 'A1', 'M1', 'M2'
virtual ~WaterColumnSectionBase()
Default destructor.
virtual std::string getSectionName() const =0
Get name of section as std::string.
MLuint64 posInFile
Location of section in file.
WaterColumnSectionBase()
Default constructor.
virtual void reset()
Set all members to 0.
Basic binary data loader class.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
Tool class for some string operations.
UINT64 MLuint64
Introduce platform independent 64 bit unsigned integer type.
Definition mlTypeDefs.h:425
unsigned int MLuint32
Definition mlTypeDefs.h:185
unsigned char MLuint8
Definition mlTypeDefs.h:109
unsigned short MLuint16
Definition mlTypeDefs.h:142
signed short MLint16
Definition mlTypeDefs.h:125
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:490
float MLfloat
Definition mlTypeDefs.h:201
MLPCLR2SonicWCLoader_EXPORT std::string convertBytesToReadableString(const char *chars, size_t numChars, bool revert)
Read a n-byte string reversely from memory into a human readable string or an empty string on nullptr...
Vector entry for storage for data from M2 sections.