473,241 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

Data structure problems.

I am working on a project to read a Bosch Measurement Data File (MDF).
The file contains a number of blocks that can be read from the file
using a baisc structure.

For example the ID BLOCK is as follows,

(Data Type) (Number of Elements) (Description)
CHAR 8 File identifier,
CHAR 8 Format identifier,
CHAR 8 Program identifier,
UINT16 1 Byte order
UINT16 1 Floating-point
UINT16 1 Version number
UINT16 1 Reserved
CHAR 2 Reserved
CHAR 30 Reserved

The measured data is described with a channel group as follows (Link is
a file offset pointer)

CHAR 2 Block type identifier, always "CG"
UINT16 1 Block size of this block in bytes (entire CGBLOCK)
LINK 1 Pointer to next data Channel group block (CGBLOCK) (NIL
allowed)
LINK 1 Pointer to first channel block (CNBLOCK) (NIL allowed)
LINK 1 Pointer to channel group comment text (TXBLOCK) (NIL allowed)
UINT16 1 Record ID
UINT16 1 Number of channels
UINT16 1 Data record size in bytes (without the record ID), i.e. data
size of the channel group for each sample
UINT32 1 Number of records

This channel group above, defines how big the data record size is and
how many records are contained. The data record can consist of many
channels that are described as follows

