08-10-2021 12:26 PM
Hi everyone,
I'm trying to extract metadata from a large volume of files, which I intend to use to create something like a diff log for channels, properties, and property values over this massive collection of files.
Right now, my best plan is to use CreateDataFileHeaderAccess to retrieve channel names; and for each channel, retrieve each property (at least the relevant ones) and the values thereof.
Unfortunately, I'm running into an issue when I try to write the value of the property "wf_start_time", which yields the error "Object doesn't support this property or method." I've confirmed that the property exists, and if the data is loaded into the Data Portal, then Data.Root.ChannelGroups(grp).Channels(chn).Properties("wf_start_time").Value returns the correct value without an error. Is there something about DataFileHeaderAccess that doesn't play nicely with this particular property, and if so, does a workaround exist?
Sample code:
Dim filePath
Dim dataFileHeaderAccess : Set dataFileHeaderAccess = CreateDataFileHeaderAccess
Dim dataStore : Set dataStore = dataFileHeaderAccess.Open(filePath, "TDMS", True)
Dim channel0 : Set channel0 = dataStore.RootElements(1).Children(grp).Children(chn)
Dim channelP : Set channelP = channel0.Properties
channelP.ListInstanceProperties = True
Dim i, oProp
i = 0
For Each oProp in channelP
i = i + 1
Call LogFileWrite(i & vbTab & oProp.Name & vbTab & oProp.Value)
Next
This code will execute until it tries to write the "wf_start_time" property value, at which time it will throw the error. Changing the LogFileWrite output (e.g. skip the step if oProp.Name = "wf_start_time") will execute the code without error - but the waveform start time is one of the properties that I'd like to have.
08-11-2021 04:16 AM
Hi AnscombesQuartet,
Yes this seems to be a bug. I will send this info to R&D.
Thank you and greetings
Walter
08-11-2021 08:29 AM
Thanks for checking. If it's useful, I'm using DIAdem 20.1.0f7908 SP1.
08-16-2021 04:47 AM
The Property<DataStore> API differs slightly in behavior from the Property<Data> API used for loaded data.
Option Explicit
Dim filePath : filePath = "C:\Users\Public\Documents\National Instruments\DIAdem 2021\Data\Example.tdms"
dim grp : grp = 2
dim chn : chn = 1
Dim dataFileHeaderAccess : Set dataFileHeaderAccess = CreateDataFileHeaderAccess
Dim dataStore : Set dataStore = dataFileHeaderAccess.Open(filePath, "TDMS", True)
Dim channel0 : Set channel0 = dataStore.RootElements(1).Children(grp).Children(chn)
Dim channelP : Set channelP = channel0.Properties
channelP.ListInstanceProperties = True
Dim i, oProp
i = 0
For Each oProp in channelP
i = i + 1
If IsObject(oProp.Value) Then
'Date/Time value
Call LogFileWrite(i & vbTab & oProp.Name & vbTab & oProp.Value.VariantDate)
else
'String, Float, or Integer value
Call LogFileWrite(i & vbTab & oProp.Name & vbTab & oProp.Value)
end if
Next
To solve your job you can think about using DIAdem Datafinder to do it and load the search result as channels.