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/LjElectrical/ElectricalPlc.cs

715 lines
20 KiB
C#

using DataBlockHelper;
using DataBlockHelper.DBHelpers;
using Mesnac.Action.ChemicalWeighing.LjWeight;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Mesnac.Action.ChemicalWeighing.LjElectrical
{
public class ElectricalPlc
{
private BasePlcHelper GetPlcHelper => BasePlcHelper.Instance;
private DB2107Helper _db2107Helper = new DB2107Helper();
private void DownElectricalView(int start, ElectricalView view)
{
PlcConnect.Instance.Write($"DB2107.{start}.0",view.Speed);
}
private void Down1324(ElectricalView view)
{
if (null != view)
{
DownElectricalView(1324,view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedD1,
// view.Speed);
}
}
private ElectricalView Up1324()
{
ElectricalView view = new ElectricalView();
view.Id = 1;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedD1.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_D1;
return view;
}
//
//
//
//
private ElectricalView Up1328()
{
ElectricalView view = new ElectricalView();
view.Id = 2;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedD2.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_D2;
return view;
}
private void Down1328(ElectricalView view)
{
if (null != view)
{
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedD2,
// view.Speed);
DownElectricalView(1328, view);
}
}
private ElectricalView Up1332()
{
ElectricalView view = new ElectricalView();
view.Id = 3;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedD3.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_D3;
return view;
}
private void Down1332(ElectricalView view)
{
if (null != view)
{
DownElectricalView(1332, view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedD3,
// view.Speed);
}
}
private ElectricalView Up1336()
{
ElectricalView view = new ElectricalView();
view.Id = 4;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedD3.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_D4;
return view;
}
private void Down1336(ElectricalView view)
{
if (null != view)
{
DownElectricalView(1336, view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedD4,
// view.Speed);
}
}
private ElectricalView Up1340()
{
ElectricalView view = new ElectricalView();
view.Id = 5;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedG1.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_G1;
return view;
}
private void Down1340(ElectricalView view)
{
if (null != view)
{
DownElectricalView(1340, view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedG1,
// view.Speed);
}
}
private ElectricalView Up1344()
{
ElectricalView view = new ElectricalView();
view.Id = 6;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedG2.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_G2;
return view;
}
private void Down1344(ElectricalView view)
{
if (null != view)
{
DownElectricalView(1344, view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedG2,
// view.Speed);
}
}
private ElectricalView Up1348()
{
ElectricalView view = new ElectricalView();
view.Id = 7;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedG3.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_G3;
return view;
}
private void Down1348(ElectricalView view)
{
if (null != view)
{
DownElectricalView(1348, view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedG3,
// view.Speed);
}
}
private ElectricalView Up1352()
{
ElectricalView view = new ElectricalView();
view.Id = 8;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedG4.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_G4;
return view;
}
private void Down1352(ElectricalView view)
{
if (null != view)
{
DownElectricalView(1352, view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedG4,
// view.Speed);
}
}
private ElectricalView Up1356()
{
ElectricalView view = new ElectricalView();
view.Id = 9;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedG5.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_G5;
return view;
}
private void Down1356(ElectricalView view)
{
if (null != view)
{
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedG5,
// view.Speed);
DownElectricalView(1356, view);
}
}
private ElectricalView Up1360()
{
ElectricalView view = new ElectricalView();
view.Id = 10;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedG6.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_G6;
return view;
}
private void Down1360(ElectricalView view)
{
if (null != view)
{
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedG6,
// view.Speed);
DownElectricalView(1360, view);
}
}
private ElectricalView Up1364()
{
ElectricalView view = new ElectricalView();
view.Id = 11;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedG7.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_G7;
return view;
}
private void Down1364(ElectricalView view)
{
if (null != view)
{
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedG7,
// view.Speed);
DownElectricalView(1364, view);
}
}
private ElectricalView Up1368()
{
ElectricalView view = new ElectricalView();
view.Id = 12;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedG8.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_G8;
return view;
}
private void Down1368(ElectricalView view)
{
if (null != view)
{
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedG8,
// view.Speed);
DownElectricalView(1368, view);
}
}
private ElectricalView Up1372()
{
ElectricalView view = new ElectricalView();
view.Id = 13;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedH1.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_H1;
return view;
}
private void Down1372(ElectricalView view)
{
if (null != view)
{
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedH1,
// view.Speed);
DownElectricalView(1372, view);
}
}
private ElectricalView Up1376()
{
ElectricalView view = new ElectricalView();
view.Id = 14;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedH2.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_H2;
return view;
}
private void Down1376(ElectricalView view)
{
if (null != view)
{
DownElectricalView(1376, view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedH2,
// view.Speed);
}
}
private ElectricalView Up1380()
{
ElectricalView view = new ElectricalView();
view.Id = 15;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedH3.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_H3;
return view;
}
private void Down1380(ElectricalView view)
{
if (null != view)
{
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedH3,
// view.Speed);
DownElectricalView(1380, view);
}
}
private ElectricalView Up1384()
{
ElectricalView view = new ElectricalView();
view.Id = 16;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedH4.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_H4;
return view;
}
private void Down1384(ElectricalView view)
{
if (null != view)
{
DownElectricalView(1384, view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedH4,
// view.Speed);
}
}
private ElectricalView Up1388()
{
ElectricalView view = new ElectricalView();
view.Id = 17;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedS1.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_S1;
return view;
}
private void Down1388(ElectricalView view)
{
if (null != view)
{
DownElectricalView(1388, view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedS1,
// view.Speed);
}
}
private ElectricalView Up1392()
{
ElectricalView view = new ElectricalView();
view.Id = 18;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedS5.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_S5;
return view;
}
private void Down1392(ElectricalView view)
{
if (null != view)
{
DownElectricalView(1392, view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedS5,
// view.Speed);
}
}
private ElectricalView Up1396()
{
ElectricalView view = new ElectricalView();
view.Id = 19;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedS7.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_S7;
return view;
}
private void Down1396(ElectricalView view)
{
if (null != view)
{
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedS7,
// view.Speed);
DownElectricalView(1396, view);
}
}
private ElectricalView Up1400()
{
ElectricalView view = new ElectricalView();
view.Id = 20;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedS11.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_S11;
return view;
}
private void Down1400(ElectricalView view)
{
if (null != view)
{
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedS11,
// view.Speed);
DownElectricalView(1400, view);
}
}
private ElectricalView Up1404()
{
ElectricalView view = new ElectricalView();
view.Id = 21;
//var basePlcHelper = GetPlcHelper;
//view.Speed = basePlcHelper.SpeedS15.NowValue.ToFloat();
view.Speed = _db2107Helper.Speed.ManSpeed_S15;
return view;
}
private void Down1404(ElectricalView view)
{
if (null != view)
{
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.SpeedS15,
// view.Speed);
DownElectricalView(1404, view);
}
}
public IList<ElectricalView> UpFromPlc()
{
IList<ElectricalView> ls = new List<ElectricalView>();
ls.Add(Up1324());
ls.Add(Up1328());
ls.Add(Up1332());
ls.Add(Up1336());
ls.Add(Up1340());
ls.Add(Up1344());
ls.Add(Up1348());
ls.Add(Up1352());
ls.Add(Up1356());
ls.Add(Up1360());
ls.Add(Up1364());
ls.Add(Up1368());
ls.Add(Up1372());
ls.Add(Up1376());
ls.Add(Up1380());
ls.Add(Up1384());
ls.Add(Up1388());
ls.Add(Up1392());
ls.Add(Up1396());
ls.Add(Up1400());
ls.Add(Up1404());
return ls;
}
public ElectricalView UpFromPlc(int id)
{
ElectricalView view = new ElectricalView();
switch (id)
{
case 1:
view = Up1324();
break;
case 2:
view = Up1328();
break;
case 3:
view = Up1332();
break;
case 4:
view = Up1336();
break;
case 5:
view = Up1340();
break;
case 6:
view = Up1344();
break;
case 7:
view = Up1348();
break;
case 8:
view = Up1352();
break;
case 9:
view = Up1356();
break;
case 10:
view = Up1360();
break;
case 11:
view = Up1364();
break;
case 12:
view = Up1368();
break;
case 13:
view = Up1372();
break;
case 14:
view = Up1376();
break;
case 15:
view = Up1380();
break;
case 16:
view = Up1384();
break;
case 17:
view = Up1388();
break;
case 18:
view = Up1392();
break;
case 19:
view = Up1396();
break;
case 20:
view = Up1400();
break;
case 21:
view = Up1404();
break;
}
return view;
}
public void DownToPlc(List<ElectricalView> views)
{
foreach (var view in views)
{
switch (view.Id)
{
case 1:
Down1324(view);
break;
case 2:
Down1328(view);
break;
case 3:
Down1332(view);
break;
case 4:
Down1336(view);
break;
case 5:
Down1340(view);
break;
case 6:
Down1344(view);
break;
case 7:
Down1348(view);
break;
case 8:
Down1352(view);
break;
case 9:
Down1356(view);
break;
case 10:
Down1360(view);
break;
case 11:
Down1364(view);
break;
case 12:
Down1368(view);
break;
case 13:
Down1372(view);
break;
case 14:
Down1376(view);
break;
case 15:
Down1380(view);
break;
case 16:
Down1384(view);
break;
case 17:
Down1388(view);
break;
case 18:
Down1392(view);
break;
case 19:
Down1396(view);
break;
case 20:
Down1400(view);
break;
case 21:
Down1404(view);
break;
}
}
}
}
}