DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

plugin argument

Solved!
Go to solution

Is there some way to send info to a plugin (an argument)?

 

I'd like to select some options on a GUI and have this affect how the plugin imports data. I can do it afterwards, but I think the process would be simpler and quicker if the plugin did it.

 

thanks,

James

0 Kudos
Message 1 of 16
(6,365 Views)

Hi James,

 

Some C++ DataPlugins have built-in parameterizations, such as the "CSV" or "HDF5" DataPlugins.  For such cases you can pass name/value parameters when calling the DataPlugin in this way:

 

DataFilePath = "D:\Test.hdf5"
FileParameters = FileParameters & "<filename>"  & DataFilePath  & "</filename>"
FileParameters = FileParameters & "<statistics>true</statistics>"
Call DataFileLoad(FileParameters, "HDF5")

I hear you saying that you want to use those parameters in a VBScript DataPlugin, though, and I don't know how to do that.  The best I can offer is to programmatically create an ASCII or XML file with the parameters in it, then pass that parameter file path to the DataPlugin.  The DataPlugin can branch based on the file extension it sees in File.Info.Extension and first read the parameter file (which contains the data file path as one of the parameters), then opens up a DataFile object with:

 

Set DataFile = OpenFile(DataFilePath)

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 16
(6,331 Views)

Thanks Brad,

Do you have any documentation on how the C++ plugin accesses the parameters?

Also a code clip from the C++ plugin accessing the parameter would be great. Maybe it could be converted to VBscript?

 

I don't think I have any documentation on C++ plugins. Converting the VBscript plugin to C++ might be an option also. Does the DIAdem editor need a different setup to support C++ coding?

 

I don't really like the idea of creating a file containing the arguments. Seems like more work than necessary. I may attempt that if the C++ method doesn't work.

 

thanks,

James

0 Kudos
Message 3 of 16
(6,309 Views)

Hi JDeckert,

 

It isn't possible to see or edit the source code of C++ DataPlugins, so it would be pretty difficult to get you a code clip.  I'm also not aware of any way to create or edit C++ DataPlugins in the DIAdem Scrip Editor.

 

How Do I Edit a URI file in DIAdem?: http://digital.ni.com/public.nsf/allkb/26BE90A19ACF0B7D862575D10071A345

 

However, if you only have a couple of options for the user to select, another way you could to this would be to create multiple VBS DataPlugins and have your GUI select the correct one based on the user's input.  This may be easier than trying to pass the parameters into the DataPlugin itself.

 

Thanks,

 

Myriam

0 Kudos
Message 4 of 16
(6,278 Views)
Solution
Accepted by topic author JDeckert

Hi JDeckert,

 

I talked to R&D about this, and it turns out that DataPlugins created with DIAdem 2014 or later (USI 14.0), there is a way to pass parameters to the VBscript code, but this is brand new.  Here's an example of how to call the DataPlugin, very similar to what I already shared with you for a C++ DataPlugin.

 

Call Data.Root.Clear
DataFilePath = "C:\Users\bradt\Documents\LabVIEW Data\New Data File.tdms"
Params = "<filename readonly='yes'>" & DataFilePath & "</filename>"
Params = Params & "<ParName1>ParValue1</ParName1>"
Params = Params & "<ParName2>ParValue2</ParName2>"
Params = Params & "<ParName3>ParValue3</ParName3>"
Call DataFileLoad(Params, "DataPluginName")

 You don't have to use XML after the filename part, if you prefer you could use delimiters for the Split() statement:

 

Call Data.Root.Clear
DataFilePath = "C:\Users\bradt\Documents\LabVIEW Data\New Data File.tdms"
Params = "<filename readonly='yes'>" & DataFilePath & "</filename>"
Params = Params & "|ParValue1|ParValue2|ParValue3"
Call DataFileLoad(Params, "DataPluginName")

 Whatever you pass in the Params variable will be available in the DataPlugin from the new global ConnectParameter variable.

 

Sub ReadStore(File) 
  Call Root.ChannelGroups.Add(File.Info.FileName)
  Root.Properties.Add "Description", ConnectParameter
End Sub

Remember, this only works if the DataPlugin is using USI 14.0 or later.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 5 of 16
(6,246 Views)

Brad,

Great timing. On Monday I got the ok at work to use 2014 and on Tuesday you solve my issue.

 

FWIW: the pipe character is somehow special. I think DIAdem expects more filenames after the pipe.

However, colon, equals, comma, semicolon all work in addition to xml, so I'm off to see if this solves my challenge.

 

thanks,

James

0 Kudos
Message 6 of 16
(6,220 Views)

Where does the USI version reside?

When testing on a new plugin the ConnectParameter worked.

Now that I'm trying to use it in an older plugin it is undefined.

So what do I need to do to make this plugin use USI 14.0?

0 Kudos
Message 7 of 16
(6,177 Views)

Hi JDeckert,

 

The USi version for a DataPlugin is editable in that DataPlugin's Advanced Properties, seen in the dialog screenshot below:

 

Image1.png

 

This is usually important when you want the DataPlugin you create in a newer DIAdem version to run on older DIAdem versions-- in that case you have to set the USI version to an older one.

 

You have to click on that little circular button,

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 8 of 16
(6,175 Views)

Hi Brad,

 

I have tried to use your method to pass argument to DataPlugin but it was not successful.

Following error message: 

Cannot load the file "\\Server\Unit01\MW_PV.hst" with the loader "HST_SelectiveLoading_HV". 

Further information:
"Either the function ReadStore could not be found or it does not accept 1 arguments."

 

Here is the code I use to call DataPlugin:

Dim DataFilePath
DataFilePath = "\\Server\Unit01\MW_PV.hst"
Dim Params
Params = "<filename readonly='yes'>" & DataFilePath & "</filename>"
Params = Params & "|10|1"
Call DataFileLoad(Params, "HST_SelectiveLoading_HV")

 

I tried different one but still failed:

Dim DataFilePath
DataFilePath = "\\Server\Unit01\MW_PV.hst"
Dim Params
Params = "<filename readonly='yes'>" & DataFilePath & "</filename>"
Params = Params & "<nWeekFromNow>10</nWeekFromNow>"
Params = Params & "<nWeekLoading>1</nWeekLoading>" Call DataFileLoad(Params, "HST_SelectiveLoading_HV")

 

The plugin "HST_SelectiveLoading_HV" is as following and used for *.hst files.

Sub ReadStore(File, nWeekFromNow, nWeekLoading)
...
end sub

My DataPlugin is set to be compatible with USI 17.0 and I am using DIAdem 2017.

If I remove parameters from Dataplugin, the code works perfectly fine. 

 

Thank you

 

 

0 Kudos
Message 9 of 16
(3,356 Views)

Please stay with the XML version (not sure if syntax errors will be ignored).

 

The functions is always:

Sub ReadStore(File) 
  dim paramString : paramString = ConnectParameter
  ' paramString will now contain the xml string you have to parse it on your own
End Sub

Adding parameters to the connection string does not change the ReadStore method

0 Kudos
Message 10 of 16
(3,346 Views)