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: 

Getting error trying to write values to channels in a dataplugin

I have a VBScript plugin. 
 
I'm getting an error trying to write data to channels that are formatted as eString or eTime. Attached is the error popup in MSE. I'm not sure what the issue is. I also tryed forcing type to other types (CStr, etc) and get other errors.
 
Attached are the error popup and MSE debug panel pics
 
I first created all my channels and saved arrays of the object references. I parsed all my data and now want to fill the empty channels with the data. The channel creation is working because they all show up in the portal if I don't try and write channel data.
 
I have an object to the channel and I'm using obj.Values correctly I think. You can see I'm trying to write the string  text="1" to the first channel object.
 
eString and eTime are enums so I don't think I can force the data to those types directly.
Download All
0 Kudos
Message 1 of 7
(3,699 Views)
Ok. I have some of this figured out for text channel, but my issue is still with time channels.
 
If my channel is formatted as eTime, how do I coerce data to that type to add the data to the channel
 
I've tried:
 
CDbl ( error mismatch type 30 and VT_8)
CSgl ( error mismatch type 30 and VT_4)
CInt  ( Overflow)
 
If I use eR64 the channel add data works properly but my channel data is no longer in DateTime format.
 
Do I have to write the channel data in eR64 then somehow change the channel format?  
0 Kudos
Message 2 of 7
(3,688 Views)
I resolved this by writing the data to the channel as eR64, then changing the channel display format to time using , channelObj.Properties.Add("displaytype","time")
0 Kudos
Message 3 of 7
(3,674 Views)

Hi jsmalley,

Are you assigning your channels values one by one in the DataPlugin with Root.ChannelGroups(1).Channels(1).Values(i) = CDbl(ValueVariable), or are you using a String or Binary Block and a DirectAccessChannel?  It is possible to assign individual CDate(ValueVariable) values to a channel in the DataPlugin.  It is also possible to assign a string block of DirectAccessChannel values as native datetime values, but it is not possible to assign a binary block of DirectAccessChannel values as native datetime values-- for that you have to go the eR64 route that you have discovered.

Brad Turpin
Product Support Engineer
National Instruments

0 Kudos
Message 4 of 7
(3,658 Views)
Assigning one-by-one with channel.value object. The only thing that worked for me was to use eR64 and change the channel property to display it as time. I guess I don't really understand the eTime datatype and how to use it 
0 Kudos
Message 5 of 7
(3,654 Views)

Hi jsmalley,

You have two native ways of getting a scaler datetime object in a DataPlugin, which you can then assign to an "eTime" channel value by value.  If you are reading in a datetime string (01/05/1999 12:23 am), then you can use the following syntax:

Set DateValue = File.Formatter.ParseString(StringValue, eTime)

If, alternatively, you are individually reading out the components of the datetime value (Years, Months, Days, Hours, Minutes, Seconds, Milliseconds), then you can use the following syntax:

Set DateValue = CreateTime(Years, Months, Days, Hours, Minutes, Seconds, Milliseconds, Microseconds, Nanoseconds)

In both cases you would assign the datetime value normally, though you have to use the "Set" syntax since you're assigning an object:

Set Root.ChannelGroups(1).Channels(1).Values(1) = DateValue

One footnote here, it is not very efficient to assign channel content value by value.  Is there a compelling reason you're not using Blocks and DirectAccessChannels?  Also, it's just fine to declare the channel as eR64 and tweak the display format property to be "Time"-- the one drawback with that is that LabVIEW and CVI and MeasurementStudio will not (yet) recognize that channel as a datetime channel, only DIAdem and Excel will.

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 6 of 7
(3,644 Views)
Hi Brad.
 
For this particular plugin, I have to decrypt information from the file before storing it in channels. The examples that I have seen for using Block and direct access channels seem to be for file to channel transfer directly to take advantage of it properly.
0 Kudos
Message 7 of 7
(3,641 Views)