From 650e6fb409828976f6d43a5955264ed52b0cec2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Thu, 10 Nov 2022 15:16:15 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=91=B3=E9=AD=94=E6=96=B9=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Converters/RecipeStatusConvert.cs | 31 +++++++++++++++++++ .../柔性味魔方/RawMaterialModel.cs | 2 +- .../BPASmartClient.MorkS.csproj | 1 + BPASmartClient.MorkS/DataServer.cs | 1 + DosingSystem/App.xaml | 1 + DosingSystem/App.xaml.cs | 6 +++- DosingSystem/Model/DeviceInquire.cs | 4 +-- DosingSystem/Model/RecipeModel.cs | 5 +++ .../View/ChangeDeviceNameView.xaml.cs | 8 ++--- DosingSystem/View/RecipeControlView.xaml | 4 +-- .../ViewModel/ChangeDeviceNameViewModel.cs | 9 ------ .../ViewModel/RecipeControlViewModel.cs | 15 ++++----- 12 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 BPASmartClient.CustomResource/Converters/RecipeStatusConvert.cs diff --git a/BPASmartClient.CustomResource/Converters/RecipeStatusConvert.cs b/BPASmartClient.CustomResource/Converters/RecipeStatusConvert.cs new file mode 100644 index 00000000..b42f5579 --- /dev/null +++ b/BPASmartClient.CustomResource/Converters/RecipeStatusConvert.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace BPASmartClient.CustomResource.Converters +{ + public class RecipeStatusConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + if (value.ToString() == "等待制作") + return Brushes.Yellow; + else if (value.ToString() == "制作完成") + return Brushes.Green; + } + return default; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs index a8e571fb..76d6eb0e 100644 --- a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs +++ b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs @@ -114,7 +114,7 @@ namespace BPASmartClient.Model set { _mRecipeStatus = value; - if (value == 1) Status = Status.等待配料; + if (value == 1 && Status != Status.配料完成) Status = Status.等待配料; else if (value == 2) Status = Status.正在配料; else if (value == 3) Status = Status.配料完成; OnPropertyChanged(); diff --git a/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj b/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj index 6ea9cbb7..f94d003f 100644 --- a/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj +++ b/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj @@ -9,6 +9,7 @@ + diff --git a/BPASmartClient.MorkS/DataServer.cs b/BPASmartClient.MorkS/DataServer.cs index 6d49c57d..8d6019e3 100644 --- a/BPASmartClient.MorkS/DataServer.cs +++ b/BPASmartClient.MorkS/DataServer.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Threading.Tasks; using BPA.Helper; using BPASmartClient.MQTT; +using BPA.Message; namespace BPASmartClient.MorkS { diff --git a/DosingSystem/App.xaml b/DosingSystem/App.xaml index a10b130a..f6eabe3e 100644 --- a/DosingSystem/App.xaml +++ b/DosingSystem/App.xaml @@ -28,6 +28,7 @@ + diff --git a/DosingSystem/App.xaml.cs b/DosingSystem/App.xaml.cs index b2e2bb6e..3b9a58cf 100644 --- a/DosingSystem/App.xaml.cs +++ b/DosingSystem/App.xaml.cs @@ -28,8 +28,12 @@ namespace BPASmartClient.DosingSystem BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut(); MenuInit(); DataInit(); - DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 + ThreadManage.GetInstance().Start(new Action(() => + { + DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 + }), "设备初始化"); MainView mv = new MainView(); + mv.TitleName = "味魔方管理系统软件[简称:味魔方] 1.0.1"; LoginView lv = new LoginView(); var res = lv.ShowDialog(); if (res != null && res == true) diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index e07a2d81..8d1787b0 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -307,7 +307,7 @@ namespace BPASmartClient.DosingSystem modbusTcp.ShowEx = new Action((s) => { MessageNotify.GetInstance.ShowRunLog(s); }); this.DeviceName = DeviceName; AlarmHelper.Init(); - + if (modbusTcp.Connected) { ThreadManage.GetInstance().StartLong(new Action(() => @@ -364,7 +364,7 @@ namespace BPASmartClient.DosingSystem modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed); modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight); modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo); - modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed * 100); + modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed); MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},参数下发完成"); } } diff --git a/DosingSystem/Model/RecipeModel.cs b/DosingSystem/Model/RecipeModel.cs index cbdb4c7b..d3ac46ea 100644 --- a/DosingSystem/Model/RecipeModel.cs +++ b/DosingSystem/Model/RecipeModel.cs @@ -40,6 +40,11 @@ namespace BPASmartClient.DosingSystem [Newtonsoft.Json.JsonIgnore] public AutoResetEvent Are { get; set; } = new AutoResetEvent(false); + [Newtonsoft.Json.JsonIgnore] + public string RecipStatus { get { return _mRecipStatus; } set { _mRecipStatus = value; OnPropertyChanged(); } } + private string _mRecipStatus; + + /// /// 原料集合 /// diff --git a/DosingSystem/View/ChangeDeviceNameView.xaml.cs b/DosingSystem/View/ChangeDeviceNameView.xaml.cs index d8ecd4ac..4b349bd3 100644 --- a/DosingSystem/View/ChangeDeviceNameView.xaml.cs +++ b/DosingSystem/View/ChangeDeviceNameView.xaml.cs @@ -1,5 +1,4 @@ -using BPASmartClient.Helper; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -12,6 +11,7 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; +using BPA.Helper; namespace BPASmartClient.DosingSystem.View { @@ -23,8 +23,8 @@ namespace BPASmartClient.DosingSystem.View public ChangeDeviceNameView() { InitializeComponent(); - ActionManage.GetInstance.CancelRegister("ChangeDeviceNameViewClose"); - ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "ChangeDeviceNameViewClose"); + //ActionManage.GetInstance.CancelRegister("ChangeDeviceNameViewClose"); + ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "ChangeDeviceNameViewClose", true); this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; } } diff --git a/DosingSystem/View/RecipeControlView.xaml b/DosingSystem/View/RecipeControlView.xaml index a05ea430..752864c0 100644 --- a/DosingSystem/View/RecipeControlView.xaml +++ b/DosingSystem/View/RecipeControlView.xaml @@ -880,8 +880,8 @@ HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" - Foreground="Yellow" - Text="等待执行" /> + Foreground="{Binding RecipStatus,Converter={StaticResource RecipeStatusConvert}}" + Text="{Binding RecipStatus}" /> p.RecipeName == deviceName); - UserTreeWait.Add(new RecipeModel { SerialNum = UserTreeWait.Count + 1, RecipeName = deviceName, RawMaterials = res.RawMaterials }); + UserTreeWait.Add(new RecipeModel { RecipStatus = "等待制作", SerialNum = UserTreeWait.Count + 1, RecipeName = deviceName, RawMaterials = res.RawMaterials }); } NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); MessageNotify.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}"); @@ -107,7 +107,7 @@ namespace BPASmartClient.DosingSystem.ViewModel if (tempDevice != null) { /*data = data.SetBitValue((byte)tempDevice.DeviceNum, true);*/ - if (tempDevice.DeviceNum > 0) + if (tempDevice.DeviceNum > 0) { int a = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true); byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD); @@ -116,9 +116,9 @@ namespace BPASmartClient.DosingSystem.ViewModel MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{item.ToBinString()}"); } } - if (tInfo.ElementAt(i).ElementAt(m).Loc >0) + if (tInfo.ElementAt(i).ElementAt(m).Loc > 0) { - if (!BarrelNum.Contains(tInfo.ElementAt(i).ElementAt(m).Loc)) + if (!BarrelNum.Contains(tInfo.ElementAt(i).ElementAt(m).Loc)) { BarrelNum.Add(tInfo.ElementAt(i).ElementAt(m).Loc); } @@ -232,6 +232,7 @@ namespace BPASmartClient.DosingSystem.ViewModel RecipeName = recipeComple.RecipeName, SerialNum = UserTreeCompelete.Count + 1, RecipCode = recipeComple.RecipCode, + RecipStatus = "制作完成" }); }); App.Current.Dispatcher.Invoke(new Action(() => @@ -283,14 +284,14 @@ namespace BPASmartClient.DosingSystem.ViewModel MessageNotify.GetInstance.ShowRunLog("错误"); return; } - else + else { switch (cnt) { case 1: int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 1); int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 2); - if (a1 >= 0) + if (a1 >= 0) { Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel); } @@ -461,7 +462,7 @@ namespace BPASmartClient.DosingSystem.ViewModel } } } - else + else { if (Location2 >= 0) { From 06a4efb0d9e867bd2b6058d64869be547c0792da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Fri, 11 Nov 2022 11:09:16 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=A5=BF=E9=97=A8=E5=AD=90=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.MorkS/Control_Morks.cs | 13 +++++++------ BPASmartClient.MorkS/DataServer.cs | 8 ++++++-- BPASmartClient.S7Net/EntityClassResolution.cs | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/BPASmartClient.MorkS/Control_Morks.cs b/BPASmartClient.MorkS/Control_Morks.cs index e7bd1ec2..80cf1f37 100644 --- a/BPASmartClient.MorkS/Control_Morks.cs +++ b/BPASmartClient.MorkS/Control_Morks.cs @@ -34,13 +34,11 @@ namespace BPASmartClient.MorkS public override void DoMain() { - - MonitorViewModel.DeviceId = DeviceId; ServerInit(); DataParse(); - Json.Read(); + Json.Read(); if (Json.Data.parSets == null) Json.Data.parSets = new ObservableCollection(); if (Json.Data.parSets.Count < 6) { @@ -273,8 +271,11 @@ namespace BPASmartClient.MorkS if (order.MorkOrder.GoodBatchings == null) return; if (mORKS.HistorySuborderId.Contains(order.MorkOrder.SuborderId)) return; OrderCount++; - Json.Data.StatisticsTime=DateTime.Now; + if (DateTime.Now.Subtract(Json.Data.StatisticsTime).Days != 0) + Json.Data.Count = 0; + Json.Data.StatisticsTime = DateTime.Now; Json.Data.Count++; + Json.Save(); OrderChange(order.MorkOrder.SuborderId, ORDER_STATUS.WAIT); DeviceProcessLogShow($"接收到{OrderCount}次订单,订单ID:{order.MorkOrder.SuborderId}"); mORKS.HistorySuborderId.Add(order.MorkOrder.SuborderId); @@ -600,7 +601,7 @@ namespace BPASmartClient.MorkS } //取餐完成逻辑处理 - if (Delay.GetInstance("CompleteChange1").Start( !mORKS.TakeMealDetect, 1)&&mORKS.CookCompleteFlatBit == true) + if (Delay.GetInstance("CompleteChange1").Start(!mORKS.TakeMealDetect, 1) && mORKS.CookCompleteFlatBit == true) { OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE); DeviceProcessLogShow($"订单【{mORKS.OutMealId}】取餐完成"); @@ -814,7 +815,7 @@ namespace BPASmartClient.MorkS mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)msm.Bowloc, SuborderId = guid }); MessageLog.GetInstance.Show($"添加订单:碗位置【{(ushort)msm.Bowloc}】"); } - + } }); } diff --git a/BPASmartClient.MorkS/DataServer.cs b/BPASmartClient.MorkS/DataServer.cs index 8d6019e3..ff948122 100644 --- a/BPASmartClient.MorkS/DataServer.cs +++ b/BPASmartClient.MorkS/DataServer.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using BPA.Helper; using BPASmartClient.MQTT; using BPA.Message; +using BPASmartClient.Model; namespace BPASmartClient.MorkS { @@ -17,15 +18,18 @@ namespace BPASmartClient.MorkS public static DataServer GetInstance => _Instance ?? (_Instance = new DataServer()); private DataServer() { } + public ScreenModelMorkS morkS { get; set; } = new ScreenModelMorkS(); + public void Init() { MQTTProxy mQTTProxy = new MQTTProxy(); mQTTProxy.Connected = new Action(() => { - mQTTProxy.Subscrib(""); + mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); ThreadManage.GetInstance().StartLong(new Action(() => { - mQTTProxy.Publish("", ""); + morkS.MorkS_OrderCount = Json.Data.Count; + mQTTProxy.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机), morkS.ToJSON()); Thread.Sleep(100); }), "海科食堂大屏监听"); }); diff --git a/BPASmartClient.S7Net/EntityClassResolution.cs b/BPASmartClient.S7Net/EntityClassResolution.cs index 75dcc8cd..81b10374 100644 --- a/BPASmartClient.S7Net/EntityClassResolution.cs +++ b/BPASmartClient.S7Net/EntityClassResolution.cs @@ -57,6 +57,7 @@ namespace BPASmartClient.S7Net default: numBytes = GetClassSize(Activator.CreateInstance(type), numBytes, isInnerProperty: true); if (type.IsClass) IncrementToEven(ref numBytes); + else if (!type.IsPrimitive && !type.IsEnum && type.IsValueType) IncrementToEven(ref numBytes); break; } From b7e7b8618a43c3b5567449412abe93a2562a4ed7 Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Fri, 11 Nov 2022 11:15:37 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=90=89=E9=A6=99=E5=B1=85=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Model/GVL_BigStation.cs | 3 +- .../Model/ProcessControl.cs | 164 +++++++++++-- .../Model/Siemens/DL_Status_DB.cs | 21 +- .../Model/Siemens/SiemensDeviceStatus.cs | 39 ++- .../App.xaml.cs | 2 + .../Model/GVL_SmallStation.cs | 8 +- .../Model/ProcessControl.cs | 222 ++++++++++++++---- .../Model/Siemens/SiemensDeviceStatus.cs | 74 ++++-- .../Model/Siemens/XL_Finish_DB.cs | 6 +- .../Model/Siemens/XL_Start_DB.cs | 4 +- .../Model/Siemens/XL_Status_DB.cs | 2 +- BPASmartClient.S7Net/EntityClassResolution.cs | 2 - BPASmartClient.S7Net/SiemensHelper.cs | 8 + 13 files changed, 442 insertions(+), 113 deletions(-) diff --git a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs index 902b256c..51deb3bd 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs @@ -39,7 +39,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// 订单请求 /// public static bool Order_Request { get; set; } = false; + public static int SiemensSendRecipeStatus { get; set; } = 0; - public const int StockBinNum = 12; + public const int Max_DosingSotckBinNum = 14; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index d312f5e9..b80059a4 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -49,12 +49,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model ActionManage.GetInstance.Register(new Action((res) => { ObservableCollection RawMaterials = new ObservableCollection(); - if (SiemensDevice.IsConnected ||true) + if (SiemensDevice.IsConnected) { if (res != null && res is DL_Start_DB recipe) { RawMaterials.Clear(); - for (int i = 0; i < 12; i++) + for (int i = 0; i < GVL_BigStation.Max_DosingSotckBinNum; i++) { if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name)) { @@ -71,12 +71,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model //报警,配方的原料名称下发和设备不一致 } } - Json.Data.Recipes.Add(new RecipeData() + App.Current.Dispatcher.Invoke(() => { - RecipeName = recipe.RecipeName, - RecipeCode = recipe.RecipeCode, - RawMaterial = RawMaterials, - //TrayCode = recipe.Order_No, + Json.Data.Recipes.Add(new RecipeData() + { + RecipeName = recipe.RecipeName, + RecipeCode = recipe.RecipeCode, + RawMaterial = RawMaterials, + TrayCode = recipe.Job_No, + }); }); } } @@ -86,7 +89,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model try { //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); - //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); + SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); if (HKDevice.IsConnected) { HKDevice.Init(); @@ -132,25 +135,134 @@ namespace BPASmartClient.JXJFoodBigStation.Model { foreach (var data in Recipes) { - if (RecipeQueue1.Count == 0 && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) + if (RecipeQueue1.Count == 0 && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) { if (!(RecipeQueue1.Contains(data.RecipeCode))) - RecipeQueue1.Enqueue(data.RecipeCode); + { + if (SiemensDevice.DL_Status is DL_Status_DB status) + { + if (GVL_BigStation.SiemensSendRecipeStatus == 3) + { + GVL_BigStation.SiemensSendRecipeStatus = 4; + SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + } + if (GVL_BigStation.SiemensSendRecipeStatus == 4) + { + if (SiemensDevice.DL_Status.Dosing_Start_ACK) + { + GVL_BigStation.SiemensSendRecipeStatus = 5; + SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); + } + } + if (GVL_BigStation.SiemensSendRecipeStatus == 5) + { + if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + { + GVL_BigStation.SiemensSendRecipeStatus = 6; + RecipeQueue1.Enqueue(data.RecipeCode); + } + } + } + + } } - else if (RecipeQueue2.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) + else if (RecipeQueue2.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) { if (!(RecipeQueue2.Contains(data.RecipeCode))) - RecipeQueue2.Enqueue(data.RecipeCode); + { + if (SiemensDevice.DL_Status is DL_Status_DB status) + { + if (GVL_BigStation.SiemensSendRecipeStatus == 3) + { + GVL_BigStation.SiemensSendRecipeStatus = 4; + SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + } + if (GVL_BigStation.SiemensSendRecipeStatus == 4) + { + if (SiemensDevice.DL_Status.Dosing_Start_ACK) + { + GVL_BigStation.SiemensSendRecipeStatus = 5; + SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); + SiemensDevice.Siemens_PLC_S7.Write("DB3231.DBX28.0", false); + } + } + if (GVL_BigStation.SiemensSendRecipeStatus == 5) + { + if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + { + GVL_BigStation.SiemensSendRecipeStatus = 6; + RecipeQueue2.Enqueue(data.RecipeCode); + } + } + } + } } else if (RecipeQueue3.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) { - if (!(RecipeQueue3.Contains(data.RecipeCode))) - RecipeQueue3.Enqueue(data.RecipeCode); + if (!(RecipeQueue3.Contains(data.RecipeCode))) + { + if (SiemensDevice.DL_Status is DL_Status_DB status) + { + if (GVL_BigStation.SiemensSendRecipeStatus == 3) + { + GVL_BigStation.SiemensSendRecipeStatus = 4; + SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + } + if (GVL_BigStation.SiemensSendRecipeStatus == 4) + { + if (SiemensDevice.DL_Status.Dosing_Start_ACK) + { + GVL_BigStation.SiemensSendRecipeStatus = 5; + SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); + SiemensDevice.Siemens_PLC_S7.Write("DB3231.DBX28.0", false); + } + } + if (GVL_BigStation.SiemensSendRecipeStatus == 5) + { + if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + { + GVL_BigStation.SiemensSendRecipeStatus = 6; + RecipeQueue3.Enqueue(data.RecipeCode); + } + } + } + } } else if (RecipeQueue4.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode)) { - if (!(RecipeQueue4.Contains(data.RecipeCode))) - RecipeQueue4.Enqueue(data.RecipeCode); + if (!(RecipeQueue4.Contains(data.RecipeCode))) + { + if (SiemensDevice.DL_Status is DL_Status_DB status) + { + if (GVL_BigStation.SiemensSendRecipeStatus == 3) + { + GVL_BigStation.SiemensSendRecipeStatus = 4; + SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + } + if (GVL_BigStation.SiemensSendRecipeStatus == 4) + { + if (SiemensDevice.DL_Status.Dosing_Start_ACK) + { + GVL_BigStation.SiemensSendRecipeStatus = 5; + SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); + SiemensDevice.Siemens_PLC_S7.Write("DB3231.DBX28.0", false); + } + } + if (GVL_BigStation.SiemensSendRecipeStatus == 5) + { + if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + { + GVL_BigStation.SiemensSendRecipeStatus = 6; + RecipeQueue4.Enqueue(data.RecipeCode); + } + } + } + } } } } @@ -266,6 +378,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (SiemensDevice.IsConnected) { + FinishData.Ask_For_Finish = true; + GVL_BigStation.SiemensSendRecipeStatus = 7; SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); } RecipeQueue1.TryDequeue(out code); @@ -705,6 +819,22 @@ namespace BPASmartClient.JXJFoodBigStation.Model RawMaterialsNamePos.Clear(); if (!HKDevice.IsConnected) { + RawMaterialsNamePos.Add("A10", 1); + RawMaterialsNamePos.Add("A20", 2); + RawMaterialsNamePos.Add("A30", 3); + RawMaterialsNamePos.Add("A40", 4); + RawMaterialsNamePos.Add("A50", 5); + RawMaterialsNamePos.Add("A60", 6); + RawMaterialsNamePos.Add("A70", 7); + RawMaterialsNamePos.Add("A80", 8); + RawMaterialsNamePos.Add("A90", 9); + RawMaterialsNamePos.Add("A100", 10); + RawMaterialsNamePos.Add("A110", 11); + RawMaterialsNamePos.Add("A120", 12); + RawMaterialsNamePos.Add("A130", 13); + RawMaterialsNamePos.Add("A140", 14); + } +/* HKDevice.StockBinName.RawMaterialName1 = "1"; HKDevice.StockBinName.RawMaterialName2 = "2"; HKDevice.StockBinName.RawMaterialName3 = "3"; @@ -775,7 +905,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName14)) { RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName14, 14); - } + }*/ } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs index 56c74a2f..90077656 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs @@ -7,12 +7,12 @@ using System.Threading.Tasks; namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { - internal class DL_Status_DB + public class DL_Status_DB { /// - /// 配料开始 + /// 配料开始确认 /// - public bool Dosing_Start { get; set; } + public bool Dosing_Start_ACK { get; set; } /// /// 配料开始确认 /// @@ -29,18 +29,21 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens /// 生产工单 /// public string RecipeCode { get; set; } - public bool Dosing_Cancel4 { get; set; } + /// + /// 配料开始 + /// + public bool Dosing_Start { get; set; } - public bool Dosing_Cancel5 { get; set; } + public bool Allow_Agv_Put { get; set; } - public bool Dosing_Cancel6 { get; set; } + public bool Allow_Agv_Get { get; set; } - public bool Dosing_Cancel7 { get; set; } + public bool Allow_Agv_Get_Empty { get; set; } - public short Dosing_Cancel8 { get; set; } + public short Pallet_Position_Occ { get; set; } public short Dosing_Cancel9 { get; set; } - public short[] Standby2 { get; set; } = new short[4]; + public short[] Standby2 { get; set; } = new short[3]; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs index d02a7bab..4631b4dd 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs @@ -15,6 +15,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens public SiemensHelper Siemens_PLC_S7 = new SiemensHelper(); public bool IsConnected => Siemens_PLC_S7.IsConnected; + public DL_Status_DB DL_Status = new DL_Status_DB(); bool a = false; public void Init() { @@ -34,7 +35,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens start.RecipeCode = "1201"; start.Order_Request_Ack = true; - for (int i = 0; i < GVL_BigStation.StockBinNum ; i++) + for (int i = 0; i < GVL_BigStation.Max_DosingSotckBinNum ; i++) { start.Material[i] = new UDT(); start.Material[i].Material_Name = "" + (i +1); @@ -42,25 +43,43 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens start.Material[i].Material_BarrelNum = (short)(i + 1); } } - if (RTrig.GetInstance("Order_Request").Start(GVL_BigStation.Order_Request)) + if (RTrig.GetInstance("Order_Request").Start(GVL_BigStation.Order_Request) && GVL_BigStation.SiemensSendRecipeStatus == 0) { - start.Order_Request = true; - Siemens_PLC_S7.WriteClass(start, 2301); + GVL_BigStation.SiemensSendRecipeStatus = 1; + this.Siemens_PLC_S7.Write("DB2301.DBX330.0", true); } - if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack)) + if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 1) { + GVL_BigStation.SiemensSendRecipeStatus = 2; ActionManage.GetInstance.Send("SiemensSendRecipe", start); + this.Siemens_PLC_S7.Write("DB2301.DBX330.0", false); + } + if (TTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 2) + { + GVL_BigStation.SiemensSendRecipeStatus = 3; + GVL_BigStation.Order_Request = false; } } if (res1 != null && res1 is DL_Status_DB status) { - + DL_Status = status; } - if (res2 != null && res2.Ask_For_Finish_PLC) + if (res2 != null && res2 is DL_Finish_DB finish) { - ActionManage.GetInstance.Send("配料完成信号确认完成"); - res2.Ask_For_Finish_PLC = false; - this.Siemens_PLC_S7.WriteClass(res2, 3); + if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC) && GVL_BigStation.SiemensSendRecipeStatus == 7) + { + finish.Order_No = ""; + finish.Product_Code = ""; + finish.job_No = 0; + for (int i = 0; i < 20; i++) + { + finish.Material[i] = new UDT1(); + } + GVL_BigStation.SiemensSendRecipeStatus = 0; + finish.Ask_For_Finish = false; + finish.ProcessTime = 0; + this.Siemens_PLC_S7.WriteClass(finish, 2261); + } } Thread.Sleep(10); }), "监听服务数据"); diff --git a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs index d118ec64..e5787289 100644 --- a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs @@ -48,6 +48,7 @@ namespace BPASmartClient.JXJFoodSmallStation base.OnExit(e); Json.Save(); Json.Save(); + Json.Save(); MessageNotify.GetInstance.LogSave(); ThreadManage.GetInstance().Dispose(); } @@ -268,6 +269,7 @@ namespace BPASmartClient.JXJFoodSmallStation Json.Read(); Json.Read(); Json.Read(); + Json.Read(); } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs index 5f6cf940..4bfa8690 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs @@ -23,14 +23,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// /// 风送料仓数目 /// - public const int Max_PowderSotckBinNum = 15; + public const int Max_PowderSotckBinNum = 5; public bool HeartBeatToPlc { get; set; } = false; public bool HeartBeatFromPlc { get; set; } = false; /// /// 是否允许西门子下发配方 /// public static bool IsAllowSiemensSendRecipe { get; set; } = false; - + /// + /// 西门子下发配方状态 0:等待下发配方 1:请求下发配方 2:上位机接收配方 3:配方接收完成 4:请求配料 5:西门子开始配料确认 6:配方配料完成 7:配料完成确认 + /// + public static int SiemensSendRecipeStatus { get; set; } = 0; /// /// 往输送带下发配方完成 /// @@ -114,6 +117,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// 是否使用本地模拟订单+风送配方 /// public bool IsUseWindSendDosing { get; set; } + public static int test1 = 1; #endregion } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index 26e477ec..25aee4c5 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -50,6 +50,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public RecipeRawMaterial RawMaterial; public void Init() { + testData(); for (int i = 0; i < 16; i++) { if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null) @@ -69,57 +70,91 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (res != null && res is XL_Start_DB recipe) { - RawMaterials.Clear(); - for (int i = 0; i < GVL_SmallStation.Max_DosingSotckBinNum; i++) - { - if (!string.IsNullOrEmpty(recipe.Material[i].Material_Name)) + if (!string.IsNullOrEmpty(recipe.RecipeCode)) { + RawMaterials.Clear(); + for (int i = 0; i < GVL_SmallStation.Max_DosingSotckBinNum; i++) { - if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name)) + if (!string.IsNullOrEmpty(recipe.Material[i].Material_Name)) { - RawMaterials.Add(new RemoteRecipeRawMaterial() + if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name)) { - 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] - }); + 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.AlarmLog("配方名称与本地不符合"); + } } else { - //MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合"); + break; } } - else + for (int i = 0; i < GVL_SmallStation.Max_PowderSotckBinNum; i++) { - break; + 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; + } } - } - for (int i = 0; i < GVL_SmallStation.Max_PowderSotckBinNum; i++) - { - if (!string.IsNullOrEmpty(recipe.Powder[i].Powder_Name)) - { - WindSendData.Add(new WindSendRawMaterial() + App.Current.Dispatcher.Invoke(() => { + Json.Data.Recipes.Add(new RemoteRecipeData() { - RawMaterialName = recipe.Powder[i].Powder_Name, - RawMaterialWeight = recipe.Powder[i].Powder_Weight + RecipeName = recipe.RecipeName, + RecipeCode = recipe.RecipeCode, + RawMaterial = RawMaterials, + TrayCode = recipe.StockCode, + WindSend = WindSendData }); - } - else - { - break; - } + }); } - Json.Data.Recipes.Add(new RemoteRecipeData() - { - RecipeName = recipe.RecipeName, - RecipeCode = recipe.RecipeCode, - RawMaterial = RawMaterials, - TrayCode = recipe.TrayCode, - WindSend = WindSendData - }); } } }), "SiemensRecipeRecive", true); + ActionManage.GetInstance.CancelRegister("SiemensRecipeFinish"); + ActionManage.GetInstance.Register(new Action((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(); + } + if (GVL_SmallStation.SiemensSendRecipeStatus == 6) + { + GVL_SmallStation.SiemensSendRecipeStatus = 7; + RecipeFinishInfo.Ask_For_Finish = true; + SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); + } + } + } + }), "SiemensRecipeFinish", true); ActionManage.GetInstance.CancelRegister("WindSendDosingFinish"); ActionManage.GetInstance.Register(new Action(() => { @@ -644,7 +679,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model 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("DB3.DBX0.0"); - } } /// @@ -661,14 +695,66 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (!(RecipeQueue.Contains(data.RecipeCode))) { - RecipeQueue.Enqueue(data.RecipeCode); + if (SiemensDevice.XL_Status is XL_Status_DB status) + { + if (GVL_SmallStation.SiemensSendRecipeStatus == 3) + { + GVL_SmallStation.SiemensSendRecipeStatus = 4; + SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode,10); + SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0",true); + } + if (GVL_SmallStation.SiemensSendRecipeStatus == 4) + { + if (SiemensDevice.XL_Status.Dosing_Confirm) + { + GVL_SmallStation.SiemensSendRecipeStatus = 5; + SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); + } + } + if (GVL_SmallStation.SiemensSendRecipeStatus == 5) + { + if (SiemensDevice.XL_Status.Dosing_Confirm == false) + { + GVL_SmallStation.SiemensSendRecipeStatus = 6; + RecipeQueue.Enqueue(data.RecipeCode); + } + + } + + } } } - else if(data.TrayCode == 2) + else if (data.TrayCode == 2) { if (!(RecipeQueueTray2.Contains(data.RecipeCode))) { - RecipeQueueTray2.Enqueue(data.RecipeCode); + if (SiemensDevice.XL_Status is XL_Status_DB status) + { + if (GVL_SmallStation.SiemensSendRecipeStatus == 3) + { + GVL_SmallStation.SiemensSendRecipeStatus = 4; + SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true); + } + if (GVL_SmallStation.SiemensSendRecipeStatus == 4) + { + if (SiemensDevice.XL_Status.Dosing_Confirm) + { + GVL_SmallStation.SiemensSendRecipeStatus = 5; + SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); + } + } + if (GVL_SmallStation.SiemensSendRecipeStatus == 5) + { + if (SiemensDevice.XL_Status.Dosing_Confirm == false) + { + GVL_SmallStation.SiemensSendRecipeStatus = 0; + RecipeQueueTray2.Enqueue(data.RecipeCode); + } + } + } } } } @@ -851,23 +937,39 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } - if (RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX1.1")) && (GVL_SmallStation.GetInstance.WindSendDosingFinish || !GVL_SmallStation.GetInstance.IsUseWindSend)) + if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX1.1")) && (GVL_SmallStation.GetInstance.WindSendDosingFinish || !GVL_SmallStation.GetInstance.IsUseWindSend)) || GVL_SmallStation.GetInstance.RecipeStatusID == 5) { var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{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(RecipeFinishInfo, 2261); + 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; + } + for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++) + { + + } + if (GVL_SmallStation.SiemensSendRecipeStatus == 6) + { + GVL_SmallStation.SiemensSendRecipeStatus = 7; + RecipeFinishInfo.Ask_For_Finish = true; + SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); + } } App.Current.Dispatcher.Invoke(() => { @@ -1079,5 +1181,23 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } + private void testData() + { + RawMaterialsNamePos.Add("A10", 1); + RawMaterialsNamePos.Add("A20", 2); + RawMaterialsNamePos.Add("A30", 3); + RawMaterialsNamePos.Add("A40", 4); + RawMaterialsNamePos.Add("A50", 5); + RawMaterialsNamePos.Add("A60", 6); + RawMaterialsNamePos.Add("A70", 7); + RawMaterialsNamePos.Add("A80", 8); + RawMaterialsNamePos.Add("A90", 9); + RawMaterialsNamePos.Add("A100", 10); + RawMaterialsNamePos.Add("A110", 11); + RawMaterialsNamePos.Add("A120", 12); + RawMaterialsNamePos.Add("A130", 13); + RawMaterialsNamePos.Add("A140", 14); + RawMaterialsNamePos.Add("A150", 15); + } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs index e17aeaaf..b62daf28 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs @@ -14,34 +14,79 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { public SiemensHelper Siemens_PLC_S7 = new SiemensHelper(); public bool IsConnected => Siemens_PLC_S7.IsConnected; - + public XL_Status_DB XL_Status = new XL_Status_DB(); + bool test; public void Init() { if (IsConnected) { - ThreadManage.GetInstance().StartLong(new Action(() => + ThreadManage.GetInstance().StartLong(new Action(() => { var Start = this.Siemens_PLC_S7.ReadClass(2201); var Status = this.Siemens_PLC_S7.ReadClass(2231); var Finish = this.Siemens_PLC_S7.ReadClass(2261); var DataColl = this.Siemens_PLC_S7.ReadClass(2291); - if (Start != null && Start.Order_Request == false && GVL_SmallStation.IsAllowSiemensSendRecipe) + if (test) { - Start.Order_Request = true; - this.Siemens_PLC_S7.WriteClass(Start, 1); + for (int i = 0; i < XL_Status.Powder.Length; i++) { + + XL_Status.Powder.ElementAt(i).Powder_Name = ""+i; + } + Siemens_PLC_S7.WriteClass(XL_Status, 2231); } - if (Start != null && RTrig.GetInstance("RecipeTrig").Start(Start.Order_Request_ACK)) + if (Start != null && Start is XL_Start_DB st) { - ActionManage.GetInstance.Send("SiemensRecipeRecive", Start); - Start.Order_Request_ACK = false; - this.Siemens_PLC_S7.WriteClass(Start, 1); + if (RTrig.GetInstance("DB2201.DBX450.0").Start(GVL_SmallStation.IsAllowSiemensSendRecipe) && GVL_SmallStation.SiemensSendRecipeStatus == 0) + { + GVL_SmallStation.SiemensSendRecipeStatus = 1; + this.Siemens_PLC_S7.Write("DB2201.DBX450.0", true); + } + if (RTrig.GetInstance("Order_Request_ACK").Start(Start.Order_Request_ACK) && GVL_SmallStation.SiemensSendRecipeStatus == 1) + { + if (!string.IsNullOrEmpty(st.RecipeCode)) + { + GVL_SmallStation.SiemensSendRecipeStatus = 2; + ActionManage.GetInstance.Send("SiemensRecipeRecive", st); + this.Siemens_PLC_S7.Write("DB2201.DBX450.0", false); + } + } + if (TTrig.GetInstance("Order_Request_ACK_").Start(Start.Order_Request_ACK) && GVL_SmallStation.SiemensSendRecipeStatus == 2) + { + GVL_SmallStation.IsAllowSiemensSendRecipe = false; + GVL_SmallStation.SiemensSendRecipeStatus = 3; + //需要等待请求信号复位才能认为接收配方完成 + } } - - if (Status != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(Status.AgvRequestPut)) + if (Finish != null && Finish is XL_Finish_DB FinishData) { - ActionManage.GetInstance.Send("AGV放货架到位",Status); - Status.AgvRequestPut = false; - this.Siemens_PLC_S7.WriteClass(Status, 2); + if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(FinishData.Ask_For_Finish_PLC) && GVL_SmallStation.SiemensSendRecipeStatus == 7) + { + FinishData.Order_No = ""; + FinishData.Product_Code = ""; + FinishData.Job_No = 0; + for (int i = 0; i < 20; i++) + { + FinishData.Material[i] = new UDT1(); + } + for (int i = 0; i < 10; i++) + { + FinishData.Powder[i] = new UDT2(); + } + GVL_SmallStation.SiemensSendRecipeStatus = 0; + FinishData.Ask_For_Finish = false; + FinishData.DosingTime = 0; + this.Siemens_PLC_S7.WriteClass(FinishData, 2261); + } + } + if (Status != null && Status is XL_Status_DB state) + { + XL_Status = state; + if (RTrig.GetInstance("Allow_AGV_Put[0]").Start(Status.AgvRequestPut)) + { + ActionManage.GetInstance.Send("AGV放货架到位", Status); + Status.AgvRequestPut = false; + this.Siemens_PLC_S7.WriteClass(Status, 2); + } } if (Status != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(Status.AgvRequestGet)) { @@ -49,7 +94,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens Status.AgvRequestGet = false; this.Siemens_PLC_S7.WriteClass(Status, 2); } - Thread.Sleep(10); }),"监听服务数据"); } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs index c7ee07a7..66972b25 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { - internal class XL_Finish_DB + public class XL_Finish_DB { /// /// 配料完成信号确认 @@ -52,7 +52,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens /// 原料名称 /// [Siemens(6)] - public string Material_Name { get; set; } + public string Material_Name { get; set; } = ""; /// /// 原料下料重量 /// @@ -68,7 +68,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens /// 粉料仓名称 /// [Siemens(6)] - public string Powder_Name { get; set; } + public string Powder_Name { get; set; } = ""; /// /// 粉料仓重量 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs index db6be882..3746f978 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs @@ -51,7 +51,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens /// /// 原料名称 /// - public string Material_Name { get; set; } + public string Material_Name { get; set; } = ""; /// /// 原料重量 /// @@ -69,7 +69,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens /// 粉料仓名称 /// [Siemens(6)] - public string Powder_Name { get; set; } + public string Powder_Name { get; set; } = ""; /// /// 粉料仓重量 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs index 722a5774..97339485 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs @@ -78,7 +78,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens /// 粉料名称 /// [Siemens(6)] - public string Powder_Name { get; set; } + public string Powder_Name { get; set; } = ""; /// /// 粉料仓剩余重量 /// diff --git a/BPASmartClient.S7Net/EntityClassResolution.cs b/BPASmartClient.S7Net/EntityClassResolution.cs index 01b52922..14f4e622 100644 --- a/BPASmartClient.S7Net/EntityClassResolution.cs +++ b/BPASmartClient.S7Net/EntityClassResolution.cs @@ -379,7 +379,6 @@ namespace BPASmartClient.S7Net { break; } - numBytes = SetBytesFromProperty(array.GetValue(i), bytes, numBytes, accessableProperty); } } @@ -388,7 +387,6 @@ namespace BPASmartClient.S7Net numBytes = SetBytesFromProperty(accessableProperty.GetValue(sourceClass, null), bytes, numBytes, accessableProperty); } } - return numBytes; } diff --git a/BPASmartClient.S7Net/SiemensHelper.cs b/BPASmartClient.S7Net/SiemensHelper.cs index 141fbb5c..2a428caa 100644 --- a/BPASmartClient.S7Net/SiemensHelper.cs +++ b/BPASmartClient.S7Net/SiemensHelper.cs @@ -1,4 +1,5 @@ using S7.Net; +using System.Text; namespace BPASmartClient.S7Net { @@ -89,6 +90,13 @@ namespace BPASmartClient.S7Net } } + public void WriteString(int db,string txt, int startAddress = 0) + { + var temp = Encoding.ASCII.GetBytes(txt); + var bytes = S7.Net.Types.S7String.ToByteArray(txt, temp.Length); + myPlc.WriteBytes(DataType.DataBlock,db, startAddress, bytes); + + } public TResult ReadClass(int db, int startByteAdr = 0) where TResult : class, new() { TResult sourceClass = new TResult(); From 250aaf6a51b85a9c4702b525b066cc0257649171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Fri, 11 Nov 2022 14:13:04 +0800 Subject: [PATCH 4/4] =?UTF-8?q?Morks=20=E6=95=B0=E6=8D=AE=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BPASmartClient.MorkS.csproj | 2 +- BPASmartClient.MorkS/Control_Morks.cs | 53 +++++++++++++++++++ BPASmartClient.MorkS/DataServer.cs | 8 +-- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj b/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj index f94d003f..12a32132 100644 --- a/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj +++ b/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj @@ -9,7 +9,7 @@ - + diff --git a/BPASmartClient.MorkS/Control_Morks.cs b/BPASmartClient.MorkS/Control_Morks.cs index 80cf1f37..868c12b2 100644 --- a/BPASmartClient.MorkS/Control_Morks.cs +++ b/BPASmartClient.MorkS/Control_Morks.cs @@ -136,7 +136,43 @@ namespace BPASmartClient.MorkS goodName = res.MorkOrder.GoodsName; SortNum = res.MorkOrder.SortNum.ToString(); } + EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { SortNum = SortNum, GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); + + var index = DataServer.GetInstance.morkS.MakeOrder.FindIndex(p => p.SortNum == SortNum); + if (index >= 0 && index < DataServer.GetInstance.morkS.MakeOrder.Count) + { + if (oRDER_STATUS == ORDER_STATUS.COMPLETED_COOK) + { + DataServer.GetInstance.morkS.MakeOrder.RemoveAt(index); + DataServer.GetInstance.morkS.MakeOrderOver.Add(new OrderMakeModel() + { + Status = oRDER_STATUS, + GoodName = goodName, + SortNum = SortNum, + StopTime = DateTime.Now.ToString("HH:mm:ss") + }); + } + else if (oRDER_STATUS == ORDER_STATUS.COMPLETED_TAKE) + { + var temp = DataServer.GetInstance.morkS.MakeOrderOver.FirstOrDefault(p => p.SortNum == SortNum); + if (temp != null) DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp); + } + else + { + DataServer.GetInstance.morkS.MakeOrder.ElementAt(index).Status = oRDER_STATUS; + } + } + else + { + DataServer.GetInstance.morkS.MakeOrder.Add(new OrderMakeModel() + { + Status = oRDER_STATUS, + GoodName = goodName, + SortNum = SortNum, + StartTime = DateTime.Now.ToString("HH:mm:ss") + }); + } } private void GetStatus(string key, Action action) @@ -152,6 +188,16 @@ namespace BPASmartClient.MorkS public override void ReadData() { + DataServer.GetInstance.morkS.Alarm.Clear(); + alarms.ForEach(item => + { + DataServer.GetInstance.morkS.Alarm.Add(new AlarmModel() + { + AlarmTime = $"{item.Date} {item.Time}", + AlarmMs = item.Info + }); + }); + GetStatus("M230.0", new Action((obj) => { if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 24) @@ -213,6 +259,11 @@ namespace BPASmartClient.MorkS mORKS.TurntableUpLimit = bools[13]; mORKS.FeedComplete = bools[14]; mORKS.TurntableMoveInPlace = bools[15]; + DataServer.GetInstance.morkS.MorkS_Temp = mORKS.TemperatureReached; + DataServer.GetInstance.morkS.Morks_SiloMeasUp = mORKS.TurntableUpLimit; + DataServer.GetInstance.morkS.Morks_SiloMeasDown = mORKS.TurntableLowerLimit; + DataServer.GetInstance.morkS.MorkS_NoBowMeas1 = mORKS.MissingBowl; + DataServer.GetInstance.morkS.MorkS_NoBowMeas2 = mORKS.MissingBowlSignal2; } })); @@ -245,6 +296,7 @@ namespace BPASmartClient.MorkS for (int i = 0; i < 6; i++) { mORKS.CookNoodlesComplete[i] = bools[i]; + DataServer.GetInstance.morkS.Morks_NoodleUpOrDown[i] = bools[i]; } } @@ -254,6 +306,7 @@ namespace BPASmartClient.MorkS { if (obj is ushort[] UshortValue && UshortValue.Length > 0 && UshortValue.Length <= 1) mORKS.TurntableFeedbackloc = UshortValue[0]; + DataServer.GetInstance.morkS.MorkS_BinLocation = mORKS.TurntableFeedbackloc; })); } diff --git a/BPASmartClient.MorkS/DataServer.cs b/BPASmartClient.MorkS/DataServer.cs index ff948122..6197e9b2 100644 --- a/BPASmartClient.MorkS/DataServer.cs +++ b/BPASmartClient.MorkS/DataServer.cs @@ -20,23 +20,25 @@ namespace BPASmartClient.MorkS public ScreenModelMorkS morkS { get; set; } = new ScreenModelMorkS(); + MQTTProxy mQTTProxy = new MQTTProxy(); public void Init() { - MQTTProxy mQTTProxy = new MQTTProxy(); mQTTProxy.Connected = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); ThreadManage.GetInstance().StartLong(new Action(() => { morkS.MorkS_OrderCount = Json.Data.Count; - mQTTProxy.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机), morkS.ToJSON()); + SendScreenDataModel sendScreenDataModel = new SendScreenDataModel(); + sendScreenDataModel.Name = ScreenDeviceType.煮面机; + sendScreenDataModel.Value = morkS.ToJSON(); + mQTTProxy.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机), sendScreenDataModel.ToJSON()); Thread.Sleep(100); }), "海科食堂大屏监听"); }); mQTTProxy.Connect("UserName", "Password", "Host", 1883, $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); } - //订单信息(正在制作,等待制作,制作完成) //煮面炉上下状态(6个煮面炉上或下) //温度状态(煮面炉温度是否到达)