06-08-2023 06:38 PM
Hello All,
Not sure how to approach this script. I have two channels (Chan1 & Chan2) of different lengths. Chan1 is longer than Chan2.
What I need to do is, create a new channel (let's call it Chan3) with the same length as Chan1. In Chan3, I need to keep repeating the data from Chan2 until the length of Chan3 is reached. The length of Chan1 and Chan2 will not always be the same, but Chan1 will always be longer than Chan2. So I need to do this programmatically.
I have attached some sample data which includes Chan1 and Chan2. In this data I have an example channel of what I need Chan3 to look like.
Thanks for any guidance.
06-12-2023 03:52 AM
Hi rvillalta319,
you can use the ChnConcat() function.
It should work like this:
Dim SourceChn, TargetChn, IndexChn
set IndexChn = Data.Root.ChannelGroups(1).Channels("Chan1")
set TargetChn = Data.Root.ChannelGroups(1).Channels.Add("Chan3",DataTypeChnFloat64)
set SourceChn = Data.Root.ChannelGroups(1).Channels("Chan2")
while TargetChn.Size < IndexChn.Size
call ChnConcat(SourceChn, TargetChn)
wend
TargetChn.Properties("length").Value = IndexChn.Size