Esempio n. 1
0
        public bool ShouldTrigger(RFInterval interval)
        {
            var shouldTrigger = Schedules.Any(s => s.ShouldTrigger(interval));
            var isAllowed     = Range == null || Range.InRange(interval);

            return(IsEnabled && shouldTrigger && isAllowed);
        }
Esempio n. 2
0
 public TimeTrigger GetActiveTimeTrigger()
 {
     if (Schedules.Any(s => s.Active))
     {
         return(Schedules.FirstOrDefault(s => s.Active).GetActiveTimeTrigger());
     }
     else //It is possible that a user deletes the active schedule, then there is no active program
     {
         return(null);
     }
 }
Esempio n. 3
0
 public TimeTrigger GetActiveTimeTriggerForDevice(string deviceName)
 {
     if (Schedules?.Any(s => s.Active && s.AppliesToDeviceNames.Contains(deviceName)) == true)
     {
         return(Schedules?.FirstOrDefault(s => s.Active && s.AppliesToDeviceNames.Contains(deviceName)).GetActiveTimeTrigger());
     }
     else //It is possible that a user deletes the active schedule, then there is no active program
     {
         return(null);
     }
 }
Esempio n. 4
0
        public void HandleEvent(IEvent ev)
        {
            this.ThrowIfInvalidEvent(ev);

            var timeEvent = ev as TimeEvent;

            Context.Log(LogType.EventReceived, timeEvent.ToString(), source: this);

            // evaluate all of the schedules to see if one is a hit, if so, then run the action configured for this consumer
            if (Schedules.Any(s => s.IsMatch(timeEvent.Time)))
            {
                EventAction(ev.Time);
            }
        }