NI Home > Community > NI Discussion Forums

DIAdem

Showing results for 
Search instead for 
Do you mean 
Reply
Member
SethRow187
Posts: 21
0 Kudos

Manipulating dataplugin script files to add channel names, units, etc?

I have an ascii data file that I want to create a dataplugin for.  The data file has a unique file extension.  The file only contains raw data (i.e. no column headers).  I can go through the dataplugin wizard and create a dataplugin for this file extension, however when I bring in the data it just names the channels "Noname" and there isn't a place in the wizard to name the channels or specify the units.
 
I know that it's possible to go into the vbs script file for the particular data plugin and edit it, however I am not very well versed in VBS script.  Does anyone know what I would have to modify in this script to specify the channel names and units without having to modify the raw data file to include column headers?  Thanks!
Trusted Enthusiast
Brad_Turpin
Posts: 2,907
0 Kudos

Re: Manipulating dataplugin script files to add channel names, units, etc?

Hi SethRow187,

You can edit the DataPlugin created by the DataPlugin Wizard, but it's not obvious where to do that as the auto-generated code is long and difficult to read, since it has to be ready to handle any posisble format permutation that the DataPlugin Wizard covers.

If you look on line 259 or thereabouts, you should find a line of code that reads:

ChannelNames = Array()

If you change this line to declare your static channel names, then save the edited DataPlugin script, your DataPlugin will load the data files with the correct channel names:

ChannelNames = Array("Time", "Speed", "Revs", "Torque")

But this doesn't help you with the units, and I believe the simplest way to get what you want would be for you to send me an example data file and let me create a quick 15 line DataPlugin that uses the right channel names and units.  This would be a lot easier for you to understand.  You'll also have to tell me what the correct channel names and unit strings are for each column in the data file.

Brad Turpin
DIAdem Product Support Engineer
National Instruments

Member
SethRow187
Posts: 21
0 Kudos

Re: Manipulating dataplugin script files to add channel names, units, etc?

Brad-

Here is an example data file.

The channel names are:  Timestamp, Voltage, Current, Inlet Temp, Exit Temp, Air Flow Rate, Air Flow Rate1, H2 Flow Rate, H2 Consumption, Power, Total Run Time, Cycle Count, Start-Stop Data Filter

The units are:  Seconds, Volts, Amps, C, C, LPM, Stoics, LPM, %, Watts, Hours, Cycles, Binary

Thanks!

(FYI, the file extension I want is .tsd, however it would not let me post the file with this extension, so I had to change it to .txt)

Trusted Enthusiast
Brad_Turpin
Posts: 2,907
0 Kudos

Re: Manipulating dataplugin script files to add channel names, units, etc?

Hi SethRow187,

The file you sent has a header line with the ChannelName(ChannelUnit) information for each column.  Does this really exist in your data files?  If so, then there's no point in using static channel names and channel units, I can parse the correct information from the first line of each file.  Let me know, I'll get everything else knocked out and will be waiting on your reply to finish.  If the data files really don't have that first header line, or they sometimes do and sometimes don't, then I'll need to have the hardcoded names and units in the DataPlugin after all.

Brad Turpin
DIAdem Product Support Engineer
National Instuments

Member
SethRow187
Posts: 21
0 Kudos

Re: Manipulating dataplugin script files to add channel names, units, etc?

For this particular data file type the header appears in the file as you see it, however we have other file types that don't always have headers, or the headers are cryptic to the end user and we would manually overwrite them when they are imported anyways.  If I could have a data plugin script created that hardcodes the names and units (or any other property) I was hoping that I would be able to use it as a template to create plugins for the other file types we have.
Trusted Enthusiast
Brad_Turpin
Posts: 2,907
0 Kudos

Re: Manipulating dataplugin script files to add channel names, units, etc?

Hi SethRow187,

Well, the real DataPlugin itself only took 15 lines, but the way I chose to hardcode the static channel names and units took another 20 lines.  Anyway, this should be much easier to read than the boiler-plate code the DataPlugin Wizard spits out.  Also, the alignment looks much better in SCRIPT than it does in an internet browser-- just copy this code over your existing DataPlugin code and save the changed VBScript file.  Note that I assumed that your timestamp was the number of seconds since 1900 (Excel's timestamp).  The offset for the first channel adds the number of seconds from 0 AD (DIAdem's timestamp) to 1900 to each value in that channel, the "displaytype" property tells DIAdem to display this number of seconds as a timestamp.

