DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Loading single Channels from File

Solved!
Go to solution

Hello,

 

I created a User Dialog where it is possible to create Presets of Channels (XML File with Group Names and Channel Names) that have to be loaded.

 

This is necessary because we have a lot of channels (~1000) but only e.g. 25 are needed for the report. What channels are needed depends on the report that has to be created, therefore the presets.

 

So I go through the XML file and load the channel one by one with the DataFileLoadSel command. This isn't very fast but it works. The problem is that when I load a channel this way, I have to recreate the group structure and root file including all properties (of the groups and root).

 

Creating the groups is not an issue, but recreating the properties is.

 

Is there any way to load only certain channels with loading the corresponding groups (wiht properties) and the root file?

 

Cheers

Michael

0 Kudos
Message 1 of 5
(2,750 Views)
Solution
Accepted by topic author M1chael5

Hi Michael,

 

I suggest you register load each entire Group-- that will take little time and will import the Group properties.  Then you can programmatically expand the selected channels and remove the channels that don't get expanded.  Here's an example script that uses the "Example" data file that ships with DIAdem:

OPTION Explicit
Dim i, j, iMax, jMax, LoadGroups, LoadChannels, DataFilePath, DelGroup, Groups, Channels, Group, Channel
Call AddLoadGroups(LoadGroups, Array("EXAMPLE", "Time", "Torque"))
Call AddLoadGroups(LoadGroups, Array("Noise data", "Noise_2", "Noise_4", "Noise_5"))
Call AddLoadGroups(LoadGroups, Array("Room Temperatures", "Temperature_3"))
DataFilePath = ProgramDrv & "Examples\Data\Example_data.tdm"
Call Data.Root.Clear
Set DelGroup = Data.Root.ChannelGroups.Add("DeleteMe")
iMax = UBound(LoadGroups)
FOR i = 1 TO iMax
  LoadChannels = LoadGroups(i)
  jMax = UBound(LoadChannels)
  Set Groups = DataFileLoadSel(DataFilePath, "TDM", LoadChannels(0) & "/*", "Register")
  IF Groups.Count = 1 THEN
    Set Group = Groups(1)
    Set Channels = Data.CreateElementList()
    FOR j = 1 TO jMax
      IF Group.Channels.Exists(LoadChannels(j)) THEN
        Set Channel = Group.Channels(LoadChannels(j))
        Call Channels.Add(Channel)
      END IF
    NEXT ' j
    Call ChnValExpand(Channels)
    Set Channels = Data.CreateElementList()
    FOR Each Channel In Group.Channels
      IF Channel.Properties("status").Value = "readonly" THEN Call Channels.Add(Channel)
    NEXT ' j
    IF Channels.Count > 0 THEN Call Data.Remove(Channels)
  END IF ' Group loaded
NEXT ' i, LoadGroup
Call Data.Root.ChannelGroups.Remove(DelGroup.Name)


Sub AddLoadGroups(LoadGroups, LoadChannels)
  Dim i
  IF NOT IsArray(LoadGroups) THEN ReDim LoadGroups(0)
  i = UBound(LoadGroups) + 1
  ReDim Preserve LoadGroups(i)
  LoadGroups(i) = LoadChannels
End Sub ' AddLoadGroups()

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 5
(2,730 Views)

Hello Brad,

I finally got some time to test your approach. It works really nice. Thank you.

 

Is it somehow possible to acces meta data on file lvl without loading the whole file? I would like to recreate the meta information in the root file.

 

Cheers

Michael

0 Kudos
Message 3 of 5
(2,696 Views)
Solution
Accepted by topic author M1chael5

Hey Micheal,

 

I found a function that should fit your needs.

CreateDataFileHeaderAccess

I hope that helps you.

 

Chris

0 Kudos
Message 4 of 5
(2,681 Views)

Thanks for your help. That was exactly what I needed.

Message 5 of 5
(2,626 Views)