|
|
|
|
using DataBlockHelper;
|
|
|
|
|
using DataBlockHelper.DBHelpers;
|
|
|
|
|
using DataBlockHelper.Entity.DB2107Entity;
|
|
|
|
|
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.LjWeight;
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down614(ProportionalSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownProportionalSettingView(614,view);
|
|
|
|
|
//var basePlcHelper = GetPlcHelper;
|
|
|
|
|
//basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.conveyV1_SV, view.SV);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ProportionalSettingView GetProportionalSettingView(int id, PID_HMI pID)
|
|
|
|
|
{
|
|
|
|
|
ProportionalSettingView vi = new ProportionalSettingView()
|
|
|
|
|
{
|
|
|
|
|
Id = id,
|
|
|
|
|
PV = pID.PV,
|
|
|
|
|
SV =pID.SV
|
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Down622(ProportionalSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownProportionalSettingView(622, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ProportionalSettingView Up622()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ProportionalSettingView vi = GetProportionalSettingView(2, _db2107Helper.PID.Purge_V1);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 2,
|
|
|
|
|
// PV = basePlcHelper.purgeV1_PV.NowValue.ToFloat(),
|
|
|
|
|
// SV = basePlcHelper.purgeV1_SV.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return vi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down630(ProportionalSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownProportionalSettingView(630, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ProportionalSettingView Up630()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ProportionalSettingView vi = GetProportionalSettingView(3, _db2107Helper.PID.Convey_V2);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 3,
|
|
|
|
|
// PV = basePlcHelper.conveyV2_PV.NowValue.ToFloat(),
|
|
|
|
|
// SV = basePlcHelper.conveyV2_SV.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return vi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Down638(ProportionalSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownProportionalSettingView(638, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ProportionalSettingView Up638()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ProportionalSettingView vi = GetProportionalSettingView(4, _db2107Helper.PID.Purge_V2);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 4,
|
|
|
|
|
// PV = basePlcHelper.purgeV2_PV.NowValue.ToFloat(),
|
|
|
|
|
// SV = basePlcHelper.purgeV2_SV.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return vi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down646(ProportionalSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownProportionalSettingView(646, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ProportionalSettingView Up646()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ProportionalSettingView vi = GetProportionalSettingView(5, _db2107Helper.PID.Convey_V3);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 5,
|
|
|
|
|
// PV = basePlcHelper.conveyV3_PV.NowValue.ToFloat(),
|
|
|
|
|
// SV = basePlcHelper.conveyV3_SV.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return vi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down654(ProportionalSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownProportionalSettingView(654, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ProportionalSettingView Up654()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ProportionalSettingView vi = GetProportionalSettingView(6, _db2107Helper.PID.Purge_V3);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 6,
|
|
|
|
|
// PV = basePlcHelper.purgeV3_PV.NowValue.ToFloat(),
|
|
|
|
|
// SV = basePlcHelper.purgeV3_SV.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return vi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down662(ProportionalSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownProportionalSettingView(662, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ProportionalSettingView Up662()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ProportionalSettingView vi = GetProportionalSettingView(7, _db2107Helper.PID.Convey_V4);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 7,
|
|
|
|
|
// PV = basePlcHelper.conveyV4_PV.NowValue.ToFloat(),
|
|
|
|
|
// SV = basePlcHelper.conveyV4_SV.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return vi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down670(ProportionalSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownProportionalSettingView(670, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ProportionalSettingView Up670()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ProportionalSettingView vi = GetProportionalSettingView(8, _db2107Helper.PID.Purge_V4);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 8,
|
|
|
|
|
// PV = basePlcHelper.purgeV4_PV.NowValue.ToFloat(),
|
|
|
|
|
// SV = basePlcHelper.purgeV4_SV.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return vi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down678(ProportionalSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownProportionalSettingView(678, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ProportionalSettingView Up678()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ProportionalSettingView vi = GetProportionalSettingView(9, _db2107Helper.PID.Convey_V5);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 9,
|
|
|
|
|
// PV = basePlcHelper.conveyV5_PV.NowValue.ToFloat(),
|
|
|
|
|
// SV = basePlcHelper.conveyV5_SV.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return vi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down686(ProportionalSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownProportionalSettingView(686, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ProportionalSettingView Up686()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ProportionalSettingView vi = GetProportionalSettingView(10, _db2107Helper.PID.Purge_V5);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 10,
|
|
|
|
|
// PV = basePlcHelper.purgeV5_PV.NowValue.ToFloat(),
|
|
|
|
|
// SV = basePlcHelper.purgeV5_SV.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return vi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void DownToPlc(IEnumerable<ProportionalSettingView> views)
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|