Showing results for 
Search instead for 
Did you mean: 

read data from a Time type channel in a Data plugin



   I am having issue reading eTime format channel values in a data plugin. I am opening a TDMS file and trying to access values in the time channel. But it simply skips all the subsequent steps in the subroutine when it encounters a command like


A similar issue with eString channels was fixed by creating channel properties for each value in the channel and reading them out. But unfortunately the channels().Properties.Add command has NO parameter to pass the required data type. By default, it is the data type of the channel. Hence, for the Time channel, I am unable to read the channel values added as channel properties.

Is there a way to convert the data type of the eTime channel to eString?


Another issue is that inside a plugin, the Custom Root properties in the original (tdms) file cannot be accessed, as Store Elements can either by of group or channel type. Only Group and channel properties can be. How to access Root properties?



0 Kudos
Message 1 of 2

In case of TDMS the root is just the first DataStoreElement.

So it would be 

dim rootO : set rootO = FromStore.Children(1)

or just like in the attached example.


The time values are accessed using an usiTimeDisp object. So you can not assign them with '=' but you net to use set.

Check help for UsiTimeDisp object.


Example code:

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) 
      Call CreateChannels(StoreElement, TDMGroup) 
      ' tdms starts with root and there is only one of them
      dim timeVal : set timeVal = StoreElement.Properties("datetime").Value ' Object: UsiTimeDisp
      Call root.Properties.Add("root_timeProp", timeVal.VariantDate)
      if StoreElement.Properties.Exists("My_prop") then
        dim MyProp : myProp = StoreElement.Properties("My_prop").Value
      end if
      Call FindAndCreateGroups(StoreElement.Children) 
    End If 
End Sub 

Sub CreateChannels(StoreGroup, TDMGroup) 
  Dim StoreChannel ' Object: ElementWithValues <DataStore>
  For Each StoreChannel In StoreGroup.Channels
    if 30 = StoreChannel.DataType AND 0 <> StoreChannel.Size then ' 30 == DataTypeDate
      dim channelTimeVal : set channelTimeVal = StoreChannel.values(1)
      call TDMGroup.Properties.Add("channelTimeValue", channelTimeVal.VariantDate)
    end if
    Call TDMGroup.Channels.AddStoreChannel(StoreChannel) 
End Sub
0 Kudos
Message 2 of 2