public void InitializeStuff()
        {
            myGroup.RetrieveAllEvents();
            // foreach (System.Collections.Generic.KeyValuePair<string, ScheduledEvent> myEvent in myGroup.ScheduledEvents)
            foreach (var _event in myGroup.ScheduledEvents)
            {
                CrestronConsole.PrintLine("Event Read:{0}, {1}:{2}", _event.Value.Name,
                                          _event.Value.DateAndTime.Hour,
                                          _event.Value.DateAndTime.Minute);
            }
            myEvent1             = new ScheduledEvent("Relay 1", myGroup);
            myEvent1.Description = "Relay 1 Desc";
            myEvent1.DateAndTime.SetRelativeEventTime(0, 5);
            myEvent1.Acknowledgeable = true;
            myEvent1.Persistent      = true;
            myEvent1.AcknowledgeExpirationTimeout.Hour = 10;
            myEvent1.UserCallBack += new ScheduledEvent.UserEventCallBack(myEvent1_UserCallBack);
            myEvent1.Enable();
            CrestronConsole.PrintLine("Event Created:{0}, {1}:{2}", myEvent1.Name,
                                      myEvent1.DateAndTime.Hour,
                                      myEvent1.DateAndTime.Minute);

            myEvent2             = new ScheduledEvent("Relay 2", myGroup);
            myEvent2.Description = "Relay 2 Desc";
            myEvent2.DateAndTime.SetRelativeEventTime(0, 7);
            myEvent2.Acknowledgeable = true;
            myEvent2.Persistent      = false;
            myEvent2.UserCallBack   += new ScheduledEvent.UserEventCallBack(myEvent1_UserCallBack);
            myEvent2.Enable();
            CrestronConsole.PrintLine("Event Created:{0}, {1}:{2}", myEvent2.Name,
                                      myEvent2.DateAndTime.Hour,
                                      myEvent2.DateAndTime.Minute);
        }
        public void InitializeStuff()
        {
            myGroup.RetrieveAllEvents();
            // foreach (System.Collections.Generic.KeyValuePair<string, ScheduledEvent> myEvent in myGroup.ScheduledEvents)
            foreach (var _event in myGroup.ScheduledEvents)
            {
                CrestronConsole.PrintLine("Event Read:{0}, {1}:{2}", _event.Value.Name,
                                                _event.Value.DateAndTime.Hour,
                                                _event.Value.DateAndTime.Minute);

            }
            myEvent1 = new ScheduledEvent("Relay 1", myGroup);
            myEvent1.Description = "Relay 1 Desc";
            myEvent1.DateAndTime.SetRelativeEventTime(0, 5);
            myEvent1.Acknowledgeable = true;
            myEvent1.Persistent = true;
            myEvent1.AcknowledgeExpirationTimeout.Hour = 10;
            myEvent1.UserCallBack += new ScheduledEvent.UserEventCallBack(myEvent1_UserCallBack);
            myEvent1.Enable();
            CrestronConsole.PrintLine("Event Created:{0}, {1}:{2}", myEvent1.Name,
                                                myEvent1.DateAndTime.Hour,
                                                myEvent1.DateAndTime.Minute);

            myEvent2 = new ScheduledEvent("Relay 2", myGroup);
            myEvent2.Description = "Relay 2 Desc";
            myEvent2.DateAndTime.SetRelativeEventTime(0, 7);
            myEvent2.Acknowledgeable = true;
            myEvent2.Persistent = false;
            myEvent2.UserCallBack += new ScheduledEvent.UserEventCallBack(myEvent1_UserCallBack);
            myEvent2.Enable();
            CrestronConsole.PrintLine("Event Created:{0}, {1}:{2}", myEvent2.Name,
                                                myEvent2.DateAndTime.Hour,
                                                myEvent2.DateAndTime.Minute);
        }
