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#

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.Hopper_1_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper_1_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up432()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 1,
HighWeight = basePlcHelper.Hopper_1_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Hopper_1_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down446(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper_2_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper_2_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up446()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 2,
HighWeight = basePlcHelper.Hopper_2_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Hopper_2_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down460(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper_3_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper_3_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up460()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 3,
HighWeight = basePlcHelper.Hopper_3_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Hopper_3_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down474(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper_4_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Hopper_4_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up474()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 4,
HighWeight = basePlcHelper.Hopper_4_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Hopper_4_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down488(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel_1_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel_1_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up488()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 5,
HighWeight = basePlcHelper.Vessel_1_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Vessel_1_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down502(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel_2_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel_2_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up502()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 6,
HighWeight = basePlcHelper.Vessel_2_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Vessel_2_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down516(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel_3_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel_3_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up516()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 7,
HighWeight = basePlcHelper.Vessel_3_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Vessel_3_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down530(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel_4_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel_4_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up530()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 8,
HighWeight = basePlcHelper.Vessel_4_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Vessel_4_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down544(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel_5_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.Vessel_5_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up544()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 9,
HighWeight = basePlcHelper.Vessel_5_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.Vessel_5_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down558(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale_1_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale_1_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up558()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 10,
HighWeight = basePlcHelper.WScale_1_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.WScale_1_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down572(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale_2_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale_2_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up572()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 11,
HighWeight = basePlcHelper.WScale_2_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.WScale_2_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down586(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale_3_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale_3_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up586()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 12,
HighWeight = basePlcHelper.WScale_3_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.WScale_3_LowWeight.NowValue.ToFloat()
};
return view;
}
private static void Down600(WeightSettingView view)
{
if (null != view)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale_4_HighWeight, view.HighWeight);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.WScale_4_LowWeight, view.LowWeight);
}
}
private static WeightSettingView Up600()
{
var basePlcHelper = GetPlcHelper;
WeightSettingView view = new WeightSettingView()
{
Id = 13,
HighWeight = basePlcHelper.WScale_4_HighWeight.NowValue.ToFloat(),
LowWeight = basePlcHelper.WScale_4_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;
}
}
}