NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
Radek_Codr
Posts: 16
0 Kudos
Accepted Solution

How can I register channels imported using DataFileLoad function in DIAdem 2012?

Hallo,

 

I would like to import data from Excel into the DIAdem 2012.

I newly use DataFileLoad and ufi file to define import plugin.

But when I want to copy a the imported channels to another group, I get err: The Channel argument of the AddChannel method must be IChannel.

 

How can I register/convert/refersh channels, so I can work with them?

 

I'm showing code sample I took from standard example collection, from: "Loading Excel Files with a DataPlugin", script file A_172132_ExcelDataPlugin.vbs

Note: to get to worky my example you have to set proprely used paths

 

If Not ItemInfoGet("sPathDocuments") Then
  Call GlobalDim("sPathDocuments")
  Call GlobalDim("sPathData")
End If
sPathDocuments = CurrentScriptPath
sPathData      = CurrentScriptPath & "..\Data\"
call PrepareAndLoadDataset

sub PrepareAndLoadDataset()
  Call Data.Root.Clear()
  If  Not FileFilterExist("A_172132_Example") Then
    Call Navigator.RegisterDataPlugin(sPathDocuments&"A_172132_Example.uri",True)
  End If
  
  set MyGroup = DataFileLoad(sPathData & "A_172132.xlsx", "A_172132_Example","") 
  set MyTemp = Data.Root.ChannelGroups.Add("temp")
  Call MyTemp.Channels.AddChannel(MyGroup.Item(1).ChannelGroups(1).Channels(1))
end sub

 

Thank you for advance.

 

Radek

Active Participant
Walter_Rick
Posts: 972
0 Kudos

Re: How can I register channels imported using DataFileLoad function in DIAdem 2012?

Hello Codr,

 

Your script works fine on with my DIAdem 2012. I just defined "Dim MyGroup, MyTemp"

The result is a new channel group with one channel. The channel is the first channel of the first group of the loaded dataset.

 

In case you would like to register the Excel file (and not load it) you need toexpand the copied channel. This looks like this:

 

sub PrepareAndLoadDataset()
  Call Data.Root.Clear()
  If  Not FileFilterExist("A_172132_Example") Then
    Call Navigator.RegisterDataPlugin(sPathDocuments&"A_172132_Example.uri",True)
  End If
  
  dim MyGroup, MyTemp, oChn
  set MyGroup = DataFileLoad(sPathData & "A_172132.xlsx", "A_172132_Example","Register") 
  set MyTemp = Data.Root.ChannelGroups.Add("temp")
  set oChn = MyTemp.Channels.AddChannel(MyGroup.Item(1).ChannelGroups(1).Channels(1))
  call ChnValExpand(oChn)
end sub

 

Greetings

Walter

Member
Radek_Codr
Posts: 16
0 Kudos

Re: How can I register channels imported using DataFileLoad function in DIAdem 2012?

I tied to register exel file, and used your code, but it doesn't help, I'm still geting same error mesage.

Member
Radek_Codr
Posts: 16
0 Kudos

Re: How can I register channels imported using DataFileLoad function in DIAdem 2012?

 

To working around this problem I'm defining a new group:

  dim MyGroup, MyTemp, NewGroup, oChn
  set MyGroup = DataFileLoad(sPathData & "A_172132.xlsx", "A_172132_Example") 
  set NewGroup = Data.Root.ChannelGroups(MyGroup.Item(1).ChannelGroups(1).Name)
  set MyTemp = Data.Root.ChannelGroups.Add("temp")
  set oChn = MyTemp.Channels.AddChannel(NewGroup.Channels(1))

 
This method but does not come to be very elegant to me.

Member
GPeter
Posts: 20
0 Kudos

Re: How can I register channels imported using DataFileLoad function in DIAdem 2012?

Hi,

 

Have you tried the "Register" import action parameter in the DataFileLoad command?

 set MyGroup = DataFileLoad(sPathData & "A_172132.xlsx", "A_172132_Example","Register")
Member
Radek_Codr
Posts: 16
0 Kudos

Re: How can I register channels imported using DataFileLoad function in DIAdem 2012?

I actually want to convert imported exel file to IChannel rather, than to register exel file to DIAdem.

But yes I tried both possibilities, with same result.

Member
Radek_Codr
Posts: 16
0 Kudos

Re: How can I register channels imported using DataFileLoad function in DIAdem 2012?

I find out, that this problem I get, when I run the script in debug mode.

 

In run mode it works correctly.

 

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page