DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Time Channel: Is there a better way?

I am evaluating DIAdem for possible use within our engineering department.  I've developed a plugin for our data file format and it works, though I'm wondering if a more efficient method exists for filling the time channel.  The file is binary and the time tag for each record is derived from four 16-bit integer channels.  The last thing my plugin does is make a pass through the data to calculate all of the time values like this:
 
  'Now calculate the time values
  Dim oTime : Set oTime = CreateTime(0,0,0,0,0,0,0,0,0)
  For i = 1 to Block.Channels.Item(3).Size
    oTime.Hour = Block.Channels.Item(3).Values(i)
    oTime.Minute = Block.Channels.Item(4).Values(i) \ 60
    oTime.Second = Block.Channels.Item(4).Values(i) Mod 60
    oTime.MilliSecond = Block.Channels.Item(5).Values(i)
    oTime.MicroSecond = Block.Channels.Item(6).Values(i) * 10
    TimeChannel.Values(i) = oTime
  Next

 
Is this the way to go or am I making this much harder than it needs to be?
0 Kudos
Message 1 of 3
(3,111 Views)

Hi Dale,

In general your code looks spot-on, though I'm surprised you're not getting an error when you're assigning the oTime value, because you should have to use the "Set" syntax when assigning an object:

Set TimeChannel.Values(i) = oTime

But aside from that, what you have there may be as good as it gets.  There are a few other tricks if you happen to have a column in your file that lists the elapsed number of seconds with DBL accuracy.  If you're willing to send over an example file, I'd be happy to look at it and let you know if I can come up with anything slicker.

Regards,
Brad Turpin
DIAdem Product Support Engineer
National Instruments

 

0 Kudos
Message 2 of 3
(3,100 Views)
Brad,
 
Thanks for your quick reply.  Nope, there is no other information about time and the rest of the file is just "columns" of binary data which I've set up as direct access channels.  Since there's no need to explicitly loop through the file to populate those channels, I thought there might be a similar mechanism I could "set and forget" for the time instead of using the For-Next loop.
 
This is my first exposure to both DIAdem and VBscript.  I wanted to be sure I wasn't making any rookie blunders.
 
Cheers,
Dale
 
0 Kudos
Message 3 of 3
(3,077 Views)