Vyhledávání
MENU
  • TapHome Apps
  • Výrazy
  • Architektura systému podle typu projektu
  • Uživatelé a oprávnění
  • Výrazy

    Výrazy se používají v Smart Rules „Rovnice“ a „Vzorec“.
    Na zařízeních Modbus lze použít další funkce pro čtení/zápis hodnot z/do registrů Modbus.

    Matematické výrazy

    +, -, *, /

    (20.5 + 9.5) / 2    (15)

    Logické výrazy

    AND, OR, !, =, !=, >, <

    (!IsRaining OR (Wind>30))
    MultiValueSwitchState != 2 (Not equal to 2)

    Funkce

    IF

    IF(logical_expression, value_if_true, value_if_false)

    Vrací jednu hodnotu, pokud je logický výraz „PRAVDA“, a druhou, pokud je „NEPRAVDA“.

    LINEAR

    Vrátí lineárně upravenou hodnotu - lineární interpolaci.

    LINEAR(input, value1_input, value1_output, value2_input, value2_output)

    Example 1: LINEAR(250,  0,0,  50,500)   (Result is 25°C)
    
    Example 2: LINEAR(Co2,  400,0,  1200,1)
              (If value from Co2 sensor is 400ppm, output for air recovery will be 0%. 
               If Co2 is 1200, output will be 100%. And if e.g. Co2=800, output will be 50%)

    LINEAR (BOUNDS)

    An extension of the LINEAR function. It linearly interpolates an input value. If the input value is outside the defined range output value will be one of the extrema (minimum or maximum).

    LINEAR(input, value1_input, value1_output, value2_input, value2_output, BOUNDS)

    Examples:

    • LINEAR(110, 100, 0, 0, 1, BOUNDS) → 0.0

    • LINEAR(110, 0, 0, 100, 1, BOUNDS) → 1.0

    LINEAR (STRICT)

    An extension of the LINEAR function. It linearly interpolates an input value. The input value must be within the defined range. If the input value is outside the defined range output value will be NaN (not a number) value.

    LINEAR(input, value1_input, value1_output, value2_input, value2_output, STRICT)

    Examples:

    • LINEAR(110, 100, 0, 0, 1, STRICT) → NaN

    • LINEAR(110, 0, 0, 100, 1, STRICT) → NaN

    SWITCH

    SWITCH(expression, case1, value1, [case2, ...], [value2, ...], default_value)

    Testuje výraz proti seznamu případů a vrací odpovídající hodnotu prvního porovnávacího případu s výchozí hodnotou, pokud není splněno nic jiného.

    Example


    Configuration

    ReadState ... SWITCH(MODBUSR(H, 168, UInt16),   0, 0,   0x02, 1,   0x04, 2,   0x08, 3,   0x10, 4,   0x40, 5, 0x800, 6,   0)
    WriteState ... MODBUSWNE(H, 168, UInt16, SWITCH(Mu,   0, 0,   1, 0x02,   2, 0x04,   3, 0x08,   4, 0x10,  5, 0x40,   6, 0x800,  0)

    Result

    MIN

    MIN(value1, value2)

    Vrací menší z obou hodnot.

    MAX

    MAX(value1, value)

    Vrací větší z obou hodnot.

    ROUND

    ROUND(value1)    

    Vrátí zaokrouhlenou hodnotu.

    Example 1: ROUND(2.01) (Result is 2)

    Example 2: ROUND(2.49) (Result is 2)

    Example 3: ROUND(2.5) (Result is 3)

    Example 4: ROUND(2.99) (Result is 3)

    Core 2018.1.9623

    DEWPOINT

    DEWPOINT(temperature, relativeHumidity)
    

    Vrátí teplotu rosného bodu vzhledem k aktuální teplotě a relativní vlhkosti. Rosný bod se počítá podle této rovnice: http://bmcnoldy.rsmas.miami.edu/Humidity.html.

    Example 1: DEWPOINT(20, 50) (Result is ~9.26)

    Example 2: DEWPOINT(0, 100) (Result is 0)

    Core 2018.1.9623

    POWER

    Core 2021.1

    The POWER function calculates a given number, raised to a supplied power.

    POWER(number, power)

    Examples:

    • POWER(2,3) … 2^3 = 8

    • POWER(10, -3) … 0,001

    • POWER(25, 0) … 1

    MOD

    Core 2021.1

    The MOD function returns the remainder of a division between two supplied numbers.

    MOD(number, divisor)

    Arguments:

    • number - The number to be divided.

    • divisor - The value that the number argument is divided by.

    Examples:

    • MOD(6, 4)  … 2

    • MOD(6, 2.5) … 1

    CEIL

    Core 2021.1

    The CEIL function rounds a supplied number away from zero, to the nearest multiple of a given number.

    CEIL(number, significance)

    Arguments:

    • number   - The number that is to be rounded.

    • significance (optional) - The multiple of significance that the supplied number should be rounded to. If the significance is not specified, then it is equal to 1.
      (This should generally have the same arithmetic sign (positive or negative) as the supplied number argument)

    Examples:

    • CEIL(22.25,0.1) … 22.3

    • CEIL(22.25,1) … 23

    • CEIL(22.25) … 23

    • CEIL(-22.25,-1) … -23

    • CEIL(-22.25,1) … -22

    • CEIL(-22.25) … -22

    • CEIL(-22.25,-5) … -25

    FLOOR

    Core 2021.1

    The FLOOR function rounds a supplied number towards zero to the nearest multiple of a specified significance.

    FLOOR(number, significance)

    Arguments:

    • number - The number that is to be rounded.

    • significance (optional) -The multiple of significance that the supplied number is to be rounded to. If the significance is not specified, then it is equal to 1.
      (This should generally have the same arithmetic sign (positive or negative) as the supplied number argument)

    Examples:

    • FLOOR(22.25,0.1)… 22.2

    • FLOOR(22.25,1) … 22

    • FLOOR(22.25) … 22

    • FLOOR(-22.25,-1) … -22

    • FLOOR(-22.25,1) … -23

    • FLOOR(-22.25) … -23

    • FLOOR(-22.25,-5) … -20

    RAND

    Core 2021.1

    The Rand function generates a random real number between 0 and 1.

    RAND()

    Examples:

    • RAND()

    RANDINT

    Core 2021.1

    The RANDINT function generates a random integer between two supplied integers.

    RANDINT(bottom, top)

    Examples:

    • RANDINT(1,5)

    • RANDINT(-2,2)

    SIGN

    Core 2021.1

    The SIGN function returns the arithmetic sign (+1, -1 or 0) of a supplied number. I.e. if the number is positive, the SIGN function returns +1, if the number is negative, the function returns -1 and if the number is 0 (zero), the function returns 0.

    SIGN(number)

    Examples:

    • SIGN(100) … 1

    • SIGN(0) … 0

    • SIGN(-100) … -1

    SQRT

    Core 2021.1

    The SQRT function calculates the positive square root of a supplied number.

    SQRT(number)

    Examples:

    • SQRT(25) … 5

    LOG

    Core 2021.1

    The LOG function calculates the logarithm of a given number, to a supplied base.

    LOG(number, base)

    Arguments:

    • number - The positive real number that you want to calculate the logarithm of.

    • base (optional) - An optional argument that specifies the base to which the logarithm should be calculated.
      If the argument is not specified, then the base argument uses the default value 10.

    Examples:

    • LOG(4,0.5) … -2

    • LOG(100) … 2

    LN

    Core 2021.1

    The LN function calculates the natural logarithm of a given number.

    LN(number)

    where the number argument is the positive real number that you want to calculate the natural logarithm of.

    Examples:

    • LN(100) … 4,60517

    Bitové operace

    GETBIT

    Returns a value of a bit in the specified position.

    GETBIT(number, bit_position)

    Arguments:

    • number - number to extract value of specific bit from

    • bit_position - position of bit, starting with 0, from right

    Examples:

    • GETBIT(2, 0) → first bit of number 2 (0b0010) is 0

    • GETBIT(4,2) → third bit of number 4 (0b0100) is 1

    GETBITS

    Returns value of specified number of bits in the specified position.

    GETBITS(number, start_bit, number_of_bits)

    Examples:

    • GETBITS(216, 3, 2) → number 216 = 0b1101 1000; value of 4th bit from the right is 1, 5th bit is 1, therefore result is 0b0011 = 3

    • GETBITS(0xFF, 0, 4) → number 0xFF = 255 = 0b1111 1111; value of first 4 bits from right is 0b1111 = 0xF = 15

    GETBYTE

    Returns a value of a byte in the specified number.

    GETBYTE(number, byte_position)

    Arguments:

    • number - number to extract value of specific byte from

    • byte_position - position of byte, starting from 0, from right

    Examples:

    • GETBYTE(256, 0) → 0001 0000 0000 → 0

    • GETBYTE(256, 1) → 0001 0000 0000 → 1

    • GETBYTE(259, 0) → 0001 0000 0011 → 3

    SETBYTE

    Assigns a new value to the specified byte in the provided number and returns a new number.

    SETBYTE( number, byte_position, new_value)

    Examples:

    • SETBYTE(1, 0, 0) → 0

    • SETBYTE(256, 0, 255) → 511

    • SETBYTE(256, 1, 1) → 256

    • SETBYTE(259, 1, 2) → 515

    SETBIT

    Assigns a new value to the specified bit in the provided number and returns a new number.

    SETBIT(number, bit_position, new_value)

    Arguments:

    • number - number to be modified

    • bit_position - position of bit, starting with 0, from right

    • new_value - 0 or 1 - value that is going to be set to specified bit

    Examples:

    • SETBIT(1, 1, 1) → 3

    • SETBIT(3, 1, 1) → 3

    • SETBIT(4, 2, 0) → 4

    • SETBIT(12, 1, 0) → 14

    SETBITS

    Assigns a new value to the specified bits in the provided number and returns a new number.

    SETBITS(number, start_bit, number_of_bits, new_value)

    Examples:

    • SETBITS(192, 4, 2, 3) → 240

    • SETBITS(192, 5, 2, 3) → 224

    <<   (LEFT BIT SHIFT)

    8 << 2   (32)

    Excel: BITLSHIFT(number, shift_amount)

    >> (RIGHT BIT SHIFT)

    32 >> 2   (8)

    Excel: BITRSHIFT(number, shift_amount)

    & (BITWISE AND)

    3 & 1   (1)

    Excel: BITAND(number1, number2)

    | (BITWISE OR)

    2 | 1 (3)

    Excel: BITOR(number1, number2)

    Hexadecimální čísla

    Výrazy mohou také interpretovat hexadecimální čísla. Je vyžadována předpona 0x a zbytek nerozlišuje velká a malá písmena.

    0x0A (10)

    0xA0A0   (41120)
    0xa0a0   (41120)

    Modbus

    Klepnutím na tento odkaz najdete další informace o konfiguraci Modbus