From e478b8fdaa74e09191304b52673fefb15f18a3a4 Mon Sep 17 00:00:00 2001 From: fyf Date: Fri, 18 Nov 2022 17:28:18 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../分餐机/ScreenSplitMealsControl3.xaml | 375 +++++++++--------- .../ScreenSplitMealsControl3.xaml.cs | 49 ++- .../ScreenSplitMealsControl3ViewModel.cs | 14 + .../炒锅/ScreenMaxWokControl.xaml | 2 +- 4 files changed, 251 insertions(+), 189 deletions(-) diff --git a/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3.xaml b/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3.xaml index 5e3c1601..14cd17f9 100644 --- a/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3.xaml +++ b/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3.xaml @@ -1,188 +1,189 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 设备工作状态 - - - - 今日刷卡数 - - - - - - - - - - - - 前一位刷卡人 - - - - 当前刷卡人 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 设备工作状态 - - - - 今日刷卡数 - - - - - - - - - - - - 前一位刷卡人 - - - - 当前刷卡人 - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 设备工作状态 + + + + 今日刷卡数 + + + + + + + + + + + + 前一位刷卡人 + + + + 当前刷卡人 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 设备工作状态 + + + + 今日刷卡数 + + + + + + + + + + + + 前一位刷卡人 + + + + 当前刷卡人 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3.xaml.cs b/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3.xaml.cs index 4d3a69f0..1f94f8bf 100644 --- a/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3.xaml.cs +++ b/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3.xaml.cs @@ -23,8 +23,55 @@ namespace BPASmartClient.ScreenLib public ScreenSplitMealsControl3() { InitializeComponent(); - this.DataContext = new ScreenSplitMealsControl3ViewModel(); + if (int.Parse(System.Configuration.ConfigurationManager.AppSettings["ShowForm"].ToString()) == 0) + { + guanggao.Visibility = Visibility.Visible; + diqiu.Visibility = Visibility.Collapsed; + } + else + { + guanggao.Visibility = Visibility.Collapsed; + diqiu.Visibility = Visibility.Visible; + } + Show(); + } + + + /// + /// 点击切换广告 + /// + /// + /// + private void StackPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + try + { + guanggao.Visibility = guanggao.Visibility == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed; + diqiu.Visibility = guanggao.Visibility == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed; + Show(); + } + catch (Exception ex) + { + + } + } + + /// + /// 显示广告 + /// + public void Show() + { + string str = string.Empty; + if (Main.GetInstance.SaasRouteReturn != null && Main.GetInstance.SaasRouteReturn.Count >= 6) + { + AdDTO dto = Main.GetInstance.SaasRouteReturn?.Find(par => par.Address == "02"); + if (dto != null) + { + str = dto.Ad; + Main.GetInstance.InitView2(str, webView, guanggao); + } + } } } } diff --git a/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3ViewModel.cs b/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3ViewModel.cs index de1fff1c..d935667d 100644 --- a/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3ViewModel.cs +++ b/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3ViewModel.cs @@ -38,6 +38,19 @@ namespace BPASmartClient.ScreenLib /// 当前刷新数据类型 /// public ScreenDeviceType type = ScreenDeviceType.分餐机; + /// + /// 订单总数 + /// + public int OrderCount + { + get { return _OrderCount; } + set + { + _OrderCount = value; + OnPropertyChanged(); + } + } + private int _OrderCount = 0; #endregion public ScreenSplitMealsControl3ViewModel() @@ -52,6 +65,7 @@ namespace BPASmartClient.ScreenLib if (modelMaxWok != null && modelMaxWok.Alarm != null) modelMaxWok.Alarm = modelMaxWok.Alarm?.OrderByDescending(k => DateTime.Parse(k.AlarmTime)).ToList(); ViewData = modelMaxWok; + OrderCount = modelMaxWok.SplitMeals_CreditCardCount_5 + modelMaxWok.SplitMeals_CreditCardCount_6; } })); Thread.Sleep(1000); diff --git a/BPASmartClient.ScreenLib/炒锅/ScreenMaxWokControl.xaml b/BPASmartClient.ScreenLib/炒锅/ScreenMaxWokControl.xaml index 1a5c6e34..82519346 100644 --- a/BPASmartClient.ScreenLib/炒锅/ScreenMaxWokControl.xaml +++ b/BPASmartClient.ScreenLib/炒锅/ScreenMaxWokControl.xaml @@ -115,7 +115,7 @@ - + From c477e4dea3334ae058689879aed30935ab8783b1 Mon Sep 17 00:00:00 2001 From: fyf Date: Fri, 18 Nov 2022 17:49:38 +0800 Subject: [PATCH 2/8] 1 --- BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj b/BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj index eabbfbcd..70a561ca 100644 --- a/BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj +++ b/BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj @@ -19,7 +19,7 @@ - + From 3a6b4611221ac3873fbcc483293676ae33be46d5 Mon Sep 17 00:00:00 2001 From: yahaha Date: Sat, 19 Nov 2022 15:49:44 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E8=8F=9C=E5=93=81=E5=BA=93=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Properties/Settings.Designer.cs | 2 +- BPASmartClient.MorkF/Control_MorkF.cs | 402 ++++++++++++------ .../Model/MaterialCoordinate.cs | 77 ++++ .../{ => Model}/MaterialOperation.cs | 15 +- BPASmartClient.MorkF/Model/MaterialSurplus.cs | 206 +++++++++ 5 files changed, 559 insertions(+), 143 deletions(-) create mode 100644 BPASmartClient.MorkF/Model/MaterialCoordinate.cs rename BPASmartClient.MorkF/{ => Model}/MaterialOperation.cs (66%) create mode 100644 BPASmartClient.MorkF/Model/MaterialSurplus.cs diff --git a/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs b/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs index 804602c2..02053c8a 100644 --- a/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs +++ b/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace BPASmartClient.JXJFoodBigStation.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs index 085bf88e..28b26e12 100644 --- a/BPASmartClient.MorkF/Control_MorkF.cs +++ b/BPASmartClient.MorkF/Control_MorkF.cs @@ -33,7 +33,7 @@ namespace BPASmartClient.MorkF /// /// 菜品库while循环最大sleep次数 /// - private const int materialSleepCount = 400; + private const int materialSleepCount = 600; /// /// 菜品库while循环每次sleep时间 @@ -54,17 +54,17 @@ namespace BPASmartClient.MorkF private const int materialHigh = 34500; /// - /// + /// 菜品库第一层的起始基点,为最下层盒子的中间点 /// private const int materialOne = 34500; /// - /// + /// 菜品库第二层的起始基点,为最下层盒子的中间点 /// private const int materialTwo = 34500; /// - /// + /// 菜品库第三层的起始基点,为最下层盒子的中间点 /// private const int materialThree = 34500; @@ -153,6 +153,8 @@ namespace BPASmartClient.MorkF ///初始化菜品库 //FoodLibInit(); Task2ReadMaterialData(); + + //Json.Read(); } /// @@ -900,25 +902,43 @@ namespace BPASmartClient.MorkF /// public bool GetDistance(int x) { + bool ret = true; //是否在第一层菜品库 if (x > 0 && x <= materialLaserHigh) { //获取传感器1的距离 - return GetDistance_1(); + ret &= GetDistance_1(); + + Thread.Sleep(400); + + //获取传感器1的距离 + ret &= GetDistance_1(); } //是否在第二层菜品库 else if (x > materialLaserHigh && x <= (2 * materialLaserHigh + clapboardLaserHigh)) { - //获取传感器1的距离 - return GetDistance_2(); + //获取传感器2的距离 + ret &= GetDistance_2(); + + Thread.Sleep(400); + + ret &= GetDistance_2(); } //是否在第三层菜品库 else if (x > (2 * materialLaserHigh + clapboardLaserHigh) && x <= (3 * materialLaserHigh + 2 * clapboardLaserHigh)) { - //获取传感器1的距离 - return GetDistance_3(); + //获取传感器3的距离 + ret &= GetDistance_3(); + + Thread.Sleep(400); + + ret &= GetDistance_3(); + } + if (!ret) + { + MessageLog.GetInstance.Show($"错误:X轴:{x}获取传感器数据出错"); } - return false; + return ret; } public void PawTurnFront() @@ -1055,26 +1075,18 @@ namespace BPASmartClient.MorkF /// 取菜x轴坐标 /// 取菜y轴坐标 /// 炒锅编号 - public void GetMaterail(int x, int y, int fryNum = 0) + public bool GetMaterail(int x, int y, int fryNum) { //设置到抓菜处 if (!SetArmPosition(x, y)) { - return; - } - - if (!GetDistance(x)) - { - MessageLog.GetInstance.Show("错误:获取传感器数据出错"); - return; + return false; } - Thread.Sleep(200); - if (!GetDistance(x)) { MessageLog.GetInstance.Show("错误:获取传感器数据出错"); - return; + return false; } Thread.Sleep(1000); @@ -1087,26 +1099,26 @@ namespace BPASmartClient.MorkF if (laserHigh > 29) { MessageLog.GetInstance.Show("错误:传感器获取数据大于隔板与传感器之间的距离"); - return; + return false; } int moveX = 0; if (LaserDistance2Coordinate(laserHigh, out moveX) != Laser2CoordinateState.MaterialNormal) { MessageLog.GetInstance.Show("错误:传感器距离转坐标值失败"); - return; + return false; } if(x < moveX) { MessageLog.GetInstance.Show("错误:传感器距离转坐标值大于当前x轴坐标"); - return; + return false; } //设置到传感器感应的距离处 if (!SetArmPosition(x - moveX, y)) { - return; + return false; } ////关闭电磁阀 @@ -1117,14 +1129,14 @@ namespace BPASmartClient.MorkF //爪子去1号位抓菜 if (!PawToPoint1()) { - return; + return false; } #endif //设置到该层菜品库最高处 if (!SetArmPosition(x - materialHigh, y)) { - return; + return false; } ////移动前开启电磁阀 @@ -1135,13 +1147,13 @@ namespace BPASmartClient.MorkF //爪子去2号位放菜 if (!PawToPoint2()) { - return; + return false; } #endif ////判断炒锅是否可以放盒 - //for(int i = 0;materialSleepCount > i && !morkFs[fryIndex].FryPot1_HOBTPut;i++) + //for (int i = 0; materialSleepCount > i && !morkFs[fryIndex].FryPot1_HOBTPut; i++) //{ - // Thread.Sleep(materialSleepTime); + // Thread.Sleep(materialSleepTime); // if (i >= materialSleepCount - 1) // { // MessageLog.GetInstance.Show("等待炒锅允许放盒超时"); @@ -1169,14 +1181,14 @@ namespace BPASmartClient.MorkF //设置到炒锅1出菜处 if (!SetArmPosition(x, y)) { - return; + return false; } #if true //爪子去3号位放菜 if (!PawToPoint3()) { - return; + return false; } #endif @@ -1188,14 +1200,14 @@ namespace BPASmartClient.MorkF //设置到炒锅1出菜处 if (!SetArmPosition(x + materialToFryDistance, y)) { - return; + return false; } #if true //爪子回到2号位 if (!PawToPoint2()) { - return; + return false; } #endif ////关闭电磁阀 @@ -1205,6 +1217,62 @@ namespace BPASmartClient.MorkF { morkFs[fryNum].GetMaterialComplete = true; } + return true; + } + + /// + /// 更新菜品库存量 + /// + /// + public bool UpdateMaterialLibraryStock() + { + try + { + //判断是否初始化 + if(!ml_morkf.InitialComplete) + { + return false; + } + + foreach(var item in MaterialCoordinate.dicNoMaterialCoordinate) + { + //设置到抓菜处 + if (!SetArmPosition(item.Value.X, item.Value.Y)) + { + return false; + } + + //获取该处的距离 + if (!GetDistance(item.Value.X)) + { + MessageLog.GetInstance.Show("错误:获取传感器数据出错"); + return false; + } + + Thread.Sleep(1000); + + //获取传感器的距离 + int laserHigh = ml_morkf.LaserDistance; + int surplus = 0; + //根据距离算出菜品余量 + Laser2CoordinateState state = LaserDistance2MaterialCount(laserHigh, out surplus); + if (state != Laser2CoordinateState.MaterialNormal || state != Laser2CoordinateState.MaterialEmpty) + { + return false; + } + + //更新菜品余量 + if (!MaterialSurplusOperation.GetInstance().UpdateSurplus(item.Key, surplus)) + { + return false; + } + } + return true; + } + catch(Exception ex) + { + return false; + } } /// @@ -1259,50 +1327,86 @@ namespace BPASmartClient.MorkF } } + /// + /// 传感器距离转为菜品数量 + /// + /// + /// + /// + public Laser2CoordinateState LaserDistance2MaterialCount(int distance, out int count) + { + count = 0; + try + { + //菜盒放多了 + if (distance < 6) + { + return Laser2CoordinateState.MaterialOverdo; + } + else if (distance >= 6 && distance < 10) + { + count = 5; + return Laser2CoordinateState.MaterialNormal; + } + else if (distance >= 10 && distance < 14) + { + count = 4; + return Laser2CoordinateState.MaterialNormal; + } + else if (distance >= 14 && distance < 19) + { + count = 3; + return Laser2CoordinateState.MaterialNormal; + } + else if (distance >= 19 && distance < 23) + { + count = 2; + return Laser2CoordinateState.MaterialNormal; + } + else if (distance >= 23 && distance < 28) + { + count = 1; + return Laser2CoordinateState.MaterialNormal; + } + else + { + count = 0; + return Laser2CoordinateState.MaterialEmpty; + } + } + catch (Exception ex) + { + return Laser2CoordinateState.MaterialUnkown; + } + } + /// /// 获取菜品测试 /// /// - private void GetMaterailTest(Coordinate coordinate) + private void GetMaterailTest(MaterialOperation materialOperation) { ThreadManage.GetInstance().Start(new Action(() => { - //int x1 = 0, x2 = 0, y = 0; - - //if (getNum % 2 == 0) - //{ - // x2 = 35000; - // y = 82000; - - //} - //else if (getNum % 2 == 1) - //{ - // x2 = 35000; - // y = 9000; - //} - //else - //{ - // MessageLog.GetInstance.Show("菜品库无效操作"); - // return; - //} + bool ret = false; try { + Coordinate myCoordinate = new Coordinate(); + //获取坐标,根据菜品的位置信息 + if (!NoMaterial2Coordinate(materialOperation.materialInfo.Loc, out myCoordinate)) + { + MessageLog.GetInstance.Show($"炒锅{materialOperation.fryNum}获取菜品[{materialOperation.materialInfo.Name}]失败,找不到对应位置"); + return; + } lock (lock_Materail) { ml_morkf.MaterailIsWorking = true; } //取菜操作 - GetMaterail(coordinate.X, coordinate.Y); - - ////机械臂回原点 - //if (!SetArmPosition(0, 0)) - //{ - // MessageLog.GetInstance.Show("菜品库[机械臂操作失败]"); - // return; - //} + ret =GetMaterail(myCoordinate.X, myCoordinate.Y, materialOperation.fryNum); } catch (Exception ex) { - + ret = false; } finally { @@ -1310,6 +1414,11 @@ namespace BPASmartClient.MorkF { ml_morkf.MaterailIsWorking = false; } + if (ret == true) + { + //指定位置菜品减一 + MaterialSurplusOperation.GetInstance().ReduceSurplus(materialOperation.materialInfo.Loc); + } } }), $"菜品库操作"); @@ -1469,48 +1578,52 @@ namespace BPASmartClient.MorkF Thread.Sleep(200); } //倒菜 - public void OutFood(int num) + public void OutFood(int num,bool isMaterial = false) { if (!morkFs.ContainsKey(num)) { return; } int i = 0; - //判断是否完成取菜 - for (i = 0; i < sleepCount * 2 && !morkFs[num].GetMaterialComplete; i++) + + if(isMaterial) { - if (i == 3) + //判断是否完成取菜 + for (i = 0; i < materialSleepCount && !morkFs[num].GetMaterialComplete; i++) { - //停止搅拌 - StopStir(num); - //火力设置为2档 - SetFire(new List { 2 }, num); + if (i == 10) + { + //停止搅拌 + StopStir(num); + //火力设置为2档 + SetFire(new List { 2 }, num); + } + Thread.Sleep(materialSleepTime); + if (i >= materialSleepCount - 1) + { + MessageLog.GetInstance.Show($"炒锅{num}倒菜超时:未能等到取菜完成"); + return; + } } - Thread.Sleep(sleepTime); - if (i >= sleepCount * 2 - 1) + + if (i > 9) { - MessageLog.GetInstance.Show($"炒锅{num}倒菜超时:未能等到取菜完成"); - return; + //开启搅拌 + StartStir(num); + //火力设置回原本火力 + SetFire(new List { morkFs[num].Fire }, num); } } - if (i > 3) - { - //开启搅拌 - StartStir(num); - //火力设置回原本火力 - SetFire(new List { morkFs[num].Fire }, num); - } - FirePot_Write("LB3", true, num); MessageLog.GetInstance.Show("倒菜启动"); - Thread.Sleep(200); + Thread.Sleep(500); - for (i = 0; i < sleepCount && !morkFs[num].FryPot1_MaterialIntoPot; i++) + for (i = 0; i < materialSleepCount && !morkFs[num].FryPot1_MaterialIntoPot; i++) { - Thread.Sleep(sleepTime); - if (i >= sleepCount - 1) + Thread.Sleep(materialSleepTime); + if (i >= materialSleepCount - 1) { MessageLog.GetInstance.Show($"炒锅{num}倒菜超时"); } @@ -1519,6 +1632,7 @@ namespace BPASmartClient.MorkF FirePot_Write("LB3", false, num); Thread.Sleep(200); MessageLog.GetInstance.Show("倒菜完成"); + morkFs[num].GetMaterialComplete = false; } //搅拌臂去原点位 public void StirArmGoOrigin(int num) @@ -1645,7 +1759,17 @@ namespace BPASmartClient.MorkF FirePot_Write("LB8", true, num); Thread.Sleep(200); } -#endregion + #endregion + + private static object saveMaterialLock = new object(); + private void SaveMaterialData() + { + lock(saveMaterialLock) + { + Json.Data = MaterialSurplusOperation.GetInstance().materialSurplus; + Json.Save(); + } + } bool isInitialArrive = false; @@ -1698,6 +1822,22 @@ namespace BPASmartClient.MorkF }); } } + if(stirFry.stirFrymessage.materials.Count > 0) + { + MaterialSurplusOperation.GetInstance().UpdateSurplusAll(stirFry.stirFrymessage.materials); + //foreach (var item in stirFry.stirFrymessage.materials) + //{ + // MaterialSurplusOperation.GetInstance().materialSurplus.dicSurplus.Add(new MaterialInfo + // { + // Id = item.Id, + // Key = item.Key, + // Name = item.Name, + // Loc = item.Loc, + // Qty = item.Qty, + // }); + //} + SaveMaterialData(); + } } MessageLog.GetInstance.Show("接收到小炒流程信息"); @@ -2005,22 +2145,41 @@ namespace BPASmartClient.MorkF case nameof(StirFryPotActionEnum.取原料): //炒锅取菜状态置为未取到 morkFs[i].GetMaterialComplete = false; - if(getMaterailNum == 0) + if(potActions.MaterialLists != null) { - if (NoMaterial2Coordinate("A2", out myCoordinate)) + foreach (var item in potActions.MaterialLists) { - materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, coordinate = myCoordinate }); - getMaterailNum++; + //通过ID获取有效的菜品对象 + MaterialInfo materialInfo = MaterialSurplusOperation.GetInstance().GetVailedMaterial(item.MaterialId); + if (materialInfo == null) + { + MessageLog.GetInstance.Show($"炒锅{i}获取菜品[{materialInfo.Name}]失败,库存不足"); + continue; + } + + materialOperationQuenes.Enqueue(new MaterialOperation { materialInfo = materialInfo, fryNum = i }); } } - else if(getMaterailNum == 1) + else { - if (NoMaterial2Coordinate("B2", out myCoordinate)) - { - materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, coordinate = myCoordinate }); - getMaterailNum++; - } + MessageLog.GetInstance.Show($"炒锅{i}获取菜品失败,菜品列表为空"); } + //if(getMaterailNum == 0) + //{ + // if (NoMaterial2Coordinate(MaterialCoordinate.MLNumberList[1], out myCoordinate)) + // { + // materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, coordinate = myCoordinate }); + // getMaterailNum++; + // } + //} + //else if(getMaterailNum == 1) + //{ + // if (NoMaterial2Coordinate(MaterialCoordinate.MLNumberList[4], out myCoordinate)) + // { + // materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, coordinate = myCoordinate }); + // getMaterailNum++; + // } + //} MessageLog.GetInstance.Show(potActions.Actions); break; case nameof(StirFryPotActionEnum.开启搅拌): @@ -2047,7 +2206,7 @@ namespace BPASmartClient.MorkF MessageLog.GetInstance.Show(potActions.Actions); break; case nameof(StirFryPotActionEnum.道菜启动): - OutFood(i); + OutFood(i, true); break; case nameof(StirFryPotActionEnum.炒制菜品): Thread.Sleep(potActions.During * 1000); @@ -2099,8 +2258,6 @@ namespace BPASmartClient.MorkF } } - private int testNum = 0; - /// /// 菜品库主流程 /// @@ -2114,13 +2271,13 @@ namespace BPASmartClient.MorkF //待菜品库操作列出队列 if (materialOperationQuenes.TryDequeue(out var res)) { + ml_morkf.MaterailIsWorking = true; MessageLog.GetInstance.Show("开始操作菜品库"); //ThreadManage.GetInstance().Start(new Action(()=>{ // GetMaterail(res.x, res.y, res.fryNum); //}),"菜品库操作"); - GetMaterailTest(res.coordinate); - testNum++; + GetMaterailTest(res); } } } @@ -2194,9 +2351,9 @@ namespace BPASmartClient.MorkF try { - if(dicNoMaterialCoordinate.ContainsKey(no)) + if(MaterialCoordinate.dicNoMaterialCoordinate.ContainsKey(no)) { - coordinate = dicNoMaterialCoordinate[no]; + coordinate = MaterialCoordinate.dicNoMaterialCoordinate[no]; return true; } else @@ -2214,43 +2371,6 @@ namespace BPASmartClient.MorkF } } - /// - /// 每个取菜点的编号与坐标字典 - /// - private static Dictionary dicNoMaterialCoordinate { get; set; } = new Dictionary() - { - {"A1",new Coordinate(){ X = 34500,Y=0} }, - {"A2",new Coordinate(){ X = 34500,Y=9000} }, - {"A3",new Coordinate(){ X = 34500,Y=0} }, - {"B1",new Coordinate(){ X = 34500,Y=0} }, - {"B2",new Coordinate(){ X = 34500,Y=83000} }, - {"B3",new Coordinate(){ X = 34500,Y=0} }, - {"C1",new Coordinate(){ X = 34500,Y=0} }, - {"C2",new Coordinate(){ X = 34500,Y=0} }, - {"C3",new Coordinate(){ X = 34500,Y=0} }, - {"D1",new Coordinate(){ X = 0,Y=0} }, - {"D2",new Coordinate(){ X = 0,Y=0} }, - {"D3",new Coordinate(){ X = 0,Y=0} }, - {"E1",new Coordinate(){ X = 0,Y=0} }, - {"E2",new Coordinate(){ X = 0,Y=0} }, - {"E3",new Coordinate(){ X = 0,Y=0} }, - {"F1",new Coordinate(){ X = 0,Y=0} }, - {"F2",new Coordinate(){ X = 0,Y=0} }, - {"F3",new Coordinate(){ X = 0,Y=0} }, - {"G1",new Coordinate(){ X = 0,Y=0} }, - {"G2",new Coordinate(){ X = 0,Y=0} }, - {"G3",new Coordinate(){ X = 0,Y=0} }, - {"H1",new Coordinate(){ X = 0,Y=0} }, - {"H2",new Coordinate(){ X = 0,Y=0} }, - {"H3",new Coordinate(){ X = 0,Y=0} }, - {"I1",new Coordinate(){ X = 0,Y=0} }, - {"I2",new Coordinate(){ X = 0,Y=0} }, - {"I3",new Coordinate(){ X = 0,Y=0} }, - {"J1",new Coordinate(){ X = 0,Y=0} }, - {"J2",new Coordinate(){ X = 0,Y=0} }, - {"J3",new Coordinate(){ X = 0,Y=0} }, - }; - public enum Laser2CoordinateState { MaterialOverdo = 0,//菜品过量 diff --git a/BPASmartClient.MorkF/Model/MaterialCoordinate.cs b/BPASmartClient.MorkF/Model/MaterialCoordinate.cs new file mode 100644 index 00000000..5b00b0a1 --- /dev/null +++ b/BPASmartClient.MorkF/Model/MaterialCoordinate.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkF.Model +{ + internal class MaterialCoordinate + { + public static List MLNumberList = new List() { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16" + , "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27" }; + + public static List MLCoordinateList = new List() + { new Coordinate() { X = 34500, Y = 0 }, new Coordinate() { X = 34500, Y = 9000 } , new Coordinate() { X = 34500, Y = 0 } , //第1层 + new Coordinate(){ X = 34500,Y=0} , new Coordinate() { X = 34500, Y = 83000 }, new Coordinate(){ X = 34500,Y=0}, //第1层 + new Coordinate(){ X = 34500,Y=0} , new Coordinate() { X = 34500, Y = 0 }, new Coordinate(){ X = 34500,Y=0}, //第1层 + new Coordinate(){ X = 0,Y=0} , new Coordinate() { X = 0, Y = 0 }, new Coordinate(){ X = 0,Y=0}, //第2层 + new Coordinate(){ X = 0,Y=0} , new Coordinate() { X = 0, Y = 0 }, new Coordinate(){ X = 0,Y=0}, //第2层 + new Coordinate(){ X = 0,Y=0} , new Coordinate() { X = 0, Y = 0 }, new Coordinate(){ X = 0,Y=0}, //第2层 + new Coordinate(){ X = 0,Y=0} , new Coordinate() { X = 0, Y = 0 }, new Coordinate(){ X = 0,Y=0}, //第3层 + new Coordinate(){ X = 0,Y=0} , new Coordinate() { X = 0, Y = 0 }, new Coordinate(){ X = 0,Y=0}, //第3层 + new Coordinate(){ X = 0,Y=0} , new Coordinate() { X = 0, Y = 0 }, new Coordinate(){ X = 0,Y=0} //第3层 + }; + + public MaterialCoordinate() + { + if(MLNumberList.Count == MLCoordinateList.Count && MLNumberList.Count == 27) + { + for(int i = 0;i + /// 每个取菜点的编号与坐标字典 + /// + public static Dictionary dicNoMaterialCoordinate { get; set; } = new Dictionary(); + //{ + // {"A1",new Coordinate(){ X = 34500,Y=0} }, + // {"A2",new Coordinate(){ X = 34500,Y=9000} }, + // {"A3",new Coordinate(){ X = 34500,Y=0} }, + // {"B1",new Coordinate(){ X = 34500,Y=0} }, + // {"B2",new Coordinate(){ X = 34500,Y=83000} }, + // {"B3",new Coordinate(){ X = 34500,Y=0} }, + // {"C1",new Coordinate(){ X = 34500,Y=0} }, + // {"C2",new Coordinate(){ X = 34500,Y=0} }, + // {"C3",new Coordinate(){ X = 34500,Y=0} }, + // {"D1",new Coordinate(){ X = 0,Y=0} }, + // {"D2",new Coordinate(){ X = 0,Y=0} }, + // {"D3",new Coordinate(){ X = 0,Y=0} }, + // {"E1",new Coordinate(){ X = 0,Y=0} }, + // {"E2",new Coordinate(){ X = 0,Y=0} }, + // {"E3",new Coordinate(){ X = 0,Y=0} }, + // {"F1",new Coordinate(){ X = 0,Y=0} }, + // {"F2",new Coordinate(){ X = 0,Y=0} }, + // {"F3",new Coordinate(){ X = 0,Y=0} }, + // {"G1",new Coordinate(){ X = 0,Y=0} }, + // {"G2",new Coordinate(){ X = 0,Y=0} }, + // {"G3",new Coordinate(){ X = 0,Y=0} }, + // {"H1",new Coordinate(){ X = 0,Y=0} }, + // {"H2",new Coordinate(){ X = 0,Y=0} }, + // {"H3",new Coordinate(){ X = 0,Y=0} }, + // {"I1",new Coordinate(){ X = 0,Y=0} }, + // {"I2",new Coordinate(){ X = 0,Y=0} }, + // {"I3",new Coordinate(){ X = 0,Y=0} }, + // {"J1",new Coordinate(){ X = 0,Y=0} }, + // {"J2",new Coordinate(){ X = 0,Y=0} }, + // {"J3",new Coordinate(){ X = 0,Y=0} }, + //}; + } +} diff --git a/BPASmartClient.MorkF/MaterialOperation.cs b/BPASmartClient.MorkF/Model/MaterialOperation.cs similarity index 66% rename from BPASmartClient.MorkF/MaterialOperation.cs rename to BPASmartClient.MorkF/Model/MaterialOperation.cs index 130546bd..9beb7e10 100644 --- a/BPASmartClient.MorkF/MaterialOperation.cs +++ b/BPASmartClient.MorkF/Model/MaterialOperation.cs @@ -1,4 +1,5 @@ -using System; +using BPA.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -20,6 +21,18 @@ namespace BPASmartClient.MorkF { public Coordinate coordinate { get; set; } = new Coordinate(); + /// + /// 菜品编号 + /// + public string id; + + /// + /// 菜品位置 + /// + public string loc; + + public MaterialInfo materialInfo; + /// /// 炒锅编号 /// diff --git a/BPASmartClient.MorkF/Model/MaterialSurplus.cs b/BPASmartClient.MorkF/Model/MaterialSurplus.cs new file mode 100644 index 00000000..494110b8 --- /dev/null +++ b/BPASmartClient.MorkF/Model/MaterialSurplus.cs @@ -0,0 +1,206 @@ +using BPA.Helper; +using BPA.Models; +using BPASmartClient.MorkF.Model; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkF +{ + internal class MaterialSurplusOperation : Singleton + { + public MaterialSurplus materialSurplus { get; set; } = new MaterialSurplus(); + + /// + /// 更新余量 + /// + /// 编号 + /// 余量 + public bool UpdateSurplus(string id, int surplus) + { + //找到所有id对应的 + MaterialInfo material = materialSurplus.dicSurplus.Find(t => t.Id == id); + if(material == null) + { + return false; + } + else + { + material.Qty = decimal.Parse(surplus.ToString()); + return true; + } + } + + /// + /// 返回有效的菜品库对象 + /// + /// + /// + public MaterialInfo GetVailedMaterial(string id) + { + int surplus = 0; + //获取该菜品所有的余量 + if(!GetAllSurplus(id,out surplus)) + { + return null; + } + + //判断库存数量是否有效 + if(surplus <= 0) + { + return null; + } + + return GetMaterial(id); + } + + /// + /// 根据编号返回余量 + /// + /// 编号 + /// 余量 + /// + private MaterialInfo GetMaterial(string id) + { + //找到所有id对应的 + MaterialInfo material = materialSurplus.dicSurplus.Find(t => t.Id == id && t.Qty != 0); + + return material; + } + + /// + /// 根据编号返回余量 + /// + /// 编号 + /// 余量 + /// + private bool GetAllSurplus(string id, out int surplus) + { + surplus = 0; + //找到所有id对应的 + List materials = materialSurplus.dicSurplus.FindAll(t=>t.Id == id); + if (materials != null) + { + foreach(MaterialInfo material in materials) + { + surplus += int.Parse(material.Qty.ToString()); + } + return true; + } + else + { + return false; + } + } + + /// + /// 余量减少 + /// + /// + /// + public bool ReduceSurplus(string loc) + { + MaterialInfo materialInfo = materialSurplus.dicSurplus.Find(t => t.Loc == loc); + if (materialInfo != null) + { + materialInfo.Qty--; + return true; + } + else + { + return false; + } + } + + /// + /// 余量增加 + /// + /// + /// + public bool AddSurplus(string loc) + { + MaterialInfo materialInfo = materialSurplus.dicSurplus.Find(t => t.Loc == loc); + if (materialInfo != null) + { + materialInfo.Qty++; + return true; + } + else + { + return false; + } + } + + /// + /// + /// + /// + public void UpdateSurplusAll(List newMaterialSurplus) + { + if (newMaterialSurplus != null) + { + List materialInfos = materialSurplus.dicSurplus; + if(materialInfos.Count != newMaterialSurplus.Count) + { + materialInfos.Clear(); + materialSurplus.dicSurplus = newMaterialSurplus; + } + else + { + MaterialInfo findMaterial = null; + //遍历旧菜品库,是否与服务器的新菜品库一致 + foreach (MaterialInfo materialInfo in materialSurplus.dicSurplus) + { + //查找该菜品是否还在 + findMaterial = newMaterialSurplus.Find(t => (t.Id == materialInfo.Id && t.Loc == materialInfo.Loc)); + //不存在则准备移除 + if (findMaterial == null) + { + //查找该菜品是否还在 + //位置上的菜品可能会更变 + findMaterial = newMaterialSurplus.Find(t => (t.Loc == materialInfo.Loc)); + if (findMaterial != null) + { + materialInfo.Qty = findMaterial.Qty; + materialInfo.Key = findMaterial.Key; + materialInfo.Id = findMaterial.Id; + materialInfo.Name = findMaterial.Name; + } + } + //存在则更新菜品库数据 + else + { + materialInfo.Qty = findMaterial.Qty; + materialInfo.Key = findMaterial.Key; + materialInfo.Name = findMaterial.Name; + } + } + } + } + else + { + //materialSurplus.dicSurplus.Clear(); + } + } + } + internal class MaterialSurplus + { + /// + /// 余量字典,key:菜品库编号,value:余量 + /// + public List dicSurplus = new List(); + + //public MaterialSurplus() + //{ + // //增加新的 + // foreach (var item in MaterialCoordinate.MLNumberList) + // { + // dicSurplus.Add(item, 0); + // } + //} + + } +} From d5aedcfc6e3664af94f2cf87149da9a65d598858 Mon Sep 17 00:00:00 2001 From: yahaha Date: Sat, 19 Nov 2022 17:29:48 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=A4=B1=E8=B4=A5=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E3=80=82=20=E8=8F=9C=E5=93=81=E5=BA=93=E5=9D=90=E6=A0=87?= =?UTF-8?q?=E7=B3=BB=E6=94=B9=E4=B8=BA=E5=8D=95=E4=BE=8B=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.MorkF/Control_MorkF.cs | 26 ++++++++++++------- .../Model/MaterialCoordinate.cs | 11 ++++---- BPASmartClient.MorkF/Model/MaterialSurplus.cs | 3 ++- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs index 28b26e12..64b09331 100644 --- a/BPASmartClient.MorkF/Control_MorkF.cs +++ b/BPASmartClient.MorkF/Control_MorkF.cs @@ -767,6 +767,7 @@ namespace BPASmartClient.MorkF { if (!ml_morkf.InitialComplete) { + MessageLog.GetInstance.Show("电磁阀启停出错,菜品库未初始化"); return; } @@ -781,6 +782,7 @@ namespace BPASmartClient.MorkF { if (!ml_morkf.InitialComplete) { + MessageLog.GetInstance.Show("爪子去到1号位出错,菜品库未初始化"); return false; } @@ -806,6 +808,7 @@ namespace BPASmartClient.MorkF { if (!ml_morkf.InitialComplete) { + MessageLog.GetInstance.Show("爪子去到2号位出错,菜品库未初始化"); return false; } @@ -831,6 +834,7 @@ namespace BPASmartClient.MorkF { if (!ml_morkf.InitialComplete) { + MessageLog.GetInstance.Show("爪子去到3号位出错,菜品库未初始化"); return false; } @@ -856,6 +860,7 @@ namespace BPASmartClient.MorkF { if (!ml_morkf.InitialComplete) { + MessageLog.GetInstance.Show("1号测距出错,菜品库未初始化"); return false; } @@ -870,6 +875,7 @@ namespace BPASmartClient.MorkF { if (!ml_morkf.InitialComplete) { + MessageLog.GetInstance.Show("2号测距出错,菜品库未初始化"); return false; } @@ -884,6 +890,7 @@ namespace BPASmartClient.MorkF { if (!ml_morkf.InitialComplete) { + MessageLog.GetInstance.Show("3号测距出错,菜品库未初始化"); return false; } @@ -959,6 +966,7 @@ namespace BPASmartClient.MorkF { if (!ml_morkf.InitialComplete) { + MessageLog.GetInstance.Show($"机械臂移动出错,菜品库未初始化"); return false; } @@ -1231,10 +1239,11 @@ namespace BPASmartClient.MorkF //判断是否初始化 if(!ml_morkf.InitialComplete) { + MessageLog.GetInstance.Show("更新菜品库存量出错,菜品库未初始化"); return false; } - foreach(var item in MaterialCoordinate.dicNoMaterialCoordinate) + foreach(var item in MaterialCoordinate.GetInstance().dicNoMaterialCoordinate) { //设置到抓菜处 if (!SetArmPosition(item.Value.X, item.Value.Y)) @@ -1418,6 +1427,7 @@ namespace BPASmartClient.MorkF { //指定位置菜品减一 MaterialSurplusOperation.GetInstance().ReduceSurplus(materialOperation.materialInfo.Loc); + SaveMaterialData(); } } @@ -2234,8 +2244,6 @@ namespace BPASmartClient.MorkF StirArmGoOrigin(i); MessageLog.GetInstance.Show($"菜品{res.GoodName}完成"); - - } catch (Exception ex) { @@ -2265,9 +2273,9 @@ namespace BPASmartClient.MorkF { if(materialOperationQuenes.Count > 0) { - //判断是否初始化与是否在工作中 - if (ml_morkf.InitialComplete && !ml_morkf.MaterailIsWorking) - { + ////判断是否初始化与是否在工作中 + //if (ml_morkf.InitialComplete && !ml_morkf.MaterailIsWorking) + //{ //待菜品库操作列出队列 if (materialOperationQuenes.TryDequeue(out var res)) { @@ -2279,7 +2287,7 @@ namespace BPASmartClient.MorkF //}),"菜品库操作"); GetMaterailTest(res); } - } + //} } } @@ -2351,9 +2359,9 @@ namespace BPASmartClient.MorkF try { - if(MaterialCoordinate.dicNoMaterialCoordinate.ContainsKey(no)) + if(MaterialCoordinate.GetInstance().dicNoMaterialCoordinate.ContainsKey(no)) { - coordinate = MaterialCoordinate.dicNoMaterialCoordinate[no]; + coordinate = MaterialCoordinate.GetInstance().dicNoMaterialCoordinate[no]; return true; } else diff --git a/BPASmartClient.MorkF/Model/MaterialCoordinate.cs b/BPASmartClient.MorkF/Model/MaterialCoordinate.cs index 5b00b0a1..11f50db7 100644 --- a/BPASmartClient.MorkF/Model/MaterialCoordinate.cs +++ b/BPASmartClient.MorkF/Model/MaterialCoordinate.cs @@ -1,4 +1,5 @@ -using System; +using BPA.Helper; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,12 +7,12 @@ using System.Threading.Tasks; namespace BPASmartClient.MorkF.Model { - internal class MaterialCoordinate + internal class MaterialCoordinate : Singleton { - public static List MLNumberList = new List() { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16" + public List MLNumberList = new List() { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16" , "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27" }; - public static List MLCoordinateList = new List() + public List MLCoordinateList = new List() { new Coordinate() { X = 34500, Y = 0 }, new Coordinate() { X = 34500, Y = 9000 } , new Coordinate() { X = 34500, Y = 0 } , //第1层 new Coordinate(){ X = 34500,Y=0} , new Coordinate() { X = 34500, Y = 83000 }, new Coordinate(){ X = 34500,Y=0}, //第1层 new Coordinate(){ X = 34500,Y=0} , new Coordinate() { X = 34500, Y = 0 }, new Coordinate(){ X = 34500,Y=0}, //第1层 @@ -40,7 +41,7 @@ namespace BPASmartClient.MorkF.Model /// /// 每个取菜点的编号与坐标字典 /// - public static Dictionary dicNoMaterialCoordinate { get; set; } = new Dictionary(); + public Dictionary dicNoMaterialCoordinate { get; set; } = new Dictionary(); //{ // {"A1",new Coordinate(){ X = 34500,Y=0} }, // {"A2",new Coordinate(){ X = 34500,Y=9000} }, diff --git a/BPASmartClient.MorkF/Model/MaterialSurplus.cs b/BPASmartClient.MorkF/Model/MaterialSurplus.cs index 494110b8..f323ca9c 100644 --- a/BPASmartClient.MorkF/Model/MaterialSurplus.cs +++ b/BPASmartClient.MorkF/Model/MaterialSurplus.cs @@ -86,7 +86,8 @@ namespace BPASmartClient.MorkF { foreach(MaterialInfo material in materials) { - surplus += int.Parse(material.Qty.ToString()); + //surplus += int.Parse(material.Qty.ToString()); + surplus += Convert.ToInt32(material.Qty); } return true; } From 10c885341438af00984e7b04efb41900007c57a0 Mon Sep 17 00:00:00 2001 From: taoye Date: Mon, 21 Nov 2022 17:08:13 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E8=B0=83=E9=85=92=E6=9C=BA=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BPASmartClient.Business.csproj | 2 +- .../BPASmartClient.CustomResource.csproj | 2 +- .../BPASmartClient.Device.csproj | 2 +- .../Properties/Settings.Designer.cs | 2 +- .../BPASmartClient.JXJFoodSmallStation.csproj | 2 +- .../BPASmartClient.Model.csproj | 2 +- BPASmartClient.Model/MixWinkModel.cs | 25 ++ BPASmartClient.Model/订单/MorkMWSimOrder.cs | 13 + .../BPASmartClient.MorkF.csproj | 2 +- .../BPASmartClient.MorkMW.csproj | 21 ++ BPASmartClient.MorkMW/Control_MorkMW.cs | 313 ++++++++++++++++++ BPASmartClient.MorkMW/GVL_MorkMW.cs | 75 +++++ BPASmartClient.MorkMW/Model/OrderLocInfo.cs | 19 ++ BPASmartClient.MorkMW/Model/SimRecipeModel.cs | 18 + BPASmartClient.MorkMW/View/DebugView.xaml | 75 +++++ BPASmartClient.MorkMW/View/DebugView.xaml.cs | 28 ++ .../ViewModel/DebugViewModel.cs | 58 ++++ .../BPASmartClient.MorkS.csproj | 2 +- BPASmartClient/App.config | 8 +- BPASmartClient/BPASmartClient.csproj | 2 + BPASmartClient/DeviceInfo.xml | 21 +- .../BPASmartClient.DosingSystem.csproj | 2 +- SmartClient.sln | 25 +- TestDemo/Form1.Designer.cs | 37 +++ TestDemo/Form1.cs | 51 ++- TestDemo/MixWinkRecipe.cs | 20 ++ TestDemo/TestDemo.csproj | 1 + 27 files changed, 798 insertions(+), 30 deletions(-) create mode 100644 BPASmartClient.Model/MixWinkModel.cs create mode 100644 BPASmartClient.Model/订单/MorkMWSimOrder.cs create mode 100644 BPASmartClient.MorkMW/BPASmartClient.MorkMW.csproj create mode 100644 BPASmartClient.MorkMW/Control_MorkMW.cs create mode 100644 BPASmartClient.MorkMW/GVL_MorkMW.cs create mode 100644 BPASmartClient.MorkMW/Model/OrderLocInfo.cs create mode 100644 BPASmartClient.MorkMW/Model/SimRecipeModel.cs create mode 100644 BPASmartClient.MorkMW/View/DebugView.xaml create mode 100644 BPASmartClient.MorkMW/View/DebugView.xaml.cs create mode 100644 BPASmartClient.MorkMW/ViewModel/DebugViewModel.cs create mode 100644 TestDemo/MixWinkRecipe.cs diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj index 7e88a063..9f0f535f 100644 --- a/BPASmartClient.Business/BPASmartClient.Business.csproj +++ b/BPASmartClient.Business/BPASmartClient.Business.csproj @@ -9,7 +9,7 @@ - + diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index 874b83ef..0afdf73d 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -410,7 +410,7 @@ - + diff --git a/BPASmartClient.Device/BPASmartClient.Device.csproj b/BPASmartClient.Device/BPASmartClient.Device.csproj index 456f5bbb..bbef1b12 100644 --- a/BPASmartClient.Device/BPASmartClient.Device.csproj +++ b/BPASmartClient.Device/BPASmartClient.Device.csproj @@ -7,7 +7,7 @@ - + diff --git a/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs b/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs index 804602c2..02053c8a 100644 --- a/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs +++ b/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace BPASmartClient.JXJFoodBigStation.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj index cdb1d4f7..4a4ac0e0 100644 --- a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj +++ b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj @@ -8,7 +8,7 @@ - + diff --git a/BPASmartClient.Model/BPASmartClient.Model.csproj b/BPASmartClient.Model/BPASmartClient.Model.csproj index 6237674c..620f2060 100644 --- a/BPASmartClient.Model/BPASmartClient.Model.csproj +++ b/BPASmartClient.Model/BPASmartClient.Model.csproj @@ -17,7 +17,7 @@ - + diff --git a/BPASmartClient.Model/MixWinkModel.cs b/BPASmartClient.Model/MixWinkModel.cs new file mode 100644 index 00000000..ae41ddbb --- /dev/null +++ b/BPASmartClient.Model/MixWinkModel.cs @@ -0,0 +1,25 @@ +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model +{ + public class MixWinkModel:ObservableObject + { + private string _materialName; + public string materialName { get { return _materialName; } set { _materialName = value;OnPropertyChanged(); } } + /// + /// 位置 + /// + private int _loc; + public int Loc { get { return _loc; } set { _loc = value;OnPropertyChanged(); } } + /// + /// 停留时间 + /// + public int Time { get { return _time; } set { _time = value;OnPropertyChanged(); } } + private int _time; + } +} diff --git a/BPASmartClient.Model/订单/MorkMWSimOrder.cs b/BPASmartClient.Model/订单/MorkMWSimOrder.cs new file mode 100644 index 00000000..5f11798b --- /dev/null +++ b/BPASmartClient.Model/订单/MorkMWSimOrder.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.订单 +{ + public class MorkMWSimOrder:BaseEvent + { + public List mixWink = new List(); + } +} diff --git a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj index ea0b7fa5..3bfcd2df 100644 --- a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj +++ b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj @@ -10,7 +10,7 @@ - + diff --git a/BPASmartClient.MorkMW/BPASmartClient.MorkMW.csproj b/BPASmartClient.MorkMW/BPASmartClient.MorkMW.csproj new file mode 100644 index 00000000..2ebedcc7 --- /dev/null +++ b/BPASmartClient.MorkMW/BPASmartClient.MorkMW.csproj @@ -0,0 +1,21 @@ + + + + net6.0-windows + enable + true + + + + + + + + + + + + + + + diff --git a/BPASmartClient.MorkMW/Control_MorkMW.cs b/BPASmartClient.MorkMW/Control_MorkMW.cs new file mode 100644 index 00000000..b181c58a --- /dev/null +++ b/BPASmartClient.MorkMW/Control_MorkMW.cs @@ -0,0 +1,313 @@ +using BPA.Helper; +using BPA.Message.Enum; +using BPASmartClient.Device; +using BPASmartClient.EventBus; +using BPASmartClient.Modbus; +using BPASmartClient.Model; +using BPASmartClient.Model.PLC; +using BPASmartClient.Model.; +using BPASmartClient.MorkMW.Model; +using Org.BouncyCastle.Bcpg.OpenPgp; +using System; +using System.Collections.Concurrent; +using System.Threading; +using static BPASmartClient.EventBus.EventBus; + +namespace BPASmartClient.MorkMW +{ + public class Control_MorkMW : BaseDevice + { + ModbusTcp modbus; + public override DeviceClientType DeviceType => DeviceClientType.MORKMW; + GVL_MorkMW morkMW = new GVL_MorkMW(); + public override void DoMain() + { + + ConnectKlpRobot("192.168.0.100", 8001); + } + + public override void MainTask() + { + ToGetWink(); + ToMixWink(); + ToPourWink(); + SignalDetect(); + } + /// + /// Ӿƹ + /// + public void ToGetWink() + { + + if (morkMW.RobotIdle && orderLocInfos.Count > 0 && !morkMW.TaskLock&&!morkMW.PourWinkComplete&& morkMW.CupSignal) + { + DeviceProcessLogShow("ʼ"); + morkMW.TaskLock = true; + if (orderLocInfos.TryDequeue(out OrderLocInfo res)) + { + foreach (var item in res.mixWink) + { + switch (item.Loc) + { + // case 7: ToMixWink(); break; + case 1: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; + case 2: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; + case 3: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; + case 4: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; + case 5: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; + case 6: ToSpecifiedLocTakeWink(item.Loc, item.Time); break; + + } + switch (item.Loc) + { + //case 7: while (!morkMW.MixWinkComplte) { Thread.Sleep(5); } break; + case 1: while (!morkMW.TakeWinkOneComplete) { Thread.Sleep(5); } break; + case 2: while (!morkMW.TakeWinkTwoComplete) { Thread.Sleep(5); } break; + case 3: while (!morkMW.TakeWinkThreeComplete) { Thread.Sleep(5); } break; + case 4: while (!morkMW.TakeWinkFourComplete) { Thread.Sleep(5); } break; + case 5: while (!morkMW.TakeWinkFiveComplete) { Thread.Sleep(5); } break; + case 6: while (!morkMW.TakeWinkSixComplete) { Thread.Sleep(5); } break; + + } + + + } + + morkMW.AllowMixWink = true;//Ӿɣ + // morkMW.AllowPourWink = true;//ɣ + } + } + } + /// + /// ƹ + /// + public void ToMixWink() + { + // modbus.WriteSingleRegister(0000, 7);//˵ + + if (morkMW.AllowMixWink) + { + DeviceProcessLogShow("ʼ"); + modbus.WriteSingleRegister(0000, 7);//˵ + morkMW.AllowMixWink = false; + } + } + /// + /// ȥӦλýӾ + /// + /// + /// + public void ToSpecifiedLocTakeWink(int loc, int time) + { + //ͽӾź + switch (loc) + { + case 1: modbus.WriteSingleRegister(0000, 1); break; + case 2: modbus.WriteSingleRegister(0000, 2); break; + case 3: modbus.WriteSingleRegister(0000, 3); break; + case 4: modbus.WriteSingleRegister(0000, 4); break; + case 5: modbus.WriteSingleRegister(0000, 5); break; + case 6: modbus.WriteSingleRegister(0000, 6); break; + + } + //ȴ˵Ӿλ + switch (loc) + { + case 1: while (!morkMW.ArriveWinkOneLoc) { Thread.Sleep(5); } break; + case 2: while (!morkMW.ArriveWinkTwoLoc) { Thread.Sleep(5); } break; + case 3: while (!morkMW.ArriveWinkThreeLoc) { Thread.Sleep(5); } break; + case 4: while (!morkMW.ArriveWinkFourLoc) { Thread.Sleep(5); } break; + case 5: while (!morkMW.ArriveWinkFiveLoc) { Thread.Sleep(5); } break; + case 6: while (!morkMW.ArriveWinkSixLoc) { Thread.Sleep(5); } break; + + } + Thread.Sleep(time * 1000);//ӾƵȴʱ + //ͽӾź + switch (loc) + { + case 1: modbus.WriteSingleCoil(4596, true); break; + case 2: modbus.WriteSingleCoil(4597, true); break; + case 3: modbus.WriteSingleCoil(4598, true); break; + case 4: modbus.WriteSingleCoil(4599, true); break; + case 5: modbus.WriteSingleCoil(4600, true); break; + case 6: modbus.WriteSingleCoil(4601, true); break; + + } + + } + /// + /// ƹ + /// + public void ToPourWink() + { + //if (morkMW.AllowPourWink && morkMW.CupSignal) + //{ + // morkMW.AllowPourWink = false; + // modbus.WriteSingleRegister(0000, 8);// + + //} + if (morkMW.CupSignal && RTrig.GetInstance("AllowOut").Start(morkMW.MixWinkComplte)) + { + DeviceProcessLogShow("ʼ"); + modbus.WriteSingleRegister(0000, 8);// + + } + + } + /// + /// źż + /// + public void SignalDetect() + { + if (RTrig.GetInstance("AllComplete").Start(morkMW.ProcessComplete)) + { + morkMW.PourWinkComplete = true; + DeviceProcessLogShow("ɣȡߵþƱ"); + } + if (morkMW.PourWinkComplete) + { + if (TTrig.GetInstance("PoutWinkCom").Start(morkMW.CupSignal)) + { + DeviceProcessLogShow("ͻȡߵþƱ,ÿվƱԴ´ζ"); + } + if (RTrig.GetInstance("PoutWinkCom").Start(morkMW.CupSignal)) + { + DeviceProcessLogShow("վƱλִһ"); + morkMW.PourWinkComplete = false; + morkMW.TaskLock = false; + Thread.Sleep(2000); + } + } + } + + + /// + /// ջ״̬ + /// + public override void ReadData() + { + //GetStatus("M230.0", new Action((obj) => + //{ + + //})); + if (modbus.Connected) + { + morkMW.ArriveWinkOneLoc = modbus.ReadCoils(4616); + morkMW.ArriveWinkTwoLoc = modbus.ReadCoils(4617); + morkMW.ArriveWinkThreeLoc = modbus.ReadCoils(4618); + morkMW.ArriveWinkFourLoc = modbus.ReadCoils(4619); + morkMW.ArriveWinkFiveLoc = modbus.ReadCoils(4620); + morkMW.ArriveWinkSixLoc = modbus.ReadCoils(4621); + + morkMW.RobotIdle = modbus.ReadCoils(4201); + + + morkMW.CupSignal = modbus.ReadInputs(0); + + + morkMW.TakeWinkOneComplete = modbus.ReadCoils(4606); + morkMW.TakeWinkTwoComplete = modbus.ReadCoils(4607); + morkMW.TakeWinkThreeComplete = modbus.ReadCoils(4608); + morkMW.TakeWinkFourComplete = modbus.ReadCoils(4609); + morkMW.TakeWinkFiveComplete = modbus.ReadCoils(4610); + morkMW.TakeWinkSixComplete = modbus.ReadCoils(4611); + morkMW.MixWinkComplte = modbus.ReadCoils(4612); + morkMW.ProcessComplete = modbus.ReadCoils(4613); + } + else + { + modbus.ModbusTcpConnect("192.168.0.100", 8001); + } + } + + public override void ResetProgram() + { + morkMW = null; + morkMW = new GVL_MorkMW(); + } + + + public override void SimOrder() + { + EventBus.EventBus.GetInstance().Subscribe(0, delegate (IEvent @event, EventCallBackHandle callBackHandle) + { + + if (@event != null && @event is MorkMWSimOrder order) + { + if (order.mixWink.Count > 0) + { + string guid = Guid.NewGuid().ToString(); + orderLocInfos.Enqueue(new OrderLocInfo { mixWink = order.mixWink, SuborderId = guid }); + DeviceProcessLogShow("յ"); + } + } + + }); + } + + public override void Stop() + { + + } + private void GetStatus(string key, Action action) + { + if (peripheralStatus.ContainsKey(key)) + { + if (peripheralStatus[key] != null) + { + action?.Invoke(peripheralStatus[key]); + } + } + } + /// + /// д + /// + /// + /// + private void WriteData(string address, object value) + { + EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value }); + } + /// + /// ݽ + /// + public void DataParse() + { + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle) + { + + if (@event != null && @event is DoOrderEvent order) + { + + } + + }); + } + #region Դ + /// + /// ӿջ + /// + /// + /// + public void ConnectKlpRobot(string ip, int port) + { + modbus = new ModbusTcp(); + modbus.Show += new Action((s) => + { + if (s != null) DeviceProcessLogShow(s); + }); + modbus.ShowEx += new Action((s) => + { + if ((s != null)) DeviceProcessLogShow(s); + }); + modbus.ModbusTcpConnect(ip, port); + + } + #endregion + /// + /// ƶ + /// + public ConcurrentQueue orderLocInfos = new ConcurrentQueue(); + + } +} diff --git a/BPASmartClient.MorkMW/GVL_MorkMW.cs b/BPASmartClient.MorkMW/GVL_MorkMW.cs new file mode 100644 index 00000000..c4d8c375 --- /dev/null +++ b/BPASmartClient.MorkMW/GVL_MorkMW.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkMW +{ + public class GVL_MorkMW + { + #region 机器人信号 + + + /// + /// 机器人空闲信号 + /// + public bool RobotIdle { get; set; } + + public bool TakeWinkOneComplete { get; set; } + public bool TakeWinkTwoComplete { get; set; } + public bool TakeWinkThreeComplete { get; set; } + public bool TakeWinkFourComplete { get; set; } + public bool TakeWinkFiveComplete { get; set; } + public bool TakeWinkSixComplete { get; set; } + + + + + public bool ArriveWinkOneLoc { get; set; } + + public bool ArriveWinkTwoLoc { get; set; } + + public bool ArriveWinkThreeLoc { get; set; } + + public bool ArriveWinkFourLoc { get; set; } + + public bool ArriveWinkFiveLoc { get; set; } + + public bool ArriveWinkSixLoc { get; set; } + /// + /// 放杯处传感器信号 + /// + public bool CupSignal { get; set; } + /// + /// 摇酒完成信号 + /// + public bool MixWinkComplte { get; set; } + /// + /// 机器人倒完酒并回到初始位的完成信号 + /// + public bool ProcessComplete { get; set; } + #endregion + + + #region 流程控制 + /// + /// 任务锁 + /// + public bool TaskLock { get; set; } + /// + /// 接酒完成 + /// + public bool AllowMixWink { get; set; } + + /// + /// 调酒完成 + /// + public bool AllowPourWink { get; set; } + /// + /// 倒酒结束标志 + /// + public bool PourWinkComplete { get; set; } + #endregion + } +} diff --git a/BPASmartClient.MorkMW/Model/OrderLocInfo.cs b/BPASmartClient.MorkMW/Model/OrderLocInfo.cs new file mode 100644 index 00000000..e2894ed1 --- /dev/null +++ b/BPASmartClient.MorkMW/Model/OrderLocInfo.cs @@ -0,0 +1,19 @@ +using BPASmartClient.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkMW.Model +{ + public class OrderLocInfo + { + public string SuborderId { get; set; } + /// + /// 单个订单的制作流程 + /// + public List mixWink=new List(); + public string GoodName { get; set; } + } +} diff --git a/BPASmartClient.MorkMW/Model/SimRecipeModel.cs b/BPASmartClient.MorkMW/Model/SimRecipeModel.cs new file mode 100644 index 00000000..071ac08c --- /dev/null +++ b/BPASmartClient.MorkMW/Model/SimRecipeModel.cs @@ -0,0 +1,18 @@ +using BPASmartClient.Model; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkMW.Model +{ + public class SimRecipeModel + { + + public string GoodsName { get; set; } + + public ObservableCollection recipe { get; set; } = new ObservableCollection();// { new MixWinkModel { materialName="白兰地",Loc=7,Time=2} }; + } +} diff --git a/BPASmartClient.MorkMW/View/DebugView.xaml b/BPASmartClient.MorkMW/View/DebugView.xaml new file mode 100644 index 00000000..9620dd48 --- /dev/null +++ b/BPASmartClient.MorkMW/View/DebugView.xaml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +