DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Dataplugin Mapping seconds to 1904 to time channel

Solved!
Go to solution

Hi Group,

 

Working on a Dataplugin, (little rusty at this!)

Try to take a binary file, that has Seconds since 1904 in 64 bit real, and create a Time channel that shows the time in the data portal.

 

Input:

3522074457.314985

Output

8/15/2015 18:00:57.3150 when viewed in portal for time channel format.

 

Function that works just fine, but alas is not available as Dataplugin command!

dim oChn: set oChn = data.root.channelgroups(1).Channels("Time")

ChnNumericToTime(oChn,TTR("1904-01-01 00:00:00 ,0","yyyy-mm-dd hh:mm:ss,ffff",true)

 

What is not clear to me is how to do this conversion from input to output from a dataplugin environment.

 

Any help would be appreciated.

 

Thanks again,

 

Paul

0 Kudos
Message 1 of 4
(2,335 Views)

Note:

 

Am using DIAdem 2018, On Windows 7-64 machine.

Paul

0 Kudos
Message 2 of 4
(2,320 Views)

Hey Paul,

 

Not sure if you've seen the resources for making custom DataPlugins but I figured I'd include them just in case.

 

(Resources for Writing Your Own DataPlugin)

https://www.ni.com/en/support/downloads/dataplugins/resources-for-writing-your-own-dataplugin.html

 

If you have the function made but cannot see it in DIAdem, you might need to register the DataPlugin.

 

(Registering DataPlugins)

https://www.ni.com/docs/en-US/bundle/diadem/page/procshell/procshell/procshell_register_dataplugins....

 

0 Kudos
Message 3 of 4
(2,290 Views)
Solution
Accepted by topic author Pesmith8

The dataplugins allow you to set an offset on time channels starting with DIAdem 2015.

The given example will show the content of the plugin to use the offset.

I attached the file containing your double value.

 

Option Explicit

const SECONDS_1_JANUARY_1904 = 60084288000
const SECONDS_1_JANUARY_1970 = 62167132800
const SECONDS_1_JANUARY_1601 = 50522659200

Sub ReadStore(File)

  Dim Block : Set Block = File.GetBinaryBlock()
  ' Use direct access channel including offset for seconds
  Dim DirectAccessChannel : Set DirectAccessChannel = Block.Channels.Add("TimeChannelWithOffset", eR64)
  DirectAccessChannel.Factor = 1.0
  DirectAccessChannel.Offset = SECONDS_1_JANUARY_1904
  
  Dim ChannelGroup : Set ChannelGroup = Root.ChannelGroups.Add("group")
  dim channel : set channel = ChannelGroup.Channels.AddDirectAccessChannel(DirectAccessChannel)
  call channel.Properties.Add("displaytype", "Time")
End Sub
Message 4 of 4
(2,268 Views)