using System;
using System.Collections.Generic;
using System.Linq;
using DataBlockHelper.DBHelpers;
using DataBlockHelper.DbWrite;
using DataBlockHelper.Entity.DB2107Entity;
using DevExpress.XtraGauges.Core.Model;
using DevExpress.XtraRichEdit.API.Layout;
namespace Mesnac.Action.ChemicalWeighing.LjPressure
{
public class PressurePLC
{
#region 压送秤A气源压力 DBW12 数组Id=1
private void DownDbw12(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(16,view);
}
}
PlcWriteUtil plcWriter = new PlcWriteUtil();
private void DownDbPressureSettingView(int start, PressureSettingView view)
{
int begin = start;
int end = begin + 4;
plcWriter.Write(PlcDbEnum.Db2107, $"{begin}.0", PlcDbType.PlcFloat, view.LowLimit);
plcWriter.Write(PlcDbEnum.Db2107, $"{end}.0", PlcDbType.PlcFloat, view.HighLimit);
}
DB2107Helper _db2107Helper = new DB2107Helper();
private PressureSettingView UpDbw12()
{
PressureSettingView view = new PressureSettingView();
var v1 = _db2107Helper.Pressure.MainPress_V1;
view.Id = 1;
view.LowLimit = v1.LowLimit;
view.HighLimit = v1.HighLimit;
return view;
}
#endregion
private void DownDbw26(PressureSettingView view)
{
// PlcWriter plcWriter=new PlcWriter();
if (view != null)
{
DownDbPressureSettingView(30, view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.topPressure_V1_LowLimit, view.LowLimit);
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.topPressure_V1_HighLimit, view.HighLimit);
}
}
private PressureSettingView UpDbw26()
{
var v1 = _db2107Helper.Pressure.TopPressure_V1;
return GetSettingView(2, v1);
}
public PressureSettingView GetSettingView(int id, Pressure_HMI v1)
{
PressureSettingView view = new PressureSettingView();
view.Id = id;
view.LowLimit = v1.LowLimit;
view.HighLimit = v1.HighLimit;
return view;
}
private void DownDbw40(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(44, view);
}
}
private PressureSettingView UpDbw40()
{
PressureSettingView view = GetSettingView(3, _db2107Helper.Pressure.LinePressure_V1);
//view.Id = 3;
//view.LowLimit = basePlcHelper.linePressure_V1_LowLimit.NowValue.ToFloat();
//view.HighLimit = basePlcHelper.linePressure_V1_HighLimit.NowValue.ToFloat();
return view;
}
private void DownDbw54(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(58, view);
}
}
private PressureSettingView UpDbw54()
{
PressureSettingView view = GetSettingView(4, _db2107Helper.Pressure.MainPress_V2);
//view.Id = 4;
//view.LowLimit = basePlcHelper.mainPress_V2_LowLimit.NowValue.ToFloat();
//view.HighLimit = basePlcHelper.mainPress_V2_HighLimit.NowValue.ToFloat();
//view.Alarm = basePlcHelper.mainPress_V2_Alarm.NowValue.ToInt();
return view;
}
private void DownDbw68(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(72, view);
}
}
private PressureSettingView UpDbw68()
{
PressureSettingView view = GetSettingView(5, _db2107Helper.Pressure.TopPressure_V2);
//view.Id = 5;
//view.LowLimit = basePlcHelper.topPressure_V2_LowLimit.NowValue.ToFloat();
//view.HighLimit = basePlcHelper.topPressure_V2_HighLimit.NowValue.ToFloat();
//view.Alarm = basePlcHelper.topPressure_V2_Alarm.NowValue.ToInt();
return view;
}
private void DownDbw82(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(86, view);
}
}
private PressureSettingView UpDbw82()
{
PressureSettingView view = GetSettingView(6, _db2107Helper.Pressure.LinePressure_V2);
//view.Id = 6;
//view.LowLimit = basePlcHelper.linePressure_V2_LowLimit.NowValue.ToFloat();
//view.HighLimit = basePlcHelper.linePressure_V2_HighLimit.NowValue.ToFloat();
//view.Alarm = basePlcHelper.linePressure_V2_Alarm.NowValue.ToInt();
return view;
}
private void DownDbw96(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(100, view);
}
}
private PressureSettingView UpDbw96()
{
PressureSettingView view = GetSettingView(7, _db2107Helper.Pressure.MainPress_V3);
//view.Id = 7;
//view.LowLimit = basePlcHelper.mainPress_V3_LowLimit.NowValue.ToFloat();
//view.HighLimit = basePlcHelper.mainPress_V3_HighLimit.NowValue.ToFloat();
//view.Alarm = basePlcHelper.mainPress_V3_Alarm.NowValue.ToInt();
return view;
}
private void DownDbw110(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(114, view);
}
}
private PressureSettingView UpDbw110()
{
PressureSettingView view = GetSettingView(8, _db2107Helper.Pressure.TopPressure_V3);
//view.Id = 8;
//view.LowLimit = basePlcHelper.topPressure_V3_LowLimit.NowValue.ToFloat();
//view.HighLimit = basePlcHelper.topPressure_V3_HighLimit.NowValue.ToFloat();
//view.Alarm = basePlcHelper.topPressure_V3_Alarm.NowValue.ToInt();
return view;
}
private void DownDbw124(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(128, view);
}
}
private PressureSettingView UpDbw124()
{
PressureSettingView view = GetSettingView(9, _db2107Helper.Pressure.LinePressure_V3);
//{
// Id = 9,
// LowLimit = basePlcHelper.linePressure_V3_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.linePressure_V3_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.linePressure_V3_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDbw138(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(142, view);
}
}
private PressureSettingView UpDbw138()
{
PressureSettingView view = GetSettingView(10, _db2107Helper.Pressure.MainPress_V4);
//{
// Id = 10,
// LowLimit = basePlcHelper.mainPress_V4_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.mainPress_V4_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.mainPress_V4_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDbw152(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(156, view);
}
}
private PressureSettingView UpDbw152()
{
PressureSettingView view = GetSettingView(11, _db2107Helper.Pressure.TopPressure_V4);
//{
// Id = 11,
// LowLimit = basePlcHelper.topPressure_V4_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.topPressure_V4_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.topPressure_V4_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDbw166(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(170, view);
}
}
private PressureSettingView UpDbw166()
{
PressureSettingView view = GetSettingView(12, _db2107Helper.Pressure.LinePressure_V4);
//{
// Id = 12,
// LowLimit = basePlcHelper.linePressure_V4_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.linePressure_V4_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.linePressure_V4_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDbw180(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(184, view);
}
}
private PressureSettingView UpDbw180()
{
PressureSettingView view = GetSettingView(13, _db2107Helper.Pressure.MainPress_V5);
//{
// Id = 13,
// LowLimit = basePlcHelper.mainPress_V5_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.mainPress_V5_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.mainPress_V5_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDbw194(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(198, view);
}
}
private PressureSettingView UpDbw194()
{
PressureSettingView view = GetSettingView(14, _db2107Helper.Pressure.TopPressure_V5);
//{
// Id = 14,
// LowLimit = basePlcHelper.topPressure_V5_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.topPressure_V5_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.topPressure_V5_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDbw208(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(212, view);
}
}
private PressureSettingView UpDbw208()
{
PressureSettingView view = GetSettingView(15, _db2107Helper.Pressure.LinePressure_V5);
//{
// Id = 15,
// LowLimit = basePlcHelper.linePressure_V5_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.linePressure_V5_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.linePressure_V5_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW222(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(226, view);
}
}
private PressureSettingView UpDbw222()
{
PressureSettingView view = GetSettingView(16, _db2107Helper.Pressure.PressDaybin_B1);
//{
// Id = 16,
// LowLimit = basePlcHelper.presDaybin_B1_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.presDaybin_B1_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.presDaybin_B1_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW236(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(240, view);
}
}
private PressureSettingView UpDbw236()
{
PressureSettingView view = GetSettingView(17, _db2107Helper.Pressure.PressDaybin_B2);
//{
// Id = 17,
// LowLimit = basePlcHelper.presDaybin_B2_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.presDaybin_B2_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.presDaybin_B2_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW250(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(254, view);
}
}
private PressureSettingView UpDbw250()
{
PressureSettingView view = GetSettingView(18, _db2107Helper.Pressure.PressDaybin_B3);
//{
// Id = 18,
// LowLimit = basePlcHelper.presDaybin_B3_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.presDaybin_B3_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.presDaybin_B3_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW264(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(268, view);
}
}
private PressureSettingView UpDbw264()
{
PressureSettingView view = GetSettingView(19, _db2107Helper.Pressure.PressDaybin_B4);
//{
// Id = 19,
// LowLimit = basePlcHelper.presDaybin_B4_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.presDaybin_B4_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.presDaybin_B4_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW278(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(282, view);
}
}
private PressureSettingView UpDbw278()
{
PressureSettingView view = GetSettingView(20, _db2107Helper.Pressure.PressDaybin_B5);
//{
// Id = 20,
// LowLimit = basePlcHelper.presDaybin_B5_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.presDaybin_B5_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.presDaybin_B5_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW292(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(296, view);
}
}
private PressureSettingView UpDbw292()
{
PressureSettingView view = GetSettingView(21, _db2107Helper.Pressure.PressDaybin_B6);
//{
// Id = 21,
// LowLimit = basePlcHelper.presDaybin_B6_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.presDaybin_B6_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.presDaybin_B6_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW306(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(310, view);
}
}
private PressureSettingView UpDbw306()
{
PressureSettingView view = GetSettingView(22, _db2107Helper.Pressure.PressDaybin_B7);
//{
// Id = 22,
// LowLimit = basePlcHelper.presDaybin_B7_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.presDaybin_B7_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.presDaybin_B7_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW320(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(324, view);
}
}
private PressureSettingView UpDbw320()
{
PressureSettingView view = GetSettingView(23, _db2107Helper.Pressure.PressDaybin_B8);
//{
// Id = 23,
// LowLimit = basePlcHelper.presDaybin_B8_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.presDaybin_B8_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.presDaybin_B8_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW334(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(338, view);
}
}
private PressureSettingView UpDbw334()
{
PressureSettingView view = GetSettingView(24, _db2107Helper.Pressure.PressDaybin_B9);
//{
// Id = 24,
// LowLimit = basePlcHelper.presDaybin_B9_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.presDaybin_B9_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.presDaybin_B9_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW348(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(352, view);
}
}
private PressureSettingView UpDbw348()
{
PressureSettingView view = GetSettingView(25, _db2107Helper.Pressure.PressDaybin_B10);
//{
// Id = 25,
// LowLimit = basePlcHelper.presDaybin_B10_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.presDaybin_B10_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.presDaybin_B10_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW362(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(366, view);
}
}
private PressureSettingView UpDbw362()
{
PressureSettingView view = GetSettingView(26, _db2107Helper.Pressure.PressDaybin_B11);
//{
// Id = 26,
// LowLimit = basePlcHelper.presDaybin_B11_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.presDaybin_B11_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.presDaybin_B11_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW376(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(380, view);
}
}
private PressureSettingView UpDbw376()
{
PressureSettingView view = GetSettingView(27, _db2107Helper.Pressure.PressDaybin_B12);
//{
// Id = 27,
// LowLimit = basePlcHelper.presDaybin_B12_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.presDaybin_B12_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.presDaybin_B12_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW390(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(394, view);
}
}
private PressureSettingView UpDbw390()
{
PressureSettingView view = GetSettingView(28, _db2107Helper.Pressure.PR2PCP01);
//{
// Id = 28,
// LowLimit = basePlcHelper.PR2PCP01_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.PR2PCP01_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.PR2PCP01_B12_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW404(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(408, view);
}
}
private PressureSettingView UpDbw404()
{
PressureSettingView view = GetSettingView(29, _db2107Helper.Pressure.PR2PCP02);
//{
// Id = 29,
// LowLimit = basePlcHelper.PR2PCP02_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.PR2PCP02_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.PR2PCP02_Alarm.NowValue.ToInt()
//};
return view;
}
private void DownDBW418(PressureSettingView view)
{
if (view != null)
{
DownDbPressureSettingView(422, view);
}
}
private PressureSettingView UpDbw418()
{
PressureSettingView view = GetSettingView(30, _db2107Helper.Pressure.PR2PCP03);
//{
// Id = 30,
// LowLimit = basePlcHelper.PR2PCP03_LowLimit.NowValue.ToFloat(),
// HighLimit = basePlcHelper.PR2PCP03_HighLimit.NowValue.ToFloat(),
// Alarm = basePlcHelper.PR2PCP03_Alarm.NowValue.ToInt()
//};
return view;
}
///
/// 下发到plc
///
///
public void DownToPlc(List ls)
{
foreach (var pressureSettingView in ls)
{
int id = pressureSettingView.Id;
switch (id)
{
case 1:
DownDbw12(pressureSettingView);
break;
case 2:
DownDbw26(pressureSettingView);
break;
case 3:
DownDbw40(pressureSettingView);
break;
case 4:
DownDbw54(pressureSettingView);
break;
case 5:
DownDbw68(pressureSettingView);
break;
case 6:
DownDbw82(pressureSettingView);
break;
case 7:
DownDbw96(pressureSettingView);
break;
case 8:
DownDbw110(pressureSettingView);
break;
case 9:
DownDbw124(pressureSettingView);
break;
case 10:
DownDbw138(pressureSettingView);
break;
case 11:
DownDbw152(pressureSettingView);
break;
case 12:
DownDbw166(pressureSettingView);
break;
case 13:
DownDbw180(pressureSettingView);
break;
case 14:
DownDbw194(pressureSettingView);
break;
case 15:
DownDbw208(pressureSettingView);
break;
case 16:
DownDBW222(pressureSettingView);
break;
case 17:
DownDBW236(pressureSettingView);
break;
case 18:
DownDBW250(pressureSettingView);
break;
case 19:
DownDBW264(pressureSettingView);
break;
case 20:
DownDBW278(pressureSettingView);
break;
case 21:
DownDBW292(pressureSettingView);
break;
case 22:
DownDBW306(pressureSettingView);
break;
case 23:
DownDBW320(pressureSettingView);
break;
case 24:
DownDBW334(pressureSettingView);
break;
case 25:
DownDBW348(pressureSettingView);
break;
case 26:
DownDBW362(pressureSettingView);
break;
case 27:
DownDBW376(pressureSettingView);
break;
case 28:
DownDBW390(pressureSettingView);
break;
case 29:
DownDBW404(pressureSettingView);
break;
case 30:
DownDBW418(pressureSettingView);
break;
}
}
}
///
/// 下发到plc
///
///
public List UpdateFromPlc()
{
List ls = new List
{
UpDbw12(),
UpDbw26(),
UpDbw40(),
UpDbw54(),
UpDbw68(),
UpDbw82(),
UpDbw96(),
UpDbw110(),
UpDbw124(),
UpDbw138(),
UpDbw152(),
UpDbw166(),
UpDbw180(),
UpDbw194(),
UpDbw208(),
UpDbw222(),
UpDbw236(),
UpDbw250(),
UpDbw264(),
UpDbw278(),
UpDbw292(),
UpDbw306(),
UpDbw320(),
UpDbw334(),
UpDbw348(),
UpDbw362(),
UpDbw376(),
UpDbw390(),
UpDbw404(),
UpDbw418()
};
return ls;
}
public PressureSettingView UpdateFromPlc(int id)
{
PressureSettingView view = new PressureSettingView();
switch (id)
{
case 1:
view= UpDbw12();
break;
case 2:
view= UpDbw26();
break;
case 3:
view= UpDbw40();
break;
case 4:
view= UpDbw54();
break;
case 5:
view= UpDbw68();
break;
case 6:
view= UpDbw82();
break;
case 7:
view= UpDbw96();
break;
case 8:
view= UpDbw110();
break;
case 9:
view= UpDbw124();
break;
case 10:
view= UpDbw138();
break;
case 11:
view= UpDbw152();
break;
case 12:
view= UpDbw166();
break;
case 13:
view= UpDbw180();
break;
case 14:
view= UpDbw194();
break;
case 15:
view= UpDbw208();
break;
case 16:
view= UpDbw222();
break;
case 17:
view= UpDbw236();
break;
case 18:
view= UpDbw250();
break;
case 19:
view= UpDbw264();
break;
case 20:
view= UpDbw278();
break;
case 21:
view= UpDbw292();
break;
case 22:
view= UpDbw306();
break;
case 23:
view= UpDbw320();
break;
case 24:
view= UpDbw334();
break;
case 25:
view= UpDbw348();
break;
case 26:
view= UpDbw362();
break;
case 27:
view= UpDbw376();
break;
case 28:
view= UpDbw390();
break;
case 29:
view= UpDbw404();
break;
case 30:
view= UpDbw418();
break;
}
return view;
}
}
}