From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
09-10-2019 10:03 AM
Hi, I am using Diadem 2018 and have the following need. I have a test that creates TDMS files every hour during a 11 hour cycle. We are running 24 cycles so I have 264 TDMS data files for this test. I would like to create a script that allows me to select the data files needed and pull out a particular data channel and time channel, append the channel data from all the TDMS files selected and show just the appended data channel and time channel in the Data Portal.
I have found code to select and get all the TDMS name and path. I then tried Call DataFileLoadSel(DataFiles(i),"TDMS","[1]/[34]","Append"). The help files makes it seem like this should work, but I keep getting errors when I run the script. It will load the first channel in the Data Portal, but the next one will give me a "Cannot Load file XXXX.tdms with the loader TDMS, Appending to internal data failed."
Can someone help with getting a script to do as described above or help with the DataFileLoadSel() function?
Thanks
Josh
09-11-2019 05:44 AM
Here are some DataFileLoadSel() examples that load a DIAdem example file that comes with the DIAdem installation (with my helping function sFilePathDIAdemExample()):
Load all channels from the first channel group
Call Data.Root.Clear()
Call DataFileLoadSel(sFilePathDIAdemExample("Example.tdm"),"TDM","[1]/*")
'Load the first & 4th channel in the first channel group
Call Data.Root.Clear()
Call DataFileLoadSel(sFilePathDIAdemExample("Example.tdm"),"TDM","[1]/[1]|[1]/[4]")
'Load the first & 4th channel in the first channel group
Call Data.Root.Clear()
Call DataFileLoadSel(sFilePathDIAdemExample("Example.tdm"),"TDM","[1]/[1]|EXAMPLE/Torque")
'Load the first, second, third, and 4th channel from the first channel group
Call Data.Root.Clear()
Call DataFileLoadSel(sFilePathDIAdemExample("Example.tdm"),"TDM","[1]/[1,2,3,4]")
Function sFilePathDIAdemExample(ByVal sFilename)
'Returns the full absolute file/path for the location of the DIAdem
'example (TDM/TDMS) file sFilename. Looks in the usual places.
'Returns "" if the file cannot be found.
sFilePathDIAdemExample = ""
Dim arrFilePaths, sFilePath, sFolder: ReDim arrFolders(1)
arrFolders(0) = ProgramDrv: arrFolders(1) = CommonDocumentsPath
Call MsgLineDisp("Searching DIAdem examples for file '" & sFilename & "'..")
For Each sFolder In arrFolders
arrFilePaths = DirListGet(sFolder,sFilename,"Date/Time","FullFilenamesRecursive")
If IsArray(arrFilePaths) Then
For Each sFilePath In arrFilePaths
If InStr(1,sFilePath,"Libr",vbTextCompare) = 0 Then
sFilePathDIAdemExample = sFilePath
Exit For
End If
Next
End If
If Len(sFilePathDIAdemExample) > 0 Then Exit For
Next
If IsArray(arrFilePaths) Then Call Erase(arrFilePaths)
If IsArray(arrFolders) Then Call Erase(arrFolders)
Call MsgLineDisp(vbTab)
End Function 'sFilePathDIAdemExample()
'----------------------------------------------------------------------------------------------
See also examples at: http://www.savvydiademsolutions.com/navigator.php?topic=DataFileLoadSel-specific-channels-by-group-i...
Regarding concatenation of channels, see:
Step #2 of this post: http://www.savvydiademsolutions.com/blog.php?topic=blog-duty-cycle-calculation
This free app: http://www.savvydiademsolutions.com/apps.php?topic=apps-bulk-concatenate
Contact me if you need a complete script solution. https://goo.gl/forms/ECjiuj2puIJPRWM13