Example 3: Binary File with Four Channels
- Updated2024-09-12
- 4 minute(s) read
DataPlugin > Examples > Example 3: Binary File with Four Channels
Example 3: Binary File with Four Channels
The following example shows you how to create a DataPlugin to read the binary file DataPluginExample3.ex3. This binary file contains the data from four channels.
Refer to DataPluginExample3.vbs to open the DataPlugin script file.
Data Format Description
The binary file contains four 32-bit integer channels. The file contains only channel data, no other information. The channel data is in blocks, which means that the first value from each channel is stored first, then the second value from each channel, and so on.
One value of one channel consists of the four bytes starting at the byte position
4*(channel index-1) + 16*(value index-1).
Configuring a DataPlugin
-
Select Settings»Extensions»DataPlugins in DIAdem NAVIGATOR.
-
Click Create DataPlugin to configure a new DataPlugin.
-
A dialog box opens where you can define the parameters for the new DataPlugin.
Enter the Name of the DataPlugin, for example, DataPluginExample3.
Below Filename Extensions, enter a list of file types that the DataPlugin can access, for example, *.ex3.Enter the filename, including the path and the filename extension, to specify the script that DIAdem uses to connect the DataPlugin, for example, DataPluginExample3.vbs. Click ... to specify the script in a file selection dialog box. If you enter the name of a script that does not exist, DIAdem generates the script.
Use Icon to specify the name, including the path and the filename extension, of the symbol file to which DIAdem links the DataPlugin, for example, DataPluginExample3.ico. Click ... to specify the symbol file in a file selection dialog box. -
Click OK.
-
The new DataPlugin is included in the list of DataPlugins. Close the dialog box.
![]() | Note You also can select Settings»Extensions»DataPlugins in DIAdem NAVIGATOR or in DIAdem SCRIPT to import, to export, to modify, or to delete an existing DataPlugin. |
You can now start programming the DataPlugin.
Creating the DataPlugin
-
Open the DataPluginExample3.vbs script in the script editor.
The script contains an example. USI uses the prepared procedure ReadStore to read the contents of the specified file File. The File parameter contains the opened file, which you selected in the DataFinder. -
Delete the contents of the ReadStore procedure until only the following lines remain:
Option Explicit Sub ReadStore(File) End Sub
Reading Binary Channel Values
-
In the procedure, create a BinaryBlock for reading out the file:
Dim Block : Set Block = File.GetBinaryBlock()
-
The file contains four channels with 32-bit integer values. Define the channels for the BinaryBlock accordingly.
Dim Channel1 : Set Channel1 = Block.Channels.Add("Channel1", eI32) Dim Channel2 : Set Channel2 = Block.Channels.Add("Channel2", eI32) Dim Channel3 : Set Channel3 = Block.Channels.Add("Channel3", eI32) Dim Channel4 : Set Channel4 = Block.Channels.Add("Channel4", eI32)
Providing the Information to USI
-
To make the four channels available to USI, complete the following steps.
In a DataPlugin, channels are assigned to a channel group and channel groups belong to a data set. First create a new channel group for the data set:
Dim ChannelGroup : Set ChannelGroup = Root.Channelgroups.Add("MyChannelGroup")
-
Then insert the channels into the channel group. Use DirectAccess channels to read the channel data directly from the file.
ChannelGroup.Channels.AddDirectAccessChannel(Channel1) ChannelGroup.Channels.AddDirectAccessChannel(Channel2) ChannelGroup.Channels.AddDirectAccessChannel(Channel3) ChannelGroup.Channels.AddDirectAccessChannel(Channel4)
-
Save the DataPlugin.
Making Additions to the DataFinder
-
Select Settings»DataFinders»Properties»DataPlugins in DIAdem NAVIGATOR and enable the DataPluginExample3 DataPlugin.
-
Click OK to close the dialog boxes.
In the DataFinder you now can navigate in the DataPluginExample3.ex3 file and drag and drop the channels into the DIAdem Data Portal.
Exporting the DataPlugin
You can export the DataPlugin as an URI file (USI Registration File), to make it accessible for other users.
-
Select Settings»Extensions»DataPlugins in DIAdem NAVIGATOR and select the DatapluginExample3 DataPlugin.
-
Click Export.
-
In the dialog box that opens, enter the name and the path of the URI file to be generated.
Installing the DataPlugin on Another Computer
You can use a URI-file DataPlugin on another computer.
-
Copy the URI file to the computer.
-
Open Windows Explorer and double-click the URI file.
The DataPlugin is installed and appears on the list of DataPlugins. In the DataFinder you now can access the files for which this DataPlugin was created.
Overview of the Methods and Properties Used
File.GetBinaryBlock
BinaryBlock.Channels
DirectAccessChannels.Add
Root.Channelgroups
Channelgroups.Add
Channelgroup.Channels
Channels.AddDirectAccessChannel