Adding Custom Metadata From Different Data Source Using Data Preparation

Updated Apr 3, 2024

Environment

Software

  • LabVIEW
  • DIAdem
  • SystemLink
  • SystemLink TDM DataFinder Module

Programming Language

  • LabVIEW G
  • Python
  • Visual Basic

Metadata is very important in a test and measurement workflow. Metadata is valuable because it helps identify, locate, and describe digital objects like files, images, videos, and websites.

Data Preparation is part of SystemLink. It helps to harmonize disparate raw data from various sources, file formats, units, and naming conventions to provide a consistent and comparable view of your test results in one source. 

This article will share how to create a data preparation instance using DIAdem and deploy to SystemLink. This will enrich your raw data file with metadata from different sources and save it as a pre-defined file format at user-desired location.

  1. Launch DIAdem.
  2. Click SCRIPT image.png
  3. Select Settings>>SystemLink TDM>>Data Preparation Procedureimage.png
  4. In the Configure Data Preparation Procedure pop up, click New Data Preparation Procedureimage.png
  5. In the newly shown New Data Preparation Procedure pop up, fill in the information accordingly and click OKimage.png
  6. In the Configure Data Preparation Procedure pop up, select V&V, enable Validation and Verification and click Edit. image.png
  7. Upon clicking the Edit button, DIAdem's SCRIPT should now displaying main_v&v.VBSPimage.png
  8. Comment line 27 as it is not needed in this case.
  9. Adding the following API to add custom properties:
    • Add a custom property into file
      • Call Data.Root.Properties.Add("File Custom Property Name", "File Custom Property Value")
        
    • Add a custom property into first channel group
      • Call Data.Root.ChannelGroups(1).Properties.Add("ChannelGroup Custom Property Name", "ChannelGroup Custom Property Value")
        
    • Add a custom property into first channel of first channel group
      • Call Data.Root.ChannelGroups(1).Channels(1).Properties.Add("Channel Custom Property Name", "Channel Custom Property Value")
  10. Click Test Data Preparation Procedure to verify performance of the script. image.png

These APIs can be used together with HTTP requests. This will ensure everytime when the data file is loaded, DataPlugin will retrieve the coresponded metadata from different data source and append into data portal.

Result below is obtained using DIAdem's default TDMS DataPlugin with the attached data file.

Add a custom property into file
  • Call Data.Root.Properties.Add("File Custom Property Name", "File Custom Property Value")
    
  • image.png
Add a custom property into first channel group
  • Call Data.Root.ChannelGroups(1).Properties.Add("ChannelGroup Custom Property Name", "ChannelGroup Custom Property Value")
    
  • image.png
Add a custom property into first channel of first channel group
  • Call Data.Root.ChannelGroups(1).Channels(1).Properties.Add("Channel Custom Property Name", "Channel Custom Property Value")
  • image.png

The following example retrieve Kuala Lumpur's datetime and add it as a custom property into file.
Option Explicit
 
Dim oRequest, res, oJsonParser, oVbsVariant
Set oRequest = CreateObject("MSXML2.ServerXMLHTTP.6.0")

Sub On_ValidationAndVerification(oContext)
 
  Call ApplicationSetLocale("english")
  
  res = sendRequest("get", "http://worldtimeapi.org/api/timezone/Asia/Kuala_Lumpur")

  Set oJsonParser = CreateJsonParser()
  Call oJsonParser.Deserialize(res, oVbsVariant)
  
  Call Data.Root.Properties.Add("KL Time", oVbsVariant.Item("datetime"))
  
End Sub
 
Function sendRequest(ByVal sType, byVal sUrl) 

  oRequest.open sType, sUrl, false 
  oRequest.setRequestHeader "Content-Type", "application/json" 
  oRequest.setRequestHeader "Accept", "application/json" 
  oRequest.setRequestHeader "User-Agent", "curl/7.50.1" 

  oRequest.send
  
  sendRequest = oRequest.responseText  
End Function
This is the outcome of the execution.
image.png

Attachments