Download DataPlugin_Examples.zip attached at the bottom of this document.
This folder contains DataPlugin Script file DataPluginExample1.vbs, and DataPluginExample1.ex1, which is the data to be loaded using DataPlugin.
Create a DataPlugin
- Start DIAdem, from the NAVIGATOR tab, open DataPlugin Settings windows by selecting Settings> Extensions> DataPlugins.
- Click Add VBS DataPlugin.
- On the New DataPlugin settings window, set the Name of the DataPlugin, the File extension of the data to be loaded, and other necessary Extended settings (select the minimum compatible USI version that allows you to install this DataPlugin. Since DataPlugin is executed by USI, the default USI version will be the same version as the USI version of the environment where DataPlugin was created. But setting the minimum compatible USI version allows your Dataplugin to be used in an environment older than the USI version of development environment.)
- Click OK to complete the DataPlugin creation.
Edit the DataPlugin Script
- To edit the created DataPlugin script, right-click on the DataPlugin name and select Edit Script.
- Click Close to close the DataPlugin setting window
After clicking on
Edit script (step 5 above), a .vbs script will be opened on DIAdem's
SCRIPT tab with the below default content.
Edit the script to reflet and describe how to read data using this DataPlugin. This example uses the contents of DataPluginExample1.vbs.
- Replace the above default script with the one below and save.
Option Explicit
Sub ReadStore(File)
'Provide the file object with information about the file format
File.Formatter.LineFeeds = vbNewLine
File.Formatter.IgnoreEmptyLines = true
File.Formatter.TrimCharacters = ""
File.Formatter.Delimiters = ";"
File.Formatter.ThousandSeparator = "."
'Read the name of the source out of the first line of the file.
Dim TitleValue: TitleValue = File.GetNextStringValue (eString)
Call Root.Properties.Add ("Name", TitleValue)
'Read the description of the implicit channel out of the second line of the file.
File.SkipLine ()'Advance to the next line.
Dim ChannelName: ChannelName = File.GetNextStringValue (eString)
Dim StartValue: StartValue = File.GetNextStringValue (eI32)
Dim Increment: Increment = File.GetNextStringValue (eI32)
Dim ChannelSize: ChannelSize = File.GetNextStringValue (eI32)
'Create the implicit channel.
Dim ChannelGroup: Set ChannelGroup = Root.ChannelGroups.Add ("MyChnGroup")
Call ChannelGroup.Channels.AddImplicitChannel (ChannelName, StartValue, Increment, ChannelSize, eI32)
'Read the root's properties out of the file
File.Formatter.Delimiters = ":"'Properties and their values are seperated by a ":"
Dim PropertyName, PropertyValue
While (File.Position <> File.Size)
File.SkipLine ()'Advance to the next line.
PropertyName = File.GetNextStringValue (eString)
PropertyValue = File.GetNextStringValue (eString)
'Create the property on the root of the plugin.
Call Root.Properties.Add (PropertyName, PropertyValue)
Wend
End Sub
Load data using the DataPlugin
- In DIAdem's NAVIGATOR, navigate to the Dataplugin, right-click DataPluginExample1.ex1 and select Open with.
- Click Load.
Data should display in the
Data Portal as below(DIAdem's
VIEW tab).
DataPluginExample1.ex1 content can also be checked in Notepad. It can be noted that the notation method (German notation method) using commas(;) separator is converted in DIAdem with "." separator. (This convertion is processed in the DataPlugin script with the line: File.Formatter.ThousandSeparator = "." )