DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Randomly Occurring DIAdem Script Error: No suitable channels specified

Solved!
Go to solution

Hello all,

 

I am using a DIAdem script I wrote to help me analyze a bunch of data files with strain gage data. I am using the script to calculate Maximum and Minimum Principal Strain from individual strain gage rosettes. All of my actual data files are quite large (2 to 4 Gigs), so I can't upload any of the data files, but I will include the relevant sections of my code. 

 

Synopsis of how the code works:

 

  1. Loads in a calculation set
  2. Runs the calculations on waveform grid strain channels and stores the max and min principal strains in new waveform channels
  3. Adds some new groups to organize the results of the rest of the code
  4. Adds a new channel in one of the new groups using channels.add()
  5. Copies the first 5 seconds of data from the first calculation set result waveform channel (max principal strain of first strain gage) using DataBlClpCopy()
    1. I know I can make DataBlClpCopy() perform this operation on a group of channels, but I was trying to get this to work on an individual channel before trying to work through through that process. I am not resistant to going through the process if it seems as though it will help with this problem.
  6. Pastes the copied data into the newly added (in step 4) channel using DataBlClpPaste()
  7. Performs statistics calcs using ChnStatisticsChannelCalc() and stores the results in new channels
  8. Moves and renames the stats calc results channels
  9. Repeats steps four through 8 for 4 channels
  10. Repeats steps 4 through 9 for the last five seconds of data
  11. Exports the stats calc results to an Excel workbook

And it all works just fine... Usually...

 

I can run this code all the way through one or more data sets without any issues. Then the next time I run it, the code will stop with an error stating that:  No suitable channels specified. (channel length 0, channel number 0 or too high)

This error occurs during the ChnStatisticsChannelCalc() line. For one of the calculations. I can then run the code again, and it will happen at a different instance of the ChnStatisticsChannelCalc(). Or, sometimes it will run all the way through with no error.

 

I thought that maybe the code was executing too fast and not giving the DataBlClpCopy() or DataBlClpPaste() commands time to finish. Also, I was curious if the problem was channel length 0 or if was a channel number problem, so I added a MsgBoxDisp() within an If.. Elseif... statement. It seems as though the problem is the channel length. 

 

Maybe the problem is with the clipboard? I tried putting some values in the new channel right after creating it with the thought that the paste command would overwrite it, but I never got that to work at all. 

 

Here is what I imagine is the offending section of code (I can supply more if requested, but since I am currently doing this for each gage, it is a bit long): 

Set SourceChannel = SourceGroup.Channels(22) 'This should be the maximum principal strain for Gage B2 after running the Max Min Prin Calcs.VBS Script with deleting wrong prins

Set DestChannel = PreSelDestGroup.Channels.Add("Max Prin Gage B2",DataTypechnfloat64) 'This is where the data I am copying from the calculated waveform channel will be stored

Call DataBlClpCopy(SourceChannel, 1, PreTestDataEnd) 'Copying from the waveform channel, starting at first row and ending 5 seconds, or 50001 samples, later

Call DataBlClpPaste(DestChannel, 1, 0,True) 'Pasting to the destination channel

PreSelDestGroup.Activate 'I put this here to see if it helps, spoiler alert: it doesn't...

if DestChannel.Size = 0 Then 'This conditional is for diagnosis of an intermittent error

  call MsgBoxDisp("It seems that " & DestChannel.Name & " is zero length. Try just clicking OK to see if that works", "MB_OK", "MsgTypeNote",,30)
  
Elseif DestChannel.Properties("number").Value = 0 Then

  call MsgBoxDisp("It seems that " & DestChannel.Name & " has zero for an index. Try just clicking OK to see if that works", "MB_OK", "MsgTypeNote",,30)
  
End If

Set ChnResult = ChnStatisticsChannelCalc(DestChannel, 120, 0, 0, False, True, False, "NameName") 'Getting the min, max, arithmetic mean, and RMS from the copied data and storing in individual numeric channels

'Channel moving and renaming of the stats results done here

 

The intermittent and seemingly random nature of this error is making me pull my hair out...

 

Thanks to those who take the time to read my novel.

 

Extra thanks in advance to anyone with help!

0 Kudos
Message 1 of 4
(1,420 Views)

Also, one more thing to add: 

Sometimes I can run the script and it will give me the error, then when I add a breakpoint after the DataBlClpCopy() and run in debug mode it works just fine...

0 Kudos
Message 2 of 4
(1,389 Views)
Solution
Accepted by topic author bpollock80

Hi bpollock80,

 

I do think removing the unnecessary dependency on the Windows Clipboard sounds like a great place to start.  The error you're getting doesn't sound like a clipboard error, but there's no reason to bother the Windows Clipboard if you want to move rows of values between channels in DIAdem-- here's the same sort of advice I just gave another Discussion Forum user:

 

https://forums.ni.com/t5/DIAdem/Split-Data-Into-Multiple-Channels-From-An-Event-Search/m-p/4148502#M...

 

What that error does sound like, as you mentioned, is either trying to calculate the statistical results of a channel with less than 2 data values in it, or perhaps a bad channel reference passed into the statistical calculation call.

 

Brad Turpin

Principal Technical Support Engineer

NI

Message 3 of 4
(1,292 Views)

Brad,

 

That seems to have done the trick. I ran a dozen files with the script modification you sent and it ran through every time. 

 

I replaced these lines of code: 

 Call DataBlClpCopy(SourceChannel, 1, PreTestDataEnd)

 Call DataBlClpPaste(DestChannel, 1, 0,True)

 with:

 Call DataBlCopy(SourceChannel, 1, PreTestDataEnd, DestChannel, 1)

 

Thanks for the help!

0 Kudos
Message 4 of 4
(1,286 Views)