using CapMachine.Model;
using CapMachine.Model.MeterConfig;
using CapMachine.Model.PLCParsModel;
using HslCommunication.Profinet.Siemens;
using Masuit.Tools;
using SharpDX;
using System.Windows.Controls;
namespace CapMachine.Wpf.ProPars
{
///
/// 程序解析方法
/// 每个参数的配置是独立的
///
public class ProParsHelper
{
///
/// 静态的集合信息
///
public static List ListPlcParsData { get; set; }
///
/// //当前的程序开始标记
/// 把地址信息给规范好
///
public static void Start()
{
//取得的PLC步骤数据,提前预设好
ListPlcParsData = new List()
{
new PlcParsData(){ Name="速度",EnName="Speed",Steps=new List(),Ratio=1,Unit="",ValueStartAddress=1006,MinStartAddress=1000,SecStartAddress=1002,CycleStartAddress=1004 },
new PlcParsData(){ Name="COND1温度 ",EnName="Cond1Temp",Step=100,Steps=new List(),Ratio=10,Unit="",ValueStartAddress=1014,MinStartAddress=1068,SecStartAddress=1070,CycleStartAddress=1098 },
new PlcParsData(){ Name="COND2温度",EnName="Cond2Temp",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle, Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1034,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="COND2压力",EnName="Cond2Press",Step=100,Steps=new List(),Ratio=100,Unit="" ,ValueStartAddress=1018,MinStartAddress=1076,SecStartAddress=1078,CycleStartAddress=0 },
new PlcParsData(){ Name="EVAP出口温度",EnName="EVAPExpTemp",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1036,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="排气压力",EnName="ExPress",Step=100,Steps=new List(),Ratio=100,Unit="" ,ValueStartAddress=1008,MinStartAddress=1056,SecStartAddress=1058,CycleStartAddress=1090 },
new PlcParsData(){ Name="HV电压",EnName="HVVol",Step=100,SetAddressInfo=AddressInfo.NoCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1022,MinStartAddress=1080,SecStartAddress=1082,CycleStartAddress=0 },
new PlcParsData(){ Name="吸气压力",EnName="InhPress",Step=100,Steps=new List(),Ratio=100,Unit="" ,ValueStartAddress=1010,MinStartAddress=1060,SecStartAddress=1062,CycleStartAddress=1094 },
new PlcParsData(){ Name="吸气温度",EnName="InhTemp",Step=100,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1012,MinStartAddress=1064,SecStartAddress=1066,CycleStartAddress=1096 },
new PlcParsData(){ Name="润滑油压力",EnName="LubePress",Step=100,SetAddressInfo=AddressInfo.NoCycle,Steps=new List(),Ratio=100,Unit="" ,ValueStartAddress=1016,MinStartAddress=1072,SecStartAddress=1074,CycleStartAddress=0 },
new PlcParsData(){ Name="LV电压",EnName="LVVol",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1024,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="OCR",EnName="OCR",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1020,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="OS1温度",EnName="OS1Temp",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1030,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="OS2温度",EnName="OS2Temp",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1032,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="PTC入口温度",EnName="PTCEntTemp",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1054,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="PTC流量",EnName="PTCFlow",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1052,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="PTC功率",EnName="PTCPw",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1050,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="压缩机环境湿度",EnName="EnvRH",Step=100,SetAddressInfo=AddressInfo.NoCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1028,MinStartAddress=1088,SecStartAddress=1090,CycleStartAddress=0 },
new PlcParsData(){ Name="压缩机环境温度",EnName="EnvTemp",Step=100,SetAddressInfo=AddressInfo.NoCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1026,MinStartAddress=1084,SecStartAddress=1086,CycleStartAddress=0 },
new PlcParsData(){ Name="输出锁定",EnName="OutLock",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1038,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="参数编号",EnName="ParNo",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1040,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="EV",EnName="EV",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1042,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="压缩机使能",EnName="CapEnable",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1044,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="吸排气阀",EnName="InhExhValve",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1046,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="PTC使能",EnName="PTCEnable",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1048,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
//new PlcParsData(){ Name="时间分钟",EnName="TimeMin",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1000,MinStartAddress=XXX,SecStartAddress=XXX,CycleStartAddress=XXX },
//new PlcParsData(){ Name="时间秒",EnName="TimeSec",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1002,MinStartAddress=XXX,SecStartAddress=XXX,CycleStartAddress=XXX },
//new PlcParsData(){ Name="次数",EnName="Cycle",Step=100,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1004,MinStartAddress=XXX,SecStartAddress=XXX,CycleStartAddress=XXX },
};
}
///
/// 获取PLC步骤信息
///
///
///
public static List GetPlcParsData(List proSteps, int Cycle)
{
//装载ListPlcParsData的结构数据
for (int i = 0; i < Cycle; i++)//Proge 大循环
{
foreach (ProStep proStep in proSteps)//ProStep 小循环
{
//每个ProStep步骤里面包含多个参数的设置
ListPlcParsData = LoadPlcParsData(proStep, ListPlcParsData);//内部循环
}
}
//装载地址 VW1000
ListPlcParsData = LoadPlcCellAddress(ListPlcParsData);
//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.ValueAddress))
{
var Result = siemensS7NetStance.Write(itemStep.ValueAddress, (short)(itemStep.Value * item.Ratio));
if (!Result.IsSuccess)
{
var data1 = 1;
}
}
if (!string.IsNullOrEmpty(itemStep.MinAddress))
{
var Result = siemensS7NetStance.Write(itemStep.MinAddress, (short)itemStep.TimeMin);
if (!Result.IsSuccess)
{
var data1 = 1;
}
}
if (!string.IsNullOrEmpty(itemStep.SecAddress))
{
var Result = siemensS7NetStance.Write(itemStep.SecAddress, (short)itemStep.TimeSec);
if (!Result.IsSuccess)
{
var data1 = 1;
}
}
if (!string.IsNullOrEmpty(itemStep.CycleAddress))
{
var Result = siemensS7NetStance.Write(itemStep.CycleAddress, (short)itemStep.Cycle);
if (!Result.IsSuccess)
{
var data1 = 1;
}
}
}
}
//siemensS7NetStance.Write();
}
///
/// 单步骤程序解析
/// 单步骤里面包括多个仪表参数的配置信息
///
/// 配置信息
/// 输出的结构信息
///
private static List LoadPlcParsData(ProStep proStep, List plcParsDatas)
{
if (proStep != null && proStep.MeterSpeeds != null)
{
//速度
GetStepsByMeterSpeeds(proStep.MeterSpeeds, plcParsDatas.Find(a => a.EnName == "Speed")!, proStep.SpeedCycle, plcParsDatas);
GetStepsByMeterCond1Temps(proStep.MeterCond1Temps, plcParsDatas.Find(a => a.EnName == "Cond1Temp")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterCond1Temps!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterCond2Temps(proStep.MeterCond2Temps, plcParsDatas.Find(a => a.EnName == "Cond2Temp")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterCond2Temps!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterCond2Presss(proStep.MeterCond2Presss, plcParsDatas.Find(a => a.EnName == "Cond2Press")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterCond2Presss!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterEVAPExpTemps(proStep.MeterEVAPExpTemps, plcParsDatas.Find(a => a.EnName == "EVAPExpTemp")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterEVAPExpTemps!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterExPresss(proStep.MeterExPresss, plcParsDatas.Find(a => a.EnName == "ExPress")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterExPresss!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterHVVols(proStep.MeterHVVols, plcParsDatas.Find(a => a.EnName == "HVVol")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterHVVols!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterInhPresss(proStep.MeterInhPresss, plcParsDatas.Find(a => a.EnName == "InhPress")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterInhPresss!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterInhTemps(proStep.MeterInhTemps, plcParsDatas.Find(a => a.EnName == "InhTemp")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterInhTemps!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterLubePresss(proStep.MeterLubePresss, plcParsDatas.Find(a => a.EnName == "LubePress")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterLubePresss!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterLVVols(proStep.MeterLVVols, plcParsDatas.Find(a => a.EnName == "LVVol")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterLVVols!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterOCRs(proStep.MeterOCRs, plcParsDatas.Find(a => a.EnName == "OCR")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterOCRs!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterOS1Temps(proStep.MeterOS1Temps, plcParsDatas.Find(a => a.EnName == "OS1Temp")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterOS1Temps!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterOS2Temps(proStep.MeterOS2Temps, plcParsDatas.Find(a => a.EnName == "OS2Temp")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterOS2Temps!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterPTCEntTemps(proStep.MeterPTCEntTemps, plcParsDatas.Find(a => a.EnName == "PTCEntTemp")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterPTCEntTemps!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterPTCFlows(proStep.MeterPTCFlows, plcParsDatas.Find(a => a.EnName == "PTCFlow")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterPTCFlows!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterPTCPws(proStep.MeterPTCPws, plcParsDatas.Find(a => a.EnName == "PTCPw")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterPTCPws!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterEnvRHs(proStep.MeterEnvRHs, plcParsDatas.Find(a => a.EnName == "EnvRH")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterEnvRHs!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
GetStepsByMeterEnvTemps(proStep.MeterEnvTemps, plcParsDatas.Find(a => a.EnName == "EnvTemp")!,
GetCycleBySpeed(proStep.MeterSpeeds, proStep.SpeedCycle, proStep.MeterEnvTemps!.Select(p => new MeterCom { Constant = p.Constant, EndValue = p.EndValue, KeepTime = p.KeepTime, StartValue = p.StartValue, StepNo = p.StepNo, ValueType = p.ValueType }).ToList()));
return plcParsDatas;
}
return plcParsDatas;
}
///
/// 根据速度表时间获取循环的次数
///
///
///
private static int GetCycleBySpeed(List meterSpeeds, int SpeedCycle, List meterComs)
{
if (meterComs != null && meterComs.Count > 0)
{
if (meterComs.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
if (meterSpeeds != null && meterSpeeds.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
var TotalTime = meterSpeeds.Sum(a => a.KeepTime) * SpeedCycle;
var MeterSlopTime = meterComs.Sum(a => a.KeepTime);
if (MeterSlopTime != 0)
{
return TotalTime / MeterSlopTime;
}
else
{
return 0;
}
}
else
{
//速度是常值
var TotalTime = meterSpeeds.FirstOrDefault()!.KeepTime;
var MeterSlopTime = meterComs.Sum(a => a.KeepTime);
if (MeterSlopTime != 0)
{
return TotalTime / MeterSlopTime;
}
else
{
return 0;
}
}
}
else
{
// meterComs 常值 就一步了,没有循环
return 0;
}
}
else
{
return 0;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 Speed
///
///
///
private static PlcParsData GetStepsByMeterSpeeds(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle, List ListPlcParsData)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterSpeedsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterSpeedsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
//跟速度绑定的数据 装载 输出锁定、参数编号、EV、压缩机使能、吸排气阀、PTC使能
var FindOutLock = ListPlcParsData.Find(a => a.Name.Equals("输出锁定"));
var OutLockData = plcMeterStepCell.DeepClone();
OutLockData.Value = Convert.ToDouble(item.OutLock);
FindOutLock.Steps.Add(OutLockData);
var FindParNo = ListPlcParsData.Find(a => a.Name.Equals("参数编号"));
var ParNoData = plcMeterStepCell.DeepClone();
ParNoData.Value = Convert.ToDouble(item.ParNo);
FindParNo.Steps.Add(ParNoData);
var FindEV = ListPlcParsData.Find(a => a.Name.Equals("EV"));
var EVData = plcMeterStepCell.DeepClone();
EVData.Value = Convert.ToDouble(item.Ev);
FindEV.Steps.Add(EVData);
var FindCapEnable = ListPlcParsData.Find(a => a.Name.Equals("压缩机使能"));
var CapEnableData = plcMeterStepCell.DeepClone();
CapEnableData.Value = Convert.ToDouble(item.CapEnable);
FindCapEnable.Steps.Add(CapEnableData);
var FindInhExhValve = ListPlcParsData.Find(a => a.Name.Equals("吸排气阀"));
var InhExhValveData = plcMeterStepCell.DeepClone();
InhExhValveData.Value = Convert.ToDouble(item.InhExhValve);
FindInhExhValve.Steps.Add(InhExhValveData);
var FindPTCEnable = ListPlcParsData.Find(a => a.Name.Equals("PTC使能"));
var PTCEnableData = plcMeterStepCell.DeepClone();
PTCEnableData.Value = Convert.ToDouble(item.PTCEnable);
FindPTCEnable.Steps.Add(PTCEnableData);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
//跟速度绑定的数据 装载 输出锁定、参数编号、EV、压缩机使能、吸排气阀、PTC使能
var FindOutLock = ListPlcParsData.Find(a => a.Name.Equals("输出锁定"));
var OutLockData = plcMeterStepCell.DeepClone();
OutLockData.Value = Convert.ToDouble(Data.OutLock);
FindOutLock.Steps.Add(OutLockData);
var FindParNo = ListPlcParsData.Find(a => a.Name.Equals("参数编号"));
var ParNoData = plcMeterStepCell.DeepClone();
ParNoData.Value = Convert.ToDouble(Data.ParNo);
FindParNo.Steps.Add(ParNoData);
var FindEV = ListPlcParsData.Find(a => a.Name.Equals("EV"));
var EVData = plcMeterStepCell.DeepClone();
EVData.Value = Convert.ToDouble(Data.Ev);
FindEV.Steps.Add(EVData);
var FindCapEnable = ListPlcParsData.Find(a => a.Name.Equals("压缩机使能"));
var CapEnableData = plcMeterStepCell.DeepClone();
CapEnableData.Value = Convert.ToDouble(Data.CapEnable);
FindCapEnable.Steps.Add(CapEnableData);
var FindInhExhValve = ListPlcParsData.Find(a => a.Name.Equals("吸排气阀"));
var InhExhValveData = plcMeterStepCell.DeepClone();
InhExhValveData.Value = Convert.ToDouble(Data.InhExhValve);
FindInhExhValve.Steps.Add(InhExhValveData);
var FindPTCEnable = ListPlcParsData.Find(a => a.Name.Equals("PTC使能"));
var PTCEnableData = plcMeterStepCell.DeepClone();
PTCEnableData.Value = Convert.ToDouble(Data.PTCEnable);
FindPTCEnable.Steps.Add(PTCEnableData);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 Cond1Temp
///
///
///
private static PlcParsData GetStepsByMeterCond1Temps(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterCond1TempsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterCond1TempsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 Cond2Temp
///
///
///
private static PlcParsData GetStepsByMeterCond2Temps(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterCond2TempsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterCond2TempsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 Cond2Press
///
///
///
private static PlcParsData GetStepsByMeterCond2Presss(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterCond2PresssOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterCond2PresssOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 EVAPExpTemp
///
///
///
private static PlcParsData GetStepsByMeterEVAPExpTemps(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterEVAPExpTempsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterEVAPExpTempsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 ExPress
///
///
///
private static PlcParsData GetStepsByMeterExPresss(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterExPresssOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterExPresssOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 HVVol
///
///
///
private static PlcParsData GetStepsByMeterHVVols(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterHVVolsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterHVVolsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 InhPress
///
///
///
private static PlcParsData GetStepsByMeterInhPresss(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterInhPresssOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterInhPresssOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 InhTemp
///
///
///
private static PlcParsData GetStepsByMeterInhTemps(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterInhTempsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterInhTempsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 LubePress
///
///
///
private static PlcParsData GetStepsByMeterLubePresss(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterLubePresssOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterLubePresssOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 LVVol
///
///
///
private static PlcParsData GetStepsByMeterLVVols(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterLVVolsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterLVVolsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 OCR
///
///
///
private static PlcParsData GetStepsByMeterOCRs(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterOCRsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterOCRsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 OS1Temp
///
///
///
private static PlcParsData GetStepsByMeterOS1Temps(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterOS1TempsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterOS1TempsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 OS2Temp
///
///
///
private static PlcParsData GetStepsByMeterOS2Temps(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterOS2TempsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterOS2TempsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 PTCEntTemp
///
///
///
private static PlcParsData GetStepsByMeterPTCEntTemps(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterPTCEntTempsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterPTCEntTempsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 PTCFlow
///
///
///
private static PlcParsData GetStepsByMeterPTCFlows(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterPTCFlowsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterPTCFlowsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 PTCPw
///
///
///
private static PlcParsData GetStepsByMeterPTCPws(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterPTCPwsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterPTCPwsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 EnvRH
///
///
///
private static PlcParsData GetStepsByMeterEnvRHs(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterEnvRHsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterEnvRHsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 单步(内部多个小步骤)解析 单个仪表参数
/// 获取 步骤信息 EnvTemp
///
///
///
private static PlcParsData GetStepsByMeterEnvTemps(ICollection? MeterDatas, PlcParsData PLCParsData, int Cycle)
{
if (MeterDatas != null && MeterDatas.Count > 0)
{
if (MeterDatas.Where(a => a.ValueType == ConfigValueType.Slope).Count() > 0)
{
//排序
var MeterEnvTempsOrder = MeterDatas.OrderBy(a => a.StepNo).ToList();
var ListCount = MeterDatas.Count;
var Index = 0;
foreach (var item in MeterEnvTempsOrder)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = item.EndValue;
plcMeterStepCell.TimeMin = GetKeepTimeMin(item.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(item.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = GetCycleCount(Cycle, Index, ListCount);
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
Index++;
}
return PLCParsData;
}
else//常值
{
var Data = MeterDatas.Where(a => a.ValueType == ConfigValueType.Constant).FirstOrDefault();
if (Data != null)
{
PlcMeterStepCell plcMeterStepCell = new PlcMeterStepCell();
plcMeterStepCell.Value = Data.Constant;
plcMeterStepCell.TimeMin = GetKeepTimeMin(Data.KeepTime);
plcMeterStepCell.TimeSec = GetKeepTimeSec(Data.KeepTime);
plcMeterStepCell.Step = GetStep(PLCParsData);
plcMeterStepCell.Cycle = 0;
//增加步骤信息
PLCParsData.Steps.Add(plcMeterStepCell);
return PLCParsData;
}
return PLCParsData;
}
}
else
{
return PLCParsData;
}
}
///
/// 获取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;
//switch (itemMeter.SetAddressInfo)
//{
// case AddressInfo.OK:
// break;
// case AddressInfo.NoCycle:
// break;
// case AddressInfo.NoTimeAndCycle:
// break;
// default:
// break;
//}
//循环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
}
}