|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
|
|
|
|
|
using DataBlockHelper;
|
|
|
|
|
using DataBlockHelper.DBHelpers;
|
|
|
|
|
using DataBlockHelper.DbWrite;
|
|
|
|
|
using DataBlockHelper.Entity.DB2107Entity;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjWeight
|
|
|
|
|
{
|
|
|
|
|
public class WeightSettingPlc
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down432(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(432, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PlcWriteUtil plcWriter = new PlcWriteUtil();
|
|
|
|
|
|
|
|
|
|
private DB2107Helper _db2107Helper = new DB2107Helper();
|
|
|
|
|
|
|
|
|
|
private void DownWeightSettingView(int start, WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
int hight = start + 4;
|
|
|
|
|
int low = start + 8;
|
|
|
|
|
|
|
|
|
|
PlcConnect.Instance.Write($"DB2107.{hight}.0", Convert.ToSingle(view.HighWeight));
|
|
|
|
|
PlcConnect.Instance.Write($"DB2107.{low}.0", Convert.ToSingle(view.LowWeight));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private WeightSettingView GetWeightSettingView(int id, Silo_HMI silo)
|
|
|
|
|
{
|
|
|
|
|
WeightSettingView view = new WeightSettingView()
|
|
|
|
|
{
|
|
|
|
|
Id = id,
|
|
|
|
|
HighWeight = silo.HighWeight,
|
|
|
|
|
LowWeight = silo.LowWeight
|
|
|
|
|
};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up432()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(1, _db2107Helper.Weight.Hopper_1);
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down446(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(446, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up446()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(2, _db2107Helper.Weight.Hopper_2);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 2,
|
|
|
|
|
// HighWeight = basePlcHelper.Hopper_2_HighWeight.NowValue.ToFloat(),
|
|
|
|
|
// LowWeight = basePlcHelper.Hopper_2_LowWeight.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down460(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(460, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up460()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(3, _db2107Helper.Weight.Hopper_3);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 3,
|
|
|
|
|
// HighWeight = basePlcHelper.Hopper_3_HighWeight.NowValue.ToFloat(),
|
|
|
|
|
// LowWeight = basePlcHelper.Hopper_3_LowWeight.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Down474(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(474, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up474()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(4, _db2107Helper.Weight.Hopper_4);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 4,
|
|
|
|
|
// HighWeight = basePlcHelper.Hopper_4_HighWeight.NowValue.ToFloat(),
|
|
|
|
|
// LowWeight = basePlcHelper.Hopper_4_LowWeight.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down488(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(488, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up488()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(5, _db2107Helper.Weight.Vessel_1);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 5,
|
|
|
|
|
// HighWeight = basePlcHelper.Vessel_1_HighWeight.NowValue.ToFloat(),
|
|
|
|
|
// LowWeight = basePlcHelper.Vessel_1_LowWeight.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down502(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(502, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up502()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(6, _db2107Helper.Weight.Vessel_2);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 6,
|
|
|
|
|
// HighWeight = basePlcHelper.Vessel_2_HighWeight.NowValue.ToFloat(),
|
|
|
|
|
// LowWeight = basePlcHelper.Vessel_2_LowWeight.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Down516(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(516, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up516()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(7, _db2107Helper.Weight.Vessel_3);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 7,
|
|
|
|
|
// HighWeight = basePlcHelper.Vessel_3_HighWeight.NowValue.ToFloat(),
|
|
|
|
|
// LowWeight = basePlcHelper.Vessel_3_LowWeight.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down530(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(530, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up530()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(8, _db2107Helper.Weight.Vessel_4);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 8,
|
|
|
|
|
// HighWeight = basePlcHelper.Vessel_4_HighWeight.NowValue.ToFloat(),
|
|
|
|
|
// LowWeight = basePlcHelper.Vessel_4_LowWeight.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down544(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(544, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up544()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(9, _db2107Helper.Weight.Vessel_5);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 9,
|
|
|
|
|
// HighWeight = basePlcHelper.Vessel_5_HighWeight.NowValue.ToFloat(),
|
|
|
|
|
// LowWeight = basePlcHelper.Vessel_5_LowWeight.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down558(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(558, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up558()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(10, _db2107Helper.Weight.WScale_1);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 10,
|
|
|
|
|
// HighWeight = basePlcHelper.WScale_1_HighWeight.NowValue.ToFloat(),
|
|
|
|
|
// LowWeight = basePlcHelper.WScale_1_LowWeight.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Down572(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(572, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up572()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(11, _db2107Helper.Weight.WScale_2);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 11,
|
|
|
|
|
// HighWeight = basePlcHelper.WScale_2_HighWeight.NowValue.ToFloat(),
|
|
|
|
|
// LowWeight = basePlcHelper.WScale_2_LowWeight.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Down586(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(586, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up586()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(12, _db2107Helper.Weight.WScale_3);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 12,
|
|
|
|
|
// HighWeight = basePlcHelper.WScale_3_HighWeight.NowValue.ToFloat(),
|
|
|
|
|
// LowWeight = basePlcHelper.WScale_3_LowWeight.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Down600(WeightSettingView view)
|
|
|
|
|
{
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
DownWeightSettingView(600, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WeightSettingView Up600()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = GetWeightSettingView(13, _db2107Helper.Weight.WScale_4);
|
|
|
|
|
//{
|
|
|
|
|
// Id = 13,
|
|
|
|
|
// HighWeight = basePlcHelper.WScale_4_HighWeight.NowValue.ToFloat(),
|
|
|
|
|
// LowWeight = basePlcHelper.WScale_4_LowWeight.NowValue.ToFloat()
|
|
|
|
|
//};
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public 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 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 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|