Ad Widget

Collapse

Trigger With Multiple Conditions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rdecarv
    Junior Member
    • Jul 2016
    • 2

    #1

    Trigger With Multiple Conditions

    Hello Guys,

    I am having a problem with a trigger that has multiple conditions. I am not sure if I am doig the right thing or at least less complicated.


    The trigger should check the last two colected values and if both are true , then the trigger will alarm.

    Here is my code. Any sugestions ? This is not working according to what I expect.

    Thanks !!!

    \\If two last values are lower than 10000 and the time is between 00 and 06AM or 18 and 2359PM \\

    {test_traff_tx.sh.last(#2)} < 10000 and
    {test_traff_tx.sh.last(#1)} < 10000 and
    {test_traff_tx.sh.time()} > 000001 and
    {test_traff_tx.sh.time()} < 060000 or
    {test_traff_tx.sh.time()} > 180000 and
    {test_traff_tx.sh.time()} < 235959
    or

    \\If two last values are lower than 450000 and the time is between 08 and 12PM or 14 and 18PM from monday to saturday \\

    {test_traff_tx.sh.last(#2)} < 450000 and
    {test_traff_tx.sh.last(#1)} < 450000 and
    {test_traff_tx.sh.time()} > 080000 and
    {test_traff_tx.sh.time()} < 120000 or
    {test_traff_tx.sh.time()} > 140000 and
    {test_traff_tx.sh.time()} < 180000 and
    {test_traff_tx.sh.dayofweek()} < 7
    or

    \\If two last values are lower than 250000 and the time is in lunch time from monday to saturday \\

    {test_traff_tx.sh.last(#2)} < 250000 and
    {test_traff_tx.sh.last(#1)} < 250000 and
    {test_traff_tx.sh.time()} > 115959 and
    {test_traff_tx.sh.time()} < 133000 and
    {test_traff_tx.sh.dayofweek()} < 7
    or

    \\If two last values are lower than 10000 and the day of week is Sunday \\

    {test_traff_tx.sh.last(#2)} < 10000 and
    {test_traff_tx.sh.last(#1)} < 10000 and
    {test_traff_tx.sh.dayofweek()} = 7
  • glebs.ivanovskis
    Senior Member
    • Jul 2015
    • 237

    #2
    You need to learn about operator precedence and use parentheses.

    What you need is "If two last values are lower than 10000 and the time is between 00 and 06AM or 18 and 2359PM". Without parentheses it will be evaluated as "(If two last values are lower than 10000 and the time is between 00 and 06AM) or (the time is between 18 and 2359PM)". To fix it you need to put parentheses like so: "(If two last values are lower than 10000) and (the time is between 00 and 06AM or 18 and 2359PM)".

    Good luck!

    Comment

    • rdecarv
      Junior Member
      • Jul 2016
      • 2

      #3
      Trigger With Multiple Conditions

      Thank you so much for your advice glebs...

      Could you please inform if this sintax looks ok now ?

      (({Hostutcoming.last(#2)}<30000 and
      {Hostutcoming.last(#1)}<30000) and

      ({Hostutcoming.time()}>000000 and
      {Hostutcoming.time()}<060000))
      or
      (({Hostutcoming.last(#2)}<6000000 and
      {Hostutcoming.last(#1)}<6000000) and

      ({Hostutcoming.time()}>080000 and
      {Hostutcoming.time()}<120000 or
      {Hostutcoming.time()}>133000 and
      {Hostutcoming.time()}<180000 and
      {Hostutcoming.dayofweek()}<6 ))
      or
      (({Hostutcoming.last(#2)}< 1000000 and
      {Hostutcoming.last(#1)}< 1000000) and
      ({Hostutcoming.time()}>115959 and
      {Hostutcoming.time()}<133000 and
      {Hostutcoming.dayofweek()}<6))
      or
      (({Hostutcoming.last(#2)}<100000 and
      {Hostutcoming.last(#1)}<100000 and
      {Hostutcoming.time()}>180000 and
      {Hostutcoming.time()}<235959))

      Comment

      • glebs.ivanovskis
        Senior Member
        • Jul 2015
        • 237

        #4
        Oh, that is a trigger!

        Formatting helps a lot in such cases (programmers habit):
        Code:
        (
        	(
        		{Host:outcoming.last(#2)}<30000
        		and
        		{Host:outcoming.last(#1)}<30000
        	)
        	and
        	(
        		{Host:outcoming.time()}>000000
        		and
        		{Host:outcoming.time()}<060000
        	)
        )
        or
        (
        	(
        		{Host:outcoming.last(#2)}<6000000
        		and
        		{Host:outcoming.last(#1)}<6000000
        	)
        	and
        	(
        [COLOR="red"]		{Host:outcoming.time()}>080000
        		and
        		{Host:outcoming.time()}<120000
        		or
        		{Host:outcoming.time()}>133000
        		and
        		{Host:outcoming.time()}<180000
        		and
        		{Host:outcoming.dayofweek()}<6
        [/COLOR]	)
        )
        or
        (
        	(
        		{Host:outcoming.last(#2)}<1000000
        		and
        		{Host:outcoming.last(#1)}<1000000
        	)
        	and
        	(
        		{Host:outcoming.time()}>115959
        		and
        		{Host:outcoming.time()}<133000
        		and
        		{Host:outcoming.dayofweek()}<6
        	)
        )
        or
        (
        	(
        		{Host:outcoming.last(#2)}<100000
        		and
        		{Host:outcoming.last(#1)}<100000
        		and
        		{Host:outcoming.time()}>180000
        		and
        		{Host:outcoming.time()}<235959
        	)
        )
        Red part looks suspicious. Currently dayofweek restriction will only affect 10-18 part.

        Comment

        Working...