DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Visual Basic (.vbsd) Data Plugin. Is it possible to change Group Name?

Solved!
Go to solution

I am working on a custom Data Plugin, that should import a file by using another DataPlugin, then make some adjustments (more specifically, add some meta-tag, change group names).

 

I was able to add the meta-tags I needed, but apparently I cannot modify group names.

 

Some notes on the plugin configuration (see also the attached picture)

  • Plugin compatible with USI 20.0
  • File reader: Filename only

Below you can find the basic structure of my script. I anticipate that I know some functionalities are not available in .vbsd files, but I was hoping it would be possible to load a file by using another plugin, and then perform operations such as group name updates.

I also tried to replace Root with Data.Root, but it doesn't work either.

 

Do you think there is a way to have those names updated?

 


 

Sub ReadStore(MyFile)

  

  ' Import File

  Call Root.ImportStore(MyFile, "MDF3") ' It works

 

  ' Add Meta-tags

  Call Root.Properties.Add("TagName", "TagValue") ' It works

 

  ' Rename Group

  Root.ChannelGroups(1).Name = Root.ChannelGroups(1).Properties("description").Value ' Not working

 

End Sub

 


 

Mdf_Metadata.png

 

0 Kudos
Message 1 of 3
(1,480 Views)
Solution
Accepted by topic author panta1978

Hi panta,

 

When I'm creating a post-processing DataPlugin that uses another DataPlugin to parse the file, I always re-create the desired hierarchy fresh from the Root object and just assign the properties and channel values from each corresponding "StoreObject", like this:

 

 

Sub ReadStore(Store)
  Dim StoreRoot, StoreGroup, Group
  Set StoreRoot = Store.Children(1)
  Call Root.Properties.AddProperties(StoreRoot.Properties)
  FOR Each StoreGroup In StoreRoot.Children
    Set Group = Root.ChannelGroups.Add(StoreGroup.Name)
    Call Group.Properties.AddProperties(StoreGroup.Properties)
    Call CreateChannels(StoreGroup, Group) 
  NEXT ' StoreGroup
End Sub


Sub CreateChannels(StoreGroup, Group)
  Dim StoreChannel, Channel
  FOR Each StoreChannel In StoreGroup.Channels
    Set Channel = Group.Channels.AddStoreChannel(StoreChannel)
  NEXT
End Sub

 

 

In the above example, I using the StoreGroup.Name property to name the corresponding Root.ChannelGroup, but that would be your opportunity to name the Root.ChannelGroup something different-- at the moment you create it.

 

Brad Turpin

Principal Technical Support Engineer

NI

0 Kudos
Message 2 of 3
(1,422 Views)

Hi Brad,

 

That is brilliant! Exactly what I was looking for. I've just checked and it works! Thanks a lot, with your advice I can make the activity I'm about to carry out way easier and more efficient!

0 Kudos
Message 3 of 3
(1,409 Views)