DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculation Manage Ignore calculation if channel exists

If I have a calculation in the calculation manager that loops over all groups (using @@CCR@@), how do I get the calculation manager to ignore a certain group if the channel is already there? 

0 Kudos
Message 1 of 7
(3,464 Views)

Hi RussellSenior,

 

What channel's existence in the group are you looking to check for? Are you storing the results of the calculation in the group the calculation occurs on?

 

Thanks,

Kevin Flanagan

Applications Engineer

0 Kudos
Message 2 of 7
(3,427 Views)

I want to look for the channel itself. So, if I have a calculation that results in the creation of "[1]/ExampleChannel", I want the calculation manager to check to see if "[1]/ExampleChannel" exists.  If it DOES exist, I want the calculation manager to not overwrite the existing channel. 

0 Kudos
Message 3 of 7
(3,425 Views)

Hi Russell,

 

I think in order to apply custom logic like this, you'll need to switch to the Advanced tab of the Calculation Manager and write the looping and IF THEN statements yourself in the VBScript that the Calculation Manager will call for that calculation.  I don't know of a feature you can invoke with the formula-based tab of the Calculation Manager to perform the channel exist check, reasonable though it is.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 7
(3,406 Views)

Thanks, I figured a validation script would be the perscription.  😛  

 

Is there a programming reference for variables available to the validation script?  I see CCR represents the current cycle.  Is there another variable that represents the output channel?

 

Specifically Is there a way to dynamically specify the output channel in the validation script, or do I have to explicity check for the channel in each and every calculation. So, for example, if my output channel is "EngineSpeed", can my validation script do this:

 

If Data.Root.ChannelGroups(@@CCR@@).Channels.Exists(SOMEVARIABLE) then

   Failed = "Chan exists"

End if

 

If SOMEVARIABLE can be dynamic, I can copy_paste my validation script. Or, is there someway to return the current calculation number, then I can just check the output name. 

 

Thanks. 

 

0 Kudos
Message 5 of 7
(3,403 Views)

Hi Russell,

 

Here's what I've learned playing around with this topic today.  The Calculation Manager will always create the empty result channel (if the LED is green) prior to running the formula or script for that calculation.  So checking if the channel exists doesn't help, but you CAN check for any channel properties.  Here's an example of editing the shipping "Power" calculation so that it only executes if it has not already been run once (which is what I think you mean).  The "CurrSymbols" variable is a 0-indexed array of the symbols in the equation, in this case {"M","n","P"}.  The "CurrValues" variable is a 0-indexed array of channel objects associated with each symbol.  Since the return symbol and channel are each in array index 2, you have to use CurrValues(2) in the IF THEN condition below:

 

IF NOT CurrValues(2).Properties.Exists("CalcDateTime") THEN
  Call Calculate("P = n * M",CurrSymbols,CurrValues,"Default")
  CurrValues(2).Properties.Add "CalcDateTime", Now
END IF

 

I figured out the array index order by using the following lines before the Calculate command one at a time:

MsgBox CurrValues(0).Name

MsgBox CurrValues(1).Name

MsgBox CurrValues(2).Name

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 6 of 7
(3,376 Views)

So, sometimes the data we get has certain channels, sometimes it doesn't.  So, I wanted to be able to have the calculation manager check these for me, and not do a particular calculation.  So, if I load some data and "Power" exists, then don't do the power calculation.  It seems that this isn't easy, so I'll just overwrite the values, and let it be. 

0 Kudos
Message 7 of 7
(3,326 Views)