|
- using BPA.Message.Enum;
- using BPASmartClient.Device;
- using BPASmartClient.EventBus;
- using BPASmartClient.Helper;
- using BPASmartClient.Model;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using static BPASmartClient.EventBus.EventBus;
-
- namespace BPASmartClient.MorkBF
- {
- public class Control_MorkBF : BaseDevice
- {
- GVL_MorkBF morkBF = new GVL_MorkBF();
-
- public override DeviceClientType DeviceType => DeviceClientType.MORKCS;
-
- public override void DoMain()
- {
- CommandRegist();//调试
- ServerInit();
- DataParse();//数据解析
- DeviceProcessLogShow("MORKF 设备初始化完成");
- }
-
- private void DataParse()
- {
- EventBus.EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle)
- {
- if (@event == null) return;
- if (@event is DoOrderEvent order)
- {
- if (order.MorkOrder.GoodBatchings == null) return;
- OrderCount++;
- DeviceProcessLogShow($"接收到{OrderCount}次订单");
-
-
-
- }
-
- });
- }
-
- private void ServerInit()
- {
- //物料信息
- EventBus.EventBus.GetInstance().Subscribe<MaterialDeliveryEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
- {
- if (@event == null) return;
- if (@event is MaterialDeliveryEvent material)
- {
- orderMaterialDelivery = material.orderMaterialDelivery;
-
- }
- });
-
- //配方数据信息
- EventBus.EventBus.GetInstance().Subscribe<RecipeBomEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
- {
- if (@event == null) return;
- if (@event is RecipeBomEvent recipe)
- {
- recipeBoms = recipe.recipeBoms;
- }
- });
- }
- /// <summary>
- /// 调试
- /// </summary>
- /// <exception cref="NotImplementedException"></exception>
- private void CommandRegist()
- {
-
- }
-
- public override void MainTask()
- {
- if(morkBF.FirePan1_Order.Count == 0&&!morkBF.FirePan1_Busy)
- {
- ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1主进程");
- }
-
- if (morkBF.FirePan2_Order.Count == 0 && !morkBF.FirePan2_Busy)
- {
- ThreadManage.GetInstance().Start(FirePot2_Process, "炒锅2主进程");
- }
- }
-
- private void FirePot1_Process()
- {
- morkBF.FirePan1_Busy = true;
- morkBF.FirePan1_Date = DateTime.Now;
- while (morkBF.FirePan1_Date.AddMinutes(1)> DateTime.Now)
- {
- Thread.Sleep(500);
- }
- ThreadManage.GetInstance().StopTask("炒锅1主进程");
- }
-
- private void FirePot2_Process()
- {
- morkBF.FirePan2_Busy = true;
- morkBF.FirePan2_Date = DateTime.Now;
- while (morkBF.FirePan2_Date.AddMinutes(1) > DateTime.Now)
- {
- Thread.Sleep(500);
- }
- ThreadManage.GetInstance().StopTask("炒锅2主进程");
- }
-
- public override void ReadData()
- {
-
- }
-
- public override void ResetProgram()
- {
- morkBF = null;
- morkBF = new GVL_MorkBF();
- }
-
- public override void SimOrder()
- {
-
- }
-
- public override void Stop()
- {
-
- }
- }
- }
|