02-08-2017 12:17 PM
Hello
I have several a few data plugins that open data files with the same extension howvever they can only be used for a particular set of data.
I know how to use a script to load a particular piece of data with its corresponding plugin, however I want to know if there is a way to set which plugin DIadem uses when a manually drag / drop data from window explorer to the data portal.
To clarify
I know how to use the navigator Tab and then right click on the file I want to open and select "open with" which allows me to select the plugin I want.
I want to have the ability to simply drag and drop the data into the data portal and change the default plugin Diadem uses when I do this.
Thanks
02-09-2017 12:07 AM
Hello Tim,
There are ways to "attach" a DataPlugin to a specific type of file, even if you have multiple types data files that use the same extension.
You can add code to a DataPlugin that checks for a location of a file, and then uses a specific type of DataPlugin based on that code.
A DataPlugin can check for a part of a file or directory name to see if it is the "correct" DataPlugin for that file.
A DataPlugin can also look for something inside a file (a character, string, etc.) that will tell it if it is the "correct" DataPlugin for that type of data file.
It is also possible to have a single DataPlugin for the same type of file, and that single DataPlugin branches into the correct code based on the rule for the file.
How do you currently know which DataPlugin to use for a specific file? Is it based on the file location, part of the file name?
If you have a rule, that can be added to the DataPlugins you have and used to decide which one is the correct one or to branch into the correct sub-part of the DataPlugin if you have a single unified DataPlugin for all you different files.
NI should be able to help you once they have more information about your "rules".
02-09-2017 03:55 AM
Most file formats have some kind of magic string ... that can be used to check.
In dataplugins we have the ability to call
RaiseError
without a describing text to signal that this is not our file. (text is empty because you can not tell why it is not your file )
This can be used to do a precheck inside the VBS Dataplugins.
Option Explicit Sub ReadStore(File) CheckIfItIsMyFile(File) ' ??? some code end sub sub CheckIfItIsMyFile(byref File) dim oldPos : set oldPos = file.Position ' Example: The first line contains a specific TEST dim firstLineOfFile : firstLineOfFile = File.GetNextLine if 0 = instr(firstLineOfFile, "MY_FORMAT_IDENTIFIER", VBTextCompare) then ' Not found RaiseError ' this is none of my files. Maybe another plugin cares end if file.Position = oldPos ' set back file position to make sure loading behavior is not changed in ReadStore end sub
The above example shows a method call
CheckIfItIsMyFile(File)
that throws error by calling RaiseError if this precheck is not given.
It wouldd only accept files that contain
MY_FORMAT_IDENTIFIER
in the first line.
If you add those prechecks to your dataplugins DIAdem will try all those that registered for this extension till it reaches one that does not call RaiseError without text.
02-09-2017 05:48 AM
Guys thanks for the great responses.
My scripts are written such that the user selects the type of test and the script uses the appropriate plugin to open the file.
AndreasK - my plugins were developed using the wizard so I cannot add any code to them.
Looks like I will need to build a data plugin that handles all cases.
One final question
How does Diadem decide which plugin to use when I drag and drop a data file into the portal? Is it as simple as the last one added?
02-09-2017 11:04 AM
Ouch, you are right the wizard does not offer adding those lines.
During default load DIAdem just determines a list of plugins that registered for the extension.
Afterwards it start trying them till one does not say "NotMyFile".
There is no guaranteed order as far as I know.
-----------------
What is possible is using events to determine that something has been dragged and show a SUD that offers the different types.
It is a combination of
Call AddUserCommandToEvent("Navigator.Events.OnInteractionLoading","OnInteractionLoading_my") Call AddUserCommandToEvent("Navigator.Events.OnInteractionLoaded","OnInteractionLoaded_my") Call AddUserCommandToEvent("Navigator.Events.OnFileLoading","OnFileLoading_my")
that you need to determine that a file was dragged from Navigator and was not loaded via script.
06-29-2017 12:16 PM
Hello,
I've had some trouble with .csv files. I wanted to drag and drop my .csv with my Dataplugin instead of the built-in .csv loader.
To solve my problem, I opened 'My DataFinder' and selected the edit button. Under the DataPlugins tab, you can de-select the built-in CSV Dataplugin.
Thanks,
-Jim