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/LjProportional/ProportionalPlc.cs

369 lines
9.9 KiB
C#

using DataBlockHelper;
using DataBlockHelper.DBHelpers;
using DataBlockHelper.Entity.DB2107Entity;
using Mesnac.Action.ChemicalWeighing.LjWeight;
using System;
using System.Collections.Generic;
1 year ago
namespace Mesnac.Action.ChemicalWeighing.LjProportional
{
public class ProportionalPlc
{
private DB2107Helper _db2107Helper = new DB2107Helper();
private void DownProportionalSettingView(int start, ProportionalSettingView view)
{
int sv = start + 4;
PlcConnect.Instance.Write($"DB2107.{sv}.0", Convert.ToSingle(view.SV));
}
1 year ago
private void Down614(ProportionalSettingView view)
1 year ago
{
if (null != view)
{
DownProportionalSettingView(614,view);
//var basePlcHelper = GetPlcHelper;
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.conveyV1_SV, view.SV);
1 year ago
}
}
private ProportionalSettingView GetProportionalSettingView(int id, PID_HMI pID)
1 year ago
{
ProportionalSettingView vi = new ProportionalSettingView()
{
Id = id,
PV = pID.PV,
SV =pID.SV
1 year ago
};
return vi;
}
private ProportionalSettingView Up614()
{
//
ProportionalSettingView vi = GetProportionalSettingView(1, _db2107Helper.PID.Convey_V1);
//{
// Id = 1,
// PV = basePlcHelper.conveyV1_PV.NowValue.ToFloat(),
// SV = basePlcHelper.conveyV1_SV.NowValue.ToFloat()
//};
return vi;
}
1 year ago
private void Down622(ProportionalSettingView view)
1 year ago
{
if (null != view)
{
DownProportionalSettingView(622, view);
1 year ago
}
}
private ProportionalSettingView Up622()
1 year ago
{
ProportionalSettingView vi = GetProportionalSettingView(2, _db2107Helper.PID.Purge_V1);
//{
// Id = 2,
// PV = basePlcHelper.purgeV1_PV.NowValue.ToFloat(),
// SV = basePlcHelper.purgeV1_SV.NowValue.ToFloat()
//};
1 year ago
return vi;
}
private void Down630(ProportionalSettingView view)
1 year ago
{
if (null != view)
{
DownProportionalSettingView(630, view);
1 year ago
}
}
private ProportionalSettingView Up630()
1 year ago
{
ProportionalSettingView vi = GetProportionalSettingView(3, _db2107Helper.PID.Convey_V2);
//{
// Id = 3,
// PV = basePlcHelper.conveyV2_PV.NowValue.ToFloat(),
// SV = basePlcHelper.conveyV2_SV.NowValue.ToFloat()
//};
1 year ago
return vi;
}
private void Down638(ProportionalSettingView view)
1 year ago
{
if (null != view)
{
DownProportionalSettingView(638, view);
1 year ago
}
}
private ProportionalSettingView Up638()
1 year ago
{
ProportionalSettingView vi = GetProportionalSettingView(4, _db2107Helper.PID.Purge_V2);
//{
// Id = 4,
// PV = basePlcHelper.purgeV2_PV.NowValue.ToFloat(),
// SV = basePlcHelper.purgeV2_SV.NowValue.ToFloat()
//};
1 year ago
return vi;
}
private void Down646(ProportionalSettingView view)
1 year ago
{
if (null != view)
{
DownProportionalSettingView(646, view);
1 year ago
}
}
private ProportionalSettingView Up646()
1 year ago
{
ProportionalSettingView vi = GetProportionalSettingView(5, _db2107Helper.PID.Convey_V3);
//{
// Id = 5,
// PV = basePlcHelper.conveyV3_PV.NowValue.ToFloat(),
// SV = basePlcHelper.conveyV3_SV.NowValue.ToFloat()
//};
1 year ago
return vi;
}
private void Down654(ProportionalSettingView view)
1 year ago
{
if (null != view)
{
DownProportionalSettingView(654, view);
1 year ago
}
}
private ProportionalSettingView Up654()
1 year ago
{
ProportionalSettingView vi = GetProportionalSettingView(6, _db2107Helper.PID.Purge_V3);
//{
// Id = 6,
// PV = basePlcHelper.purgeV3_PV.NowValue.ToFloat(),
// SV = basePlcHelper.purgeV3_SV.NowValue.ToFloat()
//};
1 year ago
return vi;
}
private void Down662(ProportionalSettingView view)
1 year ago
{
if (null != view)
{
DownProportionalSettingView(662, view);
1 year ago
}
}
private ProportionalSettingView Up662()
1 year ago
{
ProportionalSettingView vi = GetProportionalSettingView(7, _db2107Helper.PID.Convey_V4);
//{
// Id = 7,
// PV = basePlcHelper.conveyV4_PV.NowValue.ToFloat(),
// SV = basePlcHelper.conveyV4_SV.NowValue.ToFloat()
//};
1 year ago
return vi;
}
private void Down670(ProportionalSettingView view)
1 year ago
{
if (null != view)
{
DownProportionalSettingView(670, view);
1 year ago
}
}
private ProportionalSettingView Up670()
1 year ago
{
ProportionalSettingView vi = GetProportionalSettingView(8, _db2107Helper.PID.Purge_V4);
//{
// Id = 8,
// PV = basePlcHelper.purgeV4_PV.NowValue.ToFloat(),
// SV = basePlcHelper.purgeV4_SV.NowValue.ToFloat()
//};
1 year ago
return vi;
}
private void Down678(ProportionalSettingView view)
1 year ago
{
if (null != view)
{
DownProportionalSettingView(678, view);
1 year ago
}
}
private ProportionalSettingView Up678()
1 year ago
{
ProportionalSettingView vi = GetProportionalSettingView(9, _db2107Helper.PID.Convey_V5);
//{
// Id = 9,
// PV = basePlcHelper.conveyV5_PV.NowValue.ToFloat(),
// SV = basePlcHelper.conveyV5_SV.NowValue.ToFloat()
//};
1 year ago
return vi;
}
private void Down686(ProportionalSettingView view)
1 year ago
{
if (null != view)
{
DownProportionalSettingView(686, view);
1 year ago
}
}
private ProportionalSettingView Up686()
1 year ago
{
ProportionalSettingView vi = GetProportionalSettingView(10, _db2107Helper.PID.Purge_V5);
//{
// Id = 10,
// PV = basePlcHelper.purgeV5_PV.NowValue.ToFloat(),
// SV = basePlcHelper.purgeV5_SV.NowValue.ToFloat()
//};
1 year ago
return vi;
}
public void DownToPlc(IEnumerable<ProportionalSettingView> views)
1 year ago
{
foreach (var v in views)
{
switch (v.Id)
{
case 1:
Down614(v);
break;
case 2:
Down622(v);
break;
case 3:
Down630(v);
break;
case 4:
Down638(v);
break;
case 5:
Down646(v);
break;
case 6:
Down654(v);
break;
case 7:
Down662(v);
break;
case 8:
Down670(v);
break;
case 9:
Down678(v);
break;
case 10:
Down686(v);
break;
}
}
}
public ProportionalSettingView UpFromPlc(int id)
1 year ago
{
switch (id)
{
case 1:
return Up614();
case 2:
return Up622();
case 3:
return Up630();
case 4:
return Up638();
case 5:
return Up646();
case 6:
return Up654();
case 7:
return Up662();
case 8:
return Up670();
case 9:
return Up678();
case 10:
return Up686();
}
return null;
}
public IEnumerable<ProportionalSettingView> UpFromPlc()
1 year ago
{
ICollection<ProportionalSettingView> co = new List<ProportionalSettingView>();
co.Add(Up614());
co.Add(Up622());
co.Add(Up630());
co.Add(Up638());
co.Add(Up646());
co.Add(Up654());
co.Add(Up662());
co.Add(Up670());
co.Add(Up678());
co.Add(Up686());
return co;
}
}
}