Time ignition perspective

Hello, I would like to trigger an alarm if I detect engine malfunctions between 7:00 a.m. and 9:00 p.m.

For example if stpValue >100 and the time is between 7h00 and 21h00 then I trigger an alarm.

But I don’t know how to know if the time is on the interval of 7:00 a.m. and 9:00 p.m.

You could set up a normal alarm with an execution mode of Above Value for your setpoint, then place an expression binding on the Enabled property that looks something like:

timeBetween(now(), "7:00:00 am", "9:00:00 pm")
3 Likes

Thank you Sir.

That is mean
if moteur1 = 1 and setpoint = 1 and timeBetween(now(), “7:00:00 am”, “9:00:00 pm”)
alarm is enabled
else:
alarm is not enabled

I can do that?

If moteur and setpoint are boolean (True or False only) then you can use:

if moteur1 and setpoint and timeBetween(now(), “7:00:00 am”, “9:00:00 pm”):
    alarm is enabled
else:
    alarm is not enabled

Note the ‘:’ at the end of the line.


Please use the </> code formatting button when posting code. It will indent properly (important for Python) and give syntax highlighting. You can use the 🖉 edit link to fix your post.

1 Like

Be careful. You’re starting to mix scripts and expressions.

moteur1 && setpoint && timeBetween(now(), “7:00:00 am”, “9:00:00 pm”)

2 Likes

Thank you, I solved it

2 Likes

Thanks, Jordan. Can you clarify what’s wrong with my approach? timeBetween returns a boolean so why would my script be incorrect?

timeBetween is an expression language function but you wrote Jython script syntax.

2 Likes

I was just gonna requote myself. :wink:

4 Likes