CHAR 2 Block type identifier, always "CN"
UINT16 1 Block size of this block in bytes (entire CNBLOCK)
LINK 1 Pointer to next channel block (CNBLOCK) of this channel group
(NIL allowed)
LINK 1 Pointer to the conversion formula (CCBLOCK) of this signal
(NIL allowed).
LINK 1 Reserved
LINK 1 Reserved
LINK 1 Pointer to the channel comment (TXBLOCK) of this signal (NIL
allowed)
UINT16 1 Channel type 0 = data channel, 1 = time channel for all
signals of this group (in each channel group, exactly one
channel must be defined as time channel)
CHAR 32 Signal name, i.e. the first 32 characters of the ASAM-MCD
unique name
CHAR 128 Signal description
UINT16 1 Number of the first bits [0..n] (bit position within a byte:
bit 0 is the least significant bit, bit 7 is the most significant bit)
UINT16 1 Number of bits
UINT16 1 Signal data type
0 = unsigned integer
1 = signed integer (two's complement)
2,3 = IEEE 754 floating-point format
7 = String (NULL terminated)
8 = Byte Array
BOOL 1 Value range - known implementation value
REAL 1 Value range - minimum implementation value
REAL 1 Value range - maximum implementation value
REAL 1 Rate in which the variable was sampled. Unit [s]
LINK 1 Pointer to the ASAM-MCD unique name (TXBLOCK) (NIL allowed)
LINK 1 Pointer to TXBLOCK that contains the signal's display
identifier (default: NIL; NIL allowed)
UINT16 1 Byte offset of the signal in the data record in addition to
bit offset (default value: 0) note: this fields shall only be used if
the CGBLOCK record size and the actual offset
is larger than 8192 Bytes to ensure compatibility; it enables to write
data blocks larger than 8kBytes

Since I cannot determine in advance what the number of channels are and
the data format of each channel what is the best way to create the data
structure in memory. I thought of reading in the raw data to a char
array. Dynamically allocate arrays for each channel. Then casting the
char array to the proper data type for each channel and fill the
arrays. Somehow I believe there must be an easier way to do this. Any
suggestions?

Dec 6 '05 #1
1 2721
to************@gmail.com wrote:
I am working on a project to read a Bosch Measurement Data File (MDF).
The file contains a number of blocks that can be read from the file
using a baisc structure.

For example the ID BLOCK is as follows,

(Data Type) (Number of Elements) (Description)
CHAR 8 File identifier,
CHAR 8 Format identifier,
CHAR 8 Program identifier,
UINT16 1 Byte order
UINT16 1 Floating-point
UINT16 1 Version number
UINT16 1 Reserved
CHAR 2 Reserved
CHAR 30 Reserved
First step - create a struct.

typedef char MDF_CHAR8[8];
typedef char MDF_CHAR2[2];
typedef char MDF_CHAR30[30];

struct MDF_UNIT16
{
char m_data[2];

operator unsigned () const
{
// endian conversion magic here
};
};

struct ID_BLOCK
{
MDF_CHAR8 m_file_identifier;
MDF_CHAR8 m_format_identifier;
MDF_CHAR8 m_program_identifier;

MDF_UINT16 m_byte_order;
MDF_UINT16 m_floating_point;
MDF_UINT16 m_version_number;
MDF_UNIT16 m_reserved_1;
MDF_CHAR2 m_reserved_2;
MDF_CHAR30 m_reserved_3;
};

Do this for the rest of the "BLOCKS".

Then you can do simpler operations - like:

const ID_BLOCK * idblock = reinterpret_cast<const ID_BLOCK *>( data );

std::cout << idblock->m_version_number;

There is more stuff like this you can do.

The measured data is described with a channel group as follows (Link is
a file offset pointer)

CHAR 2 Block type identifier, always "CG"
UINT16 1 Block size of this block in bytes (entire CGBLOCK)
LINK 1 Pointer to next data Channel group block (CGBLOCK) (NIL
allowed)
LINK 1 Pointer to first channel block (CNBLOCK) (NIL allowed)
LINK 1 Pointer to channel group comment text (TXBLOCK) (NIL allowed)
UINT16 1 Record ID
UINT16 1 Number of channels
UINT16 1 Data record size in bytes (without the record ID), i.e. data
size of the channel group for each sample
UINT32 1 Number of records

This channel group above, defines how big the data record size is and
how many records are contained. The data record can consist of many
channels that are described as follows

CHAR 2 Block type identifier, always "CN"
UINT16 1 Block size of this block in bytes (entire CNBLOCK)
LINK 1 Pointer to next channel block (CNBLOCK) of this channel group
(NIL allowed)
LINK 1 Pointer to the conversion formula (CCBLOCK) of this signal
(NIL allowed).
LINK 1 Reserved
LINK 1 Reserved
LINK 1 Pointer to the channel comment (TXBLOCK) of this signal (NIL
allowed)
UINT16 1 Channel type 0 = data channel, 1 = time channel for all
signals of this group (in each channel group, exactly one
channel must be defined as time channel)
CHAR 32 Signal name, i.e. the first 32 characters of the ASAM-MCD
unique name
CHAR 128 Signal description
UINT16 1 Number of the first bits [0..n] (bit position within a byte:
bit 0 is the least significant bit, bit 7 is the most significant bit)
UINT16 1 Number of bits
UINT16 1 Signal data type
0 = unsigned integer
1 = signed integer (two's complement)
2,3 = IEEE 754 floating-point format
7 = String (NULL terminated)
8 = Byte Array
BOOL 1 Value range - known implementation value
REAL 1 Value range - minimum implementation value
REAL 1 Value range - maximum implementation value
REAL 1 Rate in which the variable was sampled. Unit [s]
LINK 1 Pointer to the ASAM-MCD unique name (TXBLOCK) (NIL allowed)
LINK 1 Pointer to TXBLOCK that contains the signal's display
identifier (default: NIL; NIL allowed)
UINT16 1 Byte offset of the signal in the data record in addition to
bit offset (default value: 0) note: this fields shall only be used if
the CGBLOCK record size and the actual offset
is larger than 8192 Bytes to ensure compatibility; it enables to write
data blocks larger than 8kBytes

Since I cannot determine in advance what the number of channels are and
the data format of each channel what is the best way to create the data
structure in memory.
I have no idea. What is a channel ?
... I thought of reading in the raw data to a char
array. Dynamically allocate arrays for each channel. Then casting the
char array to the proper data type for each channel and fill the
arrays.
Somthing like that would work.
... Somehow I believe there must be an easier way to do this. Any
suggestions?


No, parsing binary data is non trivial.


Dec 6 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Maria | last post by:
Hi Everyone This is a data base question so don't switch off thinking it is a Data Protection Act Question. I'm Looking for some general information regarding the UK Law on rights to access...
1
by: Da-Breegster | last post by:
Hi. I'm attempting to write a roguelike (think nethack, crawl, angband, tome, adom, and yes, I suppose even rogue) in Perl and I've ran into a problem regarding the data structure for the map and...
8
by: Steve Jorgensen | last post by:
Hi folks, I'm posting this message because it's an issue I come up against relatively often, but I can't find any writings on the subject, and I haven't been able to figure out even what key...
4
by: Dan | last post by:
I'm trying to creat a data structure, that can be either a integer, double, string, or linked list. So I created the following, but don't know if it is the data structure itself causing problems,...
10
by: Bart Goeman | last post by:
Hi, I have a question about how to put redundant information in data structures, initialized at compile time. This is often necessary for performance reasons and can't be done at run time (data...
3
by: juky | last post by:
Hi all, I have 2 applications one in VB.net and the other in VC6. I need to pass data between them. How can I do it? what's the best way to implement such communication ? Any comment will be...
3
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
5
by: Lloyd Dupont | last post by:
I'm attempting to write a fairly complex data structure. One part of the complexity is that all 8 data operations it supports delegate some code to virtual method. This is by design because I...
10
by: Uma - Chellasoft | last post by:
Hai, I am new to VB.Net programming, directly doing socket programming. In C, I will be able to map the message arrived in a socket directly to a structure. Is this possible in VB.Net. Can...
31
by: aarklon | last post by:
Hi all, this is a question which i saw in a book typedef struct mall_li_header_ { int refcnt; uchar pool; uchar flag; ushort magic_no; char data;
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.