‎04-09-2014 04:26 PM
I am working on a script that will process through around 2000 files. The script initially loads a file with a pressure and integrated torque channel. It then opens up each tdms file in a directory, strips uneseccary data before and after the torque spike (100 ft lb) then takes the average pressure, and integrates the torque curve. Each of these data points are added to the approriate channels.
I am attempting to run this code on a subset of 15 files. When I do I receive the following error at the end of the code. I am unsure what this error is or how to fix it.
Dim MyFolders() Call InitMyFolders '------------------------------------------------------------------------------- Sub InitMyFolders ReDim MyFolders(2) MyFolders(0)="C:\Users\mk43238\Documents\Test Data\5510 Grow\Graphs\" MyFolders(1)="C:\Users\mk43238\Documents\Test Data\5510 Grow" End Sub '------------------------------------------------------------------------------- Dim Pressure Dim IntegratedTorque Call Data.Root.Clear() Call Data.Root.ChannelGroups.Add("Calculated Data", 1).Activate() Call Data.Root.ChannelGroups(1).Channels.Add("Pressure",DataTypeFloat64,1) Call Data.Root.ChannelGroups(1).Channels.Add("Integrated Torque",DataTypeFloat64,2) Set Pressure = Data.Root.ChannelGroups(1).Channels(1) Set IntegratedTorque = Data.Root.ChannelGroups(1).Channels(2) Dim aFoundFiles Dim iCount, G100, L100 aFoundFiles= Dirlistget( MyFolders(0),"*.tdms","filename","onlyFilenames") If IsArray(aFoundFiles) Then For iCount= Lbound(aFoundFIles) to Ubound(aFoundFiles) Call DataFileLoad(MyFolders(0) & aFoundFiles(iCount)&".tdms","TDMS","") G100 = ChnFind("Ch(""[2]/Input Torque"")>100") L100 = ChnFind("Ch(""[2]/Input Torque"")<100",G100) If G100>0 Then If L100>0 Then Call DataBlDel("'[2]/Input Torque', '[2]/Rev Clu PSI'",1,G100,1) Call DataBlDel("'[2]/Input Torque', '[2]/Rev Clu PSI'",L100,GlobChnLength-L100,1) StatSel(1) = "No" StatSel(2) = "No" StatSel(3) = "No" StatSel(4) = "No" StatSel(5) = "No" StatSel(6) = "Yes" StatSel(7) = "No" StatSel(8) = "No" StatSel(9) = "No" StatSel(10) = "No" StatSel(11) = "No" StatSel(12) = "No" StatSel(13) = "No" StatSel(14) = "No" StatSel(15) = "No" StatSel(16) = "No" StatSel(17) = "No" StatSel(18) = "No" StatSel(19) = "No" StatSel(20) = "No" StatSel(21) = "No" StatSel(22) = "No" StatSel(23) = "No" StatClipCopy = 0 StatClipValue = 0 StatFormat = "" StatResChn = 1 StatResChnNames = 0 StatResChnNameFormat= "NameName" Call StatBlockCalc("Channel","1-","[2]/Rev Clu PSI") Call ChnIntegrate("","[2]/Input Torque","/Integrated") Pressure(iCount+1) = Data.Root.ChannelGroups(2).Channels("ArithmeticMean").Properties("maximum").Value IntegratedTorque(iCount+1) = Data.Root.ChannelGroups(2).Channels("Integrated").Properties("maximum").Value End If End If Call Data.Root.ChannelGroups.Remove(2) Next End If Call DataFileSave(MyFolders(1)&"5510 Grow.TDM","TDM")
‎04-10-2014 02:03 PM
Hi MK17,
I modified your code slightly so that I could run it on my machine, but was unable to reproduce the error you are seeing. I have a few more questions that may help point us in the right direction:
1) Which OS are you running this application on?
2) Have you ever been able to successfully run this application? If so, what has changed since then?
3) In DIAdem, go to Help >> Examples and try running an example script to see if you receive the same error.
4) Can you restart your program and run this script without opening any programs other than DIAdem to see if you receive the same error?
5) Have you been able to reproduce this same error on any other machines?
6) Would you be able to attach a couple sample data files?
Regards,
‎04-10-2014 02:04 PM
Hi MK,
I'm not entirely sure what's causing the problem, but I have created a simplified version of your script, and I also deleted values from the end of the channels first and from the beginning second, and I used the size of the channel, not the GlobChnLength variable (important) to calculate the number of values to delete.
Dim MyFolders() Call InitMyFolders '------------------------------------------------------------------------------- Sub InitMyFolders ReDim MyFolders(2) MyFolders(0)="C:\Users\mk43238\Documents\Test Data\5510 Grow\Graphs\" MyFolders(1)="C:\Users\mk43238\Documents\Test Data\5510 Grow" End Sub '------------------------------------------------------------------------------- Dim CalcGroup, CalcPressure, CalcIntegrated Dim RawGroup, RawPressure, RawTorque, RawIntegrated Call Data.Root.Clear() Set CalcGroup = Data.Root.ChannelGroups.Add("Calculated Data") Set CalcPressure = CalcGroup.Channels.Add("Pressure",DataTypeFloat64) Set CalcIntegrated = CalcGroup.Channels.Add("Integrated Torque",DataTypeFloat64) Dim aFoundFiles Dim iCount, G100, L100 aFoundFiles = DirListGet(MyFolders(0),"*.tdms","filename","onlyFilenames") If IsArray(aFoundFiles) Then For iCount= Lbound(aFoundFiles) to Ubound(aFoundFiles) Call DataFileLoad(MyFolders(0) & aFoundFiles(iCount)&".tdms","TDMS","") Set RawGroup = Data.Root.ChannelGroups(2) Set RawPressure = RawGroup.Channels("Rev Clu PSI") Set RawTorque = RawGroup.Channels("Input Torque") G100 = ChnFind("Ch(""[2]/Input Torque"")>100") L100 = ChnFind("Ch(""[2]/Input Torque"")<100",G100) If G100>0 AND L100>0 Then Call DataBlDel("'[2]/Input Torque', '[2]/Rev Clu PSI'",L100,RawPressure.Size-L100) Call DataBlDel("'[2]/Input Torque', '[2]/Rev Clu PSI'",1,G100) Call ChnIntegrate("",RawTorque,RawTorque) Pressure(iCount+1) = CCh(RawPressure, 0) IntegratedTorque(iCount+1) = CMax(RawTorque) End If Call Data.Root.ChannelGroups.Remove(2) Next End If Call DataFileSave(MyFolders(1)&"5510 Grow.TDM","TDM")
See if this helps,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
‎04-11-2014 08:08 AM
Brad,
Thank you for the ".size" tip. I am new to VBScript and I could not find out how to do that after a lot of searching.
On my main issue. It must be something to do with my computer. I sent the script to a co-worker and he was able to run this script on 1000 files. We have extremely similar setups on our computers (though he does have the basic license). I am going to attempt to uninstall/reinstall DIAdem. If that doesn't work I guess I'll have to move on to my department's IT.
Thanks everyone.
-MK
‎03-03-2015 03:19 PM
It has been a long long while, but I have finally made some headway on this issue.
I just got a new computer and thought about it so I decided to test my issue again. I still was getting the same General Error
I also have the 64-bit Beta so I thought I would try it there as well and I got this error (which I assume is basically the same):
Problem signature:
Problem Event Name: APPCRASH
Application Name: DIAdem.exe
Application Version: 14.0.7.5751
Application Timestamp: 5428926f
Fault Module Name: ot1200asu.dll
Fault Module Version: 12.0.0.0
Fault Module Timestamp: 50600546
Exception Code: c0000005
Exception Offset: 0000000000036d2b
OS Version: 6.1.7601.2.1.0.256.4
Locale ID: 1033
Additional Information 1: 81db
Additional Information 2: 81db94f1fbb98d4ee9294d7e71b19ace
Additional Information 3: 653b
Additional Information 4: 653bbbe0bb48054abdcc42dc51c87208
Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt
I was racking my brain thinking of the differences between my computer and the end users computer. Then I finally remembered that he has to open the script from the side panel (Run Script from File) while I always run it using F5 in the script window. I ran this script via "Run Script from File" and it now works properly.
I don't know why it does this, it has never done it for any other scripting. I have even wrote another script that used segments of this code for a different purpose and have never had an issue. It will be an interesting issue to try to avoid in the future.
-MK
‎03-09-2015 01:32 AM
Hello Mk17,
We would like to analyze this problem more in detail. Is it possible to share some datasets and the script?
Greetings
Walter