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.

105 lines
3.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Mesnac.Action.Base;
using Mesnac.Controls.Base;
using System.Windows.Forms;
using Mesnac.Codd.Session;
using Mesnac.Equips;
using Mesnac.Equips.BaseInfo;
using Mesnac.Action.Feeding.FeedingPlc;
using Mesnac.Action.Feeding.BasicInfo;
namespace Mesnac.Action.Feeding.FinishBatch
{
/// <summary>
/// 连续执行计划关键业务实现类
/// </summary>
public class OnFinishBatch : FeedingAction, IAction
{
private RuntimeParameter _runtime = null;
private bool isRun = false;
private void ReadData(object sender, Mesnac.Equips.ReadEventArgs e)
{
if (isRun)
{
return;
}
try
{
isRun = true;
#region 0、执行胶料称输送控制
RunShuSongHandler.Execute();
#endregion
#region 1、更新网络表中改设备的运行状态移到计时器服务类中
//if (base.NetType == NetTypes.Net)
//{
// new FeedingPlc.UpdateEquipState().Run(this._runtime);
//}
#endregion
#region 2、记录停机记录
//1、获取最后一次存盘时间保存至配置文件最后存盘时间>=3分钟 && 密炼时间PLC获取== 0 时插入停机记录,并且每分钟更新一次停机结束时间
StartStopRecord.Run();
#endregion
#region 3、设置报警状态
//SetAlermStatu
new SetAlarmStatus().Run(this._runtime);
#endregion
#region 4、实时保存配方时间
int recipeTime = PlcData.Instance.CurrentMixingTime.LastValue.ToInt();
if (recipeTime > 0)
{
SaveDataPerLotHandler.RecipeTime = recipeTime; //记录配方密炼时间
StartStopRecord.LastMixRunTime = DateTime.Now; //记录密炼最后运行时间
StartStopRecord.IsInsert = false; //清除停机记录追加标识
}
#endregion
if (new FinishBatchFlag().Run()) //存盘信号判断
{
new AutuExecuteNextPlan().Run(); //自动下传称量配方
}
new SaveFinishBatch().Run(); //保存胶料生成数据 执行下一个计划
}
finally
{
isRun = false;
}
}
private static bool OnlyRun1Time = false;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime);
//this._runtime = runtime;
//if (OnlyRun1Time)
//{
// return;
//}
//base.LogDebug("OnFinishBatch-数据存盘业务启动...");
//OnlyRun1Time = true;
//foreach (BaseEquip equip in Mesnac.Equips.Factory.Instance.AllEquips.Values)
//{
// equip.EquipReadData += ReadData;
//}
}
}
}