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: 

"Concatenating" Channels?

Hi,
 
I am using DIAdem 10.0.  I need to load several data sets into the data portal (each data set will be in one group).  Each data set has the same (or similar) channels.  For example, a simplified list of my channels:
 
Group1/ChannelA
Group2/ChannelA
Group3/ChannelA
...
GroupN/ChannelA
 
I need to "combine" all of the similar channels (ChannelA in my example) into one channel (CombChannelA) so I can create 3D graphs.  Is there a quick way to do this?  This is what I have been doing, and it is kind of slow:
 
 
 ChannelNameToCombine
  NewChnLength = 0
  NewChnName = "(Joint) " & ChannelNameToCombine
 
  ChnGroupArr = Split(ChnGroupStr, ", ")
  ChnArr = Split(ChnStr, ", ")
  For k = 0 To UBound(ChnGroupArr) - 1
    NewChnLength = NewChnLength + ChnLength(ChnGroupArr(k) & "/" & ChnArr(k))
  Next ' i
  Call GetCreateChannel(GroupIndexGet("Combined Channels"), NewChnName, NewChnLength)
  Row = 1
  For k = 0 To UBound(ChnGroupArr) - 1
     For l = 1 To ChnLength(ChnGroupArr(k) & "/" & ChnArr(k))
        ChDX(Row, CNo("Combined Channels/" & NewChnName)) = ChDX(l, CNo(ChnGroupArr(k) & "/" & ChnArr(k)))
        Row = Row + 1
      Next ' l
  Next ' k
0 Kudos
Message 1 of 4
(3,400 Views)
Sorry, I didn't finish: 
 
  ' I am looping through all data in the poral to get ChnGroupStr and ChnStr
  ChnGroupStr = "1, 2, 3, 4, 5"
  ChnStr = "ChannelA, ChannelA, ChannelA, ChannelA, ChannelA"
 
  ChannelNameToCombine = "ChannelA"
  NewChnLength = 0
  NewChnName = "(Joint) " & ChannelNameToCombine
 
  ChnGroupArr = Split(ChnGroupStr, ", ")
  ChnArr = Split(ChnStr, ", ")
  For k = 0 To UBound(ChnGroupArr) - 1
    NewChnLength = NewChnLength + ChnLength(ChnGroupArr(k) & "/" & ChnArr(k))
  Next ' i
  Call GetCreateChannel(GroupIndexGet("Combined Channels"), NewChnName, NewChnLength)
  Row = 1
  For k = 0 To UBound(ChnGroupArr) - 1
     For l = 1 To ChnLength(ChnGroupArr(k) & "/" & ChnArr(k))
        ChDX(Row, CNo("Combined Channels/" & NewChnName)) = ChDX(l, CNo(ChnGroupArr(k) & "/" & ChnArr(k)))
        Row = Row + 1
      Next ' l
  Next ' k
0 Kudos
Message 2 of 4
(3,396 Views)

Hello Julia,

please see "ChnConcat". This function concatenates two channels and should do what you are looking for. Its definitely much faster than copying all teh channels value by value.

Andreas

0 Kudos
Message 3 of 4
(3,384 Views)

Hi Julia,

This is a common use-case.  Check out the following Example Program on the ni web:

http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=C34F36CBFA7173C3E034080020E74861&p_...

Make sure you choose the "_91_" version, which is more robust, more full-featured, and faster (but will only run on DIAdem 9.1 or later).  If you are loading TDM files, just use the "Binary_Files" version and type in "TDM" for the DataPlugin name in the VBScript.

Ask if you have further questions,
Brad Turpin
DIAdem Product Support Engineer
National Intruments

0 Kudos
Message 4 of 4
(3,361 Views)