using CapMachine.Model.MeterConfig;
using CapMachine.Model;
using HslCommunication.Profinet.Siemens;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using Masuit.Tools;
namespace CapMachine.Wpf.ProPars
{
///
/// 程序解析方法
/// 每个参数的配置是独立的
/// 松芝用
///
public class ProParsSongZhiHelper
{
///
/// 静态的集合信息
///
public static List ListPlcParsData { get; set; }
///
/// //当前的程序开始标记
/// 把地址信息给规范好
///
public static void Start()
{
//取得的PLC步骤数据,提前预设好
ListPlcParsData = new List()
{
new PlcParsData(){ Name="速度",EnName="Speed",Step=150,SetAddressInfo=AddressInfo.OK,Steps=new List(),Ratio=1,Unit="",ValueStartAddress=1008,MinStartAddress=1000,SecStartAddress=1002,CycleStartAddress=1006,SlopConstAddress=1004 },
new PlcParsData(){ Name="排气压力",EnName="ExPress",SetAddressInfo=AddressInfo.OK,Step=150,Steps=new List(),Ratio=1000,Unit="" ,ValueStartAddress=1032,MinStartAddress=1024,SecStartAddress=1026,CycleStartAddress=1030,SlopConstAddress=1028 },
new PlcParsData(){ Name="吸气压力",EnName="InhPress",SetAddressInfo=AddressInfo.OK,Step=150,Steps=new List(),Ratio=1000,Unit="" ,ValueStartAddress=1046,MinStartAddress=1038,SecStartAddress=1040,CycleStartAddress=1044,SlopConstAddress=1042 },
new PlcParsData(){ Name="吸气温度",EnName="InhTemp",SetAddressInfo=AddressInfo.OK,Step=150,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1060,MinStartAddress=1052,SecStartAddress=1054,CycleStartAddress=1058,SlopConstAddress=1056 },
new PlcParsData(){ Name="冷凝器出口水温",EnName="Cond1Temp",SetAddressInfo=AddressInfo.OK,Step=150,Steps=new List(),Ratio=10,Unit="",ValueStartAddress=1074,MinStartAddress=1066,SecStartAddress=1068,CycleStartAddress=1072,SlopConstAddress=1070 },
new PlcParsData(){ Name="吸气混合器温度",EnName="OS2Temp",Step=150,SetAddressInfo=AddressInfo.NoCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1088,MinStartAddress=1080,SecStartAddress=1082 },//??
new PlcParsData(){ Name="HV电压",EnName="HVVol",Step=150,SetAddressInfo=AddressInfo.OK,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1102,MinStartAddress=1094,SecStartAddress=1096,CycleStartAddress=1100,SlopConstAddress=1198 },
new PlcParsData(){ Name="LV电压",EnName="LVVol",Step=150,SetAddressInfo=AddressInfo.NoCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1114,MinStartAddress=1106,SecStartAddress=1108},
new PlcParsData(){ Name="压缩机环境温度",EnName="EnvTemp",Step=150,SetAddressInfo=AddressInfo.OK,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1128,MinStartAddress=1120,SecStartAddress=1122,CycleStartAddress=1126,SlopConstAddress=1124 },
new PlcParsData(){ Name="压缩机环境湿度",EnName="EnvRH",Step=150,SetAddressInfo=AddressInfo.NoCycle,Steps=new List(),Ratio=10,Unit="" ,ValueStartAddress=1142,MinStartAddress=1134,SecStartAddress=1136},
//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="LubePress",Step=100,SetAddressInfo=AddressInfo.NoCycle,Steps=new List(),Ratio=100,Unit="" ,ValueStartAddress=1016,MinStartAddress=1072,SecStartAddress=1074,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="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="OutLock",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1016,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="参数编号",EnName="ParNo",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1018,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="EV",EnName="EV",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1012,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="压缩机使能",EnName="CapEnable",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1010,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="吸排气阀",EnName="InhExhValve",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=1014,MinStartAddress=0,SecStartAddress=0,CycleStartAddress=0 },
new PlcParsData(){ Name="PTC使能",EnName="PTCEnable",Step=100,SetAddressInfo=AddressInfo.NoTimeAndCycle,Steps=new List(),Ratio=1,Unit="" ,ValueStartAddress=0,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步骤信息
/// Cycle暂时不用,默认执行一次,程序的循环次数不进行
///
///
///
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;
}
///
/// 增加一行空的数据,作为终止的执行
///
public static List AddNullData(List plcParsDatas)
{
var NewStep = new ProStep()
{
MeterCond1Temps = new List() { new MeterCond1Temp() { ValueType=ConfigValueType.Constant,} },
MeterCond2Presss=new List() { new MeterCond2Press() { ValueType = ConfigValueType.Constant, } },
MeterCond2Temps= new List() { new MeterCond2Temp() { ValueType = ConfigValueType.Constant, } },
MeterEnvRHs = new List() { new MeterEnvRH() { ValueType = ConfigValueType.Constant, } },
MeterEnvTemps = new List() { new MeterEnvTemp() { ValueType = ConfigValueType.Constant, } },
MeterEVAPExpTemps = new List() { new MeterEVAPExpTemp() { ValueType = ConfigValueType.Constant, } },
MeterExPresss = new List() { new MeterExPress() { ValueType = ConfigValueType.Constant, } },
MeterHVVols = new List() { new MeterHVVol() { ValueType = ConfigValueType.Constant, } },
MeterInhPresss = new List() { new MeterInhPress() { ValueType = ConfigValueType.Constant, } },
MeterInhTemps = new List() { new MeterInhTemp() { ValueType = ConfigValueType.Constant, } },
MeterLubePresss = new List() { new MeterLubePress() { ValueType = ConfigValueType.Constant, } },
MeterLVVols = new List() { new MeterLVVol() { ValueType = ConfigValueType.Constant, } },
MeterOCRs = new List() { new MeterOCR() { ValueType = ConfigValueType.Constant, } },
MeterOS1Temps = new List() { new MeterOS1Temp() { ValueType = ConfigValueType.Constant, } },
MeterOS2Temps = new List() { new MeterOS2Temp() { ValueType = ConfigValueType.Constant, } },
MeterPTCEntTemps = new List() { new MeterPTCEntTemp() { ValueType = ConfigValueType.Constant, } },
MeterPTCFlows = new List() { new MeterPTCFlow() { ValueType = ConfigValueType.Constant, } },
MeterPTCPws = new List() { new MeterPTCPw() { ValueType = ConfigValueType.Constant, } },
MeterSpeeds = new List() { new MeterSpeed() { ValueType = ConfigValueType.Constant, } },
StepNo = 0,
SpeedCycle = 0,
Remark = "结束",
};
return LoadPlcParsData(NewStep, plcParsDatas);
}
///
/// 加载数据到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));
//var Result1 = siemensS7NetStance.Write(itemStep.ValueAddress, (short)(itemStep.Value * item.Ratio),100);
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;
}
}
if (!string.IsNullOrEmpty(itemStep.SlopConstAddress))
{
var Result = siemensS7NetStance.Write(itemStep.SlopConstAddress, (short)itemStep.SlopConst);
if (!Result.IsSuccess)
{
var data1 = 1;
}
}
}
}
//siemensS7NetStance.Write();
}
///
/// 循环次数下载给PLC
///
///
///
public static void LoadProCycleToPlc(SiemensS7Net siemensS7NetStance,int Cycle)
{
siemensS7NetStance.Write("VW230", (short)Cycle);
}
///
/// 单步骤程序解析
/// 单步骤里面包括多个仪表参数的配置信息
///
/// 配置信息
/// 输出的结构信息
///
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);
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()));
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()));
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()));
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()));
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()));
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()));
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()));
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()));
//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()));
//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()));
//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()));
//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()));
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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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);
plcMeterStepCell.SlopConst = 1;
//增加步骤信息
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;
plcMeterStepCell.SlopConst = 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 (Cycle == 1)
{
//只有一次,也就是没有循环,就是直接的步骤,统一返回没有循环固定值
return 0;
}
if (ListCount > 1)
{
//步骤ProStep内部有循环
if (Index == 0)
{
//循环开始
return -1;
}
if (ListCount == Index + 1)
{
//循环结束
return Cycle;
}
//循环中间
return 0;
}
else
{
//步骤ProStep内部就一个步序,没有循环,则直接返回步骤的Cycle
//单步骤,没有循环
return 0;
}
}
///
/// 加载PLC的地址
/// 单元分割
///
///
public static List LoadPlcCellAddress(List plcParsDatas)
{
//单步长度
int StepLengh = 150;
//展开每个控制参数的具体配置
foreach (var itemMeter in plcParsDatas)
{
//循环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;
}
if (itemMeter.SlopConstAddress != 0)//斜率和常值的地址
{
var StepCycleAddress = itemMeter.SlopConstAddress + Index * StepLengh;
itemStep.SlopConstAddress = "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("蒸发混合温度"))
{
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
}
}