DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Using FormulaCalc with single values

This seems like a silly question, but here goes.  I seem to have problems using the FormulaCalc command to calculate single-values, or channels of length=1.  For example, if I try the following in a script,
 
Call FormulaCalc("Ch('NOxTotalGrams') := " & CCH("NOxGramsPerHour",0) * (ChnLength("NOxGramsPerHour")/ChD(1, "iH_SamplingFrequency_Hz"))/3600 & "")
 
I receive an error: "Calculation result is not a channel."
 
I am able to get around this by just creating a channel through ChnAlloc of length 1, and setting the value with ChD, but I like FormulaCalc better and would prefer to use that.  What am I doing wrong!?
 
Thanks!
Julia Moeller
0 Kudos
Message 1 of 3
(3,544 Views)

Hello Julia!

Unfortunately you do everything right! DIAdem is not able to do it the way you want. In X-Frame, our DIAdem based application framework, we wrapped the FormulaCalc to detect this case and create the channel as you proposed. In the case you know it in advance and want to calculate several channels you can allocte a channel with one value and set this to 1 and use it in the formula.

Matthias

Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 2 of 3
(3,537 Views)
Hello Julia,

As Matthias mentioned the formula syntax is OK in general. "Only" the restriction of the command FormulaCalc comes up. That means the following: If your equation contains a channel reference on the left side it is necessary to have at least one channel reference on the right side. That's like it is today - but I've discussed this issue with the DIAdem developers and it seems that we can implement this use case for the next DIAdem version.

Greetings
Walter

0 Kudos
Message 3 of 3
(3,508 Views)