DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

DataSetCommentXXX

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

0 Kudos
Message 1 of 6
(3,481 Views)

You could Create a so called PluginPlugin.

 

  • Settings->options->Extensions->Dataplugins
  • Create a new and name it your way
  • Pick *.dat as extension
  • Pick Dataplugin (DAT) as filereader in the extended dialog
  • Create the plugin
  • Right click and edit the script

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"

 

0 Kudos
Message 2 of 6
(3,460 Views)

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
0 Kudos
Message 3 of 6
(3,445 Views)

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.

  • Pick Dataplugin (DAT) as filereader in the extended dialog
0 Kudos
Message 4 of 6
(3,425 Views)

See the screenshots for my process. I'm still getting the same script I posted above.

Download All
0 Kudos
Message 5 of 6
(3,415 Views)

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
0 Kudos
Message 6 of 6
(3,399 Views)