"Snooze"-like feature on alarms


adamLL

Recommended Posts

Hello,

I currently am working on an over-temp alarm. it is somewhat simple in the sense that the fire/reset events are just

Fire: T_out[0]>highT

Reset: OTreset (global variable)

To respond to this alarm - I want to decrease a power output channel by 2, which is easy to do in the fire event

However, I want to give the user an option to override automatic option - perhaps with a modal popup page that has its own countdown, and either takes action after 2 minutes or has a 1 hour "snooze" button.
Do you have any advice on how I structure the fire/reset events or other sequences in this alarm?

I have noticed that I cannot use delay() in my fire/reset events as those run in the main thread and slow my UI, so I have been trying to fix the timing using beginseq(fire_seq)

Thanks for any tips!

Link to comment
Share on other sites

You are on the right track by using beginseq() when you want to do anything with a delay().  As for snooze, the logic is pretty simple.  In your fire_seq do something like:

global actionTime = systime() + 2*60  // default is 2 minutes after now
while(systime() < actionTime)
   delay(1)
endwhile
// do the desired action

Then in the action script of your button, simply put:

actionTime += 58*60 

to add 58 minutes to the action time. As long as it is pressed within the 2 minutes, it will extend it.  You can add additional logic too, for example, not doing it if the alarm resets.

Note: You could of course replace 2*60 with 120, but it is little CPU expense and much clearer the way I did it.

Link to comment
Share on other sites

That kind of works - but instead of just delaying the action - I want it to function more like a "snooze" button on an alarm, that instead of taking action after the 1 hour, the alarm popup comes back up and gives the user another chance to snooze

Link to comment
Share on other sites

Just use a flag to determine whether it should do the action, or popup.  I don't really like popups.  For example in your case, what happens if the nobody selects anything and the popup just sits there?  Should it act like a snooze and wait for a response, or activate the alarm?

Link to comment
Share on other sites

The idea is that the popup is launched by the fire event after `beginseq(Fire_seq)`
the idea of the popup (modal with the no close flag) is to force the user to acknowledge something if they are there.
After 2 minutes, the alarm takes action, and then snoozes for 5 minutes before resetting (at which point, if the temp hasn't lowered by enough, the cycle starts again)

It's less of just a snooze, and more of a delay + a snooze if that makes sense. Delay: (the 2 minutes in which the popup are active), snooze: (the 5 minutes after automated action, or the 1 hour after user acks/ignores the alarm)

The user if they are closely monitoring the system should however, have those 2 minutes to decide if they want to acknowledge that the system is overtemped, and ignore it for 1 hour (want to make the ignore/snooze time long enough so that in the future people don't disable the alarm because it inconveniences them too often). The button to ignore/ack the alarm also closes the popup and goes back to the main control page.

An original idea I had was after the 2 minutes, if automatic action is taken, the popup was closed and replaced with a system.messagebox() informing the user of the automatic action taken. However, this was difficult to manage because if you had an unacked message box starting the same sequence multiple times before it had ended lead to odd behavior.

However, replacing the message box with just keeping the popup open and having different components become visible after the automatic action being taken was easier to get running and looks nice as well.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.