DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Merging files/groups/channels in a script

I'm sure this is a common issue, but despite extensive searching on these boards i couldn't find a soloution, hence this post.

I have an unknown number of tdm files.
Each file has the same groups containing the same channels.
Each group has it's own time channel.
(One file might contian 5 minutes of registered data, another file the next 4 minutes etc).

When diadem starts i want to run a script that merges all the data from the present files, so that each group and each channel only occurs once i the dataportal. (If i simply load them all using "DataFileLoad" groups and channels will occur multiple times, depending on the number of files).

So is there a way of letting diadem know that even though there are several files, they should be viewed as the same?

Alternatively, is there a way of programatically merging the TDM files into a new greater file containing all the present data?
0 Kudos
Message 1 of 8
(5,872 Views)
I think you can merge your files:
First of all load all files. For example, if you have three files with two groups (A and B) you get six groups (A, B, A1, B1, A2, B2). Look in the time channels from group A, A1 and A2 to find out the chronological order and then merge in groups your channels with "Call ChnConcat(ChnArg1, ChnArg2)". If group A is the newest and A2 the oldest, the first step should be:

intChnAnz=GroupChnCount(GroupIndexGet("A1"))
for i=1 to intChnAnz
strCNsource=CN(CNoXGet(GroupIndexGet(A1),i))
strCNtarget=CN(CNoXGet(GroupIndexGet(A),i))
call ChnConcat("A1/"&strCNsource,"A/"&strCNtarget)
next

After merging you can delete group A1 with "GroupDel(GroupIndexGet("A1"))" and then do the next merge ... I think you can put this also in a loop ...

I hope this helps.
Andreas
0 Kudos
Message 2 of 8
(5,849 Views)

Hi salte,

There is an application on the web that does this automatically-- check it out:

http://zone.ni.com/devzone/cda/epd/p/id/3870

Unfortunately, it seems that with the changeover from Domino server to Vignette, that this web site got garbled-- all the zip files now have cryptic names, and the most important one is missing altogether.  Are you importing your data files with the ASCII Import Wizard plugin, the Excel Import Wizard, or with a DataPlugin (including DAT, TDM, TDMS files)?

The zip files "4284.zip" and "4285.zip" at this support page cover the two Import Wizard cases, but they also each have a VBScript that consolidates groups already loaded into the Data Portal.  I can send you the missing "4286.zip" file if you are using a DataPlugin to load your files.

Regards,
Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 3 of 8
(5,840 Views)
Hi again and thanks for your replies.

Brad:
I'm importing the files programatically in a vb script, using "DataFileLoad".
The files are TDM format.

Is that enough information?
Is the missing file the one I need?
If so, i'd be very happy if you could send it to me at:
sigmund DOT fuglestad AT nov DOT com

If there already is tool for this i'd rather not spend time making it all over again.
0 Kudos
Message 4 of 8
(5,780 Views)

Hi salte,

Yup, the one you want is the link that disappeared, the "DataPlugin" flavor of this application.  You can either Assign DataPlugin="TDM" or DataPlugin="" to instruct DIAdem to use the TDM DataPlugin when loading your TDM files.

Here's the example,
Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 5 of 8
(5,760 Views)
Thanks for the link, I'm having some problems though.

As described earlier I have several groups containing several channels each. The only time i can get this script to work is if there is only one group of channels in each file.

Is that the way it is supposed to be, or am i not using it properly?

I tested with two groups of channels in each file, each group containing a time channel and a three valus channels. After running the script i was left with ONE group containing three channels, meaning the values from different channels (channels representing different values) were merged.

Any ideas regarding this?
0 Kudos
Message 6 of 8
(5,730 Views)

Hi salte,

True, the script assumes that each file has only 1 Group.  You could change the DataFileLoad() command to the DataFileLoadSel() command and pass the channel string "[1]/*" or "[2]/*" to load only the channels from Group [1] or Group [2].  Then the script will work as designed.  If you really have to merge multiple Groups from multiple files all in one step, then you'll need to edit the script significantly.

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 7 of 8
(5,708 Views)
In the end i decided to create the script pretty much from scratch, using the method suggested by wilken. Additionally I had to extend the lengths of each channel.

The script provided by Brad is probably more robust, but it was just too much code to work with (i have a rather limited amount of time).

But thanks to both of you for your input!
0 Kudos
Message 8 of 8
(5,646 Views)