private void SetSensorData(string sn, DisplaySmartBrightEasyConfig dispaySoftWareConfig, bool isAdd)
 {
     if (string.IsNullOrEmpty(sn) || (isAdd && dispaySoftWareConfig == null))
     {
         return;
     }
     if (isAdd)
     {
         if (dispaySoftWareConfig.AutoBrightSetting != null && dispaySoftWareConfig.AutoBrightSetting.UseLightSensorList != null)
         {
             if (_sn_BrightSensors.ContainsKey(sn))
             {
                 _sn_BrightSensors.Remove(sn);
             }
             _sn_BrightSensors.Add(sn, new List <PeripheralsLocation>());
             foreach (PeripheralsLocation per in dispaySoftWareConfig.AutoBrightSetting.UseLightSensorList)
             {
                 _sn_BrightSensors[sn].Add((PeripheralsLocation)per.Clone());
             }
         }
     }
     else
     {
         if (_sn_BrightSensors.ContainsKey(sn))
         {
             _sn_BrightSensors.Remove(sn);
         }
     }
 }
        private DisplaySmartBrightEasyConfig GetConfig()
        {
            DisplaySmartBrightEasyConfig config = new DisplaySmartBrightEasyConfig();
            config.DisplayUDID = "0123456789";
            config.OneDayConfigList = new List<OneSmartBrightEasyConfig>();

            OneSmartBrightEasyConfig oneItem = new OneSmartBrightEasyConfig()
            {
                ScheduleType = SmartBrightAdjustType.FixBright,
                StartTime = DateTime.Now.AddMinutes(1),
                BrightPercent = 60,
                CustomDayCollection = new List<DayOfWeek>() { DayOfWeek.Monday, DayOfWeek.Tuesday }
            };
            //config.OneDayConfigList.Add(oneItem);

            oneItem = new OneSmartBrightEasyConfig()
            {
                ScheduleType = SmartBrightAdjustType.AutoBright,
                StartTime = DateTime.Now.AddMinutes(1),
                BrightPercent = 60,
                CustomDayCollection = new List<DayOfWeek>() { DayOfWeek.Monday, DayOfWeek.Tuesday }
            };
            config.OneDayConfigList.Add(oneItem);

            oneItem = new OneSmartBrightEasyConfig()
            {
                ScheduleType = SmartBrightAdjustType.FixBright,
                StartTime = DateTime.Now.AddMinutes(11),
                BrightPercent = 40,
                CustomDayCollection = new List<DayOfWeek>() { DayOfWeek.Monday, DayOfWeek.Tuesday }
            };
            config.OneDayConfigList.Add(oneItem);


            List<PeripheralsLocation> locateList = new List<PeripheralsLocation>();
            PeripheralsLocation location = new PeripheralsLocation()
            {
                FirstSenderSN = "abc",
                SenderIndex = 0,
                SensorType = PeripheralsType.LightSensorOnSender
            };
            locateList.Add(location);

            location = new PeripheralsLocation()
            {
                FirstSenderSN = "acb",
                SenderIndex = 0,
                PortIndex = 0,
                FuncCardIndex = 0,
                SensorIndex = 1,
                SensorType = PeripheralsType.LightSensorOnFuncCardInPort
            };
            locateList.Add(location);

            List<DisplayAutoBrightMapping> maplist = new List<DisplayAutoBrightMapping>();
            DisplayAutoBrightMapping map = new DisplayAutoBrightMapping()
            {
                EnvironmentBright = 50,
                DisplayBright = 30
            };
            maplist.Add(map);

            map = new DisplayAutoBrightMapping()
            {
                EnvironmentBright = 300,
                DisplayBright = 60
            };
            maplist.Add(map);

            AutoBrightExtendData autoData = new AutoBrightExtendData()
            {
                CalcType = AutoBrightCalcType.AllAverage,
                UseLightSensorList = locateList,
                AutoBrightMappingList = maplist
            };
            config.AutoBrightSetting = autoData;

            return config;
        }
 private DisplaySmartBrightEasyConfig GetEasyConfigFromUI()
 {
     DisplaySmartBrightEasyConfig easyConfig = new DisplaySmartBrightEasyConfig()
     {
         DisplayUDID = this.DisplayUDID,
         OneDayConfigList = new List<OneSmartBrightEasyConfig>(),
         AutoBrightSetting = _sensorConfig.ExtendData
     };
     for (int i = 0; i < DisplaySmartBrightCfg.Count; i++)
     {
         easyConfig.OneDayConfigList.Add(DisplaySmartBrightCfg[i]);
     }
     return easyConfig;
 }
 private void ApplyHWBrightMode(DisplaySmartBrightEasyConfig easyConfig)
 {
     if (_globalParams.SmartBrightManager != null)
     {
         if (SelectedBrightAdjustMode == BrightAdjustMode.SmartBright)
         {
             ((SmartBright)_globalParams.SmartBrightManager).AttachSmartBright(easyConfig.DisplayUDID, easyConfig);
         }
         else
         {
             ((SmartBright)_globalParams.SmartBrightManager).DetachSmartBright(easyConfig.DisplayUDID);
         }
     }
 }
        public void InitialControlConfig(string sn, BrightnessConfigType type, DisplaySmartBrightEasyConfigBase cfg)
        {
#if test
            if (MonitorAllConfig.Instance().BrightnessConfigList == null || MonitorAllConfig.Instance().BrightnessConfigList.Count == 0)
            {
                MonitorAllConfig.Instance().BrightnessConfigList = new List <DisplaySmartBrightEasyConfig>();
                DisplaySmartBrightEasyConfig cfg = new DisplaySmartBrightEasyConfig();
                cfg.DisplayUDID       = "1405220000041214-00";
                cfg.AutoBrightSetting = new AutoBrightExtendData();
                cfg.OneDayConfigList  = new List <OneSmartBrightEasyConfig>();
                OneSmartBrightEasyConfig oneCfg = new OneSmartBrightEasyConfig();
                oneCfg.BrightPercent       = 80;
                oneCfg.CustomDayCollection = new List <DayOfWeek>();
                oneCfg.CustomDayCollection.Add(DayOfWeek.Monday);
                oneCfg.CustomDayCollection.Add(DayOfWeek.Tuesday);
                oneCfg.CustomDayCollection.Add(DayOfWeek.Wednesday);
                oneCfg.CustomDayCollection.Add(DayOfWeek.Thursday);
                oneCfg.CustomDayCollection.Add(DayOfWeek.Friday);
                cfg.OneDayConfigList.Add(oneCfg);
                oneCfg.IsConfigEnable = true;
                oneCfg.ScheduleType   = SmartBrightAdjustType.FixBright;
                oneCfg.StartTime      = DateTime.Now;


                OneSmartBrightEasyConfig oneCfg1 = new OneSmartBrightEasyConfig();
                oneCfg1.BrightPercent       = 80;
                oneCfg1.CustomDayCollection = new List <DayOfWeek>();
                oneCfg1.CustomDayCollection.Add(DayOfWeek.Monday);
                oneCfg1.CustomDayCollection.Add(DayOfWeek.Tuesday);
                oneCfg1.CustomDayCollection.Add(DayOfWeek.Wednesday);
                oneCfg1.CustomDayCollection.Add(DayOfWeek.Thursday);
                cfg.OneDayConfigList.Add(oneCfg1);
                oneCfg1.IsConfigEnable = true;
                oneCfg1.ScheduleType   = SmartBrightAdjustType.AutoBright;
                oneCfg1.StartTime      = DateTime.Now;


                OneSmartBrightEasyConfig oneCfg2 = new OneSmartBrightEasyConfig();
                oneCfg2.BrightPercent       = 80;
                oneCfg2.CustomDayCollection = new List <DayOfWeek>();
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Monday);
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Tuesday);
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Wednesday);
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Thursday);
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Friday);
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Saturday);
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Sunday);
                cfg.OneDayConfigList.Add(oneCfg2);
                oneCfg2.IsConfigEnable = true;
                oneCfg2.ScheduleType   = SmartBrightAdjustType.AutoBright;
                oneCfg2.StartTime      = DateTime.Now;
                MonitorAllConfig.Instance().BrightnessConfigList.Add(cfg);
            }
