Parameters: Math Function

<< Click to Display Table of Contents >>

Navigation:  Editing a SpecView Project > Button Attributes & Strategy Controller Actions >

Parameters: Math Function

Previous pageReturn to chapter overviewNext page

 

This Button/Strategy Controller Action allows limited amounts of mathematical and other operations to be performed on Parameters.

 

Math functions always take the form of:

       'Copy From Parameter' <Math Function> 'Operator Parameter' -> 'Copy To Parameter'

The settings below will write the value of Screw Speed x Drive Ratio to Roll Speed

 

 

butpar4

 

 

The parameters chosen for the 'Copy From', 'Operator' and 'Copy To' fields should usually be of the same type. For example, you cannot take a date, divide it by a boolean and put the result into a text type. There are however, some exceptions listed in the table below. If you need to do math on items of different types not listed below, then use the Copy function to copy the value(s) to the correct type first.

 

NOTE:  This feature can be used to extract part of the text, such as part of a barcode from a barcode reader.

 

CopyFrom

Type

MathFunction

Operator

Type

CopyTo

Type

Comments

Time

Any

Number (with decimals)

Time

Appropriate math is done on the time, e.g Multiply a time by 2.0

Text

Add

Text

Text

Concatenation.  Use to add 2 pieces of text together.

Text

Subtract

Integer

Text

Left or Right function.  If the Integer is positive, the Left-most 'x' characters are taken.  If the integer is negative, the Right-most 'x' characters are taken.  Examples:'ABCDE' Subtract 2  ->  'AB' 'ABCDE' Subtract -2  ->  'DE'

Text

Divide

Integer

Text

Mid function.  The characters from the 'x'th position onward are taken, until the end of the text (First position is 0).  Example:'ABCDE' Divide 2  ->  'CDE'

Text

Multiply

Text

Integer

Find function.  The integer is setup with the position of the first occurrence of ''Operator Text' in the 'Copy From' text.  If the text is not found, -1 is used.  Example:'ABCDE' Multiply 'BC'  ->  1'ABCDE' Multiply 'FRED' -> -1

Bool

Add

Bool

Bool

AND function:

There are 4 possible combinations:

Boolean_And

Bool

Subtract

Bool

Bool

NOT function.  Note that the Operator Parameter is not used, but must be specified.  Use the same parameter for the Copy From and the Operator.  The 'Copy To' boolean is setup with the opposite state of the 'Copy From' boolean.

Bool

Multiply

Bool

Bool

OR function.

There are 4 possible combinations:

Boolean_OR

Bool

Divide

Bool

Bool

XOR (eXclusive-OR)  function:

There are 4 possible combinations:

Boolean_XOR

Number or Integer or Enum or

Time

Add or

Subtract or Multiply

Number or Integer or Enum or Time

Bool

If the result of the math is 0, then the bool will be Off, if the result is non-zero, then the bool will be On.

This allows an Enumerated Alarm to be 'translated' into On/Off.

Note: The other Math types will all result in Bool being set to Off.

 

 

The following three math functions use variables of type integer or number (with decimals):

 

The Abs Math Function takes the first Copy From value and puts into the Copy To variable the absolute value (the positive value) of it.  However, it is also necessary to specify the second Copy From variable so set it to be the same variable name as the first.

 

The Max Math Function takes the two Copy From values and puts the higher value into the Copy To variable.

 

The Min Math Function takes the two Copy From values and puts the lower value into the Copy To variable.

 

 

The following three math functions use ONLY variables of type number (with decimals):

 

The Power Function takes the two Copy From values (x and y) and puts xy into the Copy To variable.

 

The Log_10 Function is to base 10. This is also known as the common logarithm and has many applications in science and engineering.

 This Math function takes the two Copy From values (x and y) and puts the result into the Copy To variable.

 

The Log_e Function is the natural logarithm with 'e' as its base (where e ≈ 2.718).

 This function takes the two Copy From values (x and y) and puts the result into the Copy To variable.

 

Doing math on types not listed above or not of the same type will usually result in no action being performed.  Occasionally however, unpredictable results may occur.  To avoid confusion, only perform math on items of the same type, or those listed above.