Sign in to follow this  
siggiv

Alarm Activitation According Day And Time

Recommended Posts

Hi

 

I am trying to make a user input to activate alarm according to weekday and time of day.

For example make alarm active (enable) from 18:00 on friday evening to 08:00 on monday morning.

similar as "Active Times" in DAQConnect.

 

 

 

here is how I started:

 

while (1)
   if ((systime() > 18h) && (systime() <= (08h)) & (v.ON_Button_Alarm[0] == 1))
              
Alarm.MyAlarm.Enabled = True
        Else
        Alarm.MyAlarm.Enabled = False
   Endif
   delay(1)
endwhile

 

Thanks for any help

siggi

 

 

 

 

 

Share this post


Link to post
Share on other sites

Its probably easier to simply put the criterea in the alarm itself.  I personally would create a function that returns 0 or 1 depending on whether the alarm should be active, then you could use the same criterea for a group of alarms.  So if the alarm expression was just:

 

myChannel[0] > 50

 

you would do something like:

 

(myChannel[0] > 50) && alarmsActive()

 

where alarmsActive() is a function like:

 

function alarmsActive()

   return(v.On_Button_alarm[0] && (systime() % 86400 > 3600*8) && (systime() % 86400 < 3600 * 18)))

 

I like using % 86400 to determine time of day rather than hms notation.  Note that this just disables the alarm if v.On_button_alarm is 0, and the current time of day is between 08:00 and 18:00.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this