09-26-2016 07:01 PM - edited 09-26-2016 07:02 PM
When reading in a .DAT file produced by a data aquistion system, the group pulls in "DataSetComment001.." with metadata stored by the aquisition software.
Is there a way to change the title of these lines? I'd prefer to be able to change these to the actual descriptor, for instance, instead of having "DataSetComment001: JHU/APL" I'd like it to read, "Lab Name: JHU/APL"
Being able to script this would be most helpful.
Thanks,
Tamer
09-27-2016 01:45 AM
You could Create a so called PluginPlugin.
You see the following line that copies all properties
Call TDMGroup.Properties.AddProperties(StoreElement.Properties)
Now you can replace it by
dim groupProp : for each groupProp in StoreElement.Properties select case groupProp.Name case "DataSetComment001" TDMGroup.Properties.Add "LabName", groupProp.Value case "DataSetComment002" TDMGroup.Properties.Add "my_author", groupProp.Value case else on error resume next TDMGroup.Properties.Add groupProp.Name, groupProp.Value on error goto 0 end select Next
where you can map some properties to your needs.
If you can figure out if a file is not of your kind please insert an
RaiseError
to avoid all dat files to be proccessed.
It is also possible to do this in DIAdem itself.
The advantage of this aproach is that you can use NI Datfinder to search for files from "LabName"="JHU/APL"
09-27-2016 11:04 AM
Thanks for the response, my script that's autopopulated doesn't have the Call TDMGroup line that you specified, this is what I have:
Sub ReadStore(File) 'Tell the file how the string data is formed. File.Formatter.Delimiters = ";" File.Formatter.LineFeeds = vbNewLine 'Create a file accessor Dim Block : Set Block = File.GetStringBlock() Dim DirectAccessChannel : Set DirectAccessChannel = Block.Channels.Add("FileData", eString) 'Provide the data to USI Root.Properties.Add "datetime", Now Dim ChannelGroup : Set ChannelGroup = Root.ChannelGroups.Add("MyChannelGroup1") Dim ImplicitChannel : Set ImplicitChannel = ChannelGroup.Channels.AddImplicitChannel("ValueIndex", 1, 1, DirectAccessChannel.Size(), eI32) ChannelGroup.Channels.AddDirectAccessChannel(DirectAccessChannel) End Sub
09-28-2016 07:01 AM
When you create the plugin you need to extend the dialog using the >> button.
Then you can choose the file reader. This will generate a different script.
09-28-2016 11:35 AM
See the screenshots for my process. I'm still getting the same script I posted above.
09-29-2016 02:27 AM
If your plugin already exxists, tthe vbs will not be regenerated.
The following code does only work with an selected filereader plugin.
Option Explicit Sub ReadStore(FromStore) Call FindAndCreateGroups(FromStore.Children) End Sub Sub FindAndCreateGroups(StoreElements) Dim StoreElement Dim TDMGroup For Each StoreElement in StoreElements If StoreElement.IsKindOf(eStoreChannelGroup) Then Set TDMGroup = Root.ChannelGroups.Add(StoreElement.Name) 'Call TDMGroup.Properties.AddProperties(StoreElement.Properties) dim groupProp : for each groupProp in StoreElement.Properties select case groupProp.Name case "DataSetComment001" TDMGroup.Properties.Add "my_desc", groupProp.Value case "DataSetComment002" TDMGroup.Properties.Add "my_author", groupProp.Value case else on error resume next TDMGroup.Properties.Add groupProp.Name, groupProp.Value on error goto 0 end select Next Call CreateChannels(StoreElement, TDMGroup) Else Call FindAndCreateGroups(StoreElement.Children) End If Next End Sub Sub CreateChannels(StoreGroup, TDMGroup) Dim StoreChannel For Each StoreChannel In StoreGroup.Channels Call TDMGroup.Channels.AddStoreChannel(StoreChannel) Next End Sub