private static Dictionary <int, QuantityValuePair> TempExValuePairs(FrequencyMessage message, IPhysicalCalculator calc, Dictionary <int, decimal> shellTempDic) { var tempExConfigs = SensorConfigManager.GetAllIncludedTempExSensor(); Dictionary <int, QuantityValuePair> tempExValuePairs = new Dictionary <int, QuantityValuePair>(); foreach (var config in tempExConfigs) { var i = config.ChannelIndex - 1; var j = config.SensorIndex - 1; QuantityValuePair pair = new QuantityValuePair(); pair.Orignal = QuantityValuePair.CalculateFrequency(message.Channels[i].Gratings[j]); pair.WaveLength = QuantityValuePair.FrequencyToWavelength(pair.Orignal); var wave = pair.WaveLengthExtension = QuantityValuePair.CalcFrequencyExtension( pair.WaveLength, shellTempDic[i]); var current = SensorConfigManager.GetConfigBy(i + 1, j + 1); //var extension = SensorConfigManager.GetTemperatureExtensionConfig(current); pair.PhysicalValue = QuantityValuePair.CalcPhysicalValue(current, wave, calc); // 温补通道 tempExValuePairs.Add(config.SensorId, pair); } return(tempExValuePairs); }
private static void CalcPhysical(FrequencyMessage message, IPhysicalCalculator calc, PhysicalQuantity instance, Dictionary <int, QuantityValuePair> tempExValuePairs, Dictionary <int, decimal> shellTempDic) { for (var i = 0; i < instance.ChannelValues.Length; i++) { for (var j = 0; j < instance.ChannelValues[i].GratingValues.Length; j++) { var current = SensorConfigManager.GetConfigBy(i + 1, j + 1); if (current != null && tempExValuePairs.ContainsKey(current.SensorId)) { instance.ChannelValues[i].GratingValues[j] = tempExValuePairs[current.SensorId]; } else { instance.ChannelValues[i].GratingValues[j].Orignal = QuantityValuePair.CalculateFrequency(message.Channels[i].Gratings[j]); instance.ChannelValues[i].GratingValues[j].WaveLength = QuantityValuePair.FrequencyToWavelength(instance.ChannelValues[i].GratingValues[j].Orignal); var wave = instance.ChannelValues[i].GratingValues[j].WaveLengthExtension = QuantityValuePair.CalcFrequencyExtension( instance.ChannelValues[i].GratingValues[j].WaveLength, shellTempDic[i]); var extension = SensorConfigManager.GetTemperatureExtensionConfig(current); decimal?exWave = null; if (extension != null && tempExValuePairs.ContainsKey(extension.SensorId)) { exWave = tempExValuePairs[extension.SensorId].WaveLengthExtension; } instance.ChannelValues[i].GratingValues[j].PhysicalValue = QuantityValuePair.CalcPhysicalValue(current, wave, calc, extension, exWave); } } } }