From 30d0f67030b064d3bafbba756d4d51282cfb12c3 Mon Sep 17 00:00:00 2001
From: ZhaoGang <15196688790@163.com>
Date: Fri, 28 Jul 2023 18:16:49 +0800
Subject: [PATCH] =?UTF-8?q?=E5=89=94=E9=99=A4=E8=A5=BF=E9=97=A8=E5=AD=90?=
=?UTF-8?q?=E4=B8=9A=E5=8A=A1=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BPASmartClient.JXJFoodBigStation/App.config | 8 +-
.../Model/HK_PLC/DB_Write.cs | 3 +
.../Model/HK_PLC/HKDeviceStatus.cs | 59 -
.../Model/MQTT/IMQTTServer.cs | 42 +
.../Model/MQTT/Message/IMessage.cs | 12 +
.../Model/MQTT/Message/MessageDefine.cs | 18 +
.../Model/MQTT/Message/MessageID.cs | 13 +
.../MQTT/Message/MsgPackExtensionMethod.cs | 92 +
.../Model/MQTT/Message/MsgPackage.cs | 28 +
.../Model/MQTT/MqttServer.cs | 82 +
.../Model/MQTT/Topic.cs | 26 +
.../Model/ProcessControl.cs | 3200 ++++++++---------
.../Model/Siemens/DL_DataColl_DB.cs | 2 +-
.../Model/Siemens/DL_Finish_DB.cs | 3 +-
.../View/RecipeInfosView.xaml | 4 +-
.../View/RecipeReceiveView.xaml | 4 +-
.../ViewModel/RecipeInfosViewModel.cs | 28 +
.../ViewModel/RecipeReceiveViewModel.cs | 7 +-
.../ViewModel/SelectRecipesViewModel.cs | 1 +
.../Model/GVL_SmallStation.cs | 67 +-
.../Model/ProcessControl.cs | 267 +-
.../Model/Siemens/LocalRecipeDataColl.cs | 3 +
.../ViewModel/ManualFlowViewModel.cs | 2 +-
.../ViewModel/RecipeReceiveViewModel.cs | 6 +
.../ViewModel/SelectRecipesViewModel.cs | 1 +
25 files changed, 2125 insertions(+), 1853 deletions(-)
create mode 100644 BPASmartClient.JXJFoodBigStation/Model/MQTT/IMQTTServer.cs
create mode 100644 BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/IMessage.cs
create mode 100644 BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MessageDefine.cs
create mode 100644 BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MessageID.cs
create mode 100644 BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MsgPackExtensionMethod.cs
create mode 100644 BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MsgPackage.cs
create mode 100644 BPASmartClient.JXJFoodBigStation/Model/MQTT/MqttServer.cs
create mode 100644 BPASmartClient.JXJFoodBigStation/Model/MQTT/Topic.cs
diff --git a/BPASmartClient.JXJFoodBigStation/App.config b/BPASmartClient.JXJFoodBigStation/App.config
index 35b80a6d..5ce280c3 100644
--- a/BPASmartClient.JXJFoodBigStation/App.config
+++ b/BPASmartClient.JXJFoodBigStation/App.config
@@ -2,8 +2,12 @@
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs
index 4d12381e..c003b788 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs
@@ -7,6 +7,9 @@ using System.Threading.Tasks;
namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
+ ///
+ /// 上位机只写的DB99。
+ ///
public class DB_Write
{
///
diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
index e8aaa5dc..a6ccba15 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
@@ -78,7 +78,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
int index = Array.FindIndex(recipe.RawMaterial.ToArray(), p => p.RawMaterialBarrelNum == barrel && p.RawMaterialLocation == loc);
- #region 新版本
int x = 0;
if (barrel < 3) x = (barrel - 1) * 56 + 6;
else if (barrel > 3) x = (barrel - 2) * 56 + 6;
@@ -93,64 +92,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
HK_PLC_S7.Write(address, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}");
}
- #endregion
-
- #region 旧版本
- //if (index == -1)
- //{
- // switch (barrel)
- // {
- // case 1:
- // string address = "DB99.DBD" + (6 + 4 * (loc - 1));
- // HK_PLC_S7.Write(address, 0);
- // break;
- // case 2:
- // string address1 = "DB99.DBD" + (62 + 4 * (loc - 1));
- // HK_PLC_S7.Write(address1, 0);
- // break;
- // case 4:
- // string address2 = "DB99.DBD" + (118 + 4 * (loc - 1));
- // HK_PLC_S7.Write(address2, 0);
- // break;
- // case 5:
- // string address3 = "DB99.DBD" + (174 + 4 * (loc - 1));
- // HK_PLC_S7.Write(address3, 0);
- // break;
- // default:
- // break;
-
- // }
- //}
- //else
- //{
- // switch (barrel)
- // {
- // case 1:
- // string address = "DB99.DBD" + (6 + 4 * (loc - 1));
- // HK_PLC_S7.Write(address, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
- // MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}");
- // break;
- // case 2:
- // string address1 = "DB99.DBD" + (62 + 4 * (loc - 1));
- // HK_PLC_S7.Write(address1, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
- // MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}");
- // break;
- // case 4:
- // string address2 = "DB99.DBD" + (118 + 4 * (loc - 1));
- // HK_PLC_S7.Write(address2, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
- // MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}");
- // break;
- // case 5:
- // string address3 = "DB99.DBD" + (174 + 4 * (loc - 1));
- // HK_PLC_S7.Write(address3, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
- // MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}");
- // break;
- // default:
- // break;
- // }
- //}
- #endregion
-
}
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/MQTT/IMQTTServer.cs b/BPASmartClient.JXJFoodBigStation/Model/MQTT/IMQTTServer.cs
new file mode 100644
index 00000000..ddf5d2b4
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/Model/MQTT/IMQTTServer.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodBigStation.Model.MQTT
+{
+ ///
+ /// MQTT服务器接口。
+ ///
+ public interface IMQTTServer
+ {
+ #region 配料站-->服务
+ ///
+ /// 请求取消订单。
+ ///
+ ///
+ void PulishRequestCanelOrder(string recipecCode);
+ ///
+ /// 接收配方完成后反馈
+ ///
+ void PublishReceiveRecipeFeedback();
+ ///
+ /// 配方制作完成后反馈。
+ ///
+ void PublishRecipeDosingFeedback();
+ #endregion
+
+
+ #region 服务-->配料站
+ ///
+ /// 下发配方
+ ///
+ void GetIssueRecipeMessage();
+ ///
+ /// 取消配方
+ ///
+ void GetCancelOrderMessage(string recipeCode);
+ #endregion
+ }
+}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/IMessage.cs b/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/IMessage.cs
new file mode 100644
index 00000000..0218e0c4
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/IMessage.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodBigStation.Model.MQTT.Message
+{
+ public interface IMessage
+ {
+ }
+}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MessageDefine.cs b/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MessageDefine.cs
new file mode 100644
index 00000000..f5f04b79
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MessageDefine.cs
@@ -0,0 +1,18 @@
+using BPASmartClient.JXJFoodBigStation.Model.Siemens;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodBigStation.Model.MQTT.Message
+{
+ public class MessageDefine
+ {
+ public readonly static Dictionary MSG = new Dictionary()
+ {
+ { MessageID.RecipeDosingFeedback,typeof(DL_Finish_DB)}
+
+ };
+ }
+}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MessageID.cs b/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MessageID.cs
new file mode 100644
index 00000000..0b74f2cd
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MessageID.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodBigStation.Model.MQTT.Message
+{
+ public class MessageID
+ {
+ public const int RecipeDosingFeedback = 1;
+ }
+}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MsgPackExtensionMethod.cs b/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MsgPackExtensionMethod.cs
new file mode 100644
index 00000000..13943c85
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MsgPackExtensionMethod.cs
@@ -0,0 +1,92 @@
+using BPA.Helper;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodBigStation.Model.MQTT.Message
+{
+ public static class MsgPackExtensionMethod
+ {
+ public static MsgPackage Deserialize(this string msg)
+ {
+ if (msg != null)
+ {
+ if (msg.Iskey("MessageId") && msg.Iskey("Message") && msg.Iskey("MessageLen"))
+ {
+ var obj = msg.FromJSON();
+ if (obj != null)
+ return obj;
+ }
+ else
+ {
+ var id = msg.ToLower().GetJsonObjValue("messageid");
+ if (int.TryParse(id, out int tempId))
+ {
+ if (MessageDefine.MSG.ContainsKey(tempId))
+ {
+ MsgPackage package = new MsgPackage();
+ package.MessageId = tempId;
+ if (int.TryParse(msg.ToLower().GetJsonObjValue("messagelen"), out int tempLen))
+ package.MessageLen = tempLen;
+ var res = msg.ToLower().GetJsonObjValue("message");
+ if (res != null)
+ {
+ package.Message = (IMessage)JsonConvert.DeserializeObject(res, MessageDefine.MSG[tempId]);
+ }
+ return package;
+ }
+ }
+ }
+
+ }
+ return new MsgPackage();
+ }
+
+ public static string Serialize(this IMessage mes)
+ {
+ MsgPackage msg = new MsgPackage();
+ var res = MessageDefine.MSG.FirstOrDefault(p => p.Value == mes.GetType());
+ msg.MessageId = res.Key;
+ msg.MessageLen = JsonConvert.SerializeObject(mes).Length;
+ msg.Message = mes;
+ return JsonConvert.SerializeObject(msg);
+ }
+
+ public static string GetJsonObjValue(this string input, string key)
+ {
+ try
+ {
+ JObject jo = (JObject)JsonConvert.DeserializeObject(input);
+ if (jo != null && jo.ContainsKey(key))
+ return jo[key].ToString();
+ else
+ return string.Empty;
+
+ }
+ catch (Exception EX)
+ {
+ MessageLog.GetInstance.ShowEx(EX.ToString());
+ return string.Empty;
+ }
+ }
+
+ public static bool Iskey(this string input, string key)
+ {
+ try
+ {
+ JObject jo = (JObject)JsonConvert.DeserializeObject(input);
+ return jo != null && jo.ContainsKey(key);
+ }
+ catch (Exception EX)
+ {
+ MessageLog.GetInstance.ShowEx(EX.ToString());
+ return false;
+ }
+ }
+
+ }
+}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MsgPackage.cs b/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MsgPackage.cs
new file mode 100644
index 00000000..7a36404d
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/Model/MQTT/Message/MsgPackage.cs
@@ -0,0 +1,28 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodBigStation.Model.MQTT.Message
+{
+ public class MsgPackage
+ {
+ ///
+ /// 消息ID
+ ///
+ public int MessageId { get; set; }
+
+ ///
+ /// 消息内容
+ ///
+ [JsonProperty(TypeNameHandling = TypeNameHandling.Auto)]
+ public IMessage Message { get; set; }
+
+ ///
+ /// 消息长度
+ ///
+ public int MessageLen { get; set; }
+ }
+}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/MQTT/MqttServer.cs b/BPASmartClient.JXJFoodBigStation/Model/MQTT/MqttServer.cs
new file mode 100644
index 00000000..fd2f39ed
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/Model/MQTT/MqttServer.cs
@@ -0,0 +1,82 @@
+using BPA.Communication;
+using BPA.Communication.Base;
+using BPA.Helper;
+using BPA.Message;
+using BPASmartClient.JXJFoodBigStation.Model.MQTT.Message;
+using BPASmartClient.JXJFoodBigStation.Model.Siemens;
+using Microsoft.EntityFrameworkCore.ChangeTracking;
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodBigStation.Model.MQTT
+{
+ public class MqttServer
+ {
+ private volatile static MqttServer _Instance;
+ public static void Dis() => _Instance = null;
+ public static MqttServer GetInstance => _Instance ?? (_Instance = new MqttServer());
+ private MqttServer() { }
+
+ MqttHelper mqttHelper = new MqttHelper();
+
+
+
+ ///
+ /// MQTT 消息
+ ///
+ ConcurrentQueue msg { get; set; } = new ConcurrentQueue();
+
+ public Task Init(params object[] pars)
+ {
+ return Task.Factory.StartNew(() =>
+ {
+ //mqttHelper.IsVerifyNetwork = false;
+ mqttHelper.MessageRecive = new Action(s => { msg.Enqueue(s); });
+ mqttHelper.Connected = new Action(() =>
+ {
+ if (pars.Length > 0)
+ {
+ pars.ToList().ForEach(item => { mqttHelper.Subscrib(item?.ToString()); });
+ }
+ else
+ {
+ //订阅消息
+ }
+ TaskManage.GetInstance.StartLong(new Action(() =>
+ {
+ while (msg.Count > 0)
+ {
+ try
+ {
+ if (msg.TryDequeue(out string str))
+ {
+ //解析消息
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx(ex.ToString());
+ }
+
+ }
+ Thread.Sleep(10);
+ }), "MCS工单信息接收", true);
+ });
+ mqttHelper.Connect(new ConfigurationOptions()
+ {
+ UserName= ConfigurationManager.AppSettings["MQTT_USERNAME"],
+ Password= ConfigurationManager.AppSettings["MQTT_PASSWORD"],
+ IpAddress = ConfigurationManager.AppSettings["MQTT_IPADDRESS"],
+ Port =Convert.ToInt32( ConfigurationManager.AppSettings["MQTT_PORT"]),
+ ClientId = $"MES系统业务消息,{Guid.NewGuid()}"
+ });
+ });
+ }
+ }
+}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/MQTT/Topic.cs b/BPASmartClient.JXJFoodBigStation/Model/MQTT/Topic.cs
new file mode 100644
index 00000000..c59f4637
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/Model/MQTT/Topic.cs
@@ -0,0 +1,26 @@
+namespace BPASmartClient.JXJFoodBigStation.Model.MQTT
+{
+ public sealed class Topic
+ {
+ private const string Base = "jxjbaseuri";
+
+ /// 下发配方
+ public const string IssueRecipe = $"{Base}/issuerecipe";
+
+ /// 接收配方反馈配方
+ public const string ReceiveRecipeFeedback = $"{Base}/issuerecipe";
+
+ ///
+ /// 请求取消订单
+ ///
+ public const string RequestCancelOrder= $"{Base}/cancelorder";
+
+ ///
+ /// 取消订单
+ ///
+ public const string CancelOrder = $"{Base}/cancelorder";
+
+ /// 配方完成信息反馈。
+ public const string RecipeDosingFeedback = $"{Base}/cancelorder";
+ }
+}
\ No newline at end of file
diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
index dff1b3ef..3d972090 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
@@ -13,6 +13,7 @@ using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using System.Windows.Markup;
namespace BPASmartClient.JXJFoodBigStation.Model
{
@@ -21,25 +22,25 @@ namespace BPASmartClient.JXJFoodBigStation.Model
private volatile static ProcessControl _Instance;
public static ProcessControl GetInstance => _Instance ?? (_Instance = new ProcessControl());
private ProcessControl() { }
- public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
+ //public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
DL_Finish_DB FinishData = new DL_Finish_DB();
///
- /// 西门子配方数据
+ /// MES配方数据
///
public ObservableCollection SiemensRecipes { get; set; } = new ObservableCollection();
///
/// 本地配方数据
///
- public ObservableCollection LocalRecipes { get; set; } = new ObservableCollection();
+ //public ObservableCollection LocalRecipes { get; set; } = new ObservableCollection();
///
/// 配方等待执行
///
- public ObservableCollection RecipeWaitExecute { get; set; } = new ObservableCollection();
+ //public ObservableCollection RecipeWaitExecute { get; set; } = new ObservableCollection();
///
/// 配方正在执行
///
- public ObservableCollection RecipeExecuting { get; set; } = new ObservableCollection();
+ //public ObservableCollection RecipeExecuting { get; set; } = new ObservableCollection();
///
/// 配方执行完成
///
@@ -54,7 +55,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public ObservableCollection HardWareRawMaterialInfo { get; set; } = new ObservableCollection();
public ObservableCollection RawMaterialsInfo { get; set; } = new ObservableCollection();
///
- /// 西门子配方队列
+ /// MES配方队列
///
public ConcurrentQueue SiemensRecipeQueue1 = new ConcurrentQueue();
public ConcurrentQueue SiemensRecipeQueue2 = new ConcurrentQueue();
@@ -62,21 +63,21 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public ConcurrentQueue SiemensRecipeQueue4 = new ConcurrentQueue();
public ConcurrentDictionary> SiemensRecipeQueue = new ConcurrentDictionary>();
- public ObservableCollection recipe = new ObservableCollection();
+ //public ObservableCollection recipe = new ObservableCollection();
///
/// 本地配方队列
///
- public ConcurrentQueue LocalRecipeQueue1 = new ConcurrentQueue();
- public ConcurrentQueue LocalRecipeQueue2 = new ConcurrentQueue();
- public ConcurrentQueue LocalRecipeQueue3 = new ConcurrentQueue();
- public ConcurrentQueue LocalRecipeQueue4 = new ConcurrentQueue();
+ //public ConcurrentQueue LocalRecipeQueue1 = new ConcurrentQueue();
+ //public ConcurrentQueue LocalRecipeQueue2 = new ConcurrentQueue();
+ //public ConcurrentQueue LocalRecipeQueue3 = new ConcurrentQueue();
+ //public ConcurrentQueue LocalRecipeQueue4 = new ConcurrentQueue();
///
/// 海科PLC的IP
///
public string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
///
- /// 西门子PLC的IP
+ /// MESPLC的IP
///
public string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
public void Init()
@@ -84,763 +85,764 @@ namespace BPASmartClient.JXJFoodBigStation.Model
ActionManage.GetInstance.Register(new Action
public void VarResetInit()
{
- LocalRecipeQueue1.Clear();
- LocalRecipeQueue2.Clear();
- LocalRecipeQueue3.Clear();
- LocalRecipeQueue4.Clear();
+ //LocalRecipeQueue1.Clear();
+ //LocalRecipeQueue2.Clear();
+ //LocalRecipeQueue3.Clear();
+ //LocalRecipeQueue4.Clear();
SiemensRecipeQueue1.Clear();
SiemensRecipeQueue2.Clear();
SiemensRecipeQueue3.Clear();
SiemensRecipeQueue4.Clear();
}
- public void RecipeDosing()
- {
- GVL_BigStation.AllowIssueRecipe[0] = HKDevice.PlcRead.IsAllowIssueRecipe1;
- GVL_BigStation.AllowIssueRecipe[1] = HKDevice.PlcRead.IsAllowIssueRecipe2;
- GVL_BigStation.AllowIssueRecipe[2] = HKDevice.PlcRead.IsAllowIssueRecipe3;
- GVL_BigStation.AllowIssueRecipe[3] = HKDevice.PlcRead.IsAllowIssueRecipe4;
- GVL_BigStation.ReceviceFinishRecipe[0] = HKDevice.PlcRead.ReceiveFinishRecipe1;
- GVL_BigStation.ReceviceFinishRecipe[1] = HKDevice.PlcRead.ReceiveFinishRecipe2;
- GVL_BigStation.ReceviceFinishRecipe[2] = HKDevice.PlcRead.ReceiveFinishRecipe3;
- GVL_BigStation.ReceviceFinishRecipe[3] = HKDevice.PlcRead.ReceiveFinishRecipe4;
- GVL_BigStation.DosingFinishRecipe[0] = HKDevice.PlcRead.Recipe1DosingFinish;
- GVL_BigStation.DosingFinishRecipe[1] = HKDevice.PlcRead.Recipe2DosingFinish;
- GVL_BigStation.DosingFinishRecipe[2] = HKDevice.PlcRead.Recipe3DosingFinish;
- GVL_BigStation.DosingFinishRecipe[3] = HKDevice.PlcRead.Recipe4DosingFinish;
- GVL_BigStation.IsTrayArrive[0] = HKDevice.PlcRead.Tray1InPlace;
- GVL_BigStation.IsTrayArrive[1] = HKDevice.PlcRead.Tray2InPlace;
- GVL_BigStation.IsTrayArrive[2] = HKDevice.PlcRead.Tray3InPlace;
- GVL_BigStation.IsTrayArrive[3] = HKDevice.PlcRead.Tray4InPlace;
- GVL_BigStation.IsTrayArrive[4] = HKDevice.PlcRead.Tray5InPlace;
- #region 接收配方
- SiemensRecipes = Json.Data.Recipes;
- if (SiemensRecipes.Count > 0)
- {
- foreach (var data in SiemensRecipes)
- {
- foreach (var item in SiemensRecipeQueue)
- {
- if (item.Value.Count == 0 && item.Key == data.TrayCode && GVL_BigStation.AllowIssueRecipe[item.Key - 1])
- {
- if (SiemensDevice.DL_Status is DL_Status_DB status)
- {
- switch (GVL_BigStation.SiemensSendRecipeStatus)
- {
- case 3:
- SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true);
- MessageNotify.GetInstance.ShowRunLog($"配方1,发送配方编号和请求配料标志给西门子");
- GVL_BigStation.SiemensSendRecipeStatus = 4;
- break;
- case 4:
- if (SiemensDevice.DL_Status.Dosing_Start_ACK)
- {
- SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false);
- MessageNotify.GetInstance.ShowRunLog($"配方1,西门子确认开始配料");
- GVL_BigStation.SiemensSendRecipeStatus = 5;
- }
- break;
- case 5:
- if (SiemensDevice.DL_Status.Dosing_Start_ACK == false)
- {
- item.Value.Enqueue(data.RecipeCode);
- MessageNotify.GetInstance.ShowRunLog($"配方1,配方:{data.RecipeCode},加入队列");
- GVL_BigStation.SiemensSendRecipeStatus = 0;
- }
- break;
- default:
- break;
- }
- }
- }
- }
- }
- }
- else
- {
- SiemensRecipeQueue.Clear();
- GVL_BigStation.BarrelWasherSign = false;
- for (int i = 0; i < GVL_BigStation.RecipeDosingStatus.Length; i++)
- {
- GVL_BigStation.RecipeDosingStatus[i] = 0;
- }
- }
- #endregion
- #region 取消配方
- if (GVL_BigStation.Order_Cancel) //订单取消
- {
- if (!string.IsNullOrEmpty(GVL_BigStation.Order_CancelRecipeCode))
- {
- string code = GVL_BigStation.Order_CancelRecipeCode;
- int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == GVL_BigStation.Order_CancelRecipeCode);
- short TrayCode = 0;
- if (index >= 0)
- {
- TrayCode = (short)Json.Data.Recipes.ElementAt(index).TrayCode;
- }
- switch (GVL_BigStation.Order_CancelStep)
- {
- case 0:
- if (index == -1)
- {
- GVL_BigStation.Order_CancelStep = 10;
- }
- else
- {
- GVL_BigStation.Order_CancelStep = 20;
- foreach (var item in SiemensRecipeQueue)
- {
- if (item.Value.Contains(code))
- {
- GVL_BigStation.Order_CancelStep = 30;
- }
- }
- }
- break;
- case 10:
- SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true);
- GVL_BigStation.Order_CancelStep = 11;
- break;
- case 11:
- if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false)
- {
- SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false);
- GVL_BigStation.Order_CancelStep = 12;
- }
- break;
- case 12:
- MessageNotify.GetInstance.ShowRunLog($"西门子取消订单,但未找到订单:{GVL_BigStation.Order_CancelRecipeCode}");
- GVL_BigStation.Order_Cancel = false;
- GVL_BigStation.Order_CancelRecipeCode = "";
- GVL_BigStation.Order_CancelStep = 0;
- break;
+ #region 舍弃 - 不用
+ //public void RecipeDosing()
+ //{
+ // GVL_BigStation.AllowIssueRecipe[0] = HKDevice.PlcRead.IsAllowIssueRecipe1;
+ // GVL_BigStation.AllowIssueRecipe[1] = HKDevice.PlcRead.IsAllowIssueRecipe2;
+ // GVL_BigStation.AllowIssueRecipe[2] = HKDevice.PlcRead.IsAllowIssueRecipe3;
+ // GVL_BigStation.AllowIssueRecipe[3] = HKDevice.PlcRead.IsAllowIssueRecipe4;
+ // GVL_BigStation.ReceviceFinishRecipe[0] = HKDevice.PlcRead.ReceiveFinishRecipe1;
+ // GVL_BigStation.ReceviceFinishRecipe[1] = HKDevice.PlcRead.ReceiveFinishRecipe2;
+ // GVL_BigStation.ReceviceFinishRecipe[2] = HKDevice.PlcRead.ReceiveFinishRecipe3;
+ // GVL_BigStation.ReceviceFinishRecipe[3] = HKDevice.PlcRead.ReceiveFinishRecipe4;
+ // GVL_BigStation.DosingFinishRecipe[0] = HKDevice.PlcRead.Recipe1DosingFinish;
+ // GVL_BigStation.DosingFinishRecipe[1] = HKDevice.PlcRead.Recipe2DosingFinish;
+ // GVL_BigStation.DosingFinishRecipe[2] = HKDevice.PlcRead.Recipe3DosingFinish;
+ // GVL_BigStation.DosingFinishRecipe[3] = HKDevice.PlcRead.Recipe4DosingFinish;
+ // GVL_BigStation.IsTrayArrive[0] = HKDevice.PlcRead.Tray1InPlace;
+ // GVL_BigStation.IsTrayArrive[1] = HKDevice.PlcRead.Tray2InPlace;
+ // GVL_BigStation.IsTrayArrive[2] = HKDevice.PlcRead.Tray3InPlace;
+ // GVL_BigStation.IsTrayArrive[3] = HKDevice.PlcRead.Tray4InPlace;
+ // GVL_BigStation.IsTrayArrive[4] = HKDevice.PlcRead.Tray5InPlace;
+ // #region 接收配方
+ // SiemensRecipes = Json.Data.Recipes;
+ // if (SiemensRecipes.Count > 0)
+ // {
+ // foreach (var data in SiemensRecipes)
+ // {
+ // foreach (var item in SiemensRecipeQueue)
+ // {
+ // if (item.Value.Count == 0 && item.Key == data.TrayCode && GVL_BigStation.AllowIssueRecipe[item.Key - 1])
+ // {
+ // if (SiemensDevice.DL_Status is DL_Status_DB status)
+ // {
+ // switch (GVL_BigStation.SiemensSendRecipeStatus)
+ // {
+ // case 3:
+ // SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10);
+ // SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true);
+ // MessageNotify.GetInstance.ShowRunLog($"配方1,发送配方编号和请求配料标志给MES");
+ // GVL_BigStation.SiemensSendRecipeStatus = 4;
+ // break;
+ // case 4:
+ // if (SiemensDevice.DL_Status.Dosing_Start_ACK)
+ // {
+ // SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10);
+ // SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false);
+ // MessageNotify.GetInstance.ShowRunLog($"配方1,MES确认开始配料");
+ // GVL_BigStation.SiemensSendRecipeStatus = 5;
+ // }
+ // break;
+ // case 5:
+ // if (SiemensDevice.DL_Status.Dosing_Start_ACK == false)
+ // {
+ // item.Value.Enqueue(data.RecipeCode);
+ // MessageNotify.GetInstance.ShowRunLog($"配方1,配方:{data.RecipeCode},加入队列");
+ // GVL_BigStation.SiemensSendRecipeStatus = 0;
+ // }
+ // break;
+ // default:
+ // break;
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ // else
+ // {
+ // SiemensRecipeQueue.Clear();
+ // GVL_BigStation.BarrelWasherSign = false;
+ // for (int i = 0; i < GVL_BigStation.RecipeDosingStatus.Length; i++)
+ // {
+ // GVL_BigStation.RecipeDosingStatus[i] = 0;
+ // }
+ // }
+ // #endregion
+ // #region 取消配方
+ // if (GVL_BigStation.Order_Cancel) //订单取消
+ // {
+ // if (!string.IsNullOrEmpty(GVL_BigStation.Order_CancelRecipeCode))
+ // {
+ // string code = GVL_BigStation.Order_CancelRecipeCode;
+ // int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == GVL_BigStation.Order_CancelRecipeCode);
+ // short TrayCode = 0;
+ // if (index >= 0)
+ // {
+ // TrayCode = (short)Json.Data.Recipes.ElementAt(index).TrayCode;
+ // }
+ // switch (GVL_BigStation.Order_CancelStep)
+ // {
+ // case 0:
+ // if (index == -1)
+ // {
+ // GVL_BigStation.Order_CancelStep = 10;
+ // }
+ // else
+ // {
+ // GVL_BigStation.Order_CancelStep = 20;
+ // foreach (var item in SiemensRecipeQueue)
+ // {
+ // if (item.Value.Contains(code))
+ // {
+ // GVL_BigStation.Order_CancelStep = 30;
+ // }
+ // }
+ // }
+ // break;
+ // case 10:
+ // SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true);
+ // GVL_BigStation.Order_CancelStep = 11;
+ // break;
+ // case 11:
+ // if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false)
+ // {
+ // SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false);
+ // GVL_BigStation.Order_CancelStep = 12;
+ // }
+ // break;
+ // case 12:
+ // MessageNotify.GetInstance.ShowRunLog($"MES取消订单,但未找到订单:{GVL_BigStation.Order_CancelRecipeCode}");
+ // GVL_BigStation.Order_Cancel = false;
+ // GVL_BigStation.Order_CancelRecipeCode = "";
+ // GVL_BigStation.Order_CancelStep = 0;
+ // break;
- case 20:
- SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true);
- GVL_BigStation.Order_CancelStep = 21;
- break;
- case 21:
- if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false)
- {
- SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false);
- GVL_BigStation.Order_CancelStep = 22;
- }
- break;
- case 22:
- GVL_BigStation.SiemensSendRecipeStatus = 0;
- App.Current.Dispatcher.Invoke(() =>
- {
- Json.Data.Recipes.RemoveAt(index);
- });
- MessageNotify.GetInstance.ShowRunLog($"正在执行请求订单流程,配方还未到PLC,订单号:{GVL_BigStation.Order_CancelRecipeCode}");
- GVL_BigStation.Order_Cancel = false;
- GVL_BigStation.Order_CancelRecipeCode = "";
- GVL_BigStation.Order_CancelStep = 0;
- break;
+ // case 20:
+ // SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true);
+ // GVL_BigStation.Order_CancelStep = 21;
+ // break;
+ // case 21:
+ // if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false)
+ // {
+ // SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false);
+ // GVL_BigStation.Order_CancelStep = 22;
+ // }
+ // break;
+ // case 22:
+ // GVL_BigStation.SiemensSendRecipeStatus = 0;
+ // App.Current.Dispatcher.Invoke(() =>
+ // {
+ // Json.Data.Recipes.RemoveAt(index);
+ // });
+ // MessageNotify.GetInstance.ShowRunLog($"正在执行请求订单流程,配方还未到PLC,订单号:{GVL_BigStation.Order_CancelRecipeCode}");
+ // GVL_BigStation.Order_Cancel = false;
+ // GVL_BigStation.Order_CancelRecipeCode = "";
+ // GVL_BigStation.Order_CancelStep = 0;
+ // break;
- case 30:
- foreach (var item in SiemensRecipeQueue)
- {
- if (item.Value.Contains(code))
- {
- if (GVL_BigStation.RecipeDosingStatus[item.Key - 1] != 0)
- {
- HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true);
- HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode);
- GVL_BigStation.RecipeDosingStatus[item.Key - 1] = 0;
- item.Value.TryDequeue(out code);
- GVL_BigStation.Order_CancelStep = 32;
- MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}");
- }
- else
- {
- GVL_BigStation.Order_CancelStep = 32;
- MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}");
- }
- }
- }
- break;
- case 32:
- SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true);
- GVL_BigStation.Order_CancelStep = 33;
- break;
- case 33:
- if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false)
- {
- SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false);
- App.Current.Dispatcher.Invoke(() =>
- {
- Json.Data.Recipes.RemoveAt(index);
- });
- GVL_BigStation.Order_CancelStep = 0;
- MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
- }
- break;
- default:
- break;
- }
- }
- }
- #endregion
- #region 配料
- foreach (var data in SiemensRecipeQueue)
- {
- int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == data.Value.ElementAt(0));
- if (index >= 0 && index < SiemensRecipes.Count)
- {
- string code = SiemensRecipes.ElementAt(index).RecipeCode;
- int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
- if (GVL_BigStation.RecipeDosingStatus[data.Key] == 0 && GVL_BigStation.AllowIssueRecipe[data.Key] && GVL_BigStation.IsTrayArrive[trayCode - 1])//配方4是否允许下发配发
- {
- if (SiemensRecipes.ElementAt(index).IsWashingBarrel)
- {
- if (!GVL_BigStation.BarrelWasherSign)//其他配方在洗桶时,等待其他配方洗完,在发送数据
- {
- GVL_BigStation.BarrelWasherSign = true;
- HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶
- MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");
+ // case 30:
+ // foreach (var item in SiemensRecipeQueue)
+ // {
+ // if (item.Value.Contains(code))
+ // {
+ // if (GVL_BigStation.RecipeDosingStatus[item.Key - 1] != 0)
+ // {
+ // HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true);
+ // HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode);
+ // GVL_BigStation.RecipeDosingStatus[item.Key - 1] = 0;
+ // item.Value.TryDequeue(out code);
+ // GVL_BigStation.Order_CancelStep = 32;
+ // MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}");
+ // }
+ // else
+ // {
+ // GVL_BigStation.Order_CancelStep = 32;
+ // MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}");
+ // }
+ // }
+ // }
+ // break;
+ // case 32:
+ // SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true);
+ // GVL_BigStation.Order_CancelStep = 33;
+ // break;
+ // case 33:
+ // if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false)
+ // {
+ // SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false);
+ // App.Current.Dispatcher.Invoke(() =>
+ // {
+ // Json.Data.Recipes.RemoveAt(index);
+ // });
+ // GVL_BigStation.Order_CancelStep = 0;
+ // MessageNotify.GetInstance.ShowRunLog($"队列1,MES取消订单完成,订单号:{code}");
+ // }
+ // break;
+ // default:
+ // break;
+ // }
+ // }
+ // }
+ // #endregion
+ // #region 配料
+ // foreach (var data in SiemensRecipeQueue)
+ // {
+ // int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == data.Value.ElementAt(0));
+ // if (index >= 0 && index < SiemensRecipes.Count)
+ // {
+ // string code = SiemensRecipes.ElementAt(index).RecipeCode;
+ // int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
+ // if (GVL_BigStation.RecipeDosingStatus[data.Key] == 0 && GVL_BigStation.AllowIssueRecipe[data.Key] && GVL_BigStation.IsTrayArrive[trayCode - 1])//配方4是否允许下发配发
+ // {
+ // if (SiemensRecipes.ElementAt(index).IsWashingBarrel)
+ // {
+ // if (!GVL_BigStation.BarrelWasherSign)//其他配方在洗桶时,等待其他配方洗完,在发送数据
+ // {
+ // GVL_BigStation.BarrelWasherSign = true;
+ // HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶
+ // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");
- GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now;
- HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
- HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true);
- GVL_BigStation.RecipeDosingStatus[data.Key] = 1;
- MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
- }
- }
- else
- {
- GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now;
- HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
- HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true);
- GVL_BigStation.RecipeDosingStatus[data.Key] = 1;
- MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
- }
- }
- if (GVL_BigStation.RecipeDosingStatus[data.Key] == 1 && GVL_BigStation.ReceviceFinishRecipe[data.Key])
- {
- if (SiemensRecipes.ElementAt(index).IsWashingBarrel)
- {
- HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶
- MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位");
- }
- GVL_BigStation.RecipeDosingStatus[data.Key] = 2;
- HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true);
- StockBinParReset();
- MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成");
- }
- if (GVL_BigStation.RecipeDosingStatus[data.Key] == 2 && GVL_BigStation.DosingFinishRecipe[data.Key])
- {
- if (SiemensRecipes.ElementAt(index).IsWashingBarrel)
- {
- GVL_BigStation.BarrelWasherSign = false;
- }
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
- ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index));
- if (SiemensDevice.IsConnected)
- {
- FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode;
- FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName;
- FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode;
- for (int i = 0; i < FinishData.Material.Length; i++)
- {
- FinishData.Material[i] = new UDT1();
- }
- for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++)
- {
- FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
- FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
- FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight);
- MessageNotify.GetInstance.ShowRunLog($"配方{data.Key},配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg");
- }
- FinishData.Ask_For_Finish = true;
- double a = DateTime.Now.Subtract(GVL_BigStation.RecipeDosingTime[data.Key]).TotalSeconds;
- FinishData.ProcessTime = Convert.ToInt16(a);
- SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361);
- MessageNotify.GetInstance.ShowRunLog($"{code}配方配料完成,将信号反馈给西门子");
- }
- data.Value.TryDequeue(out code);
- if (!GVL_BigStation.IsUseLocalRecipe)
- {
- App.Current.Dispatcher.Invoke(() =>
- {
- Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- });
- }
- else
- {
- App.Current.Dispatcher.Invoke(() =>
- {
- Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- });
- }
- HKDevice.HK_PLC_S7.Write($"DB99.DBX1.{data.Key + 3}", true);
- GVL_BigStation.RecipeDosingStatus[data.Key] = 3;
- }
- if (GVL_BigStation.RecipeDosingStatus[data.Key] == 3 && GVL_BigStation.DosingFinishRecipe[data.Key] == false)
- {
- HKDevice.HK_PLC_S7.Write($"DB99.DBX1.{data.Key + 3}", false);
- GVL_BigStation.RecipeDosingStatus[data.Key] = 0;
- }
- }
- }
- #endregion
- }
+ // GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now;
+ // HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
+ // HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true);
+ // GVL_BigStation.RecipeDosingStatus[data.Key] = 1;
+ // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
+ // }
+ // }
+ // else
+ // {
+ // GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now;
+ // HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
+ // HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true);
+ // GVL_BigStation.RecipeDosingStatus[data.Key] = 1;
+ // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
+ // }
+ // }
+ // if (GVL_BigStation.RecipeDosingStatus[data.Key] == 1 && GVL_BigStation.ReceviceFinishRecipe[data.Key])
+ // {
+ // if (SiemensRecipes.ElementAt(index).IsWashingBarrel)
+ // {
+ // HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶
+ // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位");
+ // }
+ // GVL_BigStation.RecipeDosingStatus[data.Key] = 2;
+ // HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true);
+ // StockBinParReset();
+ // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成");
+ // }
+ // if (GVL_BigStation.RecipeDosingStatus[data.Key] == 2 && GVL_BigStation.DosingFinishRecipe[data.Key])
+ // {
+ // if (SiemensRecipes.ElementAt(index).IsWashingBarrel)
+ // {
+ // GVL_BigStation.BarrelWasherSign = false;
+ // }
+ // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
+ // ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index));
+ // if (SiemensDevice.IsConnected)
+ // {
+ // FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode;
+ // FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName;
+ // FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode;
+ // for (int i = 0; i < FinishData.Material.Length; i++)
+ // {
+ // FinishData.Material[i] = new UDT1();
+ // }
+ // for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++)
+ // {
+ // FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
+ // FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
+ // FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight);
+ // MessageNotify.GetInstance.ShowRunLog($"配方{data.Key},配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg");
+ // }
+ // FinishData.Ask_For_Finish = true;
+ // double a = DateTime.Now.Subtract(GVL_BigStation.RecipeDosingTime[data.Key]).TotalSeconds;
+ // FinishData.ProcessTime = Convert.ToInt16(a);
+ // SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361);
+ // MessageNotify.GetInstance.ShowRunLog($"{code}配方配料完成,将信号反馈给MES");
+ // }
+ // data.Value.TryDequeue(out code);
+ // if (!GVL_BigStation.IsUseLocalRecipe)
+ // {
+ // App.Current.Dispatcher.Invoke(() =>
+ // {
+ // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
+ // });
+ // }
+ // else
+ // {
+ // App.Current.Dispatcher.Invoke(() =>
+ // {
+ // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
+ // });
+ // }
+ // HKDevice.HK_PLC_S7.Write($"DB99.DBX1.{data.Key + 3}", true);
+ // GVL_BigStation.RecipeDosingStatus[data.Key] = 3;
+ // }
+ // if (GVL_BigStation.RecipeDosingStatus[data.Key] == 3 && GVL_BigStation.DosingFinishRecipe[data.Key] == false)
+ // {
+ // HKDevice.HK_PLC_S7.Write($"DB99.DBX1.{data.Key + 3}", false);
+ // GVL_BigStation.RecipeDosingStatus[data.Key] = 0;
+ // }
+ // }
+ // }
+ // #endregion
+ //}
+ #endregion
///
/// 读取配料完成时,每个料仓的配料重量
///
@@ -2418,5 +2305,52 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
}
}
+
+ ///
+ /// 配方添加到执行队列
+ ///
+ /// 执行队列
+ /// 配方编码
+ /// 队列名称
+ ///
+ private void ReceiveRecipe(ConcurrentQueue recipeQueue,string recipeCode,string queueName)
+ {
+ if (!(recipeQueue.Contains(recipeCode)))
+ {
+ //if (SiemensDevice.DL_Status is DL_Status_DB status)
+ //{
+ switch (GVL_BigStation.SiemensSendRecipeStatus)
+ {
+ case 3:
+ //SiemensDevice.Siemens_PLC_S7.WriteString(2331, recipeCode, 10);
+ //SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true);
+ MessageNotify.GetInstance.ShowRunLog($"{queueName},发送配方编号和请求配料标志给MES");
+ GVL_BigStation.SiemensSendRecipeStatus = 4;
+ break;
+ case 4:
+ //if (SiemensDevice.DL_Status.Dosing_Start_ACK)
+ //{
+ // SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10);
+ // SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false);
+ MessageNotify.GetInstance.ShowRunLog($"{queueName},MES确认开始配料");
+ GVL_BigStation.SiemensSendRecipeStatus = 5;
+ //}
+ break;
+ case 5:
+ //if (SiemensDevice.DL_Status.Dosing_Start_ACK == false)
+ //{
+ recipeQueue.Enqueue(recipeCode);
+ MessageNotify.GetInstance.ShowRunLog($"{queueName},配方:{recipeCode},加入队列");
+ GVL_BigStation.SiemensSendRecipeStatus = 0;
+ //}
+ break;
+ default:
+ break;
+ }
+ //}
+ }
+ }
+
+
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs
index 41e36e69..fd884d52 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
- public class DL_DataColl_DB
+ public class DL_DataColl_DB
{
[Siemens(16)]
public string RecipeCode { get; set; } = "";
diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs
index 2a9b2928..40b50cd5 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs
@@ -1,4 +1,5 @@
-using BPASmartClient.S7Net;
+using BPASmartClient.JXJFoodBigStation.Model.MQTT.Message;
+using BPASmartClient.S7Net;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
index a1d57384..12885a17 100644
--- a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
+++ b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
@@ -322,7 +322,8 @@
Text="{Binding TrayCode}" />
-
+
+
+
diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
index 0dc1e74c..97ed4c3e 100644
--- a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
+++ b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
@@ -293,7 +293,7 @@
FontSize="12"
Foreground="#FF2AB2E7"
Text="{Binding RecipeName}" />
-
+ Text="配方类别:" />-->
diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs
index a3970fb1..da03c158 100644
--- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs
+++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs
@@ -62,6 +62,34 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
return;
}
+ if (string.IsNullOrWhiteSpace(RecipeName) )
+ {
+ MessageNotify.GetInstance.ShowDialog("配方名称不可为空,请修改后再试。",DialogType.Error);
+ return;
+ }
+ if (TrayCode is <=0 or >5)
+ {
+ MessageNotify.GetInstance.ShowDialog("请输入正确的托盘编号,请修改后再试。", DialogType.Error);
+ return;
+ }
+ foreach (RawMaterial item in RawMaterialsInfo)
+ {
+ if (item.RawMaterialLocation ==0)
+ {
+ MessageNotify.GetInstance.ShowDialog("请输入正确的原料位置,请修改后再试。", DialogType.Error);
+ return;
+ }
+ if (item.RawMaterialBarrelNum is <=0 or >4)
+ {
+ MessageNotify.GetInstance.ShowDialog("请输入正确的托盘桶号,请修改后再试。", DialogType.Error);
+ return;
+ }
+ if (item.RawMaterialWeight <=0)
+ {
+ MessageNotify.GetInstance.ShowDialog("请输入正确的原料重量,请修改后再试。", DialogType.Error);
+ return;
+ }
+ }
var bom= Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == RecipeCode);
if (bom == null)//新配方
{
diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs
index 776bf485..bc720586 100644
--- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs
+++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs
@@ -113,8 +113,8 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
}
Json.Data.Recipes.Clear();
- Json.Save();
Json.Data.SelectedRecipes.Clear();
+ Json.Save();
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"本地配方已全部删除!");
MessageNotify.GetInstance.ShowUserLog($"手动清除所有配方。");
});
@@ -126,6 +126,11 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
return;
}
var res = Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
+ var res1 = Json.Data.SelectedRecipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
+ if (res1 is not null)
+ {
+ Json.Data.SelectedRecipes.Remove(res1);
+ }
if (res != null)
{
Recipes.Remove(res);
diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/SelectRecipesViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/SelectRecipesViewModel.cs
index ac07886c..c55c7299 100644
--- a/BPASmartClient.JXJFoodBigStation/ViewModel/SelectRecipesViewModel.cs
+++ b/BPASmartClient.JXJFoodBigStation/ViewModel/SelectRecipesViewModel.cs
@@ -17,6 +17,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
public SelectRecipesViewModel()
{
AllRecipes = new();
+ SelectRecipes.Clear();
foreach (var item in Json.Data.SelectedRecipes)
{
SelectRecipes.Add(item);
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
index b8660926..054aa0fd 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
@@ -57,15 +57,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
///
public ushort StockBinCylinderStatus { get; set; }
- [VarComm("Global", "柔性配料料仓配料下发情况")]
///
/// 料仓配料情况
///
- public ushort[] StockBinDosingIssue { get; set; } = new ushort[5] { 0, 0, 0, 0, 0 };
[VarComm("Global", "柔性配料料仓配料下发情况")]
+ public ushort[] StockBinDosingIssue { get; set; } = new ushort[5] { 0, 0, 0, 0, 0 };
///
/// 料仓配料情况
///
+ [VarComm("Global", "柔性配料料仓配料下发情况")]
public ushort[] RecipeStockBinDosing { get; set; } = new ushort[5] { 0, 0, 0, 0, 0 };
[VarComm("Global", "柔性配料料仓配料情况")]
@@ -92,163 +92,161 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
///
public int Tray2LogicFinish { get; set; } = 0;
- [VarComm("Global", "托盘1有货架")]
///
/// 托盘1有货架
///
+ [VarComm("Global", "托盘1有货架")]
public bool Station1HaveTray { get; set; }
- [VarComm("Global", "托盘2有货架")]
///
/// 托盘2有货架
///
+ [VarComm("Global", "托盘2有货架")]
public bool Station2HaveTray { get; set; }
- [VarComm("Global", "托盘1传感器信号")]
///
/// 托盘1传感器信号
///
+ [VarComm("Global", "托盘1传感器信号")]
public bool Station1Sensor { get; set; }
- [VarComm("Global", "托盘2传感器信号")]
///
/// 托盘2传感器信号
///
+ [VarComm("Global", "托盘2传感器信号")]
public bool Station2Sensor { get; set; }
- [VarComm("Global", "托盘1气缸信号")]
///
/// 托盘1气缸信号
///
+ [VarComm("Global", "托盘1气缸信号")]
public bool Station1Cylinder { get; set; }
- [VarComm("Global", "托盘2气缸信号")]
///
/// 托盘2气缸信号
///
+ [VarComm("Global", "托盘2气缸信号")]
public bool Station2Cylinder { get; set; }
- [VarComm("Global", "AGV放托盘1完成")]
+
///
/// AGV放托盘1完成
///
+ [VarComm("Global", "AGV放托盘1完成")]
public bool AGV_PutTray1Finish { get; set; }
- [VarComm("Global", "AGV取托盘1完成")]
///
/// AGV取托盘1完成
///
+ [VarComm("Global", "AGV取托盘1完成")]
public bool AGV_GetTray1Finish { get; set; }
- [VarComm("Global", "AGV放托盘2完成")]
///
/// AGV放托盘1完成
///
+ [VarComm("Global", "AGV放托盘2完成")]
public bool AGV_PutTray2Finish { get; set; }
- [VarComm("Global", "AGV取托盘2完成")]
///
/// AGV取托盘2完成
///
+ [VarComm("Global", "AGV取托盘2完成")]
public bool AGV_GetTray2Finish { get; set; }
- [VarComm("Global", "托盘1气缸复位")]
///
/// 托盘1气缸复位
///
+ [VarComm("Global", "托盘1气缸复位")]
public bool CylinderReset { get; set; }
- [VarComm("Global", "发送给plc的心跳")]
///
/// 发送给plc的心跳
///
+ [VarComm("Global", "发送给plc的心跳")]
public bool HeartBeatToPlc { get; set; } = false;
[VarComm("Global", "屏蔽小料站料仓不足15个报警")]
-
-
public bool DisEnableStockAlarm { get; set; } = false;
- [VarComm("Global", "配方制作完成数量")]
///
/// 配方制作完成数量
///
+ [VarComm("Global", "配方制作完成数量")]
public int RecipeDosingCompleNum { get; set; } = 0;
- [VarComm("Global", "来自plc的心跳")]
///
/// 来自plc的心跳
///
+ [VarComm("Global", "来自plc的心跳")]
public bool HeartBeatFromPlc { get; set; } = false;
- [VarComm("Global", "是否允许西门子下发配方")]
///
/// 是否允许西门子下发配方
///
+ [VarComm("Global", "是否允许西门子下发配方")]
public bool IsAllowSiemensSendRecipe { get; set; } = false;
- [VarComm("Global", "西门子下发配方状态0=等待下发配方 1=请求下发配方 2=接收配方 3=配方接收配方完成 4=请求配料 5=西门子确认开始配料 6=西门子确认开始配料信号复位")]
///
/// 西门子下发配方状态 0:等待下发配方 1:请求下发配方 2:上位机接收配方 3:配方接收配方完成 4:上位机向西门子请求配料 5:西门子确认开始配料 6:西门子确认开始配料 信号复位
///
+ [VarComm("Global", "西门子下发配方状态0=等待下发配方 1=请求下发配方 2=接收配方 3=配方接收配方完成 4=请求配料 5=西门子确认开始配料 6=西门子确认开始配料信号复位")]
public int SiemensSendRecipeStatus { get; set; } = 0;
- [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")]
///
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料
///
+ [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")]
public int RecipeStatusIDTray1 { get; set; } = 0;
- [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")]
///
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料
///
+ [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")]
public int[] RecipeProcessStatus { get; set; } = new int[5] { 0, 0, 0, 0, 0 };
- [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")]
///
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料
///
+ [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")]
public bool AGVIsGetTray { get; set; } = false;
- [VarComm("Global", "配方2下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")]
///
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料
///
+ [VarComm("Global", "配方2下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")]
public int RecipeStatusIDTray2 { get; set; } = 0;
- [VarComm("Global", "当前配方正在配料位置")]
///
/// 当前料仓的位置
///
+ [VarComm("Global", "当前配方正在配料位置")]
public int StockInIsWork { get; set; } = 0;
-
- [VarComm("Global", "设置料仓配料完成")]
///
/// 当前料仓的位置
///
+ [VarComm("Global", "设置料仓配料完成")]
public bool[] StockInDosingComple { get; set; } = new bool[15];
- [VarComm("Global", "是否使用粉仓配料")]
///
/// 是否使用粉仓配料
///
+ [VarComm("Global", "是否使用粉仓配料")]
public bool IsUseWindSend { get; set; } = false;
- [VarComm("Global", "粉仓正在配料")]
///
/// 粉仓正在配料
///
+ [VarComm("Global", "粉仓正在配料")]
public bool WindSendDosing { get; set; } = false;
@@ -259,16 +257,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
#region 本地模拟配方
- [VarComm("Global", "是否使用本地模拟配方")]
///
/// 是否使用本地模拟配方
///
+ [VarComm("Global", "是否使用本地模拟配方")]
public bool IsUseLocalRecipe { get; set; }
- [VarComm("Global", "是否使用本地模拟配方")]
+
///
- /// 是否使用本地模拟配方
+ /// 不使用小料站配料
///
+ [VarComm("Global", "是否使用本地模拟配方")]
public bool NotUseSmallStation { get; set; }
///
@@ -299,16 +298,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public bool WindSendDosingComple { get; set; } = false;
- [VarComm("Global", "粉料仓配料状态")]
///
/// 粉料仓配料状态(0:无意义,1:粉料仓下配方,2:plc接收配方完成,3:粉料仓配料完成,4:粉料仓配料完成信号复位,5:排料完成)
///
+ [VarComm("Global", "粉料仓配料状态")]
public int WindSendDosingStatus { get; set; } = 0;
- [VarComm("Global", "PLC的系统模式 DB44.DBX0.1")]
///
/// PLC的系统模式 DB44.DBX0.1
///
+ [VarComm("Global", "PLC的系统模式 DB44.DBX0.1")]
public bool PlcSystemMode { get; set; } = false;
[VarComm("Global", "PLC的系统模式 DB44.DBX0.1")]
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
index c84feeea..7eed1e38 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
@@ -41,21 +41,21 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
///
- /// 物料集合
+ /// 物料集合(工位配方集合,五个键分别对应五个工位)
///
public Dictionary> RecipeQueueTray { get; set; } = new Dictionary>();
public ConcurrentQueue RecipeQueueTray2 = new ConcurrentQueue();
-
- public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
+ //XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB();
+ //public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
public WindSendDeviceStatus WindSendDevice = new WindSendDeviceStatus();
public ObservableCollection CommData { get; set; } = new ObservableCollection();
public ObservableCollection ProcessVar { get; set; } = new ObservableCollection();
- XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB();
+
///
/// 风送PLC的DB块
///
@@ -333,8 +333,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
GVL_SmallStation.GetInstance.RobotStatus = HKDevice.HK_PLC_S7.Read("DB3.DBB0");
GVL_SmallStation.GetInstance.RobotProgramNum = HKDevice.HK_PLC_S7.Read("DB3.DBB1");
}
- if (SiemensDevice.IsConnected)
- {
+ //if (SiemensDevice.IsConnected)
+ //{
ushort TrayCylinder = 0;
ushort TraySensor = 0;
if (GVL_SmallStation.GetInstance.Station1Sensor)
@@ -353,10 +353,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
TrayCylinder = TrayCylinder.SetBitValue(0, false);
}
- this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.4", GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet);
- this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW190", TraySensor);//添加工位传感器的信号
- this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号
- ushort AGV_Put = (ushort)SiemensDevice.XL_Status.AgvFinishPut;
+ //this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.4", GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet);
+ //this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW190", TraySensor);//添加工位传感器的信号
+ //this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号
+ ushort AGV_Put =0 /*(ushort)SiemensDevice.XL_Status.AgvFinishPut*/;
if (AGV_Put.GetBitValue(1))
{
GVL_SmallStation.GetInstance.AGV_PutTray1Finish = true;
@@ -365,7 +365,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
GVL_SmallStation.GetInstance.AGV_PutTray1Finish = false;
}
- ushort AGV_Get = (ushort)SiemensDevice.XL_Status.AgvFinishGet;
+ ushort AGV_Get =0/* (ushort)SiemensDevice.XL_Status.AgvFinishGet*/;
if (AGV_Get.GetBitValue(1))
{
GVL_SmallStation.GetInstance.AGV_GetTray1Finish = true;
@@ -374,7 +374,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
GVL_SmallStation.GetInstance.AGV_GetTray1Finish = false;
}
- }
+ //}
}
public void CancelOrder()
@@ -442,16 +442,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
break;
case 3:
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
+ //SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
GVL_SmallStation.GetInstance.OrderCancelStep = 4;
break;
case 4:
- if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false)
- {
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
+ //if (SiemensDevice.Siemens_PLC_S7.Read("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(() =>
@@ -465,16 +465,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
GVL_SmallStation.GetInstance.OrderCancelStep = 0;
break;
case 20:
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
+ //SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
GVL_SmallStation.GetInstance.OrderCancelStep = 21;
break;
case 21:
- if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false)
- {
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
+ //if (SiemensDevice.Siemens_PLC_S7.Read("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(() =>
@@ -489,16 +489,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//30-39为订单还未下发至上位机
case 30:
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
+ //SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
GVL_SmallStation.GetInstance.OrderCancelStep = 31;
break;
case 31:
- if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false)
- {
- SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
+ //if (SiemensDevice.Siemens_PLC_S7.Read("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;
@@ -521,33 +521,33 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
foreach (var data in RemoteRecipes)
{
- if (data.TrayCode == 1)
- {
- if (SiemensDevice.XL_Status is XL_Status_DB status)
- {
+ //if (data.TrayCode == 1)
+ //{
+ //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);
+ // 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);
+ //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)
- {
+ //if (SiemensDevice.XL_Status.Dosing_Confirm == false)
+ //{
GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 6;
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成");
- }
+ //}
break;
case 6:
for (int i = 0; i < 5; i++)
@@ -574,10 +574,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
break;
default:
break;
- }
+ //}
}
- }
+ //}
}
}
else
@@ -598,8 +598,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
foreach (var data in RemoteRecipes)
{
- if (data.TrayCode == 1)
- {
+ //if (data.TrayCode == 1)
+ //{
for (int i = 0; i < 5; i++)
{
if (GVL_SmallStation.GetInstance.NotUseSmallStation)
@@ -619,7 +619,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
- }
+ //}
}
}
else
@@ -639,6 +639,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
///
private void RecipeInfoToHKPLC()
{
+ //五个工位AGV控制请求流程。
if (!GVL_SmallStation.GetInstance.NotUseSmallStation)
{
for (int i = 0; i < 5; i++)
@@ -657,7 +658,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
break;
case 1:
if (GVL_SmallStation.GetInstance.Station1HaveTray)
-
{
HKDevice.HK_PLC_S7.Write("DB4.DBX8." + i, false);
GVL_SmallStation.GetInstance.Tray_AGVLogic[i] = 2;
@@ -688,11 +688,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
+
+ //工位配料流程
foreach (var recipe in RecipeQueueTray)
{
+ //recipeNum就是托盘号,也就是工位号。
int recipeNum = recipe.Key;
+ //判断工位是否有配方。
if (RecipeQueueTray[recipeNum].Count > 0)
{
+ //从配方列表里根据配方号查找配方
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray[recipeNum].ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
{
@@ -700,44 +705,46 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
string windSend = RemoteRecipes.ElementAt(index).ToString();
+ //当前只配托盘号为1 ,即工位1 的配方。
if (trayCode == 1)
{
+ //如果不使用小料站配料,目前没有这种工作情况。
if (GVL_SmallStation.GetInstance.NotUseSmallStation)
{
if (GVL_SmallStation.GetInstance.AGV_PutTray1Finish)
{
Thread.Sleep(5000);
var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
- 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;
- }
- RecipeFinishInfo.Ask_For_Finish = true;
- RecipeFinishInfo.DosingTime = Convert.ToInt16(0);
- SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261);
+ //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;
+ // }
+ // RecipeFinishInfo.Ask_For_Finish = true;
+ // RecipeFinishInfo.DosingTime = Convert.ToInt16(0);
+ // SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261);
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
- }
- else
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
+ //}
+ //else
{
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
}
@@ -760,9 +767,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (GVL_SmallStation.GetInstance.WindSendDosingStatus == 1)
{
+ //清空风送配料数据
WindSend_Write WindSendData111 = new WindSend_Write();
WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData111, 95);
Thread.Sleep(200);
+ //设置DB95数据并下发。
WindSendData111.TargetRecipeCode = code;
WindSendData111.IsAllowDosing = true;
foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
@@ -795,6 +804,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
GVL_SmallStation.GetInstance.WindSendDosing = true;
GVL_SmallStation.GetInstance.WindSendDosingStatus = 2;
+ //下发配料数据
WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData111, 95);
}
}
@@ -807,30 +817,39 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
+ //如果小料仓配方下发状态为0(未下发),则下发配方。并清除该工位配方的配料情况信号。
if (GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 0)
{
GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum] = 0;
+ //下发工单,并置位工单下发确认。
HKDevice.IssueRecipeToPlc(RemoteRecipes.ElementAt(index).RawMaterial, recipeNum);
HKDevice.HK_PLC_S7.Write("DB4.DBX2." + recipeNum, true);
+ //下发完成,等待开始制作。
GVL_SmallStation.GetInstance.DosingTime[recipeNum] = DateTime.Now;
GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] = 1;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方编号{code},配方号{recipeNum + 1},下发完成");
}
+ //确认是否收到工单
bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read("DB3.DBX4." + recipeNum);
if (recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 1)
{
+ //确认PLC收到工单后,复位下发确认信号。
HKDevice.HK_PLC_S7.Write("DB4.DBX2." + recipeNum, false);
GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] = 2;
GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum] = 0;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方编号{code},配方号{recipeNum + 1},配方接收完成");
}
+ //粉料仓完毕,开始控制小料仓味魔方配料。
if (GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 2)
{
+ //味魔方配料。
for (byte i = 1; i < 16; i++)
{
+ //indexArr是各配方位置反馈。
int indexArr = -1;
if (GVL_SmallStation.GetInstance.plcReadDataDB3.StockBinAllowIssue[i - 1])
{
+ //根据配方号查找各配方的三个桶的位置反馈。位置反馈用的是ushort转16位2进制表示。
switch (recipeNum)
{
case 0:
@@ -849,10 +868,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
indexArr = Array.FindIndex(GVL_SmallStation.GetInstance.plcReadDataDB3.Recipe5BarrelPosReserve.ToArray(), p => p == i);
break;
}
+ //如果料桶已经到位但没有配料完成信号。
if (indexArr >= 0 && GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum].GetBitValue((byte)i) == false)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
+ //如果重量为0,即不需要配料。则直接设为配料完成。
if (weight <= 0)
{
if (i >= 1 && i <= 8)
@@ -870,6 +891,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
else
{
+ //下发小料仓味魔方配料指令。
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)i)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
@@ -886,6 +908,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
//MessageNotify.GetInstance.ShowRunLog($"错误,有允许配料信号,但没有相应的位置 和桶号");
}
+ //味魔方配料完成后处理。
if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && indexArr >= 0 && GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum].GetBitValue((byte)i))
{
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
@@ -895,10 +918,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
else
{
+ //配料完成后,先延时一段时间再复位。
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.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
if (iIndex >= 0)
@@ -913,6 +941,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
});
}
}
+ //置位味魔方配料完成信号。
if (i >= 1 && i <= 8)
{
string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX12." + (i - 1), true);
@@ -929,6 +958,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
+
+ //接收到工单配料完成上升沿后。
bool DosingComple = HKDevice.HK_PLC_S7.Read("DB3.DBX6." + recipeNum);
if ((RTrig.GetInstance("配方配料完成").Start(DosingComple)) || (GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum] > 0 && DosingComple))
{
@@ -937,7 +968,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum] > 0)
{
for (int i = 1; i < 17; i++)
- {
+ {//看不懂
if (GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum].GetBitValue((byte)i))
{
MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓");
@@ -950,37 +981,37 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
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;
- }
- RecipeFinishInfo.Ask_For_Finish = true;
- RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
- SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261);
+ //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;
+ // }
+ // RecipeFinishInfo.Ask_For_Finish = true;
+ // RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
+ // SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261);
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
- MessageNotify.GetInstance.ShowRecipeLog(res.RecipeName);
- }
- else
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
+ // MessageNotify.GetInstance.ShowRecipeLog(res.RecipeName);
+ //}
+ //else
{
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
MessageNotify.GetInstance.ShowRecipeLog(res.RecipeName);
@@ -1285,8 +1316,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
ObservableCollection RawMaterials = new ObservableCollection();
ObservableCollection WindSendData = new ObservableCollection();
- if (SiemensDevice.IsConnected)
- {
+ //if (SiemensDevice.IsConnected)
+ //{
if (res != null && res is XL_Start_DB recipe)
{
if (!string.IsNullOrEmpty(recipe.RecipeCode))
@@ -1344,7 +1375,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
});
}
}
- }
+ //}
}), "SiemensRecipeRecive", true);
//将本地配方发送到西门子配方里,执行配料
@@ -1545,8 +1576,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (Json.Data.deviceConnectPar.SiemensConnect)
{
- SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
- if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功");
+ //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
+ //if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功");
}
}
catch (Exception ex)
@@ -1555,7 +1586,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
finally
{
- SiemensDevice.Init();
+ // SiemensDevice.Init();
MessageNotify.GetInstance.ShowRunLog("西门子plc初始化完成");
}
try
@@ -1590,11 +1621,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
try
{
- if (!SiemensDevice.IsConnected && Json.Data.deviceConnectPar.SiemensConnect)
- {
- SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
- if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子PLC重新连接成功");
- }
+ //if (!SiemensDevice.IsConnected && Json.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)
{
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/LocalRecipeDataColl.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/LocalRecipeDataColl.cs
index 1405375d..3b7dcdc9 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/LocalRecipeDataColl.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/LocalRecipeDataColl.cs
@@ -9,6 +9,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
internal class LocalRecipeDataColl
{
+ ///
+ /// 本地自定义配方集合。
+ ///
public ObservableCollection Recipes { get; set; } = new ObservableCollection();
///
/// 筛选后的配方显示集合。
diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs
index 3dfc6c82..906479f1 100644
--- a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs
+++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs
@@ -301,7 +301,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
MessageNotify.GetInstance.ShowUserLog($"设置柔性味魔方复位时间:{time}s");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{time.ToString()}:设置成功!");
});
- SiemensIsConnect = ProcessControl.GetInstance.SiemensDevice.IsConnected;
+ //SiemensIsConnect = ProcessControl.GetInstance.SiemensDevice.IsConnected;
HKPlcIsConnect = ProcessControl.GetInstance.HKDevice.IsConnected;
WindSendIsConnect = ProcessControl.GetInstance.WindSendDevice.IsConnected;
}
diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs
index f2d77d2d..2c5dfee1 100644
--- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs
+++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs
@@ -45,9 +45,15 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
if (MessageNotify.GetInstance.ShowDialog($"请确认,是否删除订单【{cnt}】?"))
{
var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == cnt);
+ var res1= Json.Data.SelectedRecipes.FirstOrDefault(p => p.RecipeCode == cnt);
+ if (res1 is not null)
+ {
+ Json.Data.SelectedRecipes.Remove(res1);
+ }
if (res != null)
{
Json.Data.Recipes.Remove(res);
+ Json.Save();
MessageNotify.GetInstance.ShowUserLog($"删除配方——{res.RecipeName}");
}
}
diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs
index ab620067..c1874885 100644
--- a/BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs
+++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs
@@ -18,6 +18,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
public SelectRecipesViewModel()
{
AllRecipes = new();
+ SelectRecipes.Clear();
foreach (var item in Json.Data.SelectedRecipes)
{
SelectRecipes.Add(item);