|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
using Mesnac.Action.Feeding.Qingquan.BasicInfo;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.Feeding.Qingquan.FeedingPlc
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 从PLC获取称量物料参数,并保存至数据库表SytJar
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class GetWeightParaAction : FeedingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.RunIni(runtime);
|
|
|
|
|
|
|
|
|
|
if (runtime.Sender != null && runtime.Sender is Control)
|
|
|
|
|
{
|
|
|
|
|
(runtime.Sender as Control).Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ICSharpCode.Core.LoggingService.Debug("从PlC获取称量物料参数,并保存至数据库表SytJar失败!");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DbHelper localHelper = base.NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
if (localHelper == null)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("从PlC获取称量物料参数,并保存至数据库表SytJar失败:获取本地数据库连接失败!");
|
|
|
|
|
runtime.IsReturn = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
localHelper.CommandType = System.Data.CommandType.Text;
|
|
|
|
|
string strSql = "update [SytJar] set mcValue = @mcValue,tqValue = @tqValue, tzValue = @tzValue, ddValue = @ddValue where JarType = @JarType and JarSerial = @JarSerial";
|
|
|
|
|
|
|
|
|
|
int len = 0; //保存长度
|
|
|
|
|
int[] mcValues = null;
|
|
|
|
|
int[] tqValues = null;
|
|
|
|
|
int[] tzValues = null;
|
|
|
|
|
int[] ddValues = null;
|
|
|
|
|
|
|
|
|
|
#region 炭黑
|
|
|
|
|
|
|
|
|
|
len = PlcData.Instance.CLWLCS_TanHei_MC.EquipData.Len;
|
|
|
|
|
mcValues = new int[len];
|
|
|
|
|
tqValues = new int[len];
|
|
|
|
|
tzValues = new int[len];
|
|
|
|
|
ddValues = new int[len];
|
|
|
|
|
if (PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_TanHei_MC, out mcValues) && PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_TanHei_TQ, out tqValues) && PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_TanHei_TZ, out tzValues) && PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_TanHei_DD, out ddValues))
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@mcValue", mcValues[i] / 100.0);
|
|
|
|
|
localHelper.AddParameter("@tqValue", tqValues[i] / 100.0);
|
|
|
|
|
localHelper.AddParameter("@tzValue", tzValues[i]);
|
|
|
|
|
localHelper.AddParameter("@ddValue", ddValues[i]);
|
|
|
|
|
localHelper.AddParameter("@JarType", "炭黑");
|
|
|
|
|
localHelper.AddParameter("@JarSerial", i + 1);
|
|
|
|
|
localHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 油1
|
|
|
|
|
|
|
|
|
|
len = PlcData.Instance.CLWLCS_You_MC1.EquipData.Len;
|
|
|
|
|
mcValues = new int[len];
|
|
|
|
|
tqValues = new int[len];
|
|
|
|
|
tzValues = new int[len];
|
|
|
|
|
ddValues = new int[len];
|
|
|
|
|
if (PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_You_MC1, out mcValues) && PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_You_TQ1, out tqValues) && PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_You_TZ1, out tzValues) && PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_You_DD1, out ddValues))
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@mcValue", mcValues[i] / 100.0);
|
|
|
|
|
localHelper.AddParameter("@tqValue", tqValues[i] / 100.0);
|
|
|
|
|
localHelper.AddParameter("@tzValue", tzValues[i]);
|
|
|
|
|
localHelper.AddParameter("@ddValue", ddValues[i]);
|
|
|
|
|
localHelper.AddParameter("@JarType", "油1");
|
|
|
|
|
localHelper.AddParameter("@JarSerial", i + 1);
|
|
|
|
|
localHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 油2
|
|
|
|
|
|
|
|
|
|
len = PlcData.Instance.CLWLCS_You_MC2.EquipData.Len;
|
|
|
|
|
mcValues = new int[len];
|
|
|
|
|
tqValues = new int[len];
|
|
|
|
|
tzValues = new int[len];
|
|
|
|
|
ddValues = new int[len];
|
|
|
|
|
if (PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_You_MC2, out mcValues) && PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_You_TQ2, out tqValues) && PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_You_TZ2, out tzValues) && PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_You_DD2, out ddValues))
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@mcValue", mcValues[i] / 100.0);
|
|
|
|
|
localHelper.AddParameter("@tqValue", tqValues[i] / 100.0);
|
|
|
|
|
localHelper.AddParameter("@tzValue", tzValues[i]);
|
|
|
|
|
localHelper.AddParameter("@ddValue", ddValues[i]);
|
|
|
|
|
localHelper.AddParameter("@JarType", "油2");
|
|
|
|
|
localHelper.AddParameter("@JarSerial", i + 1);
|
|
|
|
|
localHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 粉料
|
|
|
|
|
|
|
|
|
|
len = PlcData.Instance.CLWLCS_FenLiao_MC.EquipData.Len;
|
|
|
|
|
mcValues = new int[len];
|
|
|
|
|
tqValues = new int[len];
|
|
|
|
|
tzValues = new int[len];
|
|
|
|
|
ddValues = new int[len];
|
|
|
|
|
if (PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_FenLiao_MC, out mcValues) && PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_FenLiao_TQ, out tqValues) && PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_FenLiao_TZ, out tzValues) && PlcData.Instance.PlcRead(PlcData.Instance.CLWLCS_FenLiao_DD, out ddValues))
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@mcValue", mcValues[i] / 100.0);
|
|
|
|
|
localHelper.AddParameter("@tqValue", tqValues[i] / 100.0);
|
|
|
|
|
localHelper.AddParameter("@tzValue", tzValues[i]);
|
|
|
|
|
localHelper.AddParameter("@ddValue", ddValues[i]);
|
|
|
|
|
localHelper.AddParameter("@JarType", "粉料");
|
|
|
|
|
localHelper.AddParameter("@JarSerial", i + 1);
|
|
|
|
|
localHelper.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error(String.Format("从PlC获取称量物料参数,并保存至数据库表SytJar失败:{0}", ex.Message));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (runtime.Sender is Control)
|
|
|
|
|
{
|
|
|
|
|
(runtime.Sender as Control).Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|