@@ -12,6 +12,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<None Remove="Fonts\Debug\iconfont.ttf" /> | |||||
<None Remove="Fonts\iconfont.ttf" /> | <None Remove="Fonts\iconfont.ttf" /> | ||||
<None Remove="Image\bg.png" /> | <None Remove="Image\bg.png" /> | ||||
<None Remove="Image\btn_close.png" /> | <None Remove="Image\btn_close.png" /> | ||||
@@ -172,6 +173,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<Resource Include="Fonts\Debug\iconfont.ttf" /> | |||||
<Resource Include="Image\btn_close.png" /> | <Resource Include="Image\btn_close.png" /> | ||||
<Resource Include="Image\ComboBoxPopSelect.png" /> | <Resource Include="Image\ComboBoxPopSelect.png" /> | ||||
<Resource Include="Image\ComboBoxSelect.png" /> | <Resource Include="Image\ComboBoxSelect.png" /> | ||||
@@ -141,14 +141,13 @@ namespace BPASmartClient.DRCoffee | |||||
/// <param name="package"></param> | /// <param name="package"></param> | ||||
public void ProcessPackage(DrCoffeePackage package) | public void ProcessPackage(DrCoffeePackage package) | ||||
{ | { | ||||
lastRefreshTime = DateTime.Now; | |||||
IsConnected = OnLine; | |||||
status["CoffeeIsConnected"] = OnLine; | |||||
if (((DrCoffeeStatus)status["CoffeeStatus"]) == DrCoffeeStatus.Running && package.Status != DrCoffeeStatus.Running) | if (((DrCoffeeStatus)status["CoffeeStatus"]) == DrCoffeeStatus.Running && package.Status != DrCoffeeStatus.Running) | ||||
{ | { | ||||
status["CoffeeStatus"] = package.Status; | 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; | else status["CoffeeStatus"] = package.Status; | ||||
status["CoffeeAppStatus"] = package.ApplicationStatus; | status["CoffeeAppStatus"] = package.ApplicationStatus; | ||||
@@ -343,7 +343,7 @@ namespace BPASmartClient.Device | |||||
{ | { | ||||
MainTask(); | MainTask(); | ||||
Thread.Sleep(10); | Thread.Sleep(10); | ||||
}), $"MainTask:{DeviceId}"); | |||||
}) ,$"MainTask:{DeviceId}",true); | |||||
#endregion | #endregion | ||||
#region 设备状态监控 | #region 设备状态监控 | ||||
@@ -35,7 +35,6 @@ namespace BPASmartClient.IoT | |||||
public DataVClient() | public DataVClient() | ||||
{ | { | ||||
DataVApiAddress = InternetInfo.DataVApiAddress; | DataVApiAddress = InternetInfo.DataVApiAddress; | ||||
//ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString(); | |||||
ClientId = Plugin.GetInstance().GetPlugin<ConfigMgr>().ClientId.ToString(); | ClientId = Plugin.GetInstance().GetPlugin<ConfigMgr>().ClientId.ToString(); | ||||
DeviceName = System.Configuration.ConfigurationManager.AppSettings["DeviceName"].ToString(); | DeviceName = System.Configuration.ConfigurationManager.AppSettings["DeviceName"].ToString(); | ||||
ProductKey = System.Configuration.ConfigurationManager.AppSettings["ProductKey"].ToString(); | ProductKey = System.Configuration.ConfigurationManager.AppSettings["ProductKey"].ToString(); | ||||
@@ -71,6 +70,7 @@ namespace BPASmartClient.IoT | |||||
/// 客户端ID | /// 客户端ID | ||||
/// </summary> | /// </summary> | ||||
public string ClientId { set; get; } | public string ClientId { set; get; } | ||||
public List<int> ListDeviceId { set; get; } = new List<int>(); | |||||
/// <summary> | /// <summary> | ||||
/// MQTT上报集合 | /// MQTT上报集合 | ||||
/// </summary> | /// </summary> | ||||
@@ -200,7 +200,17 @@ namespace BPASmartClient.IoT | |||||
string message = string.Empty; | string message = string.Empty; | ||||
if (StartupMode == "API") | if (StartupMode == "API") | ||||
{ | { | ||||
if (DeviceDataV.Initialize(DataVApiAddress, ClientId, "", ref message)) | |||||
while (ListDeviceId.Count == 0) | |||||
{ | |||||
Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.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; | ProductKey = DeviceDataV.deviceTable.productkey; | ||||
DeviceName = DeviceDataV.deviceTable.devicename; | DeviceName = DeviceDataV.deviceTable.devicename; | ||||
@@ -48,6 +48,7 @@ namespace BPASmartClient.Lebai | |||||
status["RobotIsConnected"] = LebaiHelper.GetInstance().IsConnected; | status["RobotIsConnected"] = LebaiHelper.GetInstance().IsConnected; | ||||
status["RobotOK"] = LebaiHelper.GetInstance().GetValueAsync().Ok; | status["RobotOK"] = LebaiHelper.GetInstance().GetValueAsync().Ok; | ||||
status["RobotValue"] = LebaiHelper.GetInstance().GetValueAsync().Value; | status["RobotValue"] = LebaiHelper.GetInstance().GetValueAsync().Value; | ||||
if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] =(ELebaiRModel)LebaiHelper.GetInstance().robotData.RobotMode.Mode; | |||||
status["RobotValue1"] = LebaiHelper.GetInstance().GetValueAsync(1).Value; | status["RobotValue1"] = LebaiHelper.GetInstance().GetValueAsync(1).Value; | ||||
status["GetInput"] = LebaiHelper.GetInstance().GetInput(); | status["GetInput"] = LebaiHelper.GetInstance().GetInput(); | ||||
status["GetInput2"] = LebaiHelper.GetInstance().GetInput(2); | status["GetInput2"] = LebaiHelper.GetInstance().GetInput(2); | ||||
@@ -9,6 +9,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" /> | <ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | <ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.DRCoffee\BPASmartClient.DRCoffee.csproj" /> | <ProjectReference Include="..\BPASmartClient.DRCoffee\BPASmartClient.DRCoffee.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" /> | <ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" /> | ||||
@@ -45,7 +45,7 @@ namespace BPASmartClient.MorkT | |||||
morkT.MakeCoffeeOrder.OrderStatus = 1; | morkT.MakeCoffeeOrder.OrderStatus = 1; | ||||
}); | }); | ||||
int i = 0; | int i = 0; | ||||
EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent { DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); | |||||
MessageLog.GetInstance.Show("MORKT 设备初始化完成"); | MessageLog.GetInstance.Show("MORKT 设备初始化完成"); | ||||
@@ -71,7 +71,21 @@ namespace BPASmartClient.MorkT | |||||
public override void MainTask() | 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(); | MakeCoffeeProcess(); | ||||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 },(o)=> | EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 },(o)=> | ||||
{ | { | ||||
@@ -84,7 +98,8 @@ namespace BPASmartClient.MorkT | |||||
} | } | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
public override void ReadData() | public override void ReadData() | ||||
@@ -371,6 +386,7 @@ namespace BPASmartClient.MorkT | |||||
{ | { | ||||
DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]"); | DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]"); | ||||
GetAndCheeckCoffe(orderLoc);//取咖啡杯 | GetAndCheeckCoffe(orderLoc);//取咖啡杯 | ||||
if (!morkT.GetCoffeeCup) return; | |||||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10051}); //接咖啡后回原点 | EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10051}); //接咖啡后回原点 | ||||
Wait(); | Wait(); | ||||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | 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 }); | EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | ||||
//订单状态改变:完成 | //订单状态改变:完成 | ||||
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); | OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); | ||||
morkT.waitMorkOrder = order; | |||||
DeviceProcessLogShow($"{order.GoodsName}等待取餐"); | DeviceProcessLogShow($"{order.GoodsName}等待取餐"); | ||||
//WaitTakeMealOrder.Enqueue(order); | //WaitTakeMealOrder.Enqueue(order); | ||||
@@ -454,6 +472,7 @@ namespace BPASmartClient.MorkT | |||||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10050 }); //SENCE_咖啡杯回原点 | EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10050 }); //SENCE_咖啡杯回原点 | ||||
Wait(); | Wait(); | ||||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | ||||
morkT.GetCoffeeCup = false; | |||||
return; | return; | ||||
} | } | ||||
DeviceProcessLogShow("执行二次取咖啡杯"); | DeviceProcessLogShow("执行二次取咖啡杯"); | ||||
@@ -464,6 +483,7 @@ namespace BPASmartClient.MorkT | |||||
count++; | count++; | ||||
goto p; | goto p; | ||||
} | } | ||||
morkT.GetCoffeeCup = true; | |||||
DeviceProcessLogShow("取咖啡杯完成"); | DeviceProcessLogShow("取咖啡杯完成"); | ||||
} | } | ||||
@@ -482,40 +502,45 @@ namespace BPASmartClient.MorkT | |||||
/// </summary> | /// </summary> | ||||
private void MakeIceCreamProcess() | 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(); | GetIceCreamCup(); | ||||
CheckICeCreaCup(); | CheckICeCreaCup(); | ||||
GetIceCream(order); | |||||
PutIceCream(order); | |||||
if(morkT.GetIceCreamCup) | |||||
{ | |||||
GetIceCream(order); | |||||
PutIceCream(order); | |||||
} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -572,6 +601,7 @@ namespace BPASmartClient.MorkT | |||||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10049 }); //SENCE_冰淇淋杯回原点 | EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10049 }); //SENCE_冰淇淋杯回原点 | ||||
Wait(); | Wait(); | ||||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | ||||
morkT.GetIceCreamCup = false; | |||||
return; | return; | ||||
} | } | ||||
DeviceProcessLogShow($"执行{count}次取冰淇淋杯!"); | DeviceProcessLogShow($"执行{count}次取冰淇淋杯!"); | ||||
@@ -582,6 +612,7 @@ namespace BPASmartClient.MorkT | |||||
count++; | count++; | ||||
goto p; | goto p; | ||||
} | } | ||||
morkT.GetIceCreamCup = true; | |||||
DeviceProcessLogShow("冰淇淋杯检测完成"); | DeviceProcessLogShow("冰淇淋杯检测完成"); | ||||
} | } | ||||
@@ -592,34 +623,43 @@ namespace BPASmartClient.MorkT | |||||
private void GetIceCream(OrderLocInfo order) | 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 }); | EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }); | ||||
OrderChange(order.SuborderId, ORDER_STATUS.COOKING); | OrderChange(order.SuborderId, ORDER_STATUS.COOKING); | ||||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10039 }); //SENCE_接1号冰淇淋 | EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10039 }); //SENCE_接1号冰淇淋 | ||||
Wait(); | Wait(); | ||||
bool doItResult = true; | 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 }); | EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | ||||
} | } | ||||
@@ -629,21 +669,25 @@ namespace BPASmartClient.MorkT | |||||
/// <param name="order"></param> | /// <param name="order"></param> | ||||
private void PutIceCream(OrderLocInfo order) | 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_放冰淇淋位置 | EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10043 }); //SENCE_放冰淇淋位置 | ||||
Wait(); | Wait(); | ||||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | ||||
//订单状态改变:完成 | //订单状态改变:完成 | ||||
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); | OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); | ||||
morkT.waitMorkOrder = order; | |||||
DeviceProcessLogShow($"{order.GoodsName}等待取餐"); | DeviceProcessLogShow($"{order.GoodsName}等待取餐"); | ||||
//WaitTakeMealOrder.Enqueue(order); | //WaitTakeMealOrder.Enqueue(order); | ||||
@@ -25,6 +25,10 @@ namespace BPASmartClient.MorkT | |||||
/// </summary> | /// </summary> | ||||
public ConcurrentQueue<OrderLocInfo> morkOrderPushesIceCream = new ConcurrentQueue<OrderLocInfo>(); | public ConcurrentQueue<OrderLocInfo> morkOrderPushesIceCream = new ConcurrentQueue<OrderLocInfo>(); | ||||
/// <summary> | /// <summary> | ||||
/// 等待取餐订单 | |||||
/// </summary> | |||||
public OrderLocInfo waitMorkOrder = null; | |||||
/// <summary> | |||||
/// 物料存放位置 | /// 物料存放位置 | ||||
/// </summary> | /// </summary> | ||||
public Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>(); | public Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>(); | ||||
@@ -44,6 +48,14 @@ namespace BPASmartClient.MorkT | |||||
/// 冰淇淋机器出料口传感器检测 | /// 冰淇淋机器出料口传感器检测 | ||||
/// </summary> | /// </summary> | ||||
public bool IceIsOK = true; | public bool IceIsOK = true; | ||||
/// <summary> | |||||
/// 去咖啡杯成功 | |||||
/// </summary> | |||||
public bool GetCoffeeCup; | |||||
/// <summary> | |||||
/// 取冰淇淋杯成功 | |||||
/// </summary> | |||||
public bool GetIceCreamCup; | |||||
#region | #region | ||||
@@ -6,7 +6,7 @@ | |||||
xmlns:vm ="clr-namespace:BPASmartClient.MorkT.ViewModel" | xmlns:vm ="clr-namespace:BPASmartClient.MorkT.ViewModel" | ||||
mc:Ignorable="d" | mc:Ignorable="d" | ||||
Name="调试界面" | Name="调试界面" | ||||
d:DesignHeight="450" d:DesignWidth="1000" > | |||||
d:DesignHeight="500" d:DesignWidth="1000" Unloaded="Dubug_Unloaded"> | |||||
<UserControl.DataContext> | <UserControl.DataContext> | ||||
<vm:DebugViewModel/> | <vm:DebugViewModel/> | ||||
</UserControl.DataContext> | </UserControl.DataContext> | ||||
@@ -20,12 +20,13 @@ | |||||
</UserControl.Resources> | </UserControl.Resources> | ||||
<Grid> | <Grid> | ||||
<Grid.ColumnDefinitions> | <Grid.ColumnDefinitions> | ||||
<ColumnDefinition Width="*"/> | |||||
<ColumnDefinition Width="*"/> | |||||
<ColumnDefinition Width="10*"/> | |||||
<ColumnDefinition Width="10*"/> | |||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
<RowDefinition Height="9*"/> | |||||
<RowDefinition Height="10*"/> | |||||
<RowDefinition Height="14*"/> | |||||
<RowDefinition Height="6*"/> | |||||
<RowDefinition Height="20*"/> | |||||
</Grid.RowDefinitions> | </Grid.RowDefinitions> | ||||
<GroupBox Grid.ColumnSpan="2" | <GroupBox Grid.ColumnSpan="2" | ||||
@@ -81,7 +82,7 @@ | |||||
</ListBox> | </ListBox> | ||||
</Grid> | </Grid> | ||||
</GroupBox> | </GroupBox> | ||||
<GroupBox Grid.Row="1" | |||||
<GroupBox Grid.Row="2" | |||||
FontFamily="楷体" | FontFamily="楷体" | ||||
FontSize="20" | FontSize="20" | ||||
Header=" 冰淇淋机器 "> | Header=" 冰淇淋机器 "> | ||||
@@ -172,7 +173,7 @@ | |||||
</StackPanel> | </StackPanel> | ||||
</Grid> | </Grid> | ||||
</GroupBox> | </GroupBox> | ||||
<GroupBox Grid.Row="1" Grid.Column="1" | |||||
<GroupBox Grid.Row="2" Grid.Column="1" | |||||
FontFamily="楷体" | FontFamily="楷体" | ||||
FontSize="20" | FontSize="20" | ||||
Header=" 咖啡机"> | Header=" 咖啡机"> | ||||
@@ -203,13 +204,13 @@ | |||||
<ColumnDefinition Width="171" /> | <ColumnDefinition Width="171" /> | ||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<TextBlock Height="23" Width="100" FontSize="18" HorizontalAlignment="Center">咖啡机状态</TextBlock> | <TextBlock Height="23" Width="100" FontSize="18" HorizontalAlignment="Center">咖啡机状态</TextBlock> | ||||
<TextBlock FontSize="18" | |||||
<TextBlock FontSize="18" | |||||
Grid.Column="1" | Grid.Column="1" | ||||
Text="{Binding CoffeeStatus}" Height="23" Width="0" /> | |||||
Text="{Binding CoffeeStatus}" Height="23" /> | |||||
<TextBlock Grid.Column="2" Height="23" Width="80" FontSize="18">应用状态</TextBlock> | <TextBlock Grid.Column="2" Height="23" Width="80" FontSize="18">应用状态</TextBlock> | ||||
<TextBlock FontSize="18" | <TextBlock FontSize="18" | ||||
Grid.Column="3" | Grid.Column="3" | ||||
Text="{Binding AppStatus}" Height="23" Width="100" /> | |||||
Text="{Binding AppStatus}" Height="23"/> | |||||
<TextBlock Grid.Row="1" Grid.Column="0" Height="22" Width="80" FontSize="18">告警信息</TextBlock> | <TextBlock Grid.Row="1" Grid.Column="0" Height="22" Width="80" FontSize="18">告警信息</TextBlock> | ||||
<TextBlock FontSize="15" | <TextBlock FontSize="15" | ||||
Grid.Row="1" | Grid.Row="1" | ||||
@@ -248,5 +249,32 @@ | |||||
</StackPanel> | </StackPanel> | ||||
</Grid> | </Grid> | ||||
</GroupBox> | </GroupBox> | ||||
<GroupBox Header="单片机控制" | |||||
FontSize="18" | |||||
Grid.Row="1" Grid.ColumnSpan="2" | |||||
Margin="0,0,0,10"> | |||||
<StackPanel Orientation="Horizontal" | |||||
VerticalAlignment="Center" > | |||||
<Button Content="咖啡杯落杯" | |||||
Command="{Binding Button_CupControlCommand}" | |||||
CommandParameter="CUP_COFFEE" | |||||
Margin="0,0,50,0"/> | |||||
<Button Content="冰淇淋杯落杯" | |||||
Command="{Binding Button_CupControlCommand}" | |||||
CommandParameter="CUP_ICECREAM" | |||||
/> | |||||
<Button Content="单片机冰淇淋制冷" | |||||
Command="{Binding Button_SCChipRefrigerationCommand}" Cursor="Hand" | |||||
Margin="50,0" | |||||
/> | |||||
<Button Content="单片机冰淇淋打料" | |||||
Command="{Binding Button_SCChipDischargeCommand}" Cursor="Hand" /> | |||||
<Button Content="单片机冰淇淋模拟" | |||||
Command="{Binding Button_SCChipTestCommand}" Cursor="Hand" | |||||
Margin="50,0"/> | |||||
</StackPanel> | |||||
</GroupBox> | |||||
</Grid> | </Grid> | ||||
</UserControl> | </UserControl> |
@@ -1,4 +1,5 @@ | |||||
using System; | |||||
using BPASmartClient.Helper; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
@@ -24,5 +25,11 @@ namespace BPASmartClient.MorkT.View | |||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
} | } | ||||
private void Dubug_Unloaded(object sender, RoutedEventArgs e) | |||||
{ | |||||
ThreadManage.GetInstance().StopTask("MorkT-状态刷新"); | |||||
ThreadManage.GetInstance().StopTask("MorkT-传感器监视"); | |||||
} | |||||
} | } | ||||
} | } |
@@ -0,0 +1,75 @@ | |||||
<UserControl x:Class="BPASmartClient.MorkT.View.Monitor" | |||||
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.MorkT.View" | |||||
xmlns:vm="clr-namespace:BPASmartClient.MorkT.ViewModel" | |||||
mc:Ignorable="d" | |||||
Name="监控画面" | |||||
d:DesignHeight="450" d:DesignWidth="800" Unloaded="Monitor_Unloaded"> | |||||
<UserControl.DataContext> | |||||
<vm:MonitorViewModel/> | |||||
</UserControl.DataContext> | |||||
<UserControl.Resources> | |||||
<ResourceDictionary > | |||||
<vm:BoolToColorConvert x:Key="BoolToColorConvert"/> | |||||
<Style x:Key="tx_Status" TargetType="TextBlock"> | |||||
<Setter Property="FontFamily" Value="/BPASmartClient.CustomResource;component/Fonts/Debug/#iconfont"/> | |||||
<Setter Property="FontSize" Value="26"/> | |||||
<Setter Property="Text" Value=""/> | |||||
<Setter Property="VerticalAlignment" Value="Center"/> | |||||
<Setter Property="HorizontalAlignment" Value="Left"/> | |||||
</Style> | |||||
</ResourceDictionary> | |||||
</UserControl.Resources> | |||||
<Grid Margin="10,0"> | |||||
<Grid.ColumnDefinitions> | |||||
</Grid.ColumnDefinitions> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="*"/> | |||||
<RowDefinition Height="*"/> | |||||
<RowDefinition Height="*"/> | |||||
</Grid.RowDefinitions> | |||||
<GroupBox Header="传感器状态" | |||||
FontSize="20" Foreground="#40e8ff" | |||||
BorderThickness="0"> | |||||
<Grid Margin="20,0"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="3*"/> | |||||
<ColumnDefinition Width="*"/> | |||||
<ColumnDefinition Width="3*"/> | |||||
<ColumnDefinition Width="*"/> | |||||
</Grid.ColumnDefinitions> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="*"/> | |||||
<RowDefinition Height="*"/> | |||||
<RowDefinition Height="*"/> | |||||
</Grid.RowDefinitions> | |||||
<TextBlock Text="机器人夹爪处检测传感器" | |||||
FontSize="18" | |||||
VerticalAlignment="Center"/> | |||||
<TextBlock Text="冰淇淋出料口传感器" | |||||
Grid.Row="1" | |||||
FontSize="18" | |||||
VerticalAlignment="Center"/> | |||||
<TextBlock Text="取餐口传感器" | |||||
Grid.Row="2" | |||||
FontSize="18" | |||||
VerticalAlignment="Center"/> | |||||
<TextBlock Grid.Row="0" Grid.Column="1" | |||||
Style="{StaticResource tx_Status}" | |||||
Foreground="{Binding RobotSenser,Converter={StaticResource BoolToColorConvert }}"/> | |||||
<TextBlock Grid.Row="1" Grid.Column="1" | |||||
Style="{StaticResource tx_Status}" | |||||
Foreground="{Binding IceCreamSenser,Converter={StaticResource BoolToColorConvert }}"/> | |||||
<TextBlock Grid.Row="2" Grid.Column="1" | |||||
Style="{StaticResource tx_Status}" | |||||
Foreground="{Binding TakeMealSenser,Converter={StaticResource BoolToColorConvert}}"/> | |||||
</Grid> | |||||
</GroupBox> | |||||
</Grid> | |||||
</UserControl> |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// Monitor.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class Monitor : UserControl | |||||
{ | |||||
public Monitor() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
private void Monitor_Unloaded(object sender, RoutedEventArgs e) | |||||
{ | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,13 @@ | |||||
<UserControl x:Class="BPASmartClient.MorkT.View.ParSer" | |||||
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.MorkT.View" | |||||
mc:Ignorable="d" | |||||
Name="参数设置界面" | |||||
d:DesignHeight="450" d:DesignWidth="800"> | |||||
<Grid> | |||||
</Grid> | |||||
</UserControl> |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// ParSer.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class ParSer : UserControl | |||||
{ | |||||
public ParSer() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -9,6 +9,8 @@ using BPASmartClient.Message; | |||||
using BPASmartClient.Model; | using BPASmartClient.Model; | ||||
using BPASmartClient.Model.乐白机器人; | using BPASmartClient.Model.乐白机器人; | ||||
using BPASmartClient.Model.冰淇淋.Enum; | using BPASmartClient.Model.冰淇淋.Enum; | ||||
using BPASmartClient.Model.单片机; | |||||
using BPASmartClient.Model.单片机.Enum; | |||||
using BPASmartClient.Model.咖啡机.Enum; | using BPASmartClient.Model.咖啡机.Enum; | ||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | using Microsoft.Toolkit.Mvvm.ComponentModel; | ||||
using Microsoft.Toolkit.Mvvm.Input; | using Microsoft.Toolkit.Mvvm.Input; | ||||
@@ -156,21 +158,100 @@ namespace BPASmartClient.MorkT.ViewModel | |||||
public List<string> CoffeeCmds { get; set; } = new List<string>(); | public List<string> CoffeeCmds { get; set; } = new List<string>(); | ||||
public string SelectedCoffeeCmd { get; set; } | public string SelectedCoffeeCmd { get; set; } | ||||
/// <summary> | |||||
/// 制作咖啡 | |||||
/// </summary> | |||||
public RelayCommand Button_MakeCoffeeCommand { get; set; } | |||||
/// <summary> | |||||
/// 停止制作咖啡 | |||||
/// </summary> | |||||
public RelayCommand Button_StopMakeCoffeCommand { get; set; } | |||||
/// <summary> | |||||
/// 咖啡模式设置 | |||||
/// </summary> | |||||
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 | #endregion | ||||
#region 单片机 | |||||
/// <summary> | /// <summary> | ||||
/// 设备ID | |||||
/// 咖啡杯或冰淇淋杯落杯 | |||||
/// </summary> | /// </summary> | ||||
public int DeviceId { get; set; } | |||||
public RelayCommand<object> Button_CupControlCommand { get; set; } | |||||
/// <summary> | |||||
/// 单片机冰淇淋机器制冷 | |||||
/// </summary> | |||||
public RelayCommand Button_SCChipRefrigerationCommand { get; set; } | |||||
/// <summary> | |||||
/// 单片机冰淇淋机器打料 | |||||
/// </summary> | |||||
public RelayCommand Button_SCChipDischargeCommand { get; set; } | |||||
/// <summary> | |||||
/// 模拟测试 | |||||
/// </summary> | |||||
public RelayCommand Button_SCChipTestCommand { get; set; } | |||||
public ObservableCollection<VariableMonitor> variableMonitors { get; set; } | |||||
private void Button_CupControl(object CupType) | |||||
{ | |||||
EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent() { DeviceId = DeviceId, Cup = (IC_CUP)Enum.Parse(typeof(IC_CUP), CupType.ToString()) }); | |||||
} | |||||
private void Button_SCChipRefrigeration() | |||||
{ | |||||
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 }); | |||||
} | |||||
private void Button_SCChipDischarge() | |||||
{ | |||||
EventBus.EventBus.GetInstance().Publish(new SCChip_MakeIceCreamEvent { DeviceId = DeviceId, SteeringEngine = IC_SE.SE_2 }); | |||||
} | |||||
#endregion | |||||
/// <summary> | |||||
/// 设备ID | |||||
/// </summary> | |||||
public int DeviceId { get; set; } | |||||
/// <summary> | |||||
/// 设备数据 | |||||
/// </summary> | |||||
public ObservableCollection<VariableMonitor> variableMonitors { get; set; } | |||||
public DebugViewModel() | public DebugViewModel() | ||||
{ | { | ||||
Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl); | Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl); | ||||
Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream); | Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream); | ||||
Button_SetIceCreamModelCommand = new RelayCommand(Button_SetIceCreamModel); | Button_SetIceCreamModelCommand = new RelayCommand(Button_SetIceCreamModel); | ||||
Button_MakeCoffeeCommand = new RelayCommand(Button_MakeCoffee); | |||||
Button_StopMakeCoffeCommand = new RelayCommand(Button_StopMakeCoffe); | |||||
Button_CoffeeModeSetCommand = new RelayCommand(Button_CoffeeModeSet); | |||||
Button_CupControlCommand = new RelayCommand<object>(Button_CupControl); | |||||
Button_SCChipRefrigerationCommand = new RelayCommand(Button_SCChipRefrigeration); | |||||
Button_SCChipDischargeCommand = new RelayCommand(Button_SCChipDischarge); | |||||
Button_SCChipTestCommand = new RelayCommand(() => | |||||
{ | |||||
Button_SCChipRefrigeration(); | |||||
Thread.Sleep(50); | |||||
Button_SCChipDischarge(); | |||||
}); | |||||
foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode))) | foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode))) | ||||
{ | { | ||||
Coffees.Add(code.ToString()); | Coffees.Add(code.ToString()); | ||||
@@ -0,0 +1,94 @@ | |||||
using BPASmartClient.Business; | |||||
using BPASmartClient.Helper; | |||||
using BPASmartClient.Model.乐白机器人; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Globalization; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
using System.Windows.Data; | |||||
using System.Windows.Media; | |||||
namespace BPASmartClient.MorkT.ViewModel | |||||
{ | |||||
public class MonitorViewModel: ObservableObject | |||||
{ | |||||
#region 传感器 | |||||
/// <summary> | |||||
/// 机器人夹爪传感器 | |||||
/// </summary> | |||||
public bool RobotSenser { get { return _robotSenser; } set { _robotSenser = value; OnPropertyChanged(); } } | |||||
private bool _robotSenser; | |||||
/// <summary> | |||||
/// 冰淇淋出口传感器 | |||||
/// </summary> | |||||
public bool IceCreamSenser { get { return _iceCreamSenser; } set { _iceCreamSenser = value; OnPropertyChanged(); } } | |||||
private bool _iceCreamSenser; | |||||
/// <summary> | |||||
/// 取餐口检测传感器 | |||||
/// </summary> | |||||
public bool TakeMealSenser { get { return _takeMealSenser; } set { _takeMealSenser = value; OnPropertyChanged(); } } | |||||
private bool _takeMealSenser; | |||||
#endregion | |||||
/// <summary> | |||||
/// 设备ID | |||||
/// </summary> | |||||
int DeviceId; | |||||
public MonitorViewModel() | |||||
{ | |||||
Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device => | |||||
{ | |||||
if (device.Name == "MorkT") DeviceId = device.DeviceId; | |||||
}); | |||||
ThreadManage.GetInstance().StartLong(new Action(() => | |||||
{ | |||||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent() { DeviceId = DeviceId, Pin = 1 },(res)=> | |||||
{ | |||||
if(res != null&& res.Length>0&& res[0] is bool b) | |||||
{ | |||||
RobotSenser = b; | |||||
} | |||||
}); | |||||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent() { DeviceId = DeviceId, Pin = 0 }, (res) => | |||||
{ | |||||
if (res != null && res.Length > 0 && res[0] is bool b) | |||||
{ | |||||
TakeMealSenser = b; | |||||
} | |||||
}); | |||||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent() { DeviceId = DeviceId, Pin = 3 }, (res) => | |||||
{ | |||||
if (res != null && res.Length > 0 && res[0] is bool b) | |||||
{ | |||||
IceCreamSenser = b; | |||||
} | |||||
}); | |||||
Thread.Sleep(500); | |||||
}), "MorkT-传感器监视"); | |||||
} | |||||
} | |||||
public class BoolToColorConvert : IValueConverter | |||||
{ | |||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||||
{ | |||||
return (bool) value? new SolidColorBrush(Color.FromRgb(144, 238, 144)) : new SolidColorBrush(Color.FromRgb(178, 34, 34)); | |||||
} | |||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | |||||
} |
@@ -33,6 +33,43 @@ namespace BPASmartClient.SCChip | |||||
/// </summary> | /// </summary> | ||||
public bool OnLine { get { return DateTime.Now.Subtract(lastRefreshTime).TotalSeconds <= 3; } } | public bool OnLine { get { return DateTime.Now.Subtract(lastRefreshTime).TotalSeconds <= 3; } } | ||||
#region 无需上传的数据 | |||||
/// <summary> | |||||
/// 1号舵机打开完成 | |||||
/// </summary> | |||||
public bool CompletedOpen_SE_1 { get; set; } | |||||
/// <summary> | |||||
/// 2号舵机打开完成 | |||||
/// </summary> | |||||
public bool CompletedOpen_SE_2 { get; set; } | |||||
/// <summary> | |||||
/// 3号舵机打开完成 | |||||
/// </summary> | |||||
public bool CompletedOpen_SE_3 { get; set; } | |||||
/// <summary> | |||||
/// 1号舵机关闭完成 | |||||
/// </summary> | |||||
public bool CompletedClose_SE_1 { get; set; } | |||||
/// <summary> | |||||
/// 2号舵机关闭完成 | |||||
/// </summary> | |||||
public bool CompletedClose_SE_2 { get; set; } | |||||
/// <summary> | |||||
/// 3号舵机关闭完成 | |||||
/// </summary> | |||||
public bool CompletedClose_SE_3 { get; set; } | |||||
/// <summary> | |||||
/// 是否存在物品 | |||||
/// </summary> | |||||
public bool ArticleExits { get; set; } | |||||
/// <summary> | |||||
/// 物品距离 | |||||
/// </summary> | |||||
public byte ArticleDist { get; set; } | |||||
#endregion | |||||
public ICChipMachine() | public ICChipMachine() | ||||
{ | { | ||||
@@ -176,13 +213,13 @@ namespace BPASmartClient.SCChip | |||||
switch ((IC_SE)data.Value) | switch ((IC_SE)data.Value) | ||||
{ | { | ||||
case IC_SE.SE_1: | case IC_SE.SE_1: | ||||
status["CompletedOpen_SE_1"] = true; | |||||
break; | |||||
CompletedOpen_SE_1 = true; | |||||
break; | |||||
case IC_SE.SE_2: | case IC_SE.SE_2: | ||||
status["CompletedOpen_SE_2"] = true; | |||||
break; | |||||
CompletedOpen_SE_2 = true; | |||||
break; | |||||
case IC_SE.SE_3: | case IC_SE.SE_3: | ||||
status["CompletedOpen_SE_3"] = true; | |||||
CompletedOpen_SE_3 = true; | |||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
@@ -190,13 +227,13 @@ namespace BPASmartClient.SCChip | |||||
switch ((IC_SE)data.Value) | switch ((IC_SE)data.Value) | ||||
{ | { | ||||
case IC_SE.SE_1: | case IC_SE.SE_1: | ||||
status["CompletedClose_SE_1"] = true; | |||||
CompletedClose_SE_1 = true; | |||||
break; | break; | ||||
case IC_SE.SE_2: | case IC_SE.SE_2: | ||||
status["CompletedClose_SE_2"] = true; | |||||
CompletedClose_SE_2= true; | |||||
break; | break; | ||||
case IC_SE.SE_3: | case IC_SE.SE_3: | ||||
status["CompletedClose_SE_3"] = true; | |||||
CompletedClose_SE_3 = true; | |||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
@@ -214,12 +251,12 @@ namespace BPASmartClient.SCChip | |||||
{ | { | ||||
status["CompletedTake_CPU_CUP_ICECREAM"] = false; | status["CompletedTake_CPU_CUP_ICECREAM"] = false; | ||||
status["CompletedTake_CPU_CUP_COFFEE"] = false; | status["CompletedTake_CPU_CUP_COFFEE"] = false; | ||||
status["CompletedOpen_SE_1"] = false; | |||||
status["CompletedOpen_SE_2"] = false; | |||||
status["CompletedOpen_SE_3"] = false; | |||||
status["CompletedClose_SE_1"] = false; | |||||
status["CompletedClose_SE_2"] = false; | |||||
status["CompletedClose_SE_3"] = false; | |||||
//status["CompletedOpen_SE_1"] = false; | |||||
//status["CompletedOpen_SE_2"] = false; | |||||
//status["CompletedOpen_SE_3"] = false; | |||||
//status["CompletedClose_SE_1"] = false; | |||||
//status["CompletedClose_SE_2"] = false; | |||||
//status["CompletedClose_SE_3"] = false; | |||||
} | } | ||||
public override void Init() | public override void Init() | ||||
@@ -272,81 +309,93 @@ namespace BPASmartClient.SCChip | |||||
}); | }); | ||||
//STM32F103RCT6单片机舵机打料 | //STM32F103RCT6单片机舵机打料 | ||||
EventBus.EventBus.GetInstance().Subscribe<SCChip_MakeIceCreamEvent>(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<SCChip_MakeIceCreamEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||||
{ | |||||
try | |||||
{ | |||||
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine) | |||||
{ | |||||
case IC_SE.SE_1: | |||||
CompletedOpen_SE_1 = false; | |||||
break; | |||||
case IC_SE.SE_2: | |||||
CompletedOpen_SE_2 = false; | |||||
break; | |||||
case IC_SE.SE_3: | |||||
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 = !CompletedOpen_SE_1; | |||||
break; | |||||
case IC_SE.SE_2: | |||||
wait = !CompletedOpen_SE_2; | |||||
break; | |||||
case IC_SE.SE_3: | |||||
wait = !CompletedOpen_SE_3; | |||||
break; | |||||
} | |||||
} | |||||
Thread.Sleep(10); | |||||
} | |||||
Thread.Sleep(2000); | |||||
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine) | |||||
{ | |||||
case IC_SE.SE_1: | |||||
CompletedClose_SE_1 = false; | |||||
break; | |||||
case IC_SE.SE_2: | |||||
CompletedClose_SE_2 = false; | |||||
break; | |||||
case IC_SE.SE_3: | |||||
CompletedClose_SE_3 = false; | |||||
break; | |||||
} | |||||
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 = !CompletedClose_SE_1; | |||||
break; | |||||
case IC_SE.SE_2: | |||||
wait = !CompletedClose_SE_2; | |||||
break; | |||||
case IC_SE.SE_3: | |||||
wait = !CompletedClose_SE_3; | |||||
break; | |||||
} | |||||
} | |||||
Thread.Sleep(10); | |||||
} | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]"); | |||||
} | |||||
}); | |||||
//STM32F103RCT6单片机舵机打开或者关闭 | //STM32F103RCT6单片机舵机打开或者关闭 | ||||
EventBus.EventBus.GetInstance().Subscribe<SCChip_SESwitchCreamEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | EventBus.EventBus.GetInstance().Subscribe<SCChip_SESwitchCreamEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | ||||
@@ -33,12 +33,19 @@ | |||||
<TextBox x:Name="chen" Margin="10,0,0,0" Width="200" >1</TextBox> | <TextBox x:Name="chen" Margin="10,0,0,0" Width="200" >1</TextBox> | ||||
<Button Tag="Inquire" Margin="10,0,0,0" Click="Button_Click" Style="{DynamicResource CommonBtn_返回}" Width="45">查询</Button> | <Button Tag="Inquire" Margin="10,0,0,0" Click="Button_Click" Style="{DynamicResource CommonBtn_返回}" Width="45">查询</Button> | ||||
</StackPanel> | </StackPanel> | ||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | <StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | ||||
<TextBlock Width="80" HorizontalAlignment="Right" FontSize="12">客户端ID:</TextBlock> | <TextBlock Width="80" HorizontalAlignment="Right" FontSize="12">客户端ID:</TextBlock> | ||||
<TextBox x:Name="clientId" Margin="10,0,0,0" Width="200" Text="{Binding device.ClientId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | <TextBox x:Name="clientId" Margin="10,0,0,0" Width="200" Text="{Binding device.ClientId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | ||||
</StackPanel> | </StackPanel> | ||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||||
<TextBlock Width="80" HorizontalAlignment="Right" FontSize="12">设备ID:</TextBlock> | |||||
<TextBox x:Name="sbId" Margin="10,0,0,0" Width="200" Text="{Binding device.DeviceId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | |||||
</StackPanel> | |||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | <StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | ||||
<TextBlock Width="80" FontSize="12">devicename:</TextBlock> | <TextBlock Width="80" FontSize="12">devicename:</TextBlock> | ||||
<TextBox x:Name="devicename" Margin="10,0,0,0" Width="200" Text="{Binding device.devicename, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | <TextBox x:Name="devicename" Margin="10,0,0,0" Width="200" Text="{Binding device.devicename, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | ||||
@@ -100,6 +107,13 @@ | |||||
</DataTemplate> | </DataTemplate> | ||||
</DataGridTemplateColumn.CellTemplate> | </DataGridTemplateColumn.CellTemplate> | ||||
</DataGridTemplateColumn> | </DataGridTemplateColumn> | ||||
<DataGridTemplateColumn Header="设备ID" Width="2*"> | |||||
<DataGridTemplateColumn.CellTemplate> | |||||
<DataTemplate> | |||||
<TextBlock HorizontalAlignment="Center" Text="{Binding DeviceId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="12" /> | |||||
</DataTemplate> | |||||
</DataGridTemplateColumn.CellTemplate> | |||||
</DataGridTemplateColumn> | |||||
<DataGridTemplateColumn Header="云名称" Width="5*"> | <DataGridTemplateColumn Header="云名称" Width="5*"> | ||||
<DataGridTemplateColumn.CellTemplate> | <DataGridTemplateColumn.CellTemplate> | ||||
<DataTemplate> | <DataTemplate> | ||||