Jump to content

Recommended Posts

  • Seeq Team
Posted (edited)

We often do calculations where we are interested in having one result if one condition is true and a second result if another condition is true.  In this post we will discuss how to do this calculation in Seeq. 

We will create a new single signal which runs different calculations during different periods of time. This technique can be used to replicate "if" logic or "if / else" logic currently being used in excel.

Example existing code from excel or other systems

  • IF Temperature > 90 then show a result of  (Temperature * 100) 
  • IF Temperature < 90F then show a result of  (Temperature + 10)

Step 1: Identify two modes of operation

 

image.png

  • In the Tools tab identify the following conditions using the Value Search tool:

image.png

 

Step 2: Use formula to reconstruct "if/then statement" using Seeq's Splice Tool

Local Variables:

Name
Item
Type
$Temperature Temperature Signal
$HighTempCondition Greater than 90 Condition

Seeq Formula:

$HighTempCalc = $Temperature * 100
$LowTempCalc = $Temperature + 10

$LowTempCalc.splice($HighTempCalc,$HighTempCondition)
 
Section 1  -  $HighTempCalc
This is a local variable which is to be run during periods of high temperature

Section 2  -  $LowTempCalc
This is a local variable which is to be run when NOT in periods of high temperature

Final  -  $LowTempCalc.splice($HighTempCalc,$HighTempCondition)
Combine your two series. Use the LowTempCalc series, unless you are in the High Temperature condition, in which case use the HighTempCalc 
 
image.png
 
Content Verified DEC2023
Edited by Rupesh Parbhoo
Updated images, corrected language on local variables in formula.
  • Like 2
  • 1 year later...
Posted

Hi Ingrid,

you try to use splice on a scalar, which is available since R51. In lesser versions you can apply splice only on signals, so changing $h to a signal first should resolve the issue:

$h.tosignal().splice($l, $lfc)

Regards,

Thorsten

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...