Using Vbscript to Create Dataplugin and Load Data File With It in DIAdem

Updated May 7, 2024

Environment

Software

  • DIAdem

DataPlugin help to import and read data with unique format into DIAdem. This documents explains how to create, use and export a simple DataPlugin in DIAdem.

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
  1. Start DIAdem, from the NAVIGATOR tab, open DataPlugin Settings windows by selecting Settings> Extensions> DataPlugins.
  2. Click Add VBS DataPlugin.

dataplgin1.PNG
  1. 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.)
dataplgin2.PNG
  1. Click OK to complete the DataPlugin creation.
Edit the DataPlugin Script
  1. To edit the created DataPlugin script, right-click on the DataPlugin name and select Edit Script.
  2. Click Close to close the DataPlugin setting window
dataplgin3.PNG

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.

  1. 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
  1. In DIAdem's NAVIGATOR, navigate to the Dataplugin, right-click DataPluginExample1.ex1 and select Open with.
  2. Click Load.
dataplgin4.PNG

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 = "." )

dataplgin5_6.PNG

Next Steps

Follow the steps below to export the created DataPlugin and install it in another environment.
  1. From DIAdem's NAVIGATOR tab, select Settings> Extensions> DataPlugins.
  2. From the DataPlugin Settings window, select the DataPlugin you want to install in another environment and Click Export DataPlugin. 
  3. Select the location to save the exported DataPlugin (*.uri)file and save the file.

dataplgin72.PNG
  1. In another environment, Copy and regisrster this *.uri file. Double-clicking on the DataPlugin *.uri file will automatically install and register it on another environemnt. After registration, this Dataplugin can be used as shown in previous steps to load data in DIAdem.