DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

separating 16 bits of data into one 12 bit and one 4 bit channel

Stefan2,
 
The script gives you all the flexibility to calculate the offsets. The only reason that I used the sum of the constants was to better illustrate that for each channel I added a certain offset. If you want to calculate the offsets in the script, you need to be able to retrieve the information from the file. Is there something like a header you can read to know how many channels are in the file ?
 
Andreas
0 Kudos
Message 11 of 22
(2,454 Views)

Hi Andreas,

thank you for your reply!

Unfortunately, there's no header information in my data file. The block width is implicitly given by the channels I wrote into the script.

My first idea to determine the offset of a particular channel was to do it at the place in the script where I put the place holder for that particular channel. I thought I could get the offset information from BinaryBlock, but then I read in the DIAdem help that BinaryBlock doesn't update the read pointer of the file while reading a binary block.

So, for the moment, my offsets are hard-coded in the script 😞

Any other idea to avoid hard-coded offsets?

Many thanks anyway!!! 🙂

Regards,
Stefan

0 Kudos
Message 12 of 22
(2,446 Views)

Stefan,

I am a bit confused. Let's make sure I understand the requirement. The files you want to read with your DataPlugin differ by the number of channels in the file. How can you tell the number of files when you read the file ? Let's say you have one file "File_1" with 10 channels and a second file "File_2" with 20 channels. How to you know how many channels are in the two files ?

Andreas

0 Kudos
Message 13 of 22
(2,444 Views)

Hi Andreas,

sorry, if my description was confusing...

The number of channels in the file is fix. The file doesn't contain any header information, so I have to specify all channels explicitly in the VBS-script. So, one could say, my pattern of channels is hard-coded. The only thing I wanted to avoid is the hard-coding of the offsets, because whenever the data set will change in a newer version, I would have to adapt the offsets in the VBS-script (besides handling the actual changes like adding new channels, removing others, etc.).

Or, let's put it that way:

Formerly, without extracting bits from particular channels, I just adapted my VBS-script by inserting/deleting channels at the proper place when the structure of the data set changed.

Now, with extracting bits, I have to additionally
- adapt the offsets of the channels of which I want to extract several bits
- adapt the block width

I hope that helps to understand my concern.

Many thanks for your answers and your patience!

Regards,
Stefan

0 Kudos
Message 14 of 22
(2,431 Views)

Stefan,

OK, now I got it. Would it be possible to share the current version of your Plugin and a few example files ? It would be far easier to make a recommendation if I could see the actual code.

Andreas

0 Kudos
Message 15 of 22
(2,429 Views)
Hi Andreas,
 
here is the example code (VBS-script) and an example data file. It's looks and works analogue to my original VBS-script and data file, however, I simplified and shortened it.
 
(By the way: for some reason, the last line is not extracted completely: the normal channels are ok, but for the channel with the bit masking the last line of the binary file is not read!? The behaviour was the same with my original VBS-script, though. So, please don't worry about that for the moment)
 
Many thanks again for your time!
 
Regards,
Stefan
 
0 Kudos
Message 16 of 22
(2,419 Views)

Stefan,

I think I understand what you are looking for and I think we could change the code a bit so that it's easier to maintain. From looking at your code I would make the following assumptions.

For a given version of the file you know :

How much bytes are in a single scan. For the version you send me, its 4 bytes ("blockWidth")
For a given channel all the bits are always in one byte. Or could there be channels distributed across more then one byte ?
For a given channel, you know which byte the data is in, at which bit the data starts and how many bits belong to the signal.
The channel names are defined by your, there is no generic rule to create them (thats just a minor question on the side)

Please let me know whether my assumptions are correct.

0 Kudos
Message 17 of 22
(2,414 Views)
Hi Andreas,
 
my answers to your assumptions are:

1) How much bytes are in a single scan. For the version you send me, its 4 bytes ("blockWidth")
Yes, it's 4 bytes in my example. This is one of the constants I wanted to get rid of: normally, I don't have to specify the blockWidth in the script, because it is given implicitly by the channels I specify in the script. For the case of bit masking particular channels, I have to set the blockWidth manually. Is there a function to call which tells me the blockWidth?

2) For a given channel all the bits are always in one byte. Or could there be channels distributed across more then one byte ?
No, a bit mask is not longer than 8 bits and doesn't cross the boundaries of a single byte.

3) For a given channel, you know which byte the data is in, at which bit the data starts and how many bits belong to the signal.
Yes.

4) The channel names are defined by your, there is no generic rule to create them (thats just a minor question on the side)
Correct.

Basically, I don't mind (resp. can't avoid) to specify the bit mask of a new channel and to place the placeholder-channel at the proper position whenever I add a new channel needing bit-masking. However, it would be practical, if no byte-positions of existing bit-channel have to be checked and adapted and if I wouldn't have to count the number of bytes manually to set the proper block width.

Kind regards,
Stefan

0 Kudos
Message 18 of 22
(2,410 Views)
Stefan,
please find attached an updated version of your Dataplugin script. All the configuration takes place in the header of the file. You can add new channels by adding a new entry to the array in the header. Each of the entries is independent from the others so adding or deleting doesn't require changing the remaining entries.
I have setup the Plugin so that it produces the same result. I was able to fix the problem with the last value in a channel. Looks like we have a problem here (on our side) but the code I provided makes sure that you get all the values for each channel
 
Please let me know whether this fits to you idea.
 
Andreas
0 Kudos
Message 19 of 22
(2,404 Views)

Hi Andreas,

thank you very much again for your help!!

I must admit, your version of the VBS-script is much more clearly arranged than mine. Thank you for your proposal!

Unfortunately, I still have to hard-code the number of bytes per scan and the position of the bit-masked bytes (in a more clearly arranged manner, admittedly).

If you say "each of the entries is independent from the others ..." I have to object that this is not quite true (if I'm not mistaken): If you insert new channels preceeding a certain existing channel, you have to adapt the indices of all succeeding channels in array "ChannelIsInByte". That's what I wanted to avoid.

If it is not possible to get the bytes per scan and the byte position implicitly (by just mentioning the channels in the proper order in the script, like I normally do without bit-masked channels), I think I'll stick to my version for the moment. The reason is: I also have got many file structures which don't need any bit-masked channels at all. For those I wouldn't want to create header arrays if it is sufficient to just mention the channels in the proper order in the script. And for the other files (with bit-masked channels) I wouldn't want to deviate from my pattern if I don't get rid of hard-coded byte position and block width.

However, thank you very much for your time and your help!!

Kind regards,
Stefan

 

0 Kudos
Message 20 of 22
(2,346 Views)