diff --git a/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj b/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj index 382433bf..6f6fc9e1 100644 --- a/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj +++ b/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj @@ -20,7 +20,7 @@ - + diff --git a/BPASmart.PageLoad/BPASmart.PageLoad.csproj b/BPASmart.PageLoad/BPASmart.PageLoad.csproj index 115cd404..be4c76b2 100644 --- a/BPASmart.PageLoad/BPASmart.PageLoad.csproj +++ b/BPASmart.PageLoad/BPASmart.PageLoad.csproj @@ -8,7 +8,7 @@ - + diff --git a/BPASmart.Server/BPASmart.Server.csproj b/BPASmart.Server/BPASmart.Server.csproj index 6a75087c..f8531a3c 100644 --- a/BPASmart.Server/BPASmart.Server.csproj +++ b/BPASmart.Server/BPASmart.Server.csproj @@ -9,7 +9,7 @@ - + diff --git a/BPASmart.VariableManager/BPASmart.VariableManager.csproj b/BPASmart.VariableManager/BPASmart.VariableManager.csproj index 252e006a..5a7c760a 100644 --- a/BPASmart.VariableManager/BPASmart.VariableManager.csproj +++ b/BPASmart.VariableManager/BPASmart.VariableManager.csproj @@ -30,7 +30,7 @@ - + diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index 81e148b7..2a67b414 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -201,6 +201,7 @@ + @@ -362,6 +363,7 @@ + @@ -407,7 +409,7 @@ - + diff --git a/BPASmartClient.CustomResource/Converters/BoolToFillColorConverter.cs b/BPASmartClient.CustomResource/Converters/BoolToFillColorConverter.cs new file mode 100644 index 00000000..d24de8d6 --- /dev/null +++ b/BPASmartClient.CustomResource/Converters/BoolToFillColorConverter.cs @@ -0,0 +1,28 @@ +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 BoolToFillColorConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && value is bool tempBool) + { + return tempBool ? Brushes.Green : Brushes.Gray; + } + return Brushes.Gray; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BPASmartClient.CustomResource/Converters/CountIsVisiableConvert.cs b/BPASmartClient.CustomResource/Converters/CountIsVisiableConvert.cs new file mode 100644 index 00000000..9d3ba102 --- /dev/null +++ b/BPASmartClient.CustomResource/Converters/CountIsVisiableConvert.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace BPASmartClient.CustomResource.Converters +{ + public class CountIsVisiableConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + var count = value?.GetType()?.GetProperty("Count")?.GetValue(value); + if (count != null && count is int tempCount) + { + if (tempCount > 0) return Visibility.Visible; + } + } + return Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BPASmartClient.CustomResource/Image/组合边框2.png b/BPASmartClient.CustomResource/Image/组合边框2.png new file mode 100644 index 00000000..8ffa46c3 Binary files /dev/null and b/BPASmartClient.CustomResource/Image/组合边框2.png differ diff --git a/BPASmartClient.CustomResource/Pages/View/PromptView.xaml b/BPASmartClient.CustomResource/Pages/View/PromptView.xaml index f3e888b0..e489ca45 100644 --- a/BPASmartClient.CustomResource/Pages/View/PromptView.xaml +++ b/BPASmartClient.CustomResource/Pages/View/PromptView.xaml @@ -10,6 +10,7 @@ Height="200" AllowsTransparency="True" Background="{x:Null}" + Topmost="True" WindowStartupLocation="CenterScreen" WindowStyle="None" mc:Ignorable="d"> @@ -54,7 +55,7 @@ Name="infoType" Grid.Column="1" VerticalAlignment="Top" - FontSize="16" + FontSize="15" Foreground="DeepSkyBlue" /> diff --git a/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml b/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml index d2034e8a..635e3b0e 100644 --- a/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml +++ b/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml @@ -102,27 +102,19 @@ - - - - - - diff --git a/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml b/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml index 1b336e6d..79e65167 100644 --- a/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml +++ b/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml @@ -12,10 +12,10 @@ + Margin="5" + Background="Transparent"> public void StartLong(Action action, string key, bool IsRestart = false, Action RunComplete = null) { - CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource()); - bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() => - { - Thread.CurrentThread.Name = key; - ReStart: - try - { - while (!CancellationTokenSources[guid + key].IsCancellationRequested) - { - if (action != null) action(); - } - } - catch (Exception ex) - { - MessageLog.GetInstance.ShowEx(ex.ToString()); - if (IsRestart) - { - Thread.Sleep(2000); - MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启"); - goto ReStart; - } - else - { - CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp); - Threads.TryRemove(guid + key, out Task temp1); - MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已退出"); - } - } - }), CancellationTokenSources[guid + key].Token).ContinueWith(new Action((t, o) => - { - ThreadStatus(t, o.ToString()); - if (RunComplete != null) RunComplete(); - }), guid + key)); - MessageLog.GetInstance.Show($"启动线程 【{key}】"); - if (!result) MessageLog.GetInstance.Show($"【{key}】任务已存在,请检查 TaskName"); + if (!Threads.ContainsKey(guid + key)) + { + CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource()); + bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() => + { + Thread.CurrentThread.Name = key; + MessageLog.GetInstance.Show($"启动线程 【{key}】"); + ReStart: + try + { + while (!CancellationTokenSources[guid + key].IsCancellationRequested) + { + if (action != null) action(); + } + } + catch (Exception ex) + { + MessageLog.GetInstance.ShowEx(ex.ToString()); + if (IsRestart) + { + Thread.Sleep(2000); + MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启"); + goto ReStart; + } + else + { + CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp); + Threads.TryRemove(guid + key, out Task temp1); + MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已退出"); + } + } + }), CancellationTokenSources[guid + key].Token).ContinueWith(new Action((t, o) => + { + ThreadStatus(t, o.ToString()); + if (RunComplete != null) RunComplete(); + }), guid + key)); + } + else MessageLog.GetInstance.Show($"【{key}】任务已存在,请检查 TaskName"); } @@ -93,35 +96,38 @@ namespace BPASmartClient.Helper /// public void Start(Action action, string key, bool isRestart = false) { - CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource()); - bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() => + if (!Threads.ContainsKey(guid + key)) { - Thread.CurrentThread.Name = key; - try - { - if (action != null) action(); - } - catch (Exception ex) + CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource()); + bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() => { - MessageLog.GetInstance.ShowEx(ex.ToString()); - if (isRestart) + Thread.CurrentThread.Name = key; + MessageLog.GetInstance.Show($"启动线程 【{key}】"); + try { - MessageLog.GetInstance.Show($"线程 【{key}】正在重启"); - CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource item1); - Threads.TryRemove(guid + key, out Task item2); - Start(action, key, isRestart); + if (action != null) action(); } - else + catch (Exception ex) { - MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常"); + MessageLog.GetInstance.ShowEx(ex.ToString()); + if (isRestart) + { + MessageLog.GetInstance.Show($"线程 【{key}】正在重启"); + CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource item1); + Threads.TryRemove(guid + key, out Task item2); + Start(action, key, isRestart); + } + else + { + MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常"); + } } - } - }), CancellationTokenSources[guid + key].Token).ContinueWith(new Action((t, o) => - { - ThreadStatus(t, o.ToString()); - }), guid + key)); - MessageLog.GetInstance.Show($"启动线程 【{key}】"); - if (!result) MessageLog.GetInstance.Show($"【{key}】任务已存在,请检查 TaskName"); + }), CancellationTokenSources[guid + key].Token).ContinueWith(new Action((t, o) => + { + ThreadStatus(t, o.ToString()); + }), guid + key)); + } + else MessageLog.GetInstance.Show($"【{key}】任务已存在,请检查 TaskName"); } private void ThreadStatus(Task task, string key) diff --git a/BPASmartClient.JXJFoodBigStation/App.config b/BPASmartClient.JXJFoodBigStation/App.config index e5c7f162..3559a687 100644 --- a/BPASmartClient.JXJFoodBigStation/App.config +++ b/BPASmartClient.JXJFoodBigStation/App.config @@ -2,6 +2,6 @@ - + \ 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 f03a21f0..4edb4386 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs @@ -79,7 +79,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC public float Bareel1Bin13SetWeight { get; set; } public float Bareel1Bin14SetWeight { get; set; } - public float Bareel2Bin1SetWeight { get; set; } public float Bareel2Bin2SetWeight { get; set; } public float Bareel2Bin3SetWeight { get; set; } @@ -94,7 +93,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC public float Bareel2Bin12SetWeight { get; set; } public float Bareel2Bin13SetWeight { get; set; } public float Bareel2Bin14SetWeight { get; set; } - public float Bareel4Bin1SetWeight { get; set; } public float Bareel4Bin2SetWeight { get; set; } @@ -110,6 +108,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC public float Bareel4Bin12SetWeight { get; set; } public float Bareel4Bin13SetWeight { get; set; } public float Bareel4Bin14SetWeight { get; set; } + public float Bareel5Bin1SetWeight { get; set; } public float Bareel5Bin2SetWeight { get; set; } public float Bareel5Bin3SetWeight { get; set; } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs index 102503c9..38cd6123 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs @@ -17,7 +17,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC public bool IsConnected => HK_PLC_S7.IsConnected; public DB_Write PlcWrite = new DB_Write(); public DB_Read PlcRead = new DB_Read(); - + public StockBinName StockBinName = new StockBinName(); public void Init() { if (IsConnected) @@ -26,11 +26,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC { HK_PLC_S7.WriteClass(PlcWrite, 99); var res1 = HK_PLC_S7.ReadClass(98); - var res2 = HK_PLC_S7.ReadClass(97); + var res2 = HK_PLC_S7.ReadClass(97); if (res1 != null && res1 is DB_Read data1) { PlcRead = data1; } + if (res2 != null && res2 is StockBinName data2) + { + StockBinName = data2; + } Thread.Sleep(10); }),"信号收发处理"); } @@ -264,7 +268,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC } else { - MessageLog.GetInstance.ShowRunLog($"桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); switch (barrel) { case 1: @@ -470,7 +474,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC default: break; } - } + } } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/Test1.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs similarity index 97% rename from BPASmartClient.JXJFoodBigStation/Model/HK_PLC/Test1.cs rename to BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs index 0a9f0d6c..69529513 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/Test1.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC { - internal class Test1 + public class StockBinName { [Siemens(6)] public string RawMaterialName1 { get; set; } diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index ee3e1e4e..27d7ae01 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -48,27 +48,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model public ConcurrentQueue RecipeQueue4 = new ConcurrentQueue(); public ConcurrentQueue RecipeQueue5 = new ConcurrentQueue(); /// - /// AGV到达工站队列 - /// - public ConcurrentQueue AGVToWorkStationQueue = new ConcurrentQueue(); - /// /// 接收原料数据 /// public RecipeRawMaterial RawMaterial; public void Init() { - RawMaterialsNamePos.Add("1", 1); - RawMaterialsNamePos.Add("2", 2); - RawMaterialsNamePos.Add("3", 3); - RawMaterialsNamePos.Add("4", 4); - RawMaterialsNamePos.Add("5", 5); - RawMaterialsNamePos.Add("6", 6); - RawMaterialsNamePos.Add("7", 7); - RawMaterialsNamePos.Add("8", 8); - RawMaterialsNamePos.Add("9", 9); - RawMaterialsNamePos.Add("10", 10); - RawMaterialsNamePos.Add("11", 11); - RawMaterialsNamePos.Add("12", 12); ActionManage.GetInstance.Register(new Action((res) => { ObservableCollection RawMaterials = new ObservableCollection(); @@ -87,7 +71,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum, RawMaterialWeight = recipe.Material[i].Material_Weight, RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name] - }); + }); } else { @@ -99,7 +83,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model RecipeName = recipe.RecipeName, RecipeCode = recipe.RecipeCode, RawMaterial = RawMaterials, - TrayCode = recipe.TrayCode + //TrayCode = recipe.Order_No, }); } } @@ -108,7 +92,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; try { - HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); + //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); if (HKDevice.IsConnected) { @@ -138,136 +122,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName); } } - + MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败"); } }), "ManualSendRecipe", true); RecipeQueue1.Clear(); - - - //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 ThreadManage.GetInstance().StartLong(new Action(() => { - //ReadPLCDeviceInfo(); ReceviceData(); RecipeInfoToHKPLC(); Thread.Sleep(10); }), "流程处理", true); - ThreadManage.GetInstance().StartLong(new Action(() => - { - if (HKDevice.IsConnected && SiemensDevice.IsConnected) - { - AgvGetInOut(); - } - Thread.Sleep(10); - }), "AGV进站送取货", true); - ThreadManage.GetInstance().StartLong(new Action(() => - { - ReadSiemensCommData(); - ReadHKPLCCommData(); - Thread.Sleep(10); - }), "读取西门子和海科PLC的数据", true); - } - /// - /// AGV送货 - /// - /// - private void AGV_Delivery(int bitNum) - { - if ((ReadSiemens("M4002." + bitNum) is bool) && BigStation.AgvDeliveryPosition == 0) - { - BigStation.AgvDeliveryPosition = 1; - WriteHKPLC("M4002." + bitNum, true); - WriteSiemens("M4002." + bitNum, false); - } - else if (ReadHK("M5002." + bitNum) is bool && BigStation.AgvDeliveryPosition == 1) - { - BigStation.AgvDeliveryPosition = 2; - WriteSiemens("M5002." + bitNum, true); - WriteHKPLC("M5002." + bitNum, false); - } - else if (ReadSiemens("M4004." + bitNum) is bool && BigStation.AgvDeliveryPosition == 2) - { - BigStation.AgvDeliveryPosition = 3; - WriteHKPLC("M4004." + bitNum, true); - WriteSiemens("M4004." + bitNum, false); - } - else if (ReadHK("M5004." + bitNum) is bool && BigStation.AgvDeliveryPosition == 3) - { - BigStation.AgvDeliveryPosition = 4; - WriteSiemens("M5004." + bitNum, true); - WriteHKPLC("M5004." + bitNum, false); - } - else if (ReadSiemens("M4005." + bitNum) is bool && BigStation.AgvDeliveryPosition == 4) - { - BigStation.AgvDeliveryPosition = 5; - WriteHKPLC("M4005." + bitNum, true); - WriteSiemens("M4005." + bitNum, false); - } - else if (ReadHK("M5005." + bitNum) is bool && BigStation.AgvDeliveryPosition == 5) - { - WriteSiemens("M5005." + bitNum, true); - WriteHKPLC("M5005." + bitNum, false); - } - } - /// - /// AGV取货 - /// - /// - private void AGV_Pick(int bitNum) - { - if (ReadSiemens("M4003" + bitNum) is bool && BigStation.AgvPickUpPosition == 0) - { - BigStation.AgvPickUpPosition = 1; - WriteHKPLC("M4003." + bitNum, true); - WriteSiemens("M4003." + bitNum, false); - } - if (ReadHK("M5003" + bitNum) is bool && BigStation.AgvPickUpPosition == 1) - { - BigStation.AgvPickUpPosition = 2; - WriteSiemens("M5003" + bitNum, true); - WriteHKPLC("M5003" + bitNum, false); - } - if (ReadSiemens("M4006." + bitNum) is bool && BigStation.AgvPickUpPosition == 2) - { - BigStation.AgvPickUpPosition = 3; - WriteHKPLC("M4006." + bitNum, true); - WriteSiemens("M4006." + bitNum, false); - } - if (ReadHK("M5006." + bitNum) is bool && BigStation.AgvPickUpPosition == 3) - { - WriteSiemens("M5006." + bitNum, true); - WriteHKPLC("M5006." + bitNum, false); - } - } - /// - /// AGV进站送货 - /// - private void AgvGetInOut() - { - //获取工位上是否有小车 - SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool) - HKDevice.HK_PLC_S7.Read("M4007.0")); - //检测AGV到站信号 - if (AGVToWorkStationQueue.Count > 0) - { - int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == AGVToWorkStationQueue.ElementAt(0)); - int TrayLocation = RemoteRecipes.ElementAt(index).TrayCode;//根据配方编号,找到托盘的ID 托盘ID1-6 - string RecipeCode = (string)RemoteRecipes.ElementAt(index).RecipeCode; - if (TrayLocation > 0 && TrayLocation < 7) - { - AGV_Delivery(TrayLocation - 1); - if (BigStation.AgvDeliveryPosition == 5) - { - BigStation.AgvDeliveryPosition = 0; - } - AGV_Pick(TrayLocation - 1); - if (BigStation.AgvPickUpPosition == 3) - { - BigStation.AgvPickUpPosition = 0; - AGVToWorkStationQueue.TryDequeue(out RecipeCode); - } - } - } } private void ReceviceData() { @@ -318,6 +182,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model RecipeQueue4.Clear(); RecipeQueue5.Clear(); BigStation.Recipe1DosingStatus = 0; + BigStation.Recipe2DosingStatus = 0; + BigStation.Recipe3DosingStatus = 0; + BigStation.Recipe4DosingStatus = 0; + BigStation.Recipe5DosingStatus = 0; } } private void RecipeInfoToHKPLC() @@ -333,23 +201,20 @@ namespace BPASmartClient.JXJFoodBigStation.Model { HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); HKDevice.PlcWrite.Recipe1IssuedFinish = true; - //HKDevice.HK_PLC_S7.Write("DB98.DBX0.1", false);//复位允许下发配方1信号 BigStation.Recipe1DosingStatus = 1; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); } if (HKDevice.PlcRead.ReceiveFinishRecipe1 && BigStation.Recipe1DosingStatus == 1) { BigStation.Recipe1DosingStatus = 2; HKDevice.PlcWrite.Recipe1IssuedFinish = false; - HKDevice.PlcWrite.RecipeCode = 0; - HKDevice.PlcWrite.TrayCode = 0; - WeightReset(); - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } if (BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) { BigStation.Recipe1DosingStatus = 3; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe1TrayCode == 1) { foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) @@ -425,7 +290,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model { SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 3); } - //HKDevice.HK_PLC_S7.Write("DB98.DBX1.1",false); RecipeQueue1.TryDequeue(out code); IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 if (!BigStation.IsAllowManual) @@ -453,21 +317,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); HKDevice.PlcWrite.Recipe2IssuedFinish = true; BigStation.Recipe2DosingStatus = 1; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); } if (HKDevice.PlcRead.ReceiveFinishRecipe2 && BigStation.Recipe2DosingStatus == 1) { BigStation.Recipe2DosingStatus = 2; HKDevice.PlcWrite.Recipe2IssuedFinish = false; - HKDevice.PlcWrite.RecipeCode = 0; - HKDevice.PlcWrite.TrayCode = 0; - WeightReset(); - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); } if (BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) { BigStation.Recipe2DosingStatus = 3; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe2TrayCode > 0) { foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) @@ -529,7 +391,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } } - FinishData.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; FinishData.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) @@ -539,11 +400,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model FinishData.Material[i].Material_BarrelNum = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; FinishData.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; } - } if (SiemensDevice.IsConnected) { SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 3); + MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); } RecipeQueue2.TryDequeue(out code); IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 @@ -556,7 +417,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 } BigStation.Recipe2DosingStatus = 0; - } } } @@ -572,20 +432,18 @@ namespace BPASmartClient.JXJFoodBigStation.Model HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); HKDevice.PlcWrite.Recipe3IssuedFinish = true; BigStation.Recipe3DosingStatus = 1; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); } if (HKDevice.PlcRead.ReceiveFinishRecipe3 && BigStation.Recipe3DosingStatus == 1) { BigStation.Recipe3DosingStatus = 2; - HKDevice.PlcWrite.RecipeCode = 0; - HKDevice.PlcWrite.TrayCode = 0; - WeightReset(); - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); } if (HKDevice.PlcRead.Recipe3DosingFinish && BigStation.Recipe3DosingStatus == 2) { BigStation.Recipe3DosingStatus = 3; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe3TrayCode > 0) { foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) @@ -691,21 +549,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); HKDevice.PlcWrite.Recipe4IssuedFinish = true; BigStation.Recipe4DosingStatus = 1; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); } if (HKDevice.PlcRead.ReceiveFinishRecipe4 && BigStation.Recipe4DosingStatus == 1) { BigStation.Recipe4DosingStatus = 2; HKDevice.PlcWrite.Recipe4IssuedFinish = false; - HKDevice.PlcWrite.RecipeCode = 0; - HKDevice.PlcWrite.TrayCode = 0; - WeightReset(); - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); } if (BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) { BigStation.Recipe4DosingStatus = 3; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe4TrayCode > 0) { foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) @@ -799,128 +655,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } } - public ConcurrentDictionary ReadHKPLCData = new ConcurrentDictionary(); - public ConcurrentDictionary ReadSiemensData = new ConcurrentDictionary(); - - - private void ReadSiemensCommData() - { - if (SiemensDevice.IsConnected) - { - GetSiemensStatus("", new Action((obj) => - { - if (obj is bool[] bools && bools.Length > 0) - { - - } - })); - } - } - private void ReadHKPLCCommData() - { - if (HKDevice.IsConnected) - { - GetHKStatus("", new Action((obj) => - { - if (obj is bool[] bools && bools.Length > 0) - { - - } - })); - } - } - private void GetHKStatus(string key, Action action) - { - if (ReadHKPLCData.ContainsKey(key)) - { - if (ReadHKPLCData[key] != null) - { - action?.Invoke(ReadHKPLCData[key]); - } - } - } - private void GetSiemensStatus(string key, Action action) - { - - if (ReadSiemensData.ContainsKey(key)) - { - if (ReadSiemensData[key] != null) - { - action?.Invoke(ReadSiemensData[key]); - } - } - } - private void WriteSiemens(string Address, object Value) - { - if (SiemensDevice.IsConnected) - { - SiemensDevice.Siemens_PLC_S7.Write(Address, Value); - } - } - private void WriteHKPLC(string Address, object Value) - { - HKDevice.HK_PLC_S7.Write(Address, Value); - } - private object ReadSiemens(string Address) - { - if (SiemensDevice.IsConnected) - { - return SiemensDevice.Siemens_PLC_S7.Read(Address); - } - else - { - return null; - } - } - private bool[] ReadBoolsSiemens(int address, int count) - { - if (SiemensDevice.IsConnected) - { - return SiemensDevice.Siemens_PLC_S7.ReadBools(address, count); - } - else - { - return null; - } - } - private object ReadHK(string Address) - { - if (HKDevice.IsConnected) - { - return HKDevice.HK_PLC_S7.Read(Address); - } - else - { - return null; - } - } - private bool[] ReadBoolsHK(int address, int count) - { - if (HKDevice.IsConnected) - { - return HKDevice.HK_PLC_S7.ReadBools(address, count); - } - else - { - return null; - } - } /// - /// 获取料仓的原料名称和原料位置 + /// 下发配方的数据复位 /// - private void ReadPLCDeviceInfo() - { - /*for (int i = 0; i < 12; i++) - { - string RawMaterialName = HKDevice.HK_PLC_S7.Read(""); - short RawMaterialLocation = HKDevice.HK_PLC_S7.Read(""); - if (RawMaterialsNamePos.ContainsKey(RawMaterialName)) - RawMaterialsNamePos.Add(RawMaterialName, RawMaterialLocation); - }*/ - - } - private void WeightReset() + private void StockBinParReset() { + + HKDevice.PlcWrite.RecipeCode = 0; + HKDevice.PlcWrite.TrayCode = 0; + HKDevice.PlcWrite.Bareel1Bin1SetWeight = 0; HKDevice.PlcWrite.Bareel1Bin2SetWeight = 0; HKDevice.PlcWrite.Bareel1Bin3SetWeight = 0; @@ -982,5 +725,82 @@ namespace BPASmartClient.JXJFoodBigStation.Model HKDevice.PlcWrite.Bareel5Bin13SetWeight = 0; HKDevice.PlcWrite.Bareel5Bin14SetWeight = 0; } + private void testData() + { + RawMaterialsNamePos.Clear(); + if (!HKDevice.IsConnected) + { + HKDevice.StockBinName.RawMaterialName1 = "1"; + HKDevice.StockBinName.RawMaterialName2 = "2"; + HKDevice.StockBinName.RawMaterialName3 = "3"; + HKDevice.StockBinName.RawMaterialName4 = "4"; + HKDevice.StockBinName.RawMaterialName5 = "5"; + HKDevice.StockBinName.RawMaterialName6 = "6"; + HKDevice.StockBinName.RawMaterialName7 = "7"; + HKDevice.StockBinName.RawMaterialName8 = "8"; + HKDevice.StockBinName.RawMaterialName9 = "9"; + HKDevice.StockBinName.RawMaterialName10 = "10"; + HKDevice.StockBinName.RawMaterialName11 = "11"; + HKDevice.StockBinName.RawMaterialName12 = "12"; + HKDevice.StockBinName.RawMaterialName13 = "13"; + HKDevice.StockBinName.RawMaterialName14 = "14"; + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName1)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName1, 1); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName2)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName2, 2); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName3)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName3, 3); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName4)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName4, 4); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName5)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName5, 5); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName6)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName6, 6); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName7)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName7, 7); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName8)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName8, 8); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName9)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName9, 9); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName10)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName10, 10); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName11)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName11, 11); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName12)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName12, 12); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName13)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName13, 13); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName14)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName14, 14); + } + } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs new file mode 100644 index 00000000..f7279b1a --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs @@ -0,0 +1,39 @@ +using BPASmartClient.S7Net; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.Model.Siemens +{ + public class DL_DataColl_DB + { + [Siemens(16)] + public string RecipeCode { get; set; } + [Siemens(16)] + public string RecipeName { get; set; } + public bool var1 { get; set; } + public bool var2 { get; set; } + + public bool var3 { get; set; } + + public bool var4 { get; set; } + + public bool var5 { get; set; } + + public bool var6 { get; set; } + + public bool var7 { get; set; } + + public bool var8 { get; set; } + + public bool var9 { get; set; } + public short Mode { get; set; } + + public bool[] Alarm { get; set; } = new bool[24]; + public int Reserved1 { get; set; } + public int Reserved2 { get; set; } + + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs index 4394ac10..80e91369 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.S7Net; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,32 +9,42 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { internal class DL_Finish_DB { + + /// + /// 配料完成信号确认 + /// + public bool Ask_For_Finish_PLC { get; set; } + + public short[] StandbyFinish { get; set; } = new short[4]; + [Siemens(16)] /// /// 生产工单编码 /// - public string Order_No; + public string Order_No{get; set; } + [Siemens(16)] /// /// 产品名称 /// - public string Product_Code; + public string Product_Code { get; set; } + public short job_No { get; set; } /// /// 原料信息 /// - public UDT1[] Material = new UDT1[20]; + public UDT1[] Material { get; set; } = new UDT1[20]; + public short ProcessTime { get; set; } /// /// 配料完成信号 /// - public bool Ask_For_Finish; - /// - /// 配料完成信号确认 - /// - public bool Ask_For_Finish_PLC; + public bool Ask_For_Finish { get; set; } + + public short[] StandbyFinish1 { get; set; } = new short[4]; } public class UDT1 { - public string Material_Name; - public float Material_Laying_Off_Weight; - public short Material_BarrelNum; + [Siemens(6)] + public string Material_Name { get; set; } + public float Material_Laying_Off_Weight { get; set; } + public short Material_BarrelNum { get; set; } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs index 13066a70..a4a5c592 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.S7Net; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,44 +9,46 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { internal class DL_Start_DB { + [Siemens(16)] /// /// 配方编码 /// - public string RecipeCode; + public string RecipeCode { get; set; } + [Siemens(16)] /// /// 配发名称 /// - public string RecipeName; + public string RecipeName { get; set; } + public short Order_No { get; set; } + public short Pallet_No { get; set; } /// /// 物料信息 /// - public UDT[] Material = new UDT[20]; - /// - /// 托盘编号 - /// - public int TrayCode; + public UDT[] Material { get; set; } = new UDT[20]; + public bool Order_Type { get; set; } + public bool Order_Request_Ack { get; set; } + + public short[] Standby { get; set; } = new short[4]; /// /// 配方发送请求 /// - public bool Ask_For_Send_Bit; - /// - /// 上位机确认配方接收完成 - /// - public bool Ack_Ask_For_Send_Bit; + public bool Ask_For_Send_Bit { get; set; } + public short[] Standby1 { get; set; } = new short[4]; } public class UDT { + [Siemens(6)] /// /// 原料名称 /// - public string Material_Name; + public string Material_Name { get; set; } /// /// 原料重量 /// - public float Material_Weight; + public float Material_Weight { get; set; } /// /// 原料桶号 /// - public short Material_BarrelNum; + public short Material_BarrelNum { get; set; } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs index 88126d64..efcaf0d1 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.S7Net; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,53 +9,36 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { internal class DL_Status_DB { - /// - /// 生产工单 - /// - public string RecipeCode; /// /// 配料开始 /// - public bool Dosing_Start; + public bool Dosing_Start { get; set; } /// /// 配料开始确认 /// - public bool Dosing_Confirm; - /// - /// 托盘占位情况 - /// - public bool[] Pallet_Position_Occ = new bool[16]; - /// - /// 工位允许放货架 - /// - public bool[] Allow_AGV_Put = new bool[16]; - /// - /// 工位允许取货架 - /// - public bool[] Allow_AGV_Get = new bool[16]; - /// - /// AGV请求放货架 - /// - public bool[] AGV_Request_Put = new bool[16]; - /// - /// AGV请求取货架 - /// - public bool[] AGV_Request_Get = new bool[16]; - /// - /// AGV放托盘完成 - /// - public bool[] AGV_Put_Done = new bool[16]; - /// - /// 托盘号 - /// - public short[] Pan_No = new short[16]; - /// - /// 配料时间 - /// - public int DosingTime; + public bool Dosing_Confirm { get; set; } + public bool Dosing_Cancel { get; set; } + public bool Dosing_Cancel2 { get; set; } + + public bool Dosing_Cancel3 { get; set; } + + public short a { get; set; } + public short[] Standby { get; set; } = new short[3]; + [Siemens(16)] /// - /// 备用 + /// 生产工单 /// - public byte Reserve; + public string RecipeCode { get; set; } + public bool Dosing_Cancel4 { get; set; } + + public bool Dosing_Cancel5 { get; set; } + + public bool Dosing_Cancel6 { get; set; } + + public bool Dosing_Cancel7 { get; set; } + + public short Dosing_Cancel8 { get; set; } + + public short[] Standby2 { get; set; } = new short[4]; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs index a3361db3..d4969c2e 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs @@ -21,21 +21,22 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { ThreadManage.GetInstance().StartLong(new Action(() => { - var res = this.Siemens_PLC_S7.ReadClass(1); - var res1 = this.Siemens_PLC_S7.ReadClass(2); - var res2 = this.Siemens_PLC_S7.ReadClass(3); - if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit)) + var res = this.Siemens_PLC_S7.ReadClass(2301); + var res1 = this.Siemens_PLC_S7.ReadClass(2331); + var res2 = this.Siemens_PLC_S7.ReadClass(2361); + var res3 = this.Siemens_PLC_S7.ReadClass(2391); + /*if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit)) { ActionManage.GetInstance.Send("SiemensSendRecipe", res); res.Ask_For_Send_Bit = false;//接受配方信号复位 - res.Ack_Ask_For_Send_Bit = true;//配方接受完成 + //res.Ack_Ask_For_Send_Bit = true;//配方接受完成 this.Siemens_PLC_S7.WriteClass(res, 1); } - if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.Allow_AGV_Put[0])) + if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.)) { ActionManage.GetInstance.Send("AGVToStation1Sign", res1); - res1.Allow_AGV_Put[0] = false; + //res1.Allow_AGV_Put[0] = false; this.Siemens_PLC_S7.WriteClass(res1, 2); } if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1])) @@ -68,7 +69,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens res1.Allow_AGV_Put[5] = false; this.Siemens_PLC_S7.WriteClass(res1, 2); } - +*/ if (res2 != null && res2.Ask_For_Finish_PLC) { ActionManage.GetInstance.Send("配料完成信号确认完成"); diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index e145bf5b..4404997f 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -80,7 +80,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } else { - MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合"); + //MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合"); } } Json.Data.Recipes.Add(new RemoteRecipeData() @@ -112,7 +112,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model try { //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, 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); //WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200,WindSend_PLC_IP); if (HKDevice.IsConnected) { @@ -272,7 +272,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model break; default: break; - } } else if (o.ToString().Contains("阻挡气缸")) @@ -327,7 +326,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model break; default: break; - } } else if (o.ToString().Contains("进料桶顶升气缸")) diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs index 107f2920..031c17eb 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs @@ -24,6 +24,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens var res = this.Siemens_PLC_S7.ReadClass(2201); var res1 = this.Siemens_PLC_S7.ReadClass(2231); var res2 = this.Siemens_PLC_S7.ReadClass(2261); + var res4 = this.Siemens_PLC_S7.ReadClass(2291); if (res != null && res.Order_Request_ACK == false && GVL_SmallStation.GetInstance.IsAllowSiemensSendRecipe) { res.Order_Request_ACK = true; diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs new file mode 100644 index 00000000..dabd8bde --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs @@ -0,0 +1,39 @@ +using BPASmartClient.S7Net; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens +{ + internal class XL_DataColl_DB + { + [Siemens(16)] + public string RecipeCode { get; set; } + [Siemens(16)] + public string RecipeName { get; set; } + public bool var1 { get; set; } + public bool var2 { get; set; } + + public bool var3 { get; set; } + + public bool var4 { get; set; } + + public bool var5 { get; set; } + + public bool var6 { get; set; } + + public bool var7 { get; set; } + + public bool var8 { get; set; } + + public bool var9 { get; set; } + public short Mode { get; set; } + + public bool[] Alarm { get; set; } = new bool[24]; + public int Reserved1 { get; set; } + public int Reserved2 { get; set; } + + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs index 0e977bde..7fe9e791 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs @@ -9,33 +9,37 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { internal class XL_Finish_DB { - [Siemens(6)] + + /// + /// 配料完成信号确认 + /// + public bool Ask_For_Finish_PLC { get; set; } + public short[] StandbyFinish { get; set; }=new short[4]; + + [Siemens(16)] /// /// 生产工单编码 /// /// 产品名称 /// public string Product_Code { get; set; } public short Job_No { get; set; } - public UDT2[] Powder = new UDT2[10]; + public UDT2[] Powder { get; set; } = new UDT2[10]; /// /// 原料信息 /// - public UDT1[] Material = new UDT1[20]; + public UDT1[] Material { get; set; } = new UDT1[20]; public short DosingTime { get; set; } /// /// 配料完成信号 /// public bool Ask_For_Finish { get; set; } - /// - /// 配料完成信号确认 - /// - public bool Ask_For_Finish_PLC { get; set; } + public short[] StandbyFinish2 { get; set; } = new short[4]; } public class UDT1 { diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs index 5109c0cf..cd7e7ad2 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs @@ -23,19 +23,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens public short StockCode { get; set; } public short TrayCode { get; set; } - public UDT2Start[] Powder = new UDT2Start[10]; + public UDT2Start[] Powder { get; set; } = new UDT2Start[10]; /// /// 物料信息 /// - public UDTStart[] Material = new UDTStart[20]; + public UDTStart[] Material { get; set; } = new UDTStart[20]; /// /// plc确认配方接收完成 /// public bool Order_Request_ACK { get; set; } - public short[] Standby = new short[4]; + public short[] Standby { get; set; } = new short[4]; public bool Order_Request { get; set; } - public short[] Standby1 = new short[4]; + public short[] Standby1 { get; set; } = new short[4]; } public class UDTStart diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs index 8e454427..85ec6ebd 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs @@ -7,8 +7,16 @@ using System.Threading.Tasks; namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { - internal class XL_Status_DB + public class XL_Status_DB { + public bool Dosing_Confirm { get; set; } + public bool Agv1 { get; set; } + public bool Agv2 { get; set; } + public bool Agv3 { get; set; } + public bool Agv4 { get; set; } + public short AgvPos { get; set; } + public short[] Standby { get; set; } = new short[3]; + [Siemens(16)] /// /// 生产工单 @@ -18,23 +26,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens /// 配料开始 /// public bool Dosing_Start { get; set; } - /// - /// 配料开始确认 - /// - public bool Dosing_Confirm; - public bool Agv1 { get; set; } - public bool Agv2 { get; set; } - public bool Agv3 { get; set; } - public bool Agv4 { get; set; } - public short AgvPos { get; set; } - - public UDTStatus[] Powder = new UDTStatus[10]; - - public bool Agv5{ get; set; } + public bool Agv5 { get; set; } public bool Agv6 { get; set; } public bool Agv7 { get; set; } - public int Agv8 { get; set; } + + public UDTStatus[] Powder { get; set; } = new UDTStatus[10]; + public short AgvUse { get; set; } + public short[] StandbyStatus { get; set; } = new short[4]; } public class UDTStatus { diff --git a/BPASmartClient.Model/Status.cs b/BPASmartClient.Model/Status.cs new file mode 100644 index 00000000..b49d9064 --- /dev/null +++ b/BPASmartClient.Model/Status.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model +{ + public enum Status + { + 等待配料, + 正在配料, + 配料完成 + } +} diff --git a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs index 7efb9e6b..a8e571fb 100644 --- a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs +++ b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs @@ -1,6 +1,7 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -97,6 +98,9 @@ namespace BPASmartClient.Model public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } } private float _mUpLimtWeightFeedback; + + + /// /// 原料设备执行状态 /// 1:等待配料 @@ -104,7 +108,26 @@ namespace BPASmartClient.Model /// 3:下料完成 /// [Newtonsoft.Json.JsonIgnore] - public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } } + public ushort RecipeStatus + { + get { return _mRecipeStatus; } + set + { + _mRecipeStatus = value; + if (value == 1) Status = Status.等待配料; + else if (value == 2) Status = Status.正在配料; + else if (value == 3) Status = Status.配料完成; + OnPropertyChanged(); + } + } private ushort _mRecipeStatus = 1; + + /// + /// 配料状态名称 + /// + [Newtonsoft.Json.JsonIgnore] + public Status Status { get { return _mStatus; } set { _mStatus = value; OnPropertyChanged(); } } + private Status _mStatus; + } } diff --git a/BPASmartClient.S7Net/SiemensHelper.cs b/BPASmartClient.S7Net/SiemensHelper.cs index ae03de2b..4eef585d 100644 --- a/BPASmartClient.S7Net/SiemensHelper.cs +++ b/BPASmartClient.S7Net/SiemensHelper.cs @@ -52,13 +52,13 @@ namespace BPASmartClient.S7Net return default; } - private object Read(DataType dataType, int db, int address, VarType varType, int count) + public object Read(DataType dataType, int db, int address, VarType varType, int count) { if (!IsConnected) return default; return myPlc?.Read(dataType, db, address, varType, count); } - public string Write(string address, TValue value,int Retries = 1) + public string Write(string address, TValue value, int Retries = 1) { if (IsConnected) { @@ -68,7 +68,7 @@ namespace BPASmartClient.S7Net myPlc?.Write(address, value); return $"成功,地址:{address},值:{value}"; } - else + else { while (count < Retries) { @@ -83,7 +83,7 @@ namespace BPASmartClient.S7Net return $"成功,发送了{count}次,地址:{address},值:{value}"; } } - else + else { return $"失败,地址:{address},值:{value},断开连接"; } diff --git a/BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj b/BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj index b40e4922..d60d6756 100644 --- a/BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj +++ b/BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj @@ -22,7 +22,7 @@ - + diff --git a/ComputerTestDemo/ComputerTestDemo.csproj b/ComputerTestDemo/ComputerTestDemo.csproj index 26fa79a7..ae6b26da 100644 --- a/ComputerTestDemo/ComputerTestDemo.csproj +++ b/ComputerTestDemo/ComputerTestDemo.csproj @@ -10,7 +10,7 @@ - + diff --git a/DosingSystem/App.xaml b/DosingSystem/App.xaml index 74dd174a..a10b130a 100644 --- a/DosingSystem/App.xaml +++ b/DosingSystem/App.xaml @@ -26,6 +26,8 @@ + + diff --git a/DosingSystem/App.xaml.cs b/DosingSystem/App.xaml.cs index bbb1143a..91056dfb 100644 --- a/DosingSystem/App.xaml.cs +++ b/DosingSystem/App.xaml.cs @@ -96,7 +96,7 @@ namespace BPASmartClient.DosingSystem ParSet.Add(new SubMenumodel() { - SubMenuName = "通讯参数设置", + SubMenuName = "设备控制参数设置", SubMenuPermission = new Permission[] { Permission.管理员 }, AssemblyName = "BPASmartClient.DosingSystem", ToggleWindowPath = "View.CommParSetView" @@ -123,18 +123,26 @@ namespace BPASmartClient.DosingSystem ObservableCollection ManualControl = new ObservableCollection(); ManualControl.Add(new SubMenumodel() { - SubMenuName = "手动控制", + SubMenuName = "气缸手动控制", SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, AssemblyName = "BPASmartClient.DosingSystem", ToggleWindowPath = "View.ManualControlView" }); + ManualControl.Add(new SubMenumodel() { - SubMenuName = "料仓控制", + SubMenuName = "输送带手动控制", SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.StockControlView" + ToggleWindowPath = "View.ConveyerBeltManualView" }); + //ManualControl.Add(new SubMenumodel() + //{ + // SubMenuName = "料仓控制", + // SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + // AssemblyName = "BPASmartClient.DosingSystem", + // ToggleWindowPath = "View.StockControlView" + //}); MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", diff --git a/DosingSystem/BPASmartClient.DosingSystem.csproj b/DosingSystem/BPASmartClient.DosingSystem.csproj index 0807292b..8a2d893c 100644 --- a/DosingSystem/BPASmartClient.DosingSystem.csproj +++ b/DosingSystem/BPASmartClient.DosingSystem.csproj @@ -16,9 +16,8 @@ - + - diff --git a/DosingSystem/Model/ConveyerBeltModel.cs b/DosingSystem/Model/ConveyerBeltModel.cs new file mode 100644 index 00000000..f56dd3f8 --- /dev/null +++ b/DosingSystem/Model/ConveyerBeltModel.cs @@ -0,0 +1,52 @@ +using BPA.Helper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.DosingSystem +{ + public class ConveyerBeltModel : NotifyBase + { + public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged(); } } + private string _mName; + + public int Num { get { return _mNum; } set { _mNum = value; OnPropertyChanged(); } } + private int _mNum; + + public int Speed + { + get { return _mSpeed; } + set + { + _mSpeed = value; + if (Num >= 1 && Num <= 32) + { + SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBW{Num * 2 + 132}", value); + } + OnPropertyChanged(); + } + } + private int _mSpeed; + + public bool ConveyerBeltWork + { + get { return _mConveyerBeltWork; } + set + { + _mConveyerBeltWork = value; + if (Num >= 1 && Num <= 32) + { + var add = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", Num, 6); + SiemensDevice.GetInstance.MySiemens.Write(add, !value); + } + OnPropertyChanged(); + } + } + private bool _mConveyerBeltWork; + + public bool Control { get; set; } + + } +} diff --git a/DosingSystem/Model/CylinderStatusModel.cs b/DosingSystem/Model/CylinderStatusModel.cs index 8e94d96b..933851a4 100644 --- a/DosingSystem/Model/CylinderStatusModel.cs +++ b/DosingSystem/Model/CylinderStatusModel.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class CylinderStatusModel : ObservableObject + public class CylinderStatusModel : NotifyBase { /// /// 气缸原点信号 diff --git a/DosingSystem/Model/DeviceCurrentStatus.cs b/DosingSystem/Model/DeviceCurrentStatus.cs index 37ec350b..d77ddc02 100644 --- a/DosingSystem/Model/DeviceCurrentStatus.cs +++ b/DosingSystem/Model/DeviceCurrentStatus.cs @@ -4,11 +4,11 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class DeviceCurrentStatus : ObservableObject + public class DeviceCurrentStatus : NotifyBase { /// /// 当前料仓重量反馈 @@ -17,13 +17,26 @@ namespace BPASmartClient.DosingSystem private double _mWeight; /// - /// 是否正在下料 + /// 重量设置 /// - public bool IsLayOff { get { return _mIsLayOff; } set { _mIsLayOff = value; OnPropertyChanged(); } } - private bool _mIsLayOff; + public float SetWeight { get { return _mSetWeight; } set { _mSetWeight = value; OnPropertyChanged(); } } + private float _mSetWeight; + + ///// + ///// 下料控制 + ///// + //public bool IsLayOff { get { return _mIsLayOff; } set { _mIsLayOff = value; OnPropertyChanged(); } } + //private bool _mIsLayOff; + + /// + /// 下料控制 + /// + public bool BaitingControl { get { return _mBaitingControl; } set { _mBaitingControl = value; OnPropertyChanged(); } } + private bool _mBaitingControl; + /// - /// 设备是否在线 + /// 设备运行状态 /// public bool RunStatus { get { return _mRunStatus; } set { _mRunStatus = value; OnPropertyChanged(); } } private bool _mRunStatus; @@ -52,6 +65,13 @@ namespace BPASmartClient.DosingSystem public bool IsFault { get { return _mIsFault; } set { _mIsFault = value; OnPropertyChanged(); } } private bool _mIsFault; + /// + /// 桶到位检测 + /// + public bool BucketFlagbit { get { return _mBucketFlagbit; } set { _mBucketFlagbit = value; OnPropertyChanged(); } } + private bool _mBucketFlagbit; + + } diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index f928ba15..9d803541 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -81,6 +81,7 @@ namespace BPASmartClient.DosingSystem devices.Add(new Devices() { DeviceName = $"测试设备{i + 1}", + DeviceNum = i + 1, IpAddress = $"192.168.1.{i + 1}", }); } @@ -102,6 +103,7 @@ namespace BPASmartClient.DosingSystem devices.Add(new Devices() { DeviceName = $"测试设备{i + 1}", + DeviceNum = i + 1, IpAddress = $"192.168.1.{i + 1}", }); } @@ -109,11 +111,11 @@ namespace BPASmartClient.DosingSystem public void Init() { - if (!string.IsNullOrEmpty(Json.Data.Address)) IPSegment = Json.Data.Address; - else Json.Data.Address = IPSegment; + if (!string.IsNullOrEmpty(Json.Data.BaseParModel.NetworkSegAddress)) IPSegment = Json.Data.BaseParModel.NetworkSegAddress; + else Json.Data.BaseParModel.NetworkSegAddress = IPSegment; TestData(); IpAddressLines(); - DeviceDataInit(); + //DeviceDataInit(); ThreadManage.GetInstance().StartLong(new Action(() => { if (IPQueues.Count >= IPLists.Count) diff --git a/DosingSystem/Model/GlobalDevice.cs b/DosingSystem/Model/GlobalDevice.cs index 6ba4355c..bbc78b27 100644 --- a/DosingSystem/Model/GlobalDevice.cs +++ b/DosingSystem/Model/GlobalDevice.cs @@ -12,5 +12,21 @@ namespace BPASmartClient.DosingSystem /// PLC 设备数据 /// public static PlcToComputer PlcData { get; set; } = new PlcToComputer(); + + /// + /// 电机速度 + /// + public static ushort[] MotorSpeed { get; set; } = new ushort[32]; + + /// + /// 输送带控制 + /// + public static uint MotorControl { get; set; } + + /// + /// 输送带控制反馈 + /// + public static uint MotorControlFeedback { get; set; } + } } diff --git a/DosingSystem/Model/OutletInfoModel.cs b/DosingSystem/Model/OutletInfoModel.cs index 046e52dd..470115dc 100644 --- a/DosingSystem/Model/OutletInfoModel.cs +++ b/DosingSystem/Model/OutletInfoModel.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; using System.Collections.ObjectModel; namespace BPASmartClient.DosingSystem @@ -11,7 +11,7 @@ namespace BPASmartClient.DosingSystem /// /// 出料口信息 /// - public class OutletInfoModel : ObservableObject + public class OutletInfoModel : NotifyBase { /// /// 出料口名称 diff --git a/DosingSystem/Model/RecipeModel.cs b/DosingSystem/Model/RecipeModel.cs index df6e89b2..cbdb4c7b 100644 --- a/DosingSystem/Model/RecipeModel.cs +++ b/DosingSystem/Model/RecipeModel.cs @@ -6,14 +6,14 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using BPASmartClient.Model; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { /// /// 配方模块 /// - public class RecipeModel : ObservableObject + public class RecipeModel : NotifyBase { [Newtonsoft.Json.JsonIgnore] public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; OnPropertyChanged(); } } diff --git a/DosingSystem/Model/RecipeProcess.cs b/DosingSystem/Model/RecipeProcess.cs index 9de11200..d9f5c708 100644 --- a/DosingSystem/Model/RecipeProcess.cs +++ b/DosingSystem/Model/RecipeProcess.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class RecipeProcess : ObservableObject + public class RecipeProcess : NotifyBase { public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } private string _mRawMaterialName; diff --git a/DosingSystem/Model/SiemensPlc/PlcToComputer.cs b/DosingSystem/Model/SiemensPlc/PlcToComputer.cs index 0bf6dcb9..c1cf465b 100644 --- a/DosingSystem/Model/SiemensPlc/PlcToComputer.cs +++ b/DosingSystem/Model/SiemensPlc/PlcToComputer.cs @@ -11,33 +11,41 @@ namespace BPASmartClient.DosingSystem /// public class PlcToComputer { + public PlcToComputer() + { + for (int i = 0; i < cylinderFlagBitStatus.Length; i++) + { + cylinderFlagBitStatus[i] = new CylinderFlagBitStatus(); + } + } + /// /// 心跳 /// public bool Heartbeat { get; set; } /// - /// 接收完成 + /// 接收配方完成 /// public bool ResComplete { get; set; } /// - /// 系统系统或停止 + /// 系统启动或停止状态 /// public bool SystemStartOrStop { get; set; } /// - /// 手自动切换 + /// 手自动状态 /// public bool HandOrAuto { get; set; } /// /// 桶位置反馈 /// - public int[] LocationFeedback { get; set; } = new int[32]; + public short[] LocationFeedback { get; set; } = new short[32]; /// - /// 是否允许配料 + /// 桶是否允许配料 /// public bool[] IsAllowIngredients { get; set; } = new bool[32]; @@ -45,5 +53,61 @@ namespace BPASmartClient.DosingSystem /// 报警信息 /// public bool[] ArrayInfo { get; set; } = new bool[32]; + + /// + /// 本地急停 + /// + public bool LocalEStop { get; set; } + + /// + /// 远程急停 + /// + public bool RemoteEStop { get; set; } + + /// + /// 上桶工位检测 + /// + public bool OnDetection { get; set; } + + /// + /// 下桶工位检测 + /// + public bool UnderDetection { get; set; } + + /// + /// 上桶工位气缸检测 + /// + public CylinderFlagBitStatus OnCylinderDetection { get; set; } = new CylinderFlagBitStatus(); + + /// + /// 下桶工位气缸检测 + /// + public CylinderFlagBitStatus UnderCylinderDetection { get; set; } = new CylinderFlagBitStatus(); + + /// + /// 工位光电检测 + /// + public bool[] StationDetection { get; set; } = new bool[32]; + + /// + /// 气缸状态信号 + /// + public CylinderFlagBitStatus[] cylinderFlagBitStatus = new CylinderFlagBitStatus[32]; + } + + /// + /// 气缸到位检测类 + /// + public class CylinderFlagBitStatus + { + /// + /// 气缸原点信号 + /// + public bool HomeSignal { get; set; } + + /// + /// 气缸到位信号 + /// + public bool InPlaceSignal { get; set; } } } diff --git a/DosingSystem/Model/StockStatusModel.cs b/DosingSystem/Model/StockStatusModel.cs index 531882fe..16626d7c 100644 --- a/DosingSystem/Model/StockStatusModel.cs +++ b/DosingSystem/Model/StockStatusModel.cs @@ -1,4 +1,4 @@ -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; using System; using System.Collections.Generic; using System.Linq; @@ -7,31 +7,32 @@ using System.Threading.Tasks; namespace BPASmartClient.DosingSystem { - public class StockStatusModel : ObservableObject + public class StockStatusModel : NotifyBase { /// /// 料仓物料重量 /// - private double _materialWeight; public double MaterialWeight { get { return _materialWeight; } set { _materialWeight = value; OnPropertyChanged(); } } + private double _materialWeight; /// /// 料仓物料名称 /// - private string _materialName; public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } } + private string _materialName; /// /// 是否真在运行 /// - private bool _isRunning; public bool IsRunning { get { return _isRunning; } set { _isRunning = value; OnPropertyChanged(); } } + private bool _isRunning; + /// /// 是否正在下料 /// - private bool _isLayOff; public bool IsLayOff { get { return _isLayOff; } set { _isLayOff = value; OnPropertyChanged(); } } + private bool _isLayOff; /// - /// 打开状态 + /// 是否开盖 /// public bool IsOpen { get { return _mIsOpen; } set { _mIsOpen = value; OnPropertyChanged(); } } private bool _mIsOpen; @@ -39,8 +40,18 @@ namespace BPASmartClient.DosingSystem /// /// 是否故障报警 /// + public bool IsFault { get { return _isFault; } set { _isFault = value; OnPropertyChanged(); } } private bool _isFault; - public bool IsFault { get { return _isFault; } set { _isFault = value; OnPropertyChanged(); } } + /// + /// 下料状态 0:未出料 1:出料指令下发 2:出料完成 + /// + public int IssueStatus { get { return _isIssueStatus; } set { _isIssueStatus = value; OnPropertyChanged(); } } + private int _isIssueStatus; + /// + /// 下料重量 + /// + public double IssueWeight { get { return _IssueWeight; } set { _IssueWeight = value; OnPropertyChanged(); } } + private double _IssueWeight; } } diff --git a/DosingSystem/Model/ViewModelBase.cs b/DosingSystem/Model/ViewModelBase.cs index ae5f8e17..b28647bc 100644 --- a/DosingSystem/Model/ViewModelBase.cs +++ b/DosingSystem/Model/ViewModelBase.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; -using Microsoft.Toolkit.Mvvm.Input; +using BPA.Helper; + using System.Collections.ObjectModel; namespace BPASmartClient.DosingSystem { - public class ViewModelBase : ObservableObject + public class ViewModelBase : NotifyBase { public int Index { get; set; } = -1; public RelayCommand AddCommand { get; set; }//添加 diff --git a/DosingSystem/Model/par/BasePar.cs b/DosingSystem/Model/par/BasePar.cs new file mode 100644 index 00000000..fb9f0b57 --- /dev/null +++ b/DosingSystem/Model/par/BasePar.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BPA.Helper; + +namespace BPASmartClient.DosingSystem +{ + /// + /// 基础参数 + /// + public class BasePar : NotifyBase + { + /// + /// 设备扫描网段 + /// + public string NetworkSegAddress { get { return _mNetworkSegAddress; } set { _mNetworkSegAddress = value; OnPropertyChanged(); } } + private string _mNetworkSegAddress = "192.168.0."; + + /// + /// 输送带设备 PLC IP 地址 + /// + public string DeviceAddress { get { return _mDeviceAddress; } set { _mDeviceAddress = value; OnPropertyChanged(); } } + private string _mDeviceAddress = "192.168.0.1"; + + /// + /// 输送带数量 + /// + public int ConveyerBeltCount + { + get { return _mConveyerBeltCount; } + set + { + _mConveyerBeltCount = value; + //var temp = ConveyerBeltModels; + //App.Current.Dispatcher.Invoke(() => { ConveyerBeltModels.Clear(); }); + //for (int i = 0; i < value; i++) + //{ + // App.Current.Dispatcher.Invoke(() => + // { + // ConveyerBeltModels.Add(new ConveyerBeltModel() + // { + // Name = $"输送带{i + 1}速度", + // Num = i + 1, + // Speed = (i >= 0 && i < temp.Count) ? temp.ElementAt(i).Speed : 0 + // }); + // }); + //} + OnPropertyChanged(); + } + } + private int _mConveyerBeltCount = 0; + + /// + /// 升降气缸数量 + /// + public int LiftCylinderCount { get { return _mLiftCylinderCount; } set { _mLiftCylinderCount = value; OnPropertyChanged(); } } + private int _mLiftCylinderCount = 0; + + /// + /// 阻挡气缸数量 + /// + public int BlockCylinderCount { get { return _mBlockCylinderCount; } set { _mBlockCylinderCount = value; OnPropertyChanged(); } } + private int _mBlockCylinderCount = 0; + + /// + /// 托盘气缸数量 + /// + public int PalletCylinderCount { get { return _mPalletCylinderCount; } set { _mPalletCylinderCount = value; OnPropertyChanged(); } } + private int _mPalletCylinderCount = 0; + + //public ObservableCollection ConveyerBeltModels { get; set; } = new ObservableCollection(); + + } +} diff --git a/DosingSystem/Model/par/DevicePar.cs b/DosingSystem/Model/par/DevicePar.cs index 61e7bf74..899ec930 100644 --- a/DosingSystem/Model/par/DevicePar.cs +++ b/DosingSystem/Model/par/DevicePar.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; using System.Collections.ObjectModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class DevicePar + public class DevicePar : NotifyBase { /// /// 配料设备参数 @@ -17,30 +17,9 @@ namespace BPASmartClient.DosingSystem public ObservableCollection OutletInfoModels { get; set; } = new ObservableCollection(); - /// - /// 设备扫描网段 - /// - public string Address { get; set; } = string.Empty; - /// - /// 设备端口号 - /// - public int Port { get; set; } = 502; - - /// - /// 升降气缸数量 - /// - public int LiftCylinderCount { get; set; } - - /// - /// 阻挡气缸数量 - /// - public int BlockCylinderCount { get; set; } - - /// - /// 托盘气缸数量 - /// - public int PalletCylinderCount { get; set; } + public BasePar BaseParModel { get { return _mBaseParModel; } set { _mBaseParModel = value; OnPropertyChanged(); } } + private BasePar _mBaseParModel = new BasePar(); } } diff --git a/DosingSystem/Model/par/DeviceParModel.cs b/DosingSystem/Model/par/DeviceParModel.cs index c9dfe67f..d7a0d5f3 100644 --- a/DosingSystem/Model/par/DeviceParModel.cs +++ b/DosingSystem/Model/par/DeviceParModel.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class DeviceParModel : ObservableObject + public class DeviceParModel : NotifyBase { /// /// 原料名称 diff --git a/DosingSystem/Service/SiemensDevice.cs b/DosingSystem/Service/SiemensDevice.cs index dd53f713..90315ec0 100644 --- a/DosingSystem/Service/SiemensDevice.cs +++ b/DosingSystem/Service/SiemensDevice.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Threading.Tasks; using BPASmartClient.S7Net; using BPA.Helper; +using S7.Net; namespace BPASmartClient.DosingSystem { @@ -30,18 +31,54 @@ namespace BPASmartClient.DosingSystem bool tempValue = false; ThreadManage.GetInstance().StartLong(new Action(() => { - if (IsConnect) MySiemens.Write("DB4.DBX0.0", !tempValue); + if (IsConnect) MySiemens.Write("DB4.DBX0.0", tempValue);//设备心跳 + tempValue = !tempValue; Thread.Sleep(1); }), "设备心跳", true); ThreadManage.GetInstance().StartLong(new Action(() => { - GlobalDevice.PlcData = MySiemens.ReadClass(3); + //GlobalDevice.PlcData = MySiemens.ReadClass(3);//获取PLC到上位机的数据 + var res = MySiemens.Read(DataType.DataBlock, 4, 134, VarType.Word, 32); + if (res != null && res is ushort[] ushorts && ushorts.Length == 32) + { + GlobalDevice.MotorSpeed = ushorts; + } + GlobalDevice.MotorControl = MySiemens.Read("DB5.DBD6");//获取输送带控制信号 + //GlobalDevice.MotorControlFeedback = MySiemens.Read("DB3.DBD0");//获取当前输送带运行状态 Thread.Sleep(50); }), "读取输送线设备数据", true); } + /// + /// 通过顺序编号获取西门子数据地址 + /// + /// 地址标头 + /// 编号 + /// 起始地址 + /// + public string GetSiemensBitSingleAdd(string Prefix, int num, int StartAdd = 0) + { + if (num > 0) + { + string Add = string.Empty; + var FirstAdd = num / 8; + var EndAdd = (num % 8); + if (EndAdd == 0) + { + FirstAdd--; + EndAdd = 7; + } + else EndAdd--; + Add = $"{Prefix}{FirstAdd + StartAdd}.{EndAdd}"; + return Add; + } + return default; + + + } + } diff --git a/DosingSystem/View/CommParSetView.xaml b/DosingSystem/View/CommParSetView.xaml index f6b2a380..e12528e4 100644 --- a/DosingSystem/View/CommParSetView.xaml +++ b/DosingSystem/View/CommParSetView.xaml @@ -22,94 +22,200 @@ - - - - + + + +