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.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs

153 lines
4.3 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using ICSharpCode.Core;
using Mesnac.Equips;
using Mesnac.Codd.Session;
using Mesnac.Controls.Base;
using Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper;
namespace Mesnac.Action.ChemicalWeighing.FinishBatch
{
/// <summary>
/// 生产管理-后台业务-生产数据存盘业务服务类
/// </summary>
public class FinishBatchService
{
#region 字段定义
/// <summary>
/// 运行状态true:已运行false未运行
/// </summary>
private bool runState = false;
#endregion
#region 单例实现
private static FinishBatchService _instance = null;
private FinishBatchService()
{
}
public static FinishBatchService Instance
{
get
{
lock (String.Empty)
{
if (_instance == null)
{
_instance = new FinishBatchService();
}
return _instance;
}
}
}
#endregion
#region 启动服务
public void Start()
{
try
{
if (this.runState)
{
return;
}
lock (String.Empty)
{
Mesnac.Equips.Factory.Instance.SetMinHZReadDataEvent(ReadData);
this.runState = true;
}
}
catch(Exception ex)
{
ICSharpCode.Core.LoggingService<FinishBatchService>.Error("自动更新计划状态服务异常:" + ex.Message, ex);
}
}
#endregion
#region 停止服务
public void Stop()
{
try
{
if (!this.runState)
{
return;
}
lock (String.Empty)
{
ICSharpCode.Core.LoggingService<FinishBatchService>.Debug("开始停止生产数据存盘服务...");
Mesnac.Equips.Factory.Instance.ClearMinHZReadDataEvent(ReadData);
ICSharpCode.Core.LoggingService<FinishBatchService>.Debug("停止生产数据存盘服务完毕!");
this.runState = false;
}
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService<FinishBatchService>.Error("停止生产数据存盘业务服务异常:" + ex.Message, ex);
}
}
#endregion
#region 事件处理
private void ReadData(object sender, Mesnac.Equips.ReadEventArgs e)
{
try
{
lock(String.Empty)
{
#region 0、实时刷新自动保存报警
// ReportWetMixerSaveHelper.Instance.SaveWetMixerReport();
#endregion
}
}
catch(Exception ex)
{
ICSharpCode.Core.LoggingService<FinishBatchService>.Error(ex.Message, ex);
}
finally
{
#region 6、设置PCok信号为空闲
//#region 保存存盘
//BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ReportSave_MixWeight_PC_PCok, new object[] { 1 }, false);
//BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ReportSave_Mix_PC_PCok, new object[] { 1 }, false);
//BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ReportSave_MillWeight_PC_PCok, new object[] { 1 }, false);
//BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ReportSave_Mill_PC_PCok, new object[] { 1 }, false);
//#endregion
//#region 配方交互
//BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.Mix_RecipeDL_PC_PCok, new object[] { 1 }, false);
//#endregion
#endregion
}
}
#endregion
}
}