DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

loading a *.bin file with script

I've created a script file that goes out to my desktop and finds a specific .bin file, loads it, manipulates it, and then graphs certain things.  What I need to do know is have this script file go to my desktop and allow me to select ANY .bin file and load it, manipulate it, and graph it.  All of the .bin files i want to load are all the same data format, but we will be changing the names of them so we don't overwrite the previous file. 
I just can't figure out a way to do this.  The "Call FileNameGet" command doesn't seem to work. 
 
Thanks in advance for all the help!
 
Matt
0 Kudos
Message 1 of 11
(4,958 Views)
Hi Matt,

try this syntax:
filenameget "ANY", "FileRead", ,"*.bin"
unless you dont plan to select more than one file at the same time, it should work all right. If you would like to do the latter, for instance to create a list file for a batsch processing (serial evaluation) you would further need top specify a listfile name with the parameter FileDlgASCIIName.
Another possibility to create a list of all *.bin files at a certain path would be the command DirLstWrite.

Hope this helps.
Ingo Schumacher
Systems Engineering Manager CEERNational Instruments Germany
0 Kudos
Message 2 of 11
(4,937 Views)
Matt,
 
if you are using DIAdem 9.1, it's probably more convenient to move the script into a DataPlugin. This may require some changes to the script, but once its done, DIAdem support your speciic file format like it supports TDM and DAT files. Please refer to www.ni.com/dataplugins for more information on DataPlugins and how to create them.
 
Please aks if you have questions.
 
Andreas
0 Kudos
Message 3 of 11
(4,934 Views)

Thanks guys for the input.  Adreas, how would I go about linking mulitple file names to a dataplugin?  I seem to be only able to write a script that links a particular file to a dataplugin.

 

0 Kudos
Message 4 of 11
(4,891 Views)

Matt,

There are several functions/variables which are helpful when dealing with more than a single file. The single file which is already opened for you by the DataPlugin framework is the file the user selected. You can open any additional number of files using "OpenFile" which returns a file object. Please refer to the helpfile for DataPlugin development for more details.

In addition there are attributes attached to the file object you get from "ReadStore(File)". Please refer to File.Info.FullPath to see an example. Those attributes can be helpful when the name of the file you want to open is derived from the name of the file the user had selected.

Let me know if you have more questions

Andreas

0 Kudos
Message 5 of 11
(4,889 Views)

Andreas,  I've attached my files below.  The slamraam_telemetry_version1 file organizes the binary data into channels.  The hex_conv file is the file i run that does certain actions on specific channels.  The second line in the Hex_conv was created using the record feature.  So i used this record feature to create a dataplugin that is linked to slamraam_telemetry_Version1.  Then i loaded data from slamraam -- telemetry.bin. This was all done using the record feature. 

Anyway, i'm still having trouble getting the Hex_conv file to let me select ANY .bin file, not just the slamraam -- telemetry.bin file.  Thanks for all the help. 

 

Matt

Download All
0 Kudos
Message 6 of 11
(4,878 Views)

Matt,

I think I know what the problem is. Could you please do me a favour and send me one or more of your .bin files so that I can test the whole script sequence?

Andreas

0 Kudos
Message 7 of 11
(4,875 Views)
Andreas, here's a .bin file that should work.  Thanks again for all the help!
0 Kudos
Message 8 of 11
(4,866 Views)
Matt,
 
Thanks for sending the files. Here is one possible solution for your project :
In your script hex_conv Instead of
 Call DATADELALL(1)                      '... HEADERDEL 
 Call STORAGEIMPORT("<?xml version=""1.0"" encoding=""UTF-16""?>....
please use
 Call filenameget("ANY", "FileRead",,"Telemetry data (*.bin),*.bin", ,,,"Please select a telemetry file")
 Call DATADELALL(1)                      '... HEADERDEL 
 Call DATAFILELOAD(FileDlgDir&FileDlgFile&FileDlgExt,"Telemetry","")
"Filenameget" is a file selection box which allows you to select a file. The resulting filename is given in FileDlgDir&FileDlgFile&FileDlgExt. Please refer to the OLH for filenameget for more details.
Once you have the filename, please use DataFileLoad to load the data with you plugin. DataFileLoad is an alternative to StorageImport and uses a much more convenient syntax.
One thing you need to change in the code above is "Telemetry" to the name you have chosen for your plugin. From what I understand, your plugin has the default name "DataPlugin". If so, please replace "Telemetry" with "Dataplugin"
 
Looking into the script of teh DataPlugin I was wondering whether it would make sense to change
  Set Group = Root.ChannelGroups.Add(File.Info.FullPath) 'Create a channel group in USI
Message 9 of 11
(4,863 Views)
Matt,
 
Thanks for sending the files. Here is one possible solution for your project :
In your script hex_conv Instead of
 Call DATADELALL(1)                      '... HEADERDEL 
 Call STORAGEIMPORT("<?xml version=""1.0"" encoding=""UTF-16""?>....
please use
 Call filenameget("ANY", "FileRead",,"Telemetry data (*.bin),*.bin", ,,,"Please select a telemetry file")
 Call DATADELALL(1)                      '... HEADERDEL 
 Call DATAFILELOAD(FileDlgDir&FileDlgFile&FileDlgExt,"Telemetry","")
"Filenameget" is a file selection box which allows you to select a file. The resulting filename is given in FileDlgDir&FileDlgFile&FileDlgExt. Please refer to the OLH for filenameget for more details.
Once you have the filename, please use DataFileLoad to load the data with you plugin. DataFileLoad is an alternative to StorageImport and uses a much more convenient syntax.
One thing you need to change in the code above is "Telemetry" to the name you have chosen for your plugin. From what I understand, your plugin has the default name "DataPlugin". If so, please replace "Telemetry" with "Dataplugin"
 
Looking into the script of teh DataPlugin I was wondering whether it would make sense to change
  Set Group = Root.ChannelGroups.Add(File.Info.FullPath) 'Create a channel group in USI
To
  Set Group = Root.ChannelGroups.Add(File.Info.FileName)
 
This creates a group with the name of the file, without path and extension. Sometime this is sufficient information to distinguish the group and most of the time is better to handle.
 
if you like, you can change
 
  FOR i = 1 TO UBound(Channel)
    Call Group.Channels.AddDirectAccessChannel(Channel(i))
  NEXT ' i

To
 
  FOR i = 1 TO UBound(Channel)
    If ( LCase(Left(Channel(i).Name,6)) <> "unused" ) Then
      Call Group.Channels.AddDirectAccessChannel(Channel(i))
    End If
  NEXT ' i
With that you would ignore the placeholder channels in the import
 
Hope this helps
 
Andreas
Message 10 of 11
(4,864 Views)