|
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.Helper;
- using BPASmartClient.JXJFoodSmallStation.Model.GVL;
- using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
- using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial;
- using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
- using BPASmartClient.JXJFoodSmallStation.Model.WindSend;
- using BPASmartClient.Modbus;
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Configuration;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.JXJFoodSmallStation.Model
- {
- public class ProcessControl
- {
- private volatile static ProcessControl _Instance;
- public static ProcessControl GetInstance => _Instance ?? (_Instance = new ProcessControl());
- private ProcessControl() { }
-
- /// <summary>
- /// 配方数据
- /// </summary>
- public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>();
- /// <summary>
- /// 原料的名称和料仓的位置对应
- /// </summary>
- public Dictionary<string, short> RawMaterialsNamePos = new Dictionary<string, short>();
- public ObservableCollection<RawMaterialStockBin> RawMaterialsInfo => Json<DevicePar>.Data.rawMaterialStockBin;
- /// <summary>
- /// 配方队列
- /// </summary>
- public ConcurrentQueue<string> RecipeQueueTray1 = new ConcurrentQueue<string>();
-
- public ConcurrentQueue<string> RecipeQueueTray2 = new ConcurrentQueue<string>();
-
-
-
- public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
- public HKDeviceStatus HKDevice = new HKDeviceStatus();
- public WindSendDeviceStatus WindSendDevice = new WindSendDeviceStatus();
-
- public ObservableCollection<PlcInfos> CommData { get; set; } = new ObservableCollection<PlcInfos>();
- public ObservableCollection<PlcInfos> ProcessVar { get; set; } = new ObservableCollection<PlcInfos>();
- XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB();
- /// <summary>
- /// 风送PLC的DB块
- /// </summary>
- WindSend_Write WindSendData = new WindSend_Write();
- /// <summary>
- /// 接收原料数据
- /// </summary>
- public RecipeRawMaterial RawMaterial;
- public DateTime StockBinAlarmTime = DateTime.Now;
-
- public string? HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
- public string? Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
- public string? WindSend_PLC_IP = ConfigurationManager.AppSettings["WindSend_IP"];
-
- public void Init()
- {
- PlcVarMonitor();
- StockBinNameWithPos();
- RawMaterialNameWithCode();
- RegisterInit();
- DeviceConnect();
- //Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- if (HKDevice.IsConnected)
- {
- GVL_SmallStation.GetInstance.HeartBeatToPlc = !GVL_SmallStation.GetInstance.HeartBeatToPlc;
- HKDevice.HK_PLC_S7.Write("DB4.DBX0.0", GVL_SmallStation.GetInstance.HeartBeatToPlc);
- GVL_SmallStation.GetInstance.HeartBeatFromPlc = HKDevice.HK_PLC_S7.Read<bool>("DB45.DBX0.0");
- if (DeviceInquire.GetInstance.devices.Count < 15 && HKDevice.IsConnected && Json<RemoteRecipeDataColl>.Data.Recipes.Count > 0 && GVL_SmallStation.GetInstance.DisEnableStockBinAlarm == false && DateTime.Now.Subtract(StockBinAlarmTime).TotalSeconds >= 60)
- {
- HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
- App.Current.Dispatcher.Invoke(() =>
- {
- MessageNotify.GetInstance.ShowDialog($"未读取到15个柔性味魔方料仓", DialogType.Error);
- StockBinAlarmTime = DateTime.Now;
- });
- HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
- }
- }
- Thread.Sleep(200);
- }), "海科plc通信心跳", true);
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- if (GVL_SmallStation.GetInstance.Order_Cancel)
- {
- CancelOrder();//订单取消,不执行配方流程
- }
- else
- {
- ReceviceData();//配方请求
- RecipeInfoToHKPLC();//配方配料
- }
- Thread.Sleep(10);
- }), "小料站流程控制", true);
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- RealTimeData();
- foreach (var item in Json<DevicePar>.Data.windSendRawMaterial)
- {
- if (GVL_SmallStation.GetInstance.RawMaterialsNameCode.ContainsKey(item.RawMaterialName))
- {
- item.RawMaterialChineseName = GVL_SmallStation.GetInstance.RawMaterialsNameCode[item.RawMaterialName];
- }
- else
- {
- item.RawMaterialChineseName = "";
- }
- }
- Thread.Sleep(10);
- }), "西门子PLC和小料站PLC的实时数据交互流程", true);
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- HKPlcRead();
- GetStatus();
- Thread.Sleep(10);
- }), "海科PLC实时数据", true);
- }
- /// <summary>
- /// 气缸的传感器值
- /// </summary>
- private void GetStatus()
- {
- for (int i = 0; i < 8; i++)
- {
- GVL_SmallStation.GetInstance.Cylinder_JackInfo[i] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX0." + i);
- }
- for (int i = 0; i < 7; i++)
- {
- GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX1." + i);
- }
- GVL_SmallStation.GetInstance.Cylinder_JackInfo[20] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX3.6");//进料桶气缸
- GVL_SmallStation.GetInstance.Cylinder_JackInfo[21] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX3.7");//出料筒气缸1
- GVL_SmallStation.GetInstance.Cylinder_JackInfo[22] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX4.0");//出料筒气缸2
- GVL_SmallStation.GetInstance.Cylinder_JackInfo[23] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX4.1");//出料筒气缸3
-
- GVL_SmallStation.GetInstance.Cylinder_JackInfo[24] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX4.2");//托盘1_1气缸
- GVL_SmallStation.GetInstance.Cylinder_JackInfo[25] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX4.3");//托盘1_2气缸
- GVL_SmallStation.GetInstance.Cylinder_JackInfo[26] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX4.4");//托盘2_1气缸
- GVL_SmallStation.GetInstance.Cylinder_JackInfo[27] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX4.5");//托盘2_2气缸
- }
- /// <summary>
- /// DB块的变量实时值
- /// </summary>
- private void HKPlcRead()
- {
- if (HKDevice.IsConnected)
- {
- foreach (PropertyInfo item in typeof(PlcReadAddressDB3).GetProperties())
- {
- int index = Array.FindIndex(CommData.ToArray(), p => p.Name == item.Name);
- if (index >= 0)
- {
- CommData.ElementAt(index).Value = GVL_SmallStation.GetInstance.plcReadDataDB3.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.GetInstance.plcReadDataDB3, null).ToString();
- }
- }
- }
- foreach (PropertyInfo item in typeof(GVL_SmallStation).GetProperties())
- {
- int index = Array.FindIndex(ProcessVar.ToArray(), p => p.Name == item.Name);
- if (index >= 0)
- {
- ProcessVar.ElementAt(index).Value = GVL_SmallStation.GetInstance.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.GetInstance, null).ToString();
- }
- }
- }
- /// <summary>
- /// 小料站和西门子PLC之间的实时数据
- /// </summary>
- private void RealTimeData()
- {
- if (HKDevice.IsConnected)
- {
- //获取系统状态
- GVL_SmallStation.GetInstance.PlcSystemIsAutoRun = HKDevice.HK_PLC_S7.Read<bool>("DB44.DBX0.0");//系统启停
- GVL_SmallStation.GetInstance.PlcSystemMode = HKDevice.HK_PLC_S7.Read<bool>("DB44.DBX0.1");//系统模式
- GVL_SmallStation.GetInstance.PlcSystemIsPause = HKDevice.HK_PLC_S7.Read<bool>("DB44.DBX0.2");//系统暂停
-
- GVL_SmallStation.GetInstance.Station1HaveTray = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX0.7");//工站1 有货架
- GVL_SmallStation.GetInstance.Station2HaveTray = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.0");//工站2 有货架
- if (GVL_SmallStation.GetInstance.WindSendDosingComple)
- {
- HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.7", true);
- GVL_SmallStation.GetInstance.WindSendDosingComple = false;
- MessageNotify.GetInstance.ShowRunLog("风送配料完成信号,发给产线plc信号");
- }
- if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1"))
- {
- HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.7", false);
- }
- if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.7"))//允许下配方1或者允许下配方2
- {
- GVL_SmallStation.GetInstance.IsAllowSiemensSendRecipe = true;
- }
- GVL_SmallStation.GetInstance.Station1Sensor = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.1");
- GVL_SmallStation.GetInstance.Station2Sensor = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.2");
- GVL_SmallStation.GetInstance.Station1Cylinder = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.3");
- GVL_SmallStation.GetInstance.Station2Cylinder = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.4");
- GVL_SmallStation.GetInstance.RobotStatus = HKDevice.HK_PLC_S7.Read<ushort>("DB3.DBW100");
- GVL_SmallStation.GetInstance.RobotProgramNum = HKDevice.HK_PLC_S7.Read<byte>("DB3.DBB102");
- }
- if (SiemensDevice.IsConnected)
- {
- ushort TrayCylinder = 0;
- ushort TraySensor = 0;
- if (GVL_SmallStation.GetInstance.Station1Sensor)
- {
- TraySensor = TraySensor.SetBitValue(1, true);
- }
- else
- {
- TraySensor = TraySensor.SetBitValue(0, false);
- }
- if (!GVL_SmallStation.GetInstance.Station1Cylinder)
- {
- TrayCylinder = TrayCylinder.SetBitValue(1, true);
- }
- else
- {
- TrayCylinder = TrayCylinder.SetBitValue(0, false);
- }
- this.SiemensDevice.Siemens_PLC_S7.Write<bool>("DB2231.DBX28.4", GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet);
- this.SiemensDevice.Siemens_PLC_S7.Write<ushort>("DB2231.DBW190", TraySensor);//添加工位传感器的信号
- this.SiemensDevice.Siemens_PLC_S7.Write<ushort>("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号
- ushort AGV_Put = (ushort)SiemensDevice.XL_Status.AgvFinishPut;
- if (AGV_Put.Get16bitValue(1))
- {
- GVL_SmallStation.GetInstance.AGV_PutTray1Finish = true;
- }
- else
- {
- GVL_SmallStation.GetInstance.AGV_PutTray1Finish = false;
- }
- ushort AGV_Get = (ushort)SiemensDevice.XL_Status.AgvFinishGet;
- if (AGV_Get.Get16bitValue(1))
- {
- GVL_SmallStation.GetInstance.AGV_GetTray1Finish = true;
- }
- else
- {
- GVL_SmallStation.GetInstance.AGV_GetTray1Finish = false;
- }
- }
- }
-
- public void CancelOrder()
- {
- if (GVL_SmallStation.GetInstance.Order_Cancel) //订单取消
- {
- if (!string.IsNullOrEmpty(GVL_SmallStation.GetInstance.Order_CancelRecipeCode))
- {
- string code = GVL_SmallStation.GetInstance.Order_CancelRecipeCode;
- int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == code);
- switch (GVL_SmallStation.GetInstance.OrderCancelStep)
- {
- case 0://前提条件判断
- if (index == -1)
- {
- GVL_SmallStation.GetInstance.OrderCancelStep = 30;
- MessageNotify.GetInstance.ShowRunLog($"配方中并未找到订单{code}");
- }
- else
- {
- if (RecipeQueueTray1.Contains(GVL_SmallStation.GetInstance.Order_CancelRecipeCode))
- {
- GVL_SmallStation.GetInstance.OrderCancelStep = 1;
- }
- else if (RecipeQueueTray2.Contains(GVL_SmallStation.GetInstance.Order_CancelRecipeCode))
- {
- GVL_SmallStation.GetInstance.OrderCancelStep = 10;
- }
- else
- {
- GVL_SmallStation.GetInstance.OrderCancelStep = 20;
- }
- }
- break;
-
- //Case 1-9为
- case 1:
- if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 != 0)
- {
- GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
- HKDevice.HK_PLC_S7.Write("DB4.DBX2.1", true);
- MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}");
- GVL_SmallStation.GetInstance.OrderCancelStep = 2;
- }
- else
- {
- MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}");
- GVL_SmallStation.GetInstance.OrderCancelStep = 3;
- }
- break;
- case 2:
- if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.5"))
- {
- if (GVL_SmallStation.GetInstance.Station1Cylinder == false)
- {
- GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
- GVL_SmallStation.GetInstance.OrderCancelStep = 3;
- MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}");
- }
- }
- break;
- case 3:
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
- GVL_SmallStation.GetInstance.OrderCancelStep = 4;
- break;
- case 4:
- if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
- {
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
- GVL_SmallStation.GetInstance.OrderCancelStep = 9;
- MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
- }
- break;
- case 9:
- App.Current.Dispatcher.Invoke(() =>
- {
- Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);
- });
- RecipeQueueTray1.TryDequeue(out code);
- GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
- GVL_SmallStation.GetInstance.Order_Cancel = false;
- GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
- GVL_SmallStation.GetInstance.OrderCancelStep = 0;
- break;
- case 10:
- if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 != 0)
- {
- GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
- HKDevice.HK_PLC_S7.Write("DB4.DBX2.2", true);
- MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}");
- GVL_SmallStation.GetInstance.OrderCancelStep = 11;
- }
- else
- {
- MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}");
- GVL_SmallStation.GetInstance.OrderCancelStep = 12;
- }
- break;
- case 11:
- if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.6"))
- {
- if (GVL_SmallStation.GetInstance.Station2Cylinder == false)
- {
- GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
- GVL_SmallStation.GetInstance.OrderCancelStep = 12;
- MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}");
- }
- }
- break;
-
- case 12:
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
- GVL_SmallStation.GetInstance.OrderCancelStep = 13;
- break;
- case 13:
- if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
- {
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
- GVL_SmallStation.GetInstance.OrderCancelStep = 14;
- MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
- }
- break;
- case 19:
- App.Current.Dispatcher.Invoke(() =>
- {
- Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);
- });
- RecipeQueueTray2.TryDequeue(out code);
- GVL_SmallStation.GetInstance.Order_Cancel = false;
- GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;
- GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
- GVL_SmallStation.GetInstance.OrderCancelStep = 0;
- break;
-
- //20-29为订单还未下发至PLC
- case 20:
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
- GVL_SmallStation.GetInstance.OrderCancelStep = 21;
- break;
- case 21:
- if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
- {
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
- GVL_SmallStation.GetInstance.OrderCancelStep = 29;
- MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
- }
- break;
- case 29:
- App.Current.Dispatcher.Invoke(() =>
- {
- Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);
- });
- GVL_SmallStation.GetInstance.Order_Cancel = false;
- GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
- GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0;
- GVL_SmallStation.GetInstance.OrderCancelStep = 0;
- break;
-
- //30-39为订单还未下发至上位机
- case 30:
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
- GVL_SmallStation.GetInstance.OrderCancelStep = 31;
- break;
- case 31:
- if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
- {
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
- GVL_SmallStation.GetInstance.OrderCancelStep = 39;
- MessageNotify.GetInstance.ShowRunLog($"西门子取消订单完成,订单号:{code}");
- }
- break;
- case 39:
- GVL_SmallStation.GetInstance.Order_Cancel = false;
- GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
- GVL_SmallStation.GetInstance.OrderCancelStep = 0;
- break;
- }
- }
- }
- }
- /// <summary>
- /// 将配方添加到配方队列中
- /// </summary>
- private void ReceviceData()
- {
- if (!GVL_SmallStation.GetInstance.IsUseLocalRecipe)
- {
- RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
- if (RemoteRecipes.Count > 0)
- {
- foreach (var data in RemoteRecipes)
- {
- if (data.TrayCode == 1)
- {
- if (!(RecipeQueueTray1.Contains(data.RecipeCode)))
- {
- if (SiemensDevice.XL_Status is XL_Status_DB status)
- {
- switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus)
- {
- case 3:
- SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
- GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 4;
- MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料");
- break;
- case 4:
- if (SiemensDevice.XL_Status.Dosing_Confirm)
- {
- SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串
- SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
- GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 5;
- MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料");
- }
- break;
- case 5:
- if (SiemensDevice.XL_Status.Dosing_Confirm == false)
- {
- GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 6;
- MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成");
- }
- break;
- case 6:
- RecipeQueueTray1.Enqueue(data.RecipeCode);
- GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0;
- MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},加入队列");
- break;
- default:
- break;
- }
- }
- }
- }
- else if (data.TrayCode == 2)
- {
- if (!(RecipeQueueTray2.Contains(data.RecipeCode)))
- {
- if (SiemensDevice.XL_Status is XL_Status_DB status)
- {
- switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus)
- {
- case 3:
- SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
- GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 4;
- MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料");
- break;
- case 4:
- if (SiemensDevice.XL_Status.Dosing_Confirm)
- {
- SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串
- SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
- GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 5;
- MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料");
- }
- break;
- case 5:
- if (SiemensDevice.XL_Status.Dosing_Confirm == false)
- {
- GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 6;
- MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成");
- }
- break;
- case 6:
- RecipeQueueTray2.Enqueue(data.RecipeCode);
- GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0;
- MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},加入队列");
- break;
- default:
- break;
- }
- }
- }
- }
- }
- }
- else
- {
- RecipeQueueTray1.Clear();
- RecipeQueueTray2.Clear();
- /*GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
- GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;*/
- GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
- GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
- }
- }
- else
- {
- RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
- if (RemoteRecipes.Count > 0)
- {
- foreach (var data in RemoteRecipes)
- {
- if (data.TrayCode == 1)
- {
- if (!(RecipeQueueTray1.Contains(data.RecipeCode)))
- {
- RecipeQueueTray1.Enqueue(data.RecipeCode);
- }
- }
- else if (data.TrayCode == 2)
- {
- if (!(RecipeQueueTray2.Contains(data.RecipeCode)))
- {
- RecipeQueueTray2.Enqueue(data.RecipeCode);
- }
- }
- }
- }
- else
- {
- RecipeQueueTray1.Clear();
- RecipeQueueTray2.Clear();
- /*GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
- GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;*/
-
- GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
- GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
- }
- }
- }
- /// <summary>
- /// 执行配方队列中的第一个配方
- /// </summary>
- private void RecipeInfoToHKPLC()
- {
- switch (GVL_SmallStation.GetInstance.Tray1LogicFinish)
- {
- case 0:
- if (GVL_SmallStation.GetInstance.AGV_PutTray1Finish && RecipeQueueTray1.Count > 0)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true);
- GVL_SmallStation.GetInstance.AGV_PutTray1Finish = false;
- GVL_SmallStation.GetInstance.Tray1LogicFinish = 1;
- MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc");
- }
- break;
- case 1:
- if (GVL_SmallStation.GetInstance.Station1HaveTray)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", false);
- GVL_SmallStation.GetInstance.Tray1LogicFinish = 2;
- MessageNotify.GetInstance.ShowRunLog("托盘1有货架");
- }
- else
- {
- if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.5") == true)
- {
- if (GVL_SmallStation.GetInstance.CylinderReset)
- {
- HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.5", true);
- }
- MessageNotify.GetInstance.ShowRunLog("气缸收紧错位");
- }
- else
- {
- GVL_SmallStation.GetInstance.Tray1LogicFinish = 1;
- HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.5", false);
- }
- }
- break;
- case 2:
- if (GVL_SmallStation.GetInstance.AGV_GetTray1Finish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 0)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", true);
- GVL_SmallStation.GetInstance.Tray1LogicFinish = 3;
- MessageNotify.GetInstance.ShowRunLog("AGV取托盘1完成,发送给海科信号后1s后复位");
- }
- break;
- case 3:
- if (HKDevice.HK_PLC_S7.Read<bool>("DB4.DBX1.1") == true)
- {
- Thread.Sleep(1000);
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", false);
- GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
- GVL_SmallStation.GetInstance.AGV_GetTray1Finish = false;
- MessageNotify.GetInstance.ShowRunLog("AGV取托盘1完成,信号复位");
- }
- break;
- default:
- break;
- }
- switch (GVL_SmallStation.GetInstance.Tray2LogicFinish)
- {
- case 0:
- if (GVL_SmallStation.GetInstance.AGV_PutTray2Finish)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.0", true);
- GVL_SmallStation.GetInstance.AGV_PutTray2Finish = false;
- GVL_SmallStation.GetInstance.Tray2LogicFinish = 1;
- MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc");
- }
- break;
- case 1:
- if (GVL_SmallStation.GetInstance.Station2HaveTray)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.0", false);
- GVL_SmallStation.GetInstance.Tray2LogicFinish = 2;
- MessageNotify.GetInstance.ShowRunLog("托盘1有货架");
- }
- else
- {
- if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.6") == true)
- {
- if (GVL_SmallStation.GetInstance.CylinderReset)
- {
- HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.6", true);
- }
- MessageNotify.GetInstance.ShowRunLog("气缸收紧错位");
- }
- else
- {
- GVL_SmallStation.GetInstance.Tray2LogicFinish = 1;
- HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.6", false);
- }
- }
- break;
- case 2:
- if (GVL_SmallStation.GetInstance.AGV_GetTray2Finish && GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 0)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.2", true);
- GVL_SmallStation.GetInstance.Tray2LogicFinish = 3;
- }
- break;
- case 3:
- if (HKDevice.HK_PLC_S7.Read<bool>("DB4.DBX1.2") == true)
- {
- Thread.Sleep(1000);
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.2", false);
- GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;
- GVL_SmallStation.GetInstance.AGV_GetTray2Finish = false;
- }
- break;
- default:
- break;
- }
- #region 托盘1配料
- if (RecipeQueueTray1.Count > 0) /*&& GVL_SmallStation.GetInstance.Tray1LogicFinish == 2*/ //不需要等待AGV到位,就给PLC下发配方
- {
- int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray1.ElementAt(0));
- if (index >= 0 && index < RemoteRecipes.Count)
- {
- string code = RemoteRecipes.ElementAt(index).RecipeCode;
- int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
- string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
- string windSend = RemoteRecipes.ElementAt(index).ToString();
- if (trayCode == 1)
- {
- //粉料仓下发配方
- if (GVL_SmallStation.GetInstance.IsUseWindSend && GVL_SmallStation.GetInstance.Tray1LogicFinish == 2 && GVL_SmallStation.GetInstance.WindSendDosing==false)
- {
- GVL_SmallStation.GetInstance.WindSendDosing = true;
- WindSendData.TargetRecipeCode = code;
- WindSendData.IsAllowDosing = true;
- foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
- {
- if (item.RawMaterialName == "0037" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(0).RawMaterialName)
- {
- WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight;
- }
- if (item.RawMaterialName == "0038" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(1).RawMaterialName)
- {
- WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight;
- }
- if (item.RawMaterialName == "0039" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(2).RawMaterialName)
- {
- WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight;
- }
- if (item.RawMaterialName == "0045" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(3).RawMaterialName)
- {
- WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight;
- }
- if (item.RawMaterialName == "0046" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(4).RawMaterialName)
- {
- WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight;
- }
- }
- WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData, 95);
- }
- if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 0)
- {
- StockBinInit();
- GVL_SmallStation.GetInstance.StockBinDosing = 0;
- foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
- {
- HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation);
- GVL_SmallStation.GetInstance.StockBinDosing= GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)item.RawMaterialLocation,true);//哪些仓位需要配料写入
- }
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
- GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 1;
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成");
- GVL_SmallStation.GetInstance.time1 = DateTime.Now;
- }
- bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3");
- if ( recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 1)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false);
- GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 2;
- MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
- }
- if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 2)
- {
- if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
- {
- var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10");
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
- if (res > 0 && res is float loc)
- {
- int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
- if (weight <= 0)
- {
- int i = (int)loc;
- if (i >= 1 && i <= 8)
- {
- string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- MessageNotify.GetInstance.ShowRunLog(commInfo);
- }
- else if (i >= 9 && i <= 15)
- {
- string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- MessageNotify.GetInstance.ShowRunLog(commInfo1);
- }
- GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- }
- else
- {
- if (loc_index >= 0)
- {
- DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
- GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- }
- else
- {
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,错误没有找到{(int)loc}号仓的配方");
- }
- }
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,正在配料");
- }
- }
- else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
- {
- var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
- if (res > 0 && res is float loc)
- {
- int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
- if (weight <= 0)
- {
- int i = (int)loc;
- if (i >= 1 && i <= 8)
- {
- string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- MessageNotify.GetInstance.ShowRunLog(commInfo);
- }
- else if (i >= 9 && i <= 15)
- {
- string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- MessageNotify.GetInstance.ShowRunLog(commInfo1);
- }
- GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- }
- else
- {
- if (loc_index >= 0)
- {
- DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
- GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- }
- else
- {
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,错误没有找到{(int)loc}号仓的配方");
- }
- }
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,正在配料");
- }
- }
- else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
- {
- var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
- if (res > 0 && res is float loc)
- {
- int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
- if (weight <= 0)
- {
- int i = (int)loc;
- if (i >= 1 && i <= 8)
- {
- string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- MessageNotify.GetInstance.ShowRunLog(commInfo);
- }
- else if (i >= 9 && i <= 15)
- {
- string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- MessageNotify.GetInstance.ShowRunLog(commInfo1);
- }
- GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- }
- else
- {
- if (loc_index >= 0)
- {
- DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
- GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- }
- else
- {
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,错误没有找到{(int)loc}号仓的配方");
- }
- }
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,正在配料");
- }
- }
- else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
- {
- var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
- if (res > 0 && res is float loc)
- {
- int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
- if (weight <= 0)
- {
- int i = (int)loc;
- if (i >= 1 && i <= 8)
- {
- string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- MessageNotify.GetInstance.ShowRunLog(commInfo);
- }
- else if (i >= 9 && i <= 15)
- {
- string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- MessageNotify.GetInstance.ShowRunLog(commInfo1);
- }
- GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- }
- else
- {
- if (loc_index >= 0)
- {
- DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
- GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- }
- else
- {
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,错误没有找到{(int)loc}号仓的配方");
- }
- }
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,正在配料");
- }
- }
- for (int i = 1; i < 16; i++)
- {
- if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
- {
- int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
- if (res >= 0)
- {
- Thread.Sleep(GVL_SmallStation.GetInstance.Time);
- RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
- bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
- MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
- float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000);
- int iIndex = Array.FindIndex(Json<DevicePar>.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
- if (iIndex >= 0)
- {
- if (Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange)
- {
- HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
- App.Current.Dispatcher.Invoke(() =>
- {
- MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning);
- HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
- });
- }
- }
- if (i >= 1 && i <= 8)
- {
- string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- MessageNotify.GetInstance.ShowRunLog(commInfo);
- }
- else if (i >= 9 && i <= 15)
- {
- string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- MessageNotify.GetInstance.ShowRunLog(commInfo1);
- }
- }
- GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- }
- }
- if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1"))))
- {
- if (GVL_SmallStation.GetInstance.StockBinDosing > 0)
- {
- for (int i = 1; i < 17; i++)
- {
- if (GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
- {
- MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓");
- }
- }
- }
- var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
- foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
- {
- MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g");
- }
- if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
- {
- RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
- RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
- RecipeFinishInfo.Job_No = (short)trayCode;
- for (int i = 0; i < 20; i++)
- {
- RecipeFinishInfo.Material[i] = new UDT1();
- }
- for (int i = 0; i < 10; i++)
- {
- RecipeFinishInfo.Powder[i] = new UDT2();
- }
- for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
- {
- RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
- RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
- RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
- }
- for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
- {
- RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
- }
- double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds;
- RecipeFinishInfo.Ask_For_Finish = true;
- RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
- SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
-
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
- }
- else
- {
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
- }
- GVL_SmallStation.GetInstance.WindSendDosing = false;
- App.Current.Dispatcher.Invoke(() =>
- {
- Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
- });
- RecipeQueueTray1.TryDequeue(out code);
- HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
- GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
- }
- }
- }
- }
- }
- //if (RecipeQueueTray1.Count > 0) /*&& GVL_SmallStation.GetInstance.Tray1LogicFinish == 2*/ //不需要等待AGV到位,就给PLC下发配方
- //{
- // foreach (var queue in RecipeQueueTray1)
- // {
- // int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == queue.ToString());
- // if (index >= 0 && index < RemoteRecipes.Count)
- // {
- // int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
- // string code = RemoteRecipes.ElementAt(index).RecipeCode;
- // string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
- // string windSend = RemoteRecipes.ElementAt(index).ToString();
- // if (trayCode == 1)
- // {
- // //粉料仓下发配方
- // if (GVL_SmallStation.GetInstance.IsUseWindSend && GVL_SmallStation.GetInstance.Tray1LogicFinish == 2 && GVL_SmallStation.GetInstance.WindSendDosing == false)
- // {
- // GVL_SmallStation.GetInstance.WindSendDosing = true;
- // WindSendData.TargetRecipeCode = code;
- // WindSendData.IsAllowDosing = true;
- // foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
- // {
- // if (item.RawMaterialName == "0037" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(0).RawMaterialName)
- // {
- // WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight;
- // }
- // if (item.RawMaterialName == "0038" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(1).RawMaterialName)
- // {
- // WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight;
- // }
- // if (item.RawMaterialName == "0039" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(2).RawMaterialName)
- // {
- // WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight;
- // }
- // if (item.RawMaterialName == "0045" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(3).RawMaterialName)
- // {
- // WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight;
- // }
- // if (item.RawMaterialName == "0046" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(4).RawMaterialName)
- // {
- // WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight;
- // }
- // }
- // WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData, 95);
- // }
- // if (GVL_SmallStation.GetInstance.RecipeProcessStatus[0] == 0)
- // {
- // StockBinInit();
- // GVL_SmallStation.GetInstance.StockBinDosing = 0;
- // HKDevice.IssueRecipeToPlc(RemoteRecipes.ElementAt(index).RawMaterial, 1);
- // HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
- // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 1;
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成");
- // GVL_SmallStation.GetInstance.time1 = DateTime.Now;
- // }
- // bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3");
- // if (recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 1)
- // {
- // HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false);
- // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 2;
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
- // }
- // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 2)
- // {
- // if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
- // {
- // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10");
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
- // if (res > 0 && res is float loc)
- // {
- // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
- // if (weight <= 0)
- // {
- // int i = (int)loc;
- // if (i >= 1 && i <= 8)
- // {
- // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo);
- // }
- // else if (i >= 9 && i <= 15)
- // {
- // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo1);
- // }
- // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- // }
- // else
- // {
- // if (loc_index >= 0)
- // {
- // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
- // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- // }
- // else
- // {
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,错误没有找到{(int)loc}号仓的配方");
- // }
- // }
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,正在配料");
- // }
- // }
- // else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
- // {
- // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
- // if (res > 0 && res is float loc)
- // {
- // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
- // if (weight <= 0)
- // {
- // int i = (int)loc;
- // if (i >= 1 && i <= 8)
- // {
- // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo);
- // }
- // else if (i >= 9 && i <= 15)
- // {
- // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo1);
- // }
- // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- // }
- // else
- // {
- // if (loc_index >= 0)
- // {
- // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
- // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- // }
- // else
- // {
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,错误没有找到{(int)loc}号仓的配方");
- // }
- // }
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,正在配料");
- // }
- // }
- // else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
- // {
- // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
- // if (res > 0 && res is float loc)
- // {
- // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
- // if (weight <= 0)
- // {
- // int i = (int)loc;
- // if (i >= 1 && i <= 8)
- // {
- // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo);
- // }
- // else if (i >= 9 && i <= 15)
- // {
- // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo1);
- // }
- // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- // }
- // else
- // {
- // if (loc_index >= 0)
- // {
- // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
- // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- // }
- // else
- // {
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,错误没有找到{(int)loc}号仓的配方");
- // }
- // }
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,正在配料");
- // }
- // }
- // else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
- // {
- // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
- // if (res > 0 && res is float loc)
- // {
- // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
- // if (weight <= 0)
- // {
- // int i = (int)loc;
- // if (i >= 1 && i <= 8)
- // {
- // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo);
- // }
- // else if (i >= 9 && i <= 15)
- // {
- // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo1);
- // }
- // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- // }
- // else
- // {
- // if (loc_index >= 0)
- // {
- // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
- // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- // }
- // else
- // {
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,错误没有找到{(int)loc}号仓的配方");
- // }
- // }
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,正在配料");
- // }
- // }
- // for (int i = 1; i < 16; i++)
- // {
- // if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
- // {
- // int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
- // if (res >= 0)
- // {
- // Thread.Sleep(GVL_SmallStation.GetInstance.Time);
- // RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
- // bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
- // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
- // float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000);
- // int iIndex = Array.FindIndex(Json<DevicePar>.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
- // if (iIndex >= 0)
- // {
- // if (Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange)
- // {
- // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
- // App.Current.Dispatcher.Invoke(() =>
- // {
- // MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning);
- // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
- // });
- // }
- // }
- // if (i >= 1 && i <= 8)
- // {
- // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo);
- // }
- // else if (i >= 9 && i <= 15)
- // {
- // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo1);
- // }
- // }
- // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- // }
- // }
- // if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1"))))
- // {
- // if (GVL_SmallStation.GetInstance.StockBinDosing > 0)
- // {
- // for (int i = 1; i < 17; i++)
- // {
- // if (GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
- // {
- // MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓");
- // }
- // }
- // }
- // var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
- // foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
- // {
- // MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g");
- // }
- // if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
- // {
- // RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
- // RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
- // RecipeFinishInfo.Job_No = (short)trayCode;
- // for (int i = 0; i < 20; i++)
- // {
- // RecipeFinishInfo.Material[i] = new UDT1();
- // }
- // for (int i = 0; i < 10; i++)
- // {
- // RecipeFinishInfo.Powder[i] = new UDT2();
- // }
- // for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
- // {
- // RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
- // RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
- // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
- // }
- // for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
- // {
- // RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
- // }
- // double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds;
- // RecipeFinishInfo.Ask_For_Finish = true;
- // RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
- // SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
-
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
- // }
- // else
- // {
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
- // }
- // GVL_SmallStation.GetInstance.WindSendDosing = false;
- // App.Current.Dispatcher.Invoke(() =>
- // {
- // Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
- // });
- // RecipeQueueTray1.TryDequeue(out code);
- // HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
- // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
- // }
- // }
- // }
- // }
- // }
- //} //if (RecipeQueueTray1.Count > 0) /*&& GVL_SmallStation.GetInstance.Tray1LogicFinish == 2*/ //不需要等待AGV到位,就给PLC下发配方
- //{
- // foreach (var queue in RecipeQueueTray1)
- // {
- // int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == queue.ToString());
- // if (index >= 0 && index < RemoteRecipes.Count)
- // {
- // int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
- // string code = RemoteRecipes.ElementAt(index).RecipeCode;
- // string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
- // string windSend = RemoteRecipes.ElementAt(index).ToString();
- // if (trayCode == 1)
- // {
- // //粉料仓下发配方
- // if (GVL_SmallStation.GetInstance.IsUseWindSend && GVL_SmallStation.GetInstance.Tray1LogicFinish == 2 && GVL_SmallStation.GetInstance.WindSendDosing == false)
- // {
- // GVL_SmallStation.GetInstance.WindSendDosing = true;
- // WindSendData.TargetRecipeCode = code;
- // WindSendData.IsAllowDosing = true;
- // foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
- // {
- // if (item.RawMaterialName == "0037" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(0).RawMaterialName)
- // {
- // WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight;
- // }
- // if (item.RawMaterialName == "0038" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(1).RawMaterialName)
- // {
- // WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight;
- // }
- // if (item.RawMaterialName == "0039" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(2).RawMaterialName)
- // {
- // WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight;
- // }
- // if (item.RawMaterialName == "0045" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(3).RawMaterialName)
- // {
- // WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight;
- // }
- // if (item.RawMaterialName == "0046" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(4).RawMaterialName)
- // {
- // WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight;
- // }
- // }
- // WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData, 95);
- // }
- // if (GVL_SmallStation.GetInstance.RecipeProcessStatus[0] == 0)
- // {
- // StockBinInit();
- // GVL_SmallStation.GetInstance.StockBinDosing = 0;
- // HKDevice.IssueRecipeToPlc(RemoteRecipes.ElementAt(index).RawMaterial, 1);
- // HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
- // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 1;
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成");
- // GVL_SmallStation.GetInstance.time1 = DateTime.Now;
- // }
- // bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3");
- // if (recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 1)
- // {
- // HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false);
- // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 2;
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
- // }
- // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 2)
- // {
- // if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
- // {
- // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10");
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
- // if (res > 0 && res is float loc)
- // {
- // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
- // if (weight <= 0)
- // {
- // int i = (int)loc;
- // if (i >= 1 && i <= 8)
- // {
- // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo);
- // }
- // else if (i >= 9 && i <= 15)
- // {
- // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo1);
- // }
- // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- // }
- // else
- // {
- // if (loc_index >= 0)
- // {
- // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
- // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- // }
- // else
- // {
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,错误没有找到{(int)loc}号仓的配方");
- // }
- // }
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,正在配料");
- // }
- // }
- // else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
- // {
- // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
- // if (res > 0 && res is float loc)
- // {
- // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
- // if (weight <= 0)
- // {
- // int i = (int)loc;
- // if (i >= 1 && i <= 8)
- // {
- // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo);
- // }
- // else if (i >= 9 && i <= 15)
- // {
- // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo1);
- // }
- // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- // }
- // else
- // {
- // if (loc_index >= 0)
- // {
- // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
- // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- // }
- // else
- // {
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,错误没有找到{(int)loc}号仓的配方");
- // }
- // }
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,正在配料");
- // }
- // }
- // else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
- // {
- // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
- // if (res > 0 && res is float loc)
- // {
- // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
- // if (weight <= 0)
- // {
- // int i = (int)loc;
- // if (i >= 1 && i <= 8)
- // {
- // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo);
- // }
- // else if (i >= 9 && i <= 15)
- // {
- // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo1);
- // }
- // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- // }
- // else
- // {
- // if (loc_index >= 0)
- // {
- // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
- // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- // }
- // else
- // {
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,错误没有找到{(int)loc}号仓的配方");
- // }
- // }
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,正在配料");
- // }
- // }
- // else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
- // {
- // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
- // if (res > 0 && res is float loc)
- // {
- // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
- // if (weight <= 0)
- // {
- // int i = (int)loc;
- // if (i >= 1 && i <= 8)
- // {
- // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo);
- // }
- // else if (i >= 9 && i <= 15)
- // {
- // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo1);
- // }
- // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- // }
- // else
- // {
- // if (loc_index >= 0)
- // {
- // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
- // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- // }
- // else
- // {
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,错误没有找到{(int)loc}号仓的配方");
- // }
- // }
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,正在配料");
- // }
- // }
- // for (int i = 1; i < 16; i++)
- // {
- // if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
- // {
- // int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
- // if (res >= 0)
- // {
- // Thread.Sleep(GVL_SmallStation.GetInstance.Time);
- // RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
- // bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
- // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
- // float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000);
- // int iIndex = Array.FindIndex(Json<DevicePar>.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
- // if (iIndex >= 0)
- // {
- // if (Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange)
- // {
- // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
- // App.Current.Dispatcher.Invoke(() =>
- // {
- // MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning);
- // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
- // });
- // }
- // }
- // if (i >= 1 && i <= 8)
- // {
- // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo);
- // }
- // else if (i >= 9 && i <= 15)
- // {
- // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo1);
- // }
- // }
- // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
- // }
- // }
- // if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1"))))
- // {
- // if (GVL_SmallStation.GetInstance.StockBinDosing > 0)
- // {
- // for (int i = 1; i < 17; i++)
- // {
- // if (GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
- // {
- // MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓");
- // }
- // }
- // }
- // var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
- // foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
- // {
- // MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g");
- // }
- // if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
- // {
- // RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
- // RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
- // RecipeFinishInfo.Job_No = (short)trayCode;
- // for (int i = 0; i < 20; i++)
- // {
- // RecipeFinishInfo.Material[i] = new UDT1();
- // }
- // for (int i = 0; i < 10; i++)
- // {
- // RecipeFinishInfo.Powder[i] = new UDT2();
- // }
- // for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
- // {
- // RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
- // RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
- // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
- // }
- // for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
- // {
- // RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
- // }
- // double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds;
- // RecipeFinishInfo.Ask_For_Finish = true;
- // RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
- // SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
-
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
- // }
- // else
- // {
- // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
- // }
- // GVL_SmallStation.GetInstance.WindSendDosing = false;
- // App.Current.Dispatcher.Invoke(() =>
- // {
- // Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
- // });
- // RecipeQueueTray1.TryDequeue(out code);
- // HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
- // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
- // }
- // }
- // }
- // }
- // }
- //}
- #endregion
- #region 托盘2配料 ---硬件不具备条件,不使用
- //if (RecipeQueueTray2.Count > 0 && GVL_SmallStation.GetInstance.Tray2LogicFinish == 2)
- //{
- // int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray2.ElementAt(0));
- // if (index >= 0 && index < RemoteRecipes.Count)
- // {
- // string code = RemoteRecipes.ElementAt(index).RecipeCode;
- // int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
- // string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
- // if (trayCode == 2)
- // {
- // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 0)
- // {
- // StockBinInit();
- // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},初始化");
- // foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
- // {
- // HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation, 2);
- // }
- // HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true);
- // GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 1;
- // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},下发完成");
- // }
-
- // if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.4") && GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 1)
- // {
- // HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", false);
- // GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 2;
- // MessageNotify.GetInstance.ShowRunLog($"配方:{recipeName},plc端 配方接收完成");
- // }
- // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 2)
- // {
- // if (RTrig.GetInstance("DB3.DBX50.4").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.4")))
- // {
- // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD26");
- // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{res}料仓,允许配料");
- // if (res > 0 && res is float loc)
- // {
- // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- // double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
- // if (loc_index >= 0)
- // {
- // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量
- // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- // }
- // GVL_SmallStation.GetInstance.DosingTray2 = true;
- // GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
- // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成");
- // }
- // }
- // else if (RTrig.GetInstance("DB3.DBX50.5").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.5")))
- // {
- // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD30");
- // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{res}料仓,允许配料");
- // if (res > 0 && res is float loc)
- // {
- // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- // double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
- // if (loc_index >= 0)
- // {
- // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
- // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- // }
- // GVL_SmallStation.GetInstance.DosingTray2 = true;
- // GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
- // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成");
- // }
- // }
- // else if (RTrig.GetInstance("DB3.DBX50.6").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.6")))
- // {
- // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD34");
- // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{res}料仓,允许配料");
- // if (res > 0 && res is float loc)
- // {
- // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- // double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
- // if (loc_index >= 0)
- // {
- // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
- // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- // }
- // GVL_SmallStation.GetInstance.DosingTray2 = true;
- // GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
- // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成");
- // }
- // }
- // else if (RTrig.GetInstance("DB3.DBX50.7").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.7")))
- // {
- // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD38");
- // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{res}料仓,允许配料");
- // if (res > 0 && res is float loc)
- // {
- // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- // double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
- // if (loc_index >= 0)
- // {
- // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
- // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
- // }
- // GVL_SmallStation.GetInstance.DosingTray2 = true;
- // GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
- // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成");
- // }
- // }
- // if (GVL_SmallStation.GetInstance.DosingTray2 == true && GVL_SmallStation.GetInstance.DosingTray1 == false && GVL_SmallStation.GetInstance.DosingTray2Loc > 0 && GVL_SmallStation.GetInstance.DosingTray2Loc < 16)
- // {
- // Thread.Sleep(GVL_SmallStation.GetInstance.Time);
- // int i = GVL_SmallStation.GetInstance.DosingTray2Loc;
- // if (RTrig.GetInstance("Tray2StatusDevice" + i).Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
- // {
- // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{recipeName},{i}号仓,配料完成");
- // int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
- // RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
- // bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
- // float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight);
- // int iIndex = Array.FindIndex(Json<DevicePar>.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
- // if (iIndex >= 0)
- // {
- // if (Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange)
- // {
- // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
- // App.Current.Dispatcher.Invoke(() =>
- // {
- // MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning);
- // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
- // });
- // }
- // }
- // if (info)
- // {
- // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功");
- // }
- // else
- // {
- // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送失败");
- // }
- // if (i >= 1 && i <= 8)
- // {
- // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo);
- // }
- // else if (i >= 9 && i <= 15)
- // {
- // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- // MessageNotify.GetInstance.ShowRunLog(commInfo1);
- // }
- // GVL_SmallStation.GetInstance.DosingTray2 = false;
- // GVL_SmallStation.GetInstance.DosingTray2Loc = 0;
- // }
- // }
- // if (RTrig.GetInstance("DB3.DBX1.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.2")))
- // {
- // var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
- // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方{res.RecipeName},配料完成");
- // RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
- // RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
- // for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
- // {
- // RecipeFinishInfo.Material[i] = new UDT1();
- // RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
- // RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
- // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
- // }
- // if (SiemensDevice.IsConnected)
- // {
- // RecipeFinishInfo.Ask_For_Finish = true;
- // SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
- // }
- // App.Current.Dispatcher.Invoke(() =>
- // {
- // Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
- // });
- // RecipeQueueTray2.TryDequeue(out code);
- // HKDevice.HK_PLC_S7.Write("DB3.DBX1.2", false);
- // GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
- // }
- // }
- // }
- // }
- //}
- #endregion
- }
- private void StockBinInit()
- {
- for (int i = 1; i < 16; i++)
- {
- if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)
- {
- DeviceInquire.GetInstance.GetDevice(i).StatusReset();
- }
- }
- }
- /// <summary>
- /// 料仓的位置和原料名称的对应
- /// </summary>
- public void StockBinNameWithPos()
- {
- RawMaterialsNamePos.Clear();
- foreach (var material in RawMaterialsInfo)
- {
- if (!string.IsNullOrEmpty(material.RawMaterialName))
- {
- if (!RawMaterialsNamePos.ContainsKey(material.RawMaterialName))
- {
- RawMaterialsNamePos.Add(material.RawMaterialName, (short)material.RawMaterialLocation);
- }
- }
- }
- }
- /// <summary>
- /// PLC的DB3变量列表
- /// </summary>
- public void PlcVarMonitor()
- {
- foreach (PropertyInfo item in typeof(PlcReadAddressDB3).GetProperties())
- {
- if (Attribute.IsDefined(item, typeof(VarCommAttribute)))
- {
- CommData.Add(new PlcInfos()
- {
- Count = CommData.Count + 1,
- Name = item.Name,
- Address = item.GetCustomAttribute<VarCommAttribute>().Address,
- Type = item.PropertyType.ToString(),
- Describe = item.GetCustomAttribute<VarCommAttribute>().Describe,
- Value = item.GetValue(GVL_SmallStation.GetInstance.plcReadDataDB3).ToString(),
- });
- }
- }
-
- foreach (PropertyInfo item in typeof(GVL_SmallStation).GetProperties())
- {
- if (Attribute.IsDefined(item, typeof(VarCommAttribute)))
- {
- ProcessVar.Add(new PlcInfos()
- {
- Count = ProcessVar.Count + 1,
- Name = item.Name,
- Type = item.PropertyType.ToString(),
- Address = item.GetCustomAttribute<VarCommAttribute>().Address,
- Describe = item.GetCustomAttribute<VarCommAttribute>().Describe,
- Value = item.GetValue(GVL_SmallStation.GetInstance).ToString()
- });
- }
- }
- }
- public void RegisterInit()
- {
- //手动控制气缸 DB5.DBX0.0~DB5.DBX4.5
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null)
- {
- if (o.ToString().Contains("升降气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2));
- if (index >= 1 && index <= 15)
- {
- string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1);
- if (index == 8) address = "DB5.DBX0.7";
- HKDevice.HK_PLC_S7.Write<bool>(address, true);
- MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:{address},值:true");
- }
- }
- else if (o.ToString().Contains("阻挡气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2));
- if (index >= 1 && index <= 15)
- {
- string address = "";
- if (index == 1) address = "DB5.DBX1.7";
- if (index == 2) address = "DB5.DBX2.0";
- if (index == 3) address = "DB5.DBX2.1";
- if (index == 4) address = "DB5.DBX2.2";
- if (index == 5) address = "DB5.DBX2.3";
- if (index == 6) address = "DB5.DBX2.4";
- if (index == 7) address = "DB5.DBX2.5";
- if (index == 8) address = "DB5.DBX2.6";
- if (index == 9) address = "DB5.DBX2.7";
- if (index == 10) address = "DB5.DBX3.0";
- if (index == 11) address = "DB5.DBX3.1";
- if (index == 12) address = "DB5.DBX3.2";
- if (index == 13) address = "DB5.DBX3.3";
- if (index == 14) address = "DB5.DBX3.4";
- if (index == 15) address = "DB5.DBX3.5";
- HKDevice.HK_PLC_S7.Write<bool>(address, true);
- }
- }
- else if (o.ToString().Contains("进料桶顶升气缸"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", false);//默认顶升
- MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.6,值:false");
- }
- else if (o.ToString().Contains("出料桶顶升气缸1"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", true);
- MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.7,值:true");
- }
- else if (o.ToString().Contains("出料桶顶升气缸2"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", true);
- MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.0,值:true");
- }
- else if (o.ToString().Contains("出料桶顶升气缸3"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", true);
- MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.1,值:true");
- }
- else if (o.ToString().Contains("托盘气缸1_1"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", false);//默认伸出
- }
- else if (o.ToString().Contains("托盘气缸1_2"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", false);
- }
- else if (o.ToString().Contains("托盘气缸2_1"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", false);
- }
- else if (o.ToString().Contains("托盘气缸2_2"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", false);
- }
- }
- }), "ManualOpen", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null)
- {
- if (o.ToString().Contains("升降气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2));
- if (index >= 1 && index <= 15)
- {
- string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1);
- if (index == 8) address = "DB5.DBX0.7";
- HKDevice.HK_PLC_S7.Write<bool>(address, false);
- MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:{address},值:false");
- }
- }
- else if (o.ToString().Contains("阻挡气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2));
- if (index >= 1 && index <= 15)
- {
- string address = "";
- if (index == 1) address = "DB5.DBX1.7";
- if (index == 2) address = "DB5.DBX2.0";
- if (index == 3) address = "DB5.DBX2.1";
- if (index == 4) address = "DB5.DBX2.2";
- if (index == 5) address = "DB5.DBX2.3";
- if (index == 6) address = "DB5.DBX2.4";
- if (index == 7) address = "DB5.DBX2.5";
- if (index == 8) address = "DB5.DBX2.6";
- if (index == 9) address = "DB5.DBX2.7";
- if (index == 10) address = "DB5.DBX3.0";
- if (index == 11) address = "DB5.DBX3.1";
- if (index == 12) address = "DB5.DBX3.2";
- if (index == 13) address = "DB5.DBX3.3";
- if (index == 14) address = "DB5.DBX3.4";
- if (index == 15) address = "DB5.DBX3.5";
- HKDevice.HK_PLC_S7.Write<bool>(address, false);
- }
- }
- else if (o.ToString().Contains("进料桶顶升气缸"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", true);
- MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.6,值:true");
- }
- else if (o.ToString().Contains("出料桶顶升气缸1"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", false);
- MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.7,值:false");
- }
- else if (o.ToString().Contains("出料桶顶升气缸2"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", false);
- MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.0,值:false");
- }
- else if (o.ToString().Contains("出料桶顶升气缸3"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", false);
- MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.1,值:false");
- }
- else if (o.ToString().Contains("托盘气缸1_1"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", true);
- }
- else if (o.ToString().Contains("托盘气缸1_2"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", true);
- }
- else if (o.ToString().Contains("托盘气缸2_1"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", true);
- }
- else if (o.ToString().Contains("托盘气缸2_2"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", true);
- }
- }
- }), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
- //手动控制电机轴 DB5.DBX4.6~DB5.DBX5.2
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX4.6", true); }), "StartAxisLoadCommand", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX4.6", false); }), "StopAxisLoadCommand", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX4.7", true); }), "StartAxisMidCommand", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX4.7", false); }), "StopAxisMidCommand", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX5.0", true); }), "StartAxisUnLoadCommand", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX5.0", false); }), "StopAxisUnLoadCommand", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX5.1", true); }), "StartAxis1Command", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX5.1", false); }), "StopAxis1Command", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX5.2", true); }), "StartAxis2Command", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX5.2", false); }), "StopAxis2Command", true);
-
- //西门子配方处理
- ActionManage.GetInstance.Register(new Action<object>((res) =>
- {
- ObservableCollection<RemoteRecipeRawMaterial> RawMaterials = new ObservableCollection<RemoteRecipeRawMaterial>();
- ObservableCollection<WindSendRawMaterial> WindSendData = new ObservableCollection<WindSendRawMaterial>();
- if (SiemensDevice.IsConnected)
- {
- if (res != null && res is XL_Start_DB recipe)
- {
- if (!string.IsNullOrEmpty(recipe.RecipeCode))
- {
- RawMaterials.Clear();
- for (int i = 0; i < GVL_SmallStation.Max_DosingSotckBinNum; i++)
- {
- if (!string.IsNullOrEmpty(recipe.Material[i].Material_Name))
- {
- if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name))
- {
- RawMaterials.Add(new RemoteRecipeRawMaterial()
- {
- RawMaterialName = recipe.Material[i].Material_Name,
- RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum,
- RawMaterialWeight = recipe.Material[i].Material_Weight,
- RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name]
- });
- }
- else
- {
- MessageNotify.GetInstance.ShowRunLog($"原料:{recipe.Material[i].Material_Name},不在配料表");
- }
- }
- else
- {
- break;
- }
- }
- for (int i = 0; i < GVL_SmallStation.Max_PowderSotckBinNum; i++)
- {
- if (!string.IsNullOrEmpty(recipe.Powder[i].Powder_Name))
- {
- WindSendData.Add(new WindSendRawMaterial()
- {
- RawMaterialName = recipe.Powder[i].Powder_Name,
- RawMaterialWeight = recipe.Powder[i].Powder_Weight
- });
- }
- else
- {
- break;
- }
- }
- App.Current.Dispatcher.Invoke(() => {
- Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
- {
- RecipeName = recipe.RecipeName,
- RecipeCode = recipe.RecipeCode,
- RawMaterial = RawMaterials,
- TrayCode = recipe.StockCode,
- WindSend = WindSendData
- });
- });
- }
- }
- }
- }), "SiemensRecipeRecive", true);
- ActionManage.GetInstance.Register(new Action<object>((res) =>
- {
- // if (SiemensDevice.IsConnected)
- // {
- // if (res != null && res is RemoteRecipeData recipe)
- // {
- // RecipeFinishInfo.Order_No = recipe.RecipeCode;
- // RecipeFinishInfo.Product_Code = recipe.RecipeName;
- // RecipeFinishInfo.Job_No = (short)recipe.TrayCode;
- // for (int i = 0; i < recipe.RawMaterial.Count; i++)
- // {
- // RecipeFinishInfo.Material[i] = new UDT1();
- // RecipeFinishInfo.Material[i].Material_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName;
- // RecipeFinishInfo.Material[i].Material_BarrelNum = recipe.RawMaterial.ElementAt(i).RawMaterialBarrelNum;
- // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight;
- // }
- // for (int i = 0; i < recipe.WindSend.Count; i++)
- // {
- // RecipeFinishInfo.Powder[i] = new UDT2();
- // RecipeFinishInfo.Powder[i].Powder_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName;
- // RecipeFinishInfo.Powder[i].Powder_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight;
- // }
- // if (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus == 6)
- // {
- // GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 7;
- // RecipeFinishInfo.Ask_For_Finish = true;
- // SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
- // }
- // }
- // }
- }), "SiemensRecipeFinish", true);
-
- //将本地配方发送到西门子配方里,执行配料
- ActionManage.GetInstance.Register(new Action<Object>((res) =>
- {
- if (res != null && res is RemoteRecipeData recipe)
- {
- Json<RemoteRecipeDataColl>.Data.Recipes.Add(recipe);
- }
- }), "LocalSimulationRecipeIssue", true);
-
- //手动控制系统模式
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.0", true); }), "SystemStart", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.0", false); }), "SystemStop", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.2", true); }), "SystemPause", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.2", false); }), "SystemReset", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.1", false); }), "SystemAutoMode", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.1", true); }), "SystemDebugMode", true);
- //流程控制
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.3", true); }), "ManualSystemReset", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.4", true); }), "CLearRecipeInfo", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX0.7", true); }), "AGVPutTrayFinish", true);
- ActionManage.GetInstance.Register(new Action(() =>
- {
- Json<RemoteRecipeDataColl>.Data.Recipes.Clear();
- GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0;
-
- GVL_SmallStation.GetInstance.Order_Cancel = false;
- GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
- GVL_SmallStation.GetInstance.OrderCancelStep = 0;
-
- RecipeQueueTray1.Clear();
- RecipeQueueTray2.Clear();
- GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
- GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
- GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
- GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;
- StockBinInit();
- MessageNotify.GetInstance.ShowRunLog("系统流程复位,等待西门子重新下发订单");
- }), "BPASystemReset", true);
-
- //往海科PLC写值
- ActionManage.GetInstance.Register(new Action<Object>((o) =>
- {
- if (o != null && o is HKDeviceWrite data)
- {
- if (data.PlcVarType == PlcVarType.Bool)
- {
- bool value = (bool)data.Value;
- HKDevice.HK_PLC_S7.Write<bool>(data.Address , value);
- }
- else if (data.PlcVarType == PlcVarType.Byte)
- {
- byte value = (byte)data.Value;
- HKDevice.HK_PLC_S7.Write<byte>(data.Address, value);
- }
- else if (data.PlcVarType == PlcVarType.Int)
- {
- short value = (short)data.Value;
- HKDevice.HK_PLC_S7.Write<short>(data.Address, value);
- }
- else if (data.PlcVarType == PlcVarType.Dint)
- {
- int value = (int)data.Value;
- HKDevice.HK_PLC_S7.Write<int>(data.Address, value);
- }
- else if (data.PlcVarType == PlcVarType.Real)
- {
- float value = (float)data.Value;
- HKDevice.HK_PLC_S7.Write<float>(data.Address, value);
- }
- }
- }), "PLCWrite", true);
-
- //电机速度
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null && o is short value)
- {
- HKDevice.HK_PLC_S7.Write("DB47.DBW8", value);
- }
- }), "AxisLoadSpeedSet", true);
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null && o is short value)
- {
- HKDevice.HK_PLC_S7.Write("DB47.DBW10", value);
- }
- }), "AxisMidSpeedSet", true);
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null && o is short value)
- {
- HKDevice.HK_PLC_S7.Write("DB47.DBW12", value);
- }
- }), "AxisUnLoadSpeedSet", true);
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null && o is float value)
- {
- HKDevice.HK_PLC_S7.Write("DB47.DBD0", value);
- }
- }), "Axis1SpeedSet", true);
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null && o is float value)
- {
- HKDevice.HK_PLC_S7.Write("DB47.DBD4", value);
- }
- }), "Axis2SpeedSet", true);
-
- //机器人的操作
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null && o is string address)
- {
- HKDevice.HK_PLC_S7.Write(address, true);
- }
- }), "RobotSendTrueCommand", true);
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null && o is string address)
- {
- HKDevice.HK_PLC_S7.Write(address, false);
- }
- }), "RobotSendFalseCommand", true);
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null && o is short Value)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBB102", (byte)Value);
- }
- }), "RobotSetProgramNum", true);
-
- }
- public void DeviceConnect()
- {
- try
- {
- if (Json<DevicePar>.Data.deviceConnectPar.HKPlcConnect)
- {
- HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
- if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科plc连接成功");
- }
- }
- catch (Exception ex)
- {
- MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败,等待重新连接");
- }
- finally
- {
- HKDevice.Init();
- MessageNotify.GetInstance.ShowRunLog("海科plc初始化完成");
- }
- try
- {
- if (Json<DevicePar>.Data.deviceConnectPar.SiemensConnect)
- {
- SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
- if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功");
- }
- }
- catch (Exception ex)
- {
- MessageNotify.GetInstance.ShowAlarmLog("西门子plc连接失败,等待重新连接");
- }
- finally
- {
- SiemensDevice.Init();
- MessageNotify.GetInstance.ShowRunLog("西门子plc初始化完成");
- }
- try
- {
- if (Json<DevicePar>.Data.deviceConnectPar.WindSendConnect)
- {
- WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP);
- if (WindSendDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("风送plc连接成功");
- }
- }
- catch (Exception ex)
- {
- MessageNotify.GetInstance.ShowAlarmLog("粉料plc连接失败,等待重新连接");
- }
- finally
- {
- WindSendDevice.Init();
- MessageNotify.GetInstance.ShowRunLog("风送粉料plc初始化完成");
- }
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- try
- {
- if (!HKDevice.IsConnected && Json<DevicePar>.Data.deviceConnectPar.HKPlcConnect)
- {
- HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
- if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接成功");
- }
- }
- catch (Exception ex)
- {
- }
- try
- {
- if (!SiemensDevice.IsConnected && Json<DevicePar>.Data.deviceConnectPar.SiemensConnect)
- {
- SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
- if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子PLC重新连接成功");
- }
- }
- catch (Exception ex)
- {
- }
- try
- {
- if (!WindSendDevice.IsConnected && Json<DevicePar>.Data.deviceConnectPar.WindSendConnect)
- {
- WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP);
- if (WindSendDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("风送plc重新连接成功");
- }
- }
- catch (Exception ex)
- {
- }
- Thread.Sleep(50);
- }), "设备连接", true);
- }
-
- private void DosingDevice(int Index, int DeviceID)
- {
- if (RTrig.GetInstance("Tray2StatusDevice" + DeviceID).Start(DeviceInquire.GetInstance.GetDevice(DeviceID).deviceStatus.RunStatus == 3))
- {
- MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{RemoteRecipes.ElementAt(Index).RecipeName},{DeviceID}号仓,配料完成");
- int res = Array.FindIndex(RemoteRecipes.ElementAt(Index).RawMaterial.ToArray(), p => p.RawMaterialLocation == DeviceID);
- RemoteRecipes.ElementAt(Index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(DeviceID).deviceStatus.CutWeightFeedback;
- DeviceInquire.GetInstance.GetDevice(DeviceID).StatusReset();
- if (DeviceID >= 1 && DeviceID <= 8)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (DeviceID - 1), true);
- }
- else if (DeviceID >= 9 && DeviceID <= 15)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (DeviceID - 9), true);
- }
- }
- }
- public void RawMaterialNameWithCode()
- {
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.Clear();
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0001", "色拉油");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0002", "一级菜油");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0003", "菜籽油");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0004", "青花椒油");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0005", "卤牛肉丁");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0006", "冻鸡肉丁");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0007", "香菇丁");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0008", "高水分糍粑海椒");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0009", "低水分糍粑海椒");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0010", "辣豆瓣");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0011", "整豆豉");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0012", "豆豉细粒");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0013", "卤黄豆");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0014", "野山椒粒");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0015", "竹笋丁");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0016", "香辣酱辣椒酱");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0017", "芽菜粒");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0018", "榨菜丁");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0019", "盐菜");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0020", "洋葱丁");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0021", "番茄酱");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0022", "甜豆瓣");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0023", "甜面酱");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0024", "芝麻酱");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0025", "炸花生");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0026", "盐渍青椒丁");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0027", "备料剁红椒");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0028", "萝卜丁");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0029", "油芝麻");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0030", "生姜");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0031", "大蒜");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0032", "榨菜酱");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0033", "炸碗豆");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0034", "大头菜丁");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0035", "酱油");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0036", "I+G");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0037", "味精");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0038", "白糖");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0039", "食盐");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0040", "花椒酱");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0041", "调味膏2");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0042", "调味膏5");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0043", "十三香调味膏");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0044", "酱香膏");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0045", "芽菜香料粉");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0046", "香料A");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0047", "香料D");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0048", "猪肉精膏");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0049", "调味膏3");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0050", "柠檬酸粉");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0051", "辣椒红");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0052", "辣椒油树脂");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0053", "水态混和酸");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0054", "加水稀释后防腐剂");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0055", "异维C钠粉");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0056", "琼脂粉");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0057", "香葱油");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0058", "水态甜味剂");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0059", "孜然粉");
- GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0060", "孜然油");
- }
- }
- }
|