04-16-2021 11:28 AM
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:
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!
Solved! Go to Solution.
04-16-2021 12:59 PM
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...
05-06-2021 03:42 PM
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:
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
05-06-2021 04:13 PM
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!