|
|
|
|
using DevExpress.Office.Drawing;
|
|
|
|
|
using DevExpress.Office.Utils;
|
|
|
|
|
using DevExpress.XtraEditors.Filtering.Templates;
|
|
|
|
|
using HslCommunication.Profinet.Siemens;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.ChemicalWeighingPlc;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity.PptPlan;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity.station;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Product.PptPlan;
|
|
|
|
|
using Mesnac.Controls.Default;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Timers;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Show
|
|
|
|
|
{
|
|
|
|
|
public class InitFormAction : ChemicalWeighingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
#region 字段定义
|
|
|
|
|
|
|
|
|
|
public static bool IsFirstRun = true; //是否首次运行
|
|
|
|
|
private RuntimeParameter _runtime;
|
|
|
|
|
//private DbMCControl _planDateControl = null; //计划日期
|
|
|
|
|
//private DbMCControl _pptShiftControl = null; //班次
|
|
|
|
|
private DbMCControl _clientGridControl = null; //本地计划控件
|
|
|
|
|
string planFlag= string.Empty;
|
|
|
|
|
string planFlag2 = string.Empty;
|
|
|
|
|
bool planFlag3 = true;
|
|
|
|
|
bool Flag4 = true;
|
|
|
|
|
bool Flag5 = true;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
System.Timers.Timer timer = new System.Timers.Timer(3000);
|
|
|
|
|
System.Timers.Timer timer2 = new System.Timers.Timer(3000);
|
|
|
|
|
System.Timers.Timer timer3 = new System.Timers.Timer(1000);
|
|
|
|
|
System.Timers.Timer timer4 = new System.Timers.Timer(1000);
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.RunIni(runtime);
|
|
|
|
|
|
|
|
|
|
#region 首次执行,进行事件订阅
|
|
|
|
|
|
|
|
|
|
if (IsFirstRun)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ICSharpCode.Core.LoggingService<XlInitAction>.Debug("小料展示界面-窗体初始化业务...");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_weigh").FirstOrDefault(); //获取本机台计划控件
|
|
|
|
|
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<InitFormAction>.Error("{首页展示}缺少本机台计划网格控件...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//StartServer1();
|
|
|
|
|
//StartServer2();
|
|
|
|
|
//InitData();
|
|
|
|
|
//1号地磅
|
|
|
|
|
|
|
|
|
|
timer.Elapsed += new ElapsedEventHandler(StartServer1);
|
|
|
|
|
timer.AutoReset = true;
|
|
|
|
|
timer.Enabled = true;
|
|
|
|
|
timer.Start();
|
|
|
|
|
|
|
|
|
|
////IsFirstRun = false;
|
|
|
|
|
//////2号地磅
|
|
|
|
|
|
|
|
|
|
timer2.Elapsed += new ElapsedEventHandler(StartServer2);
|
|
|
|
|
timer2.AutoReset = true;
|
|
|
|
|
timer2.Enabled = true;
|
|
|
|
|
timer2.Start();
|
|
|
|
|
|
|
|
|
|
timer3.Elapsed += new ElapsedEventHandler(UpdateShow1);
|
|
|
|
|
timer3.AutoReset = true;
|
|
|
|
|
timer3.Enabled = true;
|
|
|
|
|
timer3.Start();
|
|
|
|
|
|
|
|
|
|
timer4.Elapsed += new ElapsedEventHandler(UpdateShow2);
|
|
|
|
|
timer4.AutoReset = true;
|
|
|
|
|
timer4.Enabled = true;
|
|
|
|
|
timer4.Start();
|
|
|
|
|
|
|
|
|
|
//StartServer1();
|
|
|
|
|
//StartServer2();
|
|
|
|
|
#region 初始化
|
|
|
|
|
|
|
|
|
|
#region 获取界面控件
|
|
|
|
|
|
|
|
|
|
string source = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//DbMCControl planDateControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[xl_plan].[Plan_Date]").FirstOrDefault();
|
|
|
|
|
//DbMCControl pptShiftControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_Shiftime").FirstOrDefault();
|
|
|
|
|
//DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "xl_plan").FirstOrDefault(); //获取本机台计划网格控件
|
|
|
|
|
|
|
|
|
|
//if (planDateControl == null)
|
|
|
|
|
//{
|
|
|
|
|
// ICSharpCode.Core.LoggingService<InitFormAction>.Error("{当班计划-窗体加载} 缺少日期选择控件...");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//if (pptShiftControl == null)
|
|
|
|
|
//{
|
|
|
|
|
// ICSharpCode.Core.LoggingService<InitFormAction>.Error("{当班计划-窗体加载} 缺少班次组合框控件...");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//if (clientGridControl == null)
|
|
|
|
|
//{
|
|
|
|
|
// ICSharpCode.Core.LoggingService<XlInitAction>.Error("{小料展示界面-窗体加载} 缺少计划列表网格控件...");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//this._runtime = runtime;
|
|
|
|
|
//this._clientGridControl = clientGridControl;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 初始化操作
|
|
|
|
|
|
|
|
|
|
//DataGridView clientGrid = (clientGridControl.BaseControl as DataGridView);
|
|
|
|
|
|
|
|
|
|
//this.InitGridViewEvent(clientGrid);
|
|
|
|
|
//this.InitData();
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 方法定义
|
|
|
|
|
|
|
|
|
|
#region 网格事件处理方法
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化网格样式
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dgv">DataGridView网格控件对象</param>
|
|
|
|
|
private void InitGridViewEvent(DataGridView dgv)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 初始化界面控件数据
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化界面控件数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void InitData()
|
|
|
|
|
{
|
|
|
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_weigh").FirstOrDefault(); //获取本机台计划控件
|
|
|
|
|
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<InitFormAction>.Error("{首页展示}缺少本机台计划网格控件...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lock (String.Empty)
|
|
|
|
|
{
|
|
|
|
|
//本地计划
|
|
|
|
|
if (clientGridControl != null && clientGridControl.BaseControl != null)
|
|
|
|
|
{
|
|
|
|
|
//clientGridControl.BaseControl.BindDataSource = null;
|
|
|
|
|
//clientGridControl.BaseControl.BindDataSource = dt;
|
|
|
|
|
|
|
|
|
|
#region 根据计划状态处理背景色
|
|
|
|
|
|
|
|
|
|
DataGridView clientGrid = clientGridControl.BaseControl as DataGridView;
|
|
|
|
|
SetBackColor(clientGrid);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<InitFormAction>.Warn("接在首页展示物料失败:本地控件为Null...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void StartServer1(object sender, ElapsedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var lblPlanName = base.GetControlById("lblPlanName") as System.Windows.Forms.Label;//配方名称
|
|
|
|
|
if (lblPlanName == null)
|
|
|
|
|
{
|
|
|
|
|
timer.Stop();
|
|
|
|
|
timer.Close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_weigh").FirstOrDefault(); //获取本机台计划控件
|
|
|
|
|
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<InitFormAction>.Error("{首页展示}缺少本机台计划网格控件...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (true)
|
|
|
|
|
{
|
|
|
|
|
planFlag3 = false;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var lblRecipeName = base.GetControlById("lblRecipeName") as System.Windows.Forms.Label;//配方名称
|
|
|
|
|
var lblTotalBatch = base.GetControlById("lblTotalBatch") as System.Windows.Forms.Label;//总批次
|
|
|
|
|
|
|
|
|
|
var lblMaterial = base.GetControlById("lblMaterial") as System.Windows.Forms.Label;//物料名称
|
|
|
|
|
var XProgressBar = base.GetControlById("XProgressBar") as System.Windows.Forms.ProgressBar;//进度条
|
|
|
|
|
var lblStandardWeight = base.GetControlById("lblStandardWeight") as System.Windows.Forms.Label;//标重
|
|
|
|
|
var lblStateMessage = base.GetControlById("lblStateMessage") as System.Windows.Forms.Label;//配方名称
|
|
|
|
|
var lblPlanStateMessage = base.GetControlById("lblPlanState") as System.Windows.Forms.Label;//计划状态
|
|
|
|
|
var rate = base.GetControlById("MCLabel2") as System.Windows.Forms.Label;//理论固含
|
|
|
|
|
DataTable table = PlanHelper.GetProPlan();//正在执行的任务
|
|
|
|
|
if (table == null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
lblStateMessage.Text = "状态信息";
|
|
|
|
|
lblMaterial.Text = "物料";
|
|
|
|
|
lblPlanName.Text = "计划号";
|
|
|
|
|
lblRecipeName.Text = "配方";
|
|
|
|
|
clientGridControl.BaseControl.BindDataSource = null;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SiemensS7Net plc = PlcConnect.Instance;
|
|
|
|
|
int status01 = plc.ReadInt16("DB110.DBW1770").Content;
|
|
|
|
|
//int status01 = BasePlcHelper.Instance.solvent_status01.NowValue.ToInt();
|
|
|
|
|
if (status01 == 1)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "请加料!";
|
|
|
|
|
}
|
|
|
|
|
int status02 = plc.ReadInt16("DB110.DBW1772").Content;
|
|
|
|
|
//int status02 = BasePlcHelper.Instance.solvent_status02.NowValue.ToInt();
|
|
|
|
|
if (status02 == 1)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "超重";
|
|
|
|
|
}
|
|
|
|
|
int statusEnd = plc.ReadInt16("DB110.DBW1774").Content;
|
|
|
|
|
int runState = plc.ReadInt16("DB110.DBW1780").Content;
|
|
|
|
|
//int runState = BasePlcHelper.Instance.solvent_SystemRuning.NowValue.ToInt();
|
|
|
|
|
if (runState == 1 && status01 == 1&& statusEnd==0)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "请加料!";
|
|
|
|
|
}
|
|
|
|
|
int status04 = plc.ReadInt16("DB110.DBW1776").Content;
|
|
|
|
|
//int status04 = BasePlcHelper.Instance.solvent_status04.NowValue.ToInt();
|
|
|
|
|
if (status04 == 1&& runState == 1)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "请清空地磅,扫描之后放物料!";
|
|
|
|
|
}
|
|
|
|
|
if (status04 == 1 && runState == 0)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "请清空地磅,扫描之后放物料!";
|
|
|
|
|
}
|
|
|
|
|
if (status04 == 0 && runState == 1 && status01 ==0)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "请扫描拉缸条码,核对投料类型!";
|
|
|
|
|
}
|
|
|
|
|
if (runState == 0 && status01 == 0 && status04 == 0 && status02 == 0)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "状态信息";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (statusEnd ==1 )
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "完成";
|
|
|
|
|
}
|
|
|
|
|
List<MetagePlan> materialList = PlanHelper.DataTableToList(table);
|
|
|
|
|
if (materialList.Count == 0) { return; }
|
|
|
|
|
MetagePlan plan2 = null;
|
|
|
|
|
var matlCode = BasePlcHelper.Instance.solvent_materialNo.NowValue.ToInt();
|
|
|
|
|
if (matlCode == 0)
|
|
|
|
|
{
|
|
|
|
|
plan2 = materialList.FirstOrDefault(d => d.MID == 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
plan2 = materialList.FirstOrDefault(d => d.MID == matlCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (plan2 == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var matSerial = plan2.MID;
|
|
|
|
|
|
|
|
|
|
MetagePlan plan = materialList.FirstOrDefault(d => d.MID == matSerial);
|
|
|
|
|
if (plan2 != null) { lblPlanStateMessage.Text = plan2.Plan_StateText; }
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(planFlag))
|
|
|
|
|
{
|
|
|
|
|
if (planFlag == plan.Plan_Id)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
planFlag = plan.Plan_Id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
planFlag = plan.Plan_Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (plan != null)
|
|
|
|
|
{
|
|
|
|
|
lblPlanStateMessage.Text = plan2.Plan_StateText;
|
|
|
|
|
var p = materialList.FirstOrDefault();
|
|
|
|
|
lblPlanName.Text = p.Plan_Id;
|
|
|
|
|
lblRecipeName.Text = p.Recipe_Name;
|
|
|
|
|
lblMaterial.Text = plan.Material_name;//正在执行的物料号
|
|
|
|
|
lblStandardWeight.Text = plan.Total_Weight.ToString("f2");
|
|
|
|
|
rate.Text = plan.TheoryRate.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lock (String.Empty)
|
|
|
|
|
{
|
|
|
|
|
//本地计划
|
|
|
|
|
if (clientGridControl != null && clientGridControl.BaseControl != null)
|
|
|
|
|
{
|
|
|
|
|
clientGridControl.BaseControl.BindDataSource = null;
|
|
|
|
|
clientGridControl.BaseControl.BindDataSource = table;
|
|
|
|
|
|
|
|
|
|
#region 根据计划状态处理背景色
|
|
|
|
|
|
|
|
|
|
DataGridView clientGrid = clientGridControl.BaseControl as DataGridView;
|
|
|
|
|
SetBackColor(clientGrid);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<InitFormAction>.Warn("接在首页展示物料失败:本地计划控件为Null...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
planFlag3 = true;
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
planFlag3 = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void StartServer2(object sender, ElapsedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var lblPlanName = base.GetControlById("lblPlanName2") as System.Windows.Forms.Label;//计划名称
|
|
|
|
|
if (lblPlanName == null)
|
|
|
|
|
{
|
|
|
|
|
timer2.Stop();
|
|
|
|
|
timer2.Close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var lblRecipeName = base.GetControlById("lblRecipeName2") as System.Windows.Forms.Label;//配方名称
|
|
|
|
|
var lblTotalBatch = base.GetControlById("lblTotalBatch2") as System.Windows.Forms.Label;//总批次
|
|
|
|
|
|
|
|
|
|
var lblMaterial = base.GetControlById("lblMaterial2") as System.Windows.Forms.Label;//物料名称
|
|
|
|
|
var XProgressBar = base.GetControlById("XProgressBar2") as System.Windows.Forms.ProgressBar;//进度条
|
|
|
|
|
var lblStandardWeight = base.GetControlById("lblStandardWeight2") as System.Windows.Forms.Label;//标重
|
|
|
|
|
var lblStateMessage = base.GetControlById("lblStateMessage2") as System.Windows.Forms.Label;//配方名称
|
|
|
|
|
var lblPlanStateMessage = base.GetControlById("lblPlanState2") as System.Windows.Forms.Label;//计划状态
|
|
|
|
|
var rate = base.GetControlById("lblRate") as System.Windows.Forms.Label;//理论固含
|
|
|
|
|
|
|
|
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_weigh").FirstOrDefault(); //获取本机台计划控件
|
|
|
|
|
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<InitFormAction>.Error("{首页展示}缺少本机台计划网格控件...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DataTable table = PlanHelper.GetProWeighbridge2Plan();//正在执行的任务
|
|
|
|
|
if (table == null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
lblStateMessage.Text = "状态信息";
|
|
|
|
|
lblMaterial.Text = "物料";
|
|
|
|
|
lblPlanName.Text = "计划号";
|
|
|
|
|
lblRecipeName.Text = "配方";
|
|
|
|
|
clientGridControl.BaseControl.BindDataSource = null;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SiemensS7Net plc = PlcConnect.Instance;
|
|
|
|
|
int status01 = plc.ReadInt16("DB111.DBW1770").Content;
|
|
|
|
|
//int status01 = BasePlcHelper.Instance.solvent_status01.NowValue.ToInt();
|
|
|
|
|
if (status01 == 1)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "请加料!";
|
|
|
|
|
}
|
|
|
|
|
int status02 = plc.ReadInt16("DB111.DBW1772").Content;
|
|
|
|
|
//int status02 = BasePlcHelper.Instance.solvent_status02.NowValue.ToInt();
|
|
|
|
|
if (status02 == 1)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "超重";
|
|
|
|
|
}
|
|
|
|
|
int statusEnd = plc.ReadInt16("DB111.DBW1774").Content;
|
|
|
|
|
int runState = plc.ReadInt16("DB111.DBW1780").Content;
|
|
|
|
|
//int runState = BasePlcHelper.Instance.solvent_SystemRuning.NowValue.ToInt();
|
|
|
|
|
if (runState == 1 && status01 == 1 && statusEnd == 0)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "请加料!";
|
|
|
|
|
}
|
|
|
|
|
int status04 = plc.ReadInt16("DB111.DBW1776").Content;
|
|
|
|
|
//int status04 = BasePlcHelper.Instance.solvent_status04.NowValue.ToInt();
|
|
|
|
|
if (status04 == 1 && runState == 1)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "请清空地磅,扫描之后放物料!";
|
|
|
|
|
}
|
|
|
|
|
if (status04 == 1 && runState == 0)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "请清空地磅,扫描之后放物料!";
|
|
|
|
|
}
|
|
|
|
|
if (status04 == 0 && runState == 1 && status01 == 0)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "请扫描拉缸条码,核对投料类型!";
|
|
|
|
|
}
|
|
|
|
|
if (runState == 0 && status01 == 0 && status04 == 0 && status02 == 0)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "状态信息";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (statusEnd == 1)
|
|
|
|
|
{
|
|
|
|
|
lblStateMessage.Text = "完成";
|
|
|
|
|
}
|
|
|
|
|
List<MetagePlan> materialList = PlanHelper.DataTableToList(table);
|
|
|
|
|
if (materialList.Count == 0) { return; }
|
|
|
|
|
MetagePlan plan2 = null;
|
|
|
|
|
var matlCode = BasePlcHelper.Instance.solvent_materialNo.NowValue.ToInt();
|
|
|
|
|
if (matlCode == 0)
|
|
|
|
|
{
|
|
|
|
|
plan2 = materialList.FirstOrDefault(d => d.MID == 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
plan2 = materialList.FirstOrDefault(d => d.MID == matlCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (plan2 == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var matSerial = plan2.MID;
|
|
|
|
|
|
|
|
|
|
MetagePlan plan = materialList.FirstOrDefault(d => d.MID == matSerial);
|
|
|
|
|
if (plan2 != null) { lblPlanStateMessage.Text = plan2.Plan_StateText; }
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(planFlag2))
|
|
|
|
|
{
|
|
|
|
|
if (planFlag2 == plan.Plan_Id)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
planFlag2 = plan.Plan_Id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
planFlag2 = plan.Plan_Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (plan != null)
|
|
|
|
|
{
|
|
|
|
|
lblPlanStateMessage.Text = plan2.Plan_StateText;
|
|
|
|
|
var p = materialList.FirstOrDefault();
|
|
|
|
|
lblPlanName.Text = p.Plan_Id;
|
|
|
|
|
lblRecipeName.Text = p.Recipe_Name;
|
|
|
|
|
lblMaterial.Text = plan.Material_name;//正在执行的物料号
|
|
|
|
|
lblStandardWeight.Text = plan.Total_Weight.ToString("f2");
|
|
|
|
|
rate.Text = plan.TheoryRate.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lock (String.Empty)
|
|
|
|
|
{
|
|
|
|
|
//本地计划
|
|
|
|
|
if (clientGridControl != null && clientGridControl.BaseControl != null)
|
|
|
|
|
{
|
|
|
|
|
clientGridControl.BaseControl.BindDataSource = null;
|
|
|
|
|
clientGridControl.BaseControl.BindDataSource = table;
|
|
|
|
|
|
|
|
|
|
#region 根据计划状态处理背景色
|
|
|
|
|
|
|
|
|
|
DataGridView clientGrid = clientGridControl.BaseControl as DataGridView;
|
|
|
|
|
SetBackColor(clientGrid);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<InitFormAction>.Warn("接在首页展示物料失败:本地计划控件为Null...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateShow1(object sender, ElapsedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var lblPlanName = base.GetControlById("lblPlanName2") as System.Windows.Forms.Label;//计划名称
|
|
|
|
|
if (lblPlanName == null)
|
|
|
|
|
{
|
|
|
|
|
timer3.Stop();
|
|
|
|
|
timer3.Close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (Flag4)
|
|
|
|
|
{
|
|
|
|
|
Flag4 = false;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var lblReqSerialName = base.GetControlById("lblTotalBatch") as System.Windows.Forms.Label;//计划数
|
|
|
|
|
var lblFinishedNumName = base.GetControlById("MCLabel203") as System.Windows.Forms.Label;//完成数
|
|
|
|
|
var lblResidueNumName = base.GetControlById("MCLabel244") as System.Windows.Forms.Label;//剩余
|
|
|
|
|
var lblRealTimeWeightName = base.GetControlById("lblRealTimeWeight") as System.Windows.Forms.Label;//实时
|
|
|
|
|
var lblSetWeight = base.GetControlById("lblSetWeight") as System.Windows.Forms.Label;//设定重量
|
|
|
|
|
var lblTankNo = base.GetControlById("lblTankNo") as System.Windows.Forms.Label;//罐号
|
|
|
|
|
var lblRate = base.GetControlById("MCLabel240") as System.Windows.Forms.Label;//实际固含
|
|
|
|
|
var pbName = base.GetControlById("XProgressBar") as System.Windows.Forms.ProgressBar;//柱状图
|
|
|
|
|
var lblTimeOut = base.GetControlById("lblTimeOut") as System.Windows.Forms.Label;//倒计时
|
|
|
|
|
var lblStatus01 = base.GetControlById("GreenLight2") as Mesnac.Controls.ChemicalWeighing.GreenLight;//加料
|
|
|
|
|
var lblStatus02 = base.GetControlById("RedLight2") as Mesnac.Controls.ChemicalWeighing.RedLight;//超重
|
|
|
|
|
var lblStatus03 = base.GetControlById("YellewLight2") as Mesnac.Controls.ChemicalWeighing.YellewLight;//完成
|
|
|
|
|
var btn16 = base.GetControlById("MCBtn16") as System.Windows.Forms.Button;//设定值
|
|
|
|
|
var btn17 = base.GetControlById("MCBtn17") as System.Windows.Forms.Button;//实时值
|
|
|
|
|
|
|
|
|
|
SiemensS7Net plc = PlcConnect.Instance;
|
|
|
|
|
int reqSerial = plc.ReadInt16("DB110.DBW22").Content;//计划数
|
|
|
|
|
lblReqSerialName.Text = reqSerial.ToString();
|
|
|
|
|
int finishedNum = plc.ReadInt16("DB110.DBW2").Content;//完成数
|
|
|
|
|
lblFinishedNumName.Text = finishedNum.ToString();
|
|
|
|
|
int residueNum = (plc.ReadInt16("DB110.DBW8").Content / 10) - (plc.ReadInt16("DB110.DBW16").Content / 10);//剩余数
|
|
|
|
|
lblResidueNumName.Text = residueNum.ToString();
|
|
|
|
|
int scaleWeight = plc.ReadInt16("DB110.DBW0").Content / 10;//实时
|
|
|
|
|
lblRealTimeWeightName.Text = scaleWeight.ToString();
|
|
|
|
|
int set_R = plc.ReadInt16("DB110.DBW8").Content / 10;//设定重量||柱状图最大值
|
|
|
|
|
lblSetWeight.Text = set_R.ToString();
|
|
|
|
|
int materialNo = plc.ReadInt16("DB110.DBW1758").Content / 10;//罐号
|
|
|
|
|
lblTankNo.Text = materialNo.ToString();
|
|
|
|
|
decimal p= decimal.Parse(plc.ReadInt16("DB110.DBW10").Content.ToString());
|
|
|
|
|
decimal rate_R = p / 100;//实际固含
|
|
|
|
|
|
|
|
|
|
lblRate.Text = rate_R.ToString();
|
|
|
|
|
int timeOut = plc.ReadInt16("DB110.DBW1766").Content;//倒计时
|
|
|
|
|
lblTimeOut.Text = timeOut.ToString();
|
|
|
|
|
int act_Weight = plc.ReadInt16("DB110.DBW16").Content / 10;//柱状图实时值||实际重量
|
|
|
|
|
pbName.Maximum = set_R;
|
|
|
|
|
pbName.Minimum = 0;
|
|
|
|
|
pbName.Value = act_Weight;
|
|
|
|
|
|
|
|
|
|
btn16.Text = set_R.ToString();
|
|
|
|
|
btn17.Text = scaleWeight.ToString();
|
|
|
|
|
int status01 = plc.ReadInt16("DB110.DBW1770").Content;//加料
|
|
|
|
|
if (status01 == 1)
|
|
|
|
|
{
|
|
|
|
|
lblStatus01.Status = Mesnac.Controls.ChemicalWeighing.GreenLight.Statuses.ylMove;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lblStatus01.Status = Mesnac.Controls.ChemicalWeighing.GreenLight.Statuses.ylNormal;
|
|
|
|
|
}
|
|
|
|
|
int status02 = plc.ReadInt16("DB110.DBW1772").Content;//完成
|
|
|
|
|
if (status02 == 1)
|
|
|
|
|
{
|
|
|
|
|
lblStatus03.Status = Mesnac.Controls.ChemicalWeighing.YellewLight.Statuses.ylYellew;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lblStatus03.Status = Mesnac.Controls.ChemicalWeighing.YellewLight.Statuses.ylNormal;
|
|
|
|
|
}
|
|
|
|
|
int status03 = plc.ReadInt16("DB110.DBW1774").Content;//超重
|
|
|
|
|
if (status03 == 1)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
lblStatus02.Status = Mesnac.Controls.ChemicalWeighing.RedLight.Statuses.ylAlarm;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lblStatus02.Status = Mesnac.Controls.ChemicalWeighing.RedLight.Statuses.ylNormal;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Flag4 = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private void UpdateShow2(object sender, ElapsedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var lblPlanName = base.GetControlById("lblPlanName2") as System.Windows.Forms.Label;//计划名称
|
|
|
|
|
if (lblPlanName == null)
|
|
|
|
|
{
|
|
|
|
|
timer4.Stop();
|
|
|
|
|
timer4.Close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (Flag5)
|
|
|
|
|
{
|
|
|
|
|
Flag5 = false;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var lblReqSerialName = base.GetControlById("MCLabel217") as System.Windows.Forms.Label;//计划数
|
|
|
|
|
var lblFinishedNumName = base.GetControlById("MCLabel213") as System.Windows.Forms.Label;//完成数
|
|
|
|
|
var lblResidueNumName = base.GetControlById("MCLabel246") as System.Windows.Forms.Label;//剩余
|
|
|
|
|
var lblRealTimeWeightName = base.GetControlById("MCLabel223") as System.Windows.Forms.Label;//实时
|
|
|
|
|
var lblSetWeight = base.GetControlById("MCLabel222") as System.Windows.Forms.Label;//设定重量
|
|
|
|
|
var lblTankNo = base.GetControlById("MCLabel218") as System.Windows.Forms.Label;//罐号
|
|
|
|
|
var lblRate = base.GetControlById("MCLabel237") as System.Windows.Forms.Label;//实际固含
|
|
|
|
|
var pbName = base.GetControlById("XProgressBar2147483646") as System.Windows.Forms.ProgressBar;//柱状图
|
|
|
|
|
var lblTimeOut = base.GetControlById("MCLabel229") as System.Windows.Forms.Label;//倒计时
|
|
|
|
|
var lblStatus01 = base.GetControlById("GreenLight1") as Mesnac.Controls.ChemicalWeighing.GreenLight;//加料
|
|
|
|
|
var lblStatus02 = base.GetControlById("RedLight1") as Mesnac.Controls.ChemicalWeighing.RedLight;//超重
|
|
|
|
|
var lblStatus03 = base.GetControlById("YellewLight1") as Mesnac.Controls.ChemicalWeighing.YellewLight;//完成
|
|
|
|
|
var btn16 = base.GetControlById("MCBtn15") as System.Windows.Forms.Button;//设定值
|
|
|
|
|
var btn17 = base.GetControlById("MCBtn14") as System.Windows.Forms.Button;//实时值
|
|
|
|
|
|
|
|
|
|
SiemensS7Net plc = PlcConnect.Instance;
|
|
|
|
|
int reqSerial = plc.ReadInt16("DB111.DBW22").Content;//计划数
|
|
|
|
|
lblReqSerialName.Text = reqSerial.ToString();
|
|
|
|
|
int finishedNum = plc.ReadInt16("DB111.DBW2").Content;//完成数
|
|
|
|
|
lblFinishedNumName.Text = finishedNum.ToString();
|
|
|
|
|
int residueNum = (plc.ReadInt16("DB111.DBW8").Content / 10) - (plc.ReadInt16("DB111.DBW16").Content / 10);//剩余数
|
|
|
|
|
lblResidueNumName.Text = residueNum.ToString();
|
|
|
|
|
int scaleWeight = plc.ReadInt16("DB111.DBW0").Content / 10;//实时
|
|
|
|
|
lblRealTimeWeightName.Text = scaleWeight.ToString();
|
|
|
|
|
int set_R = plc.ReadInt16("DB111.DBW8").Content / 10;//设定重量||柱状图最大值
|
|
|
|
|
lblSetWeight.Text = set_R.ToString();
|
|
|
|
|
int materialNo = plc.ReadInt16("DB111.DBW1758").Content / 10;//罐号
|
|
|
|
|
lblTankNo.Text = materialNo.ToString();
|
|
|
|
|
decimal p = decimal.Parse(plc.ReadInt16("DB111.DBW10").Content.ToString());
|
|
|
|
|
decimal rate_R = p / 100;//实际固含
|
|
|
|
|
|
|
|
|
|
lblRate.Text = rate_R.ToString();
|
|
|
|
|
int timeOut = plc.ReadInt16("DB111.DBW1766").Content;//倒计时
|
|
|
|
|
lblTimeOut.Text = timeOut.ToString();
|
|
|
|
|
int act_Weight = plc.ReadInt16("DB111.DBW16").Content / 10;//柱状图实时值||实际重量
|
|
|
|
|
pbName.Maximum = set_R;
|
|
|
|
|
pbName.Minimum = 0;
|
|
|
|
|
pbName.Value = act_Weight;
|
|
|
|
|
|
|
|
|
|
btn16.Text = set_R.ToString();
|
|
|
|
|
btn17.Text = scaleWeight.ToString();
|
|
|
|
|
int status01 = plc.ReadInt16("DB111.DBW1770").Content;//加料
|
|
|
|
|
if (status01 == 1)
|
|
|
|
|
{
|
|
|
|
|
lblStatus01.Status = Mesnac.Controls.ChemicalWeighing.GreenLight.Statuses.ylMove;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lblStatus01.Status = Mesnac.Controls.ChemicalWeighing.GreenLight.Statuses.ylNormal;
|
|
|
|
|
}
|
|
|
|
|
int status02 = plc.ReadInt16("DB111.DBW1772").Content;//完成
|
|
|
|
|
if (status02 == 1)
|
|
|
|
|
{
|
|
|
|
|
lblStatus03.Status = Mesnac.Controls.ChemicalWeighing.YellewLight.Statuses.ylYellew;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lblStatus03.Status = Mesnac.Controls.ChemicalWeighing.YellewLight.Statuses.ylNormal;
|
|
|
|
|
}
|
|
|
|
|
int status03 = plc.ReadInt16("DB111.DBW1774").Content;//超重
|
|
|
|
|
if (status03 == 1)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
lblStatus02.Status = Mesnac.Controls.ChemicalWeighing.RedLight.Statuses.ylAlarm;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lblStatus02.Status = Mesnac.Controls.ChemicalWeighing.RedLight.Statuses.ylNormal;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Flag5 = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 设置(网格控件)计划状态背景色
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置计划状态背景色
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="grid"></param>
|
|
|
|
|
public static void SetBackColor(DataGridView grid)
|
|
|
|
|
{
|
|
|
|
|
lock (String.Empty)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (grid == null || grid.Visible == false)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Warn("设置背景色失败:网格控件为null或不可见");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grid.ClearSelection(); //清空选中行
|
|
|
|
|
grid.ColumnHeadersHeight = 25;
|
|
|
|
|
grid.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
|
|
|
|
grid.RowHeadersVisible = false;
|
|
|
|
|
grid.RowTemplate.Height = 28;
|
|
|
|
|
grid.RowsDefaultCellStyle.Font = new System.Drawing.Font("宋体", 12, System.Drawing.FontStyle.Bold);
|
|
|
|
|
foreach (DataGridViewRow row in grid.Rows)
|
|
|
|
|
{
|
|
|
|
|
row.DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(220, 220, 220); //灰色
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<InitFormAction>.Error("设置背景色失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|