@@ -103,7 +103,7 @@ namespace BPASmartClient.DRCoffee | |||
//一系列解包 | |||
while (dataStorage.GetSize() > 0) | |||
{ | |||
IsConnected = true; | |||
byte item = dataStorage.GetData(); | |||
if (DrCoffee.HEADER == item) | |||
{ | |||
@@ -147,6 +147,7 @@ namespace BPASmartClient.DRCoffee | |||
status["Status"] = package.Status; | |||
lastRefreshTime = DateTime.Now; | |||
IsConnected = OnLine; | |||
new DRCoffee_CoffeEndCookEvent() { DeviceId = DeviceId }.Publish(); | |||
} | |||
else status["Status"] = package.Status; | |||
@@ -160,8 +161,7 @@ namespace BPASmartClient.DRCoffee | |||
|| (DrCoffeeFault)status["Fault"] != DrCoffeeFault.无故障 | |||
) | |||
{ | |||
IsWork = false; | |||
IsWork = false; | |||
} | |||
else | |||
IsWork = true; | |||
@@ -177,7 +177,7 @@ namespace BPASmartClient.DRCoffee | |||
public override void Init() | |||
{ | |||
commProxy = new SerialPortClient(PortName,(BaudRates)Enum.Parse(typeof(BaudRates),BaudRate)); | |||
commProxy = new SerialPortClient(communicationPar.SerialPort,(BaudRates)communicationPar.BaudRate); | |||
commProxy.SetDataStorage(dataStorage); | |||
//咖博士咖啡机制作 | |||
@@ -130,6 +130,7 @@ namespace BPASmartClient.Device | |||
peripherals.ForEach(p => | |||
{ | |||
p.DeviceId = this.DeviceId; | |||
p.Init(); | |||
}); | |||
this.peripherals = peripherals; | |||
@@ -48,7 +48,6 @@ namespace BPASmartClient.GSIceCream | |||
try | |||
{ | |||
commProxy.Start(); | |||
IsConnected = true; | |||
free = false; | |||
MainLoop(); | |||
} | |||
@@ -89,6 +88,12 @@ namespace BPASmartClient.GSIceCream | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
status["test"] = 0; | |||
for (int i = 0; i < 1000; i++) | |||
{ | |||
status["test"] = (int)status["test"] + 1; | |||
Thread.Sleep(1000); | |||
} | |||
ResolveMsg(); | |||
}), "冰淇淋解析线程"); | |||
} | |||
@@ -177,13 +182,14 @@ namespace BPASmartClient.GSIceCream | |||
private void ProcessHeart(ICMSG_Heart_UP heartUpMsg) | |||
{ | |||
IsConnected = OnLine; | |||
status["CurrentMode"] = heartUpMsg.MS; | |||
status["YLWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.YLWD_L,heartUpMsg.YLWD_H },0); | |||
status["HQWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HQWD_L,heartUpMsg.HQWD_H },0); | |||
status["HJWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HJWD_L,heartUpMsg.HJWD_H },0); | |||
status["DL"] = BitConverter.ToInt16(new byte[] { heartUpMsg.DL_L,heartUpMsg.DL_H },0); | |||
status["DL"] = BitConverter.ToInt16(new byte[] { heartUpMsg.DL_L, heartUpMsg.DL_H }, 0); | |||
status["Fault"] = (MORKI_FAULT)BitConverter.ToInt16(new byte[] { heartUpMsg.GZ_L,heartUpMsg.GZ_H },0); | |||
status["CXB"] = heartUpMsg.CXB; | |||
status["CXB"] = heartUpMsg.CXB; | |||
status["DLCompleted"] = (heartUpMsg.DLTJ >> 4 & 1) == 1; | |||
if (RTrig.GetInstance("打料完成检测").Start((bool)status["DLCompleted"])) | |||
@@ -195,6 +201,7 @@ namespace BPASmartClient.GSIceCream | |||
{ | |||
MessageLog.GetInstance.Show("打料中"); | |||
} | |||
Thread.Sleep(100); | |||
} | |||
private void ProcessModeUp(ICMSG_MODE_UP modeUpMsg) | |||
@@ -243,12 +250,11 @@ namespace BPASmartClient.GSIceCream | |||
public override void Init() | |||
{ | |||
commProxy = new SerialPortClient(PortName,(BaudRates)Enum.Parse(typeof(BaudRates),BaudRate)); | |||
//广深冰淇淋机模式设置 | |||
commProxy = new SerialPortClient(communicationPar.SerialPort, (BaudRates)communicationPar.BaudRate); | |||
commProxy.SetDataStorage(dataStorage); | |||
//广深冰淇淋机模式设置 | |||
EventBus.EventBus.GetInstance().Subscribe<GSIceCream_ModeSetEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
EventBus.EventBus.GetInstance().Subscribe<GSIceCream_ModeSetEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
@@ -258,7 +264,7 @@ namespace BPASmartClient.GSIceCream | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
MessageLog.GetInstance.Show(string.Format("设置模式[{0}]",Enum.GetName(typeof(MORKI_MODE),((GSIceCream_ModeSetEvent)@event).Mode))); | |||
MessageLog.GetInstance.Show(string.Format("设置模式[{0}]", Enum.GetName(typeof(MORKI_MODE), ((GSIceCream_ModeSetEvent)@event).Mode))); | |||
} | |||
catch (Exception ex) | |||
{ | |||
@@ -333,6 +339,7 @@ namespace BPASmartClient.GSIceCream | |||
InitStatus(); | |||
//测试用 | |||
Start(); | |||
MessageLog.GetInstance.Show("冰淇淋机器初始化完成"); | |||
} | |||
} | |||
@@ -15,16 +15,13 @@ using BPASmartClient.EventBus; | |||
using static BPASmartClient.EventBus.EventBus; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.LebaiRobot; | |||
using BPASmartClient.Model.乐白机器人; | |||
namespace BPASmartClient.Lebai | |||
{ | |||
public class LebaiRobot: BasePeripheral | |||
{ | |||
/// <summary> | |||
/// IP地址 | |||
/// </summary> | |||
public string IpAddress { get; set; } = "192.168.0.1"; | |||
/// <summary> | |||
/// 抓手上传感器输入位索引 | |||
/// </summary> | |||
@@ -43,13 +40,18 @@ namespace BPASmartClient.Lebai | |||
public override void Start() | |||
{ | |||
LebaiHelper.GetInstance().Connect(IpAddress); | |||
ThreadManage.GetInstance().StartLong(() => { LebaiHelper.GetInstance().Reconnect(IpAddress); Thread.Sleep(5000); }, "机器人重连检测"); | |||
LebaiHelper.GetInstance().Connect(communicationPar.IPAddress); | |||
ThreadManage.GetInstance().StartLong(() => { LebaiHelper.GetInstance().Reconnect(communicationPar.IPAddress); Thread.Sleep(5000); }, "机器人重连检测"); | |||
ThreadManage.GetInstance().StartLong(() => | |||
{ | |||
status["Connected"] = LebaiHelper.GetInstance().IsConnected; | |||
IsConnected = LebaiHelper.GetInstance().IsConnected; | |||
status["OK"] = LebaiHelper.GetInstance().GetValueAsync().Ok; | |||
status["Value"] = LebaiHelper.GetInstance().GetValueAsync().Value; | |||
if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] = LebaiHelper.GetInstance().robotData.RobotMode.Mode; | |||
LebaiHelper.GetInstance().GetRobotModeStatus(); | |||
Thread.Sleep(10); | |||
},"获取乐白机器人数据"); | |||
} | |||
public override void Stop() | |||
@@ -63,8 +65,72 @@ namespace BPASmartClient.Lebai | |||
{ | |||
}); | |||
//获取机器人信号 | |||
EventBus.EventBus.GetInstance().Subscribe<LebaiRobot_GetInputEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
if (@event is LebaiRobot_GetInputEvent getInput) | |||
{ | |||
callBack.Invoke(LebaiHelper.GetInstance().GetInput(getInput.Pin)); | |||
} | |||
}); | |||
//获取Tcp信号 | |||
EventBus.EventBus.GetInstance().Subscribe<Demo_MakeCoffeeEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
if (@event is LebaiRobot_GetInputEvent getTCPInput) | |||
{ | |||
callBack.Invoke(LebaiHelper.GetInstance().GetTcpInput(getTCPInput.Pin)); | |||
} | |||
}); | |||
//机器人输入信号 | |||
EventBus.EventBus.GetInstance().Subscribe<LebaiRobot_SetValueEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
if (@event is LebaiRobot_SetValueEvent SetValueEvent) | |||
{ | |||
LebaiHelper.GetInstance().SetValue(SetValueEvent.RobotSetValue); | |||
} | |||
}); | |||
//控制机器人 | |||
EventBus.EventBus.GetInstance().Subscribe<LebaiRobot_LebaiControlEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
if (@event is LebaiRobot_LebaiControlEvent lebaiControlEvent) | |||
{ | |||
switch (lebaiControlEvent.LebaiControl) | |||
{ | |||
case "机器人启动": | |||
LebaiHelper.GetInstance().StartRobot(); | |||
break; | |||
case "启动示教": | |||
LebaiHelper.GetInstance().StartTeachMode(); | |||
break; | |||
case "停止示教": | |||
LebaiHelper.GetInstance().EndtTeachMode(); | |||
break; | |||
case "机器人急停": | |||
LebaiHelper.GetInstance().EStopRobot(); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
}); | |||
//选择机器人场景 | |||
EventBus.EventBus.GetInstance().Subscribe<LebaiRobot_LebaiSenceEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
if (@event is LebaiRobot_LebaiSenceEvent lebaiSenceEvent) | |||
{ | |||
LebaiHelper.GetInstance().Scene(lebaiSenceEvent.LebaiSence); | |||
} | |||
}); | |||
InitStatus(); | |||
Start(); | |||
MessageLog.GetInstance.Show("乐白机器人初始化完成"); | |||
} | |||
@@ -15,45 +15,7 @@ namespace BPASmartClient.LebaiRobot | |||
public class LebaiHelper:Singleton<LebaiHelper> | |||
{ | |||
#region 且时且多设备 | |||
//取咖啡杯 set:=1 get:=101 10031 | |||
//取冰淇淋杯 set:=1 get:=101 10032 | |||
//咖啡杯检测 set:=1 get:=101 10033 | |||
//冰淇淋杯检测 set:=1 get:=101 10034 | |||
//二次取咖啡杯 set:=1 get:=101 10035 | |||
//二次取冰淇淋杯 set:=1 get:=101 10036 | |||
//接咖啡 set:=1 get:=101 10037 | |||
//接冰淇淋公共点 set:=1 get:=101 10038 | |||
//接1号冰淇淋 set:=1 get:=101 10039 | |||
//接2号冰淇淋 set:=1 get:=101 10040 | |||
//接3号冰淇淋 set:=1 get:=101 10041 | |||
//放咖啡位置 set:=1 get:=101 10042 | |||
//放冰淇淋位置 set:=1 get:=101 10043 | |||
public const int SENCE_取咖啡杯 = 10031; | |||
public const int SENCE_取冰淇淋杯 = 10032; | |||
public const int SENCE_咖啡杯检测 = 10033; | |||
public const int SENCE_冰淇淋杯检测 = 10034; | |||
public const int SENCE_二次取咖啡杯 = 10035; | |||
public const int SENCE_二次取冰淇淋杯 = 10036; | |||
public const int SENCE_接咖啡 = 10037; | |||
public const int SENCE_接冰淇淋公共点 = 10038; | |||
public const int SENCE_接1号冰淇淋 = 10039; | |||
public const int SENCE_接2号冰淇淋 = 10040; | |||
public const int SENCE_接3号冰淇淋 = 10041; | |||
public const int SENCE_放咖啡位置 = 10042; | |||
public const int SENCE_放冰淇淋位置 = 10043; | |||
//add 新加场景 | |||
public const int SENCE_接咖啡后回原点 = 10051; | |||
public const int SENCE_咖啡杯回原点 = 10050; | |||
public const int SENCE_冰淇淋杯回原点 = 10049; | |||
public const int SENCE_取咖啡出餐 = 10052; | |||
#endregion | |||
private LebaiRobotClient client; | |||
public RobotData robotData; | |||
public bool IsIdle { get; set; } = false; | |||
@@ -302,6 +264,24 @@ namespace BPASmartClient.LebaiRobot | |||
return false; | |||
} | |||
public bool GetTcpInput(int pin = 1) | |||
{ | |||
try | |||
{ | |||
if (client == null) return false; | |||
var res = client.GetTcpDIO(new IOPin() { Pin = pin }).Result; | |||
if (res != null) | |||
{ | |||
return res.Value == 1 ? true : false; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
} | |||
return false; | |||
} | |||
/// <summary> | |||
/// 运行指定的场景 | |||
/// </summary> | |||
@@ -7,11 +7,13 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.EventBus\BPASmartClient.EventBus.csproj" /> | |||
<Compile Remove="机器人\**" /> | |||
<EmbeddedResource Remove="机器人\**" /> | |||
<None Remove="机器人\**" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Folder Include="机器人\Enum\" /> | |||
<ProjectReference Include="..\BPASmartClient.EventBus\BPASmartClient.EventBus.csproj" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -0,0 +1,33 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Model.乐白机器人.Enum | |||
{ | |||
public class Lebai_qsqdCode | |||
{ | |||
#region 且时且多设备 | |||
public const int SENCE_取咖啡杯 = 10031; | |||
public const int SENCE_取冰淇淋杯 = 10032; | |||
public const int SENCE_咖啡杯检测 = 10033; | |||
public const int SENCE_冰淇淋杯检测 = 10034; | |||
public const int SENCE_二次取咖啡杯 = 10035; | |||
public const int SENCE_二次取冰淇淋杯 = 10036; | |||
public const int SENCE_接咖啡 = 10037; | |||
public const int SENCE_接冰淇淋公共点 = 10038; | |||
public const int SENCE_接1号冰淇淋 = 10039; | |||
public const int SENCE_接2号冰淇淋 = 10040; | |||
public const int SENCE_接3号冰淇淋 = 10041; | |||
public const int SENCE_放咖啡位置 = 10042; | |||
public const int SENCE_放冰淇淋位置 = 10043; | |||
//add 新加场景 | |||
public const int SENCE_接咖啡后回原点 = 10051; | |||
public const int SENCE_咖啡杯回原点 = 10050; | |||
public const int SENCE_冰淇淋杯回原点 = 10049; | |||
public const int SENCE_取咖啡出餐 = 10052; | |||
#endregion | |||
} | |||
} |
@@ -0,0 +1,48 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Model.乐白机器人 | |||
{ | |||
/// <summary> | |||
/// 获取机器人输入DI状态 | |||
/// </summary> | |||
public class LebaiRobot_GetInputEvent : BaseEvent | |||
{ | |||
public int Pin { get; set; } = 0; | |||
} | |||
/// <summary> | |||
/// /// <summary> | |||
/// 获取机器人输入TCPDI状态 | |||
/// </summary> | |||
/// </summary> | |||
public class LebaiRobot_GetTCPInputEvent : BaseEvent | |||
{ | |||
public int Pin { get; set; } = 1; | |||
} | |||
/// <summary> | |||
/// 输入机器人信号 | |||
/// </summary> | |||
public class LebaiRobot_SetValueEvent : BaseEvent | |||
{ | |||
public int RobotSetValue { get; set; } | |||
} | |||
/// <summary> | |||
/// 机器人控制 | |||
/// </summary> | |||
public class LebaiRobot_LebaiControlEvent : BaseEvent | |||
{ | |||
public string LebaiControl { get; set; } | |||
} | |||
/// <summary> | |||
/// 选择乐白机器人场景 | |||
/// </summary> | |||
public class LebaiRobot_LebaiSenceEvent : BaseEvent | |||
{ | |||
public int LebaiSence { get; set; } | |||
} | |||
} |
@@ -8,10 +8,25 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.DRCoffee\BPASmartClient.DRCoffee.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Lebai\BPASmartClient.Lebai.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Update="View\DebugView.xaml.cs"> | |||
<SubType>Code</SubType> | |||
</Compile> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Page Update="View\DebugView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
<SubType>Designer</SubType> | |||
</Page> | |||
</ItemGroup> | |||
</Project> |
@@ -7,6 +7,7 @@ using BPASmartClient.Lebai; | |||
using BPASmartClient.LebaiRobot; | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Model.乐白机器人; | |||
using BPASmartClient.Model.冰淇淋.Enum; | |||
using BPASmartClient.Model.单片机; | |||
using BPASmartClient.Model.单片机.Enum; | |||
@@ -27,6 +28,7 @@ namespace BPASmartClient.MorkT | |||
GLV_MorkT morkT = new GLV_MorkT(); | |||
public override void DoMain() | |||
{ | |||
IsHealth = true; | |||
@@ -37,28 +39,13 @@ namespace BPASmartClient.MorkT | |||
if (morkT.MakeCoffeeOrder != null) | |||
morkT.MakeCoffeeOrder.OrderStatus = 1; | |||
}); | |||
int i = 0; | |||
////ThreadManage.GetInstance().StartLong(new Action(() => | |||
////{ | |||
//// i = (int)Status.status["GSIceCream.IceCreamMachine.test"]; | |||
////}),"test"); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
switch (o) | |||
{ | |||
case "机器人启动": | |||
LebaiHelper.GetInstance().StartRobot(); | |||
break; | |||
case "启动示教": | |||
LebaiHelper.GetInstance().StartTeachMode(); | |||
break; | |||
case "停止示教": | |||
LebaiHelper.GetInstance().EndtTeachMode(); | |||
break; | |||
case "机器人急停": | |||
LebaiHelper.GetInstance().EStopRobot(); | |||
break; | |||
default: | |||
break; | |||
} | |||
}),"调试控制-机器人控制"); | |||
MessageLog.GetInstance.Show("MORKT 设备初始化完成"); | |||
} | |||
@@ -69,20 +56,49 @@ namespace BPASmartClient.MorkT | |||
morkT = new GLV_MorkT(); | |||
} | |||
private void GetStatus(string key, Action<object> action) | |||
{ | |||
if (peripheralStatus.ContainsKey(key)) | |||
{ | |||
if (peripheralStatus[key] != null) | |||
{ | |||
action?.Invoke(peripheralStatus[key]); | |||
} | |||
} | |||
} | |||
public override void MainTask() | |||
{ | |||
GetStatus("RobotMode", new Action<object>((o) => | |||
{ | |||
})); | |||
MakeCoffeeProcess(); | |||
if(!LebaiHelper.GetInstance().GetInput())//取餐口有空余位置 | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 },(o)=> | |||
{ | |||
MakeIceCreamProcess(); | |||
MakeCoffeeComplete(); | |||
} | |||
if(o != null && o.Length > 0 && o[0] is bool resultValue) | |||
{ | |||
if(!resultValue)//取餐口有空余位置 | |||
{ | |||
MakeIceCreamProcess(); | |||
MakeCoffeeComplete(); | |||
} | |||
} | |||
}); | |||
} | |||
public override void ReadData() | |||
{ | |||
morkT.lebai = LebaiHelper.GetInstance().GetValueAsync(); | |||
LebaiHelper.GetInstance().GetRobotModeStatus(); | |||
} | |||
@@ -186,7 +202,6 @@ namespace BPASmartClient.MorkT | |||
} | |||
}); | |||
} | |||
/// <summary> | |||
/// 验证当前是做咖啡还是做冰淇淋 | |||
/// </summary> | |||
@@ -208,7 +223,7 @@ namespace BPASmartClient.MorkT | |||
private void Wait(int value = 101) | |||
{ | |||
while (!(morkT.lebai.Ok && morkT.lebai.Value == value)) | |||
while (!((bool)Status.status["Lebai.LebaiRobot.OK"] && (int)Status.status["Lebai.LebaiRobot.Value"] == value)) | |||
{ | |||
Thread.Sleep(5); | |||
} | |||
@@ -236,9 +251,9 @@ namespace BPASmartClient.MorkT | |||
{ | |||
DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]"); | |||
GetAndCheeckCoffe(orderLoc); | |||
LebaiHelper.GetInstance().Scene(LebaiHelper.SENCE_接咖啡后回原点);//把咖啡杯放到咖啡机机的位置后回原点 | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10051}); //接咖啡后回原点 | |||
Wait(); | |||
LebaiHelper.GetInstance().SetValue(1); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
new DRCoffee_MakeCoffeeEvent() { DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) }.Publish(); //接咖啡控制 | |||
DeviceProcessLogShow($"发送咖啡机制作{orderLoc.Loc}!"); | |||
morkT.IsCoffeeMake = true; morkT.MakeCoffeeOrder = orderLoc; | |||
@@ -271,9 +286,9 @@ namespace BPASmartClient.MorkT | |||
/// </summary> | |||
private void DoCoffeeQC(OrderLocInfo order) | |||
{ | |||
LebaiHelper.GetInstance().Scene(LebaiHelper.SENCE_取咖啡出餐); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10052 }); //SENCE_取咖啡出餐 | |||
Wait(); | |||
LebaiHelper.GetInstance().SetValue(1); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
//订单状态改变:完成 | |||
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); | |||
DeviceProcessLogShow($"{order.GoodsName}等待取餐"); | |||
@@ -287,36 +302,45 @@ namespace BPASmartClient.MorkT | |||
/// <param name="order"></param> | |||
private void GetAndCheeckCoffe(OrderLocInfo order) | |||
{ | |||
LebaiHelper.GetInstance().SetValue(0); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }); | |||
OrderChange(order.SuborderId, ORDER_STATUS.COOKING); | |||
LebaiHelper.GetInstance().Scene(LebaiHelper.SENCE_取咖啡杯); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10031 }); //SENCE_取咖啡杯 | |||
Wait(); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制 | |||
Thread.Sleep(500); | |||
DeviceProcessLogShow("尝试取咖啡杯!"); | |||
LebaiHelper.GetInstance().SetValue(1); | |||
int count = 2; | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
int count = 1; | |||
bool result = true; | |||
p: | |||
LebaiHelper.GetInstance().Scene(LebaiHelper.SENCE_咖啡杯检测); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10033 }); //SENCE_咖啡杯检测 | |||
Wait(); | |||
LebaiHelper.GetInstance().SetValue(1); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent { DeviceId = DeviceId, Pin = 1 }, (o)=> | |||
{ | |||
if(o != null && o.Length > 0 && o[0] is bool resultValue) | |||
{ | |||
result = resultValue; | |||
} | |||
}); | |||
if (!LebaiHelper.GetInstance().GetInput()) | |||
if (!result) | |||
{ | |||
if (count >= 3) | |||
{ | |||
//退出循环回到初始位置 | |||
DeviceProcessLogShow($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!"); | |||
LebaiHelper.GetInstance().Scene(LebaiHelper.SENCE_咖啡杯回原点); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10050 }); //SENCE_咖啡杯回原点 | |||
Wait(); | |||
LebaiHelper.GetInstance().SetValue(1); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
return; | |||
} | |||
DeviceProcessLogShow("执行二次取咖啡杯"); | |||
LebaiHelper.GetInstance().Scene(LebaiHelper.SENCE_二次取咖啡杯); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10035 }); //SENCE_二次取咖啡杯 | |||
Wait(); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制 | |||
LebaiHelper.GetInstance().SetValue(1); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
count++; | |||
goto p; | |||
} | |||
@@ -340,16 +364,24 @@ namespace BPASmartClient.MorkT | |||
{ | |||
if (IceCreamCanMake()) | |||
{ | |||
if(Status.status.ContainsKey("CurrentMode")) | |||
if(Status.status.ContainsKey("GSIceCream.IceCreamMachine.CurrentMode")) | |||
{ | |||
if ((MORKI_MODE)Status.status["CurrentMode"] != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
if ((MORKI_MODE)Status.status["GSIceCream.IceCreamMachine.CurrentMode"] != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
} | |||
if(Status.status.ContainsKey("CBX")) | |||
if(Status.status.ContainsKey("GSIceCream.IceCreamMachine.CBX")) | |||
{ | |||
if ((short)Status.status["CBX"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 | |||
if ((short)Status.status["GSIceCream.IceCreamMachine.CBX"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 | |||
{ | |||
if (LebaiHelper.GetInstance().GetInput(3)) | |||
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; | |||
@@ -383,8 +415,8 @@ namespace BPASmartClient.MorkT | |||
/// </summary> | |||
private void GetIceCreamCup() | |||
{ | |||
LebaiHelper.GetInstance().SetValue(0); | |||
LebaiHelper.GetInstance().Scene(LebaiHelper.SENCE_取冰淇淋杯); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10032 }); //SENCE_取冰淇淋杯 | |||
Wait(); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制 | |||
Thread.Sleep(500); | |||
@@ -398,27 +430,35 @@ namespace BPASmartClient.MorkT | |||
private void CheckICeCreaCup() | |||
{ | |||
int count = 2; | |||
LebaiHelper.GetInstance().SetValue(1); | |||
bool result = true; | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
p: | |||
LebaiHelper.GetInstance().Scene(LebaiHelper.SENCE_冰淇淋杯检测); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10034 }); //SENCE_冰淇淋杯检测 | |||
Wait(); | |||
LebaiHelper.GetInstance().SetValue(1); | |||
if (!LebaiHelper.GetInstance().GetInput()) | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent { DeviceId = DeviceId, Pin = 1 }, (o) => | |||
{ | |||
if (o != null && o.Length > 0 && o[0] is bool resultValue) | |||
{ | |||
result = resultValue; | |||
} | |||
}); | |||
if (!result) | |||
{ | |||
if (count >= 3) | |||
{ | |||
//退出循环回到初始位置 | |||
DeviceProcessLogShow($"执行{count}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!"); | |||
LebaiHelper.GetInstance().Scene(LebaiHelper.SENCE_冰淇淋杯回原点); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10049 }); //SENCE_冰淇淋杯回原点 | |||
Wait(); | |||
LebaiHelper.GetInstance().SetValue(1); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
return; | |||
} | |||
DeviceProcessLogShow($"执行{count}次取冰淇淋杯!"); | |||
LebaiHelper.GetInstance().Scene(LebaiHelper.SENCE_二次取冰淇淋杯); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10036 }); //SENCE_二次取冰淇淋杯 | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制 | |||
Wait(); | |||
LebaiHelper.GetInstance().SetValue(1); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
count++; | |||
goto p; | |||
} | |||
@@ -433,9 +473,9 @@ namespace BPASmartClient.MorkT | |||
{ | |||
//制冷模式 | |||
new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
LebaiHelper.GetInstance().SetValue(0); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }); | |||
OrderChange(order.SuborderId, ORDER_STATUS.COOKING); | |||
LebaiHelper.GetInstance().Scene(LebaiHelper.SENCE_接1号冰淇淋); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10039 }); //SENCE_接1号冰淇淋 | |||
Wait(); | |||
bool doItResult = true; | |||
//出料 | |||
@@ -451,7 +491,7 @@ namespace BPASmartClient.MorkT | |||
{ | |||
int count_1 = 0; | |||
while ((short)Status.status["CBX"] <= 86) | |||
while ((short)Status.status["GSIceCream.IceCreamMachine.CBX"] <= 86) | |||
{ | |||
Thread.Sleep(5); | |||
count_1++; | |||
@@ -460,7 +500,7 @@ namespace BPASmartClient.MorkT | |||
} | |||
IceCreamCookCheck(); | |||
} | |||
LebaiHelper.GetInstance().SetValue(1); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
} | |||
/// <summary> | |||
@@ -469,13 +509,19 @@ namespace BPASmartClient.MorkT | |||
/// <param name="order"></param> | |||
private void PutIceCream(OrderLocInfo order) | |||
{ | |||
while (LebaiHelper.GetInstance().GetInput()) | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 }, (res) => | |||
{ | |||
Thread.Sleep(500); | |||
} | |||
LebaiHelper.GetInstance().Scene(LebaiHelper.SENCE_放冰淇淋位置); | |||
if (res[0] is bool resultValue) | |||
{ | |||
while (resultValue) | |||
{ | |||
Thread.Sleep(500); | |||
} | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10043 }); //SENCE_放冰淇淋位置 | |||
Wait(); | |||
LebaiHelper.GetInstance().SetValue(1); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
//订单状态改变:完成 | |||
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); | |||
DeviceProcessLogShow($"{order.GoodsName}等待取餐"); | |||
@@ -488,9 +534,17 @@ namespace BPASmartClient.MorkT | |||
/// </summary> | |||
public void IceCreamCookCheck() | |||
{ | |||
bool result = true; | |||
int retry = 3; | |||
DateTime beginTime = DateTime.Now; | |||
while (!LebaiHelper.GetInstance().GetInput(3)) | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 } ,(res)=> | |||
{ | |||
if (res[0] is bool resultValue) | |||
{ | |||
result = resultValue; | |||
} | |||
} ); | |||
while (!result) | |||
{ | |||
if (retry <= 0 && DateTime.Now.Subtract(beginTime).TotalSeconds >= 10) | |||
{ | |||
@@ -1,4 +1,5 @@ | |||
using Robotc; | |||
using BPASmartClient.Device; | |||
using Robotc; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
@@ -8,7 +9,7 @@ using System.Threading.Tasks; | |||
namespace BPASmartClient.MorkT | |||
{ | |||
public class GLV_MorkT | |||
public class GLV_MorkT:IStatus | |||
{ | |||
/// <summary> | |||
/// 咖啡订单队列 | |||
@@ -29,10 +30,7 @@ namespace BPASmartClient.MorkT | |||
/// </summary> | |||
public OrderLocInfo MakeCoffeeOrder = new OrderLocInfo(); | |||
/// <summary> | |||
/// 获取乐百机器人的数据 | |||
/// </summary> | |||
public SignalResult lebai = new SignalResult(); | |||
/// <summary> | |||
/// 咖啡机位置是否有咖啡在制作中 | |||
@@ -98,26 +98,26 @@ namespace BPASmartClient.MorkT | |||
return temp; | |||
} | |||
internal static IC_SE GetIceCreamSE(string loc, out int sence) | |||
{ | |||
switch (loc) | |||
{ | |||
case ICE_MAIN_BATCHIN1_LOC: | |||
sence = LebaiHelper.SENCE_接1号冰淇淋; | |||
return IC_SE.SE_1; | |||
//internal static IC_SE GetIceCreamSE(string loc, out int sence) | |||
//{ | |||
// switch (loc) | |||
// { | |||
// case ICE_MAIN_BATCHIN1_LOC: | |||
// sence = LebaiHelper.SENCE_接1号冰淇淋; | |||
// return IC_SE.SE_1; | |||
case ICE_MAIN_BATCHIN2_LOC: | |||
sence = LebaiHelper.SENCE_接2号冰淇淋; | |||
return IC_SE.SE_2; | |||
// case ICE_MAIN_BATCHIN2_LOC: | |||
// sence = LebaiHelper.SENCE_接2号冰淇淋; | |||
// return IC_SE.SE_2; | |||
case ICE_MAIN_BATCHIN3_LOC: | |||
sence = LebaiHelper.SENCE_接3号冰淇淋; | |||
return IC_SE.SE_3; | |||
// case ICE_MAIN_BATCHIN3_LOC: | |||
// sence = LebaiHelper.SENCE_接3号冰淇淋; | |||
// return IC_SE.SE_3; | |||
default: | |||
sence = LebaiHelper.SENCE_接1号冰淇淋; | |||
return IC_SE.SE_1; | |||
} | |||
} | |||
// default: | |||
// sence = LebaiHelper.SENCE_接1号冰淇淋; | |||
// return IC_SE.SE_1; | |||
// } | |||
//} | |||
} | |||
} |
@@ -1,14 +1,14 @@ | |||
<UserControl x:Class="BPASmartClient.Control.MorkT_DebugView" | |||
<UserControl x:Class="BPASmartClient.MorkT.View.DebugView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.Control" | |||
xmlns:vm ="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel" | |||
xmlns:vm ="clr-namespace:BPASmartClient.MorkT.ViewModel" | |||
mc:Ignorable="d" | |||
Name="调试界面" | |||
d:DesignHeight="450" d:DesignWidth="1000" > | |||
<UserControl.DataContext> | |||
<vm:MorkT_DebugViewModel/> | |||
<vm:DebugViewModel/> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
@@ -38,6 +38,14 @@ | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="3*"/> | |||
</Grid.RowDefinitions> | |||
<StackPanel Orientation="Horizontal"> | |||
<TextBlock Text="连接状态" /> | |||
<TextBlock Text="{Binding RobotConnected}" | |||
Margin="40,0"/> | |||
<TextBlock Text="机器人模式:"/> | |||
<TextBlock Text="{Binding RobotMode}" | |||
Margin="40,0"/> | |||
</StackPanel> | |||
<TextBlock Text="连接状态" /> | |||
<TextBlock Text="{Binding RobotConnected}" | |||
Margin="120,0,0,0"/> |
@@ -13,14 +13,14 @@ using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPASmartClient.Control | |||
namespace BPASmartClient.MorkT.View | |||
{ | |||
/// <summary> | |||
/// MorkT_DebugView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class MorkT_DebugView : UserControl | |||
public partial class DebugView : UserControl | |||
{ | |||
public MorkT_DebugView() | |||
public DebugView() | |||
{ | |||
InitializeComponent(); | |||
} |
@@ -0,0 +1,226 @@ | |||
using BPASmartClient.Business; | |||
using BPASmartClient.DRCoffee; | |||
using BPASmartClient.EventBus; | |||
using BPASmartClient.GSIceCream; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.LebaiRobot; | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Model.乐白机器人; | |||
using BPASmartClient.Model.冰淇淋.Enum; | |||
using BPASmartClient.Model.咖啡机.Enum; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Threading; | |||
namespace BPASmartClient.MorkT.ViewModel | |||
{ | |||
public class DebugViewModel : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 设备ID | |||
/// </summary> | |||
int DeviceId { get; set; } | |||
#region 乐白机器人 | |||
/// <summary> | |||
/// 乐白机器人连接状态 | |||
/// </summary> | |||
public string RobotConnected { get { return _robotConnected; } set { _robotConnected = value; OnPropertyChanged(); } } | |||
private string _robotConnected { get; set; } | |||
/// <summary> | |||
/// 乐白机器人的模式状态 | |||
/// </summary> | |||
public ELebaiRModel RobotMode { get { return _robotMode; } set { _robotMode = value; OnPropertyChanged(); } } | |||
private ELebaiRModel _robotMode { get; set; } | |||
/// <summary> | |||
/// 机器人控制指令 | |||
/// </summary> | |||
public RelayCommand<object> Button_RobotControlCommand { get; set; } | |||
/// <summary> | |||
/// 机器人控制 | |||
/// </summary> | |||
/// <param name="o"></param> | |||
private void Button_RobotControl(object o) | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiControlEvent { DeviceId = DeviceId, LebaiControl = o.ToString() }); | |||
} | |||
#endregion | |||
#region 冰淇淋机器 | |||
/// <summary> | |||
/// 制作冰淇淋 | |||
/// </summary> | |||
public RelayCommand Button_MakeIceCreamCommand { get; set; } | |||
/// <summary> | |||
/// 选择冰淇淋模式 | |||
/// </summary> | |||
public RelayCommand Button_SetIceCreamModelCommand { get; set; } | |||
/// <summary> | |||
/// 冰淇淋连接状态 | |||
/// </summary> | |||
public string IceCreamConnected { get { return _iceCreamConnected; } set { _iceCreamConnected = value; OnPropertyChanged(); } } | |||
private string _iceCreamConnected { get; set; } | |||
/// <summary> | |||
/// 预冷温度 | |||
/// </summary> | |||
public short YLWD { get { return _yLWD; } set { _yLWD = value; OnPropertyChanged(); } } | |||
private short _yLWD { get; set; } | |||
/// <summary> | |||
/// 回气温度 | |||
/// </summary> | |||
public short HQWD { get { return _hQWD; } set { _hQWD = value; OnPropertyChanged(); } } | |||
private short _hQWD { get; set; } | |||
/// <summary> | |||
/// 环境温度 | |||
/// </summary> | |||
public short HJWD { get { return _hJWD; } set { _hJWD = value; OnPropertyChanged(); } } | |||
private short _hJWD { get; set; } | |||
/// <summary> | |||
/// 电流 | |||
/// </summary> | |||
public short DL { get { return _DL; } set { _DL = value; OnPropertyChanged(); } } | |||
private short _DL { get; set; } | |||
/// <summary> | |||
/// 电压 | |||
/// </summary> | |||
public short DY { get { return _dy; } set { _dy = value; OnPropertyChanged(); } } | |||
private short _dy { get; set; } | |||
/// <summary> | |||
/// 当前模式 | |||
/// </summary> | |||
public MORKI_MODE CurrentMode { get { return _CurrentMode; } set { _CurrentMode = value; OnPropertyChanged(); } } | |||
private MORKI_MODE _CurrentMode; | |||
/// <summary> | |||
/// 故障 | |||
/// </summary> | |||
public MORKI_FAULT IceCreamFault { get { return _IceCreamFault; } set { _IceCreamFault = value; OnPropertyChanged(); } } | |||
private MORKI_FAULT _IceCreamFault { get; set; } | |||
/// <summary> | |||
/// 成型比 | |||
/// </summary> | |||
public byte CXB { get { return _cXB; } set { _cXB = value; OnPropertyChanged(); } } | |||
private byte _cXB { get; set; } | |||
/// <summary> | |||
/// 打料完成状态 | |||
/// </summary> | |||
public string DLCompleted { get { return _dLCompleted; } set { _dLCompleted = value; OnPropertyChanged(); } } | |||
private string _dLCompleted { get; set; } | |||
public List<string> IceCreamModes { get; set; } = new List<string>(); | |||
public string SelecteIceCreamdMode { get; set; } | |||
private void Button_MakeIceCream() | |||
{ | |||
} | |||
private void Button_SetIceCreamModel() | |||
{ | |||
MORKI_MODE mORKI_MODE = (MORKI_MODE)Enum.Parse(typeof(MORKI_MODE), SelecteIceCreamdMode); | |||
new GSIceCream_ModeSetEvent() { DeviceId = DeviceId, Mode = mORKI_MODE }.Publish(); | |||
} | |||
#endregion | |||
#region 咖啡机 | |||
/// <summary> | |||
/// 咖啡机连接状态 | |||
/// </summary> | |||
public string CoffeeConnected { get { return _coffeeConnected; } set { _coffeeConnected = value; OnPropertyChanged(); } } | |||
private string _coffeeConnected { get; set; } | |||
/// <summary> | |||
/// 咖啡机状态 | |||
/// </summary> | |||
public DrCoffeeStatus CoffeeStatus { get { return _coffeeStatus; } set { _coffeeStatus = value; OnPropertyChanged(); } } | |||
private DrCoffeeStatus _coffeeStatus { get; set; } | |||
/// <summary> | |||
/// 应用状态 | |||
/// </summary> | |||
public DrCoffeeAppStatus AppStatus { get { return _appStatus; } set { _appStatus = value; OnPropertyChanged(); } } | |||
private DrCoffeeAppStatus _appStatus { get; set; } | |||
/// <summary> | |||
/// 告警 | |||
/// </summary> | |||
public DrCoffeeWarning Warning { get { return _warning; } set { _warning = value; OnPropertyChanged(); } } | |||
public DrCoffeeWarning _warning { get; set; } | |||
/// <summary> | |||
/// 故障信息 | |||
/// </summary> | |||
public DrCoffeeFault CaffeeFault { get { return _caffeeFault; } set { _caffeeFault = value; OnPropertyChanged(); } } | |||
public DrCoffeeFault _caffeeFault { get; set; } | |||
public List<string> Coffees { get; set; } = new List<string>(); | |||
public string SelectedCoffee { get; set; } | |||
public List<string> CoffeeCmds { get; set; } = new List<string>(); | |||
public string SelectedCoffeeCmd { get; set; } | |||
#endregion | |||
Dictionary<string, object> CurrentData { get; set; } | |||
public DebugViewModel() | |||
{ | |||
Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl); | |||
Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream); | |||
Button_SetIceCreamModelCommand = new RelayCommand(Button_SetIceCreamModel); | |||
foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode))) | |||
{ | |||
Coffees.Add(code.ToString()); | |||
} | |||
SelectedCoffee = Coffees[0]; | |||
foreach (DrCoffeeCommCmd code in Enum.GetValues(typeof(DrCoffeeCommCmd))) | |||
{ | |||
CoffeeCmds.Add(code.ToString()); | |||
} | |||
SelectedCoffeeCmd = CoffeeCmds[0]; | |||
foreach (MORKI_MODE code in Enum.GetValues(typeof(MORKI_MODE))) | |||
{ | |||
IceCreamModes.Add(code.ToString()); | |||
} | |||
SelecteIceCreamdMode = IceCreamModes[0]; | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device => | |||
{ | |||
CurrentData?.Clear(); | |||
if (device.Name == "MorkT") CurrentData = device.Status.GetStatus(); | |||
DeviceId = device.DeviceId; | |||
}); | |||
if (CurrentData != null && CurrentData.Count != 0) | |||
{ | |||
RobotConnected = (bool)CurrentData["Lebai.LebaiRobot.IsConnected"] ? "已连接" : "未连接"; | |||
//IceCreamConnected = (bool)CurrentData["GSIceCream.IceCreamMachine.IsConnected"] ? "已连接" : "未连接"; | |||
//CoffeeConnected = (bool)CurrentData["GSIceCream.IceCreamMachine.IsConnected"] ? "已连接" : "未连接"; | |||
RobotMode = (ELebaiRModel)CurrentData["Lebai.LebaiRobot.RobotMode"]; | |||
//CoffeeStatus = (DrCoffeeStatus)CurrentData["DRCoffee.CoffeeMachine.Status"]; | |||
//AppStatus = (DrCoffeeAppStatus)CurrentData["DRCoffee.CoffeeMachine.AppStatus"]; | |||
//Warning = (DrCoffeeWarning)CurrentData["DRCoffee.CoffeeMachine.Warning"]; | |||
//CaffeeFault = (DrCoffeeFault)CurrentData["DRCoffee.CoffeeMachine.Fault"]; | |||
//YLWD = (short)CurrentData["GSIceCream.IceCreamMachine.YLWD"]; | |||
//HQWD = (short)CurrentData["GSIceCream.IceCreamMachine.HQWD"]; | |||
//HJWD = (short)CurrentData["GSIceCream.IceCreamMachine.HJWD"]; | |||
//DL = (short)CurrentData["GSIceCream.IceCreamMachine.DL"]; | |||
//DY = (short)CurrentData["GSIceCream.IceCreamMachine.DY"]; | |||
//CurrentMode = (MORKI_MODE)CurrentData["GSIceCream.IceCreamMachine.CurrentMode"]; | |||
//IceCreamFault = (MORKI_FAULT)CurrentData["GSIceCream.IceCreamMachine.Fault"]; | |||
//CXB = (byte)CurrentData["GSIceCream.IceCreamMachine.CXB"]; | |||
//DLCompleted = (bool)CurrentData["GSIceCream.IceCreamMachine.DLCompleted"] ? "打料完成" : "打料中"; | |||
} | |||
Thread.Sleep(500); | |||
}), "MorkT-状态刷新"); | |||
} | |||
} | |||
} |
@@ -224,7 +224,7 @@ namespace BPASmartClient.SCChip | |||
public override void Init() | |||
{ | |||
commProxy = new SerialPortClient(PortName,(BaudRates)Enum.Parse(typeof(BaudRates),BaudRate)); | |||
commProxy = new SerialPortClient(communicationPar.SerialPort,(BaudRates)communicationPar.BaudRate); | |||
commProxy.SetDataStorage(dataStorage); | |||
//STM32F103RCT6单片机下杯 | |||
@@ -1,4 +1,5 @@ | |||
| |||
using BPASmartClient.Business; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.IoT; | |||
using DataVAPI.Tool.IOT; | |||
@@ -22,7 +23,7 @@ namespace BPASmartClient.ViewModel | |||
deviceTable = new ObservableCollection<DeviceTable>(); | |||
device = new DeviceTable(); | |||
deviceTableSelectedItem = new DeviceTable(); | |||
ApiURL = System.Configuration.ConfigurationManager.AppSettings["DataVServiceUri"].ToString(); | |||
ApiURL = InternetInfo.DataVApiAddress; | |||
Refresh(); | |||
} | |||
#endregion | |||
@@ -1,4 +1,5 @@ | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.Business; | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.IoT; | |||
@@ -51,7 +52,7 @@ namespace BPASmartClient.ViewModel | |||
#region 函数 | |||
public void Init() | |||
{ | |||
DataVApiAddress = System.Configuration.ConfigurationManager.AppSettings["DataVServiceUri"].ToString(); | |||
DataVApiAddress = InternetInfo.DataVApiAddress; | |||
LogDataFile = new ObservableCollection<FileModel>(); | |||
//查询 | |||
@@ -1,212 +0,0 @@ | |||
using BPASmartClient.Business; | |||
using BPASmartClient.Device; | |||
using BPASmartClient.DRCoffee; | |||
using BPASmartClient.EventBus; | |||
using BPASmartClient.GSIceCream; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Lebai; | |||
using BPASmartClient.LebaiRobot; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Model.冰淇淋.Enum; | |||
using BPASmartClient.Model.咖啡机.Enum; | |||
using BPASmartClient.SCChip; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.ViewModel | |||
{ | |||
public class MorkT_DebugViewModel : ObservableObject | |||
{ | |||
#region 乐白机器人 | |||
/// <summary> | |||
/// 乐白机器人连接状态 | |||
/// </summary> | |||
public string RobotConnected { get; set; } | |||
/// <summary> | |||
/// 乐白机器人的模式状态 | |||
/// </summary> | |||
public ELebaiRModel RobotMode { get; set; } | |||
/// <summary> | |||
/// 机器人控制指令 | |||
/// </summary> | |||
public RelayCommand<object> Button_RobotControlCommand { get; set; } | |||
/// <summary> | |||
/// 机器人控制 | |||
/// </summary> | |||
/// <param name="o"></param> | |||
private void Button_RobotControl(object o) | |||
{ | |||
ActionManage.GetInstance.Send("调试控制-机器人控制",o.ToString()); | |||
} | |||
#endregion | |||
#region 冰淇淋机器 | |||
/// <summary> | |||
/// 制作冰淇淋 | |||
/// </summary> | |||
public RelayCommand Button_MakeIceCreamCommand { get; set; } | |||
/// <summary> | |||
/// 选择冰淇淋模式 | |||
/// </summary> | |||
public RelayCommand Button_SetIceCreamModelCommand { get; set; } | |||
/// <summary> | |||
/// 冰淇淋连接状态 | |||
/// </summary> | |||
public string IceCreamConnected { get; set; } | |||
/// <summary> | |||
/// 预冷温度 | |||
/// </summary> | |||
public short YLWD { get; set; } | |||
/// <summary> | |||
/// 回气温度 | |||
/// </summary> | |||
public short HQWD { get; set; } | |||
/// <summary> | |||
/// 环境温度 | |||
/// </summary> | |||
public short HJWD { get; set; } | |||
/// <summary> | |||
/// 电流 | |||
/// </summary> | |||
public short DL { get; set; } | |||
/// <summary> | |||
/// 电压 | |||
/// </summary> | |||
public short DY { get; set; } | |||
/// <summary> | |||
/// 当前模式 | |||
/// </summary> | |||
public MORKI_MODE CurrentMode { get; set; } | |||
/// <summary> | |||
/// 故障 | |||
/// </summary> | |||
public MORKI_FAULT IceCreamFault { get; set; } | |||
/// <summary> | |||
/// 成型比 | |||
/// </summary> | |||
public byte CXB { get; set; } | |||
/// <summary> | |||
/// 打料完成状态 | |||
/// </summary> | |||
public string DLCompleted { get; set; } | |||
public List<string> IceCreamModes { get; set; } = new List<string>(); | |||
public string SelecteIceCreamdMode { get; set; } | |||
private void Button_MakeIceCream() | |||
{ | |||
} | |||
private void Button_SetIceCreamModel() | |||
{ | |||
MORKI_MODE mORKI_MODE = (MORKI_MODE)Enum.Parse(typeof(MORKI_MODE), SelecteIceCreamdMode); | |||
new GSIceCream_ModeSetEvent() { Mode = mORKI_MODE }.Publish(); | |||
} | |||
#endregion | |||
#region 咖啡机 | |||
/// <summary> | |||
/// 咖啡机连接状态 | |||
/// </summary> | |||
public string CoffeeConnected { get; set; } | |||
/// <summary> | |||
/// 咖啡机状态 | |||
/// </summary> | |||
public DrCoffeeStatus CoffeeStatus { get; set; } | |||
/// <summary> | |||
/// 应用状态 | |||
/// </summary> | |||
public DrCoffeeAppStatus AppStatus { get; set; } | |||
/// <summary> | |||
/// 告警 | |||
/// </summary> | |||
public DrCoffeeWarning Warning { get; set; } | |||
/// <summary> | |||
/// 故障信息 | |||
/// </summary> | |||
public DrCoffeeFault CaffeeFault { get; set; } | |||
public List<string> Coffees { get; set; } = new List<string>(); | |||
public string SelectedCoffee { get; set; } | |||
public List<string> CoffeeCmds { get; set; } = new List<string>(); | |||
public string SelectedCoffeeCmd { get; set; } | |||
#endregion | |||
Dictionary<string, object> CurrentData { get; set; } | |||
public MorkT_DebugViewModel() | |||
{ | |||
Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl); | |||
Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream); | |||
Button_SetIceCreamModelCommand = new RelayCommand(Button_SetIceCreamModel); | |||
foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode))) | |||
{ | |||
Coffees.Add(code.ToString()); | |||
} | |||
SelectedCoffee = Coffees[0]; | |||
foreach (DrCoffeeCommCmd code in Enum.GetValues(typeof(DrCoffeeCommCmd))) | |||
{ | |||
CoffeeCmds.Add(code.ToString()); | |||
} | |||
SelectedCoffeeCmd = CoffeeCmds[0]; | |||
foreach (MORKI_MODE code in Enum.GetValues(typeof(MORKI_MODE))) | |||
{ | |||
IceCreamModes.Add(code.ToString()); | |||
} | |||
SelecteIceCreamdMode = IceCreamModes[0]; | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device => | |||
{ | |||
if (device.Name == "MorkT") CurrentData = device.Status.GetStatus(); | |||
}); | |||
if (CurrentData != null && CurrentData.Count != 0) | |||
{ | |||
RobotConnected = (bool)CurrentData["Lebai.LebaiRobot.Connected"] ? "已连接" : "未连接"; | |||
IceCreamConnected = (bool)CurrentData["GSIceCream.IceCreamMachine.IsConnected"] ? "已连接" : "未连接"; | |||
CoffeeConnected = (bool)CurrentData["GSIceCream.IceCreamMachine.IsConnected"] ? "已连接" : "未连接"; | |||
RobotMode = (ELebaiRModel)CurrentData["Lebai.LebaiRobot.RobotMode"]; | |||
CoffeeStatus = (DrCoffeeStatus)CurrentData["DRCoffee.CoffeeMachine.Status"]; | |||
AppStatus = (DrCoffeeAppStatus)CurrentData["DRCoffee.CoffeeMachine.AppStatus"]; | |||
Warning = (DrCoffeeWarning)CurrentData["DRCoffee.CoffeeMachine.Warning"]; | |||
CaffeeFault = (DrCoffeeFault)CurrentData["DRCoffee.CoffeeMachine.Fault"]; | |||
YLWD = (short)CurrentData["GSIceCream.IceCreamMachine.YLWD"]; | |||
HQWD = (short)CurrentData["GSIceCream.IceCreamMachine.HQWD"]; | |||
HJWD = (short)CurrentData["GSIceCream.IceCreamMachine.HJWD"]; | |||
DL = (short)CurrentData["GSIceCream.IceCreamMachine.DL"]; | |||
DY = (short)CurrentData["GSIceCream.IceCreamMachine.DY"]; | |||
CurrentMode = (MORKI_MODE)CurrentData["GSIceCream.IceCreamMachine.CurrentMode"]; | |||
IceCreamFault = (MORKI_FAULT)CurrentData["GSIceCream.IceCreamMachine.Fault"]; | |||
CXB = (byte)CurrentData["GSIceCream.IceCreamMachine.CXB"]; | |||
DLCompleted = (bool)CurrentData["GSIceCream.IceCreamMachine.DLCompleted"] ? "打料完成" : "打料中"; | |||
} | |||
Thread.Sleep(500); | |||
}), "MorkT-状态刷新"); | |||
} | |||
} | |||
} |
@@ -82,11 +82,13 @@ | |||
Header="阿里连接维护" | |||
Tag="DataVView" /> | |||
<Separator /> | |||
<MenuItem | |||
Click="MenuItem_Click" | |||
<MenuItem | |||
Click="Debug_Click" | |||
FontSize="12" | |||
Header="调试界面" | |||
Tag="MorkT_DebugView" /> | |||
Tag="DebugView" /> | |||
</MenuItem> | |||
<MenuItem Header="状态监视"> | |||
<MenuItem | |||
@@ -13,8 +13,10 @@ using BPASmartClient.Model.冰淇淋.Enum; | |||
using BPASmartClient.Model.咖啡机.Enum; | |||
using BPASmartClient.Peripheral; | |||
using BPASmartClient.ViewModel; | |||
using Newtonsoft.Json; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.IO; | |||
using System.Linq; | |||
using System.Reflection; | |||
@@ -73,9 +75,9 @@ namespace BPASmartClient | |||
ThreadManage.GetInstance().Start(new Action(() => | |||
{ | |||
GetDevices(); | |||
mainConsole = new MainConsole(); | |||
mainConsole.Start(); | |||
GetDevices(); | |||
}), "启动主控制台", false); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
@@ -137,6 +139,24 @@ namespace BPASmartClient | |||
} | |||
})); | |||
}), "IotBroadcast"); | |||
//var text = TextHelper.GetInstance.ReadTextInfo("StartShop", "DeviceConfig"); | |||
//string path = $"{LocaPath.GetInstance().GetDeviceConfigPath}{text}.json"; | |||
//if (File.Exists(path)) | |||
//{ | |||
// string JsonString = File.ReadAllText(path); | |||
// var result = JsonConvert.DeserializeObject<ObservableCollection<DeviceConfigModelJson>>(JsonString); | |||
// if (result != null) | |||
// { | |||
// foreach (var shop in result)//店铺集合 | |||
// { | |||
// foreach (var device in shop.deviceModels)//设备集合 | |||
// { | |||
// dv.Items.Add(new MenuItem { Header = device.DeviceModule }); | |||
// } | |||
// } | |||
// } | |||
//} | |||
} | |||
/// <summary> | |||
/// 获取设备集合 | |||
@@ -200,10 +220,9 @@ namespace BPASmartClient | |||
}); | |||
}); | |||
} | |||
#endregion | |||
#region Click | |||
} | |||
/// <summary> | |||
/// 菜单切换栏 | |||
/// </summary> | |||
@@ -225,6 +244,24 @@ namespace BPASmartClient | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient 中引发错误,MainWindow.xaml.cs 类MenuItem_Click(),描述:[{ex.Message}]"); | |||
} | |||
} | |||
private void Debug_Click(object sender,RoutedEventArgs e) | |||
{ | |||
try | |||
{ | |||
if (sender is MenuItem) | |||
{ | |||
Type type = Assembly.Load("BPASmartClient.MorkT").GetType("BPASmartClient.MorkT.View.DebugView"); | |||
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes); | |||
contentRegion.Content = (FrameworkElement)cti.Invoke(null); | |||
Title.Text = (sender as MenuItem).Header?.ToString() + "界面"; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient 中引发错误,MainWindow.xaml.cs 类MenuItem_Click(),描述:[{ex.Message}]"); | |||
} | |||
} | |||
#endregion | |||
#region 公用 | |||