Let me know if you have questions,
Brad Turpin
DIAdem Product Support Engineer
National Instruments

 

OPTION EXPLICIT

Sub ReadStore(File)
  Dim i, Block, Group, Channel, ChanNames, ChanUnits
  File.Formatter.Delimiters = vbTAB
  File.Formatter.LineFeeds = vbCRLF
  Call GetHdrInfo(ChanNames, ChanUnits)
  Set Group = Root.ChannelGroups.Add(File.Info.FileName)
  Set Block = File.GetStringBlock()
  FOR i = 1 TO UBound(ChanNames)
    Set Channel = Block.Channels.Add(ChanNames(i), eR64)
    Channel.Properties.Add "unit_string", ChanUnits(i)
    IF i = 1 THEN
      Channel.Offset = 3600*24*693958
      Channel.Properties.Add "displaytype", "Time"
    END IF
    Call Group.Channels.AddDirectAccessChannel(Channel)
  NEXT ' i
End Sub


Sub GetHdrInfo(ChanNames, ChanUnits)
  Dim i, iMax
  iMax = 14
  ReDim ChanNames(iMax)
  ReDim ChanUnits(iMax)
  i = i + 1 : ChanNames(i) = "Timestamp"      : ChanUnits(i) = "Sec"
  i = i + 1 : ChanNames(i) = "Voltage"        : ChanUnits(i) = "Volts"
  i = i + 1 : ChanNames(i) = "Current"        : ChanUnits(i) = "Amps"
  i = i + 1 : ChanNames(i) = "Input Temp"     : ChanUnits(i) = "C"
  i = i + 1 : ChanNames(i) = "Exit Temp"      : ChanUnits(i) = "C"
  i = i + 1 : ChanNames(i) = "Air Flow Rate"  : ChanUnits(i) = "SLPM"
  i = i + 1 : ChanNames(i) = "Air Flow Rate"  : ChanUnits(i) = "Stoics"
  i = i + 1 : ChanNames(i) = "H2 Flow Rate"   : ChanUnits(i) = "SLPM"
  i = i + 1 : ChanNames(i) = "H2 Consumption" : ChanUnits(i) = "%"
  i = i + 1 : ChanNames(i) = "Power"          : ChanUnits(i) = "Watts"
  i = i + 1 : ChanNames(i) = "Total Run Time" : ChanUnits(i) = "Hrs"
  i = i + 1 : ChanNames(i) = "Cycle Count"
  i = i + 1 : ChanNames(i) = "Start/Stop Data Filter"
  i = i + 1 : ChanNames(i) = "Comments"
End Sub ' GetHdrInfo()

 

Member
SethRow187
Posts: 21
0 Kudos

Re: Manipulating dataplugin script files to add channel names, units, etc?

Thanks Brad.  This is great, and much easier to work with.  I will play around with it and let you know if I have any questions.
Member
SethRow187
Posts: 21
0 Kudos

Re: Manipulating dataplugin script files to add channel names, units, etc?

One more thing.  The timestamp is actually the labview generated timestamp (which I believe is based on the year 1904?).  Do you know what offset I should build in for this?  Thanks.
Trusted Enthusiast
Brad_Turpin
Posts: 2,907
0 Kudos

Re: Manipulating dataplugin script files to add channel names, units, etc?

The offset in seconds for LabVIEW datetime values should be 60084288000
Member
Stagsden
Posts: 33
0 Kudos

Re: Manipulating dataplugin script files to add channel names, units, etc?

Dear Brad,

 

I am having similar problems with my data. I just need to get the header line incorporated into the channel names.

Would you be able to generate a dataplugin to read the following data?

I only have the one line, but it is dificult to undertsand the VBS script.

 

I also cannot get rid off the << symbol next to the time data.

The data files produced do not have an extension usually, therefore I added txt just to be able to send it.

Thanks

Stagsden