DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a date and a time to create one channel in a data plugin

Solved!
Go to solution

I would like to preface this question with the fact that I am new to VBS programming.  What I want to do is create a plugin. Most of it is done but I am having a problem with adding two times to make one.  I have a text file that stores the date and time separated by a tab.  This file format was design for excel.  When I bring it in both the date and time are in different channels and I can't figure out a way to add the two and either replace one of them or even place it into a separate variable.  Below is an example. 

Chan(1) contains the date, Chan (2) contains the time.  This statement that places the data into the channel is:     

Set StandChannels(0).Values(k) = Chan(1).Values(i)

 

I have tried:

Set StandChannels(0).Values(k) = Chan(1).Values(i)+Chan(2).Values(i)

error: Object doesn't support this property or method

or

Chan(1).Values(i) = Chan(1).Values(i)+Chan(2).Values(i)

error: Object doesn't support this property or method

 

I have tried many other iterations and have not had any success.  This seems to be an easy task I am probably missing something simple.

0 Kudos
Message 1 of 6
(4,626 Views)

Hi Eli_A,

 

I was wanting to get more information. Would it be possible to post a sample data set so that we could see the format? What is the data type for the StandChannels object?

 

Thank you!

Chris T.
0 Kudos
Message 2 of 6
(4,583 Views)

Hi Eli_A,

 

You need to add a "ProcessedChannel" to the Group and assign the DateChannel and the TimeChannel DirectAccessChannels to it instead of to the Group, like this:

 

Set DateTimeChannel = Group.Channels.AddProcessedChannel("DateTime", eTime, eAddProcessor)
Set DateChannel = Block.Channels.Add("Date", eTime)
Set TimeChannel = Block.Channels.Add("Time", eTime)
Call DateTimeChannel.Channels.Add(DateChannel)
Call DateTimeChannel.Channels.Add(TimeChannel) 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 3 of 6
(4,570 Views)

Chris and Brad,

 

Sorry I didn't respond sooner.  I tried the suggestion on the code and it made sense seeing it but I could not get it to work within the code.  I am enclosing the code and the file.  I would like to explain that the plugin is currently design to accept two different file versions.  I have sent you the newer file version.  I received an initial plugin from a coworker that I believe came from NI and which accounts for the frame work and I modified it a great deal to get it to this point.  I appreciate your help; it has been somewhat frustrating not completely understanding the different types of channels, how to access the information needed, and finding examples of what I wanted done.

 

Elias

0 Kudos
Message 4 of 6
(4,549 Views)
Solution
Accepted by topic author Eli_A

Hi Elias,

 

The first problem was that your datetime format string was wrong, you needed to use:

File.Formatter.TimeFormat = "MM/DD/YY hh:mm:ss.fff"

 Or perhaps if your year is first it should be:

File.Formatter.TimeFormat = "YY/MM/DD hh:mm:ss.fff"

The second issue was slipperier.  The NewGroups(0) that you throw away was combining the ProcessedChannel values correctly, but you weren't succeeding in picking off the ones you wanted from Chan(0).  I'm actually not sure why the method you were using didn't work, but I found a similar one that does.  Note that I only made the changes in the SUB New_File(File, ChanNames) part of the code, not the SUB Previous_File(File, ChanNames) part of the code (got tired of typing).

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

 

Message 5 of 6
(4,542 Views)

Brad,

 

Thanks, the solution was exactly what I was looking for.  I am kind of glad that I was not the only one that had problems with the second part.  I appreciate the help with this issue.

 

Elias

0 Kudos
Message 6 of 6
(4,522 Views)