using CapMachine.Model; using CapMachine.Model.PLCParsModel; using CapMachine.Wpf.Dtos; using HslCommunication.Profinet.Siemens; using System.Windows.Controls; namespace CapMachine.Wpf.ProPars { /// /// 程序解析方法 Quick /// public class ProParsHelperQuick { /// /// 获取PLC步骤信息 /// /// /// public static void GetPlcParsData(List proSteps, SiemensS7Net siemensS7NetStance) { //取得的PLC步骤数据,提前预设好 List ListPlcParsDataQuick = new List() { new PlcParsDataQuick(){ Name="速度",EnName="Speed",Step=100,Steps=new List(),Ratio=1,Unit="",ValueStartAddress=1006, }, new PlcParsDataQuick(){ Name="COND1温度 ",EnName="Cond1Temp",Step=100,Steps=new List(),Ratio=10,Unit="",ValueStartAddress=1014, }, new PlcParsDataQuick(){ Name="COND2温度",EnName="Cond2Temp",Step=100,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1034, }, new PlcParsDataQuick(){ Name="COND2压力",EnName="Cond2Press",Step=100,Steps=new List(),Ratio=100,Unit="" ,ValueStartAddress=1018, }, new PlcParsDataQuick(){ Name="EVAP出口温度",EnName="EVAPExpTemp",Step=100,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1036, }, new PlcParsDataQuick(){ Name="排气压力",EnName="ExPress",Step=100,Steps=new List(),Ratio=100,Unit="" ,ValueStartAddress=1008, }, new PlcParsDataQuick(){ Name="HV电压",EnName="HVVol",Step=100,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1022, }, new PlcParsDataQuick(){ Name="吸气压力",EnName="InhPress",Step=100,Steps=new List(),Ratio=100,Unit="" ,ValueStartAddress=1010,}, new PlcParsDataQuick(){ Name="吸气温度",EnName="InhTemp",Step=100,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1012, }, new PlcParsDataQuick(){ Name="润滑油压力",EnName="LubePress",Step=100,Steps=new List(),Ratio=100,Unit="" ,ValueStartAddress=1016, }, new PlcParsDataQuick(){ Name="LV电压",EnName="LVVol",Step=100,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1024, }, new PlcParsDataQuick(){ Name="OCR",EnName="OCR",Step=100,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1020, }, new PlcParsDataQuick(){ Name="OS1温度",EnName="OS1Temp",Step=100,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1030, }, new PlcParsDataQuick(){ Name="OS2温度",EnName="OS2Temp",Step=100,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1032, }, new PlcParsDataQuick(){ Name="PTC入口温度",EnName="PTCEntTemp",Step=100,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1054, }, new PlcParsDataQuick(){ Name="PTC流量",EnName="PTCFlow",Step=100,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1052, }, new PlcParsDataQuick(){ Name="PTC功率",EnName="PTCPw",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1050, }, new PlcParsDataQuick(){ Name="压缩机环境湿度",EnName="EnvRH",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1028, }, new PlcParsDataQuick(){ Name="压缩机环境温度",EnName="EnvTemp",Step=100,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1026, }, new PlcParsDataQuick(){ Name="输出锁定",EnName="OutLock",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1038, }, new PlcParsDataQuick(){ Name="参数编号",EnName="ParNo",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1040, }, new PlcParsDataQuick(){ Name="EV",EnName="EV",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1042, }, new PlcParsDataQuick(){ Name="压缩机使能",EnName="CapEnable",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1044, }, new PlcParsDataQuick(){ Name="吸排气阀",EnName="InhExhValve",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1046, }, new PlcParsDataQuick(){ Name="PTC使能",EnName="PTCEnable",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1048, }, new PlcParsDataQuick(){ Name="时间分钟",EnName="TimeMin",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1000, }, new PlcParsDataQuick(){ Name="时间秒",EnName="TimeSec",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1002, }, new PlcParsDataQuick(){ Name="次数",EnName="Cycle",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1004, }, //new PlcParsData(){ Name="加热器功率",EnName="HeatPw",Steps=new List(),Ratio=1,Unit="" }, //new PlcParsData(){ Name="加热器流量",EnName="HeatFlow",Steps=new List(),Ratio=1,Unit="" }, //new PlcParsData(){ Name="加热器入口水温",EnName="HeatInWatTemp",Steps=new List(),Ratio=1,Unit="" }, }; var CurStep = 1; foreach (QuickMeterStepDto proStep in proSteps)//小循环 { //每个步骤里面包含多个参数的设置 ListPlcParsDataQuick = LoadPlcParsData(proStep, ListPlcParsDataQuick, CurStep);//内部循环 CurStep++; } LoadDataToPLC(siemensS7NetStance, ListPlcParsDataQuick); //装载地址 VW1000 //var datga = LoadPlcBlockAddress(ListPlcParsData, 1000); //return ListPlcParsData; } /// /// 加载数据到PLC /// public static void LoadDataToPLC(SiemensS7Net siemensS7NetStance, List plcParsDatas) { foreach (var item in plcParsDatas) { foreach (var itemStep in item.Steps) { if (!string.IsNullOrEmpty(itemStep.Address)) { var Result = siemensS7NetStance.Write(itemStep.Address, (short)(itemStep.Value * item.Ratio)); //if (item.Name.Contains("压力")) //{ // var Result = siemensS7NetStance.Write(itemStep.Address, (short)itemStep.Value * 100); // if (!Result.IsSuccess) // { // } //} //else if (item.Name.Contains("温度")) //{ // var Result = siemensS7NetStance.Write(itemStep.Address, (short)itemStep.Value * 10); // if (!Result.IsSuccess) // { // } //} //else if (item.Name.Contains("电压")) //{ // var Result = siemensS7NetStance.Write(itemStep.Address, (short)itemStep.Value * 10); // if (!Result.IsSuccess) // { // } //} //else if (item.Name.Contains("湿度")) //{ // var Result = siemensS7NetStance.Write(itemStep.Address, (short)itemStep.Value * 10); // if (!Result.IsSuccess) // { // } //} //else //{ // var Result = siemensS7NetStance.Write(itemStep.Address, (short)itemStep.Value); // if (!Result.IsSuccess) // { // } //} } } } var data = 1; //siemensS7NetStance.Write(); } /// /// 单步骤程序解析 /// 单步骤里面包括多个仪表参数的配置信息 /// /// /// /// private static List LoadPlcParsData(QuickMeterStepDto proStep, List plcParsDatas, int CurStep) { if (proStep != null) { foreach (var item in plcParsDatas) { switch (item.EnName) { case "Speed": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.Speed, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "Cond1Temp": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.Cond1Temp, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "Cond2Temp": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.Cond2Temp, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "Cond2Press": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.Cond2Press, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "EVAPExpTemp": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.EVAPExpTemp, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "ExPress": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.ExPress, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "HVVol": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.HVVol, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "InhPress": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.InhPress, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "InhTemp": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.InhTemp, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "LubePress": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.LubePress, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "LVVol": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.LVVol, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "OCR": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.OCR, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "OS1Temp": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.OS1Temp, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "OS2Temp": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.OS2Temp, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "PTCEntTemp": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.PTCEntTemp, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "PTCFlow": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.PTCFlow, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "PTCPw": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.PTCPw, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "EnvRH": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.EnvRH, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "EnvTemp": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.EnvTemp, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "OutLock": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.OutLock == true ? 1 : 0, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "ParNo": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.ParNo, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "EV": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.EV, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "CapEnable": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.CapEnable == true ? 1 : 0, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "InhExhValve": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.InhExhValve == true ? 1 : 0, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "PTCEnable": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.PTCEnable == true ? 1 : 0,Address= GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "TimeMin": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.TimeMin, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "TimeSec": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.TimeSec, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; case "Cycle": item.Steps.Add(new PlcMeterStepCellQuick() { Step = CurStep, Value = proStep.Cycle, Address = GetAddress(item.ValueStartAddress, CurStep, item.Step) }); break; default: break; } } return plcParsDatas; } return plcParsDatas; } private static string GetAddress(int startAddress, int StepNo, int Step) { var CurStepValue = startAddress + (StepNo - 1) * Step; return "V" + CurStepValue.ToString(); } /// /// 获取KeepTime分钟信息 /// /// private static int GetKeepTimeMin(int keeptime) { return keeptime / 60; } /// /// 获取KeepTime 秒信息 /// /// private static int GetKeepTimeSec(int keeptime) { return keeptime % 60; } /// /// 获取步骤信息 /// /// /// /// private static int GetStep(PlcParsData plcParsData) { if (plcParsData.Steps != null && plcParsData.Steps.Any()) { return plcParsData.Steps.Count + 1; } else { return 1; } } /// /// 获取Cycle信息 /// /// private static int GetCycleCount(int Cycle, int Index, int ListCount) { if (ListCount > 1) { //步骤ProStep内部有循环 if (Index == 0) { //循环开始 return -1; } if (ListCount == Index + 1) { //循环结束 return Cycle; } //循环中间 return 0; } else { //步骤ProStep内部就一个步序,没有循环,则直接返回步骤的Cycle //单步骤,没有循环 return 0; } } /// /// 加载PLC的地址 /// 单元分割 /// /// private static List LoadPlcCellAddress(List plcParsDatas) { //单步长度 int StepLengh = 100; foreach (var itemMeter in plcParsDatas) { //var Stepaddress = StartAddress + Index * StepLengh; //循环Index int Index = 0; //循环内部的步骤信息 foreach (var itemStep in itemMeter.Steps.OrderBy(a => a.Step)) { if (itemMeter.ValueStartAddress != 0) { var StepValueAddress = itemMeter.ValueStartAddress + Index * StepLengh; itemStep.ValueAddress = "V" + StepValueAddress; } if (itemMeter.MinStartAddress != 0) { var StepMinAddress = itemMeter.MinStartAddress + Index * StepLengh; itemStep.MinAddress = "V" + StepMinAddress; } if (itemMeter.SecStartAddress != 0) { var StepSecAddress = itemMeter.SecStartAddress + Index * StepLengh; itemStep.SecAddress = "V" + StepSecAddress; } if (itemMeter.CycleStartAddress != 0) { var StepCycleAddress = itemMeter.CycleStartAddress + Index * StepLengh; itemStep.CycleAddress = "V" + StepCycleAddress; } Index++; } } return plcParsDatas; } /// /// 加载PLC块地址信息 /// /// /// /// private static List LoadPlcBlockAddress(List plcParsDatas, int start) { //开始地址 int StartAddress = start; //单步长度 int StepLengh = 100; //循环Index int Index = 0; //数据集合 List BlockDatas = new List(); foreach (var item in plcParsDatas) { var StepAddress = StartAddress + Index * StepLengh; //每个步骤封装成一个PlcBlockData short[] shorts = new short[19];//看有多少个字段 //shorts[item.Speed!.Index - 1] = (short)item.Speed!.Value!; //shorts[item.Cond1Temp!.Index - 1] = (short)item.Cond1Temp!.Value!; //shorts[item.Cond2Temp!.Index - 1] = (short)item.Cond2Temp!.Value!; //shorts[item.CondPress!.Index - 1] = (short)item.CondPress!.Value!; //shorts[item.EVAPExpTemp!.Index - 1] = (short)item.EVAPExpTemp!.Value!; //shorts[item.ExPress!.Index - 1] = (short)item.ExPress!.Value!; //shorts[item.HVVol!.Index - 1] = (short)item.HVVol!.Value!; //shorts[item.InhPress!.Index - 1] = (short)item.InhPress!.Value!; //shorts[item.InhTemp!.Index - 1] = (short)item.InhTemp!.Value!; //shorts[item.LoPress!.Index - 1] = (short)item.LoPress!.Value!; //shorts[item.LVVol!.Index - 1] = (short)item.LVVol!.Value!; //shorts[item.OCR!.Index - 1] = (short)item.OCR!.Value!; //shorts[item.OS1Temp!.Index - 1] = (short)item.OS1Temp!.Value!; //shorts[item.OS2Temp!.Index - 1] = (short)item.OS2Temp!.Value!; //shorts[item.PTCEntTemp!.Index - 1] = (short)item.PTCEntTemp!.Value!; //shorts[item.PTCFlow!.Index - 1] = (short)item.PTCFlow!.Value!; //shorts[item.PTCPw!.Index - 1] = (short)item.PTCPw!.Value!; //shorts[item.TestBoxRH!.Index - 1] = (short)item.TestBoxRH!.Value!; //shorts[item.TestBoxTemp!.Index - 1] = (short)item.TestBoxTemp!.Value!; BlockDatas.Add(new PlcBlockData() { StartAddress = "VW" + StepAddress.ToString(), ArrValue = shorts }); Index++; } return BlockDatas; } /// /// 根据名称获取Index信息 /// /// public static int GetIndexByName(DataGridColumn dataGridColumn) { var headerText = (dataGridColumn.Header as TextBlock).Text; if (headerText.Contains("COND1温度 ")) { return 0; } else if (headerText.Contains("COND2温度")) { return 1; } else if (headerText.Contains("COND2压力")) { return 2; } else if (headerText.Contains("EVAP出口温度")) { return 3; } else if (headerText.Contains("排气压力")) { return 4; } else if (headerText.Contains("HV电压")) { return 5; } else if (headerText.Contains("吸气压力")) { return 6; } else if (headerText.Contains("吸气温度")) { return 7; } else if (headerText.Contains("润滑油压力")) { return 8; } else if (headerText.Contains("LV电压")) { return 9; } else if (headerText.Contains("OCR")) { return 10; } else if (headerText.Contains("OS1温度")) { return 11; } else if (headerText.Contains("OS2温度")) { return 12; } else if (headerText.Contains("PTC入口温度")) { return 13; } else if (headerText.Contains("PTC流量")) { return 14; } else if (headerText.Contains("PTC功率")) { return 15; } else if (headerText.Contains("试验箱湿度")) { return 16; } else if (headerText.Contains("试验箱温度")) { return 17; } else { return 0; } } #region 获取数据 /// /// 获取 MeterCellByMeterCond1Temps /// /// private static double GetMeterCellByMeterCond1Temps(ICollection meterCond1Temps, int Index) { try { if (meterCond1Temps.Count() >= (Index + 1)) { return meterCond1Temps.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterCond1Temps.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterCond2Temps /// /// private static double GetMeterCellByMeterCond2Temps(ICollection meterCond2Temps, int Index) { try { if (meterCond2Temps.Count() >= (Index + 1)) { return meterCond2Temps.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterCond2Temps.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterCondPresss /// /// private static double GetMeterCellByMeterCondPresss(ICollection meterCondPresss, int Index) { try { if (meterCondPresss.Count() >= (Index + 1)) { return meterCondPresss.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterCondPresss.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterEVAPExpTemps /// /// private static double GetMeterCellByMeterEVAPExpTemps(ICollection meterEVAPExpTemps, int Index) { try { if (meterEVAPExpTemps.Count() >= (Index + 1)) { return meterEVAPExpTemps.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterEVAPExpTemps.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterExPresss /// /// private static double GetMeterCellByMeterExPresss(ICollection meterExPresss, int Index) { try { if (meterExPresss.Count() >= (Index + 1)) { return meterExPresss.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterExPresss.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterHVVols /// /// private static double GetMeterCellByMeterHVVols(ICollection meterHVVols, int Index) { try { if (meterHVVols.Count() >= (Index + 1)) { return meterHVVols.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterHVVols.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterInhPresss /// /// private static double GetMeterCellByMeterInhPresss(ICollection meterInhPresss, int Index) { try { if (meterInhPresss.Count() >= (Index + 1)) { return meterInhPresss.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterInhPresss.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterInhTemps /// /// private static double GetMeterCellByMeterInhTemps(ICollection meterInhTemps, int Index) { try { if (meterInhTemps.Count() >= (Index + 1)) { return meterInhTemps.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterInhTemps.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterLoPresss /// /// private static double GetMeterCellByMeterLoPresss(ICollection meterLoPresss, int Index) { try { if (meterLoPresss.Count() >= (Index + 1)) { return meterLoPresss.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterLoPresss.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterLVVols /// /// private static double GetMeterCellByMeterLVVols(ICollection meterLVVols, int Index) { try { if (meterLVVols.Count() >= (Index + 1)) { return meterLVVols.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterLVVols.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterOCRs /// /// private static double GetMeterCellByMeterOCRs(ICollection meterOCRs, int Index) { try { if (meterOCRs.Count() >= (Index + 1)) { return meterOCRs.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterOCRs.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterOS1Temps /// /// private static double GetMeterCellByMeterOS1Temps(ICollection meterOS1Temps, int Index) { try { if (meterOS1Temps.Count() >= (Index + 1)) { return meterOS1Temps.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterOS1Temps.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterOS2Temps /// /// private static double GetMeterCellByMeterOS2Temps(ICollection meterOS2Temps, int Index) { try { if (meterOS2Temps.Count() >= (Index + 1)) { return meterOS2Temps.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterOS2Temps.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterPTCEntTemps /// /// private static double GetMeterCellByMeterPTCEntTemps(ICollection meterPTCEntTemps, int Index) { try { if (meterPTCEntTemps.Count() >= (Index + 1)) { return meterPTCEntTemps.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterPTCEntTemps.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterPTCFlows /// /// private static double GetMeterCellByMeterPTCFlows(ICollection meterPTCFlows, int Index) { try { if (meterPTCFlows.Count() >= (Index + 1)) { return meterPTCFlows.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterPTCFlows.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterPTCPws /// /// private static double GetMeterCellByMeterPTCPws(ICollection meterPTCPws, int Index) { try { if (meterPTCPws.Count() >= (Index + 1)) { return meterPTCPws.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterPTCPws.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterTestBoxRHs /// /// private static double GetMeterCellByMeterTestBoxRHs(ICollection meterTestBoxRHs, int Index) { try { if (meterTestBoxRHs.Count() >= (Index + 1)) { return meterTestBoxRHs.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterTestBoxRHs.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } /// /// 获取 MeterCellByMeterTestBoxTemps /// /// private static double GetMeterCellByMeterTestBoxTemps(ICollection meterTestBoxTemps, int Index) { try { if (meterTestBoxTemps.Count() >= (Index + 1)) { return meterTestBoxTemps.ToList()[Index].EndValue; } //找不到的话,则返回第一个值 return meterTestBoxTemps.FirstOrDefault()!.EndValue; } catch (Exception ex) { return 0.0; } } #endregion } }