Example #3
0
        public void start(string name, DateTime time, ArrayList weekdays)
        {
            ScheduledEvent startSch = new ScheduledEvent(name + this.schdulerID, this.schGroup);

            startSch.Description = "schedule to:" + this.schdulerID;
            DateTime now = DateTime.Now;

            startSch.DateAndTime.SetAbsoluteEventTime(now.Year, now.Month, now.Day, time.Hour, time.Minute);
            calcRepeat(startSch, weekdays);
            startSch.Acknowledgeable = true;
            startSch.Persistent      = false;
            startSch.AcknowledgeExpirationTimeout.Hour = 24 * 30 * 12;
            startSch.UserCallBack += new ScheduledEvent.UserEventCallBack(callback);
            startSch.Enable();
            CrestronConsole.PrintLine("Event create with {0} {1}:{2}", startSch.Name, startSch.DateAndTime.Hour, startSch.DateAndTime.Minute);
        }
        void myKeypad_ButtonStateChange(GenericBase device, ButtonEventArgs args)
        {
            try
            {
                if (args.Button.State == eButtonState.Pressed)
                {
                    CrestronConsole.PrintLine("Button {0} was pressed.", args.Button.Number);
                    switch (args.Button.Number)
                    {
                    case 1:
                        var selWeekDays = new ScheduledEventCommon.eWeekDays();
                        selWeekDays |= ScheduledEventCommon.eWeekDays.Monday;
                        selWeekDays |= ScheduledEventCommon.eWeekDays.Tuesday;
                        selWeekDays |= ScheduledEventCommon.eWeekDays.Friday;

                        CrestronConsole.PrintLine("Initializing program response for button {0}", args.Button.Number);
                        myEventGroup.ClearAllEvents();
                        if (myEventGroup.ScheduledEvents.ContainsKey("MyEvent") == false)
                        {
                            myEvent             = new ScheduledEvent("MyEvent", myEventGroup);
                            myEvent.Description = "My first event";
                            myEvent.DateAndTime.SetAbsoluteEventTime(2019, 03, 11, 10, 30);
                            myEvent.Acknowledgeable = false;
                            myEvent.Persistent      = true;
                            myEvent.UserCallBack   += new ScheduledEvent.UserEventCallBack(myEvent_UserCallBack);
                            myEvent.Recurrence.Weekly(selWeekDays);

                            /*
                             * myEvent.Recurrence.Weekly(
                             *  ScheduledEventCommon.eWeekDays.Monday &
                             *  ScheduledEventCommon.eWeekDays.Tuesday &
                             *  ScheduledEventCommon.eWeekDays.Friday, 10);
                             */
                            myEvent.Enable();

                            CrestronConsole.PrintLine("Event {0} created for {1}:{2}",
                                                      myEvent.Name,
                                                      myEvent.DateAndTime.Hour,
                                                      myEvent.DateAndTime.Minute);
                        }
                        break;

                    case 2:
                        CrestronConsole.PrintLine("Initializing program response for button {0}", args.Button.Number);
                        myEventGroup.ClearAllEvents();
                        break;

                    case 3:
                        CrestronConsole.PrintLine("Initializing program response for button {0}", args.Button.Number);
                        CrestronConsole.PrintLine("Event {0} is scheduled for {1}/{2}/{3} {4}:{5}",
                                                  myEvent.Name,
                                                  myEvent.DateAndTime.Month,
                                                  myEvent.DateAndTime.Day,
                                                  myEvent.DateAndTime.Year,
                                                  myEvent.DateAndTime.Hour,
                                                  myEvent.DateAndTime.Minute);
                        break;

                    case 4:
                        ComPorts[1].Send(String.Format("{0}{1}{2}{3}{4}",
                                                       Convert.ToChar(0x31),
                                                       Convert.ToChar(0x32),
                                                       Convert.ToChar(0x33),
                                                       Convert.ToChar(0x34),
                                                       Convert.ToChar(0x0D)));
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                CrestronConsole.PrintLine("Exception occurred --> {0}", e.Message);
                ErrorLog.Notice(String.Format("Exception occurred --> {0}", e.Message));
            }
            finally { }
        }