From 4e52c8df799ed0473c5a0a5582bb3560de363fbd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com>
Date: Mon, 30 May 2022 14:00:04 +0800
Subject: [PATCH 1/9] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...rkT.Lebai.JC.csproj => BPASmartClient.MorkTLebaiJC.csproj} | 0
BPASmartClient.MorkT.Lebai.JC/Class1.cs | 2 +-
...Morkt.JAKA.JC.csproj => BPASmartClient.MorkTJAKAJC.csproj} | 0
BPASmartClient.Morkt.JAKA.JC/Class1.cs | 2 +-
SmartClient.sln | 4 ++--
5 files changed, 4 insertions(+), 4 deletions(-)
rename BPASmartClient.MorkT.Lebai.JC/{BPASmartClient.MorkT.Lebai.JC.csproj => BPASmartClient.MorkTLebaiJC.csproj} (100%)
rename BPASmartClient.Morkt.JAKA.JC/{BPASmartClient.Morkt.JAKA.JC.csproj => BPASmartClient.MorkTJAKAJC.csproj} (100%)
diff --git a/BPASmartClient.MorkT.Lebai.JC/BPASmartClient.MorkT.Lebai.JC.csproj b/BPASmartClient.MorkT.Lebai.JC/BPASmartClient.MorkTLebaiJC.csproj
similarity index 100%
rename from BPASmartClient.MorkT.Lebai.JC/BPASmartClient.MorkT.Lebai.JC.csproj
rename to BPASmartClient.MorkT.Lebai.JC/BPASmartClient.MorkTLebaiJC.csproj
diff --git a/BPASmartClient.MorkT.Lebai.JC/Class1.cs b/BPASmartClient.MorkT.Lebai.JC/Class1.cs
index 8ced363c..8f78d56d 100644
--- a/BPASmartClient.MorkT.Lebai.JC/Class1.cs
+++ b/BPASmartClient.MorkT.Lebai.JC/Class1.cs
@@ -1,6 +1,6 @@
using System;
-namespace BPASmartClient.MorkT.Lebai.JC
+namespace BPASmartClient.MorkTLebaiJC
{
public class Class1
{
diff --git a/BPASmartClient.Morkt.JAKA.JC/BPASmartClient.Morkt.JAKA.JC.csproj b/BPASmartClient.Morkt.JAKA.JC/BPASmartClient.MorkTJAKAJC.csproj
similarity index 100%
rename from BPASmartClient.Morkt.JAKA.JC/BPASmartClient.Morkt.JAKA.JC.csproj
rename to BPASmartClient.Morkt.JAKA.JC/BPASmartClient.MorkTJAKAJC.csproj
diff --git a/BPASmartClient.Morkt.JAKA.JC/Class1.cs b/BPASmartClient.Morkt.JAKA.JC/Class1.cs
index ca60a540..bf85f49d 100644
--- a/BPASmartClient.Morkt.JAKA.JC/Class1.cs
+++ b/BPASmartClient.Morkt.JAKA.JC/Class1.cs
@@ -1,6 +1,6 @@
using System;
-namespace BPASmartClient.Morkt.JAKA.JC
+namespace BPASmartClient.MorktJAKAJC
{
public class Class1
{
diff --git a/SmartClient.sln b/SmartClient.sln
index 98ffd673..58907647 100644
--- a/SmartClient.sln
+++ b/SmartClient.sln
@@ -80,9 +80,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.LebaiRobot",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkM", "BPASmartClient.MorkM\BPASmartClient.MorkM.csproj", "{74DB1F85-9B73-4113-8FE4-A63754BC7DF9}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkT.Lebai.JC", "BPASmartClient.MorkT.Lebai.JC\BPASmartClient.MorkT.Lebai.JC.csproj", "{0A06C9E5-5C42-4BCE-B6E6-D8054C72255D}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkTLebaiJC", "BPASmartClient.MorkT.Lebai.JC\BPASmartClient.MorkTLebaiJC.csproj", "{0A06C9E5-5C42-4BCE-B6E6-D8054C72255D}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.Morkt.JAKA.JC", "BPASmartClient.Morkt.JAKA.JC\BPASmartClient.Morkt.JAKA.JC.csproj", "{6B0FD858-A60D-41B9-A923-358B0CE2A254}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkTJAKAJC", "BPASmartClient.Morkt.JAKA.JC\BPASmartClient.MorkTJAKAJC.csproj", "{6B0FD858-A60D-41B9-A923-358B0CE2A254}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
From 6c7db8cb88e0f0b978894d42843c58abf8429737 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com>
Date: Mon, 30 May 2022 20:34:03 +0800
Subject: [PATCH 2/9] =?UTF-8?q?=E7=85=AE=E9=9D=A2=E6=9C=BA=E9=80=BB?=
=?UTF-8?q?=E8=BE=91=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BPASmartClient.DRCoffee/CoffeeMachine.cs | 119 ++++----
BPASmartClient.Device/BaseDevice.cs | 11 +
BPASmartClient.GSIceCream/IceCreamMachine.cs | 144 ++++-----
BPASmartClient.KLMCoffee/CoffeeMachine.cs | 212 ++++++-------
BPASmartClient.Lebai/LebaiRobot.cs | 14 +-
BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs | 8 +-
BPASmartClient.MorkS/Control_Morks.cs | 55 +++-
BPASmartClient.MorkS/GVL_MORKS.cs | 8 +-
BPASmartClient.Peripheral/BasePeripheral.cs | 4 +-
BPASmartClient.Peripheral/IPeripheral.cs | 2 +
BPASmartClient.SCChip/ICChipMachine.cs | 302 ++++++++++---------
11 files changed, 474 insertions(+), 405 deletions(-)
diff --git a/BPASmartClient.DRCoffee/CoffeeMachine.cs b/BPASmartClient.DRCoffee/CoffeeMachine.cs
index e897453f..37b886dc 100644
--- a/BPASmartClient.DRCoffee/CoffeeMachine.cs
+++ b/BPASmartClient.DRCoffee/CoffeeMachine.cs
@@ -16,7 +16,7 @@ namespace BPASmartClient.DRCoffee
///
/// 咖啡机
///
- public class CoffeeMachine :BasePeripheral
+ public class CoffeeMachine : BasePeripheral
{
//通讯代理
SerialPortClient commProxy = null;
@@ -95,7 +95,7 @@ namespace BPASmartClient.DRCoffee
commProxy.SendData(cmdAsk);
}
Thread.Sleep(200);
- }),"咖啡机询问线程");
+ }), "咖啡机询问线程");
ThreadManage.GetInstance().StartLong(new Action(() =>
{
@@ -132,7 +132,7 @@ namespace BPASmartClient.DRCoffee
}
}
Thread.Sleep(5);
- }),"咖啡机解析线程");
+ }), "咖啡机解析线程");
}
///
@@ -141,7 +141,7 @@ namespace BPASmartClient.DRCoffee
///
public void ProcessPackage(DrCoffeePackage package)
{
-
+
if (((DrCoffeeStatus)status["CoffeeStatus"]) == DrCoffeeStatus.Running && package.Status != DrCoffeeStatus.Running)
{
status["CoffeeStatus"] = package.Status;
@@ -154,17 +154,17 @@ namespace BPASmartClient.DRCoffee
status["CoffeeAppStatus"] = package.ApplicationStatus;
status["CoffeeWarning"] = package.Warning;
status["CoffeeFault"] = package.Fault;
-
+
if ((DrCoffeeStatus)status["CoffeeStatus"] == DrCoffeeStatus.Warning
|| (DrCoffeeStatus)status["CoffeeStatus"] == DrCoffeeStatus.Fault
|| (DrCoffeeWarning)status["CoffeeWarning"] != DrCoffeeWarning.无警告
|| (DrCoffeeFault)status["CoffeeFault"] != DrCoffeeFault.无故障
)
{
- IsWork = false;
+ IsWork = false;
}
else
- IsWork = true;
+ IsWork = true;
}
protected override void InitStatus()
@@ -177,68 +177,71 @@ namespace BPASmartClient.DRCoffee
public override void Init()
{
- commProxy = new SerialPortClient(communicationPar.SerialPort,(BaudRates)communicationPar.BaudRate);
+ commProxy = new SerialPortClient(communicationPar.SerialPort, (BaudRates)communicationPar.BaudRate);
commProxy.SetDataStorage(dataStorage);
//咖博士咖啡机制作
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- free = true;
- Thread.Sleep(200);
- drinksOrder.CommCmd = DrCoffeeCommCmd.饮品制作指令;
- drinksOrder.DrinksCode = ((DRCoffee_MakeCoffeeEvent)@event).DrinkCode;
- commProxy.SendData(DrCoffee.Packe(drinksOrder));
- Thread.Sleep(200);
- free = false;
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
- }
- });
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ free = true;
+ Thread.Sleep(200);
+ drinksOrder.CommCmd = DrCoffeeCommCmd.饮品制作指令;
+ drinksOrder.DrinksCode = ((DRCoffee_MakeCoffeeEvent)@event).DrinkCode;
+ commProxy.SendData(DrCoffee.Packe(drinksOrder));
+ Thread.Sleep(200);
+ free = false;
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
+ }
+ });
//咖博士咖啡机取消制作咖啡
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- free = true;
- Thread.Sleep(200);
- drinksOrder.CommCmd = DrCoffeeCommCmd.取消应用指令;
- drinksOrder.DrinksCode = 0;
- commProxy.SendData(DrCoffee.Packe(drinksOrder));
- Thread.Sleep(200);
- free = false;
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
- }
- });
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ free = true;
+ Thread.Sleep(200);
+ drinksOrder.CommCmd = DrCoffeeCommCmd.取消应用指令;
+ drinksOrder.DrinksCode = 0;
+ commProxy.SendData(DrCoffee.Packe(drinksOrder));
+ Thread.Sleep(200);
+ free = false;
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
+ }
+ });
//咖博士咖啡机模式设置
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- free = true;
- Thread.Sleep(200);
- drinksOrder.CommCmd = ((DRCoffee_CoffeeCommCmdEvent)@event).CommCmd;
- commProxy.SendData(DrCoffee.Packe(drinksOrder));
- Thread.Sleep(200);
- free = false;
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
- }
- });
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ free = true;
+ Thread.Sleep(200);
+ drinksOrder.CommCmd = ((DRCoffee_CoffeeCommCmdEvent)@event).CommCmd;
+ commProxy.SendData(DrCoffee.Packe(drinksOrder));
+ Thread.Sleep(200);
+ free = false;
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
+ }
+ });
InitStatus();
//测试
Start();
}
+ public override void WriteData(string address, object value)
+ {
+ }
}
}
diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs
index cb873488..c511c86f 100644
--- a/BPASmartClient.Device/BaseDevice.cs
+++ b/BPASmartClient.Device/BaseDevice.cs
@@ -110,6 +110,17 @@ namespace BPASmartClient.Device
#endregion
+ public void WriteControl(string address, object value)
+ {
+ if (peripherals != null)
+ {
+ for (int i = 0; i < peripherals.Count; i++)
+ {
+ peripherals.ElementAt(i).WriteData(address, value);
+ }
+ }
+ }
+
///
/// 设备过程日志显示
///
diff --git a/BPASmartClient.GSIceCream/IceCreamMachine.cs b/BPASmartClient.GSIceCream/IceCreamMachine.cs
index 93b661f3..0005faff 100644
--- a/BPASmartClient.GSIceCream/IceCreamMachine.cs
+++ b/BPASmartClient.GSIceCream/IceCreamMachine.cs
@@ -14,8 +14,8 @@ using static BPASmartClient.GSIceCream.MessageDefine;
namespace BPASmartClient.GSIceCream
{
- public class IceCreamMachine :BasePeripheral
- {
+ public class IceCreamMachine : BasePeripheral
+ {
//通讯代理
SerialPortClient commProxy = null;
//是否下发指令,主线程等待
@@ -179,13 +179,13 @@ namespace BPASmartClient.GSIceCream
IsConnected = OnLine;
status["IceCreamIsConnected"] = OnLine;
status["IceCreamCurrentMode"] = heartUpMsg.MS;
- status["IceCreamYLWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.YLWD_L,heartUpMsg.YLWD_H },0);
- status["IceCreamHQWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HQWD_L,heartUpMsg.HQWD_H },0);
- status["IceCreamHJWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HJWD_L,heartUpMsg.HJWD_H },0);
+ status["IceCreamYLWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.YLWD_L, heartUpMsg.YLWD_H }, 0);
+ status["IceCreamHQWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HQWD_L, heartUpMsg.HQWD_H }, 0);
+ status["IceCreamHJWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HJWD_L, heartUpMsg.HJWD_H }, 0);
status["IceCreamDL"] = BitConverter.ToInt16(new byte[] { heartUpMsg.DL_L, heartUpMsg.DL_H }, 0);
- status["IceCreamFault"] = (MORKI_FAULT)BitConverter.ToInt16(new byte[] { heartUpMsg.GZ_L,heartUpMsg.GZ_H },0);
+ status["IceCreamFault"] = (MORKI_FAULT)BitConverter.ToInt16(new byte[] { heartUpMsg.GZ_L, heartUpMsg.GZ_H }, 0);
status["IceCreamCXB"] = heartUpMsg.CXB;
- status["IceCreamDLCompleted"] = (heartUpMsg.DLTJ >> 4 & 1) == 1;
+ status["IceCreamDLCompleted"] = (heartUpMsg.DLTJ >> 4 & 1) == 1;
if (RTrig.GetInstance("打料完成检测").Start((bool)status["IceCreamDLCompleted"]))
{
@@ -201,7 +201,7 @@ namespace BPASmartClient.GSIceCream
private void ProcessModeUp(ICMSG_MODE_UP modeUpMsg)
{
- MessageLog.GetInstance.Show(string.Format("模式返回为:{0}",modeUpMsg.Mode));
+ MessageLog.GetInstance.Show(string.Format("模式返回为:{0}", modeUpMsg.Mode));
}
public void ProcessMsg(byte[] data)
@@ -269,79 +269,83 @@ namespace BPASmartClient.GSIceCream
});
//广深冰淇淋机打料
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- if ((MORKI_FAULT)status["IceCreamFault"] != MORKI_FAULT.未发生故障)
- {
- MessageLog.GetInstance.Show(string.Format("当前存在故障[{0}%],不允许制作",(MORKI_FAULT)status["IceCreamFault"]));
- new GSIceCream_EndCookEvent() { DeviceId = DeviceId,Status = false }.Publish();
- callBack?.Invoke(false);
- return;
- }
- if ((byte)status["IceCreamCXB"] <= 86)
- {
- MessageLog.GetInstance.Show(string.Format("当前成型比[{0}%],低于86%,不允许制作",(byte)status["IceCreamCXB"]));
- new GSIceCream_EndCookEvent() { DeviceId = DeviceId,Status = false }.Publish();
- callBack?.Invoke(false );
- return;
- }
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ if ((MORKI_FAULT)status["IceCreamFault"] != MORKI_FAULT.未发生故障)
+ {
+ MessageLog.GetInstance.Show(string.Format("当前存在故障[{0}%],不允许制作", (MORKI_FAULT)status["IceCreamFault"]));
+ new GSIceCream_EndCookEvent() { DeviceId = DeviceId, Status = false }.Publish();
+ callBack?.Invoke(false);
+ return;
+ }
+ if ((byte)status["IceCreamCXB"] <= 86)
+ {
+ MessageLog.GetInstance.Show(string.Format("当前成型比[{0}%],低于86%,不允许制作", (byte)status["IceCreamCXB"]));
+ new GSIceCream_EndCookEvent() { DeviceId = DeviceId, Status = false }.Publish();
+ callBack?.Invoke(false);
+ return;
+ }
- bool modeRight = (MORKI_MODE)status["IceCreamCurrentMode"] == MORKI_MODE.制冷模式;
+ bool modeRight = (MORKI_MODE)status["IceCreamCurrentMode"] == MORKI_MODE.制冷模式;
- if (!modeRight)
- {
- free = true;
- Thread.Sleep(200);
+ if (!modeRight)
+ {
+ free = true;
+ Thread.Sleep(200);
- var temp = IcPack.StructureToByte(ICMSG_MODE_DW.Build(MORKI_MODE.制冷模式));
- commProxy.SendData(temp);
+ var temp = IcPack.StructureToByte(ICMSG_MODE_DW.Build(MORKI_MODE.制冷模式));
+ commProxy.SendData(temp);
- Thread.Sleep(200);
- free = false;
- MessageLog.GetInstance.Show(string.Format("出料操作->设置模式[{0}]",MORKI_MODE.制冷模式));
+ Thread.Sleep(200);
+ free = false;
+ MessageLog.GetInstance.Show(string.Format("出料操作->设置模式[{0}]", MORKI_MODE.制冷模式));
- DateTime freeTime = DateTime.Now.AddSeconds(5);
- while (DateTime.Now < freeTime)
- {
- Thread.Sleep(10);
- modeRight = (MORKI_MODE)status["IceCreamCurrentMode"] == MORKI_MODE.制冷模式;
- if (modeRight)
- break;
- }
- }
+ DateTime freeTime = DateTime.Now.AddSeconds(5);
+ while (DateTime.Now < freeTime)
+ {
+ Thread.Sleep(10);
+ modeRight = (MORKI_MODE)status["IceCreamCurrentMode"] == MORKI_MODE.制冷模式;
+ if (modeRight)
+ break;
+ }
+ }
- if (modeRight)
- {
- free = true;
- Thread.Sleep(200);
- var data = IcPack.StructureToByte(ICMSG_MODE_DW.Build(MORKI_MODE.打料));
- commProxy.SendData(data);
- Thread.Sleep(200);
- free = false;
- new GSIceCream_EndCookEvent() { DeviceId = DeviceId,Status =true}.Publish();
- MessageLog.GetInstance.Show(string.Format("出料操作->设置模式[{0}]",MORKI_MODE.打料));
- callBack?.Invoke(true);
- }
- else
- {
- MessageLog.GetInstance.Show(string.Format("出料操作->模式切换失败,当前模式[{0}],不允许出料",(MORKI_MODE)status["IceCreamCurrentMode"]));
- new GSIceCream_EndCookEvent() { DeviceId = DeviceId,Status = false }.Publish();
- callBack?.Invoke(false);
- }
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.GSIceCream 中引发错误,IceCreamMachine 类,描述:[{ex.Message}]");
- callBack?.Invoke(false);
- }
- });
+ if (modeRight)
+ {
+ free = true;
+ Thread.Sleep(200);
+ var data = IcPack.StructureToByte(ICMSG_MODE_DW.Build(MORKI_MODE.打料));
+ commProxy.SendData(data);
+ Thread.Sleep(200);
+ free = false;
+ new GSIceCream_EndCookEvent() { DeviceId = DeviceId, Status = true }.Publish();
+ MessageLog.GetInstance.Show(string.Format("出料操作->设置模式[{0}]", MORKI_MODE.打料));
+ callBack?.Invoke(true);
+ }
+ else
+ {
+ MessageLog.GetInstance.Show(string.Format("出料操作->模式切换失败,当前模式[{0}],不允许出料", (MORKI_MODE)status["IceCreamCurrentMode"]));
+ new GSIceCream_EndCookEvent() { DeviceId = DeviceId, Status = false }.Publish();
+ callBack?.Invoke(false);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.GSIceCream 中引发错误,IceCreamMachine 类,描述:[{ex.Message}]");
+ callBack?.Invoke(false);
+ }
+ });
InitStatus();
//测试用
Start();
MessageLog.GetInstance.Show("冰淇淋机器初始化完成");
}
+
+ public override void WriteData(string address, object value)
+ {
+ }
}
}
diff --git a/BPASmartClient.KLMCoffee/CoffeeMachine.cs b/BPASmartClient.KLMCoffee/CoffeeMachine.cs
index 0b803647..ae5519cf 100644
--- a/BPASmartClient.KLMCoffee/CoffeeMachine.cs
+++ b/BPASmartClient.KLMCoffee/CoffeeMachine.cs
@@ -19,7 +19,7 @@ namespace BPASmartClient.KLMCoffee
///
/// 伽乐美咖啡机
///
- public class CoffeeMachine :BasePeripheral
+ public class CoffeeMachine : BasePeripheral
{
//通讯代理
SerialPortClient commProxy = null;
@@ -92,12 +92,12 @@ namespace BPASmartClient.KLMCoffee
commProxy.SendData(cmdAsk);
}
Thread.Sleep(200);
- }),"咖啡机询问线程");
+ }), "咖啡机询问线程");
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ResolveMsg();
- }),"咖啡机解析线程");
+ }), "咖啡机解析线程");
}
private void ResolveMsg()
@@ -117,7 +117,7 @@ namespace BPASmartClient.KLMCoffee
{
temp.Add(dataStorage.GetData());
}
- List vs = new List() { temp[temp.Count - 4],temp[temp.Count - 3],temp[temp.Count - 2],temp[temp.Count - 1] };
+ List vs = new List() { temp[temp.Count - 4], temp[temp.Count - 3], temp[temp.Count - 2], temp[temp.Count - 1] };
//帧尾
if (Encoding.ASCII.GetString(vs.ToArray()).ToLower() == "\\r\\n" || Encoding.ASCII.GetString(vs.ToArray()).ToLower() == "\r\n")
@@ -146,9 +146,9 @@ namespace BPASmartClient.KLMCoffee
status["Warning"] = systemStatus.faultMessage.dataFault();
status["Keep"] = systemStatus.upkeepMessage;
if (systemStatus.faultMessage.IsFault() || systemStatus.upkeepMessage.IsUpkeep())
- IsWork=false;
+ IsWork = false;
else
- IsWork=true;
+ IsWork = true;
}
}
@@ -164,128 +164,130 @@ namespace BPASmartClient.KLMCoffee
status["drinkType"] = DrinkType.意式;
status["AppStatus"] = TaskIndex.无任务;
status["progress"] = 0;
- status["Warning"] = new FaultMessage(0x00,0x00).dataFault();
+ status["Warning"] = new FaultMessage(0x00, 0x00).dataFault();
status["Keep"] = new UpkeepMessage(0x00).dataFault();
}
public override void Init()
{
- commProxy = new SerialPortClient(PortName,(BaudRates)Enum.Parse(typeof(BaudRates),BaudRate));
+ commProxy = new SerialPortClient(PortName, (BaudRates)Enum.Parse(typeof(BaudRates), BaudRate));
commProxy.SetDataStorage(dataStorage);
//伽乐美咖啡机制作
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- free = true;
- Thread.Sleep(200);
- byte[] data=command.ReturnsCommandData(K95CommandEnum.配方咖啡制作.GetString(),new RecipeModel().Packe(((KLMCoffee_MakeCoffeeEvent)@event).DrinkCode));
- commProxy.SendData(data);
- Thread.Sleep(200);
- free = false;
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
- }
- });
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ free = true;
+ Thread.Sleep(200);
+ byte[] data = command.ReturnsCommandData(K95CommandEnum.配方咖啡制作.GetString(), new RecipeModel().Packe(((KLMCoffee_MakeCoffeeEvent)@event).DrinkCode));
+ commProxy.SendData(data);
+ Thread.Sleep(200);
+ free = false;
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
+ }
+ });
//伽乐美咖啡机取消制作咖啡
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- free = true;
- Thread.Sleep(200);
- byte[] data = command.ReturnsCancelMake();
- commProxy.SendData(data);
- Thread.Sleep(200);
- free = false;
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
- }
- });
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ free = true;
+ Thread.Sleep(200);
+ byte[] data = command.ReturnsCancelMake();
+ commProxy.SendData(data);
+ Thread.Sleep(200);
+ free = false;
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
+ }
+ });
//伽乐美咖啡机清洗冲泡器
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- free = true;
- Thread.Sleep(200);
- byte[] data = command.ReturnsWashCPJ();
- commProxy.SendData(data);
- Thread.Sleep(200);
- free = false;
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
- }
- });
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ free = true;
+ Thread.Sleep(200);
+ byte[] data = command.ReturnsWashCPJ();
+ commProxy.SendData(data);
+ Thread.Sleep(200);
+ free = false;
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
+ }
+ });
//伽乐美咖啡机放杯确认
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- free = true;
- Thread.Sleep(200);
- byte[] data = command.ReturnsCupIsOK();
- commProxy.SendData(data);
- Thread.Sleep(200);
- free = false;
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
- }
- });
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ free = true;
+ Thread.Sleep(200);
+ byte[] data = command.ReturnsCupIsOK();
+ commProxy.SendData(data);
+ Thread.Sleep(200);
+ free = false;
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
+ }
+ });
//伽乐美咖啡机清洗奶沫器
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- free = true;
- Thread.Sleep(200);
- byte[] data = command.ReturnsWashNMJ();
- commProxy.SendData(data);
- Thread.Sleep(200);
- free = false;
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
- }
- });
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ free = true;
+ Thread.Sleep(200);
+ byte[] data = command.ReturnsWashNMJ();
+ commProxy.SendData(data);
+ Thread.Sleep(200);
+ free = false;
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
+ }
+ });
//伽乐美咖啡机清洗奶沫器确认
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- free = true;
- Thread.Sleep(200);
- byte[] data = command.ReturnsWashNMJIsOK();
- commProxy.SendData(data);
- Thread.Sleep(200);
- free = false;
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
- }
- });
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ free = true;
+ Thread.Sleep(200);
+ byte[] data = command.ReturnsWashNMJIsOK();
+ commProxy.SendData(data);
+ Thread.Sleep(200);
+ free = false;
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
+ }
+ });
InitStatus();
}
-
+ public override void WriteData(string address, object value)
+ {
+ }
}
}
diff --git a/BPASmartClient.Lebai/LebaiRobot.cs b/BPASmartClient.Lebai/LebaiRobot.cs
index 721cc893..07a7ced0 100644
--- a/BPASmartClient.Lebai/LebaiRobot.cs
+++ b/BPASmartClient.Lebai/LebaiRobot.cs
@@ -19,7 +19,7 @@ using BPASmartClient.Model.乐白机器人;
namespace BPASmartClient.Lebai
{
- public class LebaiRobot: BasePeripheral
+ public class LebaiRobot : BasePeripheral
{
///
@@ -51,7 +51,7 @@ namespace BPASmartClient.Lebai
if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] = LebaiHelper.GetInstance().robotData.RobotMode.Mode;
LebaiHelper.GetInstance().GetRobotModeStatus();
Thread.Sleep(10);
- },"获取乐白机器人数据");
+ }, "获取乐白机器人数据");
}
@@ -62,7 +62,7 @@ namespace BPASmartClient.Lebai
public override void Init()
{
- EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack )
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
});
@@ -90,7 +90,7 @@ namespace BPASmartClient.Lebai
if (@event == null) return;
if (@event is LebaiRobot_SetValueEvent SetValueEvent)
{
- LebaiHelper.GetInstance().SetValue(SetValueEvent.RobotSetValue);
+ LebaiHelper.GetInstance().SetValue(SetValueEvent.RobotSetValue);
}
});
//控制机器人
@@ -116,7 +116,7 @@ namespace BPASmartClient.Lebai
default:
break;
}
-
+
}
});
//选择机器人场景
@@ -134,6 +134,8 @@ namespace BPASmartClient.Lebai
MessageLog.GetInstance.Show("乐白机器人初始化完成");
}
-
+ public override void WriteData(string address, object value)
+ {
+ }
}
}
diff --git a/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs b/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs
index b7b11c7f..3551f1ff 100644
--- a/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs
+++ b/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs
@@ -48,7 +48,7 @@ namespace BPASmartClient.PLC
{
if (@event == null) return;
var par = @event as WriteModel;
-
+ //M32.7地址复位
modbusTcp.Write(par?.Address, par?.Value);
});
}
@@ -63,6 +63,12 @@ namespace BPASmartClient.PLC
}
+ public override void WriteData(string address, object value)
+ {
+ if (address != null && value != null)
+ modbusTcp.Write(address, value);
+ }
+
protected override void InitStatus()
{
diff --git a/BPASmartClient.MorkS/Control_Morks.cs b/BPASmartClient.MorkS/Control_Morks.cs
index 8ebe8c34..d2ba57aa 100644
--- a/BPASmartClient.MorkS/Control_Morks.cs
+++ b/BPASmartClient.MorkS/Control_Morks.cs
@@ -17,6 +17,7 @@ using System.Reflection;
using BPASmartClient.MorkS.Model;
using System.Collections.ObjectModel;
using BPASmartClient.MorkS.ViewModel;
+using BPASmartClient.Business;
namespace BPASmartClient.MorkS
{
@@ -287,8 +288,6 @@ namespace BPASmartClient.MorkS
else
IsHealth = true;
- //if (mORKS.AllowRun)
- //{
TakeBowlTask();
TakeNoodleTask();
@@ -298,7 +297,15 @@ namespace BPASmartClient.MorkS
SingleDetect();
TurntableControl();
- //}
+
+ var data = new List();
+ for (int i = 0; i < Json.Data.parSets.Count; i++)
+ {
+ data.Add(Json.Data.parSets.ElementAt(i).IsShield);
+ }
+
+ WriteControl("M260.0", data.ToArray());
+
}
private void BowlControl(OrderLocInfo orderLocInfo)
@@ -400,6 +407,11 @@ namespace BPASmartClient.MorkS
{
if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc))
{
+ if (!mORKS.TurntableLowerLimit)
+ {
+ WriteData("M32.7", false);
+ DeviceProcessLogShow($"执行了转台启动互锁信号复位");
+ }
TurntableStart(loc);
DeviceProcessLogShow($"没有物料检测的启动转台控制,转台位置:[{loc}]");
break;
@@ -414,6 +426,15 @@ namespace BPASmartClient.MorkS
}
}
+ //if (DelayRTrig.GetInstance("互锁信号复位").Start(!mORKS.TurntableLowerLimit && mORKS.TurntableMoveInPlace, 2))
+ //{
+ // if (!mORKS.TurntableLowerLimit)
+ // {
+ // WriteData("M32.7", false);
+ // DeviceProcessLogShow($"执行了转台启动互锁信号复位");
+ // }
+ //}
+
//补料中检测
if (RTrig.GetInstance("mORKS.Feeding").Start(mORKS.Feeding))
{
@@ -488,6 +509,17 @@ namespace BPASmartClient.MorkS
RobotOutMeal();
CookNoodleStatusReset((ushort)(loc + 1));
ResetAllowFallNoodle();
+
+
+ //新增,待测试
+ //if (mORKS.RbOutMealComplete)
+ //{
+ // ResetCookComplete();
+ // mORKS.CookCompleteFlatBit = false;
+ // DeviceProcessLogShow("取餐过程中复位出餐完成信号");
+ //}
+
+
mORKS.OutMealId = mORKS.IngredientsCompleteId;
mORKS.IngredientsCompleteId = string.Empty;
mORKS.CookNodelId[loc] = string.Empty;
@@ -522,7 +554,7 @@ namespace BPASmartClient.MorkS
}
//取餐完成逻辑处理
- if (Delay.GetInstance("CompleteChange1").Start(mORKS.CookCompleteFlatBit && !mORKS.TakeMealDetect, 2))
+ if (Delay.GetInstance("CompleteChange1").Start(mORKS.CookCompleteFlatBit && !mORKS.TakeMealDetect, 1))
{
OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE);
DeviceProcessLogShow($"订单【{mORKS.OutMealId}】取餐完成");
@@ -531,15 +563,6 @@ namespace BPASmartClient.MorkS
mORKS.OutMealId = string.Empty;
}
- //if (DelayRTrig.GetInstance("CompleteChange1").Start(mORKS.CookCompleteFlatBit && !mORKS.TakeMealDetect, 2))
- //{
- // OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE);
- // DeviceProcessLogShow($"订单【{mORKS.OutMealId}】取餐完成");
- // ResetCookComplete();
- // mORKS.CookCompleteFlatBit = false;
- // mORKS.OutMealId = string.Empty;
- //}
-
//机器人取面完成信号检测
if (RTrig.GetInstance("TakeNoodleComplete").Start(mORKS.RbTakeNoodleComplete))
{
@@ -552,7 +575,11 @@ namespace BPASmartClient.MorkS
int OutMealRequstCount = mORKS.CookNoodlesComplete.Where(p => p == true).ToList().Count;
int mlCount = mORKS.NoodleCookerStatus.Where(p => p == true).ToList().Count;
- mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0);
+
+ mORKS.PriorityJudgment = Delay.GetInstance("取餐优先级判断").Start(mORKS.TurntableLocLists.Count > 0 && !mORKS.TurntableLowerLimit, 4);
+ mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment);
+
+
}
diff --git a/BPASmartClient.MorkS/GVL_MORKS.cs b/BPASmartClient.MorkS/GVL_MORKS.cs
index bc1c6a73..35702f06 100644
--- a/BPASmartClient.MorkS/GVL_MORKS.cs
+++ b/BPASmartClient.MorkS/GVL_MORKS.cs
@@ -42,7 +42,13 @@ namespace BPASmartClient.MorkS
public bool AllowRun { get; set; }
///
- /// //机器人任务互锁信号
+ /// 优先级判断
+ ///
+ [VariableMonitor("优先级判断条件")]
+ public bool PriorityJudgment { get; set; }
+
+ ///
+ /// 机器人任务互锁信号,false:取面,true:出餐
///
//[Circuit(new string[] { "机器人取面", "出面控制" }, "机器人互锁", new bool[] { true, false })]
[VariableMonitor("机器人任务互锁信号")]
diff --git a/BPASmartClient.Peripheral/BasePeripheral.cs b/BPASmartClient.Peripheral/BasePeripheral.cs
index c4631550..96664eb5 100644
--- a/BPASmartClient.Peripheral/BasePeripheral.cs
+++ b/BPASmartClient.Peripheral/BasePeripheral.cs
@@ -47,16 +47,18 @@ namespace BPASmartClient.Peripheral
return null;
}
-
public abstract void Start();
public abstract void Stop();
public abstract void Init();
+ public abstract void WriteData(string address, object value);
+
public ConcurrentDictionary GetAllStatus()
{
return status;
}
+
}
}
diff --git a/BPASmartClient.Peripheral/IPeripheral.cs b/BPASmartClient.Peripheral/IPeripheral.cs
index ed05864a..7aaa611c 100644
--- a/BPASmartClient.Peripheral/IPeripheral.cs
+++ b/BPASmartClient.Peripheral/IPeripheral.cs
@@ -53,6 +53,8 @@ namespace BPASmartClient.Peripheral
///
ConcurrentDictionary status { get; set; }
+ void WriteData(string address, object value);
+
///
/// 初始化
///
diff --git a/BPASmartClient.SCChip/ICChipMachine.cs b/BPASmartClient.SCChip/ICChipMachine.cs
index 58dc54b6..c26f158a 100644
--- a/BPASmartClient.SCChip/ICChipMachine.cs
+++ b/BPASmartClient.SCChip/ICChipMachine.cs
@@ -14,7 +14,7 @@ using static BPASmartClient.EventBus.EventBus;
namespace BPASmartClient.SCChip
{
- public class ICChipMachine :BasePeripheral
+ public class ICChipMachine : BasePeripheral
{
//通讯代理
SerialPortClient commProxy = null;
@@ -80,7 +80,7 @@ namespace BPASmartClient.SCChip
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ResolveMsg();
- }),"单片机解析线程");
+ }), "单片机解析线程");
}
private void ResolveMsg()
@@ -120,8 +120,8 @@ namespace BPASmartClient.SCChip
IntPtr allocIntPtr = Marshal.AllocHGlobal(size);
try
{
- Marshal.Copy(dataBuffer,0,allocIntPtr,size);
- structure = (ICChipPackage)Marshal.PtrToStructure(allocIntPtr,typeof(ICChipPackage));
+ Marshal.Copy(dataBuffer, 0, allocIntPtr, size);
+ structure = (ICChipPackage)Marshal.PtrToStructure(allocIntPtr, typeof(ICChipPackage));
}
finally
{
@@ -141,8 +141,8 @@ namespace BPASmartClient.SCChip
IntPtr bufferIntPtr = Marshal.AllocHGlobal(size);
try
{
- Marshal.StructureToPtr(structure,bufferIntPtr,true);
- Marshal.Copy(bufferIntPtr,buffer,0,size);
+ Marshal.StructureToPtr(structure, bufferIntPtr, true);
+ Marshal.Copy(bufferIntPtr, buffer, 0, size);
}
finally
{
@@ -201,8 +201,8 @@ namespace BPASmartClient.SCChip
}
break;
}
- if(!OnLine) IsWork = false;
- else IsWork = true;
+ if (!OnLine) IsWork = false;
+ else IsWork = true;
}
catch (Exception ex)
{
@@ -224,163 +224,167 @@ namespace BPASmartClient.SCChip
public override void Init()
{
- commProxy = new SerialPortClient(communicationPar.SerialPort,(BaudRates)communicationPar.BaudRate);
+ commProxy = new SerialPortClient(communicationPar.SerialPort, (BaudRates)communicationPar.BaudRate);
commProxy.SetDataStorage(dataStorage);
//STM32F103RCT6单片机下杯
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- switch ((@event as SCChip_TakeCupEvent).Cup)
- {
- case IC_CUP.CUP_ICECREAM:
- status["CompletedTake_CPU_CUP_ICECREAM"] = false;
- break;
- case IC_CUP.CUP_COFFEE:
- status["CompletedTake_CPU_CUP_COFFEE"] = false;
- break;
- }
- package.Cmd = IC_CMD.TAKE_CUP;
- package.Value = (byte)(@event as SCChip_TakeCupEvent).Cup;
- commProxy.SendData(StructureToByte(package));
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ switch ((@event as SCChip_TakeCupEvent).Cup)
+ {
+ case IC_CUP.CUP_ICECREAM:
+ status["CompletedTake_CPU_CUP_ICECREAM"] = false;
+ break;
+ case IC_CUP.CUP_COFFEE:
+ status["CompletedTake_CPU_CUP_COFFEE"] = false;
+ break;
+ }
+ package.Cmd = IC_CMD.TAKE_CUP;
+ package.Value = (byte)(@event as SCChip_TakeCupEvent).Cup;
+ commProxy.SendData(StructureToByte(package));
- bool wait = true;
- var waitTimeout = DateTime.Now.AddSeconds(3);
- while (wait)
- {
- wait = DateTime.Now < waitTimeout;
- if (wait)
- {
- switch ((@event as SCChip_TakeCupEvent).Cup)
- {
- case IC_CUP.CUP_ICECREAM:
- wait = !(bool)status["CompletedTake_CPU_CUP_ICECREAM"];
- break;
- case IC_CUP.CUP_COFFEE:
- wait = !(bool)status["CompletedTake_CPU_CUP_COFFEE"];
- break;
- }
- }
- Thread.Sleep(10);
- }
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]");
- }
- });
+ bool wait = true;
+ var waitTimeout = DateTime.Now.AddSeconds(3);
+ while (wait)
+ {
+ wait = DateTime.Now < waitTimeout;
+ if (wait)
+ {
+ switch ((@event as SCChip_TakeCupEvent).Cup)
+ {
+ case IC_CUP.CUP_ICECREAM:
+ wait = !(bool)status["CompletedTake_CPU_CUP_ICECREAM"];
+ break;
+ case IC_CUP.CUP_COFFEE:
+ wait = !(bool)status["CompletedTake_CPU_CUP_COFFEE"];
+ break;
+ }
+ }
+ Thread.Sleep(10);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]");
+ }
+ });
//STM32F103RCT6单片机舵机打料
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
- {
- case IC_SE.SE_1:
- status["CompletedOpen_SE_1"] = false;
- break;
- case IC_SE.SE_2:
- status["CompletedOpen_SE_2"] = false;
- break;
- case IC_SE.SE_3:
- status["CompletedOpen_SE_3"] = false;
- break;
- }
- package.Cmd = IC_CMD.OPEN_SE;
- package.Value = (byte)(@event as SCChip_MakeIceCreamEvent).SteeringEngine;
- commProxy.SendData(StructureToByte(package));
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
+ {
+ case IC_SE.SE_1:
+ status["CompletedOpen_SE_1"] = false;
+ break;
+ case IC_SE.SE_2:
+ status["CompletedOpen_SE_2"] = false;
+ break;
+ case IC_SE.SE_3:
+ status["CompletedOpen_SE_3"] = false;
+ break;
+ }
+ package.Cmd = IC_CMD.OPEN_SE;
+ package.Value = (byte)(@event as SCChip_MakeIceCreamEvent).SteeringEngine;
+ commProxy.SendData(StructureToByte(package));
- bool wait = true;
- DateTime waitTimeout = DateTime.Now.AddSeconds(3);
- while (wait)
- {
- wait = DateTime.Now < waitTimeout;
- if (wait)
- {
- switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
- {
- case IC_SE.SE_1:
- wait = !(bool)status["CompletedOpen_SE_1"];
- break;
- case IC_SE.SE_2:
- wait = !(bool)status["CompletedOpen_SE_2"];
- break;
- case IC_SE.SE_3:
- wait = !(bool)status["CompletedOpen_SE_3"];
- break;
- }
- }
- Thread.Sleep(10);
- }
- Thread.Sleep(2000);
- package.Cmd = IC_CMD.CLOSE_SE;
- package.Value = (byte)(@event as SCChip_MakeIceCreamEvent).SteeringEngine;
- commProxy.SendData(StructureToByte(package));
+ bool wait = true;
+ DateTime waitTimeout = DateTime.Now.AddSeconds(3);
+ while (wait)
+ {
+ wait = DateTime.Now < waitTimeout;
+ if (wait)
+ {
+ switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
+ {
+ case IC_SE.SE_1:
+ wait = !(bool)status["CompletedOpen_SE_1"];
+ break;
+ case IC_SE.SE_2:
+ wait = !(bool)status["CompletedOpen_SE_2"];
+ break;
+ case IC_SE.SE_3:
+ wait = !(bool)status["CompletedOpen_SE_3"];
+ break;
+ }
+ }
+ Thread.Sleep(10);
+ }
+ Thread.Sleep(2000);
+ package.Cmd = IC_CMD.CLOSE_SE;
+ package.Value = (byte)(@event as SCChip_MakeIceCreamEvent).SteeringEngine;
+ commProxy.SendData(StructureToByte(package));
- wait = true;
- waitTimeout = DateTime.Now.AddSeconds(3);
- while (wait)
- {
- wait = DateTime.Now < waitTimeout;
- if (wait)
- {
- switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
- {
- case IC_SE.SE_1:
- wait = !(bool)status["CompletedClose_SE_1"];
- break;
- case IC_SE.SE_2:
- wait = !(bool)status["CompletedClose_SE_2"];
- break;
- case IC_SE.SE_3:
- wait = !(bool)status["CompletedClose_SE_3"];
- break;
- }
- }
- Thread.Sleep(10);
- }
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]");
- }
- });
+ wait = true;
+ waitTimeout = DateTime.Now.AddSeconds(3);
+ while (wait)
+ {
+ wait = DateTime.Now < waitTimeout;
+ if (wait)
+ {
+ switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
+ {
+ case IC_SE.SE_1:
+ wait = !(bool)status["CompletedClose_SE_1"];
+ break;
+ case IC_SE.SE_2:
+ wait = !(bool)status["CompletedClose_SE_2"];
+ break;
+ case IC_SE.SE_3:
+ wait = !(bool)status["CompletedClose_SE_3"];
+ break;
+ }
+ }
+ Thread.Sleep(10);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]");
+ }
+ });
//STM32F103RCT6单片机舵机打开或者关闭
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- package.Cmd = (@event as SCChip_SESwitchCreamEvent).IsOpen ? IC_CMD.OPEN_SE : IC_CMD.CLOSE_SE;
- package.Value = (byte)(@event as SCChip_SESwitchCreamEvent).SteeringEngine;
- commProxy.SendData(StructureToByte(package));
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]");
- }
- });
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ package.Cmd = (@event as SCChip_SESwitchCreamEvent).IsOpen ? IC_CMD.OPEN_SE : IC_CMD.CLOSE_SE;
+ package.Value = (byte)(@event as SCChip_SESwitchCreamEvent).SteeringEngine;
+ commProxy.SendData(StructureToByte(package));
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]");
+ }
+ });
//STM32F103RCT6单片机控制冰淇淋机器转
- EventBus.EventBus.GetInstance().Subscribe(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
- {
- try
- {
- package.Cmd = IC_CMD.ROTOR;
- package.Value = (@event as SCChip_RotorSwitchEvent).TurnOn ? (byte)IC_ROTOR.OPEN_ROTOR : (byte)IC_ROTOR.CLOSE_ROTOR;
- commProxy.SendData(StructureToByte(package));
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]");
- }
- });
+ EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
+ {
+ try
+ {
+ package.Cmd = IC_CMD.ROTOR;
+ package.Value = (@event as SCChip_RotorSwitchEvent).TurnOn ? (byte)IC_ROTOR.OPEN_ROTOR : (byte)IC_ROTOR.CLOSE_ROTOR;
+ commProxy.SendData(StructureToByte(package));
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]");
+ }
+ });
InitStatus();
//测试
Start();
}
+
+ public override void WriteData(string address, object value)
+ {
+ }
}
}
From dbcddb07ec210b80c1b4518f03aac6ceb49645ad Mon Sep 17 00:00:00 2001
From: fyf
Date: Tue, 31 May 2022 11:30:42 +0800
Subject: [PATCH 3/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BPASmartClient.IoT/DataVClient.cs | 15 +++++++++++++--
BPASmartClient/Control/DataVView.xaml | 14 ++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/BPASmartClient.IoT/DataVClient.cs b/BPASmartClient.IoT/DataVClient.cs
index c4ca8862..d1528331 100644
--- a/BPASmartClient.IoT/DataVClient.cs
+++ b/BPASmartClient.IoT/DataVClient.cs
@@ -42,7 +42,7 @@ namespace BPASmartClient.IoT
DeviceSecret = System.Configuration.ConfigurationManager.AppSettings["DeviceSecret"].ToString();
StartupMode = System.Configuration.ConfigurationManager.AppSettings["StartupMode"].ToString();
BroadcastPubTopic = InternetInfo.BroadcastPubTopic;
-
+
//MaintainTable maintainTable = new MaintainTable();
//maintainTable.Id = Guid.NewGuid().ToString();
@@ -71,6 +71,7 @@ namespace BPASmartClient.IoT
/// 客户端ID
///
public string ClientId { set; get; }
+ public List ListDeviceId { set; get; } = new List();
///
/// MQTT上报集合
///
@@ -200,7 +201,17 @@ namespace BPASmartClient.IoT
string message = string.Empty;
if (StartupMode == "API")
{
- if (DeviceDataV.Initialize(DataVApiAddress, ClientId, "", ref message))
+ while (ListDeviceId.Count == 0)
+ {
+ Plugin.GetInstance()?.GetPlugin()?.GetDevices()?.ForEach(device =>
+ {
+ if (device != null)
+ {
+ ListDeviceId.Add(device.DeviceId);
+ }
+ });
+ }
+ if (DeviceDataV.Initialize(DataVApiAddress, ClientId, ListDeviceId.Count==0?"": ListDeviceId?.First().ToString(), ref message))
{
ProductKey = DeviceDataV.deviceTable.productkey;
DeviceName = DeviceDataV.deviceTable.devicename;
diff --git a/BPASmartClient/Control/DataVView.xaml b/BPASmartClient/Control/DataVView.xaml
index e5667a76..4080bcbf 100644
--- a/BPASmartClient/Control/DataVView.xaml
+++ b/BPASmartClient/Control/DataVView.xaml
@@ -33,12 +33,19 @@
1
+
+
客户端ID:
+
+ 设备ID:
+
+
+
devicename:
@@ -100,6 +107,13 @@
+
+
+
+
+
+
+
From a481ed340285e8cd651c3babbe7b7bb7d71ecdc2 Mon Sep 17 00:00:00 2001
From: NXX <447201003@qq>
Date: Tue, 31 May 2022 14:01:25 +0800
Subject: [PATCH 4/9] MorkT
---
.../BPASmartClient.CustomResource.csproj | 2 +
BPASmartClient.DRCoffee/CoffeeMachine.cs | 9 +-
BPASmartClient.Device/BaseDevice.cs | 2 +-
BPASmartClient.IoT/DataVClient.cs | 3 +-
BPASmartClient.Lebai/LebaiRobot.cs | 2 +-
.../BPASmartClient.MorkT.csproj | 1 +
BPASmartClient.MorkT/Control_MorkT.cs | 176 +++++++++++-------
BPASmartClient.MorkT/GLV_MorkT.cs | 12 ++
BPASmartClient.MorkT/View/DebugView.xaml | 48 ++++-
BPASmartClient.MorkT/View/DebugView.xaml.cs | 9 +-
BPASmartClient.MorkT/View/Monitor.xaml | 75 ++++++++
BPASmartClient.MorkT/View/Monitor.xaml.cs | 34 ++++
BPASmartClient.MorkT/View/ParSer.xaml | 13 ++
BPASmartClient.MorkT/View/ParSer.xaml.cs | 28 +++
.../ViewModel/DebugViewModel.cs | 87 ++++++++-
.../ViewModel/MonitorViewModel.cs | 94 ++++++++++
BPASmartClient.SCChip/ICChipMachine.cs | 95 +++++++---
17 files changed, 578 insertions(+), 112 deletions(-)
create mode 100644 BPASmartClient.MorkT/View/Monitor.xaml
create mode 100644 BPASmartClient.MorkT/View/Monitor.xaml.cs
create mode 100644 BPASmartClient.MorkT/View/ParSer.xaml
create mode 100644 BPASmartClient.MorkT/View/ParSer.xaml.cs
create mode 100644 BPASmartClient.MorkT/ViewModel/MonitorViewModel.cs
diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
index 5ab4bd64..d712bfdf 100644
--- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
+++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
@@ -12,6 +12,7 @@
+
@@ -172,6 +173,7 @@
+
diff --git a/BPASmartClient.DRCoffee/CoffeeMachine.cs b/BPASmartClient.DRCoffee/CoffeeMachine.cs
index e897453f..e1874dd0 100644
--- a/BPASmartClient.DRCoffee/CoffeeMachine.cs
+++ b/BPASmartClient.DRCoffee/CoffeeMachine.cs
@@ -141,14 +141,13 @@ namespace BPASmartClient.DRCoffee
///
public void ProcessPackage(DrCoffeePackage package)
{
-
+ lastRefreshTime = DateTime.Now;
+ IsConnected = OnLine;
+ status["CoffeeIsConnected"] = OnLine;
if (((DrCoffeeStatus)status["CoffeeStatus"]) == DrCoffeeStatus.Running && package.Status != DrCoffeeStatus.Running)
{
status["CoffeeStatus"] = package.Status;
- lastRefreshTime = DateTime.Now;
- IsConnected = OnLine;
- status["CoffeConnected"] = OnLine;
- new DRCoffee_CoffeEndCookEvent() { DeviceId = DeviceId }.Publish();
+ EventBus.EventBus.GetInstance().Publish(new DRCoffee_CoffeEndCookEvent() { DeviceId = DeviceId });
}
else status["CoffeeStatus"] = package.Status;
status["CoffeeAppStatus"] = package.ApplicationStatus;
diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs
index 8055356d..60943f21 100644
--- a/BPASmartClient.Device/BaseDevice.cs
+++ b/BPASmartClient.Device/BaseDevice.cs
@@ -325,7 +325,7 @@ namespace BPASmartClient.Device
{
MainTask();
Thread.Sleep(10);
- }), $"MainTask:{DeviceId}");
+ }) ,$"MainTask:{DeviceId}",true);
#endregion
#region 设备状态监控
diff --git a/BPASmartClient.IoT/DataVClient.cs b/BPASmartClient.IoT/DataVClient.cs
index c4ca8862..a0315030 100644
--- a/BPASmartClient.IoT/DataVClient.cs
+++ b/BPASmartClient.IoT/DataVClient.cs
@@ -35,8 +35,7 @@ namespace BPASmartClient.IoT
public DataVClient()
{
DataVApiAddress = InternetInfo.DataVApiAddress;
- //ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString();
- ClientId = Plugin.GetInstance().GetPlugin().ClientId.ToString();
+ ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString();
DeviceName = System.Configuration.ConfigurationManager.AppSettings["DeviceName"].ToString();
ProductKey = System.Configuration.ConfigurationManager.AppSettings["ProductKey"].ToString();
DeviceSecret = System.Configuration.ConfigurationManager.AppSettings["DeviceSecret"].ToString();
diff --git a/BPASmartClient.Lebai/LebaiRobot.cs b/BPASmartClient.Lebai/LebaiRobot.cs
index 721cc893..945029ea 100644
--- a/BPASmartClient.Lebai/LebaiRobot.cs
+++ b/BPASmartClient.Lebai/LebaiRobot.cs
@@ -48,7 +48,7 @@ namespace BPASmartClient.Lebai
status["RobotIsConnected"] = LebaiHelper.GetInstance().IsConnected;
status["RobotOK"] = LebaiHelper.GetInstance().GetValueAsync().Ok;
status["RobotValue"] = LebaiHelper.GetInstance().GetValueAsync().Value;
- if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] = LebaiHelper.GetInstance().robotData.RobotMode.Mode;
+ if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] =(ELebaiRModel)LebaiHelper.GetInstance().robotData.RobotMode.Mode;
LebaiHelper.GetInstance().GetRobotModeStatus();
Thread.Sleep(10);
},"获取乐白机器人数据");
diff --git a/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj b/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj
index 08d23ce9..e3705e10 100644
--- a/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj
+++ b/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj
@@ -9,6 +9,7 @@
+
diff --git a/BPASmartClient.MorkT/Control_MorkT.cs b/BPASmartClient.MorkT/Control_MorkT.cs
index 53d67dd1..247f2c7e 100644
--- a/BPASmartClient.MorkT/Control_MorkT.cs
+++ b/BPASmartClient.MorkT/Control_MorkT.cs
@@ -45,7 +45,7 @@ namespace BPASmartClient.MorkT
morkT.MakeCoffeeOrder.OrderStatus = 1;
});
int i = 0;
-
+ EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent { DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 });
MessageLog.GetInstance.Show("MORKT 设备初始化完成");
@@ -71,7 +71,21 @@ namespace BPASmartClient.MorkT
public override void MainTask()
{
-
+ if (morkT.waitMorkOrder != null)//更新订单取走状态
+ {
+ EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent() { DeviceId = DeviceId, Pin = 0 }, (o) =>
+ {
+ if (o != null && o.Length > 0 && o[0] is bool res)
+ {
+ if (!res)
+ {
+ OrderChange(morkT.waitMorkOrder.SuborderId, ORDER_STATUS.COMPLETED_TAKE);
+ DeviceProcessLogShow("订单取餐完成");
+ morkT.waitMorkOrder = null;
+ }
+ }
+ });
+ }
MakeCoffeeProcess();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 },(o)=>
{
@@ -84,7 +98,8 @@ namespace BPASmartClient.MorkT
}
}
});
-
+
+
}
public override void ReadData()
@@ -371,6 +386,7 @@ namespace BPASmartClient.MorkT
{
DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]");
GetAndCheeckCoffe(orderLoc);//取咖啡杯
+ if (!morkT.GetCoffeeCup) return;
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10051}); //接咖啡后回原点
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
@@ -380,6 +396,7 @@ namespace BPASmartClient.MorkT
}
}
+
}
@@ -411,6 +428,7 @@ namespace BPASmartClient.MorkT
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
//订单状态改变:完成
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK);
+ morkT.waitMorkOrder = order;
DeviceProcessLogShow($"{order.GoodsName}等待取餐");
//WaitTakeMealOrder.Enqueue(order);
@@ -454,6 +472,7 @@ namespace BPASmartClient.MorkT
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10050 }); //SENCE_咖啡杯回原点
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
+ morkT.GetCoffeeCup = false;
return;
}
DeviceProcessLogShow("执行二次取咖啡杯");
@@ -464,6 +483,7 @@ namespace BPASmartClient.MorkT
count++;
goto p;
}
+ morkT.GetCoffeeCup = true;
DeviceProcessLogShow("取咖啡杯完成");
}
@@ -482,40 +502,45 @@ namespace BPASmartClient.MorkT
///
private void MakeIceCreamProcess()
{
- if (IceCreamCanMake())
- {
- if(peripheralStatus.ContainsKey("IceCreamCurrentMode"))
- {
- if ((MORKI_MODE)peripheralStatus["IceCreamCurrentMode"] != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();
- }
-
- if(peripheralStatus.ContainsKey("IceCreamCXB"))
- {
- if ((byte)peripheralStatus["IceCreamCXB"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作
- {
- bool result = true;
- EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) =>
- {
- if (res[0] is bool resultValue)
- {
- result = resultValue;
- }
- });
- if (result)
- {
- if (morkT.IceIsOK) DeviceProcessLogShow("请检查冰淇淋出料口有无遮挡");
- morkT.IceIsOK = false;
- }
- else if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order))
- {
- morkT.IceIsOK = true;
- DeviceProcessLogShow($"开始制作 [冰淇淋] 订单[{order.SortNum}]");
- DoIceCream(order);
- }
- }
- }
-
- }
+ //if (IceCreamCanMake())
+ //{
+ if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order))
+ {
+ DoIceCream(order);
+ }
+
+ //if(peripheralStatus.ContainsKey("IceCreamCurrentMode"))
+ //{
+ // if ((MORKI_MODE)peripheralStatus["IceCreamCurrentMode"] != MORKI_MODE.制冷模式) EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent { DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 });
+ //}
+
+ //if(peripheralStatus.ContainsKey("IceCreamCXB"))
+ //{
+ // if ((byte)peripheralStatus["IceCreamCXB"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作
+ // {
+ // bool result = true;
+ // EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) =>
+ // {
+ // if (res[0] is bool resultValue)
+ // {
+ // result = resultValue;
+ // }
+ // });
+ // if (result)
+ // {
+ // if (morkT.IceIsOK) DeviceProcessLogShow("请检查冰淇淋出料口有无遮挡");
+ // morkT.IceIsOK = false;
+ // }
+ // else if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order))
+ // {
+ // morkT.IceIsOK = true;
+ // DeviceProcessLogShow($"开始制作 [冰淇淋] 订单[{order.SortNum}]");
+ // DoIceCream(order);
+ // }
+ // }
+ //}
+
+ //}
}
@@ -526,8 +551,12 @@ namespace BPASmartClient.MorkT
{
GetIceCreamCup();
CheckICeCreaCup();
- GetIceCream(order);
- PutIceCream(order);
+ if(morkT.GetIceCreamCup)
+ {
+ GetIceCream(order);
+ PutIceCream(order);
+ }
+
}
///
@@ -572,6 +601,7 @@ namespace BPASmartClient.MorkT
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10049 }); //SENCE_冰淇淋杯回原点
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
+ morkT.GetIceCreamCup = false;
return;
}
DeviceProcessLogShow($"执行{count}次取冰淇淋杯!");
@@ -582,6 +612,7 @@ namespace BPASmartClient.MorkT
count++;
goto p;
}
+ morkT.GetIceCreamCup = true;
DeviceProcessLogShow("冰淇淋杯检测完成");
}
@@ -592,34 +623,43 @@ namespace BPASmartClient.MorkT
private void GetIceCream(OrderLocInfo order)
{
//制冷模式
- EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent {DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 });
+ //EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent {DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 });
OrderChange(order.SuborderId, ORDER_STATUS.COOKING);
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10039 }); //SENCE_接1号冰淇淋
Wait();
bool doItResult = true;
+
//出料
- EventBus.EventBus.GetInstance().Publish(new GSIceCream_DischargeEvent { DeviceId = DeviceId },(o)=>
- {
- doItResult = (bool)o[0];
- });
- if (doItResult)
- {
- IceCreamCookCheck();
- }
- else
- {
- int count_1 = 0;
+ EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = true });
+ Thread.Sleep(500);
+ EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = false });
+ EventBus.EventBus.GetInstance().Publish(new SCChip_MakeIceCreamEvent { DeviceId = DeviceId ,SteeringEngine = IC_SE.SE_2 });//冰淇淋出料
+ DeviceProcessLogShow("开始等待6s");
+ Thread.Sleep(6000);
- while ((byte)peripheralStatus["IceCreamCXB"] <= 86)
- {
- Thread.Sleep(5);
- count_1++;
- if (count_1 >= 2000)
- break;
- }
- IceCreamCookCheck();
- }
+ //出料
+ //EventBus.EventBus.GetInstance().Publish(new GSIceCream_DischargeEvent { DeviceId = DeviceId },(o)=>
+ //{
+ // doItResult = (bool)o[0];
+ //});
+ //if (doItResult)
+ //{
+ // IceCreamCookCheck();
+ //}
+ //else
+ //{
+ // int count_1 = 0;
+
+ // while ((byte)peripheralStatus["IceCreamCXB"] <= 86)
+ // {
+ // Thread.Sleep(5);
+ // count_1++;
+ // if (count_1 >= 2000)
+ // break;
+ // }
+ // IceCreamCookCheck();
+ //}
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
}
@@ -629,21 +669,25 @@ namespace BPASmartClient.MorkT
///
private void PutIceCream(OrderLocInfo order)
{
- EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 }, (res) =>
+ bool resultValue = true;
+ while (resultValue)
{
- if (res[0] is bool resultValue)
+ EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 }, (res) =>
{
- while (resultValue)
+ if (res[0] is bool b)
{
- Thread.Sleep(500);
+ resultValue = b;
}
- }
- });
+ });
+ Thread.Sleep(500);
+ }
+
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10043 }); //SENCE_放冰淇淋位置
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
//订单状态改变:完成
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK);
+ morkT.waitMorkOrder = order;
DeviceProcessLogShow($"{order.GoodsName}等待取餐");
//WaitTakeMealOrder.Enqueue(order);
diff --git a/BPASmartClient.MorkT/GLV_MorkT.cs b/BPASmartClient.MorkT/GLV_MorkT.cs
index c825bbd2..f124da95 100644
--- a/BPASmartClient.MorkT/GLV_MorkT.cs
+++ b/BPASmartClient.MorkT/GLV_MorkT.cs
@@ -25,6 +25,10 @@ namespace BPASmartClient.MorkT
///
public ConcurrentQueue morkOrderPushesIceCream = new ConcurrentQueue();
///
+ /// 等待取餐订单
+ ///
+ public OrderLocInfo waitMorkOrder = null;
+ ///
/// 物料存放位置
///
public Dictionary batchings = new Dictionary();
@@ -44,6 +48,14 @@ namespace BPASmartClient.MorkT
/// 冰淇淋机器出料口传感器检测
///
public bool IceIsOK = true;
+ ///
+ /// 去咖啡杯成功
+ ///
+ public bool GetCoffeeCup;
+ ///
+ /// 取冰淇淋杯成功
+ ///
+ public bool GetIceCreamCup;
#region
diff --git a/BPASmartClient.MorkT/View/DebugView.xaml b/BPASmartClient.MorkT/View/DebugView.xaml
index 5a23087b..db1ee199 100644
--- a/BPASmartClient.MorkT/View/DebugView.xaml
+++ b/BPASmartClient.MorkT/View/DebugView.xaml
@@ -6,7 +6,7 @@
xmlns:vm ="clr-namespace:BPASmartClient.MorkT.ViewModel"
mc:Ignorable="d"
Name="调试界面"
- d:DesignHeight="450" d:DesignWidth="1000" >
+ d:DesignHeight="500" d:DesignWidth="1000" Unloaded="Dubug_Unloaded">
@@ -20,12 +20,13 @@
-
-
+
+
-
-
+
+
+
-
@@ -172,7 +173,7 @@
-
@@ -203,13 +204,13 @@
咖啡机状态
-
+ Text="{Binding CoffeeStatus}" Height="23" />
应用状态
+ Text="{Binding AppStatus}" Height="23"/>
告警信息
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BPASmartClient.MorkT/View/DebugView.xaml.cs b/BPASmartClient.MorkT/View/DebugView.xaml.cs
index c482d29d..b685bf7b 100644
--- a/BPASmartClient.MorkT/View/DebugView.xaml.cs
+++ b/BPASmartClient.MorkT/View/DebugView.xaml.cs
@@ -1,4 +1,5 @@
-using System;
+using BPASmartClient.Helper;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -24,5 +25,11 @@ namespace BPASmartClient.MorkT.View
{
InitializeComponent();
}
+
+ private void Dubug_Unloaded(object sender, RoutedEventArgs e)
+ {
+ ThreadManage.GetInstance().StopTask("MorkT-状态刷新");
+ ThreadManage.GetInstance().StopTask("MorkT-传感器监视");
+ }
}
}
diff --git a/BPASmartClient.MorkT/View/Monitor.xaml b/BPASmartClient.MorkT/View/Monitor.xaml
new file mode 100644
index 00000000..4eaff171
--- /dev/null
+++ b/BPASmartClient.MorkT/View/Monitor.xaml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BPASmartClient.MorkT/View/Monitor.xaml.cs b/BPASmartClient.MorkT/View/Monitor.xaml.cs
new file mode 100644
index 00000000..b5d76d55
--- /dev/null
+++ b/BPASmartClient.MorkT/View/Monitor.xaml.cs
@@ -0,0 +1,34 @@
+using BPASmartClient.Helper;
+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.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace BPASmartClient.MorkT.View
+{
+ ///
+ /// Monitor.xaml 的交互逻辑
+ ///
+ public partial class Monitor : UserControl
+ {
+ public Monitor()
+ {
+ InitializeComponent();
+ }
+
+
+ private void Monitor_Unloaded(object sender, RoutedEventArgs e)
+ {
+ }
+ }
+}
diff --git a/BPASmartClient.MorkT/View/ParSer.xaml b/BPASmartClient.MorkT/View/ParSer.xaml
new file mode 100644
index 00000000..8d87d132
--- /dev/null
+++ b/BPASmartClient.MorkT/View/ParSer.xaml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/BPASmartClient.MorkT/View/ParSer.xaml.cs b/BPASmartClient.MorkT/View/ParSer.xaml.cs
new file mode 100644
index 00000000..ea8ef7c8
--- /dev/null
+++ b/BPASmartClient.MorkT/View/ParSer.xaml.cs
@@ -0,0 +1,28 @@
+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.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace BPASmartClient.MorkT.View
+{
+ ///
+ /// ParSer.xaml 的交互逻辑
+ ///
+ public partial class ParSer : UserControl
+ {
+ public ParSer()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/BPASmartClient.MorkT/ViewModel/DebugViewModel.cs b/BPASmartClient.MorkT/ViewModel/DebugViewModel.cs
index 90913821..1f234724 100644
--- a/BPASmartClient.MorkT/ViewModel/DebugViewModel.cs
+++ b/BPASmartClient.MorkT/ViewModel/DebugViewModel.cs
@@ -9,6 +9,8 @@ using BPASmartClient.Message;
using BPASmartClient.Model;
using BPASmartClient.Model.乐白机器人;
using BPASmartClient.Model.冰淇淋.Enum;
+using BPASmartClient.Model.单片机;
+using BPASmartClient.Model.单片机.Enum;
using BPASmartClient.Model.咖啡机.Enum;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
@@ -156,21 +158,100 @@ namespace BPASmartClient.MorkT.ViewModel
public List CoffeeCmds { get; set; } = new List();
public string SelectedCoffeeCmd { get; set; }
+ ///
+ /// 制作咖啡
+ ///
+ public RelayCommand Button_MakeCoffeeCommand { get; set; }
+ ///
+ /// 停止制作咖啡
+ ///
+ public RelayCommand Button_StopMakeCoffeCommand { get; set; }
+ ///
+ /// 咖啡模式设置
+ ///
+ public RelayCommand Button_CoffeeModeSetCommand { get; set; }
+
+ private void Button_MakeCoffee()
+ {
+ EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee)});
+ }
+ private void Button_StopMakeCoffe()
+ {
+ EventBus.EventBus.GetInstance().Publish(new DRCoffee_CancelMakeCoffeeEvent() { DeviceId = DeviceId });
+ }
+ private void Button_CoffeeModeSet()
+ {
+ EventBus.EventBus.GetInstance().Publish(new DRCoffee_CoffeeCommCmdEvent() { DeviceId = DeviceId, CommCmd = (DrCoffeeCommCmd)Enum.Parse(typeof(DrCoffeeCommCmd), SelectedCoffeeCmd)});
+ }
#endregion
+ #region 单片机
///
- /// 设备ID
+ /// 咖啡杯或冰淇淋杯落杯
///
- public int DeviceId { get; set; }
+ public RelayCommand