private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     dev_mgr=(App.Current as App).coor_mgr;
     try
     {
         StreetLightInfo[] infos = dev_mgr.GetStreetLightList(devid);
         datagrid1.ItemsSource = infos[0].sch.Segnments.OrderBy(n => n.Time).ToArray();
         info = infos[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            dev_mgr=(App.Current as App).coor_mgr;
            try
            {
                CeraDevices.StreetLightInfo[] infos = dev_mgr.GetStreetLightList(devid);

                foreach (ScheduleSegnment seg in infos[0].sch.Segnments)
                {
                    if (seg.Time == 15555)
                        seg.Level = 255;
                }
                datagrid1.ItemsSource = infos[0].sch.Segnments.OrderBy(n => n.Time).ToArray();
                info = infos[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void savelog(StreetLightInfo[] infos)
        {
            try
            {

                bool writeheader = false ;
                if (!System.IO.File.Exists("led.csv"))
                    writeheader = true;
                using (StreamWriter wr = System.IO.File.AppendText(AppDomain.CurrentDomain.BaseDirectory + "led.csv"))
                {
                    if (writeheader)
                        wr.WriteLine("TimeStamp,DevID,MAC,cmt,CurrentDimLevel,V,A,F,W,KWHP,KWHN,IsSchedule,LightSensor,Temperature,rtc");
                    
                    foreach (StreetLightInfo info in infos)
                    {
                        wr.Write(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")+",");
                        wr.Write("\t"+info.DevID + ",");
                        wr.Write("\t"+info.MAC + ",");
                    
                        wr.Write("\t"+info.cmt + ",");
                        wr.Write(info.CurrentDimLevel + ",");
                        wr.Write(info.V + ",");
                        wr.Write(info.A + ",");
                        wr.Write(info.F + ",");
                        wr.Write(info.W + ",");
                        wr.Write(info.KWHP + ",");
                        wr.Write(info.KWHN + ",");
                        wr.Write(info.IsScheduleEnable + ",");
                        wr.Write(info.LightSensor + ",");
                        wr.Write(info.Temperature + ",");
                        wr.WriteLine(info.rtc+"");
                       
                     
                    }

                }
            }
            catch { ;}
        }