private void SetBright(bool isSucess, int value) { lock (_lockObj) { AutoReadResultData auto = _autoReadResultDatas.Find(a => a.SN == _current_ScannerInfo.SN); if (auto != null) { auto.AutoBrightInfo.IsSucess = isSucess; auto.AutoBrightInfo.BrightValue = value; } else { _autoReadResultDatas.Add(new AutoReadResultData() { SN = _current_ScannerInfo.SN, AutoBrightInfo = new AutoGetBrightInfo() { IsSucess = isSucess, BrightValue = value } }); } } }
private void ExecSensorData(PeripheralsLocateInfo perInfos) { lock (_lockObj) { foreach (KeyValuePair <string, List <PeripheralsLocation> > keyValue in _sn_BrightSensors) { if (perInfos.UseablePeripheralList == null || perInfos.UseablePeripheralList.Count == 0) { AutoReadResultData auto = _autoReadResultDatas.Find(a => a.SN == keyValue.Key); if (auto != null) { auto.AutoSensorInfo.IsSucess = false; auto.AutoSensorInfo.SensorValue = 0; } else { _autoReadResultDatas.Add(new AutoReadResultData() { SN = keyValue.Key, AutoSensorInfo = new AutoGetSensorInfo() { IsSucess = false, SensorValue = 0 } }); } continue; } int value = 0; int count = 0; foreach (PeripheralsLocation per in keyValue.Value) { var resultItem = perInfos.UseablePeripheralList.FirstOrDefault(o => o.Equals(per)); if (resultItem != null) { value += (int)resultItem.SensorValue; count++; } } if (count > 0) { AutoReadResultData auto = _autoReadResultDatas.Find(a => a.SN == keyValue.Key); if (auto != null) { auto.AutoSensorInfo.IsSucess = true; auto.AutoSensorInfo.SensorValue = (int)(value / count); } else { _autoReadResultDatas.Add(new AutoReadResultData() { SN = keyValue.Key, AutoSensorInfo = new AutoGetSensorInfo() { IsSucess = true, SensorValue = (int)(value / count) } }); } } } } }