You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjWeight/WeightSettingPlc.cs

429 lines
14 KiB
C#

1 year ago
using System.Collections.Generic;
using DevExpress.PivotGrid.CriteriaVisitors;
namespace Mesnac.Action.ChemicalWeighing.LjWeight
{
public class WeightSettingPlc
{
private static BasePlcHelper GetPlcHelper => BasePlcHelper.Instance;
private static void Down432(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper1_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper1_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up432()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 1,
HighWeight = basePlcHelper.Hopper1_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Hopper1_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down446(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper2_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper2_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up446()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 2,
HighWeight = basePlcHelper.Hopper2_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Hopper2_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down460(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper3_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper3_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up460()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 3,
HighWeight = basePlcHelper.Hopper3_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Hopper3_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down474(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper4_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper4_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up474()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 4,
HighWeight = basePlcHelper.Hopper4_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Hopper4_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down488(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel1_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel1_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up488()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 5,
HighWeight = basePlcHelper.Vessel1_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Vessel1_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down502(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel2_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel2_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up502()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 6,
HighWeight = basePlcHelper.Vessel2_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Vessel2_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down516(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel3_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel3_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up516()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 7,
HighWeight = basePlcHelper.Vessel3_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Vessel3_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down530(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel4_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel4_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up530()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 8,
HighWeight = basePlcHelper.Vessel4_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Vessel4_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down544(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel5_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel5_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up544()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 9,
HighWeight = basePlcHelper.Vessel5_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Vessel5_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down558(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale1_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale1_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up558()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 10,
HighWeight = basePlcHelper.WScale1_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.WScale1_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down572(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale2_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale2_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up572()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 11,
HighWeight = basePlcHelper.WScale2_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.WScale2_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down586(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale3_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale3_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up586()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 12,
HighWeight = basePlcHelper.WScale3_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.WScale3_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down600(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale4_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale4_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up600()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 13,
HighWeight = basePlcHelper.WScale4_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.WScale4_LowWeight.NowValue.ToFloat()
};
return view;
}
public static void DownToPlc(IEnumerable<WeightSettingView> views)
{
foreach (var v in views)
{
switch (v.Id)
{
case 1:
Down432(v);
break;
case 2:
Down446(v);
break;
case 3:
Down460(v);
break;
case 4:
Down474(v);
break;
case 5:
Down488(v);
break;
case 6:
Down502(v);
break;
case 7:
Down516(v);
break;
case 8:
Down530(v);
break;
case 9:
Down544(v);
break;
case 10:
Down558(v);
break;
case 11:
Down572(v);
break;
case 12:
Down586(v);
break;
case 13:
Down600(v);
break;
}
}
}
public static WeightSettingView UpFromPlc(int id)
{
switch (id)
{
case 1:
return Up432();
case 2:
return Up446();
case 3:
return Up460();
case 4:
return Up474();
case 5:
return Up488();
case 6:
return Up502();
case 7:
return Up516();
case 8:
return Up530();
case 9:
return Up544();
case 10:
return Up558();
case 11:
return Up572();
case 12:
return Up586();
case 13:
return Up600();
}
return null;
}
public static IEnumerable<WeightSettingView> UpFromPlc()
{
ICollection<WeightSettingView> ls = new List<WeightSettingView>();
ls.Add(Up432());
ls.Add(Up446());
ls.Add(Up460());
ls.Add(Up474());
ls.Add(Up488());
ls.Add(Up502());
ls.Add(Up516());
ls.Add(Up530());
ls.Add(Up544());
ls.Add(Up558());
ls.Add(Up572());
ls.Add(Up586());
ls.Add(Up600());
return ls;
}
}
}