public MainWindow()
        {
            InitializeComponent();
#if !DEBUG
            System.Windows.Threading.DispatcherTimer tmr = new System.Windows.Threading.DispatcherTimer();
            tmr.Tick += async   (s, a) =>
                {
                    try
                    {
                        StreetLightInfo[] infos=null;
                        if (chkStopCycleQuery.IsChecked == false)
                        {
                            
                            infos = await dev.GetVisibleStreetLightListAsync();
                            
                            this.datagrid1.ItemsSource = infos.OrderBy(n=>n.DevID).ToArray();
                          
                            CeraDevices.Schedule sch = new CeraDevices.Schedule();
                            sch.Segnments = Schedules;
                            int repcnt = 0;
                            foreach (StreetLightInfo info in infos)
                            {
                                if (chkIsRepair.IsChecked == true && !sch.IsEqual(info.sch))
                                {
                                    dev.SetDeviceSchedule(info.DevID, sch.GetScheduleSegTimeString(), sch.GetScheduleSegLevelString());
                                    repcnt++;
                                }
                              //  grdSchedule.ItemsSource
                            }

                            this.Title = repcnt + "/" + infos.Length.ToString();
                            
                        }
                        if (cyclecnt++ * cycle % 600 == 0) //10 min
                            if (chkIsLog.IsChecked == true)
                                savelog(infos);
                       
                    }
                    catch { ;}
                };

            tmr.Interval = TimeSpan.FromSeconds(60);
            tmr.Start();
           

            
          //  dev.SetDeviceRTC("*", DateTime.Now);
#endif
            for (int i = 0; i < Schedules.Length; i++)
                Schedules[i] = new ScheduleSegnment();
            this.grdSchedule.ItemsSource = Schedules;
        }