10-10-2012 07:03 AM
Hello Everyone,
i habe a problem, when i use diadem script to calculate. There is always a error overflow or überlauf. Can someone help me ? Thank you very much!
kanalname3="[12]/tCool_eng_out"
kanallaenge =ChnPropValGet(kanalname3, "length")
For i= 720tokanallaenge
index_wert=CHD(i, kanalname3)
If index_wert >min_tCool_eng_out ThenIf index_wert< max_tCool_eng_out Then
summe3= summe3+index_wert
zaehler3=zaehler3+1
End if
Endif
Next
R12= summe3/zaehler3 here is the error
average3 =ChnLinGen("VF-028 Logdata/average tCool_eng_out",0,0,2) 'neuen Kanal "av.tCool_eng_out" erstellen
CHD(1,average3)=R12
10-10-2012 11:30 AM
There is no initialization for "zaehler3"
10-11-2012 02:08 AM
Thank you for your solution. But it did not work
10-11-2012 02:14 AM
OK, did you try to print the values before the statement in line "R12= summe3/zaehler3 here is the error"
Something like
LogFileWrite("Summe3 "&Summe3)
LogFileWrite("Zaehler3 "&Zaehler3)
That should at least make it obvious which of the two variable creates the problem
Do you by any means have Novalues in the channel ?
10-11-2012 02:47 AM
Hello, thanks a lot for so fast reply. I only want to print the values after the statement in line "R12= summe3/zaehler3 ". I do have some novalues in the channel. Maybe this is the problem. When i calculate the average, i plus the values, which are not novalues,and the corresponding cycle number,then division.
10-11-2012 03:05 AM
Sorry for not bringing this up earlier:
Are you aware that there are statistic function in DIAdem which probably can do what you implemented as a script ?
10-11-2012 03:15 AM
ok, problem is that, i have over 200 TDM datas to handle. So script is better. Thank you very much !
10-11-2012 03:48 AM
I understand. What I meant was using the built-in function in DIAdem to calculate teh values your are looking for. The following example calculates statistic values for a channel "Speed" in group one. This works even if you have NoValues in the channel:
Dim K
For K = 1 to 23
StatSel(K) = "No"
Next
StatSel(2) = "Yes"
StatSel(6) = "Yes"
StatClipCopy = 0
StatClipValue = 0
StatFormat = ""
StatResChn = 0
StatResChnNames = 0
Call StatBlockCalc("Channel","1-","[1]/Speed")
LogFileWrite("Aritmetic mean value: "&Data.Root.ChannelGroups(1).Channels("Speed").Properties("ResultStatArithMean").Value)
10-11-2012 04:39 AM
Hello,
Thank you for this solution.How can i put the result to report? I did it like the following picture. Could i ask another question? Are there any solutions, that i can collect all average values from 100 TDM datas to only one excel with script?
10-11-2012 05:31 AM
Using the generated statistic values in a report is straightforward. If you run the script I provided, you will see that the channel now has a new property called "ResultStatArithMean".
Go to REPORT , select the property in the Dataportal (down in the list of all properties for the channel) and drag&drop the property to REPORT. Please drop it on an area with no control behind it. You will see that DIAdem creates a text which shows the value of the property. If you double click on that text, you will see that it is a reference to the attribute you calculated. So if you run the script with a different data set and you use the same layout, you will see the new value from the new dataset.
Regarding your second question : I am not sure whether I fully understand what you want to achieve, but you probably want to write the properties from the different channels to a single Excel sheet.
To to do, I would recommend to open a new Excel sheet using the Excel ActiveX interface (documentation available from Microsoft) . Then you copy the property values from the channel to the Excel sheet.
Hope that helps