コード例 #1
0
        private void response(SimplSharpString data)
        {
            string   fileName = "\\NVRAM\\" + this.hostID + "_" + this.schdulerID + ".plist";
            string   url      = new JsonUtil().parseURL(data.ToString());
            var      xml      = new SceneXML();
            Schedule sch      = null;

            if (url.Equals(""))
            {
                sch = xml.parseSchedule(fileName);
            }
            else
            {
                uint size = new Http().download(url, fileName);
                if (size > 0)
                {
                    sch = xml.parseSchedule(fileName);
                }
            }

            String   schName   = "scene";
            DateTime now       = DateTime.Now;
            int      h         = int.Parse(sch.startTime.Split(':')[0]);
            int      m         = int.Parse(sch.startTime.Split(':')[1]);
            DateTime startTime = new DateTime(now.Year, now.Month, now.Day, h, m, 0);

            h = int.Parse(sch.endTime.Split(':')[0]);
            m = int.Parse(sch.endTime.Split(':')[1]);
            DateTime endTime = new DateTime(now.Year, now.Month, now.Day, h, m, 0);
            int      inteval = sch.interval;

            if (this.schduleType == schType.device)
            {
                int min  = startTime.Minute + inteval;
                int hour = startTime.Hour;
                if (min > 59)
                {
                    hour++;
                }
                endTime = new DateTime(now.Year, now.Month, now.Day, hour, min, 0);
                schName = "device";
            }

            start(schName, startTime, sch.weekDays);
            start("e_" + schName, endTime, sch.weekDays);
        }
コード例 #2
0
        public void callback(ScheduledEvent e, ScheduledEventCommon.eCallbackReason r)
        {
            CrestronConsole.PrintLine("scheduler at:{0}", DateTime.Now.ToString());
            string fileName   = "\\NVRAM\\" + this.hostID + "_" + this.schdulerID + ".plist";
            var    xml        = new SceneXML();
            string deviceinfo = xml.parseSceneToDevices(fileName);

            if (e.Name == "scene" + this.schdulerID || e.Name == "device" + this.schdulerID)
            {
                if (openit != null)
                {
                    openit(deviceinfo);
                }
            }
            if (e.Name == "e_scene" + this.schdulerID || e.Name == "e_device" + this.schdulerID)
            {
                if (openit != null)
                {
                    closeit(deviceinfo);
                }
            }
        }