Specifying a time to check for tag = true

Hello

I have a tag I would like to tie an alarm to. However, I want it to alarm out only during the shift hours which are 8PM - 6AM. How would I create a tag to express the tag only during this time?

Thank you
Steve

I would make 4 tags.

  1. Alarm Tag (OPC BOOL)
  2. Shift Start Time (memory Date)
  3. Shift End Time (memory Date)
  4. Shift Alarm Tag (Expression BOOL)

Have an alarm configured on the Shift Alarm Tag. It's expression should check for Alarm Tag and current time between Shift Start and End Time.

{alarmTag} && dateIsBetween(now(),{shiftStart},{shiftEnd})

How would you update the shift time to today's date automatically? From my limited understanding, the date format requires a specific date to be set.

Ah, yes. I overlooked that. I think you should be able to use an expression function to strip out the hours and minutes for comparison, rather than using the dateIsBetween() function.

In that case, I would modify the original 4 tags and add one. Shift Start and End become INTs ranging from 0000 -> 2359. Then, add another INT memory tag for the current time with the same range.

  1. alarm
  2. shiftStart_HHMM
  3. shiftEnd_HHMM
  4. now_HHMM
  5. shiftAlarm

now_HHMM's expression is

( getHour24(now()) *100) + getMinute(now())

shiftAlarm's expression would be

{alarm}
&&
( {now_HHMM} > {shiftStart_HHMM} ) && ( {now_HHMM} < {shiftEnd_HHMM} )

Use some expression bindings on the container that sets the shift start and end times to combine them for storage in the tags.

**edit: you might have to mess with this expression because I now see that what I have written won't quite work for times that go overnight

You could use scheduled scripts to toggle a boolean tag at the start and end of the shift, and use that tag in the evaluation.

But do you want to suppress the alarm entirely, or only the notification ?