diff --git a/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj b/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj index 190af161..f442881c 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 729ab884..53196873 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 ce7c3363..c47c5a34 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 c633d45b..caac5a94 100644 --- a/BPASmart.VariableManager/BPASmart.VariableManager.csproj +++ b/BPASmart.VariableManager/BPASmart.VariableManager.csproj @@ -30,7 +30,7 @@ - + diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj index 25dfbd1c..0d77ddd4 100644 --- a/BPASmartClient.Business/BPASmartClient.Business.csproj +++ b/BPASmartClient.Business/BPASmartClient.Business.csproj @@ -8,7 +8,7 @@ - + diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index 609d0a2a..86047719 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -409,7 +409,7 @@ - + diff --git a/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs b/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs index f0688f09..4e15c59e 100644 --- a/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs +++ b/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs @@ -81,7 +81,7 @@ namespace BPASmartClient.CustomResource.Pages.Model catch (Exception) { - // throw; + // throw; } } } @@ -109,34 +109,40 @@ namespace BPASmartClient.CustomResource.Pages.Model public bool ShowDialog(string info, DialogType dialogType = DialogType.Information) { - PromptView PV = new PromptView(); - PV.TextBlockInfo = info; - switch (dialogType) + bool result = false; + Application.Current.Dispatcher.Invoke(() => { - case DialogType.Warning: - PV.TextBlockIcon = ""; - PV.TextBlockForeground = Brushes.Yellow; - PV.infoType.Text = "警告:"; - //PV.Cancel.Visibility = Visibility.Collapsed; - break; - case DialogType.Error: - PV.TextBlockIcon = ""; - PV.TextBlockForeground = Brushes.Red; - PV.infoType.Text = "错误:"; - //PV.Cancel.Visibility = Visibility.Collapsed; - break; - case DialogType.Information: - PV.TextBlockIcon = ""; - PV.TextBlockForeground = Brushes.DeepSkyBlue; - PV.infoType.Text = "提示:"; - //PV.Cancel.Visibility = Visibility.Visible; - break; - default: - break; - } - PV.infoType.Foreground = PV.TextBlockForeground; - var res = PV.ShowDialog(); - return res == null ? false : (bool)res; + PromptView PV = new PromptView(); + PV.TextBlockInfo = info; + switch (dialogType) + { + case DialogType.Warning: + PV.TextBlockIcon = ""; + PV.TextBlockForeground = Brushes.Yellow; + PV.infoType.Text = "警告:"; + //PV.Cancel.Visibility = Visibility.Collapsed; + break; + case DialogType.Error: + PV.TextBlockIcon = ""; + PV.TextBlockForeground = Brushes.Red; + PV.infoType.Text = "错误:"; + //PV.Cancel.Visibility = Visibility.Collapsed; + break; + case DialogType.Information: + PV.TextBlockIcon = ""; + PV.TextBlockForeground = Brushes.DeepSkyBlue; + PV.infoType.Text = "提示:"; + //PV.Cancel.Visibility = Visibility.Visible; + break; + default: + break; + } + PV.infoType.Foreground = PV.TextBlockForeground; + + var res = PV.ShowDialog(); + result = res == null ? false : (bool)res; + }); + return result; } } diff --git a/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml b/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml index 79e65167..55ea5e43 100644 --- a/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml +++ b/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml @@ -83,7 +83,7 @@ Duration="0:0:20" /> - + @@ -96,6 +96,7 @@ Duration="0:0:20" /> + 100) { pathFigure.StartPoint = new Point(0, 35 + (BeltHeight - 100) / 2); - pathFigure.Segments.Add(new LineSegment(new Point(BeltWidth - 10, 35 + (BeltHeight - 100)/2), true)); + pathFigure.Segments.Add(new LineSegment(new Point(BeltWidth - 10, 35 + (BeltHeight - 100) / 2), true)); } else { @@ -74,7 +89,7 @@ namespace BPASmartClient.CustomResource.UserControls { this.recDown.Margin = new Thickness(0, BeltHeight - 20, 0, 0); } - else + else { this.recDown.Margin = new Thickness(0, 80, 0, 0); } @@ -115,15 +130,29 @@ namespace BPASmartClient.CustomResource.UserControls private static void OnDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - - if ((d as ConveyBelt2)?.BeltDirection == 0) - { - VisualStateManager.GoToState(d as ConveyBelt2, "RightState", false); - } - else + string status = "Stop"; + if ((d as ConveyBelt2).IsRun) { - VisualStateManager.GoToState(d as ConveyBelt2, "LeftState", false); + if ((d as ConveyBelt2)?.BeltDirection == 0) + { + VisualStateManager.GoToState(d as ConveyBelt2, "RightState", false); + return; + } + else + { + VisualStateManager.GoToState(d as ConveyBelt2, "LeftState", false); + return; + } } + VisualStateManager.GoToState(d as ConveyBelt2, status, false); + //if ((d as ConveyBelt2)?.BeltDirection == 0) + //{ + // VisualStateManager.GoToState(d as ConveyBelt2, "RightState", false); + //} + //else + //{ + // VisualStateManager.GoToState(d as ConveyBelt2, "LeftState", false); + //} } } diff --git a/BPASmartClient.DosingSystemSingle/App.xaml b/BPASmartClient.DosingSystemSingle/App.xaml index 7fb508f6..49315c62 100644 --- a/BPASmartClient.DosingSystemSingle/App.xaml +++ b/BPASmartClient.DosingSystemSingle/App.xaml @@ -1,4 +1,5 @@ - - + diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs index a35d57c1..090121ed 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs @@ -170,7 +170,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料 /// - public int RecipeStatusIDTray2 { get; set; } = 0; + public int[] RecipeProcessStatus { get; set; } = new int[5] { 0, 0, 0, 0, 0 }; + [VarComm("Global", "当前配方正在配料位置")] /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs index f03fda0e..f90bd07f 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using BPASmartClient.S7Net; using BPASmartClient.CustomResource.Pages.Model; using System.Threading; +using System.Collections.ObjectModel; namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC { @@ -188,5 +189,41 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC } } } + + public void IssueRecipeToPlc(ObservableCollection rawMaterials,int recipeLoction) + { + if (IsConnected) + { + ushort barrel1 = 0; + ushort barrel2 = 0; + ushort barrel3 = 0; + foreach (var item in rawMaterials) + { + switch (item.RawMaterialBarrelNum) + { + case 1: + barrel1 = barrel1.SetBitValue((byte)item.RawMaterialLocation, true); + break; + case 2: + barrel2 = barrel2.SetBitValue((byte)item.RawMaterialLocation, true); + break; + case 3: + barrel3 = barrel3.SetBitValue((byte)item.RawMaterialLocation, true); + break; + default: + break; + } + } + string AddresBarrel1 = "DB4.DBW" + (12 + (recipeLoction - 1) * 6); + string AddresBarrel2 = "DB4.DBW" + (14 + (recipeLoction - 1) * 6); + string AddresBarrel3 = "DB4.DBW" + (16 + (recipeLoction - 1) * 6); + HK_PLC_S7.Write(AddresBarrel1, barrel1); + HK_PLC_S7.Write(AddresBarrel2, barrel2); + HK_PLC_S7.Write(AddresBarrel3, barrel3); + MessageNotify.GetInstance.ShowRunLog($"配方下发,plc配方位置{recipeLoction},桶1料仓配料{barrel1.ToBinString}"); + MessageNotify.GetInstance.ShowRunLog($"配方下发,plc配方位置{recipeLoction},桶2料仓配料{barrel1.ToBinString}"); + MessageNotify.GetInstance.ShowRunLog($"配方下发,plc配方位置{recipeLoction},桶3料仓配料{barrel1.ToBinString}"); + } + } } -} +} \ No newline at end of file diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index 258093e6..863094fb 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -38,8 +38,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// 配方队列 /// public ConcurrentQueue RecipeQueueTray1 = new ConcurrentQueue(); + public ConcurrentQueue RecipeQueueTray2 = new ConcurrentQueue(); + + public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); public HKDeviceStatus HKDevice = new HKDeviceStatus(); public WindSendDeviceStatus WindSendDevice = new WindSendDeviceStatus(); diff --git a/BPASmartClient.JakaRobot/JaKaHelper.cs b/BPASmartClient.JakaRobot/JaKaHelper.cs index 85c0ce2f..046ccc43 100644 --- a/BPASmartClient.JakaRobot/JaKaHelper.cs +++ b/BPASmartClient.JakaRobot/JaKaHelper.cs @@ -1,5 +1,7 @@ using BPASmartClient.Helper; using BPASmartClient.Message; +using System.Net; +using System.Net.NetworkInformation; using System.Text; namespace BPASmartClient.JakaRobot @@ -60,7 +62,7 @@ namespace BPASmartClient.JakaRobot //public const string SENCE_初始位 = "20000"; #endregion - private int rshd = -1; + public int rshd = -1; private bool login = false; /// @@ -74,49 +76,124 @@ namespace BPASmartClient.JakaRobot public bool IsIdle { get; set; } = false; public bool IsConnected { get { return login; } } public bool IsDeviceFirstInit { get; set; } + private string IpAddress { get; set; } + private bool IsPingOk { get; set; } + + public void Conn(string ip) + { + jakaAPI.create_handler(ip.ToCharArray(), ref rshd); + login = true; + } public void Connect(string ip) { - bool ErrorFlag = false; - ThreadManage.GetInstance().StartLong(new Action(() => + MessageLog.GetInstance.Show("节卡机器人连接中。。。。。"); + IpAddress = ip; + Task.Factory.StartNew(() => { - if (rshd == -1 || login == false) + while (!IsPingOk) { - try - { - jakaAPI.create_handler(ip.ToCharArray(), ref rshd); - login = true; - } - catch (Exception ex) - { - if (!ErrorFlag) - { - MessageLog.GetInstance.ShowEx(ex.ToString()); - ErrorFlag = true; - login = false; - } - Thread.Sleep(3000); - } + Ping myPing = new Ping(); + myPing.PingCompleted += new PingCompletedEventHandler(_myPing_PingCompleted); + myPing.SendAsync(IpAddress, 1000, null); + Thread.Sleep(3000); } - if (login && IsDeviceFirstInit==false) + }); + + + //bool ErrorFlag = false; + //ThreadManage.GetInstance().StartLong(new Action(() => + //{ + // if (rshd == -1 || login == false) + // { + // try + // { + // jakaAPI.create_handler(ip.ToCharArray(), ref rshd); + // login = true; + // } + // catch (Exception ex) + // { + // if (!ErrorFlag) + // { + // MessageLog.GetInstance.ShowEx(ex.ToString()); + // ErrorFlag = true; + // login = false; + // } + // Thread.Sleep(3000); + // } + // } + // if (login && IsDeviceFirstInit == false) + // { + // try + // { + // Power_On();//打开机器人电源 + // Thread.Sleep(1000); + // Enable_robot();//机器人上使能 + // IsDeviceFirstInit = true; + // MessageLog.GetInstance.Show("机器人已上电使能"); + // } + // catch (Exception ex) + // { + // MessageLog.GetInstance.ShowEx("机器人未完成上电和使能"); + // } + // } + // Thread.Sleep(5000); + //}), $"节卡机器人连接", true); + + } + + private void _myPing_PingCompleted(object sender, PingCompletedEventArgs e) + { + if (e.Reply != null && e.Reply.Status == IPStatus.Success) + { + IsPingOk = true; + MessageLog.GetInstance.Show("节卡机器人物理网络准备就绪"); + Thread.Sleep(3000); + bool ErrorFlag = false; + ThreadManage.GetInstance().StartLong(new Action(() => { - try + if (rshd == -1 || login == false) { - Power_On();//打开机器人电源 - Thread.Sleep(1000); - Enable_robot();//机器人上使能 - IsDeviceFirstInit = true; - MessageLog.GetInstance.Show("机器人已上电使能"); + try + { + int result = jakaAPI.create_handler(IpAddress.ToCharArray(), ref rshd); + login = true; + MessageLog.GetInstance.Show($"节卡机器人创建连接成功,句柄:{rshd},返回值:{result}"); + } + catch (Exception ex) + { + if (!ErrorFlag) + { + MessageLog.GetInstance.ShowEx(ex.ToString()); + ErrorFlag = true; + login = false; + } + Thread.Sleep(3000); + } } - catch (Exception ex) + if (login && IsDeviceFirstInit == false) { - MessageLog.GetInstance.ShowEx("机器人未完成上电和使能"); + try + { + MessageLog.GetInstance.Show("节卡机器人打开电源准备"); + Thread.Sleep(2000); + Power_On();//打开机器人电源 + Thread.Sleep(1000); + MessageLog.GetInstance.Show("节卡机器人上使能准备"); + Enable_robot();//机器人上使能 + IsDeviceFirstInit = true; + MessageLog.GetInstance.Show("机器人已上电使能"); + } + catch (Exception ex) + { + MessageLog.GetInstance.ShowEx("机器人未完成上电和使能"); + } } - } - Thread.Sleep(5000); - }), $"节卡机器人连接", true); - + Thread.Sleep(5000); + }), $"节卡机器人连接", true); + } } + public void Power_On() { if (login) @@ -129,10 +206,10 @@ namespace BPASmartClient.JakaRobot { MessageLog.GetInstance.ShowEx(ave.ToString()); } - //catch (Exception ex) - //{ - // MessageLog.GetInstance.ShowEx(ex.ToString()); - //} + catch (Exception ex) + { + MessageLog.GetInstance.ShowEx(ex.ToString()); + } } else { @@ -324,8 +401,8 @@ namespace BPASmartClient.JakaRobot { try { - //加载 - p: file = Programname.ToCharArray(); + //加载 + p: file = Programname.ToCharArray(); MessageLog.GetInstance.Show($"调用文件名:{Programname}"); status = new JKTYPE.ProgramState(); jakaAPI.get_program_state(ref rshd, ref status); diff --git a/BPASmartClient.Model/GlobalFoodMenu.cs b/BPASmartClient.Model/GlobalFoodMenu.cs deleted file mode 100644 index 73bdd544..00000000 --- a/BPASmartClient.Model/GlobalFoodMenu.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.Model -{ - public class GlobalFoodMenu - { - public static ObservableCollection LocalFoodMenus = new ObservableCollection(); - } -} diff --git a/BPASmartClient.Model/小炒机/MaterialAndFryingTime.cs b/BPASmartClient.Model/小炒机/MaterialAndFryingTime.cs new file mode 100644 index 00000000..dba43182 --- /dev/null +++ b/BPASmartClient.Model/小炒机/MaterialAndFryingTime.cs @@ -0,0 +1,15 @@ +using BPA.Models; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.小炒机 +{ + public class MaterialAndFryingTime + { + public Dictionary> materials { get; set; } = new Dictionary>(); + } +} diff --git a/BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj b/BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj index 14337820..163b8885 100644 --- a/BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj +++ b/BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj @@ -13,6 +13,7 @@ + diff --git a/BPASmartClient.MorkBF/Control_MorkBF.cs b/BPASmartClient.MorkBF/Control_MorkBF.cs index d720c09a..a87d88f7 100644 --- a/BPASmartClient.MorkBF/Control_MorkBF.cs +++ b/BPASmartClient.MorkBF/Control_MorkBF.cs @@ -9,6 +9,7 @@ using BPASmartClient.Model; using BPASmartClient.Model.大炒; using BPASmartClient.MorkBF.Model; using BPASmartClient.MorkBF.ViewModel; +using BPASmartClient.ViewModel; using System; using System.Collections.Generic; using System.Linq; @@ -36,14 +37,14 @@ namespace BPASmartClient.MorkBF MonitorViewModel.DeviceId = DeviceId; ActionManage.GetInstance.Register(new Action(() => { - GlobalFoodMenu.LocalFoodMenus.Clear(); - if (BPASmartClient.Helper.Json.Data.FryPotMessage.Count > 0) - { - foreach (var item in BPASmartClient.Helper.Json.Data.FryPotMessage) - { - GlobalFoodMenu.LocalFoodMenus.Add(new FoodMenuModel { GoodKey = item.GoodKey, GoodName = item.GoodName }); - } - } + //GlobalFoodMenu.LocalFoodMenus.Clear(); + //if (BPASmartClient.Helper.Json.Data.FryPotMessage.Count > 0) + //{ + // foreach (var item in BPASmartClient.Helper.Json.Data.FryPotMessage) + // { + // GlobalFoodMenu.LocalFoodMenus.Add(new FoodMenuModel { GoodKey = item.GoodKey, GoodName = item.GoodName }); + // } + //} }), "更新菜单"); CommandRegist();//调试 ServerInit(); @@ -1022,7 +1023,7 @@ namespace BPASmartClient.MorkBF WorkStatus_1 = morkBF.FryPan1_TemperatureNow > 0 ? WorkStatus.工作 : WorkStatus.待机, WorkStatus_2 = morkBF.FryPan2_TemperatureNow > 0 ? WorkStatus.工作 : WorkStatus.待机, RobotStatu = WorkStatus.工作, - Alarm = new List(), + Alarm = new List(), FailuresCount = 0, StatsCount = statsModels, MaxWok_Dishes_1 = "满汉全席", diff --git a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj index d4750439..ac69f6eb 100644 --- a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj +++ b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj @@ -18,6 +18,7 @@ + diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs index 2d687cdf..db339e8e 100644 --- a/BPASmartClient.MorkF/Control_MorkF.cs +++ b/BPASmartClient.MorkF/Control_MorkF.cs @@ -1,4 +1,5 @@ using BPA.Message; +using System; using BPA.Message.Enum; using BPASmartClient.Device; using BPASmartClient.EventBus; @@ -16,6 +17,8 @@ using System.Windows.Documents; using BPASmartClient.Business; using Microsoft.CodeAnalysis; using BPASmartClient.MorkF.ViewModel; +using BPASmartClient.ViewModel; +using System.Windows; namespace BPASmartClient.MorkF { @@ -35,7 +38,7 @@ namespace BPASmartClient.MorkF /// /// 菜品库while循环最大sleep次数 /// - private const int materialSleepCount = 900; + private const int materialSleepCount = 600; /// /// 菜品库while循环每次sleep时间 @@ -50,40 +53,40 @@ namespace BPASmartClient.MorkF /// /// 菜品盒下移高度,相对于坐标系 /// - private const int materialBoxHigh = 4080; + //private const int materialBoxHigh = 4080; - //菜品库出餐高度 - private const int materialHigh = 33000; + ////菜品库出餐高度 + //private const int materialHigh = 33000; - //传感器到菜品库的高度(坐标系) - private const int materialLaserHigh = 34500; + ////传感器到菜品库的高度(坐标系) + //private const int materialLaserHigh = 34500; /// /// 菜品盒坐标系高度 /// - private const int materialBoxHeight = 9500; + private const int materialBoxHeight = 9700; //传感器1到菜品库的高度(厘米) - private const int materialLaserHighCM_1 = 22; + //private const int materialLaserHighCM_1 = 22; - //传感器2到菜品库的高度(厘米) - private const int materialLaserHighCM_2 = 27; + ////传感器2到菜品库的高度(厘米) + //private const int materialLaserHighCM_2 = 27; - //传感器3到菜品库的高度(厘米) - private const int materialLaserHighCM_3 = 31; + ////传感器3到菜品库的高度(厘米) + //private const int materialLaserHighCM_3 = 31; /// /// 传感器到隔板的距离(坐标系) /// private const int clapboardLaserHigh = 10000; - //炒锅1倒菜的xy坐标 - private const int materialPutPositionXFry1 = 70000; - private const int materialPutPositionYFry1 = 40000; + ////炒锅1倒菜的xy坐标 + //private const int materialPutPositionXFry1 = 70000; + //private const int materialPutPositionYFry1 = 40000; - //炒锅2倒菜的xy坐标 - private const int materialPutPositionXFry2 = 70000; - private const int materialPutPositionYFry2 = 40000; + ////炒锅2倒菜的xy坐标 + //private const int materialPutPositionXFry2 = 70000; + //private const int materialPutPositionYFry2 = 40000; //菜品库机械爪放置菜品距离 private const int materialToFryDistance = 10000; @@ -146,7 +149,7 @@ namespace BPASmartClient.MorkF /// /// 告警列表 /// - private List alarmModel = new List(); + private List alarmModel = new List(); /// /// @@ -201,7 +204,7 @@ namespace BPASmartClient.MorkF MaterialCoordinate.GetInstance().frying2 = materialCoordinate.frying2; MaterialCoordinate.GetInstance().materialHeight = materialCoordinate.materialHeight; MaterialCoordinate.GetInstance().MaterialOneX = materialCoordinate.MaterialOneX; - MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX; + MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX; MaterialCoordinate.GetInstance().MaterialThreeX = materialCoordinate.MaterialThreeX; } ////菜品库编号与坐标系对象存储 @@ -346,7 +349,15 @@ namespace BPASmartClient.MorkF ml_morkf.PawArrivePortThree = bools[2]; } }), 2); - + //获取爪子伸出退回到位 + GetStatus("M10.6", new Action((objects) => + { + if (objects is bool[] bools && bools.Length == 2) + { + ml_morkf.PawOutComplete = bools[0]; + ml_morkf.PawInComplete = bools[1]; + } + }), 2); //获取总初始化完成 GetStatus("M10.2", new Action((objects) => { @@ -396,7 +407,6 @@ namespace BPASmartClient.MorkF ActionManage.GetInstance.Register(PLCInite, "InitCommand"); ActionManage.GetInstance.Register(StartOrder, "StartOrder"); ActionManage.GetInstance.Register(StartOrderMain, "开始下单"); - ActionManage.GetInstance.Register(StartLocalOrder, "StartLocalOrder"); ActionManage.GetInstance.Register(StopLocalOrder, "StopLocalOrder"); ActionManage.GetInstance.Register(new Action((o) => { @@ -478,8 +488,21 @@ namespace BPASmartClient.MorkF GetDistance_3(); }), "GetDistance_3"); }), "GetDistance_3"); - ActionManage.GetInstance.Register(PawExtend, "PawTurnFront"); - ActionManage.GetInstance.Register(PawShrink, "PawTurnBack"); + ActionManage.GetInstance.Register(new Action(() => + { + ThreadManage.GetInstance().Start(new Action(() => + { + PawExtend(); + }), "PawTurnFront"); + }), "PawTurnFront"); + + ActionManage.GetInstance.Register(new Action(() => + { + ThreadManage.GetInstance().Start(new Action(() => + { + PawShrink(); + }), "PawTurnBack"); + }), "PawTurnBack"); ActionManage.GetInstance.Register(new Action((list) => { ThreadManage.GetInstance().Start(new Action(() => @@ -704,7 +727,7 @@ namespace BPASmartClient.MorkF } /// - /// 本地菜单下单 + /// 根据菜品ID下单 /// private void StartOrder(object o) { @@ -728,44 +751,42 @@ namespace BPASmartClient.MorkF } /// - /// 本地菜单下单 + /// 主界面本地菜单下单 /// private void StartOrderMain(object o) { if (o == null) return; - if (o is string goodId) - { - var res = LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey.ToString() == goodId);//匹配订单对应制作流程 - if (res != null) - { - /* morkF.listStirBom.Add(res.StirFryBomInfo);*///添加订单制作流程 - if (StirFryGoodsQuenes.Count > 0) return; - StirFryGoodsQuenes.Enqueue(new OrderLocInfo() - { - SuborderId = Guid.NewGuid().ToString(), - StirPotActions = res.StirPotActions, - GoodName = "本地菜品" - }); - MessageLog.GetInstance.Show($"添加本地订单{res.GoodsKey}"); - } - } - } + //if (o is FoodMenuModel good) + //{ + // NewStartLocalOrder(good.GoodName); + //} - private void StartLocalOrder() - { - if (StirFryGoodsQuenes.Count > 0) return;//只能一个一个做 - if (Json.Data.LocalstirFryGoods.StirPotActions.Count > 0) - { - StirFryGoodsQuenes.Enqueue(new OrderLocInfo() - { - SuborderId = Guid.NewGuid().ToString(), - StirPotActions = Json.Data.LocalstirFryGoods.StirPotActions, - GoodName = "本地菜品" - }); - MessageLog.GetInstance.Show($"添加本地模拟的订单{Json.Data.LocalstirFryGoods.GoodsKey}"); - } + + //if (o == null) return; + //if (o is string goodId) + //{ + // var res = LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey.ToString() == goodId);//匹配订单对应制作流程 + // if (res != null) + // { + // /* morkF.listStirBom.Add(res.StirFryBomInfo);*///添加订单制作流程 + // if (StirFryGoodsQuenes.Count > 0) return; + // StirFryGoodsQuenes.Enqueue(new OrderLocInfo() + // { + // SuborderId = Guid.NewGuid().ToString(), + // StirPotActions = res.StirPotActions, + // GoodName = "本地菜品" + // }); + // MessageLog.GetInstance.Show($"添加本地订单{res.GoodsKey}"); + // } + //} } + + + /// + /// 本地配置的订单 + /// + /// private void NewStartLocalOrder(string materialName) { //if (StirFryGoodsQuenes.Count > 0) return;//只能一个一个做 @@ -800,6 +821,7 @@ namespace BPASmartClient.MorkF GoodName = materialName }); MessageLog.GetInstance.Show($"添加本地模拟的订单{Json.Data.LocalstirFryGoods.GoodsKey}"); + MessageBox.Show("下单成功"); } } @@ -968,33 +990,54 @@ namespace BPASmartClient.MorkF /// 爪子伸出 /// /// 电磁阀启停:true:启动。false:停止。 - public void PawExtend() + public bool PawExtend() { if (!ml_morkf.InitialComplete) { MessageLog.GetInstance.ShowEx("爪子伸出错误,菜品库未初始化"); - return; + return false; } - + Thread.Sleep(500); MaterailLibrary_Write("M0.6", true); - //等待爪子伸出延时4s - Thread.Sleep(6000); + for (int i = 0; i < materialSleepCount && !ml_morkf.PawOutComplete; i++)//潘华小炒没有夹爪到位功能 + { + Thread.Sleep(materialSleepTime); + if (i >= materialSleepCount - 1) + { + MessageLog.GetInstance.ShowEx("爪子伸出超时"); + return false; + } + } + return true; + ////等待爪子伸出延时4s + //Thread.Sleep(6000); } /// /// 爪子收缩 /// /// 电磁阀启停:true:启动。false:停止。 - public void PawShrink() + public bool PawShrink() { if (!ml_morkf.InitialComplete) { MessageLog.GetInstance.ShowEx("爪子伸出错误,菜品库未初始化"); - return; + return false; } MaterailLibrary_Write("M0.7", true); + Thread.Sleep(500); + for (int i = 0; i < materialSleepCount && !ml_morkf.PawInComplete; i++)//潘华小炒没有夹爪到位功能 + { + Thread.Sleep(materialSleepTime); + if (i >= materialSleepCount - 1) + { + MessageLog.GetInstance.ShowEx("爪子伸出超时"); + return false; + } + } + return true; //等待爪子收缩延时4s - Thread.Sleep(6000); + //Thread.Sleep(6000); } /// /// 电磁阀启停 @@ -1033,6 +1076,10 @@ namespace BPASmartClient.MorkF Thread.Sleep(materialSleepTime); if (i >= materialSleepCount - 1) { + if (i == 10) + { + MaterailLibrary_Write("M1.0", true); + } MessageLog.GetInstance.ShowEx("爪子去到1号位超时"); return false; } @@ -1063,6 +1110,10 @@ namespace BPASmartClient.MorkF Thread.Sleep(materialSleepTime); if (i >= materialSleepCount - 1) { + if (i == 10) + { + MaterailLibrary_Write("M1.1", true); + } MessageLog.GetInstance.ShowEx("爪子去到2号位超时"); return false; } @@ -1090,10 +1141,14 @@ namespace BPASmartClient.MorkF for (int i = 0; i < materialSleepCount && !ml_morkf.PawArrivePortThree; i++) { Thread.Sleep(materialSleepTime); + if(i == 30) + { + MaterailLibrary_Write("M1.2", true); + } if (i >= materialSleepCount - 1) { MessageLog.GetInstance.ShowEx("爪子去到3号位超时"); - return false; + } } if (!ml_morkf.PawPositon_3) @@ -1243,6 +1298,12 @@ namespace BPASmartClient.MorkF return false; } + if (x>212000|| y >240000) + { + MessageLog.GetInstance.ShowEx("机械臂移动超出范围"); + return false; + } + //取反 x = 0 - Math.Abs(x); y = 0 - Math.Abs(y); @@ -1285,7 +1346,7 @@ namespace BPASmartClient.MorkF //MessageLog.GetInstance.Show("机械臂移动操作完成"); - Thread.Sleep(500); + Thread.Sleep(300); return true; } @@ -1374,9 +1435,9 @@ namespace BPASmartClient.MorkF Thread.Sleep(1000); //获取传感器的距离,转换成坐标系的点 - //int laserHigh = ml_morkf.LaserDistance; + int laserHigh = ml_morkf.LaserDistance; - int laserHigh = 400; + //秦工要求读取后置0 WriteDistance(0); @@ -1396,7 +1457,7 @@ namespace BPASmartClient.MorkF } //设置到传感器感应的距离处 - if (!SetArmPosition(x, y)) + if (!SetArmPosition(x - moveX, y)) { return false; } @@ -1414,7 +1475,11 @@ namespace BPASmartClient.MorkF } //伸出爪子 - PawExtend(); + if (!PawExtend()) + { + return false; + } + //移动前开启电磁阀 Electromagnetism(new List { false }); @@ -1461,16 +1526,18 @@ namespace BPASmartClient.MorkF return false; } - WriteSpeed(50000); + WriteSpeed(50000);//移动速度 //ThreadManage.GetInstance().Start(new Action(() => //{ // //收缩爪子 // PawShrink(); //}), "GetMaterialPawShrink"); - PawShrink(); + + //收缩爪子 + if (!PawShrink()) return false; //判断炒锅是否可以放盒 - for (int i = 0; materialSleepCount > i && !morkFs[fryIndex].FryPot1_HOBTPut; i++) + for (int i = 0; materialSleepCount > i && !morkFs[fryNum].FryPot1_HOBTPut; i++) { Thread.Sleep(materialSleepTime); if (i >= materialSleepCount - 1) @@ -1520,8 +1587,12 @@ namespace BPASmartClient.MorkF return false; } + //伸出爪子 - PawExtend(); + if (!PawExtend()) + { + return false; + } Thread.Sleep(300); @@ -1530,7 +1601,7 @@ namespace BPASmartClient.MorkF Thread.Sleep(300); //收缩爪子 - PawShrink(); + if (!PawShrink()) return false; //设置到炒锅i出菜处 if (!SetArmPosition(x + materialToFryDistance, y)) @@ -1578,10 +1649,13 @@ namespace BPASmartClient.MorkF Electromagnetism(new List { true }); //爪子收回 - PawShrink(); + if (!PawShrink()) + { + return false; + } //爪子去2号点位 - if(!PawToPoint2()) + if (!PawToPoint2()) { return false; } @@ -1670,8 +1744,10 @@ namespace BPASmartClient.MorkF Laser2CoordinateState laser2CoordinateState = LaserDistance2MaterialCount(distance, x, out boxCount); if (laser2CoordinateState == Laser2CoordinateState.MaterialNormal) { + int compensateHeight = boxCount > 1 ? 500 : 0;//补偿高度,超过1层盒子增加补偿 + //盒子高度计算除去起始位置的那个盒子 - x_high = (boxCount - 1) * materialBoxHeight; + x_high = (boxCount - 1) * materialBoxHeight + compensateHeight; } return laser2CoordinateState; @@ -1722,6 +1798,7 @@ namespace BPASmartClient.MorkF if(heightDifferent < 0) { MessageLog.GetInstance.ShowEx($"菜品库检测{x}处的菜品量时,传感器获取的高度差为负数,请校准该层高度"); + return Laser2CoordinateState.MaterialEmpty; ; } //盒子高度为45,但是需要考虑到误差,不足35,则认为为空 @@ -2216,11 +2293,7 @@ namespace BPASmartClient.MorkF GoodsKey = item.GoodsKey, StirPotActions = OrderSort(item.StirPotActions), }); - GlobalFoodMenu.LocalFoodMenus.Add(new FoodMenuModel - { - GoodKey = item.GoodsKey.ToString(), - GoodName = "", - }); + } } @@ -2357,9 +2430,9 @@ namespace BPASmartClient.MorkF /// /// /// - private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) + private void OrderChange(string Id , string goodName, ORDER_STATUS oRDER_STATUS,int deviceId) { - EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid }); + EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, GoodName = goodName,DeviceId = deviceId, SubOrderId =Id }); } /// @@ -2405,7 +2478,7 @@ namespace BPASmartClient.MorkF if (materialInfo != null) { //if - if(Convert.ToInt32(materialInfo.Qty) - goodBatching.BatchingCount < 0) + if(System.Convert.ToInt32(materialInfo.Qty) - goodBatching.BatchingCount < 0) { MessageLog.GetInstance.ShowEx($"{materialInfo.Name}不够,请更新菜品库,并点击检测"); return; @@ -2487,13 +2560,14 @@ namespace BPASmartClient.MorkF if (morkFs[i].AutoMode && morkFs[i].FryPot1_InitialComplete && ml_morkf.InitialComplete && !morkFs[i].FryWorking)//炒锅在自动状态&&初始化完成&&菜品库初始化&&是否在炒菜中 { - Thread.Sleep(5000); + Thread.Sleep(4000); lock(lock_MainProcessExcute) { //待炒小炒队列出队列 if (StirFryGoodsQuenes.TryDequeue(out var res)) { + OrderChange(res.SuborderId, res.GoodName, ORDER_STATUS.WAIT, DeviceId = i); //设置当前炒制菜品 nowStirFryGood[i] = res; //炒锅工作状态置为正在工作中 @@ -2519,7 +2593,7 @@ namespace BPASmartClient.MorkF bool ret = true; MessageLog.GetInstance.Show($"炒锅{i}开始炒制菜品{res.GoodName}"); - + OrderChange(res.SuborderId, res.GoodName, ORDER_STATUS.COOKING, DeviceId = i); morkFs[i].GoodName = res.GoodName; Coordinate myCoordinate = new Coordinate(); @@ -2542,7 +2616,7 @@ namespace BPASmartClient.MorkF //更新 morkFs[i].UpdateProcess(potActions); - + switch (potActions.Actions) { case nameof(StirFryPotActionEnum.加热开启): @@ -2608,6 +2682,16 @@ namespace BPASmartClient.MorkF MessageLog.GetInstance.Show(potActions.Actions); break; case nameof(StirFryPotActionEnum.取原料): + if(potActions.SeasoningLists[0].Loc == 1 || + potActions.SeasoningLists[0].Loc == 9 || + potActions.SeasoningLists[0].Loc == 10 || + potActions.SeasoningLists[0].Loc == 18 || + potActions.SeasoningLists[0].Loc == 19 || + potActions.SeasoningLists[0].Loc == 27 ) + { + MessageLog.GetInstance.ShowEx("该取料位置禁止使用"); + return; + } //炒锅取菜状态置为未取到 morkFs[i].GetMaterialComplete = false; @@ -2678,7 +2762,7 @@ namespace BPASmartClient.MorkF ret = OutFood(i, out error, true); if(ret == false) { - alarmModel.Add(new AlarmModel() { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = error }); + alarmModel.Add(new BPA.Message.AlarmModel() { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = error }); } break; case nameof(StirFryPotActionEnum.炒制菜品): @@ -2696,7 +2780,7 @@ namespace BPASmartClient.MorkF } if (ret == false) { - alarmModel.Add(new AlarmModel() { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = error }); + alarmModel.Add(new BPA.Message.AlarmModel() { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = error }); } MessageLog.GetInstance.Show(potActions.Actions); break; @@ -2713,9 +2797,9 @@ namespace BPASmartClient.MorkF Thread.Sleep(3000); //回原点位 StirArmGoOrigin(i); - + OrderChange(res.SuborderId, res.GoodName, ORDER_STATUS.COMPLETED_COOK, DeviceId = i); //同时只能允许有一个出餐 - lock(lock_OutMeal) + lock (lock_OutMeal) { //出餐启动 OutMeal(i); @@ -2804,12 +2888,12 @@ namespace BPASmartClient.MorkF if (batchingInfo == null) { //为空就新增 - BatchingInfos.Add(new BatchingInfo() { BatchingCount = Convert.ToInt32(surplus.Qty) - stagingCount, BatchingLoc = surplus.Loc, BatchingId = surplus.Key }); + BatchingInfos.Add(new BatchingInfo() { BatchingCount = System.Convert.ToInt32(surplus.Qty) - stagingCount, BatchingLoc = surplus.Loc, BatchingId = surplus.Key }); } else { batchingInfo.BatchingLoc = surplus.Loc; - batchingInfo.BatchingCount = Convert.ToInt32(surplus.Qty) - stagingCount; + batchingInfo.BatchingCount = System.Convert.ToInt32(surplus.Qty) - stagingCount; } } Thread.Sleep(1000); diff --git a/BPASmartClient.MorkF/Convert/PotActionToVisibilityConvert.cs b/BPASmartClient.MorkF/Convert/PotActionToVisibilityConvert.cs new file mode 100644 index 00000000..f63a3b2d --- /dev/null +++ b/BPASmartClient.MorkF/Convert/PotActionToVisibilityConvert.cs @@ -0,0 +1,35 @@ +using AlibabaCloud.SDK.Iot20180120.Models; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace BPASmartClient.MorkF.Convert +{ + internal class PotActionToVisibilityConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Visibility vs = Visibility.Collapsed; + if(value is string action) + { + switch (action) + { + case "": + default: + break; + } + } + return vs; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BPASmartClient.MorkF/ML_MorkF.cs b/BPASmartClient.MorkF/ML_MorkF.cs index 993de6c1..4ce879a3 100644 --- a/BPASmartClient.MorkF/ML_MorkF.cs +++ b/BPASmartClient.MorkF/ML_MorkF.cs @@ -35,6 +35,15 @@ namespace BPASmartClient.MorkF /// public bool InitialComplete { get; set; } + /// + /// 爪子伸出到位 + /// + public bool PawOutComplete { get; set; } + /// + /// 爪子缩回到位 + /// + public bool PawInComplete { get; set; } + private bool _ArriveComplete = false; /// /// 定位到达,上升沿捕获需要特殊处理 diff --git a/BPASmartClient.MorkF/Model/FoodMenuModel.cs b/BPASmartClient.MorkF/Model/FoodMenuModel.cs new file mode 100644 index 00000000..48d0f862 --- /dev/null +++ b/BPASmartClient.MorkF/Model/FoodMenuModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkF.Model +{ + public class FoodMenuModel + { + public string ID { get; set; } + public string FoodName { get; set; } + public Dictionary FoodHouseMaterials { get; set; } = new Dictionary(); + + } + + + + + +} diff --git a/BPASmartClient.MorkF/Model/MaterialSurplus.cs b/BPASmartClient.MorkF/Model/MaterialSurplus.cs index b75043fd..0bef04b9 100644 --- a/BPASmartClient.MorkF/Model/MaterialSurplus.cs +++ b/BPASmartClient.MorkF/Model/MaterialSurplus.cs @@ -87,7 +87,7 @@ namespace BPASmartClient.MorkF foreach(MaterialInfo material in materials) { //surplus += int.Parse(material.Qty.ToString()); - surplus += Convert.ToInt32(material.Qty); + surplus += System.Convert.ToInt32(material.Qty); } return true; } diff --git a/BPASmartClient.MorkF/View/DebugView.xaml b/BPASmartClient.MorkF/View/DebugView.xaml index 186c5233..e6baed2a 100644 --- a/BPASmartClient.MorkF/View/DebugView.xaml +++ b/BPASmartClient.MorkF/View/DebugView.xaml @@ -55,16 +55,16 @@ -