From 2a3924abacaab4597264f10818d4969f791c5dc7 Mon Sep 17 00:00:00 2001
From: NXX <447201003@qq>
Date: Tue, 25 Oct 2022 13:22:35 +0800
Subject: [PATCH 01/22] morkf
---
.../BPASmartClient.Business.csproj | 2 +-
BPASmartClient.Business/Plugin/DeviceMgr.cs | 2 +-
.../BPASmartClient.CustomResource.csproj | 2 +-
.../BPASmartClient.Device.csproj | 2 +-
.../BPASmartClient.DosingHKProject.csproj | 2 +-
.../BPASmartClient.JXJFoodSmallStation.csproj | 2 +-
.../Model/RawMaterial/DeviceInquire.cs | 4 +-
.../View/RecipeConfige.xaml.cs | 177 +-
BPASmartClient.Modbus/ModbusTcp.cs | 28 +-
.../BPASmartClient.Model.csproj | 2 +-
.../BPASmartClient.MorkF.csproj | 3 +-
BPASmartClient.MorkF/Control_MorkF.cs | 2553 ++++-------------
BPASmartClient.MorkF/GVL_MorkF.cs | 367 +--
.../Model/StirFryPushMessages.cs | 14 +
BPASmartClient.MorkF/OrderLocInfo.cs | 6 +-
BPASmartClient.MorkF/View/DebugView.xaml | 126 +-
BPASmartClient.MorkF/View/DebugView.xaml.cs | 2 +-
.../ViewModel/DebugViewModel.cs | 150 +-
.../BPASmartClient.MorkS.csproj | 2 +-
.../BPASmartClient.MorkTHQ.csproj | 2 +-
.../ShopDeviceConfigViewModel.cs | 4 +-
.../Control/ShopDeviceConfigView.xaml.cs | 37 +-
.../BPASmartClient.DosingSystem.csproj | 2 +-
23 files changed, 1148 insertions(+), 2343 deletions(-)
create mode 100644 BPASmartClient.MorkF/Model/StirFryPushMessages.cs
diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj
index 5acb186c..0a299989 100644
--- a/BPASmartClient.Business/BPASmartClient.Business.csproj
+++ b/BPASmartClient.Business/BPASmartClient.Business.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/BPASmartClient.Business/Plugin/DeviceMgr.cs b/BPASmartClient.Business/Plugin/DeviceMgr.cs
index 3a81e207..887ec80a 100644
--- a/BPASmartClient.Business/Plugin/DeviceMgr.cs
+++ b/BPASmartClient.Business/Plugin/DeviceMgr.cs
@@ -95,7 +95,7 @@ namespace BPASmartClient.Business
#region 获取物料数据
string result = string.Empty;
- for (int i = 0; i < 2; i++)
+ for (int i = 0; i < 3; i++)
{
try
{
diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
index 5df25cfc..58565f9b 100644
--- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
+++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
@@ -396,7 +396,7 @@
-
+
diff --git a/BPASmartClient.Device/BPASmartClient.Device.csproj b/BPASmartClient.Device/BPASmartClient.Device.csproj
index ec00f1d4..dc5df46f 100644
--- a/BPASmartClient.Device/BPASmartClient.Device.csproj
+++ b/BPASmartClient.Device/BPASmartClient.Device.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/BPASmartClient.DosingProject/BPASmartClient.DosingHKProject.csproj b/BPASmartClient.DosingProject/BPASmartClient.DosingHKProject.csproj
index 0031ee4d..fe9551e2 100644
--- a/BPASmartClient.DosingProject/BPASmartClient.DosingHKProject.csproj
+++ b/BPASmartClient.DosingProject/BPASmartClient.DosingHKProject.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj
index 4ee61c76..0944c51b 100644
--- a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj
+++ b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
index 10f0f3c8..6b1fd24e 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
@@ -348,8 +348,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (modbusTcp.Connected)
{
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量
- string returnValue = modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
- if (returnValue.Substring(0, 2) == "成功")
+ bool returnValue = modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
+ if (returnValue)
{
MessageLog.GetInstance.ShowRunLog("发送成功" + returnValue);
}
diff --git a/BPASmartClient.MilkWithTea/View/RecipeConfige.xaml.cs b/BPASmartClient.MilkWithTea/View/RecipeConfige.xaml.cs
index 389aab52..abaf3f39 100644
--- a/BPASmartClient.MilkWithTea/View/RecipeConfige.xaml.cs
+++ b/BPASmartClient.MilkWithTea/View/RecipeConfige.xaml.cs
@@ -26,6 +26,12 @@ namespace BPASmartClient.MilkWithTea.View
Border ultUE;
Popup mypopup;
ListBoxItem OldItem;
+ bool isDown = false;
+
+ ///
+ /// 当前拖拽子控件Item
+ ///
+ private ListBoxItem ChildListBoxItem;
public RecipeConfige()
{
@@ -102,60 +108,141 @@ namespace BPASmartClient.MilkWithTea.View
private void listview1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
- var pos = e.GetPosition(listview1);
- HitTestResult result = VisualTreeHelper.HitTest(listview1, pos);
- OldItem = Utils.FindVisualParent(result.VisualHit);
- if(OldItem != null)
+ try
{
- if (e.Source is Border)
+ if (isDown)
+ {
+ isDown = false;
+ return;
+ }
+ var pos = e.GetPosition(listview1);
+ HitTestResult result = VisualTreeHelper.HitTest(listview1, pos);
+ if (result == null) return;
+ OldItem = Utils.FindVisualParent(result.VisualHit);
+ if (OldItem != null)
{
- ultUE = (Border)e.Source;
- ultUE.CaptureMouse();
- ultUE.Visibility = Visibility.Collapsed;
- CloneVisual(ultUE, e);
+ if (e.Source is Border)
+ {
+ ultUE = (Border)e.Source;
+ ultUE.CaptureMouse();
+ ChildListBoxItem = Utils.FindVisualParent(VisualTreeHelper.HitTest(ultUE, e.GetPosition(ultUE)).VisualHit);
+ CloneVisual(ultUE, e);
+ isDown = true;
+ }
}
}
+ catch (Exception)
+ {
+
+ throw;
+ }
}
private void listview1_MouseMove(object sender, MouseEventArgs e)
{
- Point ptLeftUp = new Point(0, 0);
- Point ptRightDown = new Point(this.ActualWidth, this.ActualHeight);
- ptLeftUp = listview1.PointToScreen(ptLeftUp);
- ptRightDown = listview1.PointToScreen(ptRightDown);
- double y = e.GetPosition(listview1).Y;
- double x = e.GetPosition(listview1).X;
- if (mypopup != null)
- {
- mypopup.HorizontalOffset = ptLeftUp.X + x - ((FrameworkElement)ultUE).ActualWidth / 2;
- mypopup.VerticalOffset = ptLeftUp.Y + y - ((FrameworkElement)ultUE).ActualHeight / 2;
- }
+ if (isDown == false) return;
+ if (e.LeftButton != MouseButtonState.Pressed)
+ listview1_MouseLeftButtonUp(null,null);
+ Point ptLeftUp = new Point(0, 0);
+ Point ptRightDown = new Point(this.ActualWidth, this.ActualHeight);
+ ptLeftUp = listview1.PointToScreen(ptLeftUp);
+ ptRightDown = listview1.PointToScreen(ptRightDown);
+ double y = e.GetPosition(listview1).Y;
+ double x = e.GetPosition(listview1).X;
+ if (mypopup != null)
+ {
+ mypopup.HorizontalOffset = ptLeftUp.X + x - ((FrameworkElement)ultUE).ActualWidth / 2;
+ mypopup.VerticalOffset = ptLeftUp.Y + y - ((FrameworkElement)ultUE).ActualHeight / 2;
+ }
+ MoveListBoxStyle(e, true);
+
+
}
private void listview1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
- if(mypopup != null)
+ //鼠标未按下返回
+ if (!isDown) return;
+
+ isDown = false;
+ if (mypopup != null)
{
mypopup.IsOpen = false;
mypopup = null;
}
-
- if (OldItem == null) return;
- var pos = e.GetPosition(listview1);
- HitTestResult result = VisualTreeHelper.HitTest(listview1, pos);
- if(result == null) return;
- var Newitem = Utils.FindVisualParent(result.VisualHit);
- if (Newitem == null) return;
- if (OldItem == Newitem) return;
- int iold = listview1.Items.IndexOf((LocalMaterail)OldItem.DataContext);
- int inew = listview1.Items.IndexOf((LocalMaterail)Newitem.DataContext);
- RecipeConfigeViewModel.Materails.Move(iold,inew);
+
+ MoveListBoxStyle(e, false);
+ //if (OldItem == null) return;
+ //var pos = e.GetPosition(listview1);
+ //HitTestResult result = VisualTreeHelper.HitTest(listview1, pos);
+ //if(result == null) return;
+ //var Newitem = Utils.FindVisualParent(result.VisualHit);
+ //if (Newitem == null) return;
+ //if (OldItem == Newitem) return;
+ //int iold = listview1.Items.IndexOf((LocalMaterail)OldItem.DataContext);
+ //int inew = listview1.Items.IndexOf((LocalMaterail)Newitem.DataContext);
+ //RecipeConfigeViewModel.Materails.Move(iold,inew);
}
+
+ ///
+ /// 移动效果
+ ///
+ ///
+ private void MoveListBoxStyle(MouseEventArgs e, bool isBool)
+ {
+ try
+ {
+ if (isBool)//为真,根据鼠标位置设置行透明度和显示状态
+ {
+ //移动到某行减轻某行 暗黑
+ foreach (ListBoxItem item in Utils.FindVisualChildren(listview1))
+ {
+ if (item != ChildListBoxItem)//这就是其他控件
+ {
+ double item_width = item.ActualWidth; //当前行宽
+ double item_height = item.ActualHeight; //当前行高
+ double item_x = e.GetPosition(item).X; //鼠标相对当前行X位移
+ double item_y = e.GetPosition(item).Y; //鼠标相对当前行Y位移
+
+ if (item_y <= item_height && item_y > 0 && item_x > 0 && item_x <= item_width)//鼠标进入哪一行,则将那一行变灰
+ {
+ item.Opacity = 0.5;
+ int lao_index = RecipeConfigeViewModel.Materails.IndexOf(item.Content as LocalMaterail);
+ int new_index = RecipeConfigeViewModel.Materails.IndexOf(ChildListBoxItem.Content as LocalMaterail);
+ RecipeConfigeViewModel.Materails.Move(lao_index, new_index);
+ }
+ else //鼠标没在哪一行,则保持原状
+ {
+ item.Opacity = 1;
+ }
+ }
+ else
+ {
+ item.Visibility = Visibility.Hidden;
+ }
+ }
+ }
+ else//为假 恢复所有行透明度和显示状态
+ {
+ //移动到某行减轻某行 暗黑
+ foreach (ListBoxItem item in Utils.FindVisualChildren(listview1))
+ {
+ item.Opacity = 1;
+ item.Visibility = Visibility.Visible;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ }
+ }
}
+
+
internal static class Utils
{
//根据子元素查找父元素
@@ -170,5 +257,31 @@ namespace BPASmartClient.MilkWithTea.View
}
return null;
}
+
+ ///
+ /// 查询子控件
+ ///
+ ///
+ ///
+ ///
+ public static IEnumerable FindVisualChildren(DependencyObject depObj) where T : DependencyObject
+ {
+ if (depObj != null)
+ {
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
+ {
+ DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
+ if (child != null && child is T)
+ {
+ yield return (T)child;
+ }
+
+ foreach (T childOfChild in FindVisualChildren(child))
+ {
+ yield return childOfChild;
+ }
+ }
+ }
+ }
}
}
diff --git a/BPASmartClient.Modbus/ModbusTcp.cs b/BPASmartClient.Modbus/ModbusTcp.cs
index 8734228e..dd519e8a 100644
--- a/BPASmartClient.Modbus/ModbusTcp.cs
+++ b/BPASmartClient.Modbus/ModbusTcp.cs
@@ -1,4 +1,5 @@
using BPASmartClient.Helper;
+using BPASmartClient.Message;
//using BPASmartClient.Message;
using NModbus;
using System;
@@ -55,7 +56,7 @@ namespace BPASmartClient.Modbus
IPAdress = ip;
Port = port;
modbusFactory = new ModbusFactory();
- Connect();
+ Connect();
if (Connected)
{
master.Transport.ReadTimeout = 2000;//读取超时时间
@@ -131,6 +132,18 @@ namespace BPASmartClient.Modbus
}
}
}
+ if (address.ToUpper().Contains("LB") && address.Length >= 3)
+ {
+ var res = address.Substring(2);
+ if (res != null && res.Length > 0)
+ {
+ if(int.TryParse(res, out int firstAddress))
+ {
+ return firstAddress;
+ }
+ }
+ }
+
else if (address.ToUpper().Contains("VW") && address.Length >= 3)
{
var res = address.Substring(2);
@@ -242,6 +255,11 @@ namespace BPASmartClient.Modbus
commandType = CommandType.Inputs;
return master.ReadInputs(slaveAddress, startAddress, len);
}
+ else if (address.ToUpper().Contains("LB"))
+ {
+ commandType = CommandType.Coils;
+ return master.ReadCoils(slaveAddress, startAddress, len);
+ }
}
catch (Exception ex)
@@ -306,6 +324,14 @@ namespace BPASmartClient.Modbus
else if (value is bool[] boolsValue)
master.WriteMultipleCoils(slaveAddress, startAddress, boolsValue);
}
+ else if(address.ToUpper().Contains("LB"))
+ {
+ commandType = CommandType.Coils;
+ if (value is bool boolValue)
+ master.WriteSingleCoil(slaveAddress, startAddress, boolValue);
+ else if (value is bool[] boolsValue)
+ master.WriteMultipleCoils(slaveAddress, startAddress, boolsValue);
+ }
else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW") || address.ToUpper().Contains("D"))
{
commandType = CommandType.HoldingRegisters;
diff --git a/BPASmartClient.Model/BPASmartClient.Model.csproj b/BPASmartClient.Model/BPASmartClient.Model.csproj
index 953b9861..87c447b0 100644
--- a/BPASmartClient.Model/BPASmartClient.Model.csproj
+++ b/BPASmartClient.Model/BPASmartClient.Model.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj
index 9e968e28..ab9195b2 100644
--- a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj
+++ b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj
@@ -10,10 +10,11 @@
-
+
+
diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs
index 87fecb75..bebf66c2 100644
--- a/BPASmartClient.MorkF/Control_MorkF.cs
+++ b/BPASmartClient.MorkF/Control_MorkF.cs
@@ -19,8 +19,6 @@ namespace BPASmartClient.MorkF
public AutoResetEvent minorReset = new AutoResetEvent(false);
public AutoResetEvent mainReset = new AutoResetEvent(false);
GVL_MorkF morkF = new GVL_MorkF();//全局对象声明
- public StirFryBom stirFryBom = new StirFryBom();//创建获取流程的对象
- List stirFryGoods = new List();//创建商品对象
List resultorder = new List();//调试变量
///
/// 入口
@@ -35,20 +33,31 @@ namespace BPASmartClient.MorkF
#region 调试代码
public void CommandRegist()
{
- #region 设备控制
+ #region 设备控制
ActionManage.GetInstance.Register(PLCInite, "InitCommand");
+ ActionManage.GetInstance.Register(FoodPlcInite, "FoodPlcInite");
ActionManage.GetInstance.Register(InitialData, "SimultaorOrder");
-
+
#endregion
- ActionManage.GetInstance.Register(ShreddCabbage, "ShreddCabbage");
- ActionManage.GetInstance.Register(FryPork, "FryPork");
- ActionManage.GetInstance.Register(XingBaoGu, "XingBaoGu");
+ #region 菜品库
+ ActionManage.GetInstance.Register(FoodLibInit, "FoodLibInit");
+ ActionManage.GetInstance.Register(Electromagnetism, "Electromagnetism");
+ ActionManage.GetInstance.Register(Electromagnetism, "Electromagnetism");
+ ActionManage.GetInstance.Register(GetDistance_1, "GetDistance_1");
+ ActionManage.GetInstance.Register(GetDistance_2, "GetDistance_2");
+ ActionManage.GetInstance.Register(GetDistance_3, "GetDistance_3");
+ ActionManage.GetInstance.Register(PawTurnFront, "PawTurnFront");
+ ActionManage.GetInstance.Register(PawTurnBack, "PawTurnBack");
+ ActionManage.GetInstance.Register(SetArmPosition, "SetArmPosition");
+ #endregion
+ //ActionManage.GetInstance.Register(PLCInite, "InitCommand");
#region 配料控制
- ActionManage.GetInstance.Register(OutMaterials, "OutMaterials");
+ ActionManage.GetInstance.Register(OutSeasoning, "OutMaterials");
#endregion
#region 炒锅1
+ ActionManage.GetInstance.Register(Plc1Reset, "Plc1Reset");
ActionManage.GetInstance.Register(AddOil, "AddOil");
ActionManage.GetInstance.Register(StartFire, "StartFire");
ActionManage.GetInstance.Register(StopFire, "StopFire");
@@ -66,142 +75,195 @@ namespace BPASmartClient.MorkF
}
-
- ///
- /// 手撕包菜流程
- ///
- public void ShreddCabbage()
+ #region 菜品库
+
+ public void FoodLibInit()
+ {
+ WriteControl("",true);
+ }
+ public void Electromagnetism(object o)
{
- if (stirFryBom.StirFryActions.Count > 0)
+ if (o == null) return;
+ if (o is List bs && bs.Count == 1)
{
- stirFryBom.StirFryActions.Clear();
+ WriteControl("", bs[0]);
}
- //流程
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List() { StirFryRobotAction.清洗槽取锅 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List() { StirFryPotAction.大火持续 }, During = 5 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, RobotActions = new List() { StirFryRobotAction.取A料 }, PotActions = new List() { StirFryPotAction.加油, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 6 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List() { StirFryPotAction.停止旋转, StirFryPotAction.停止火力, StirFryPotAction.搅拌臂上位 } });//加A料
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List() { StirFryRobotAction.取B料 }, PotActions = new List() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 6 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, RobotActions = new List() { StirFryRobotAction.取C料 }, PotActions = new List() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 9 });
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List() { StirFryRobotAction.灶取锅 } });
- morkF.listStirBom.Add(stirFryBom);
}
+ public void GetDistance_1()
+ {
+ WriteControl("", true);
+ }
+ public void GetDistance_2()
+ {
+ WriteControl("", true);
+ }
+ public void GetDistance_3()
+ {
+ WriteControl("", true);
+ }
+ public void PawTurnFront()
+ {
+ WriteControl("", true);
+ }
+ public void PawTurnBack()
+ {
+ WriteControl("", true);
+ }
+ ///
+ /// 设定机械臂的位置
+ ///
+ ///
+ ///
+ public void SetArmPosition(int X, int y)
+ {
+ WriteControl("", true);
+ }
+ #endregion
+
///
- /// 盐煎肉流程
+ /// 出调料
///
- public void FryPork()
+ ///
+ public void OutSeasoning(object o)
{
- if (stirFryBom.StirFryActions.Count > 0)
+ if (o == null) return;
+ if (o is List ints && ints.Count == 2)
{
- stirFryBom.StirFryActions.Clear();
+ WriteControl(morkF.PassWayValue[ints[0]], (ushort)ints[1]);//写入通道值
+ Thread.Sleep(400);
+ WriteControl(morkF.StartPassWay[ints[0]], true);//开启通道
+ Thread.Sleep(400);
}
- //流程
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List() { StirFryRobotAction.清洗槽取锅 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 15 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List() { StirFryPotAction.加油, StirFryPotAction.停止火力 }, During = 19 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List() { StirFryRobotAction.加入A料 } });
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 20 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List() { StirFryPotAction.停止火力 }, During = 35 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位, } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, RobotActions = new List() { StirFryRobotAction.加入B料 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 22 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, PotActions = new List() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T12, RobotActions = new List() { StirFryRobotAction.加入C料 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T13, PotActions = new List() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 70 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T14, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T15, RobotActions = new List() { StirFryRobotAction.灶取锅 } });
}
///
- /// 酱烧杏鲍菇流程
+ /// 出多个调料
///
- public void XingBaoGu()
+ public void OutSeasonings(List seasoningLists)
{
- if (stirFryBom.StirFryActions.Count > 0)
+ foreach(SeasoningList seasoning in seasoningLists)
{
- stirFryBom.StirFryActions.Clear();
+ WriteControl(morkF.PassWayValue[seasoning.Loc], (ushort)seasoning.Qty);
+ Thread.Sleep(300);
}
- //流程
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List() { StirFryRobotAction.清洗槽取锅 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, RobotActions = new List() { StirFryRobotAction.加入A料 }, PotActions = new List() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 5 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List() { StirFryPotAction.加油 }, During = 12 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加A料
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, RobotActions = new List() { StirFryRobotAction.加入B料 }, PotActions = new List() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 25 });
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, RobotActions = new List() { StirFryRobotAction.加入C料 }, PotActions = new List() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 });
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 55 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List() { StirFryRobotAction.灶取锅 } });
+ foreach (SeasoningList seasoning in seasoningLists)
+ {
+ WriteControl(morkF.StartPassWay[seasoning.Loc], true);
+ Thread.Sleep(300);
+ }
+
}
- //出配料
- public void OutMaterials(object o)
+
+ #region 炒锅1
+ ///
+ /// 复位
+ ///
+ public void Plc1Reset()
{
- if (o == null) return;
- if (o is List ints && ints.Count == 2)
+ StopFire();
+ Thread.Sleep(200);
+ StopStir();
+ Thread.Sleep(200);
+ WriteControl("LB5", false);
+ Thread.Sleep(200);
+ WriteControl("LB3", false);
+ Thread.Sleep(200);
+ WriteControl("LB6", false);
+ Thread.Sleep(200);
+ WriteControl("LB7", false);
+ Thread.Sleep(200);
+ WriteControl("LB4", false);
+ Thread.Sleep(200);
+ WriteControl("LB53", false);
+ foreach(var item in morkF.StartPassWay.Values)
{
- WriteControl(morkF.PassWayValue[ints[0]], ints[1]);//写入通道值
- Thread.Sleep(500);
- WriteControl(morkF.StartPassWay[ints[0]], true);//开启通道
+ Thread.Sleep(200);
+ WriteControl(item, false);
}
}
+ //加油
+ public void AddOil()
+ {
- #region 炒锅1
+ }
//加热启动
public void StartFire()
{
- WriteControl("M0.1", true);
+ WriteControl("LB1", true);
+ Thread.Sleep(200);
}
//加热停止
public void StopFire()
{
- WriteControl("M0.1", false);
+ WriteControl("LB1", false);
+ Thread.Sleep(200);
}
//搅拌启动
public void StartStir()
{
- WriteControl("M0.2", true);
+ WriteControl("LB2", true);
+ Thread.Sleep(200);
}
//搅拌启停止
public void StopStir()
{
- WriteControl("M0.2", false);
+ WriteControl("LB2", false);
+ Thread.Sleep(200);
}
//倒菜
public void OutFood()
{
- WriteControl("M0.3", true);
+ WriteControl("LB3", true);
+ MessageLog.GetInstance.Show("倒菜启动");
+ while (!morkF.FryPot1_MaterialIntoPot)
+ {
+ Thread.Sleep(200);
+ }
+ WriteControl("LB3", false);
+ Thread.Sleep(200);
+ MessageLog.GetInstance.Show("倒菜完成");
}
//搅拌臂去原点位
public void StirArmGoOrigin()
{
- WriteControl("M0.5", true);
+ WriteControl("LB5", true);
+ MessageLog.GetInstance.Show("搅拌臂去原点位");
+ while (!morkF.ArmOnOrigin)
+ {
+ Thread.Sleep(200);
+ }
+ WriteControl("LB5", false);
+ Thread.Sleep(200);
+ MessageLog.GetInstance.Show("搅拌臂到达原点位");
+
}
//搅拌臂去炒制位
public void StirArmGoWork()
{
- WriteControl("M0.6", true);
+ WriteControl("LB6", true);
+ MessageLog.GetInstance.Show("搅拌臂去工作位");
+ while (!morkF.ArmOnWorking)
+ {
+ Thread.Sleep(200);
+ }
+
+ WriteControl("LB6", false);
+ Thread.Sleep(200);
+ MessageLog.GetInstance.Show("搅拌臂到达工作位");
}
//HBOT放盒子到位
public void HBOTGoWork()
{
- WriteControl("M0.7", true);
+ WriteControl("LB7", true);
+ Thread.Sleep(400);
+ WriteControl("LB7", false);
}
//出餐启动
public void OutMeal()
{
- WriteControl("M0.4", true);
+ WriteControl("LB4", true);
+ Thread.Sleep(200);
+ WriteControl("LB4", false);
}
//加热挡位设定
public void SetFire(object o)
@@ -209,19 +271,24 @@ namespace BPASmartClient.MorkF
if(o == null) return;
if(o is List ints&&ints.Count == 1)
{
- WriteControl("VW228",ints[0]);
-
+ WriteControl("LW14", (ushort)ints[0]);
+ Thread.Sleep(200);
+
}
}
- //搅拌挡位设定
+
+ ///
+ /// 搅拌挡位设定
+ ///
+ ///
public void SetStir(object o)
{
if (o == null) return;
if (o is List ints && ints.Count == 1)
{
- WriteControl("VW230", ints[0]);
-
+ WriteControl("LW15", (ushort)ints[0]);
+ Thread.Sleep(200);
}
}
@@ -243,27 +310,16 @@ namespace BPASmartClient.MorkF
//morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId });
//resultorder.AddRange(new int[] { 1, 2, 3 });
- for (int i = 0; i < morkF.listStirBom.Count; i++)
- {
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List() { 1 } });//A料
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List() { 2 } });//B料
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List() { 3 } });//C料
- morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i });
- //resultorder.AddRange(new int[] { 1, 2, 3 });
- }
+ //for (int i = 0; i < morkF.listStirBom.Count; i++)
+ //{
+ // morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List() { 1 } });//A料
+ // morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List() { 2 } });//B料
+ // morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List() { 3 } });//C料
+ // morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i });
+ // //resultorder.AddRange(new int[] { 1, 2, 3 });
+ //}
- //多个订单
- //string subId = Guid.NewGuid().ToString();
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List() { 1 } });//A料
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List() { 2 } });//B料
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List() { 3 } });//C料
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1, MaterialLoc = new List() { 1 } });//A料
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1, MaterialLoc = new List() { 2 } });//B料
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1, MaterialLoc = new List() { 3 } });//C料
- //morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId });
- //morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1 });
- //resultorder.AddRange(new int[] { 1, 2, 3 });
- //resultorder.AddRange(new int[] { 1, 2, 3 });
+
}
#endregion
@@ -280,42 +336,38 @@ namespace BPASmartClient.MorkF
public override void ReadData()
{
- GetStatus("M0.1", new Action((bools) =>
- {
- Initing = bools[0];
- morkF.InitialComplete = Initing;
- }));
- GetStatus("M1.0", new Action((bools) =>
+ GetStatus("LB50", new Action((bools) =>
{
- morkF.ProvidePlateModule = bools[0];
- morkF.ProvidePlateComplete = bools[2];
- morkF.CleanModule = bools[3];
- morkF.CleanComplete = bools[5];
+ morkF.FryPot1_InitialComplete = bools[0];
+ morkF.FryPot1_HOBTPut = bools[1];
+ morkF.FryPot1_HOBTGet = bools[2];
+ morkF.FryPot1_MaterialIntoPot = bools[3];
+ morkF.OutFoodCompelete = bools[4];
+ morkF.CanOutFood = bools[5];
+ morkF.GetFoodCompelete = bools[6];
+ morkF.CanOutPotWashingWater = bools[7];
+ morkF.ArmOnOrigin = bools[8];
+ morkF.ArmOnWorking = bools[9];
+ morkF.PotOnOrigin = bools[10];
}));
- GetStatus("M2.0", new Action((bools) =>
+ GetStatus("LB74", new Action((bools) =>
{
- morkF.KitchenOneStatus = bools[1];
- morkF.KitchenSecondStatus = bools[4];
- morkF.FallOilComplete = bools[8];
- }));
- GetStatus("M8.0", new Action((bools) =>
- {
- morkF.TurnMachineUpComplete = bools[1];
- morkF.TurnMachineDownComplete = bools[3];
- }));
- GetStatus("M13.5", new Action((bools) =>
- {
- morkF.MaterialArriveComplete = bools[0];
+ for (int i = 0; i < 15; i++)
+ {
+ morkF.PassWay1_Compelete[i] = bools[i];
+ }
+
+
}));
- GetStatus("M16.0", new Action((bools) =>
+ GetStatus("LB90", new Action((bools) =>
{
- morkF.PutPotToKitchenComlete = bools[1];
- morkF.TakeMaterialComplete = bools[2];
- morkF.FallMaterialComplete = bools[3];
- morkF.PlaceRinseTableComplete = bools[5];
- morkF.RoobotIdle = bools[6];
+ morkF.AutoMode = bools[0];
+
}));
+
+
+
}
private void ServerInit()
{
@@ -337,7 +389,6 @@ namespace BPASmartClient.MorkF
if (@event is RecipeBomEvent recipe)
{
recipeBoms = recipe.recipeBoms;
- WriteRecipeBoms();
}
});
//小炒流程信息
@@ -346,118 +397,98 @@ namespace BPASmartClient.MorkF
if (@event == null) return;
if (@event is StirFryGoodsEvent stirFry)
{
- stirFryGoods = stirFry.stirFrymessage.stirFryGoods;
+ morkF.LocalstirFryGoods = stirFry.stirFrymessage.stirFryGoods;
MessageLog.GetInstance.Show("接收到小炒流程信息");
//流程解析
- foreach (var item in stirFryGoods)
+ foreach (var item in morkF.LocalstirFryGoods)
{
- MessageLog.GetInstance.ShowEx($"执行菜谱{item.GoodsKey}");
+ MessageLog.GetInstance.Show($"添加菜谱{item.GoodsKey}");
// morkF.listStirBom.Add(item.StirFryBomInfo);//添加订单制作流程
- foreach (var items in item.StirFryBomInfo.StirFryActions)
+ foreach (var items in item.StirPotActions)
{
- MessageLog.GetInstance.Show($"执行流程{items.Time}");
- foreach (var pro in items.RobotActions)
- {
- switch (pro)
- {
- case StirFryRobotAction.等待:
- MessageLog.GetInstance.Show($"等待");
- break;
- case StirFryRobotAction.清洗槽取锅:
- MessageLog.GetInstance.Show($"清洗槽取锅");
- break;
- case StirFryRobotAction.灶放锅:
- MessageLog.GetInstance.Show($"灶放锅");
- break;
- case StirFryRobotAction.清洗槽放锅:
- MessageLog.GetInstance.Show($"清洗槽放锅");
- break;
- case StirFryRobotAction.取A料:
- MessageLog.GetInstance.Show($"取A料");
- break;
- case StirFryRobotAction.取B料:
- MessageLog.GetInstance.Show($"取B料");
- break;
- case StirFryRobotAction.取C料:
- MessageLog.GetInstance.Show($"取C料");
- break;
- case StirFryRobotAction.加入A料:
- MessageLog.GetInstance.Show($"加入A料");
- break;
- case StirFryRobotAction.加入B料:
- MessageLog.GetInstance.Show($"加入B料");
- break;
- case StirFryRobotAction.加入C料:
- MessageLog.GetInstance.Show($"加入C料");
- break;
- case StirFryRobotAction.切换快速:
- MessageLog.GetInstance.Show($"切换快速");
- break;
- case StirFryRobotAction.切换中速:
- MessageLog.GetInstance.Show($"切换中速");
- break;
- case StirFryRobotAction.丢料盒:
- MessageLog.GetInstance.Show($"丢料盒");
- break;
- case StirFryRobotAction.倒菜:
- MessageLog.GetInstance.Show($"倒菜");
- break;
- case StirFryRobotAction.灶取锅:
- MessageLog.GetInstance.Show($"灶取锅");
- break;
- }
- }
- foreach (var pro in items.PotActions)
+ switch (items.Actions)
{
- switch (pro)
- {
- case StirFryPotAction.NONE:
- break;
- case StirFryPotAction.加热:
- MessageLog.GetInstance.Show($"加热");
- break;
- case StirFryPotAction.大火t1s:
- MessageLog.GetInstance.Show($"大火1s");
- break;
- case StirFryPotAction.加油:
- MessageLog.GetInstance.Show($"加油");
- break;
- case StirFryPotAction.中火t2s:
- MessageLog.GetInstance.Show($"中火2s");
- break;
- case StirFryPotAction.小火持续:
- MessageLog.GetInstance.Show($"小火持续");
- break;
- case StirFryPotAction.中火持续:
- MessageLog.GetInstance.Show($"中火持续");
- break;
- case StirFryPotAction.大火持续:
- MessageLog.GetInstance.Show($"大火持续");
- break;
- case StirFryPotAction.停止火力:
- MessageLog.GetInstance.Show($"停止火力");
- break;
- case StirFryPotAction.搅拌臂上位:
- MessageLog.GetInstance.Show($"搅拌臂上位");
- break;
- case StirFryPotAction.搅拌臂中位:
- MessageLog.GetInstance.Show($"搅拌臂中位");
- break;
- case StirFryPotAction.搅拌臂下位:
- MessageLog.GetInstance.Show($"搅拌臂下位");
- break;
- case StirFryPotAction.低速旋转:
- MessageLog.GetInstance.Show($"低速旋转");
- break;
- case StirFryPotAction.快速旋转:
- MessageLog.GetInstance.Show($"快速旋转");
- break;
- case StirFryPotAction.停止旋转:
- MessageLog.GetInstance.Show($"停止旋转");
- break;
- }
+ case "加热开启":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置加热挡位1":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置加热挡位2":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置加热挡位3":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置加热挡位4":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置加热挡位5":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置加热挡位6":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置加热挡位7":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置加热挡位8":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置加热挡位9":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置加热挡位10":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "停止加热":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "加调料":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "取原料":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "开启搅拌":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置搅拌挡位1":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置搅拌挡位2":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "设置搅拌挡位3":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "关闭搅拌":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "出餐启动":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "倒菜品":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "搅拌臂原点位":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "搅拌臂炒制位":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ case "洗锅":
+ MessageLog.GetInstance.Show(items.Actions);
+ break;
+ default:
+ break;
+
}
+
+
}
+
+
}
}
});
@@ -488,1785 +519,397 @@ namespace BPASmartClient.MorkF
OrderCount++;
DeviceProcessLogShow($"接收到{OrderCount}次订单");
- var res = stirFryGoods?.FirstOrDefault(p => p.GoodsKey == order.MorkOrder.RecipeId);//匹配订单对应制作流程
+ var res = morkF.LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey == order.MorkOrder.RecipeId);//匹配订单对应制作流程
if (res != null)
{
- morkF.listStirBom.Add(res.StirFryBomInfo);//添加订单制作流程
- if (morkF.TakeMaterialQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
+ /* morkF.listStirBom.Add(res.StirFryBomInfo);*///添加订单制作流程
+ if (morkF.StirFryGoodsQuenes.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
{
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, MaterialLoc = res.StirFryBomInfo.ALoc });
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, MaterialLoc = res.StirFryBomInfo.BLoc });
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, MaterialLoc = res.StirFryBomInfo.CLoc });
-
- }
-
-
- //foreach (var item in order.MorkOrder.GoodBatchings)
- //{
- if (morkF.TakePlateQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
- {
- morkF.TakePlateQueue.Enqueue(new OrderLocInfo()
+ morkF.StirFryGoodsQuenes.Enqueue(new OrderLocInfo()
{
SuborderId = order.MorkOrder.SuborderId,
+ StirPotActions = res.StirPotActions,
+ GoodName = order.MorkOrder.GoodsName
});
}
- //}
}
}
});
}
- //}
+
///
/// 主任务
///
public override void MainTask()
{
- TakePlatelTask();
- TurntableControl();
- MainProcessExecute();
- MinorProcessExcute();
- SingleProcess();
- }
- //辅流程执行
- private void MinorProcessExcute()
- {
- if (!morkF.MinorProcessExcuteLock)
- {
- morkF.MinorProcessExcuteLock = true;
- Task.Run(() =>
- {
- if (morkF.MinorProcessFlag && !morkF.RoobotIdle && morkF.TakeMaterialQueue.Count > 0 && morkF.listStirBom.Count > 0 )
- {
- morkF.MinorProessStatus = true;
- morkF.MainProcessStatus = false;
- StirFryBom bom = morkF.listStirBom.ElementAt(0);
- morkF.listStirBom.RemoveAt(0);
- foreach (var res in bom.StirFryActions)
- {
- DeviceProcessLogShow($"执行流程{res.Time}");
- //机器人线程
- Task taskRobot = Task.Run(new Action(() =>
- {
- foreach (var temp in res.RobotActions)
- {
- switch (temp)
- {
- case StirFryRobotAction.清洗槽取锅:
- TakePotTask();//执行取锅操作
- break;
- case StirFryRobotAction.取A料:
- TakeBurdenATask();//执行取A料操作
- break;
- case StirFryRobotAction.取B料:
- TakeBurdenATask();//执行取B料操作
- break;
- case StirFryRobotAction.取C料:
- TakeBurdenCTask();//执行取C料操作
- break;
- case StirFryRobotAction.灶取锅:
- MinorProcessOutDishTask();//执行出餐操作
- MinorProcessCleanPotTask();//洗锅操作
- break;
- }
-
- }
-
- }));
- //炒锅线程操作
- Task taskPot = Task.Run(new Action(() =>
- {
- foreach (var temp in res.PotActions)
- {
- switch (temp)
- {
- case StirFryPotAction.NONE:
- break;
- case StirFryPotAction.大火t1s:
- MinorProcessKitchenAdjustGears(3);
- // Task.Delay(1000).Wait(); //大火加热1s//执行大火锅干操作
- break;
- case StirFryPotAction.加油:
- AddOil();//注油//执行加油操作
- break;
- case StirFryPotAction.中火t2s:
- MinorProcessKitchenAdjustGears(2);
- Task.Delay(2000).Wait();//执行操作
- break;
- case StirFryPotAction.小火持续:
- MinorProcessKitchenAdjustGears(1);
- break;
- case StirFryPotAction.中火持续:
- MinorProcessKitchenAdjustGears(5);
- break;
- case StirFryPotAction.大火持续:
- MinorProcessKitchenAdjustGears(7);
- break;
- case StirFryPotAction.停止火力:
- MinorProcessKitchenAdjustGears(0);//关闭灶加热
- break;
- case StirFryPotAction.搅拌臂上位:
- MinorProcessTurnUpStatusDetect();//执行搅拌臂上位操作
- break;
- case StirFryPotAction.搅拌臂下位:
- MinorProcessTurnDownStatusDetect();//执行搅拌臂下位操作
- break;
- case StirFryPotAction.低速旋转:
- MinorProcessTurnMachineGearsControl(1);//执行搅拌臂速度1挡操作
- break;
- case StirFryPotAction.快速旋转:
- MinorProcessTurnMachineGearsControl(2);//执行搅拌臂速度3挡操作
- break;
- case StirFryPotAction.停止旋转:
- MinorProcessTurnMachineGearsControl(0);//执行搅拌臂速度0挡操作
- break;
- }
- }
- }));
- Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束
- Task.Delay(res.During * 1000).Wait();//当前流程延迟
- if (morkF.MainProcessWait)
- {
- if (morkF.MainHasTakeMaterial)
- {
-
- }
- else
- {
- MinorProcessKitchenAdjustGears(0);//关闭灶加热
- //阻塞辅流程
- minorReset.WaitOne();
- //morkF.MinorProessStatus = true;
- //morkF.MainProcessStatus = false;
- }
-
- }
-
- }
- morkF.MinorOutMealComplete = true;
- }
- else
- {
- morkF.MinorProcessExcuteLock = false;//解除辅流程自锁
- }
- });
- }
+ MainProcessExcute();
+ //MinorProcessExcute();
+ //SingleProcess();
}
- //机器人,锅灶主流程执行
- public void MainProcessExecute()
+ ///
+ /// 炒锅主流程
+ ///
+ private void MainProcessExcute()
{
- if (!morkF.MainProcessExcuteLock)
+ if(morkF.StirFryGoodsQuenes.Count>0&&morkF.AutoMode&&morkF.FryPot1_InitialComplete)//炒锅在自动状态&&初始化完成
{
- morkF.MainProcessExcuteLock = true;
- Task.Run(new Action(() =>
+ if(morkF.StirFryGoodsQuenes.TryDequeue(out var res))
{
- if (!morkF.RoobotIdle && morkF.InitialComplete && morkF.TakeMaterialQueue.Count > 0 && morkF.MainProcessFlag&& morkF.listStirBom.Count > 0)
+ foreach(var item in res.StirPotActions)
{
- morkF.MainProcessStatus = true;
- morkF.MinorProessStatus = false;
- StirFryBom bom = morkF.listStirBom.ElementAt(0);
- morkF.listStirBom.RemoveAt(0);
- foreach (var res in bom.StirFryActions)//遍历所有流程
+ switch (item.Actions)
{
- DeviceProcessLogShow($"执行流程{res.Time}");
- //机器人线程
- Task taskRobot = Task.Run(new Action(() =>
- {
- foreach (var temp in res.RobotActions)
- {
- switch (temp)
- {
- case StirFryRobotAction.清洗槽取锅:
- TakePotTask();//执行取锅操作
- break;
- case StirFryRobotAction.取A料:
- TakeBurdenATask();//执行取A料操作
- break;
- case StirFryRobotAction.取B料:
- TakeBurdenATask();//执行取B料操作
- break;
- case StirFryRobotAction.取C料:
- TakeBurdenCTask();//执行取C料操作
- break;
- case StirFryRobotAction.灶取锅:
- MainProcessOutDishTask();//执行出餐操作
- MainProcessCleanPotTask();//洗锅操作
- break;
- }
-
- }
-
- }));
- //炒锅线程操作
- Task taskPot = Task.Run(new Action(() =>
- {
- foreach (var temp in res.PotActions)
- {
- switch (temp)
- {
- case StirFryPotAction.NONE:
- break;
- case StirFryPotAction.大火t1s:
- MainProcessKitchenAdjustGears(3);
- // Task.Delay(1000).Wait(); //大火加热1s//执行大火锅干操作
- break;
- case StirFryPotAction.加油:
- AddOil();//注油//执行加油操作
- break;
- case StirFryPotAction.中火t2s:
- MainProcessKitchenAdjustGears(2);
- Task.Delay(2000).Wait();//执行操作
- break;
- case StirFryPotAction.小火持续:
- MainProcessKitchenAdjustGears(1);
- break;
- case StirFryPotAction.中火持续:
- MainProcessKitchenAdjustGears(5);
- break;
- case StirFryPotAction.大火持续:
- MainProcessKitchenAdjustGears(7);
- break;
- case StirFryPotAction.停止火力:
- MainProcessKitchenAdjustGears(0);//关闭灶加热
- break;
- case StirFryPotAction.搅拌臂上位:
- MainProcessTurnUpStatusDetect();//执行搅拌臂上位操作
- break;
- case StirFryPotAction.搅拌臂下位:
- MainProcessTurnDownStatusDetect();//执行搅拌臂下位操作
- break;
- case StirFryPotAction.低速旋转:
- MainProcessTurnMachineGearsControl(1);//执行搅拌臂速度1挡操作
- break;
- case StirFryPotAction.快速旋转:
- MainProcessTurnMachineGearsControl(2);//执行搅拌臂速度3挡操作
- break;
- case StirFryPotAction.停止旋转:
- MainProcessTurnMachineGearsControl(0);//执行搅拌臂速度0挡操作
- break;
- }
- }
- }));
- Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束
- Task.Delay(res.During * 1000).Wait();//当前流程延迟
- #region 两口锅逻辑
- //if (morkF.MinorProcessWait)
- //{
- // if (morkF.MinorHasTakeMaterial)//针对主流程准备出餐但辅流程机器人忙碌情况下,辅流程不阻塞
- // {
- // }
- // else
- // {
- // MainProcessKitchenAdjustGears(0);//关闭灶加热
- // //阻塞主流程
- // mainReset.WaitOne();
- // //morkF.MinorProessStatus = false;
- // //morkF.MainProcessStatus = true;
- // }
-
- //}
- #endregion
+ case "加热开启":
+ StartFire();
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置加热挡位1":
+ SetFire(new List { 1 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置加热挡位2":
+ SetFire(new List { 2 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置加热挡位3":
+ SetFire(new List { 3 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置加热挡位4":
+ SetFire(new List { 4 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置加热挡位5":
+ SetFire(new List { 5 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置加热挡位6":
+ SetFire(new List { 6 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置加热挡位7":
+ SetFire(new List { 7 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置加热挡位8":
+ SetFire(new List { 8 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置加热挡位9":
+ SetFire(new List { 9 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置加热挡位10":
+ SetFire(new List { 10 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "停止加热":
+ StopFire();
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "加调料":
+ OutSeasonings(item.SeasoningLists);
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "取原料":
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "开启搅拌":
+ StartStir();
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置搅拌挡位1":
+ SetStir(new List { 1 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置搅拌挡位2":
+ SetStir(new List { 2 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "设置搅拌挡位3":
+ SetStir(new List { 3 });
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "关闭搅拌":
+ StopStir();
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "出餐启动":
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "倒菜品":
+ OutFood();
+ break;
+ case "炒制菜品":
+ Thread.Sleep(item.FryTime * 1000);
+ break;
+ case "搅拌臂原点位":
+ StirArmGoOrigin();
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "搅拌臂炒制位":
+ StirArmGoWork();
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ case "洗锅":
+ MessageLog.GetInstance.Show(item.Actions);
+ break;
+ default:
+ break;
+
}
- morkF.MainOutMealComplete = true;
- }
- else
- {
- morkF.MainProcessExcuteLock = false;//解除流程自锁
}
- }));
- }
+
+ }
+ Plc1Reset();//复位
+ MessageLog.GetInstance.Show($"菜品{res.GoodName}完成");
+
+ }
}
+ //辅流程执行
+ //private void MinorProcessExcute()
+ //{
+ // if (!morkF.MinorProcessExcuteLock)
+ // {
+ // morkF.MinorProcessExcuteLock = true;
+ // Task.Run(() =>
+ // {
+ // if (morkF.MinorProcessFlag && morkF.TakeMaterialQueue.Count > 0 && morkF.listStirBom.Count > 0 )
+ // {
+ // morkF.MinorProessStatus = true;
+ // morkF.MainProcessStatus = false;
+ // StirFryBom bom = morkF.listStirBom.ElementAt(0);
+ // morkF.listStirBom.RemoveAt(0);
+ // foreach (var res in bom.StirFryActions)
+ // {
+ // DeviceProcessLogShow($"执行流程{res.Time}");
+ // //机器人线程
+ // Task taskRobot = Task.Run(new Action(() =>
+ // {
+ // foreach (var temp in res.RobotActions)
+ // {
+ // switch (temp)
+ // {
+
+ // }
+
+ // }
+
+ // }));
+ // //炒锅线程操作
+ // Task taskPot = Task.Run(new Action(() =>
+ // {
+ // foreach (var temp in res.PotActions)
+ // {
+ // switch (temp)
+ // {
+ // case StirFryPotAction.NONE:
+ // break;
+
+ // }
+ // }
+ // }));
+ // Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束
+ // Task.Delay(res.During * 1000).Wait();//当前流程延迟
+ // if (morkF.MainProcessWait)
+ // {
+ // if (morkF.MainHasTakeMaterial)
+ // {
+
+ // }
+ // else
+ // {
+ // //关闭灶加热
+ // //阻塞辅流程
+ // minorReset.WaitOne();
+ // //morkF.MinorProessStatus = true;
+ // //morkF.MainProcessStatus = false;
+ // }
+
+ // }
+
+ // }
+ // morkF.MinorOutMealComplete = true;
+ // }
+ // else
+ // {
+ // morkF.MinorProcessExcuteLock = false;//解除辅流程自锁
+ // }
+ // });
+ // }
+ //}
+
+
///
/// 信号处理
///
private void SingleProcess()
{
+ //if (!morkF.AutoMode)
+ //{
+ // if (morkF.IsAuto)
+ // {
+ // Plc1Reset();
+ // morkF.IsAuto = false;
+ // }
+ //}
+ //else morkF.IsAuto = true;
+
- //主流程出餐完成,相应变量复位
- if (morkF.MainOutMealComplete)
- {
- morkF.MainOutMealComplete = false;
- morkF.TakePlateLock = false;
- morkF.MainProcessExcuteLock = false;
- morkF.MainOrderMaterialCom = false;
- morkF.MainProcessWait = false;//主流程出餐完成取消辅流程线程阻塞
-
- #region 单口锅逻辑
- morkF.PotInPlace = false;
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessPotLoc == 1)
- //{
- // morkF.PotInPlace = false;
- //}
- //else if (morkF.MainProcessPotLoc == 2)
- //{
- // morkF.SecondPotInPlace = false;
- //}
- #endregion
- }
- //辅流程出餐完成,相应变量复位
- if (morkF.MinorOutMealComplete)
- {
- morkF.MinorOutMealComplete = false;
- morkF.TakePlateLock = false;
- morkF.MinorProcessExcuteLock = false;
- morkF.MinorOrderMaterialCom = false;
- morkF.MinorProcessWait = false;//辅流程出餐完成取消主流程线程阻塞
- if (morkF.MinorProcessPotLoc == 1)
- {
- morkF.PotInPlace = false;
- }
- else if (morkF.MinorProcessPotLoc == 2)
- {
- morkF.SecondPotInPlace = false;
- }
- }
}
- ///
- /// 转台控制
- ///
- private void TurntableControl()
+ private void GetStatus(string key, Action action)
{
- //模拟订单
- if (morkF.TakeMaterialQueue.Count > 0 && !morkF.TurnTableLock && General_Config.SimOrderAllow)
- {
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo info))
- {
- TurnMaterialStore(info.MaterialLoc[0]);
- DeviceProcessLogShow($"转台转到【{info.MaterialLoc[0]}】位置");
- morkF.TurnTableLock = true;
- }
- else
- {
- DeviceProcessLogShow("当前订单未找到可用的物料信息");
- }
-
- }
- //正式订单
- if (morkF.TakeMaterialQueue.Count > 0 && !morkF.TurnTableLock)
+ if (peripheralStatus.ContainsKey(key))
{
- //var result = orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == morkF.TakeMaterialQueue.ElementAt(0).BatchingId).ToList();
- var materialLoc = morkF.TakeMaterialQueue.ElementAt(0).MaterialLoc;
- if (materialLoc.Count != 0)
- {
- TurnMaterialStore(materialLoc[0]);
- DeviceProcessLogShow($"转台转到【{materialLoc[0]}】位置");
- morkF.TurnTableLock = true; //取料完成后置false
-
- }
- else
- {
- DeviceProcessLogShow("当前订单未找到可用的物料信息");
- }
-
+ action((bool[])peripheralStatus[key]);//获取PLC指定地址的状态值
}
-
-
}
-
-
///
- /// 供盘
+ /// 写数据
///
- ///
- private void TakePlatelTask()
+ ///
+ ///
+ private void WriteData(string address, object value)
{
- if (!morkF.RoobotIdle && morkF.InitialComplete && morkF.TakePlateQueue.Count > 0 && !morkF.ProvidePlateModule && !morkF.TakePlateLock)
- {
-
- if (morkF.TakePlateQueue.TryDequeue(out OrderLocInfo order))
- {
- StartTakePlate();
- #region 两口锅逻辑
- //if (morkF.MainProcessStatus)
- // morkF.MainCurrentOrderId = order.SuborderId;
-
- //if (morkF.MinorProessStatus)
- // morkF.MinorCurrentOrderId = order.SuborderId;
- #endregion
- #region 单口锅逻辑
- morkF.CurrentOrderId = order.SuborderId;
- #endregion
- morkF.TakePlateLock = true; //订单完成后置false
-
-
- DeviceProcessLogShow($"订单【{order.SuborderId}】执行取碗控制");
- }
- }
+ EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value });
}
///
- /// 取锅到灶台
+ /// 炒锅初始化
///
- ///
- private void TakePotTask()
+ public void PLCInite()
{
-
- while (morkF.CleanModule || morkF.KitchenOneStatus || !morkF.CleanComplete || morkF.RoobotIdle)//等待取锅条件满足
- {
- Task.Delay(5).Wait();
- }
-
- #region 单口锅逻辑
- //if (!morkF.CleanModule && !morkF.KitchenOneStatus && morkF.CleanComplete)
- //{
- //取1号锅到1号灶台
- TakePotToKitchen(1);
- WriteData("M1.5", false);//清洗模组1完成复位
- DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行取锅到灶台控制");
- while (!morkF.PutPotToKitchenComlete)
+
+ WriteData("LB0", true);
+ while(!morkF.FryPot1_InitialComplete)
{
- Task.Delay(5).Wait();
+ Thread.Sleep(500);
}
- morkF.PotInPlace = true;//锅到位
- WriteData("M14.0", false);//机器人取锅完成复位
- //}
- #endregion
- #region 两口锅逻辑
- //while (!((!morkF.CleanModule || !morkF.SecondCleanModule) && (!morkF.KitchenOneStatus || !morkF.KitchenSecondStatus) && (morkF.CleanComplete || morkF.SecondCleanComplete)))//等待取锅条件满足
- //{
- // Task.Delay(5).Wait();
- //}
- //while (morkF.RoobotIdle)//等待机器人空闲
- //{
- // Task.Delay(5).Wait();
- //}
- //if (!morkF.CleanModule && !morkF.KitchenOneStatus && morkF.CleanComplete)
- //{
- // //取1号锅到1号灶台
- // TakePotToKitchen(1);
- // morkF.CurrentPutPotLoc = 1;
- // WriteData("M1.5", false);//清洗模组1完成复位
- // DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行取锅到灶台控制");
-
- //}
- //else if (!morkF.SecondCleanModule && !morkF.KitchenOneStatus && morkF.SecondCleanComplete)
- //{
- // //取2号锅到1号灶台
- // TakePotToKitchen(1);
- // morkF.CurrentPutPotLoc = 1;
- // WriteData("M2.0", false);//清洗模组2完成复位
- //}
- //if (!morkF.SecondCleanModule && !morkF.KitchenSecondStatus && morkF.SecondCleanComplete)
- //{
- // //取2号锅到2号灶台
- // TakePotToKitchen(2);
- // morkF.CurrentPutPotLoc = 2;
- // WriteData("M2.0", false);//清洗模组2完成复位
- //}
- //else if (!morkF.CleanModule && !morkF.KitchenSecondStatus && morkF.CleanComplete)
- //{
- // //取1号锅到2号灶台
- // TakePotToKitchen(2);
- // morkF.CurrentPutPotLoc = 2;
- // WriteData("M2.0", false);//清洗模组1完成复位
- //}
- //if (morkF.MainProcessStatus)
- //{
- // morkF.MainProcessPotLoc = morkF.CurrentPutPotLoc;
- // DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】执行取锅到灶台控制");
- //}
- //if (morkF.MinorProessStatus)
- //{
- // morkF.MinorProcessPotLoc = morkF.CurrentPutPotLoc;
- // DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】执行取锅到灶台控制");
- //}
- //if (morkF.CurrentPutPotLoc == 1)
- //{
- // while (!morkF.PutPotToKitchenComlete)
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.PotInPlace = true;//锅到位
- // WriteData("M14.0", false);//机器人取锅完成复位
- //}
- //if (morkF.CurrentPutPotLoc == 2)
- //{
- // while (!morkF.PutPotToSecondKitchenComlete)
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.SecondPotInPlace = true;
- // WriteData("M14.4", false);//机器人取锅完成复位
- //}
- #endregion
-
- Thread.Sleep(2000);
-
-
-
-
+ WriteData("LB0", false);
}
///
- /// 写入配方数据到 PLC
+ /// 菜品库初始化
///
- private void WriteRecipeBoms()
+ public void FoodPlcInite()
{
- //List recipeBoms = new List();
- //if (this.recipeBoms == null) return;
- //foreach (var item in this.recipeBoms.RecipeIds)
- //{
- // foreach (var rec in item.Recipes)
- // {
- // recipeBoms.Add((ushort)rec);
- // }
- //}
- //if (recipeBoms.Count > 0)
- //{
- // //配方数据地址范围:VW2000 - VW2278
- // WriteData("VW2000", recipeBoms.ToArray());
- //}
- //else {DeviceProcessLogShow("配方数据为空"); }
+ WriteData("", true);
}
+
///
- /// 转台复位
- ///
- ///
- public void TurnReset(int loc)
+
+ public override void Stop()
{
- switch (loc)
- {
- case 1: WriteData("M13.0", false); break;
- case 2: WriteData("M13.1", false); break;
- case 3: WriteData("M13.2", false); break;
- case 4: WriteData("M13.3", false); break;
- case 5: WriteData("M13.4", false); break;
- }
+
}
- ///
- /// 取素菜A料
- ///
- private void TakeBurdenATask()
+
+ public override void SimOrder()
{
- int loc = 0;
- #region 单口锅逻辑
- while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- {
- Task.Delay(5).Wait();
- }
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- {
- loc = order.MaterialLoc[0];
- TakeBurden();
- TurnReset(loc);//转台复位
+ ActionManage.GetInstance.Register(morkSim, "模拟小炒锅1订单");
+ }
- DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- }
- //等待取料完成
- while (!morkF.TakeMaterialComplete)
+ private void morkSim(object o)
+ {
+ if (o == null) return;
+ if(o is List ins)
{
- Task.Delay(5).Wait();
- }
- WriteData("M14.1", false);//机器人取料完成复位
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessStatus)
- //{
- // if (morkF.MainProcessPotLoc == 1)
- // {
- // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // else
- // {
- // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- // {
- // loc = order.MaterialLoc[0];
- // TakeBurden();
- // TurnReset(loc);//转台复位
-
- // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- // }
- // //等待取料完成
- // while (!morkF.TakeMaterialComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.MainOrderMaterialCom = false;
- // morkF.MainHasTakeMaterial = true;
- // WriteData("M14.1", false);//机器人取料完成复位
- //}
- //if (morkF.MinorProessStatus)
- //{
- // if (morkF.MinorProcessPotLoc == 1)
- // {
- // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // else
- // {
- // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- // {
- // loc = order.MaterialLoc[0];
- // TakeBurden();
- // TurnReset(loc);//转台复位
+ ThreadManage.GetInstance().Start(new Action(() =>
+ {
+ if (morkF.FryPot1_InitialComplete && morkF.AutoMode)//初始化完成&&自动模式&& 锅在原点位置
+ {
+ if (!morkF.ArmOnWorking)//搅拌臂是否在工作位
+ {
+ StirArmGoWork();
- // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- // }
- // //等待取料完成
- // while (!morkF.TakeMaterialComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.MinorOrderMaterialCom = false;
- // morkF.MinorHasTakeMaterial = true;
- // WriteData("M14.5", false);//机器人取料完成复位
- //}
- #endregion
- morkF.TurnTableLock = false;//转台互锁解除
-
-
- }
-
- ///
- /// 取素菜B料
- ///
- private void TakeBurdenBTask()
- {
- int loc = 0;
- //while (morkF.RoobotIdle || (!morkF.PotInPlace && !morkF.SecondPotInPlace) || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位
- //{
- // Task.Delay(5).Wait();
- //}
- if (morkF.MainProcessStatus)
- {
- if (morkF.MainProcessPotLoc == 1)
- {
- while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- {
- Task.Delay(5).Wait();
- }
- }
- else
- {
- while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
- {
- Task.Delay(5).Wait();
- }
- }
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- {
- loc = order.MaterialLoc[0];
- TakeBurden();
- TurnReset(loc);//转台复位
-
- DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- }
- //等待取料完成
- while (!morkF.TakeMaterialComplete)
- {
- Task.Delay(5).Wait();
- }
- morkF.MainOrderMaterialCom = false;
- morkF.MainHasTakeMaterial = true;
- WriteData("M14.1", false);//机器人取料完成复位
- }
- if (morkF.MinorProessStatus)
- {
- if (morkF.MinorProcessPotLoc == 1)
- {
- while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- {
- Task.Delay(5).Wait();
- }
- }
- else
- {
- while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
- {
- Task.Delay(5).Wait();
- }
- }
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- {
- loc = order.MaterialLoc[0];
- TakeBurden();
- TurnReset(loc);//转台复位
-
- DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- }
- //等待取料完成
- while (!morkF.TakeMaterialComplete)
- {
- Task.Delay(5).Wait();
- }
- morkF.MinorOrderMaterialCom = false;
- morkF.MinorHasTakeMaterial = true;
- WriteData("M14.5", false);//机器人取料完成复位
- }
- morkF.TurnTableLock = false;//转台互锁解除
- }
- ///
- /// 取调味品C料
- ///
- ///
- private void TakeBurdenCTask()
- {
- #region 单口锅逻辑
- int loc = 0;
- while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- {
- Task.Delay(5).Wait();
- }
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- {
- loc = order.MaterialLoc[0];
- TakeBurden();
- TurnReset(loc);//转台复位
-
- DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- }
- //等待取料完成
- while (!morkF.TakeMaterialComplete)
- {
- Task.Delay(5).Wait();
- }
-
- WriteData("M14.1", false);//机器人取料完成复位
- morkF.TurnTableLock = false;//转台互锁解除
- #endregion
- #region 两口锅逻辑
- //int loc = 0;
-
- //if (morkF.MainProcessStatus)
- //{
- // if (morkF.MainProcessPotLoc == 1)
- // {
- // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // else
- // {
- // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- // {
- // loc = order.MaterialLoc[0];
- // TakeBurden();
- // TurnReset(loc);//转台复位
-
- // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- // }
- // //等待取料完成
- // while (!morkF.TakeMaterialComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.MainOrderMaterialCom = false;
- // morkF.MainHasTakeMaterial = true;
- // WriteData("M14.1", false);//机器人取料完成复位
- //}
- //if (morkF.MinorProessStatus)
- //{
- // if (morkF.MinorProcessPotLoc == 1)
- // {
- // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // else
- // {
- // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- // {
- // loc = order.MaterialLoc[0];
- // TakeBurden();
- // TurnReset(loc);//转台复位
-
- // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- // }
- // //等待取料完成
- // while (!morkF.TakeMaterialComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.MinorOrderMaterialCom = false;
- // morkF.MinorHasTakeMaterial = true;
- // WriteData("M14.5", false);//机器人取料完成复位
- //}
- //morkF.TurnTableLock = false;//转台互锁解除
- #endregion
- }
- ///
- /// 主流程出餐
- ///
- private void MainProcessOutDishTask()
- {
- //while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
- //{
- // Task.Delay(5).Wait();
- //}
- #region 单口锅逻辑
- while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
- {
- Task.Delay(5).Wait();
- }
- if (morkF.TakePlateQueue.Count == 0)
- {
- WriteData("M0.7", false);//无订单关闭抽风机
- }
- MainProcessRobotOutMeal();
- WriteData("M1.2", false);//供盘复位
- DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行取锅到清洗台控制");
- #endregion
- #region 两口锅逻辑
- //while (morkF.RoobotIdle || (morkF.CleanModule && morkF.SecondCleanModule) || !morkF.ProvidePlateComplete)//等待条件满足
- //{
- // Task.Delay(5).Wait();
- //}
- //if (morkF.TakePlateQueue.Count == 0)
- //{
- // WriteData("M0.7", false);//无订单关闭抽风机
- //}
- //MainProcessRobotOutMeal();
- //WriteData("M1.2", false);//供盘复位
- //DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】执行取锅到清洗台控制");
- #endregion
-
- }
- ///
- /// 复流程流程出餐
- ///
- private void MinorProcessOutDishTask()
- {
- //while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
- //{
- // Task.Delay(5).Wait();
- //}
- while (morkF.RoobotIdle || (morkF.CleanModule && morkF.SecondCleanModule) || !morkF.ProvidePlateComplete)//等待条件满足
- {
- Task.Delay(5).Wait();
- }
- if (morkF.TakePlateQueue.Count == 0)
- {
- WriteData("M0.7", false);//无订单关闭抽风机
- }
- MinorProcessRobotOutMeal();
- WriteData("M1.2", false);//供盘复位
- DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】执行取锅到清洗台控制");
- }
- ///
- /// 主流程洗锅放锅
- ///
- private void MainProcessCleanPotTask()
- {
- #region 单口锅逻辑
- while (!morkF.PlaceRinseTableComplete || morkF.CleanModule)
- {
- Task.Delay(5).Wait();
- }
- WriteData("M14.2", false);//机器人出餐完成复位
- CleanModuleControl("Start", 1);
- DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行清洗操作");
- #endregion
- #region 两口锅逻辑
- //while ((!morkF.PlaceRinseTableComplete || morkF.CleanModule) && (!morkF.PlaceRinseSecondTableComplete || morkF.SecondCleanModule))
- //{
- // Task.Delay(5).Wait();
- //}
-
- //WriteData("M14.2", false);//机器人出餐完成复位
- //if (morkF.PlaceRinseTableComplete && !morkF.CleanModule)
- //{
- // CleanModuleControl("Start", 1);
- //}
- //if (morkF.PlaceRinseSecondTableComplete && !morkF.SecondCleanModule)
- //{
- // CleanModuleControl("Start", 2);
- //}
- //DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】执行清洗操作");
- //morkF.MainProcessFlag = false;
- //minorReset.Set();
- #endregion
- //OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK);
- }
-
- ///
- /// 辅流程洗锅放锅
- ///
- private void MinorProcessCleanPotTask()
- {
- while ((!morkF.PlaceRinseTableComplete || morkF.CleanModule) && (!morkF.PlaceRinseSecondTableComplete || morkF.SecondCleanModule))
- {
- Task.Delay(5).Wait();
- }
-
- WriteData("M14.6", false);//机器人出餐完成复位
- if (morkF.PlaceRinseTableComplete && !morkF.CleanModule)
- {
- CleanModuleControl("Start", 1);
- }
- if (morkF.PlaceRinseSecondTableComplete && !morkF.SecondCleanModule)
- {
- CleanModuleControl("Start", 2);
- }
- DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】执行清洗操作");
- morkF.MinorProcessFlag = false;
- mainReset.Set();
-
- //OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK);
- }
- ///
- /// 任务复位重启
- ///
- //private void ResetProgram()
- //{
- // ThreadManage.GetInstance().StartLong(new Action(() =>
- // {
- // if (RTrig.GetInstance("ResetProgram").Start(morkF.DevicDataInite))
- // {
- // ThreadManage.GetInstance().StopTask("MainTask", new Action(() =>
- // {
- // ThreadManage.GetInstance().StopTask("ReadPLCData", new Action(() =>
- // {
- // morkF = null;
- // morkF = new GVL_MorkF();
- // ActionManage.GetInstance.Send("ResetProgram");
- // ActionManage.GetInstance.Send("ClearOrders");
- // ReadData();
- // Main();
- // }));
- // }));
- // }
-
- // Thread.Sleep(10);
- // }), "ResetProgram");
- //}
- ///
- /// 主流程翻转机下降及状态检测
- ///
- public void MainProcessTurnDownStatusDetect()
- {
- int potLoc = MainProcessTurnMachineOrientControl("Down");
-
- if (potLoc == 1)
- {
- while (!morkF.TurnMachineDownComplete)//等待翻转机下降完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.3", false);//下降完成复位
- }
- if (potLoc == 2)
- {
- while (!morkF.SecondTurnMachineDownComplete)//等待翻转机下降完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.7", false);//下降完成复位
- }
- DeviceProcessLogShow($"翻转机下降完成");
-
- }
- ///
- /// 辅流程翻转机下降及状态检测
- ///
- public void MinorProcessTurnDownStatusDetect()
- {
- int potLoc = MinorProcessTurnMachineOrientControl("Down");
-
- if (potLoc == 1)
- {
- while (!morkF.TurnMachineDownComplete)//等待翻转机下降完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.3", false);//下降完成复位
- }
- if (potLoc == 2)
- {
- while (!morkF.SecondTurnMachineDownComplete)//等待翻转机下降完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.7", false);//下降完成复位
- }
- DeviceProcessLogShow($"翻转机下降完成");
- //if (morkF.MaterialCount == 3 && morkF.MainProcessStatus)
- //{
- // morkF.MainProcessWait = true;
- //}
- //else if (morkF.MaterialCount == 3 && morkF.MinorProessStatus)
- //{
- // morkF.MinorProcessWait = true;
- //}
-
- }
- ///
- /// 主流程翻转机上升及状态检测
- ///
- public void MainProcessTurnUpStatusDetect()
- {
- //while (morkF.RoobotIdle)//机器人忙碌
- //{
- // Task.Delay(5).Wait();
- //}
- MainProcessTurnMachineOrientControl("Top");//翻转机上升
- #region 单口锅逻辑
- while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.1", false);//上升完成复位
- WriteData("M14.3", true);//倒料
- while (!morkF.FallMaterialComplete)//等待倒料完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M14.3", false);//倒料复位
- DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】,配料倒料完成");
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessPotLoc == 1)
- //{
- // while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
- // {
- // Task.Delay(5).Wait();
- // }
- // WriteData("M8.1", false);//上升完成复位
- // if (!morkF.MainOrderMaterialCom)
- // {
- // WriteData("M14.3", true);//倒料
- // while (!morkF.FallMaterialComplete)//等待倒料完成
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.MaterialCount++;
- // WriteData("M14.3", false);//倒料复位
- // if (morkF.MaterialCount == 3)
- // {
- // //允许执行下一个订单流程
- // morkF.MaterialCount = 0;
- // morkF.MinorProcessFlag = true;
-
- // }
- // morkF.MainOrderMaterialCom = true;
- // morkF.MainHasTakeMaterial = false;
- // DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】,配料倒料完成");
- // }
- // else //辅程准备阻塞
- // {
- // morkF.MainProcessWait = true;
- // }
- //}
- //if (morkF.MainProcessPotLoc == 2)
- //{
- // while (!morkF.SecondTurnMachineUpComplete)//等待翻转机上升完成以及取料完成
- // {
- // Task.Delay(5).Wait();
- // }
- // WriteData("M8.5", false);//上升完成复位
- // if (!morkF.MainOrderMaterialCom)
- // {
- // WriteData("M14.7", true);//倒料
- // while (!morkF.SecondFallMaterialComplete)//等待倒料完成
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.MaterialCount++;
- // WriteData("M14.7", false);//倒料复位
- // if (morkF.MaterialCount == 3)
- // {
- // //允许执行下一个订单流程
- // morkF.MaterialCount = 0;
- // morkF.MinorProcessFlag = true;
-
- // }
- // morkF.MainOrderMaterialCom = true;
- // morkF.MainHasTakeMaterial = false;
- // DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】,配料倒料完成");
- // }
- // else //辅流程准备阻塞
- // {
- // morkF.MainProcessWait = true;
- // }
- //}
- #endregion
- DeviceProcessLogShow("翻转机上升完成");
- }
- ///
- /// 辅流程翻转机上升及状态检测
- ///
- public void MinorProcessTurnUpStatusDetect()
- {
- while (morkF.RoobotIdle)//机器人忙碌
- {
- Task.Delay(5).Wait();
- }
- MinorProcessTurnMachineOrientControl("Top");//翻转机上升
+ while (!morkF.ArmOnWorking)
+ {
+ Thread.Sleep(500);
+ }
+ OutSeasoning(new List { 1, 100 });//加油500g
+ while (!morkF.PassWay1_1Compelete)
+ {
+ Thread.Sleep(1000);
+ }
+ WriteControl(morkF.StartPassWay[ 1], false);//开启通道关闭
+ Thread.Sleep(500);
+ SetFire(new List { ins[1] });//加热三档
+
+ StartFire();//开始加热
+ Thread.Sleep(500);
+ SetStir(new List { ins[2] });//搅拌二挡
+ Thread.Sleep(500);
+ StartStir();//开始搅拌
+ Thread.Sleep(ins[0]*1000);//加热10s
+
+ OutSeasoning(new List { 11, 30 });//加调料1 50g
+ Thread.Sleep(400);
+ OutSeasoning(new List { 12, 30 });//加调料2 30g
+ while (!morkF.PassWay1_11Compelete&& !morkF.PassWay1_12Compelete)
+ {
+ Thread.Sleep(1000);
+ }
+
+
+
+
+ WriteControl(morkF.StartPassWay[11], false);//开启通道关闭
+ Thread.Sleep(500);
+ WriteControl(morkF.StartPassWay[12], false);//开启通道信号关闭
+
+
+
+ Thread.Sleep(500);
+
+ OutFood();//倒菜品1
+ while (!morkF.FryPot1_MaterialIntoPot)//菜品1倒菜完成
+ {
+ Thread.Sleep(500);
+ }
+ WriteControl("LB53", false);
+ Thread.Sleep(500);
+ SetFire(new List { ins[4] });//菜品1加热档
+ Thread.Sleep(500);
+ SetStir(new List() { ins[5] });//菜品1搅拌挡
+ Thread.Sleep(ins[3]*1000);//菜品1炒制时间
+
+ OutSeasoning(new List {3, 8 });//加调料3 20g
+ while (!morkF.PassWay1_3Compelete)
+ {
+ Thread.Sleep(1000);
+ }
+ WriteControl(morkF.StartPassWay[3], false);//开启通道信号关闭
+ Thread.Sleep(500);
+ OutFood();//倒菜菜品2
+ while (!morkF.FryPot1_MaterialIntoPot)//菜品2倒菜完成
+ {
+ Thread.Sleep(500);
+ }
+ WriteControl("LB53", false);
+ Thread.Sleep(500);
+ SetFire(new List { ins[7] });//菜品2加热档
+ Thread.Sleep(500);
+ SetStir(new List() { ins[8] });//菜品2搅拌挡
+ Thread.Sleep(ins[6] * 1000);//菜品2炒制时间
- if (morkF.MinorProcessPotLoc == 1)
- {
- while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.1", false);//上升完成复位
- if (!morkF.MinorOrderMaterialCom)
- {
- WriteData("M14.3", true);//倒料
- while (!morkF.FallMaterialComplete)//等待倒料完成
- {
- Task.Delay(5).Wait();
- }
- morkF.MaterialCount++;
- WriteData("M14.3", false);//倒料复位
- if (morkF.MaterialCount == 3)
- {
- //允许执行下一个订单流程
- morkF.MaterialCount = 0;
- morkF.MainProcessFlag = true;
- }
- morkF.MinorOrderMaterialCom = true;
- morkF.MinorHasTakeMaterial = false;
- DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】,配料倒料完成");
- }
- else //主程准备阻塞
- {
- morkF.MinorProcessWait = true;
- }
- }
- if (morkF.MinorProcessPotLoc == 2)
- {
- while (!morkF.SecondTurnMachineUpComplete)//等待翻转机上升完成以及取料完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.5", false);//上升完成复位
- if (!morkF.MinorOrderMaterialCom)
- {
- WriteData("M14.7", true);//倒料
- while (!morkF.SecondFallMaterialComplete)//等待倒料完成
- {
- Task.Delay(5).Wait();
- }
- morkF.MaterialCount++;
- WriteData("M14.7", false);//倒料复位
- if (morkF.MaterialCount == 3)
- {
- //允许执行下一个订单流程
- morkF.MaterialCount = 0;
- morkF.MainProcessFlag = true;
+ StopStir();//停止搅拌
+ Thread.Sleep(500);
+ StopFire();//停止加热
+ Thread.Sleep(2000);
+ StirArmGoOrigin();//搅拌臂回原点位
+ }
}
- morkF.MinorOrderMaterialCom = true;
- morkF.MinorHasTakeMaterial = false;
- DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】,配料倒料完成");
- }
- else //主流程准备阻塞
- {
- morkF.MinorProcessWait = true;
- }
- }
- DeviceProcessLogShow("翻转机上升完成");
-
- }
- private void GetStatus(string key, Action action)
- {
- if (peripheralStatus.ContainsKey(key))
- {
- action((bool[])peripheralStatus[key]);//获取PLC指定地址的状态值
- }
- }
- ///
- /// 写数据
- ///
- ///
- ///
- private void WriteData(string address, object value)
- {
- EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value });
- }
-
- public void FirstPotGears(int number)
- {
- switch (number)
- {
- case 0:
- //if (morkF.MainProcessStatus && morkF.PotInPlace)
- WriteData("M4.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
- //if (morkF.MinorProessStatus && morkF.SecondPotInPlace)
- // WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
- break;
- case 1:
- // if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
- break;
- case 2:
- //if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
- break;
- case 3:
- //if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
- break;
- case 4:
- // if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
- break;
- case 5:
- if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
- break;
- case 6:
- // if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
- break;
- case 7:
- // if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
- break;
- case 8:
- //if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
- break;
- case 9:
- //if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
- break;
-
- }
- }
-
- public void SecondPotGears(int number)
- {
- switch (number)
- {
- case 0:
- //if (morkF.MainProcessStatus && morkF.PotInPlace)
- WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
- //if (morkF.MinorProessStatus && morkF.SecondPotInPlace)
- // WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
- break;
- case 1:
- // if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
- break;
- case 2:
- //if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
- break;
- case 3:
- //if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
- break;
- case 4:
- // if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
- break;
- case 5:
- if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
- break;
- case 6:
- // if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
- break;
- case 7:
- // if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
- break;
- case 8:
- //if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
- break;
- case 9:
- //if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
- break;
-
- }
- }
- ///
- /// 主流程灶台档位调节
- ///
- public void MainProcessKitchenAdjustGears(int number)
- {
- #region 单口锅逻辑
- while (!morkF.PotInPlace)
- {
- Task.Delay(5).Wait();
- }
- FirstPotGears(number);
- DeviceProcessLogShow($"灶台【{morkF.CurrentOrderId}】档位调节至【{number}】挡");
- #endregion
-
- #region 两口锅逻辑
- //if (morkF.MainProcessPotLoc == 1)
- //{
- // while (!morkF.PotInPlace)
- // {
- // Task.Delay(5).Wait();
- // }
- // FirstPotGears(number);
- //}
- //if (morkF.MainProcessPotLoc == 2)
- //{
- // while (!morkF.SecondPotInPlace)
- // {
- // Task.Delay(5).Wait();
- // }
- // SecondPotGears(number);
- //}
- //DeviceProcessLogShow($"灶台【{morkF.MainProcessPotLoc}】档位调节至【{number}】挡");
- #endregion
-
- }
- ///
- /// 辅流程灶台档位调节
- ///
- public void MinorProcessKitchenAdjustGears(int number)
- {
- if (morkF.MinorProcessPotLoc == 1)
- {
- while (!morkF.PotInPlace)
- {
- Task.Delay(5).Wait();
- }
- FirstPotGears(number);
- }
- if (morkF.MinorProcessPotLoc == 2)
- {
- while (!morkF.SecondPotInPlace)
- {
- Task.Delay(5).Wait();
- }
- SecondPotGears(number);
- }
- DeviceProcessLogShow($"灶台【{morkF.MinorProcessPotLoc}】档位调节至【{number}】挡");
- }
- ///
- /// PLC转台控制
- ///
- ///
- public void TurnMaterialStore(int loc)
- {
- switch (loc)
- {
- case 1:
- WriteData("M13.0", true);
- break;
- case 2:
- WriteData("M13.1", true);
- break;
- case 3:
- WriteData("M13.2", true);
- break;
- case 4:
- WriteData("M13.3", true);
- break;
- case 5:
- WriteData("M13.4", true);
- break;
- }
-
- }
- public void PLCInite()
- {
- WriteData("M0.0", true);
-
- }
- ///
- /// 供盘启动
- ///
- public void StartTakePlate()
- {
- WriteData("M1.1", true);
- }
- ///
- /// 取锅到灶台
- ///
- public void TakePotToKitchen(int loc)
- {
- if (loc == 1)
- WriteData("M14.0", true);
- if (loc == 2)
- WriteData("M14.4", true);
- }
- ///
- /// 主流程机器人出餐并将锅放置清洗台位置
- ///
- public void MainProcessRobotOutMeal()
- {
- #region 单口锅逻辑
- WriteData("M14.2", true);//1号锅出餐
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessPotLoc == 1)
- //{
- // WriteData("M14.2", true);//1号锅出餐
- //}
- //else if (morkF.MainProcessPotLoc == 2)
- //{
- // WriteData("M14.6", true);//2号锅出餐
- //}
- #endregion
- }
-
- ///
- /// 复流程机器人出餐并将锅放置清洗台位置
- ///
- public void MinorProcessRobotOutMeal()
- {
-
- if (morkF.MinorProcessPotLoc == 1)
- {
- WriteData("M14.2", true);//1号锅出餐
- }
- else if (morkF.MinorProcessPotLoc == 2)
- {
- WriteData("M14.6", true);//2号锅出餐
- }
-
-
- }
- public void OpenDraft()
- {
- WriteData("M0.7", true);//打开抽风机
- }
- ///
- /// 注油
- ///
- public void AddOil()
- {
- #region 单口锅逻辑
- while (!morkF.PotInPlace)
- {
- Task.Delay(5).Wait();
- }
- WriteData("M2.7", true);//加油
- OpenDraft();
- DeviceProcessLogShow("开始注油");
- while (!morkF.FallOilComplete)
- {
- Task.Delay(5).Wait();
- }
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessStatus)
- //{
- // if (morkF.MainProcessPotLoc == 1)
- // {
- // while (!morkF.PotInPlace)
- // {
- // Task.Delay(5).Wait();
- // }
- // WriteData("M2.7", true);//加油
- // OpenDraft();
- // DeviceProcessLogShow("开始注油");
- // while (!morkF.FallOilComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // if (morkF.MainProcessPotLoc == 2)
- // {
- // while (!morkF.SecondPotInPlace)
- // {
- // Task.Delay(5).Wait();
- // }
- // WriteData("M3.1", true);//加油
- // OpenDraft();
- // DeviceProcessLogShow("开始注油");
- // while (!morkF.SecondOilComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- //}
- //if (morkF.MinorProessStatus)
- //{
- // if (morkF.MinorProcessPotLoc == 1)
- // {
- // while (!morkF.PotInPlace)
- // {
- // Task.Delay(5).Wait();
- // }
- // WriteData("M2.7", true);//加油
- // OpenDraft();
- // DeviceProcessLogShow("开始注油");
- // while (!morkF.FallOilComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // if (morkF.MinorProcessPotLoc == 2)
- // {
- // while (!morkF.SecondPotInPlace)
- // {
- // Task.Delay(5).Wait();
- // }
- // WriteData("M3.1", true);//加油
- // OpenDraft();
- // DeviceProcessLogShow("开始注油");
- // while (!morkF.SecondOilComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- //}
- #endregion
- //while (!morkF.FallOilComplete || !morkF.SecondOilComplete)
- //{
- // Task.Delay(5).Wait();
- //}
- DeviceProcessLogShow("注油完成");
-
- }
- public void FirstPotTurnMachine(string orientation)
- {
- switch (orientation)
- {
- case "Top": WriteData("M8.0", true); break;
- case "Down": WriteData("M8.2", true); break;
- }
- }
- public void SecondPotTurnMachine(string orientation)
- {
- switch (orientation)
- {
- case "Top": WriteData("M8.4", true); break;
- case "Down": WriteData("M8.6", true); break;
- }
- }
-
- ///
- /// 主流程翻转机方向控制
- ///
- ///
- public int MainProcessTurnMachineOrientControl(string orientation)
- {
- int potLoc = 0;
- #region 单口锅逻辑
- FirstPotTurnMachine(orientation);
- potLoc = 1;
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessPotLoc == 1)
- //{
- // FirstPotTurnMachine(orientation);
- // potLoc = 1;
- //}
- //if (morkF.MainProcessPotLoc == 2)
- //{
- // SecondPotTurnMachine(orientation);
- // potLoc = 2;
- //}
- #endregion
- DeviceProcessLogShow($"翻转机执行{orientation}操作");
-
- return potLoc;
- }
- ///
- /// 辅流程翻转机方向控制
- ///
- ///
- public int MinorProcessTurnMachineOrientControl(string orientation)
- {
- int potLoc = 0;
-
- if (morkF.MinorProcessPotLoc == 1)
- {
- FirstPotTurnMachine(orientation);
- potLoc = 1;
- }
- if (morkF.MinorProcessPotLoc == 2)
- {
- SecondPotTurnMachine(orientation);
- potLoc = 2;
- }
-
- DeviceProcessLogShow($"翻转机执行{orientation}操作");
- return potLoc;
- }
- public void FirstPotTurnMachine(int gear)
- {
- while (!morkF.PotInPlace)
- {
- Task.Delay(5).Wait();
+ }), "模拟炒锅1订单");
}
- switch (gear)
- {
- case 0: WriteData("M7.0", true); Task.Delay(1000).Wait(); break;//关闭翻炒机
- case 1: WriteData("M7.1", true); break;//翻炒机1挡
- case 2: WriteData("M7.2", true); break;//翻炒机2挡
- case 3: WriteData("M7.3", true); break;//翻炒机3挡
- }
- }
- public void SecondPotTurnMachine(int gear)
- {
- while (!morkF.SecondPotInPlace)
- {
- Task.Delay(5).Wait();
- }
- switch (gear)
- {
- case 0: WriteData("M7.4", true); Task.Delay(1000).Wait(); break;//关闭翻炒机
- case 1: WriteData("M7.5", true); break;//翻炒机1挡
- case 2: WriteData("M7.6", true); break;//翻炒机2挡
- case 3: WriteData("M7.7", true); break;//翻炒机3挡
- }
- }
-
- ///
- /// 主流程翻转机档位控制
- ///
- public void MainProcessTurnMachineGearsControl(int gear)
- {
- #region 单口锅逻辑
- FirstPotTurnMachine(gear);
- DeviceProcessLogShow($"炒锅【{morkF.CurrentOrderId}】翻转机档位调至{gear}挡");
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessPotLoc == 1)
- //{
- // FirstPotTurnMachine(gear);
- //}
- //if (morkF.MainProcessPotLoc == 2)
- //{
- // SecondPotTurnMachine(gear);
- //}
- //DeviceProcessLogShow($"炒锅【{morkF.MainProcessPotLoc}】翻转机档位调至{gear}挡");
- #endregion
- }
- ///
- /// 辅流程翻转机档位控制
- ///
- public void MinorProcessTurnMachineGearsControl(int gear)
- {
- if (morkF.MinorProcessPotLoc == 1)
- {
- FirstPotTurnMachine(gear);
- }
- if (morkF.MinorProcessPotLoc == 2)
- {
- SecondPotTurnMachine(gear);
- }
-
- DeviceProcessLogShow($"炒锅【{morkF.MinorProcessPotLoc}】翻转机档位调至{gear}挡");
- }
- ///
- /// 取A,B,C料
- ///
- public void TakeBurden()
- {
- #region 单口锅逻辑
- WriteData("M14.1", true);//机器人取料至1号锅
- #endregion
- #region 两口锅逻辑
- //if (morkF.PotInPlace)
- // WriteData("M14.1", true);//机器人取料至1号锅
- //if (morkF.SecondPotInPlace)
- // WriteData("M14.5", true);//机器人取料至2号锅
- #endregion
- }
- ///
- /// 清洗模组1启停控制
- ///
- public void CleanModuleControl(string status, int loc)
- {
- if (loc == 1)
- {
- if (status == "Start")
- {
- WriteData("M1.4", true);
- }
- if (status == "Stop")
- {
- WriteData("M1.4", false);
- }
- DeviceProcessLogShow($"清洗模组1执行【{status}】操作");
- }
- if (loc == 2)
- {
- if (status == "Start")
- {
- WriteData("M1.7", true);
- }
- if (status == "Stop")
- {
- WriteData("M1.7", false);
- }
- DeviceProcessLogShow($"清洗模组2执行【{status}】操作");
- }
- }
-
- public override void Stop()
- {
-
- }
-
- public override void SimOrder()
- {
-
+
+
}
}
}
\ No newline at end of file
diff --git a/BPASmartClient.MorkF/GVL_MorkF.cs b/BPASmartClient.MorkF/GVL_MorkF.cs
index c2734d8a..c577aa90 100644
--- a/BPASmartClient.MorkF/GVL_MorkF.cs
+++ b/BPASmartClient.MorkF/GVL_MorkF.cs
@@ -10,100 +10,106 @@ namespace BPASmartClient.MorkF
{
internal class GVL_MorkF
{
-
- ///
- /// 初始化完成状态
- ///
- public bool InitialComplete { get; set; }
- ///
- /// 供盘 模组状态 忙碌1 空闲0
- ///
- public bool ProvidePlateModule { get; set; }
- ///
- /// 供盘完成状态
- ///
- public bool ProvidePlateComplete { get; set; }
///
- /// 清洗模组1状态 忙碌1 空闲0
+ /// 小炒菜单集合
///
- public bool CleanModule { get; set; }
+ public List LocalstirFryGoods =new List();
///
- /// 清洗模组2状态 忙碌1 空闲0
+ /// 小炒队列
///
- public bool SecondCleanModule { get; set; }
- ///
- /// 清洗模组1完成状态
- ///
- public bool CleanComplete { get; set; }
+ public ConcurrentQueue StirFryGoodsQuenes = new ConcurrentQueue();
- //
- /// 清洗模组2完成状态
- ///
- public bool SecondCleanComplete { get; set; }
- ///
- /// 锅灶1状态 忙碌1 空闲0
- ///
- public bool KitchenOneStatus { get; set; }
+ public bool IsAuto = true;
+ #region 炒锅1
///
- /// 锅灶1状态 忙碌1 空闲0
+ /// 炒锅自动模式
///
- public bool KitchenSecondStatus { get; set; }
+ public bool AutoMode { get; set; }
///
- /// 锅灶1注油完成状态
+ /// 炒锅1初始化完成
///
- public bool FallOilComplete { get; set; }
+ public bool FryPot1_InitialComplete { get; set; }
///
- /// 锅灶2注油完成状态
+ /// 炒锅1允许HBOT放盒
///
- public bool SecondOilComplete { get; set; }
+ public bool FryPot1_HOBTPut { get; set; }
///
- /// 锅灶1翻转机上升完成状态
+ /// 炒锅1允许HBOT取盒
///
- public bool TurnMachineUpComplete { get; set; }
+ public bool FryPot1_HOBTGet { get; set; }
///
- /// 锅灶2翻转机上升完成状态
+ /// 往炒锅倒菜完成
///
- public bool SecondTurnMachineUpComplete { get; set; }
+ public bool FryPot1_MaterialIntoPot { get; set; }
///
- /// 锅灶1翻转机下降完成状态
+ /// 出餐完成
///
- public bool TurnMachineDownComplete { get; set; }
-
+ public bool OutFoodCompelete { get; set; }
///
- /// 锅灶2翻转机下降完成状态
+ /// 允许出餐倒菜
///
- public bool SecondTurnMachineDownComplete { get; set; }
+ public bool CanOutFood { get; set; }
///
- /// 料仓旋转到位状态
+ /// 窗口取餐完成
///
- public bool MaterialArriveComplete { get; set; }
+ public bool GetFoodCompelete { set; get; }
///
- /// 机器人空闲状态 1:忙碌 0:空闲
+ /// 允许倒洗锅水
///
- public bool RoobotIdle { get; set; }
+ public bool CanOutPotWashingWater { get; set; }
///
- /// 放锅至灶台1完成状态
+ /// 搅拌臂在原点位
///
- public bool PutPotToKitchenComlete { get; set; }
-
+ public bool ArmOnOrigin { get; set; }
///
- /// 放锅至灶台2完成状态
+ /// 搅拌臂在工作位
///
- public bool PutPotToSecondKitchenComlete { get; set; }
+ public bool ArmOnWorking { get; set; }
///
- /// 机器人取料完成状态
+ /// 锅在原点位
///
- public bool TakeMaterialComplete { get; set; }
- ///
- /// 机器人放锅至清洗台1完成状态
- ///
- public bool PlaceRinseTableComplete { get; set; }
- ///
- /// 机器人放锅至清洗台2完成状态
- ///
- public bool PlaceRinseSecondTableComplete { get; set; }
+ public bool PotOnOrigin { get; set; }
+
+ #endregion
+
+ #region 调料通道
+ public bool PassWay1_1Compelete { get; set; }
+ public bool PassWay1_2Compelete { get; set; }
+ public bool PassWay1_3Compelete { get; set; }
+ public bool PassWay1_4Compelete { get; set; }
+ public bool PassWay1_5Compelete { get; set; }
+ public bool PassWay1_6Compelete { get; set; }
+ public bool PassWay1_7Compelete { get; set; }
+ public bool PassWay1_8Compelete { get; set; }
+ public bool PassWay1_9Compelete { get; set; }
+ public bool PassWay1_10Compelete { get; set; }
+ public bool PassWay1_11Compelete { get; set; }
+ public bool PassWay1_12Compelete { get; set; }
+ public bool PassWay1_13Compelete { get; set; }
+ public bool PassWay1_14Compelete { get; set; }
+ public Dictionary PassWay1_Compelete = new Dictionary();
+ #endregion
+
+ public GVL_MorkF()
+ {
+ PassWay1_Compelete.Add(1,PassWay1_1Compelete);
+ PassWay1_Compelete.Add(2,PassWay1_2Compelete);
+ PassWay1_Compelete.Add(3,PassWay1_3Compelete);
+ PassWay1_Compelete.Add(4,PassWay1_4Compelete);
+ PassWay1_Compelete.Add(5,PassWay1_5Compelete);
+ PassWay1_Compelete.Add(6,PassWay1_6Compelete);
+ PassWay1_Compelete.Add(7,PassWay1_7Compelete);
+ PassWay1_Compelete.Add(8,PassWay1_8Compelete);
+ PassWay1_Compelete.Add(9,PassWay1_9Compelete);
+ PassWay1_Compelete.Add(10,PassWay1_10Compelete);
+ PassWay1_Compelete.Add(11,PassWay1_11Compelete);
+ PassWay1_Compelete.Add(12,PassWay1_12Compelete);
+ PassWay1_Compelete.Add(13,PassWay1_13Compelete);
+ PassWay1_Compelete.Add(14,PassWay1_14Compelete);
+ }
+
///
/// 订单取配料队列
///
@@ -112,185 +118,12 @@ namespace BPASmartClient.MorkF
/// 订单供盘队列
///
public ConcurrentQueue TakePlateQueue = new ConcurrentQueue();
- ///
- /// 存放主流程当前订单唯一ID
- ///
- public string MainCurrentOrderId { get; set; }
- ///
- /// 存放辅流程当前订单唯一ID
- ///
- public string MinorCurrentOrderId { get; set; }
- ///
- /// PLC上升沿初始化触发信号
- ///
- public bool DevicDataInite { set; get; }
- ///
- /// 取素菜A料完成
- ///
- public bool TakeVegBurdenAComplete { get; set; }
- ///
- /// 取荤菜A料完成
- ///
- public bool TakeMeatBurdenAComplete { get; set; }
- ///
- /// 所有A料下锅完成
- ///
- public bool TakeAllBurdenAComplete { get; set; }
- ///
- /// 取素菜B料完成
- ///
- public bool TakeVegBurdenBComplete { get; set; }
- ///
- /// 所有B料下锅完成
- ///
- public bool TakeAllBurdenBComplete { get; set; }
- ///
- /// 取C料完成
- ///
- public bool TakeBurdenCComplete { get; set; }
- ///
- /// 除C料外,所有配料下锅标志
- ///
- public bool TakeAllBurdenComplete { get; set; }
- ///
- /// 锅1到位 true:到位 false:未到位
- ///
- public bool PotInPlace { get; set; }
- ///
- /// 锅2到位 true:到位 false:未到位
- ///
- public bool SecondPotInPlace { get; set; }
- ///
- /// true:烹饪完成
- ///
- public bool CookingComplete { get; set; }
- ///
- /// 注油完成
- ///
- public bool AddOilComplete { get; set; }
- ///
- /// 1号锅倒料完成
- ///
- public bool FallMaterialComplete { get; set; }
- ///
- /// 2号锅倒料完成
- ///
- public bool SecondFallMaterialComplete { get; set; }
- ///
- /// 供盘互锁
- ///
- public bool TakePlateLock { get; set; }
- ///
- /// 取锅互锁
- ///
- public bool TakePotLock { get; set; }
- ///
- /// 取素菜A料互锁
- ///
- public bool TakeVegALock { get; set; }
- ///
- /// 取荤菜A料互锁
- ///
- public bool TakeMeatALock { get; set; }
- ///
- /// 取素菜B料互锁
- ///
- public bool TakeVegBLock { get; set; }
- ///
- /// 取C料互锁
- ///
- public bool TakeBurdenCLcok { get; set; }
- ///
- /// 烹饪任务互锁
- ///
- public bool CookingLock { get; set; }
- ///
- /// 转台互锁
- ///
- public bool TurnTableLock { get; set; }
- ///
- /// 主流程自锁
- ///
- public bool MainProcessExcuteLock { get; set; }
- ///
- /// 辅流程自锁
- ///
- public bool MinorProcessExcuteLock { get; set; }
- ///
- /// 开始取料标志
- ///
- public bool AllowTakeMaterial { get; set; }
- ///
- /// 主流程订单完成标志
- ///
- public bool MainOutMealComplete { get; set; }
- ///
- /// 辅流程订单完成标志
- ///
- public bool MinorOutMealComplete { get; set; }
- ///
- /// 主流程订单取料结束
- ///
- public bool MainOrderMaterialCom { get; set; }
- ///
- /// 主流程是否取料判断
- ///
- public bool MainHasTakeMaterial { get; set; }
- ///
- /// 主流程等待
- ///
- public bool MainProcessWait { get; set; }
- ///
- /// 辅流程等待
- ///
- public bool MinorProcessWait { get; set; }
- ///
- /// 辅流程订单取料结束
- ///
- public bool MinorOrderMaterialCom { get; set; }
- ///
- /// 辅流程是否取料判断
- ///
- public bool MinorHasTakeMaterial { get; set; }
- ///
- /// 存储订单对应流程对象
- ///
- public List listStirBom=new List();
+
+
+
- ///
- /// 下配料次数
- ///
- public int MaterialCount { get; set; }
- ///
- /// 允许执行辅流程标识
- ///
- public bool MinorProcessFlag { get; set; }
- ///
- /// 辅流程执行状态
- ///
- public bool MinorProessStatus { get; set; }
- ///
- /// 允许执行主流程标识
- ///
- public bool MainProcessFlag { get; set; } = true;
- ///
- /// 主流程执行状态
- ///
- public bool MainProcessStatus { get; set; } = true;
- ///
- /// 当前放锅位置 1:1号锅 2: 2号锅
- ///
- public int CurrentPutPotLoc { get; set; }
- ///
- /// 主流程所执行的锅位置
- ///
- public int MainProcessPotLoc { get; set; }
- ///
- /// 辅流程所执行的锅位置
- ///
- public int MinorProcessPotLoc { get; set; }
#region 单口锅逻辑变量
@@ -303,39 +136,39 @@ namespace BPASmartClient.MorkF
public Dictionary StartPassWay { get; set; } = new Dictionary()
{
- {1,"M3.0" },
- {2,"M3.1" },
- {3,"M3.2" },
- {4,"M3.3" },
- {5,"M3.4" },
- {6,"M3.5" },
- {7,"M3.6" },
- {8,"M3.7" },
- {9,"M4.0" },
- {10,"M4.1" },
- {11,"M4.2" },
- {12,"M4.3" },
- {13,"M4.4" },
- {13,"M4.5" },
+ {1,"LB24" },
+ {2,"LB25" },
+ {3,"LB26" },
+ {4,"LB27" },
+ {5,"LB28" },
+ {6,"LB29" },
+ {7,"LB30" },
+ {8,"LB31" },
+ {9,"LB32" },
+ {10,"LB33" },
+ {11,"LB34" },
+ {12,"LB35" },
+ {13,"LB36" },
+ {14,"LB37" },
};
public Dictionary PassWayValue { get; set; } = new Dictionary()
{
- {1,"VW200" },
- {2,"VW202" },
- {3,"VW204" },
- {4,"VW206" },
- {5,"VW208" },
- {6,"VW210" },
- {7,"VW212" },
- {8,"VW214" },
- {9,"VW216" },
- {10,"VW218" },
- {11,"VW220" },
- {12,"VW222" },
- {13,"VW224" },
- {13,"VW226" },
+ {1,"LW0" },
+ {2,"LW1" },
+ {3,"LW2" },
+ {4,"LW3" },
+ {5,"LW4" },
+ {6,"LW5" },
+ {7,"LW6" },
+ {8,"LW7" },
+ {9,"LW8" },
+ {10,"LW9" },
+ {11,"LW10" },
+ {12,"LW11" },
+ {13,"LW12" },
+ {14,"LW13" },
};
}
}
diff --git a/BPASmartClient.MorkF/Model/StirFryPushMessages.cs b/BPASmartClient.MorkF/Model/StirFryPushMessages.cs
new file mode 100644
index 00000000..6eccd5cb
--- /dev/null
+++ b/BPASmartClient.MorkF/Model/StirFryPushMessages.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using BPA.Message;
+
+namespace BPASmartClient.MorkF.Model
+{
+ public class StirFryPushMessages
+ {
+ public StirFryPushMessage pushMessage = new StirFryPushMessage();
+ }
+}
diff --git a/BPASmartClient.MorkF/OrderLocInfo.cs b/BPASmartClient.MorkF/OrderLocInfo.cs
index 4d171aa3..3891bde1 100644
--- a/BPASmartClient.MorkF/OrderLocInfo.cs
+++ b/BPASmartClient.MorkF/OrderLocInfo.cs
@@ -1,4 +1,5 @@
-using System;
+using BPA.Models;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,8 +10,9 @@ namespace BPASmartClient.MorkF
internal class OrderLocInfo
{
public string SuborderId { get; set; }
- public List MaterialLoc { get; set; } = new List();//物料A位置
+ public List StirPotActions = new List();
public ushort RecipeNumber { get; set; }
public int BatchingId { get; set; }
+ public string GoodName { get; set; }
}
}
\ No newline at end of file
diff --git a/BPASmartClient.MorkF/View/DebugView.xaml b/BPASmartClient.MorkF/View/DebugView.xaml
index 4d07a7b9..3fb087cc 100644
--- a/BPASmartClient.MorkF/View/DebugView.xaml
+++ b/BPASmartClient.MorkF/View/DebugView.xaml
@@ -4,8 +4,12 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.MorkF.View"
+ xmlns:vm="clr-namespace:BPASmartClient.MorkF.ViewModel"
mc:Ignorable="d"
- d:DesignHeight="600" d:DesignWidth="1300">
+ d:DesignHeight="900" d:DesignWidth="1300">
+
+
+
@@ -16,38 +20,98 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
@@ -106,7 +170,7 @@
-
+
diff --git a/BPASmartClient.MorkF/View/DebugView.xaml.cs b/BPASmartClient.MorkF/View/DebugView.xaml.cs
index 397537de..bbd1c9f7 100644
--- a/BPASmartClient.MorkF/View/DebugView.xaml.cs
+++ b/BPASmartClient.MorkF/View/DebugView.xaml.cs
@@ -24,7 +24,7 @@ namespace BPASmartClient.MorkF.View
public DebugView()
{
InitializeComponent();
- this.DataContext = new DebugViewModel();
+
}
}
diff --git a/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs b/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs
index e11d25a0..f9807ac9 100644
--- a/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs
+++ b/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs
@@ -1,9 +1,12 @@
-using BPASmartClient.Helper;
+using BPASmartClient.Business;
+using BPASmartClient.Device;
+using BPASmartClient.Helper;
using BPASmartClient.MorkF.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -13,30 +16,68 @@ namespace BPASmartClient.MorkF.ViewModel
internal class DebugViewModel : ObservableObject
{
public bool SimOrderEnable { get { return General_Config.SimOrderAllow; } set { General_Config.SimOrderAllow = value; OnPropertyChanged(); } }
+ ///
+ /// 设备数据
+ ///
+ public ObservableCollection variableMonitors { get; set; }
+
+ ///
+ /// 设备ID
+ ///
+ public int DeviceId { get; set; }
+
#region 设备控制
public RelayCommand PlcInite { get; set; }
- public RelayCommand SimulateOrder { get; set; }
- public RelayCommand MaterialOne { get; set; }
- public RelayCommand MaterialTwo { get; set; }
- public RelayCommand MaterialThree { get; set; }
- public RelayCommand MaterialFour { get; set; }
- public RelayCommand MaterialFive { get; set; }
- public RelayCommand OpenExhaust { get;set; }
- public RelayCommand CloaseExhaust { get; set; }
- public RelayCommand StartQXOne { get; set; }
- public RelayCommand StartQXTwo { get; set; }
- #endregion
+ public RelayCommand FoodPlcInite { get; set; }
+ public RelayCommand Plc1Reset { get; set; }
+
+
+
+ #endregion
#region 菜品控制
+ public string RealX { get { return _realX; } set { _realX = value; OnPropertyChanged(); } }
+ private string _realX;
+ public string RealY { get { return _realY; } set { _realY = value; OnPropertyChanged(); } }
+ private string _realY;
+
+ public int SettingX { get { return _settingX; } set { _settingX = value; OnPropertyChanged(); } }
+ private int _settingX = 0;
+ public int SettingY { get { return _settingY; } set { _settingY = value; OnPropertyChanged(); } }
+ private int _settingY = 0;
+
+ public int MoveSpeed { get { return _moveSpeed; } set { _moveSpeed = value; OnPropertyChanged(); } }
+ private int _moveSpeed;
+ public string SensingDistance_1 { get { return _sensingDistance_1; } set { _sensingDistance_1 = value; OnPropertyChanged(); } }
+ private string _sensingDistance_1 ;
+ public string SensingDistance_2 { get { return _sensingDistance_2; } set { _sensingDistance_2 = value; OnPropertyChanged(); } }
+ private string _sensingDistance_2 ;
+ public string SensingDistance_3 { get { return _sensingDistance_3; } set { _sensingDistance_3 = value; OnPropertyChanged(); } }
+ private string _sensingDistance_3;
+ public bool PawPositon1 { get { return _pawPositon1; } set { _pawPositon1 = value; OnPropertyChanged(); } }
+ private bool _pawPositon1;
+ public bool PawPositon2 { get { return _pawPositon2; } set { _pawPositon2 = value; OnPropertyChanged(); } }
+ private bool _pawPositon2;
+ public bool PawPositon3 { get { return _pawPositon3; } set { _pawPositon3 = value; OnPropertyChanged(); } }
+ private bool _pawPositon3;
+
+
+ public RelayCommand FoodLibInit { get; set; }//初始化
+ public RelayCommand StartElectromagnetism { get; set; }//电磁阀启动
+ public RelayCommand StopElectromagnetism { get; set; }
+ public RelayCommand SetSpeed { get; set; }//速度设定
+ public RelayCommand GetDistance_1 { get; set; }//感应测距1
+ public RelayCommand GetDistance_2 { get; set; }//感应测距2
+ public RelayCommand GetDistance_3 { get; set; }//感应测距3
+ public RelayCommand PawTurnFront { get; set; }//夹爪正转
+ public RelayCommand PawTurnBack { get; set; }//夹爪反转
+ public RelayCommand SetArmPosition { get; set; }//机器臂位置设定
- public RelayCommand ShreddCabbage { get; set; }
- public RelayCommand FryPork { get; set; }
- public RelayCommand XingBaoGu { get; set; }
#endregion
-
+
#region 配料仓控制
- public List PassageWays = new List()
+ public List PassageWays { get; set; } = new List()
{
"通道1",
"通道2",
@@ -61,6 +102,7 @@ namespace BPASmartClient.MorkF.ViewModel
#endregion
#region 炒锅1
+ public RelayCommand Pot1SimOrder { get; set; }
public RelayCommand AddOil { get; set; }
public RelayCommand StartFire { get; set; }
public RelayCommand StopFire { get; set; }
@@ -79,6 +121,28 @@ namespace BPASmartClient.MorkF.ViewModel
private int _fireGear;
public int StirGear { get { return _stirGear; } set { _stirGear = value; OnPropertyChanged(); } }
private int _stirGear;
+ #region 模拟
+ public int OilTime { get { return _oilTime; } set { _oilTime = value; OnPropertyChanged(); } }
+ private int _oilTime = 10;
+ public int OilFirGear { get { return _oilFirGear; } set { _oilFirGear = value; OnPropertyChanged(); } }
+ private int _oilFirGear = 3;
+ public int OilStrGear { get { return _oilStrGear; } set { _oilStrGear = value; OnPropertyChanged(); } }
+ private int _oilStrGear = 1;
+
+ public int Food1Time { get { return _food1Time; } set { _food1Time = value; OnPropertyChanged(); } }
+ private int _food1Time = 30;
+ public int Food1FirGear { get { return _food1FirGear; } set { _food1FirGear = value; OnPropertyChanged(); } }
+ private int _food1FirGear = 6;
+ public int Food1StrGear { get { return _food1StrGear; } set { _food1StrGear = value; OnPropertyChanged(); } }
+ private int _food1StrGear = 2;
+
+ public int Food2Time { get { return _food2Time; } set { _food2Time = value; OnPropertyChanged(); } }
+ private int _food2Time = 30;
+ public int Food2FirGear { get { return _food2FirGear; } set { _food2FirGear = value; OnPropertyChanged(); } }
+ private int _food2FirGear = 6;
+ public int Food2StrGear { get { return _food2StrGear; } set { _food2StrGear = value; OnPropertyChanged(); } }
+ private int _food2StrGear = 2;
+ #endregion
#endregion
@@ -102,28 +166,33 @@ namespace BPASmartClient.MorkF.ViewModel
{
#region 设备控制
PlcInite = new RelayCommand(() => { ActionManage.GetInstance.Send("InitCommand"); });
- SimulateOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("SimultaorOrder"); });
- MaterialOne = new RelayCommand(() => { ActionManage.GetInstance.Send("MaterialOne"); });
- MaterialTwo = new RelayCommand(() => { ActionManage.GetInstance.Send("MaterialTwo"); });
- MaterialThree = new RelayCommand(() => { ActionManage.GetInstance.Send("MaterialThree"); });
- MaterialFour = new RelayCommand(() => { ActionManage.GetInstance.Send("MaterialFour"); });
- MaterialFive = new RelayCommand(() => { ActionManage.GetInstance.Send("MaterialFive"); });
- OpenExhaust = new RelayCommand(() => { ActionManage.GetInstance.Send("OpenExhaust"); });
- CloaseExhaust = new RelayCommand(() => { ActionManage.GetInstance.Send("CloseExhaust"); });
- StartQXOne = new RelayCommand(() => { ActionManage.GetInstance.Send("StartQXOne", 1); });
- StartQXTwo = new RelayCommand(() => { ActionManage.GetInstance.Send("StartQXTwo", 2); });
+ FoodPlcInite = new RelayCommand(() => { ActionManage.GetInstance.Send("FoodPlcInite"); });
+ Plc1Reset = new RelayCommand(() => { ActionManage.GetInstance.Send("Plc1Reset"); });
#endregion
- ShreddCabbage = new RelayCommand(() => { ActionManage.GetInstance.Send("ShreddCabbage"); });
- FryPork = new RelayCommand(() => { ActionManage.GetInstance.Send("FryPork"); });
- XingBaoGu = new RelayCommand(() => { ActionManage.GetInstance.Send("XingBaoGu"); });
+ #region 菜品控制
+
+ FoodLibInit = new RelayCommand(() => { ActionManage.GetInstance.Send("FoodLibInit"); });//菜品库初始化
+ StartElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List { true }); });//电磁阀启动
+ StopElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List { false });});//电磁阀关闭
+ SetSpeed = new RelayCommand(() =>
+ {
+ ActionManage.GetInstance.Send("SetSpeed", new List { MoveSpeed });
+ });//设定速度
+ GetDistance_1 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_1"); });//感应距离1
+ GetDistance_2 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_2"); });//感应距离2
+ GetDistance_3 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_3"); });//感应距离3
+ PawTurnFront = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnFront"); });//夹爪正转
+ PawTurnBack = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnBack"); });//夹爪反转
+ SetArmPosition = new RelayCommand(() => { ActionManage.GetInstance.Send("SetArmPosition", new List { SettingX, SettingY }); });//设定机械臂位置
+ #endregion
#region 配料仓控制
OutMaterials = new RelayCommand(() => { ActionManage.GetInstance.Send("OutMaterials" ,new List { PassagePosition,Weight } ); });
#endregion
-
#region 炒锅1
+ Pot1SimOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("模拟小炒锅1订单",new List { OilTime,OilFirGear,OilStrGear,Food1Time,Food1FirGear,Food1StrGear,Food2Time,Food2FirGear,Food2StrGear }); });//模拟订单
AddOil = new RelayCommand(() => { ActionManage.GetInstance.Send("AddOil", 1); });//加油
StartFire = new RelayCommand(() => { ActionManage.GetInstance.Send("StartFire"); });//加热启动
StopFire = new RelayCommand(() => { ActionManage.GetInstance.Send("StopFire"); });//加热停止
@@ -138,8 +207,6 @@ namespace BPASmartClient.MorkF.ViewModel
SetStir = new RelayCommand(() => { ActionManage.GetInstance.Send("SetStir", new List { StirGear }); });//搅拌挡位设定
#endregion
-
-
#region 炒锅2
SecAddOil = new RelayCommand(() => { ActionManage.GetInstance.Send("AddOil", 2); });
SecTempTurnOff = new RelayCommand(() => { ActionManage.GetInstance.Send("TakeOff", 2); });
@@ -155,6 +222,23 @@ namespace BPASmartClient.MorkF.ViewModel
SecAutoModel = new RelayCommand(() => { ActionManage.GetInstance.Send("AutoModel", 2); });
SecManualModel = new RelayCommand(() => { ActionManage.GetInstance.Send("ManualModel", 2); });
#endregion
+
+ Plugin.GetInstance()?.GetPlugin()?.GetDevices().ForEach(device =>
+ {
+ if (device.Name == "MorkT") DeviceId = device.DeviceId
+ ;
+ });
+
+ ThreadManage.GetInstance().StartLong(new Action(() =>
+ {
+ variableMonitors = Plugin.GetInstance()?.GetPlugin()?.GetDevices()?.FirstOrDefault(p => p.DeviceId == DeviceId)?.variableMonitors;
+
+ if(variableMonitors != null)
+ {
+ RealX = variableMonitors.FirstOrDefault(p => p.Notes == "机械手臂X").CurrentValue;
+ RealY = variableMonitors.FirstOrDefault(p => p.Notes == "机械手臂Y").CurrentValue;
+ }
+ }), "获取小炒数据");
}
}
diff --git a/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj b/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj
index 336101e6..ae24e079 100644
--- a/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj
+++ b/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/BPASmartClient.MorkT_HQ/BPASmartClient.MorkTHQ.csproj b/BPASmartClient.MorkT_HQ/BPASmartClient.MorkTHQ.csproj
index 9498c495..c20c9352 100644
--- a/BPASmartClient.MorkT_HQ/BPASmartClient.MorkTHQ.csproj
+++ b/BPASmartClient.MorkT_HQ/BPASmartClient.MorkTHQ.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs b/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
index c3f0fe84..4442540f 100644
--- a/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
+++ b/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
@@ -87,6 +87,7 @@ namespace BPASmartClient.ViewModel
}
}
}
+
}
private void NewCommunication(object? obj)
@@ -109,7 +110,8 @@ namespace BPASmartClient.ViewModel
{
CommunicationName = $"Communication_{num}",
DeviceModelId = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == dm.DeviceName)?.Id,
- communicationPar = new CommunicationPar() { IsNetworkPort = false }
+ communicationPar = new CommunicationPar() { IsNetworkPort = false },
+
});
break;
diff --git a/BPASmartClient/Control/ShopDeviceConfigView.xaml.cs b/BPASmartClient/Control/ShopDeviceConfigView.xaml.cs
index d7131331..ab21b48b 100644
--- a/BPASmartClient/Control/ShopDeviceConfigView.xaml.cs
+++ b/BPASmartClient/Control/ShopDeviceConfigView.xaml.cs
@@ -78,17 +78,40 @@ namespace BPASmartClient.Control
int commIndex = Array.FindIndex(ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ToArray(), p => p.DeviceModelId == communicationModel.DeviceModelId);
if (commIndex >= 0 && commIndex < ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.Count)
{
- if (ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).variables.Count <= 0)
+ foreach (var item in ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies)
{
- for (int i = 0; i < 20; i++)
+ if (item.variables.Count <= 0)
{
- ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).variables.Add(new Variable()
+ for (int i = 0; i < 20; i++)
{
- Id = ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).variables.Count,
- Address = string.Empty,
- ReadLeng = 0
- });
+ item.variables.Add(new Variable()
+ {
+ Id = ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).variables.Count,
+ Address = string.Empty,
+ ReadLeng = 0
+ });
+ }
}
+ //if (ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).variables.Count <= 0)
+ //{
+ // for (int i = 0; i < 20; i++)
+ // {
+ // ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).variables.Add(new Variable()
+ // {
+ // Id = ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).variables.Count,
+ // Address = string.Empty,
+ // ReadLeng = 0
+ // });
+ // }
+ // {
+ // ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).variables.Add(new Variable()
+ // {
+ // Id = ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).variables.Count,
+ // Address = string.Empty,
+ // ReadLeng = 0
+ // });
+ // }
+ //}
}
}
}
diff --git a/DosingSystem/BPASmartClient.DosingSystem.csproj b/DosingSystem/BPASmartClient.DosingSystem.csproj
index d6aaf8b9..bdcb1342 100644
--- a/DosingSystem/BPASmartClient.DosingSystem.csproj
+++ b/DosingSystem/BPASmartClient.DosingSystem.csproj
@@ -16,7 +16,7 @@
-
+
From 3f1327562bf791a3cb9c888dae3d0a7d587ac91e Mon Sep 17 00:00:00 2001
From: NXX <447201003@qq>
Date: Thu, 27 Oct 2022 13:14:27 +0800
Subject: [PATCH 02/22] BIserver
---
BPASmartClient.MorkF/Control_MorkF.cs | 274 +++++++++-----
BPASmartClient.MorkF/Model/LocalPotStep.cs | 14 +
BPASmartClient.MorkF/View/DebugView.xaml | 10 +-
BPASmartClient.MorkF/View/DebugView.xaml.cs | 14 +-
BPASmartClient.MorkF/View/LocalMenu.xaml | 80 +++++
BPASmartClient.MorkF/View/LocalMenu.xaml.cs | 333 ++++++++++++++++++
.../ViewModel/DebugViewModel.cs | 8 +-
.../ViewModel/LocalMenuViewModel.cs | 99 ++++++
.../BPASmartClient.MorkS.csproj | 2 +-
.../BPASmartClient.MorkTHQ.csproj | 2 +-
.../BPASmartClient.DosingSystem.csproj | 2 +-
11 files changed, 732 insertions(+), 106 deletions(-)
create mode 100644 BPASmartClient.MorkF/Model/LocalPotStep.cs
create mode 100644 BPASmartClient.MorkF/View/LocalMenu.xaml
create mode 100644 BPASmartClient.MorkF/View/LocalMenu.xaml.cs
create mode 100644 BPASmartClient.MorkF/ViewModel/LocalMenuViewModel.cs
diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs
index bebf66c2..4b4ac915 100644
--- a/BPASmartClient.MorkF/Control_MorkF.cs
+++ b/BPASmartClient.MorkF/Control_MorkF.cs
@@ -10,6 +10,7 @@ using BPA.Models;
using static BPASmartClient.EventBus.EventBus;
using BPASmartClient.Model.小炒机;
using BPASmartClient.MorkF.Model;
+using System.Text;
namespace BPASmartClient.MorkF
{
@@ -37,7 +38,8 @@ namespace BPASmartClient.MorkF
ActionManage.GetInstance.Register(PLCInite, "InitCommand");
ActionManage.GetInstance.Register(FoodPlcInite, "FoodPlcInite");
ActionManage.GetInstance.Register(InitialData, "SimultaorOrder");
-
+ ActionManage.GetInstance.Register(StartOrder, "StartOrder");
+ ActionManage.GetInstance.Register(StartLocalOrder, "StartLocalOrder");
#endregion
#region 菜品库
@@ -72,14 +74,14 @@ namespace BPASmartClient.MorkF
ActionManage.GetInstance.Register(SetStir, "SetStir");
#endregion
-
+
}
#region 菜品库
public void FoodLibInit()
{
- WriteControl("",true);
+ WriteControl("", true);
}
public void Electromagnetism(object o)
{
@@ -108,7 +110,7 @@ namespace BPASmartClient.MorkF
public void PawTurnBack()
{
WriteControl("", true);
- }
+ }
///
/// 设定机械臂的位置
///
@@ -140,7 +142,7 @@ namespace BPASmartClient.MorkF
///
public void OutSeasonings(List seasoningLists)
{
- foreach(SeasoningList seasoning in seasoningLists)
+ foreach (SeasoningList seasoning in seasoningLists)
{
WriteControl(morkF.PassWayValue[seasoning.Loc], (ushort)seasoning.Qty);
Thread.Sleep(300);
@@ -150,7 +152,7 @@ namespace BPASmartClient.MorkF
WriteControl(morkF.StartPassWay[seasoning.Loc], true);
Thread.Sleep(300);
}
-
+
}
#region 炒锅1
@@ -174,7 +176,7 @@ namespace BPASmartClient.MorkF
WriteControl("LB4", false);
Thread.Sleep(200);
WriteControl("LB53", false);
- foreach(var item in morkF.StartPassWay.Values)
+ foreach (var item in morkF.StartPassWay.Values)
{
Thread.Sleep(200);
WriteControl(item, false);
@@ -240,16 +242,20 @@ namespace BPASmartClient.MorkF
//搅拌臂去炒制位
public void StirArmGoWork()
{
- WriteControl("LB6", true);
- MessageLog.GetInstance.Show("搅拌臂去工作位");
- while (!morkF.ArmOnWorking)
+ if (!morkF.ArmOnWorking)
{
+ WriteControl("LB6", true);
+ MessageLog.GetInstance.Show("搅拌臂去工作位");
+ while (!morkF.ArmOnWorking)
+ {
+ Thread.Sleep(200);
+ }
+
+ WriteControl("LB6", false);
Thread.Sleep(200);
+ MessageLog.GetInstance.Show("搅拌臂到达工作位");
}
-
- WriteControl("LB6", false);
- Thread.Sleep(200);
- MessageLog.GetInstance.Show("搅拌臂到达工作位");
+
}
//HBOT放盒子到位
public void HBOTGoWork()
@@ -268,16 +274,16 @@ namespace BPASmartClient.MorkF
//加热挡位设定
public void SetFire(object o)
{
- if(o == null) return;
- if(o is List ints&&ints.Count == 1)
+ if (o == null) return;
+ if (o is List ints && ints.Count == 1)
{
WriteControl("LW14", (ushort)ints[0]);
Thread.Sleep(200);
}
-
+
}
-
+
///
/// 搅拌挡位设定
///
@@ -319,8 +325,47 @@ namespace BPASmartClient.MorkF
// //resultorder.AddRange(new int[] { 1, 2, 3 });
//}
-
-
+
+
+ }
+
+ ///
+ /// 本地菜单下单
+ ///
+ private void StartOrder(object o)
+ {
+ if(o==null) return;
+ if(o is int goodId)
+ {
+ var res = morkF.LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey == goodId);//匹配订单对应制作流程
+ if (res != null)
+ {
+ /* morkF.listStirBom.Add(res.StirFryBomInfo);*///添加订单制作流程
+ if (morkF.StirFryGoodsQuenes.Count > 0) return;
+ morkF.StirFryGoodsQuenes.Enqueue(new OrderLocInfo()
+ {
+ SuborderId = Guid.NewGuid().ToString(),
+ StirPotActions = res.StirPotActions,
+ GoodName = "本地菜品"
+ });
+ MessageLog.GetInstance.Show($"添加本地订单{res.GoodsKey}");
+ }
+ }
+ }
+
+ private void StartLocalOrder()
+ {
+ if (morkF.StirFryGoodsQuenes.Count > 0) return;//只能一个一个做
+ if (Json.Data.LocalstirFryGoods.StirPotActions.Count>0)
+ {
+ morkF.StirFryGoodsQuenes.Enqueue(new OrderLocInfo()
+ {
+ SuborderId = Guid.NewGuid().ToString(),
+ StirPotActions = Json.Data.LocalstirFryGoods.StirPotActions,
+ GoodName = "本地菜品"
+ });
+ MessageLog.GetInstance.Show($"添加本地模拟的订单{Json.Data.LocalstirFryGoods.GoodsKey}");
+ }
}
#endregion
@@ -397,88 +442,103 @@ namespace BPASmartClient.MorkF
if (@event == null) return;
if (@event is StirFryGoodsEvent stirFry)
{
- morkF.LocalstirFryGoods = stirFry.stirFrymessage.stirFryGoods;
+ if (stirFry.stirFrymessage.stirFryGoods.Count > 0)
+ {
+ foreach (var item in stirFry.stirFrymessage.stirFryGoods)
+ {
+ morkF.LocalstirFryGoods.Add(new StirFryGoods
+ {
+ GoodsKey = item.GoodsKey,
+ StirPotActions = OrderSort(item.StirPotActions),
+ });
+ }
+ }
+
MessageLog.GetInstance.Show("接收到小炒流程信息");
//流程解析
foreach (var item in morkF.LocalstirFryGoods)
{
MessageLog.GetInstance.Show($"添加菜谱{item.GoodsKey}");
// morkF.listStirBom.Add(item.StirFryBomInfo);//添加订单制作流程
+ string MenuStep = "菜单步骤:";
foreach (var items in item.StirPotActions)
{
switch (items.Actions)
{
- case "加热开启":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.加热开启):
+ MenuStep += items.Actions + ",";
break;
- case "设置加热挡位1":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置加热挡位1):
+ MenuStep += items.Actions + ",";
break;
- case "设置加热挡位2":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置加热挡位2):
+ MenuStep += items.Actions + ",";
break;
- case "设置加热挡位3":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置加热挡位3):
+ MenuStep += items.Actions + ",";
break;
- case "设置加热挡位4":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置加热挡位4):
+ MenuStep += items.Actions + ",";
break;
- case "设置加热挡位5":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置加热挡位5):
+ MenuStep += items.Actions + ",";
break;
- case "设置加热挡位6":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置加热挡位6):
+ MenuStep += items.Actions + ",";
break;
- case "设置加热挡位7":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置加热挡位7):
+ MenuStep += items.Actions + ",";
break;
- case "设置加热挡位8":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置加热挡位8):
+ MenuStep += items.Actions + ",";
break;
- case "设置加热挡位9":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置加热挡位9):
+ MenuStep += items.Actions + ",";
break;
- case "设置加热挡位10":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置加热挡位10):
+ MenuStep += items.Actions + ",";
break;
- case "停止加热":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.停止加热):
+ MenuStep += items.Actions + ",";
break;
- case "加调料":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.加调料):
+ MenuStep += items.Actions + ",";
break;
- case "取原料":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.取原料):
+ MenuStep += items.Actions + ",";
break;
- case "开启搅拌":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.开启搅拌):
+ MenuStep += items.Actions + ",";
break;
- case "设置搅拌挡位1":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置搅拌挡位1):
+ MenuStep += items.Actions + ",";
break;
- case "设置搅拌挡位2":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置搅拌挡位2):
+ MenuStep += items.Actions + ",";
break;
- case "设置搅拌挡位3":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.设置搅拌挡位3):
+ MenuStep += items.Actions + ",";
break;
- case "关闭搅拌":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.关闭搅拌):
+ MenuStep += items.Actions + ",";
break;
- case "出餐启动":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.出餐启动):
+ MenuStep += items.Actions + ",";
break;
- case "倒菜品":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.道菜启动):
+ MenuStep += items.Actions + ",";
break;
- case "搅拌臂原点位":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.炒制菜品):
+ MenuStep += items.Actions + ",";
break;
- case "搅拌臂炒制位":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.搅拌臂原点位):
+ MenuStep += items.Actions + ",";
break;
- case "洗锅":
- MessageLog.GetInstance.Show(items.Actions);
+ case nameof(StirFryPotActionEnum.搅拌臂炒制位):
+ MenuStep += items.Actions + ",";
+ break;
+ case nameof(StirFryPotActionEnum.洗锅):
+ MenuStep += items.Actions + ",";
break;
default:
break;
@@ -487,12 +547,33 @@ namespace BPASmartClient.MorkF
}
-
+ MessageLog.GetInstance.Show(MenuStep);
+
+
}
}
});
}
+
+
+ private List OrderSort(List potActions)
+ {
+ if (potActions.Count > 1)
+ {
+ potActions.Sort(
+ delegate (PotActions st1, PotActions st2)
+ {
+ //降序排列
+ //return st2.FryTime.CompareTo(st1.FryTime);
+
+ //升序版(颠倒 st1 和 st2 即可)
+ return st1.FryTime.CompareTo(st2.FryTime);
+
+ });
+ }
+ return potActions;
+ }
///
/// 订单状态发布
///
@@ -518,6 +599,7 @@ namespace BPASmartClient.MorkF
if (order.MorkOrder.GoodBatchings == null) return;
OrderCount++;
DeviceProcessLogShow($"接收到{OrderCount}次订单");
+ Enum.GetNames(typeof(StirFryPotActionEnum));
var res = morkF.LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey == order.MorkOrder.RecipeId);//匹配订单对应制作流程
if (res != null)
@@ -561,99 +643,99 @@ namespace BPASmartClient.MorkF
{
switch (item.Actions)
{
- case "加热开启":
+ case nameof(StirFryPotActionEnum.加热开启):
StartFire();
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置加热挡位1":
+ case nameof(StirFryPotActionEnum.设置加热挡位1):
SetFire(new List { 1 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置加热挡位2":
+ case nameof(StirFryPotActionEnum.设置加热挡位2):
SetFire(new List { 2 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置加热挡位3":
+ case nameof(StirFryPotActionEnum.设置加热挡位3):
SetFire(new List { 3 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置加热挡位4":
+ case nameof(StirFryPotActionEnum.设置加热挡位4):
SetFire(new List { 4 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置加热挡位5":
+ case nameof(StirFryPotActionEnum.设置加热挡位5):
SetFire(new List { 5 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置加热挡位6":
+ case nameof(StirFryPotActionEnum.设置加热挡位6):
SetFire(new List { 6 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置加热挡位7":
+ case nameof(StirFryPotActionEnum.设置加热挡位7):
SetFire(new List { 7 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置加热挡位8":
+ case nameof(StirFryPotActionEnum.设置加热挡位8):
SetFire(new List { 8 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置加热挡位9":
+ case nameof(StirFryPotActionEnum.设置加热挡位9):
SetFire(new List { 9 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置加热挡位10":
+ case nameof(StirFryPotActionEnum.设置加热挡位10):
SetFire(new List { 10 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "停止加热":
+ case nameof(StirFryPotActionEnum.停止加热):
StopFire();
MessageLog.GetInstance.Show(item.Actions);
break;
- case "加调料":
+ case nameof(StirFryPotActionEnum.加调料):
OutSeasonings(item.SeasoningLists);
MessageLog.GetInstance.Show(item.Actions);
break;
- case "取原料":
+ case nameof(StirFryPotActionEnum.取原料):
MessageLog.GetInstance.Show(item.Actions);
break;
- case "开启搅拌":
+ case nameof(StirFryPotActionEnum.开启搅拌):
StartStir();
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置搅拌挡位1":
+ case nameof(StirFryPotActionEnum.设置搅拌挡位1):
SetStir(new List { 1 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置搅拌挡位2":
+ case nameof(StirFryPotActionEnum.设置搅拌挡位2):
SetStir(new List { 2 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "设置搅拌挡位3":
+ case nameof(StirFryPotActionEnum.设置搅拌挡位3):
SetStir(new List { 3 });
MessageLog.GetInstance.Show(item.Actions);
break;
- case "关闭搅拌":
+ case nameof(StirFryPotActionEnum.关闭搅拌):
StopStir();
MessageLog.GetInstance.Show(item.Actions);
break;
- case "出餐启动":
+ case nameof(StirFryPotActionEnum.出餐启动):
MessageLog.GetInstance.Show(item.Actions);
break;
- case "倒菜品":
+ case nameof(StirFryPotActionEnum.道菜启动):
OutFood();
break;
- case "炒制菜品":
- Thread.Sleep(item.FryTime * 1000);
+ case nameof(StirFryPotActionEnum.炒制菜品):
+ Thread.Sleep(item.During * 1000);
break;
- case "搅拌臂原点位":
+ case nameof(StirFryPotActionEnum.搅拌臂原点位):
StirArmGoOrigin();
MessageLog.GetInstance.Show(item.Actions);
break;
- case "搅拌臂炒制位":
+ case nameof(StirFryPotActionEnum.搅拌臂炒制位):
StirArmGoWork();
MessageLog.GetInstance.Show(item.Actions);
break;
- case "洗锅":
+ case nameof(StirFryPotActionEnum.洗锅):
MessageLog.GetInstance.Show(item.Actions);
break;
default:
diff --git a/BPASmartClient.MorkF/Model/LocalPotStep.cs b/BPASmartClient.MorkF/Model/LocalPotStep.cs
new file mode 100644
index 00000000..cfae0cd9
--- /dev/null
+++ b/BPASmartClient.MorkF/Model/LocalPotStep.cs
@@ -0,0 +1,14 @@
+using BPA.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.MorkF.Model
+{
+ public class LocalPotStep
+ {
+ public StirFryGoods LocalstirFryGoods { get; set; } = new StirFryGoods();
+ }
+}
diff --git a/BPASmartClient.MorkF/View/DebugView.xaml b/BPASmartClient.MorkF/View/DebugView.xaml
index 3fb087cc..4f81ab65 100644
--- a/BPASmartClient.MorkF/View/DebugView.xaml
+++ b/BPASmartClient.MorkF/View/DebugView.xaml
@@ -33,9 +33,13 @@
-
-
-
+
+
+
+
+
+
+
diff --git a/BPASmartClient.MorkF/View/DebugView.xaml.cs b/BPASmartClient.MorkF/View/DebugView.xaml.cs
index bbd1c9f7..7cb98a10 100644
--- a/BPASmartClient.MorkF/View/DebugView.xaml.cs
+++ b/BPASmartClient.MorkF/View/DebugView.xaml.cs
@@ -1,4 +1,6 @@
-using BPASmartClient.MorkF.ViewModel;
+using BPASmartClient.Helper;
+using BPASmartClient.MorkF.Model;
+using BPASmartClient.MorkF.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -24,8 +26,14 @@ namespace BPASmartClient.MorkF.View
public DebugView()
{
InitializeComponent();
-
-
+ Json.Read();
+
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ LocalMenu localMenu = new LocalMenu();
+ localMenu.ShowDialog();
}
}
}
diff --git a/BPASmartClient.MorkF/View/LocalMenu.xaml b/BPASmartClient.MorkF/View/LocalMenu.xaml
new file mode 100644
index 00000000..63b2f2f4
--- /dev/null
+++ b/BPASmartClient.MorkF/View/LocalMenu.xaml
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BPASmartClient.MorkF/View/LocalMenu.xaml.cs b/BPASmartClient.MorkF/View/LocalMenu.xaml.cs
new file mode 100644
index 00000000..8c0c001d
--- /dev/null
+++ b/BPASmartClient.MorkF/View/LocalMenu.xaml.cs
@@ -0,0 +1,333 @@
+using BPA.Models;
+using BPASmartClient.Helper;
+using BPASmartClient.MorkF.ViewModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace BPASmartClient.MorkF.View
+{
+ ///
+ /// LocalMenu.xaml 的交互逻辑
+ ///
+ public partial class LocalMenu : Window
+ {
+
+ double X, Y;
+ Border ultUE;
+ Popup mypopup;
+ ListBoxItem OldItem;
+ ListBoxItem new_Item;
+ bool isDown = false;
+
+ int lao_index;
+ int new_index;
+
+
+ ///
+ /// 当前拖拽子控件Item
+ ///
+ private ListBoxItem ChildListBoxItem;
+
+ public LocalMenu()
+ {
+ InitializeComponent();
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ private int GetCurrentIndex(GetPositionDelegate getPosition)
+ {
+ int index = -1;
+ for (int i = 0; i < listview1.Items.Count; ++i)
+ {
+ ListBoxItem item = GetListViewItem(i);
+ if (item != null && this.IsMouseOverTarget(item, getPosition))
+ {
+ index = i;
+ break;
+ }
+ }
+ return index;
+ }
+
+ private bool IsMouseOverTarget(Visual target, GetPositionDelegate getPosition)
+ {
+ Rect bounds = VisualTreeHelper.GetDescendantBounds(target);
+ Point mousePos = getPosition((IInputElement)target);
+ return bounds.Contains(mousePos);
+ }
+
+
+ delegate Point GetPositionDelegate(IInputElement element);
+
+ ListBoxItem GetListViewItem(int index)
+ {
+ if (listview1.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
+ return null;
+ return listview1.ItemContainerGenerator.ContainerFromIndex(index) as ListBoxItem;
+ }
+
+ private void CloneVisual(Border border, MouseButtonEventArgs e)
+ {
+ ListBoxItem listBoxItem = new ListBoxItem();
+ Point ptLeftUp = new Point(0, 0);
+ ptLeftUp = listview1.PointToScreen(ptLeftUp);
+ mypopup = new Popup();
+ double y = e.GetPosition(listview1).Y;
+ double x = e.GetPosition(listview1).X;
+
+ VisualBrush brush = new VisualBrush(border);
+ Rectangle rect = new Rectangle();
+ rect.Width = border.ActualWidth;
+ rect.Height = border.ActualHeight;
+ rect.Fill = brush;
+ rect.Opacity = border.Opacity;
+ border.Opacity = 0.8;
+ mypopup.Child = rect;
+ mypopup.AllowsTransparency = true;
+ mypopup.HorizontalOffset = ptLeftUp.X + x - ((FrameworkElement)ultUE).ActualWidth / 2;
+ mypopup.VerticalOffset = ptLeftUp.Y + y - ((FrameworkElement)ultUE).ActualHeight / 2;
+ mypopup.IsOpen = true;
+ }
+
+ private void listview1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ try
+ {
+ if (isDown)
+ {
+ isDown = false;
+ return;
+ }
+ var pos = e.GetPosition(listview1);
+ HitTestResult result = VisualTreeHelper.HitTest(listview1, pos);
+ if (result == null) return;
+ OldItem = Utils.FindVisualParent(result.VisualHit);
+ if (OldItem != null)
+ {
+ if (e.Source is Border)
+ {
+ ultUE = (Border)e.Source;
+ ultUE.CaptureMouse();
+ ChildListBoxItem = Utils.FindVisualParent(VisualTreeHelper.HitTest(ultUE, e.GetPosition(ultUE)).VisualHit);
+ CloneVisual(ultUE, e);
+ isDown = true;
+ }
+ }
+ }
+ catch (Exception)
+ {
+
+ throw;
+ }
+ }
+
+
+
+ private void listview1_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (sender is ListBox listview&& e.LeftButton == MouseButtonState.Pressed&& listview.SelectedItem != null)
+ {
+ var pos = e.GetPosition(listview1);
+ HitTestResult result = VisualTreeHelper.HitTest(listview1, pos);
+ if (result == null)
+ {
+ return;
+ }
+ var listBoxItem = Utils.FindVisualParent(result.VisualHit);
+ if (listBoxItem == null || listBoxItem.Content != listview1.SelectedItem)
+ {
+ return;
+ }
+ DataObject dataObj = new DataObject(listBoxItem.Content as PotActions);
+ DragDrop.DoDragDrop(listview1, dataObj, DragDropEffects.Move);
+ ActionManage.GetInstance.Send("SortFryTime");
+ }
+
+
+ }
+
+ private void listview1_Drop(object sender, DragEventArgs e)
+ {
+ var pos = e.GetPosition(listview1);
+ var result = VisualTreeHelper.HitTest(listview1, pos);
+ if (result == null)
+ {
+ return;
+ }
+ //查找元数据
+ var sourcePerson = e.Data.GetData(typeof(PotActions)) as PotActions;
+ if (sourcePerson == null)
+ {
+ return;
+ }
+ //查找目标数据
+ var listBoxItem = Utils.FindVisualParent(result.VisualHit);
+ if (listBoxItem == null)
+ {
+ return;
+ }
+ var targetPerson = listBoxItem.Content as PotActions;
+ if (ReferenceEquals(targetPerson, sourcePerson))
+ {
+ return;
+ }
+ int i = listview1.Items.IndexOf(sourcePerson);
+ int j = listview1.Items.IndexOf(targetPerson);
+ ActionManage.GetInstance.Send("PotActionStep", new int[] { i, j });
+ //LocalMenuViewModel.PotActionStep.RemoveAt(listview1.Items.IndexOf(sourcePerson));
+ //LocalMenuViewModel.PotActionStep.Insert(listview1.Items.IndexOf(targetPerson)+1, sourcePerson);
+ //targetPerson.FryTime = listview1.Items.IndexOf(targetPerson) -1;
+ //LocalMenuViewModel.PotActionStep.Move(listview1.Items.IndexOf(sourcePerson), listview1.Items.IndexOf(targetPerson));
+
+
+ }
+
+ private void listview1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+
+ ////鼠标未按下返回
+ //if (!isDown) return;
+
+ //isDown = false;
+
+ //var pos = e.GetPosition(listview1);
+ //HitTestResult result = VisualTreeHelper.HitTest(listview1, pos);
+ //if (result == null) return;
+ //new_Item = Utils.FindVisualParent(result.VisualHit);
+ //if (mypopup != null)
+ //{
+ // mypopup.IsOpen = false;
+ // mypopup = null;
+ //}
+
+ //MoveListBoxStyle(e, false);
+
+
+ }
+
+ private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ this.DragMove();
+ }
+
+
+
+ ///
+ /// 移动效果
+ ///
+ ///
+ private void MoveListBoxStyle(MouseEventArgs e, bool isBool)
+ {
+ try
+ {
+ if (isBool)//为真,根据鼠标位置设置行透明度和显示状态
+ {
+ //移动到某行减轻某行 暗黑
+ //foreach (ListBoxItem item in Utils.FindVisualChildren(listview1))
+ //{
+ // if (item != ChildListBoxItem)//这就是其他控件
+ // {
+ // double item_width = item.ActualWidth; //当前行宽
+ // double item_height = item.ActualHeight; //当前行高
+ // double item_x = e.GetPosition(item).X; //鼠标相对当前行X位移
+ // double item_y = e.GetPosition(item).Y; //鼠标相对当前行Y位移
+
+ // if (item_y <= item_height && item_y > 0 && item_x > 0 && item_x <= item_width)//鼠标进入哪一行,则将那一行变灰
+ // {
+ // item.Opacity = 0.5;
+ // item.Background = Brushes.AliceBlue;
+ // lao_index = LocalMenuViewModel.PotActionStep.IndexOf(item.Content as PotActions);
+ // new_index = LocalMenuViewModel.PotActionStep.IndexOf(ChildListBoxItem.Content as PotActions);
+ // //LocalMenuViewModel.PotActionStep.Move(lao_index, new_index);
+ // }
+ // else //鼠标没在哪一行,则保持原状
+ // {
+ // item.Opacity = 1;
+
+ // }
+ // }
+ // else
+ // {
+ // item.Visibility = Visibility.Hidden;
+ // }
+ //}
+ }
+ else//为假 恢复所有行透明度和显示状态
+ {
+
+ //LocalMenuViewModel.PotActionStep.Move(lao_index, new_index);
+
+ //移动到某行减轻某行 暗黑
+ foreach (ListBoxItem item in Utils.FindVisualChildren(listview1))
+ {
+ item.Background = Brushes.Transparent;
+ item.Opacity = 1;
+ item.Visibility = Visibility.Visible;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+ }
+
+
+ internal static class Utils
+ {
+ //根据子元素查找父元素
+ public static T FindVisualParent(DependencyObject obj) where T : class
+ {
+ while (obj != null)
+ {
+ if (obj is T)
+ return obj as T;
+
+ obj = VisualTreeHelper.GetParent(obj);
+ }
+ return null;
+ }
+
+ ///
+ /// 查询子控件
+ ///
+ ///
+ ///
+ ///
+ public static IEnumerable FindVisualChildren(DependencyObject depObj) where T : DependencyObject
+ {
+ if (depObj != null)
+ {
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
+ {
+ DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
+ if (child != null && child is T)
+ {
+ yield return (T)child;
+ }
+
+ foreach (T childOfChild in FindVisualChildren(child))
+ {
+ yield return childOfChild;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs b/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs
index f9807ac9..e0012c74 100644
--- a/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs
+++ b/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs
@@ -27,13 +27,17 @@ namespace BPASmartClient.MorkF.ViewModel
public int DeviceId { get; set; }
#region 设备控制
+ public int FoodMenuID { get { return _foodMenuID; } set { _foodMenuID = value; OnPropertyChanged(); } }
+ private int _foodMenuID;
public RelayCommand PlcInite { get; set; }
public RelayCommand FoodPlcInite { get; set; }
public RelayCommand Plc1Reset { get; set; }
+ public RelayCommand StartOrder { get; set; }
+ public RelayCommand StartLocalOrder { get; set; }
- #endregion
+ #endregion
#region 菜品控制
public string RealX { get { return _realX; } set { _realX = value; OnPropertyChanged(); } }
@@ -168,6 +172,8 @@ namespace BPASmartClient.MorkF.ViewModel
PlcInite = new RelayCommand(() => { ActionManage.GetInstance.Send("InitCommand"); });
FoodPlcInite = new RelayCommand(() => { ActionManage.GetInstance.Send("FoodPlcInite"); });
Plc1Reset = new RelayCommand(() => { ActionManage.GetInstance.Send("Plc1Reset"); });
+ StartOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartOrder", FoodMenuID); });
+ StartLocalOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartLocalOrder"); });
#endregion
#region 菜品控制
diff --git a/BPASmartClient.MorkF/ViewModel/LocalMenuViewModel.cs b/BPASmartClient.MorkF/ViewModel/LocalMenuViewModel.cs
new file mode 100644
index 00000000..75225ebe
--- /dev/null
+++ b/BPASmartClient.MorkF/ViewModel/LocalMenuViewModel.cs
@@ -0,0 +1,99 @@
+using BPA.Models;
+using BPASmartClient.Helper;
+using BPASmartClient.MorkF.Model;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using Microsoft.Toolkit.Mvvm.Input;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.MorkF.ViewModel
+{
+
+ partial class LocalMenuViewModel:ObservableObject
+ {
+ public ObservableCollection PotActionStep { get; set; } = new ObservableCollection();
+
+
+ public ObservableCollection strPotActions { get; set; } = new ObservableCollection();
+
+
+
+ public RelayCommand