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.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Script to an .URI File

I have the set of Data attached and I was trying to incorperate the Script below into my URI file so I can have it done for me on the import.  My issue is I need the Channel "Queue_Time" to show up as a Time Channel only.  I have tried to import the channel as a Time Channel however it does not show up correct and in turn messes with the rest of my Data calculations.  What I need from the channel is just the Time portion alone.  Running this below gets me what I need but like I said I would like to incorperate it into my URI so the load takes care of it. 

 

 

Any help is always appriciated.

 

 

Dim Group
Set Group = Data.Root.ActiveChannelGroup
Call StringChanToDateChan(Group, "Queue_Time")

Sub StringChanToDateChan(Group, ChanName)
  Dim DateStrgChannel, DateTimeChannel, Formula, Variables, ChanRefs
  Set DateStrgChannel = Group.Channels(ChanName) : DateStrgChannel.Name = ChanName & "-DateStr"
  Set DateTimeChannel = Group.Channels.Add(ChanName, DataTypeDate)
  Formula = "DateTime = CDate(DateStr)"
  Variables = Array("DateTime", "DateStr")
  ChanRefs  = Array(DateTimeChannel, DateStrgChannel)
  Call Calculate(Formula, Variables, ChanRefs)
  Call Group.Channels.Remove(DateStrgChannel.Name)
  Call Data.Move(DateTimeChannel, Group.Channels,6) ' number at the end is the index it moves it to.
  Call ChnRenumber
End Sub ' StringChanToDateChan()

Download All
0 Kudos
Message 1 of 7
(6,017 Views)

Hi,

 

First, you can't attach code like that to the dataplugin. They only include dataplugin source code. They run once and don't run anything extra after they finish. If you could, I don't believe it would run when you wanted it to anyway. However, there may be other options based on your application. How big are the data files? Rows? Columns? If they are too large, we may have to see about splitting it up somehow. Also, which version of DIAdem are you using?

Jason H
Automated Test Software R&D
0 Kudos
Message 2 of 7
(5,983 Views)
I am running up to 8000 rows of data and about 12 to 15 channels. I am running 2012 sp1
0 Kudos
Message 3 of 7
(5,976 Views)
Since the only way to do this is after the data is already loaded, I think the fastest way to do what you want is to assign that script to a Function Group. That way, as soon as you pull the data in, you can hit the key combination and it will sort the data appropriately. I'm attaching some documentation on that for your convenience.
 
Jason H
Automated Test Software R&D
0 Kudos
Message 4 of 7
(5,951 Views)

Hey J,

 

You actually haven't posted any data files yet.  Would you please?  It may still be possible to push this functionality into the DataPlugin used to load the data file.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 7
(5,904 Views)

Hello,

 

Here is the data that I am using. 

 

Thanks - J

0 Kudos
Message 6 of 7
(5,846 Views)

Hi J,

 

It looks to me like you can do the time formatting in the DataPlugin just fine.  Interestingly, the Call_Start_Time and Call_End_Time channels are configured in Excel as datetime columns and all the rest of the datetime columns are configured as strings.  The attached DataPlugin converts all rows of those other datetime columns from strings to datetime.

 

Also, the kind of data you have here is what is called "record-based" data, meaning that the row affiliations are stronger than the column affiliations.  Typically with this type of data you want to load selected rows from one or more files for analysis and reporting.  I constructed this DataPlugin to support that scenario, but you'll need to index the files you want to use first and run a query to extract the desired rows.

 

Ask as you have questions,

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 7 of 7
(5,766 Views)