#endif
            _type = type;
            dataGridView_BrightnessConfig.Rows.Clear();
            BrightnessConfig_BindingSource.Clear();
            _brightnessVM.Initialize(sn, cfg);
            BrightnessConfig_BindingSource.ResetBindings(false);
            _brightnessVM.BrightnessConfigList.Sort(CompareBrightnessByTime);
            if (dataGridView_BrightnessConfig.SelectedRows.Count != 0)
            {
                dataGridView_BrightnessConfig.SelectedRows[0].Selected = false;
            }
            if (cfg == null)
            {
                return;
            }
            if (cfg.AutoBrightSetting == null || cfg.AutoBrightSetting.AutoBrightMappingList == null || cfg.AutoBrightSetting.AutoBrightMappingList.Count == 0)
            {
                ConfigState = LightSensorConfigState.NoMapping_State;
            }

            if (cfg.AutoBrightSetting == null || cfg.AutoBrightSetting.UseLightSensorList == null || cfg.AutoBrightSetting.UseLightSensorList.Count == 0)
            {
                ConfigState = LightSensorConfigState.NoSensor_State;
            }
        }
        public void InitialControlConfig(string sn, DisplaySmartBrightEasyConfigBase cfg)
        {
#if test
            if (MonitorAllConfig.Instance().BrightnessConfigList == null || MonitorAllConfig.Instance().BrightnessConfigList.Count == 0)
            {
                MonitorAllConfig.Instance().BrightnessConfigList = new List <DisplaySmartBrightEasyConfig>();
                DisplaySmartBrightEasyConfig cfg = new DisplaySmartBrightEasyConfig();
                cfg.DisplayUDID       = "1405220000041214-00";
                cfg.AutoBrightSetting = new AutoBrightExtendData();
                cfg.OneDayConfigList  = new List <OneSmartBrightEasyConfig>();
                OneSmartBrightEasyConfig oneCfg = new OneSmartBrightEasyConfig();
                oneCfg.BrightPercent       = 80;
                oneCfg.CustomDayCollection = new List <DayOfWeek>();
                oneCfg.CustomDayCollection.Add(DayOfWeek.Monday);
                oneCfg.CustomDayCollection.Add(DayOfWeek.Tuesday);
                oneCfg.CustomDayCollection.Add(DayOfWeek.Wednesday);
                oneCfg.CustomDayCollection.Add(DayOfWeek.Thursday);
                oneCfg.CustomDayCollection.Add(DayOfWeek.Friday);
                cfg.OneDayConfigList.Add(oneCfg);
                oneCfg.IsConfigEnable = true;
                oneCfg.ScheduleType   = SmartBrightAdjustType.FixBright;
                oneCfg.StartTime      = DateTime.Now;


                OneSmartBrightEasyConfig oneCfg1 = new OneSmartBrightEasyConfig();
                oneCfg1.BrightPercent       = 80;
                oneCfg1.CustomDayCollection = new List <DayOfWeek>();
                oneCfg1.CustomDayCollection.Add(DayOfWeek.Monday);
                oneCfg1.CustomDayCollection.Add(DayOfWeek.Tuesday);
                oneCfg1.CustomDayCollection.Add(DayOfWeek.Wednesday);
                oneCfg1.CustomDayCollection.Add(DayOfWeek.Thursday);
                cfg.OneDayConfigList.Add(oneCfg1);
                oneCfg1.IsConfigEnable = true;
                oneCfg1.ScheduleType   = SmartBrightAdjustType.AutoBright;
                oneCfg1.StartTime      = DateTime.Now;


                OneSmartBrightEasyConfig oneCfg2 = new OneSmartBrightEasyConfig();
                oneCfg2.BrightPercent       = 80;
                oneCfg2.CustomDayCollection = new List <DayOfWeek>();
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Monday);
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Tuesday);
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Wednesday);
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Thursday);
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Friday);
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Saturday);
                oneCfg2.CustomDayCollection.Add(DayOfWeek.Sunday);
                cfg.OneDayConfigList.Add(oneCfg2);
                oneCfg2.IsConfigEnable = true;
                oneCfg2.ScheduleType   = SmartBrightAdjustType.AutoBright;
                oneCfg2.StartTime      = DateTime.Now;
                MonitorAllConfig.Instance().BrightnessConfigList.Add(cfg);
            }
#endif
            _currentSn = sn;
            //SetBrightnessValue(MonitorAllConfig.Instance().GetCurrentBrightnessValueBy(_currentSn));
            InitializeViewData(sn, cfg);
            _brightnessVM.BrightnessConfigList.Sort(CompareBrightnessByTime);
            if (cfg == null)
            {
                ConfigState = LightSensorConfigState.NoSensor_State;
                return;
            }
            if (cfg.AutoBrightSetting == null || cfg.AutoBrightSetting.AutoBrightMappingList == null || cfg.AutoBrightSetting.AutoBrightMappingList.Count == 0)
            {
                ConfigState = LightSensorConfigState.NoMapping_State;
            }

            if (cfg.AutoBrightSetting == null || cfg.AutoBrightSetting.UseLightSensorList == null || cfg.AutoBrightSetting.UseLightSensorList.Count == 0)
            {
                ConfigState = LightSensorConfigState.NoSensor_State;
            }
        }