From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

close the 2nd file loaded - why does DIAdem merge all the files I open?

Solved!
Go to solution

OK, so maybe this is just a case of moving my thinking into the DIAdem world, but I need help here to understand something.

 

Let's say I open a file of data (file_a).  Then, I open a second file (file_b) that I am using to store some channel cross reference data (sometimes file_a comes from test cell1, test cell2, or test cell3, so the names of channels vary.  I have a table to look that up.  There are other groups with other functions.).

 

Now, when I'm all done using the information that was loaded by opening file_b, I can't simply close file_b.  In fact, file_b never appeared in the portal, DIAdem just took all the stuff that was in file_b and put it in with the data groups from file_a. 

 

Let's further say I have no idea how many data groups will be loaded when I open file_b, nor what they might be named, as the amount of stuff I need to look up changes over time.  So I have no easy way to call out which data groups to close.  But I want them closed.  I want to save file_a, with the work done, and I don't want file_b's contents saved with it.  Can it be done???

 

(PS I tried registering file_b instead of opening it but when I saved file_a at the end of the process the new data groups went into the saved file anyway.)

 

 

0 Kudos
Message 1 of 3
(2,599 Views)
Solution
Accepted by topic author jheadley

It is like you figured out.

 

DIAdem does not work on a file but adds data to the internal structure.

If a file is saved the internal data is saved. This fits quiet well in a world of generating repetive reports but does not match your use case of working on a single file.

 

However the information where a chanel comes from is stored at each channel, so it is possible to figure out what groups to remove in a script.

 

Lets fill the portal with different data

Option Explicit

data.Root.Clear
' load two files
DataFileLoad ProgramDrv & "examples\Data\Crash.tdm"
DataFileLoad ProgramDrv & "examples\Data\DIESEL.tdm"
' create a group during processing
call data.root.ChannelGroups.Add("created").Channels.Add("Created",DataTypeFloat64) 

The following scrpt will remove groups that do not belong to the file of the first group

Option Explicit

call RemoveAllGroupsNotOfFile(Data.Root.ChannelGroups(1).Channels(1), false)

Sub RemoveAllGroupsNotOfFile(byRef refChnO, byval delNonLoaded)
  dim refFilePath : refFilePath = refChnO.Properties("sourcedatafilepath").Value & refChnO.Properties("sourcedatafilename").Value
  dim i : for i = data.Root.ChannelGroups.Count to 1 step -1
    dim grpO : set grpO = data.Root.ChannelGroups(i)
    if grpO.Channels.Count > 0 then
      dim grpFilePath : grpFilePath = grpO.Channels(1).Properties("sourcedatafilepath").Value & grpO.Channels(1).Properties("sourcedatafilename").Value
      if 0 <> strcomp(refFilePath, grpFilePath, VBTextCompare) then
        if "" <> grpFilePath or delNonLoaded then
          data.Root.ChannelGroups.Remove(i)
        end if
      end if
    end if
  Next
end sub

The second parameter is used to determine if generated data should also be removed.

 

P.S.: The behavior does not really differ from other programs but the default is different. DIAdem merges files automatically at load time instead of opening a second DIAdem instance while other applications will open a second instance if  new file is opened.

0 Kudos
Message 2 of 3
(2,564 Views)

Yeah that will do the job.  I already knew when I was asking the question that the answer wouldn't look like what I was used to, but rather would look something like this, with a for loop examining the parts and deciding which ones to eliminate.  Thanks.

0 Kudos
Message 3 of 3
(2,542 Views)