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: 

Split channel data according to date

Hello!

 

I have 4 channels in a single channel group. one of the channels is a date/time channel with 3 minute intervals between each row, over about 80 days.

 

I would like to split the date/time channel into 24 hour periods with each period being the next day and with each period going into a new channel.

When that happens I would like the data in the other 3 channels to be cut off and put into new channels wherever the date channel is cut off.

 

Thanks,

 

Ariel

0 Kudos
Message 1 of 3
(5,058 Views)

Hi,

I don't know your data structure exactly, but this might help:

 

dim i, length, loops
length = cl("[1]/[1]")
loops = length/480
for i = 1 to loops

  Call Data.Root.ChannelGroups.Add("day_" & i, i+1).Activate()
  Call Data.Root.ChannelGroups(i+1).Channels.Add("Channel",DataTypeFloat64,1)
  Call Data.Root.ChannelGroups(i+1).Channels.Add("Channel1",DataTypeFloat64,2)
  Call Data.Root.ChannelGroups(i+1).Channels.Add("Channel2",DataTypeFloat64,3)
  Call Data.Root.ChannelGroups(i+1).Channels.Add("Channel3",DataTypeFloat64,4)
  Call DataBlCopy("'[1]/[1]' - '[1]/[4]'",480*(i-1)+1, 480,"'["&i+1&"]/Channel' - '["&i+1&"]/Channel3'",1)
next

 

Regards

Simyfren

0 Kudos
Message 2 of 3
(5,052 Views)

PS:
the magic number 480 means that you need 480 rows for one day.

Simyfren

0 Kudos
Message 3 of 3
(5,051 Views)