Browse Source

冲突解决

样式分支
pry 2 years ago
parent
commit
1665893283
26 changed files with 2200 additions and 61 deletions
  1. +10
    -1
      BPASmartClient.Lebai/LebaiRobot.cs
  2. +5
    -2
      BPASmartClient.LebaiRobot/LebaiHelper.cs
  3. +4
    -0
      BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs
  4. +6
    -0
      BPASmartClient.Model/乐白机器人/LebaiRobotEvent.cs
  5. +56
    -24
      BPASmartClient.MorkT/Control_MorkT.cs
  6. +3
    -0
      BPASmartClient.MorkT/GLV_MorkT.cs
  7. +52
    -25
      BPASmartClient.MorkT/View/DebugView.xaml
  8. +2
    -2
      BPASmartClient.MorkT/View/DebugView.xaml.cs
  9. +15
    -3
      BPASmartClient.MorkT/ViewModel/DebugViewModel.cs
  10. +54
    -0
      BPASmartClient.MorkT_HQ/BPASmartClient.MorkT_HQ.csproj
  11. +766
    -0
      BPASmartClient.MorkT_HQ/Control_MorkT_HQ.cs
  12. +118
    -0
      BPASmartClient.MorkT_HQ/GLV_MorkT_HQ.cs
  13. +25
    -0
      BPASmartClient.MorkT_HQ/OrderLocInfo.cs
  14. +124
    -0
      BPASmartClient.MorkT_HQ/PolymerBatching.cs
  15. +266
    -0
      BPASmartClient.MorkT_HQ/View/DebugView.xaml
  16. +35
    -0
      BPASmartClient.MorkT_HQ/View/DebugView.xaml.cs
  17. +75
    -0
      BPASmartClient.MorkT_HQ/View/Monitor.xaml
  18. +34
    -0
      BPASmartClient.MorkT_HQ/View/Monitor.xaml.cs
  19. +13
    -0
      BPASmartClient.MorkT_HQ/View/ParSer.xaml
  20. +28
    -0
      BPASmartClient.MorkT_HQ/View/ParSer.xaml.cs
  21. +326
    -0
      BPASmartClient.MorkT_HQ/ViewModel/DebugViewModel.cs
  22. +94
    -0
      BPASmartClient.MorkT_HQ/ViewModel/MonitorViewModel.cs
  23. +2
    -2
      BPASmartClient.SCChip/ICChipMachine.cs
  24. +23
    -1
      BPASmartClient/MainWindow.xaml
  25. +41
    -1
      BPASmartClient/MainWindow.xaml.cs
  26. +23
    -0
      SmartClient.sln

+ 10
- 1
BPASmartClient.Lebai/LebaiRobot.cs View File

@@ -94,7 +94,7 @@ namespace BPASmartClient.Lebai
if (@event == null) return;
if (@event is LebaiRobot_SetValueEvent SetValueEvent)
{
LebaiHelper.GetInstance().SetValue(SetValueEvent.RobotSetValue);
callBack?.Invoke(LebaiHelper.GetInstance().SetValue(SetValueEvent.RobotSetValue));
}
});
//控制机器人
@@ -133,6 +133,15 @@ namespace BPASmartClient.Lebai
}
});

EventBus.EventBus.GetInstance().Subscribe<LebaiRobot_SetOutPutEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (@event == null) return;
if (@event is LebaiRobot_LebaiSenceEvent lebaiSenceEvent)
{
}
});

InitStatus();
Start();
MessageLog.GetInstance.Show("乐白机器人初始化完成");


+ 5
- 2
BPASmartClient.LebaiRobot/LebaiHelper.cs View File

@@ -43,7 +43,7 @@ namespace BPASmartClient.LebaiRobot
}
}
StartRobot();
Thread.Sleep(500);
MessageLog.GetInstance.Show("乐百机器人连接成功!");
}
/// <summary>
@@ -70,12 +70,14 @@ namespace BPASmartClient.LebaiRobot

try
{
robotData = client.GetRobotData().Result; }
robotData = client.GetRobotData().Result;
}
catch (Exception)
{
robotData = null;
// throw;
}
Thread.Sleep(10);
}
MessageLog.GetInstance.Show("乐白机器人断开连接,准备重连");
int num = 0;
@@ -246,6 +248,7 @@ namespace BPASmartClient.LebaiRobot
signalValue.Index = index;
signalValue.Value = value;
return client.SetSignal(signalValue).Result;

}

/// <summary>


+ 4
- 0
BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs View File

@@ -28,6 +28,10 @@ namespace BPASmartClient.Model.乐白机器人.Enum
public const int SENCE_咖啡杯回原点 = 10050;
public const int SENCE_冰淇淋杯回原点 = 10049;
public const int SENCE_取咖啡出餐 = 10052;

// 单片机冰淇淋机器场景
public const int SENCE_单片机接冰淇淋 = 10055;
public const int SENCE_单片机放冰淇淋位置 = 10056;
#endregion
}
}

+ 6
- 0
BPASmartClient.Model/乐白机器人/LebaiRobotEvent.cs View File

@@ -45,4 +45,10 @@ namespace BPASmartClient.Model.乐白机器人
public int LebaiSence { get; set; }

}

public class LebaiRobot_SetOutPutEvent : BaseEvent
{
public int RobotSetOut { get; set; }
}
}


+ 56
- 24
BPASmartClient.MorkT/Control_MorkT.cs View File

@@ -9,10 +9,12 @@ using BPASmartClient.LebaiRobot;
using BPASmartClient.Message;
using BPASmartClient.Model;
using BPASmartClient.Model.乐白机器人;
using BPASmartClient.Model.乐白机器人.Enum;
using BPASmartClient.Model.冰淇淋.Enum;
using BPASmartClient.Model.单片机;
using BPASmartClient.Model.单片机.Enum;
using BPASmartClient.Peripheral;
using Robotc;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -231,6 +233,13 @@ namespace BPASmartClient.MorkT
morkT.CaffeeFault = coffeeFault;
}
}));
GetStatus("SCChipIsConnect", new Action<object>((o) =>
{
if (o is bool b)
{
morkT.SCChipIsConnect = b;
}
}));
}


@@ -387,10 +396,10 @@ namespace BPASmartClient.MorkT
DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]");
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 = Lebai_qsqdCode.SENCE_接咖啡后回原点 }); //接咖啡后回原点
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) });//接咖啡控制
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() {DeviceId = DeviceId, DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) });//接咖啡控制
DeviceProcessLogShow($"发送咖啡机制作{orderLoc.Loc}!");
morkT.IsCoffeeMake = true; morkT.MakeCoffeeOrder = orderLoc;
}
@@ -425,7 +434,7 @@ namespace BPASmartClient.MorkT
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10052 }); //SENCE_取咖啡出餐
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
//订单状态改变:完成
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK);
morkT.waitMorkOrder = order;
@@ -440,7 +449,7 @@ namespace BPASmartClient.MorkT
/// <param name="order"></param>
private void GetAndCheeckCoffe(OrderLocInfo order)
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 },(o)=>{ });
OrderChange(order.SuborderId, ORDER_STATUS.COOKING);
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10031 }); //SENCE_取咖啡杯

@@ -448,14 +457,14 @@ namespace BPASmartClient.MorkT
EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_COFFEE });//落碗控制
Thread.Sleep(500);
DeviceProcessLogShow("尝试取咖啡杯!");
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
int count = 1;
bool result = true;
p:
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10033 }); //SENCE_咖啡杯检测
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent { DeviceId = DeviceId, Pin = 1 }, (o) =>
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent { DeviceId = DeviceId, Pin = 1 }, (o)=>
{
if (o != null && o.Length > 0 && o[0] is bool resultValue)
{
@@ -471,7 +480,7 @@ namespace BPASmartClient.MorkT
DeviceProcessLogShow($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!");
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10050 }); //SENCE_咖啡杯回原点
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
morkT.GetCoffeeCup = false;
return;
}
@@ -479,7 +488,7 @@ namespace BPASmartClient.MorkT
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10035 }); //SENCE_二次取咖啡杯
Wait();
EventBus.EventBus.GetInstance().Equals(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_COFFEE });//落碗控制
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
count++;
goto p;
}
@@ -564,7 +573,8 @@ namespace BPASmartClient.MorkT
/// </summary>
private void GetIceCreamCup()
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 });
MessageLog.GetInstance.Show("准备开始制作冰淇淋");
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }, (o) => { });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10032 }); //SENCE_取冰淇淋杯
Wait();
EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_ICECREAM });//落碗控制
@@ -580,11 +590,30 @@ namespace BPASmartClient.MorkT
{
int count = 2;
bool result = true;
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
p:
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10034 }); //SENCE_冰淇淋杯检测
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
Thread.Sleep(500);
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) =>
{
if (o != null && o.Length > 0 && o[0] is SignalResult res)
{
MessageLog.GetInstance.Show(res.ToString());
}
});
while((int)peripheralStatus["RobotValue"] != 0)
{
Thread.Sleep(10);
}
MessageLog.GetInstance.Show($"乐白机器人信号值{peripheralStatus["RobotValue"].ToString()}");
//while ((ELebaiRModel)peripheralStatus["RobotMode"] !=ELebaiRModel.空闲状态)
//{
// EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
// Thread.Sleep(500);
//}

EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent { DeviceId = DeviceId, Pin = 1 }, (o) =>
{
if (o != null && o.Length > 0 && o[0] is bool resultValue)
@@ -600,7 +629,7 @@ namespace BPASmartClient.MorkT
DeviceProcessLogShow($"执行{count}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!");
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10049 }); //SENCE_冰淇淋杯回原点
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 },(o) => { });
morkT.GetIceCreamCup = false;
return;
}
@@ -608,7 +637,7 @@ namespace BPASmartClient.MorkT
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10036 }); //SENCE_二次取冰淇淋杯
EventBus.EventBus.GetInstance().Equals(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_ICECREAM });//落碗控制
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
count++;
goto p;
}
@@ -624,19 +653,22 @@ namespace BPASmartClient.MorkT
{
//制冷模式
//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 }, (o) => { });
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 = 10055 }); //SENCE_接1号冰淇淋
Wait();
bool doItResult = true;

//出料
EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = true });
//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 LebaiRobot_LebaiSenceEvent { DeviceId=DeviceId,})

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);
Thread.Sleep(5000);

//出料
//EventBus.EventBus.GetInstance().Publish(new GSIceCream_DischargeEvent { DeviceId = DeviceId },(o)=>
@@ -660,7 +692,7 @@ namespace BPASmartClient.MorkT
// }
// IceCreamCookCheck();
//}
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
}

/// <summary>
@@ -681,10 +713,10 @@ namespace BPASmartClient.MorkT
});
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 = 10056 }); //SENCE_放冰淇淋位置
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
//订单状态改变:完成
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK);
morkT.waitMorkOrder = order;


+ 3
- 0
BPASmartClient.MorkT/GLV_MorkT.cs View File

@@ -110,6 +110,9 @@ namespace BPASmartClient.MorkT
[VariableMonitor("咖啡机故障")]
public DrCoffeeFault CaffeeFault { get; set; }

[VariableMonitor("单片机连接状态")]
public bool SCChipIsConnect { get; set; }

#endregion
}
}

+ 52
- 25
BPASmartClient.MorkT/View/DebugView.xaml View File

@@ -25,7 +25,7 @@
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="14*"/>
<RowDefinition Height="6*"/>
<RowDefinition Height="0.1*"/>
<RowDefinition Height="20*"/>
</Grid.RowDefinitions>

@@ -62,27 +62,27 @@
</ControlTemplate>
</ListBox.Template>
<Button Content="机器人启动"
Margin="20,5" Width="150" Height="40"
Margin="20,5" Width="150" Height="60"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人启动">
CommandParameter="机器人启动" Cursor="Hand">
</Button>
<Button Content="启动示教"
Margin="20,5" Width="150" Height="40"
Margin="20,5" Width="150" Height="60"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="启动示教"/>
<Button Content="停止示教"
Margin="20,5" Width="150" Height="40"
Margin="20,5" Width="150" Height="60"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="停止示教"/>
<Button Content="机器人急停"
Margin="20,5" Width="110" Height="40"
Margin="20,5" Width="110" Height="60"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人急停"/>

</ListBox>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2"
<!--<GroupBox Grid.Row="2"
FontFamily="楷体"
FontSize="20"
Header=" 冰淇淋机器 ">
@@ -172,7 +172,50 @@
</StackPanel>
</StackPanel>
</Grid>
</GroupBox>-->
<GroupBox Grid.Row="2" Grid.Column="0"
FontSize="20" FontFamily="楷体"
Header="单片机冰淇淋" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="5*"/>
</Grid.RowDefinitions>
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding SCChipIsConnect}"
Margin="120,0,0,0"/>
<TextBlock Grid.Row="1" Text="单片机控制" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<ListBox Grid.Row="2" Background="Transparent">
<ListBox.Template>
<ControlTemplate TargetType="{x:Type ListBox}">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<WrapPanel Orientation="Horizontal" IsItemsHost="True" ScrollViewer.CanContentScroll="True"/>
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
<Button Content="咖啡杯落杯" Height="40" Width="120"
Command="{Binding Button_CupControlCommand}"
CommandParameter="CUP_COFFEE"
Margin="10,10,50,10" Cursor="Hand"/>
<Button Content="冰淇淋杯落杯" Height="40" Width="120"
Command="{Binding Button_CupControlCommand}"
CommandParameter="CUP_ICECREAM" Margin="10,10,50,10"
/>
<Button Content="单片机冰淇淋制冷" Height="40" Width="120"
Command="{Binding Button_SCChipRefrigerationCommand}" Cursor="Hand"
Margin="10,10,50,10"
/>
<Button Content="单片机冰淇淋打料" Height="40" Width="120" Margin="10,10,50,10"
Command="{Binding Button_SCChipDischargeCommand}" Cursor="Hand" />
<Button Content="单片机冰淇淋模拟" Height="40" Width="120"
Command="{Binding Button_SCChipTestCommand}" Cursor="Hand"
Margin="10,10,50,10"/>

</ListBox>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2" Grid.Column="1"
FontFamily="楷体"
FontSize="20"
@@ -252,27 +295,11 @@
<GroupBox Header="单片机控制"
FontSize="18"
Grid.Row="1" Grid.ColumnSpan="2"
Margin="0,0,0,10">
Margin="0,0,0,10" HorizontalAlignment="Right" Width="1000">
<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>



+ 2
- 2
BPASmartClient.MorkT/View/DebugView.xaml.cs View File

@@ -28,8 +28,8 @@ namespace BPASmartClient.MorkT.View

private void Dubug_Unloaded(object sender, RoutedEventArgs e)
{
ThreadManage.GetInstance().StopTask("MorkT-状态刷新");
ThreadManage.GetInstance().StopTask("MorkT-传感器监视");
//ThreadManage.GetInstance().StopTask("MorkT-状态刷新");
//ThreadManage.GetInstance().StopTask("MorkT-传感器监视");
}
}
}

+ 15
- 3
BPASmartClient.MorkT/ViewModel/DebugViewModel.cs View File

@@ -44,6 +44,13 @@ namespace BPASmartClient.MorkT.ViewModel
/// 机器人控制
/// </summary>
/// <param name="o"></param>
public RelayCommand Button_SetValueCommand { get; set; }

private void Button_SetValue()
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
}
private void Button_RobotControl(object o)
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiControlEvent { DeviceId = DeviceId, LebaiControl = o.ToString() });
@@ -187,6 +194,11 @@ namespace BPASmartClient.MorkT.ViewModel

#region 单片机
/// <summary>
/// 单片机连接状态
/// </summary>
public string SCChipIsConnect { get { return _sCChipIsConnect; } set { _sCChipIsConnect = value; OnPropertyChanged(); } }
private string _sCChipIsConnect { get; set; }
/// <summary>
/// 咖啡杯或冰淇淋杯落杯
/// </summary>
public RelayCommand<object> Button_CupControlCommand { get; set; }
@@ -235,6 +247,8 @@ namespace BPASmartClient.MorkT.ViewModel
public DebugViewModel()
{
Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl);
Button_SetValueCommand = new RelayCommand(Button_SetValue);

Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream);
Button_SetIceCreamModelCommand = new RelayCommand(Button_SetIceCreamModel);

@@ -274,9 +288,6 @@ namespace BPASmartClient.MorkT.ViewModel
if (device.Name == "MorkT") DeviceId = device.DeviceId
;
});



ThreadManage.GetInstance().StartLong(new Action(() =>
{

@@ -287,6 +298,7 @@ namespace BPASmartClient.MorkT.ViewModel
RobotConnected = variableMonitors.FirstOrDefault(p=>p.Notes == "机器人连接状态").CurrentValue == "True" ? "已连接" : "未连接";
IceCreamConnected = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋连接状态").CurrentValue == "True" ? "已连接" : "未连接";
CoffeeConnected = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
SCChipIsConnect = variableMonitors.FirstOrDefault(p => p.Notes == "单片机连接状态").CurrentValue == "True" ? "已连接" : "未连接";

RobotMode = variableMonitors.FirstOrDefault(p => p.Notes == "机器人状态").CurrentValue;



+ 54
- 0
BPASmartClient.MorkT_HQ/BPASmartClient.MorkT_HQ.csproj View File

@@ -0,0 +1,54 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<BaseOutputPath>bin\</BaseOutputPath>
<DebugType>portable</DebugType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Models" Version="1.0.10" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" />
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.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" />
<ProjectReference Include="..\BPASmartClient.MORKSM.BK.PLC\BPASmartClient.PLC.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="View\DebugView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="View\Monitor.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="View\ParSer.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>

<ItemGroup>
<Page Update="View\DebugView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="View\Monitor.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="View\ParSer.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>

</Project>

+ 766
- 0
BPASmartClient.MorkT_HQ/Control_MorkT_HQ.cs View File

@@ -0,0 +1,766 @@
using BPA.Message.Enum;
using BPASmartClient.Device;
using BPASmartClient.DRCoffee;
using BPASmartClient.EventBus;
using BPASmartClient.GSIceCream;
using BPASmartClient.Helper;
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;
using BPASmartClient.Peripheral;
using Robotc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static BPASmartClient.EventBus.EventBus;

namespace BPASmartClient.MorkT_HQ
{
public class Control_MorkT_HQ : BaseDevice
{
public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKT; } }

GLV_MorkT_HQ morkT = new GLV_MorkT_HQ();


public override void DoMain()
{
if(Json<KeepDataBase>.Data.IsVerify)
{
IsHealth = true;
}
IsHealth = true;
ServerInit();
DataParse();
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (morkT.MakeCoffeeOrder != null)
morkT.MakeCoffeeOrder.OrderStatus = 1;
});
int i = 0;
EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent { DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 });

MessageLog.GetInstance.Show("MORKT 设备初始化完成");

}

public override void ResetProgram()
{
morkT = null;
morkT = new GLV_MorkT_HQ();
}


private void GetStatus(string key, Action<object> action)
{
if (peripheralStatus.ContainsKey(key))
{
if (peripheralStatus[key] != null)
{
action?.Invoke(peripheralStatus[key]);
}
}
}

public override void MainTask()
{
if (morkT.waitMorkOrder != null)//更新订单取走状态
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent() { DeviceId = DeviceId, Pin = 0 }, (o) =>
{
if (o != null && o.Length > 0 && o[0] is bool res)
{
if (!res)
{
OrderChange(morkT.waitMorkOrder.SuborderId, ORDER_STATUS.COMPLETED_TAKE);
DeviceProcessLogShow("订单取餐完成");
morkT.waitMorkOrder = null;
}
}
});
}
MakeCoffeeProcess();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 },(o)=>
{
if(o != null && o.Length > 0 && o[0] is bool resultValue)
{
if(!resultValue)//取餐口有空余位置
{
MakeIceCreamProcess();
MakeCoffeeComplete();
}
}
});

}

public override void ReadData()
{
GetStatus("RobotIsConnected", new Action<object>((o) =>
{
if (o is bool b)
{
morkT.RobotIsConnected = b;
}
}));

GetStatus("RobotMode", new Action<object>((o) =>
{
if (o is ELebaiRModel eLebaiRModel)
{
morkT.RobotMode = eLebaiRModel;
}
}));


GetStatus("IceCreamIsConnected", new Action<object>((o) =>
{
if (o is bool b)
{
morkT.IceCreamIsConnected = b;
}
}));

GetStatus("IceCreamYLWD", new Action<object>((o) =>
{
if (o is short s)
{
morkT.YLWD = s;
}
}));

GetStatus("IceCreamHQWD", new Action<object>((o) =>
{
if (o is short s)
{
morkT.HQWD = s;
}
}));

GetStatus("IceCreamDL", new Action<object>((o) =>
{
if (o is short s)
{
morkT.DL = s;
}
}));

GetStatus("IceCreamDY", new Action<object>((o) =>
{
if (o is short s)
{
morkT.DY = s;
}
}));

GetStatus("IceCreamCXB", new Action<object>((o) =>
{
if (o is byte bt)
{
morkT.CBX = bt;
}
}));

GetStatus("IceCreamCurrentMode", new Action<object>((o) =>
{
if (o is MORKI_MODE mORKI_MODE)
{
morkT.IceCreamMode = mORKI_MODE;
}
}));

GetStatus("IceCreamFault", new Action<object>((o) =>
{
if (o is MORKI_FAULT mORKI_FAULT)
{
morkT.IceCreamFault = mORKI_FAULT;
}
}));

GetStatus("IceCreamDLCompleted", new Action<object>((o) =>
{
if (o is bool b)
{
morkT.DLCompleted = b;
}
}));

GetStatus("CoffeeIsConnected", new Action<object>((o) =>
{
if (o is bool b)
{
morkT.CoffeeIsConnected = b;
}
}));

GetStatus("CoffeeStatus", new Action<object>((o) =>
{
if (o is DrCoffeeStatus coffeeStatus)
{
morkT.DrCoffeeStatus = coffeeStatus;
}
}));

GetStatus("CoffeeAppStatus", new Action<object>((o) =>
{
if (o is DrCoffeeAppStatus appStatus)
{
morkT.CoffeeAppStatus = appStatus;
}
}));

GetStatus("CoffeeWarning", new Action<object>((o) =>
{
if (o is DrCoffeeWarning coffeeWarning)
{
morkT.CoffeeWarning = coffeeWarning;
}
}));
GetStatus("CoffeeFault", new Action<object>((o) =>
{
if (o is DrCoffeeFault coffeeFault)
{
morkT.CaffeeFault = coffeeFault;
}
}));
GetStatus("SCChipIsConnect", new Action<object>((o) =>
{
if (o is bool b)
{
morkT.SCChipIsConnect = b;
}
}));
}



public override void Stop()
{
}


private void ServerInit()
{
//物料信息
EventBus.EventBus.GetInstance().Subscribe<MaterialDeliveryEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (@event == null) return;
if (@event is MaterialDeliveryEvent material)
{
orderMaterialDelivery = material.orderMaterialDelivery;
}
});

//配方数据信息
EventBus.EventBus.GetInstance().Subscribe<RecipeBomEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (@event == null) return;
if (@event is RecipeBomEvent recipe)
{
recipeBoms = recipe.recipeBoms;
}
});
}

/// <summary>
/// 数据解析
/// </summary>
private void DataParse()
{
EventBus.EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle)
{
if (@event == null) return;
if (@event is DoOrderEvent order)
{
if (order.MorkOrder.GoodBatchings == null) return;
OrderCount++;
DeviceProcessLogShow($"接收到{OrderCount}次订单");
//构建所有商品物料信息
morkT.batchings = PolymerBatching.BuildAll();
//商品类型
GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER;
foreach (var item in order.MorkOrder.GoodBatchings)
{
var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
if (res != null)
{
//验证商品是咖啡还是冰淇淋
if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER)
{
//获取当前物料所属商品类型
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc);
}
string loc_Goods = string.Empty;
//获取主料和容器位置
if (morkT.batchings[res.BatchingLoc].BatchingClass == BATCHING_CLASS.MAIN_MATERIAL) loc_Goods = res.BatchingLoc;
if (!string.IsNullOrEmpty(loc_Goods))
{
switch (currentGoodsType)
{
case GOODS_TYPE.COFFEE:
if (morkT.morkOrderPushesCoffee.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
{
morkT.morkOrderPushesCoffee.Enqueue(new OrderLocInfo()
{
SuborderId = order.MorkOrder.SuborderId,
BatchingId = res.BatchingId,
Loc = loc_Goods,
GoodsName = order.MorkOrder.GoodsName,
SortNum = order.MorkOrder.SortNum
});
}
break;
case GOODS_TYPE.ICECREAM:
if (morkT.morkOrderPushesIceCream.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
{
morkT.morkOrderPushesIceCream.Enqueue(new OrderLocInfo()
{
SuborderId = order.MorkOrder.SuborderId,
BatchingId = res.BatchingId,
Loc = loc_Goods,
GoodsName = order.MorkOrder.GoodsName,
SortNum = order.MorkOrder.SortNum
});
}
break;
case GOODS_TYPE.NEITHER:
DeviceProcessLogShow("未知的商品类型");
break;
}
}
}
}
}
});
}
/// <summary>
/// 验证当前是做咖啡还是做冰淇淋
/// </summary>
/// <param name="batchingLoc">物料位置</param>
private GOODS_TYPE ValidateGoodsByBatching(string batchingLoc)
{
if (morkT.batchings.ContainsKey(batchingLoc))
return morkT.batchings[batchingLoc].GoodsType;
return GOODS_TYPE.NEITHER;
}


private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
{
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType });
}

private void Wait(int value = 101)
{
while (!((bool)peripheralStatus["RobotOK"] && (int)peripheralStatus["RobotValue"] == value))
{
Thread.Sleep(5);
}
}

/// <summary>
/// 是否可以开始制作咖啡
/// </summary>
/// <returns></returns>
private bool CoffeeCanMake()
{
bool canMake = (IsHealth && morkT.morkOrderPushesCoffee.Count > 0 && !morkT.IsCoffeeMake) ? true : false;
return canMake;

}

/// <summary>
/// 制作咖啡流程
/// </summary>
private void MakeCoffeeProcess()
{
if (CoffeeCanMake())
{
if (morkT.morkOrderPushesCoffee.TryDequeue(out OrderLocInfo orderLoc))
{
DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]");
GetAndCheeckCoffe(orderLoc);//取咖啡杯
if (!morkT.GetCoffeeCup) return;
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10051}); //接咖啡后回原点
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() {DeviceId = DeviceId, DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) });//接咖啡控制
DeviceProcessLogShow($"发送咖啡机制作{orderLoc.Loc}!");
morkT.IsCoffeeMake = true; morkT.MakeCoffeeOrder = orderLoc;
}

}


}
/// <summary>
/// 咖啡机制作完咖啡,取走并放到取餐口,最后回原点
/// </summary>
private void MakeCoffeeComplete()
{
if (morkT.IsCoffeeMake && IsHealth)
{
if (morkT.MakeCoffeeOrder != null && morkT.MakeCoffeeOrder.OrderStatus == 1)
{
DeviceProcessLogShow($"将咖啡移动到取餐位 [咖啡] 订单[{morkT.MakeCoffeeOrder.SortNum}]");
DoCoffeeQC(morkT.MakeCoffeeOrder);
morkT.MakeCoffeeOrder = null;
morkT.IsCoffeeMake = false;
}
}
}


/// <summary>
/// 将咖啡杯从咖啡机 取走到 取餐口
/// </summary>
private void DoCoffeeQC(OrderLocInfo order)
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10052 }); //SENCE_取咖啡出餐
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
//订单状态改变:完成
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK);
morkT.waitMorkOrder = order;
DeviceProcessLogShow($"{order.GoodsName}等待取餐");
//WaitTakeMealOrder.Enqueue(order);

}

/// <summary>
/// 取咖啡杯&&咖啡杯检测 若检测失败机器人回原点
/// </summary>
/// <param name="order"></param>
private void GetAndCheeckCoffe(OrderLocInfo order)
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 },(o)=>{ });
OrderChange(order.SuborderId, ORDER_STATUS.COOKING);
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10031 }); //SENCE_取咖啡杯

Wait();
EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId= DeviceId ,Cup = IC_CUP.CUP_COFFEE});//落碗控制
Thread.Sleep(500);
DeviceProcessLogShow("尝试取咖啡杯!");
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
int count = 1;
bool result = true;
p:
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10033 }); //SENCE_咖啡杯检测
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
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}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!");
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10050 }); //SENCE_咖啡杯回原点
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
morkT.GetCoffeeCup = false;
return;
}
DeviceProcessLogShow("执行二次取咖啡杯");
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10035 }); //SENCE_二次取咖啡杯
Wait();
EventBus.EventBus.GetInstance().Equals(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_COFFEE });//落碗控制
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
count++;
goto p;
}
morkT.GetCoffeeCup = true;
DeviceProcessLogShow("取咖啡杯完成");
}

/// <summary>
/// 冰淇淋是否可以开始制作
/// </summary>
/// <returns></returns>
private bool IceCreamCanMake()
{
bool canMake = (IsHealth && morkT.morkOrderPushesIceCream.Count > 0) ? true : false;
return canMake;
}

/// <summary>
/// 制作冰淇淋流程
/// </summary>
private void MakeIceCreamProcess()
{
//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);
// }
// }
//}

//}
}


/// <summary>
/// 做冰淇淋
/// </summary>
private void DoIceCream(OrderLocInfo order)
{
GetIceCreamCup();
CheckICeCreaCup();
if(morkT.GetIceCreamCup)
{
GetIceCream(order);
PutIceCream(order);
}
}

/// <summary>
/// 取冰淇淋杯
/// </summary>
private void GetIceCreamCup()
{
MessageLog.GetInstance.Show("准备开始制作冰淇淋");
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }, (o) => { });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10032 }); //SENCE_取冰淇淋杯
Wait();
EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_ICECREAM });//落碗控制
Thread.Sleep(500);
DeviceProcessLogShow("尝试取冰淇淋杯!");

}

/// <summary>
/// 冰淇淋杯检测,失败后机器人回到原点
/// </summary>
private void CheckICeCreaCup()
{
int count = 2;
bool result = true;
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
p:
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10034 }); //SENCE_冰淇淋杯检测
Wait();
Thread.Sleep(500);
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) =>
{
if (o != null && o.Length > 0 && o[0] is SignalResult res)
{
MessageLog.GetInstance.Show(res.ToString());
}
});
while((int)peripheralStatus["RobotValue"] != 0)
{
Thread.Sleep(10);
}
MessageLog.GetInstance.Show($"乐白机器人信号值{peripheralStatus["RobotValue"].ToString()}");
//while ((ELebaiRModel)peripheralStatus["RobotMode"] !=ELebaiRModel.空闲状态)
//{
// EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
// Thread.Sleep(500);
//}

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}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!");
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10049 }); //SENCE_冰淇淋杯回原点
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 },(o) => { });
morkT.GetIceCreamCup = false;
return;
}
DeviceProcessLogShow($"执行{count}次取冰淇淋杯!");
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10036 }); //SENCE_二次取冰淇淋杯
EventBus.EventBus.GetInstance().Equals(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_ICECREAM });//落碗控制
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
count++;
goto p;
}
morkT.GetIceCreamCup = true;
DeviceProcessLogShow("冰淇淋杯检测完成");
}

/// <summary>
/// 机器人取接冰淇淋
/// </summary>
/// <param name="order"></param>
private void GetIceCream(OrderLocInfo order)
{
//制冷模式
//EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent {DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 });
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }, (o) => { });
OrderChange(order.SuborderId, ORDER_STATUS.COOKING);
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10055 }); //SENCE_接1号冰淇淋
Wait();
bool doItResult = true;

//出料
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 });
Thread.Sleep(500);
EventBus.EventBus.GetInstance().Publish(new SCChip_MakeIceCreamEvent { DeviceId = DeviceId, SteeringEngine = IC_SE.SE_2 });//冰淇淋出料
DeviceProcessLogShow("开始等待6s");
Thread.Sleep(5000);

//出料
//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 }, (o) => { });
}

/// <summary>
/// 把冰淇淋放到取餐位后回原点
/// </summary>
/// <param name="order"></param>
private void PutIceCream(OrderLocInfo order)
{
bool resultValue = true;
while (resultValue)
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 }, (res) =>
{
if (res[0] is bool b)
{
resultValue = b;
}
});
Thread.Sleep(500);
}
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10056 }); //SENCE_放冰淇淋位置
Wait();
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { });
//订单状态改变:完成
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK);
morkT.waitMorkOrder = order;
DeviceProcessLogShow($"{order.GoodsName}等待取餐");
//WaitTakeMealOrder.Enqueue(order);

}

/// <summary>
/// 冰淇淋机器制作冰淇淋
/// </summary>
public void IceCreamCookCheck()
{
bool result = false;
int retry = 3;
DateTime beginTime = DateTime.Now;
while (!result)
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) =>
{
if (res[0] is bool resultValue)
{
result = resultValue;
}
});
if (retry <= 0 || DateTime.Now.Subtract(beginTime).TotalSeconds >= 10)
{
DeviceProcessLogShow("超时未出料,重试次数用尽");
break;
}
if (DateTime.Now.Subtract(beginTime).TotalSeconds > 5)
{
DeviceProcessLogShow("超时未出料,重新发送打料指令");
EventBus.EventBus.GetInstance().Publish( new GSIceCream_ModeSetEvent() { DeviceId =DeviceId, Mode = MORKI_MODE.打料 });
beginTime = DateTime.Now;
retry--;
}
Thread.Sleep(10);
}
DeviceProcessLogShow("开始等待6s");
Thread.Sleep(5000);

}

public override void SimOrder()
{
throw new NotImplementedException();
}
}
}

+ 118
- 0
BPASmartClient.MorkT_HQ/GLV_MorkT_HQ.cs View File

@@ -0,0 +1,118 @@
using BPASmartClient.Device;
using BPASmartClient.DRCoffee;
using BPASmartClient.GSIceCream;
using BPASmartClient.LebaiRobot;
using BPASmartClient.Model.冰淇淋.Enum;
using Robotc;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkT_HQ
{
public class GLV_MorkT_HQ:IStatus
{
/// <summary>
/// 咖啡订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesCoffee = new ConcurrentQueue<OrderLocInfo>();

/// <summary>
/// 冰淇淋订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesIceCream = new ConcurrentQueue<OrderLocInfo>();
/// <summary>
/// 等待取餐订单
/// </summary>
public OrderLocInfo waitMorkOrder = null;
/// <summary>
/// 物料存放位置
/// </summary>
public Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>();

/// <summary>
/// 当前正在制作咖啡
/// </summary>
public OrderLocInfo MakeCoffeeOrder = new OrderLocInfo();



/// <summary>
/// 咖啡机位置是否有咖啡在制作中
/// </summary>
public bool IsCoffeeMake = false;
/// <summary>
/// 冰淇淋机器出料口传感器检测
/// </summary>
public bool IceIsOK = true;
/// <summary>
/// 去咖啡杯成功
/// </summary>
public bool GetCoffeeCup;
/// <summary>
/// 取冰淇淋杯成功
/// </summary>
public bool GetIceCreamCup;

#region

[VariableMonitor("机器人连接状态")]
public bool RobotIsConnected { get; set; }

[VariableMonitor("机器人状态")]
public ELebaiRModel RobotMode { get; set; }

[VariableMonitor("冰淇淋连接状态")]
public bool IceCreamIsConnected { get; set; }

[VariableMonitor("冰淇淋机器预冷温度")]
public short YLWD { get; set; }

[VariableMonitor("冰淇淋机器回气温度")]
public short HQWD { get; set; }

[VariableMonitor("冰淇淋机器环境温度")]
public short HJWD { get; set; }

[VariableMonitor("冰淇淋机器电流")]
public short DL { get; set; }

[VariableMonitor("冰淇淋机器电压")]
public short DY { get; set; }

[VariableMonitor("冰淇淋机器成型比")]
public byte CBX { get; set; }

[VariableMonitor("冰淇淋机器模式")]
public MORKI_MODE IceCreamMode { get; set; }

[VariableMonitor("冰淇淋机器故障")]
public MORKI_FAULT IceCreamFault { get; set; }

[VariableMonitor("冰淇淋机器打料完成")]
public bool DLCompleted { get; set; }

[VariableMonitor("咖啡机连接状态")]
public bool CoffeeIsConnected { get; set; }

[VariableMonitor("咖啡机状态")]
public DrCoffeeStatus DrCoffeeStatus { get; set; }

[VariableMonitor("咖啡机应用状态")]
public DrCoffeeAppStatus CoffeeAppStatus { get; set; }

[VariableMonitor("咖啡机告警")]
public DrCoffeeWarning CoffeeWarning { get; set; }

[VariableMonitor("咖啡机故障")]
public DrCoffeeFault CaffeeFault { get; set; }

[VariableMonitor("单片机连接状态")]
public bool SCChipIsConnect { get; set; }

#endregion
}
}

+ 25
- 0
BPASmartClient.MorkT_HQ/OrderLocInfo.cs View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkT_HQ
{
public class OrderLocInfo
{
public string SuborderId { get; set; }
public string GoodsName { get; set; }
public string Loc { get; set; }
public int SortNum { get; set; }
public int BatchingId { get; set; }

public int OrderStatus { get; set; }

public OrderLocInfo()
{
OrderStatus = 0;
}
}
}

+ 124
- 0
BPASmartClient.MorkT_HQ/PolymerBatching.cs View File

@@ -0,0 +1,124 @@

using BPASmartClient.Lebai;
using BPASmartClient.LebaiRobot;
using BPASmartClient.Model.单片机.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkT_HQ
{
public enum GOODS_TYPE
{
NEITHER,
COFFEE,
ICECREAM,
JUICE
}

public enum BATCHING_CLASS
{
HOLDER,
MAIN_MATERIAL,
}

public class PolymerBatching
{
internal const string ICE_MAIN_BATCHIN1_LOC = "52";
internal const string ICE_MAIN_BATCHIN2_LOC = "53";
internal const string ICE_MAIN_BATCHIN3_LOC = "54";
internal const string COFFEE_HOLDER_LOC = "30";
internal const string ICE_HOLDER_LOC = "51";
public static Dictionary<string, GOODS_TYPE> GOODS_TYPES = new Dictionary<string, GOODS_TYPE>() {
{"1", GOODS_TYPE.COFFEE},
{"2", GOODS_TYPE.COFFEE},
{"3", GOODS_TYPE.COFFEE},
{"4", GOODS_TYPE.COFFEE},
{"5", GOODS_TYPE.COFFEE},
{"6", GOODS_TYPE.COFFEE},
{"7", GOODS_TYPE.COFFEE},
{"8", GOODS_TYPE.COFFEE},
{"9", GOODS_TYPE.COFFEE},
{"10",GOODS_TYPE.COFFEE},
{"11",GOODS_TYPE.COFFEE},
{"12",GOODS_TYPE.COFFEE},
{"13",GOODS_TYPE.COFFEE},
{"14",GOODS_TYPE.COFFEE},
{"15",GOODS_TYPE.COFFEE},
{"16",GOODS_TYPE.COFFEE},
{"17",GOODS_TYPE.COFFEE},
{"18",GOODS_TYPE.COFFEE},
{"19",GOODS_TYPE.COFFEE},
{"20",GOODS_TYPE.COFFEE},
{"21",GOODS_TYPE.COFFEE},
{"22",GOODS_TYPE.COFFEE},
{"23",GOODS_TYPE.COFFEE},
{"24",GOODS_TYPE.COFFEE},
{"25",GOODS_TYPE.COFFEE},
{"30",GOODS_TYPE.COFFEE},
{"51",GOODS_TYPE.ICECREAM},
{ICE_MAIN_BATCHIN1_LOC,GOODS_TYPE.ICECREAM},
{ICE_MAIN_BATCHIN2_LOC,GOODS_TYPE.ICECREAM},
{ICE_MAIN_BATCHIN3_LOC,GOODS_TYPE.ICECREAM},
};

public GOODS_TYPE GoodsType { get; set; }
public BATCHING_CLASS BatchingClass { get; set; }
private string loc;

public string Loc
{
get { return loc; }
set
{
loc = value;
if (GOODS_TYPES.ContainsKey(loc))
GoodsType = GOODS_TYPES[loc];
switch (loc)
{
case COFFEE_HOLDER_LOC:
case ICE_HOLDER_LOC:
BatchingClass = BATCHING_CLASS.HOLDER;
break;
default:
BatchingClass = BATCHING_CLASS.MAIN_MATERIAL;
break;
}
}
}

internal static Dictionary<string, PolymerBatching> BuildAll()
{
Dictionary<string, PolymerBatching> temp = new Dictionary<string, PolymerBatching>();
foreach (var item in GOODS_TYPES)
{
temp.Add(item.Key, new PolymerBatching() { Loc = item.Key });
}
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;

// 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;

// default:
// sence = LebaiHelper.SENCE_接1号冰淇淋;
// return IC_SE.SE_1;
// }
//}
}
}

+ 266
- 0
BPASmartClient.MorkT_HQ/View/DebugView.xaml View File

@@ -0,0 +1,266 @@
<UserControl x:Class="BPASmartClient.MorkT_HQ.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:vm ="clr-namespace:BPASmartClient.MorkT_HQ.ViewModel"
mc:Ignorable="d"
Name="调试界面"
d:DesignHeight="500" d:DesignWidth="1000" Unloaded="Dubug_Unloaded">
<UserControl.DataContext>
<vm:DebugViewModel />
</UserControl.DataContext>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="14*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="20*"/>
</Grid.RowDefinitions>

<GroupBox Grid.ColumnSpan="2"
FontFamily="楷体"
FontSize="20"
Header=" 乐白机器人 ">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<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"/>
<TextBlock Text="乐白机器人控制"
Grid.Row="1"
VerticalAlignment="Center" HorizontalAlignment="Center"/>
<ListBox Grid.Row="2" Background="Transparent">
<ListBox.Template>
<ControlTemplate TargetType="{x:Type ListBox}">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<WrapPanel Orientation="Horizontal" IsItemsHost="True" ScrollViewer.CanContentScroll="True"/>
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
<Button Content="机器人启动"
Margin="20,5" Width="150" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人启动">
</Button>
<Button Content="启动示教"
Margin="20,5" Width="150" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="启动示教"/>
<Button Content="停止示教"
Margin="20,5" Width="150" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="停止示教"/>
<Button Content="机器人急停"
Margin="20,5" Width="110" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人急停"/>

</ListBox>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2"
FontFamily="楷体"
FontSize="20"
Header=" 冰淇淋机器 ">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding IceCreamConnected}"
Margin="120,0,0,0"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>

<TextBlock Grid.Row="0" Grid.Column="0">预冷温度</TextBlock>
<TextBlock
Grid.Row="0"
Grid.Column="1"
Text="{Binding YLWD}" />
<TextBlock Grid.Row="0" Grid.Column="2">回气温度</TextBlock>
<TextBlock
Grid.Row="0"
Grid.Column="3"
Text="{Binding HQWD}" />

<TextBlock Grid.Row="1" Grid.Column="0">环境温度</TextBlock>
<TextBlock
Grid.Row="1"
Grid.Column="1"
Text="{Binding HJWD}" />
<TextBlock Grid.Row="1" Grid.Column="2">当前模式</TextBlock>
<TextBlock
Grid.Row="1"
Grid.Column="3"
Text="{Binding CurrentMode}" />

<TextBlock Grid.Row="2" Grid.Column="0">电流</TextBlock>
<TextBlock
Grid.Row="2"
Grid.Column="1"
Text="{Binding DL}" />
<TextBlock Grid.Row="2" Grid.Column="2">电压</TextBlock>
<TextBlock
Grid.Row="2"
Grid.Column="3"
Text="{Binding DY}" />

<TextBlock Grid.Row="3" Grid.Column="0">成型比</TextBlock>
<TextBlock
Grid.Row="3"
Grid.Column="1"
Text="{Binding CXB}" />
<TextBlock Grid.Row="3" Grid.Column="2">故障</TextBlock>
<TextBlock
Grid.Row="3"
Grid.Column="3"
Text="{Binding IceCreamFault}" />
</Grid>
<StackPanel Grid.Row="2" Orientation="Vertical">
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>冰淇淋</TextBlock>
<Button Command="{Binding Button_MakeIceCreamCommand}"
Margin="20,0"
Content="制作" />
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>模式</TextBlock>
<ComboBox Width="100"
Margin="20,0"
ItemsSource="{Binding IceCreamModes}"
SelectedItem="{Binding SelecteIceCreamdMode}" />
<Button Command="{Binding Button_SetIceCreamModelCommand}"
Margin="20,0"
Content="设置" />
</StackPanel>
</StackPanel>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2" Grid.Column="1"
FontFamily="楷体"
FontSize="20"
Header=" 咖啡机">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding CoffeeConnected}"
Margin="120,0,0,0"/>
<Grid Grid.Row="1">
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="99" />
<ColumnDefinition Width="140" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="171" />
</Grid.ColumnDefinitions>
<TextBlock Height="23" Width="100" FontSize="18" HorizontalAlignment="Center">咖啡机状态</TextBlock>
<TextBlock FontSize="18"
Grid.Column="1"
Text="{Binding CoffeeStatus}" Height="23" />
<TextBlock Grid.Column="2" Height="23" Width="80" FontSize="18">应用状态</TextBlock>
<TextBlock FontSize="18"
Grid.Column="3"
Text="{Binding AppStatus}" Height="23"/>
<TextBlock Grid.Row="1" Grid.Column="0" Height="22" Width="80" FontSize="18">告警信息</TextBlock>
<TextBlock FontSize="15"
Grid.Row="1"
Grid.Column="1"
Text="{Binding Warning}" />
<TextBlock Grid.Row="1" Grid.Column="2" Height="22" Width="80" FontSize="18">故障信息</TextBlock>
<TextBlock FontSize="18"
Grid.Row="1"
Grid.Column="3"
Text="{Binding CaffeeFault}" Height="22" Width="60" />
</Grid>
<StackPanel Grid.Row="2" Orientation="Vertical">
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>饮品</TextBlock>
<ComboBox Margin="10,0"
Width="100"
ItemsSource="{Binding Coffees}"
SelectedItem="{Binding SelectedCoffee}" />
<Button Margin="10,0"
Command="{}"
Content="制作"/>
<Button Margin="10,0"
Command="{}"
Content="停止制作"/>
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>模式</TextBlock>
<ComboBox Margin="10,0"
Width="100"
ItemsSource="{Binding CoffeeCmds}"
SelectedItem="{Binding SelectedCoffeeCmd}"/>
<Button Margin="10,0"
Command="{}"
Content="设置" Cursor="Hand"/>
</StackPanel>
</StackPanel>
</Grid>
</GroupBox>
<GroupBox Header="单片机控制"
FontSize="18"
Grid.Row="1" Grid.ColumnSpan="2"
Margin="0,0,0,10" HorizontalAlignment="Right" Width="1000">
<StackPanel Orientation="Horizontal"
VerticalAlignment="Center" >

</StackPanel>
</GroupBox>

</Grid>
</UserControl>

+ 35
- 0
BPASmartClient.MorkT_HQ/View/DebugView.xaml.cs View File

@@ -0,0 +1,35 @@
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_HQ.View
{
/// <summary>
/// MorkT_DebugView.xaml 的交互逻辑
/// </summary>
public partial class DebugView : UserControl
{
public DebugView()
{
InitializeComponent();
}

private void Dubug_Unloaded(object sender, RoutedEventArgs e)
{
//ThreadManage.GetInstance().StopTask("MorkT-状态刷新");
//ThreadManage.GetInstance().StopTask("MorkT-传感器监视");
}
}
}

+ 75
- 0
BPASmartClient.MorkT_HQ/View/Monitor.xaml View File

@@ -0,0 +1,75 @@
<UserControl x:Class="BPASmartClient.MorkT_HQ.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_HQ.View"
xmlns:vm="clr-namespace:BPASmartClient.MorkT_HQ.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="&#xea6b;"/>
<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>

+ 34
- 0
BPASmartClient.MorkT_HQ/View/Monitor.xaml.cs View File

@@ -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_HQ.View
{
/// <summary>
/// Monitor.xaml 的交互逻辑
/// </summary>
public partial class Monitor : UserControl
{
public Monitor()
{
InitializeComponent();
}


private void Monitor_Unloaded(object sender, RoutedEventArgs e)
{
}
}
}

+ 13
- 0
BPASmartClient.MorkT_HQ/View/ParSer.xaml View File

@@ -0,0 +1,13 @@
<UserControl x:Class="BPASmartClient.MorkT_HQ.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_HQ.View"
mc:Ignorable="d"
Name="参数设置界面"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>

+ 28
- 0
BPASmartClient.MorkT_HQ/View/ParSer.xaml.cs View File

@@ -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_HQ.View
{
/// <summary>
/// ParSer.xaml 的交互逻辑
/// </summary>
public partial class ParSer : UserControl
{
public ParSer()
{
InitializeComponent();
}
}
}

+ 326
- 0
BPASmartClient.MorkT_HQ/ViewModel/DebugViewModel.cs View File

@@ -0,0 +1,326 @@
using BPASmartClient.Business;
using BPASmartClient.Device;
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.单片机;
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.Collections.ObjectModel;
using System.Linq;
using System.Threading;

namespace BPASmartClient.MorkT_HQ.ViewModel
{
public class DebugViewModel : ObservableObject
{
#region 乐白机器人
/// <summary>
/// 乐白机器人连接状态
/// </summary>
public string RobotConnected { get { return _robotConnected; } set { _robotConnected = value; OnPropertyChanged(); } }
private string _robotConnected { get; set; }
/// <summary>
/// 乐白机器人的模式状态
/// </summary>
public string RobotMode { get { return _robotMode; } set { _robotMode = value; OnPropertyChanged(); } }
private string _robotMode { get; set; }
/// <summary>
/// 机器人控制指令
/// </summary>
public RelayCommand<object> Button_RobotControlCommand { get; set; }
/// <summary>
/// 机器人控制
/// </summary>
/// <param name="o"></param>
public RelayCommand Button_SetValueCommand { get; set; }

private void Button_SetValue()
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 });
}
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 string YLWD { get { return _yLWD; } set { _yLWD = value; OnPropertyChanged(); } }
private string _yLWD { get; set; }
/// <summary>
/// 回气温度
/// </summary>
public string HQWD { get { return _hQWD; } set { _hQWD = value; OnPropertyChanged(); } }
private string _hQWD { get; set; }
/// <summary>
/// 环境温度
/// </summary>
public string HJWD { get { return _hJWD; } set { _hJWD = value; OnPropertyChanged(); } }
private string _hJWD { get; set; }
/// <summary>
/// 电流
/// </summary>
public string DL { get { return _DL; } set { _DL = value; OnPropertyChanged(); } }
private string _DL { get; set; }
/// <summary>
/// 电压
/// </summary>
public string DY { get { return _dy; } set { _dy = value; OnPropertyChanged(); } }
private string _dy { get; set; }
/// <summary>
/// 当前模式
/// </summary>
public string CurrentMode { get { return _CurrentMode; } set { _CurrentMode = value; OnPropertyChanged(); } }
private string _CurrentMode;
/// <summary>
/// 故障
/// </summary>
public string IceCreamFault { get { return _IceCreamFault; } set { _IceCreamFault = value; OnPropertyChanged(); } }
private string _IceCreamFault { get; set; }
/// <summary>
/// 成型比
/// </summary>
public string CXB { get { return _cXB; } set { _cXB = value; OnPropertyChanged(); } }
private string _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 string CoffeeStatus { get { return _coffeeStatus; } set { _coffeeStatus = value; OnPropertyChanged(); } }
private string _coffeeStatus { get; set; }
/// <summary>
/// 应用状态
/// </summary>
public string AppStatus { get { return _appStatus; } set { _appStatus = value; OnPropertyChanged(); } }
private string _appStatus { get; set; }
/// <summary>
/// 告警
/// </summary>
public string Warning { get { return _warning; } set { _warning = value; OnPropertyChanged(); } }
public string _warning { get; set; }
/// <summary>
/// 故障信息
/// </summary>
public string CaffeeFault { get { return _caffeeFault; } set { _caffeeFault = value; OnPropertyChanged(); } }
public string _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; }
/// <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

#region 单片机
/// <summary>
/// 单片机连接状态
/// </summary>
public string SCChipIsConnect { get { return _sCChipIsConnect; } set { _sCChipIsConnect = value; OnPropertyChanged(); } }
private string _sCChipIsConnect { get; set; }
/// <summary>
/// 咖啡杯或冰淇淋杯落杯
/// </summary>
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; }

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()
{
Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl);
Button_SetValueCommand = new RelayCommand(Button_SetValue);

Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream);
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)))
{
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];

Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device =>
{
if (device.Name == "MorkT") DeviceId = device.DeviceId
;
});
ThreadManage.GetInstance().StartLong(new Action(() =>
{

variableMonitors = Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices()?.FirstOrDefault(p => p.DeviceId == DeviceId)?.variableMonitors;

if (variableMonitors != null && variableMonitors.Count > 0)
{
RobotConnected = variableMonitors.FirstOrDefault(p=>p.Notes == "机器人连接状态").CurrentValue == "True" ? "已连接" : "未连接";
IceCreamConnected = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋连接状态").CurrentValue == "True" ? "已连接" : "未连接";
CoffeeConnected = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
SCChipIsConnect = variableMonitors.FirstOrDefault(p => p.Notes == "单片机连接状态").CurrentValue == "True" ? "已连接" : "未连接";

RobotMode = variableMonitors.FirstOrDefault(p => p.Notes == "机器人状态").CurrentValue;

CoffeeStatus = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机状态").CurrentValue;
AppStatus = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机应用状态").CurrentValue;
Warning = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机告警").CurrentValue;
CaffeeFault = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机故障").CurrentValue;

YLWD = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器预冷温度").CurrentValue;
HQWD = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器回气温度").CurrentValue;
HJWD = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器环境温度").CurrentValue;
DL = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器电流").CurrentValue;
DY = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器电压").CurrentValue;
CurrentMode = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器模式").CurrentValue;
IceCreamFault = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器故障").CurrentValue;
CXB = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器成型比").CurrentValue;
DLCompleted = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器打料完成")?.CurrentValue == "True" ? "打料完成" : "打料中";
}
Thread.Sleep(500);
}), "MorkT-状态刷新");
}

}
}

+ 94
- 0
BPASmartClient.MorkT_HQ/ViewModel/MonitorViewModel.cs View File

@@ -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_HQ.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();
}
}

}

+ 2
- 2
BPASmartClient.SCChip/ICChipMachine.cs View File

@@ -196,7 +196,7 @@ namespace BPASmartClient.SCChip
{
case IC_CMD.HEART_BEAT:
lastRefreshTime = DateTime.Now;
status["OnLine"] = OnLine;
status["SCChipIsConnect"] = OnLine;
break;
case IC_CMD.TAKE_CUP:
switch ((IC_CUP)data.Value)
@@ -351,7 +351,7 @@ namespace BPASmartClient.SCChip
}
Thread.Sleep(10);
}
Thread.Sleep(2000);
Thread.Sleep(1700);
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
{
case IC_SE.SE_1:


+ 23
- 1
BPASmartClient/MainWindow.xaml View File

@@ -16,6 +16,7 @@
Topmost="False"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
WindowState="Maximized"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
@@ -50,7 +51,28 @@
VerticalAlignment="Center"
Style="{DynamicResource imagetop_Title}" />
<Grid Grid.Column="1">
<Menu x:Name="myMenu">
<!--#region 用户菜单界面-->
<StackPanel x:Name="myPanel" Orientation="Horizontal" Visibility="Visible" >
<Button Height="40" Width="120"
Content="日志监视"
Margin="50,0,20,0"
Click="MenuItem_Click"
Tag ="LogView"
/>
<Button Height="40" Width="120"
Content="设备监控"
Margin="20,0" Cursor="Hand"
Click="DeviceMonitor_Click"
Tag =""/>
<Button Height="40" Width="120"
Margin="20,0"
Content="订单监视"
Click="MenuItem_Click"
Tag ="OrderStatusView" Cursor="Hand"/>
</StackPanel>
<!--#endregion-->
<Menu x:Name="myMenu" Visibility="Collapsed">
<MenuItem Header="功能列表">
<MenuItem
Click="MenuItem_Click"


+ 41
- 1
BPASmartClient/MainWindow.xaml.cs View File

@@ -48,6 +48,7 @@ namespace BPASmartClient
ActionManage.GetInstance.Register(new Action(() =>
{
myMenu.Visibility = Visibility.Visible;
myPanel.Visibility = Visibility.Collapsed;
MenuItem_Click(new MenuItem() { Tag = "LogView", Header = "日志监视" }, null);
}), "LoginSuccess");
Initialize();
@@ -59,7 +60,15 @@ namespace BPASmartClient
/// </summary>
private void Initialize()
{
this.ButClose.Click += (o, e) => { this.Close(); };
this.ButClose.Click += (o, e) =>
{
MessageBoxResult res = MessageBox.Show("确定关闭上位机软件?", "警告", MessageBoxButton.OKCancel);
if(res == MessageBoxResult.OK)
{
this.Close();
}
};
this.br.MouseLeftButtonDown += (o, e) =>
{
if (e.ClickCount > 1)
@@ -220,6 +229,13 @@ namespace BPASmartClient
contentRegion.Content = (FrameworkElement)cti.Invoke(null);
Title.Text = (sender as MenuItem).Header?.ToString() + "界面";
}
else if(sender is Button)
{
Type type = Type.GetType($"BPASmartClient.Control.{(sender as Button).Tag?.ToString()}");
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
contentRegion.Content = (FrameworkElement)cti.Invoke(null);
Title.Text = (sender as Button).Content?.ToString() + "界面";
}
}
catch (Exception ex)
{
@@ -329,8 +345,32 @@ namespace BPASmartClient
private void Button_LogOut(object sender, RoutedEventArgs e)
{
myMenu.Visibility = Visibility.Hidden;
myPanel.Visibility = Visibility.Visible;
}
#endregion

private void DeviceMonitor_Click(object sender, RoutedEventArgs e)
{
string deviceName = string.Empty;
var result = Plugin.GetInstance().GetPlugin<ConfigMgr>()?.deviceConfigModelJsons;
if (result != null)
{
foreach (var shop in result)//店铺集合
{
deviceName = shop.deviceModels[0].DeviceName;
}
}
if(deviceName != null)
{
Type type = Assembly.Load($"BPASmartClient.{deviceName}").GetType($"BPASmartClient.{deviceName}.View.DebugView");
if (type == null) return;
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
contentRegion.Content = (FrameworkElement)cti.Invoke(null);
Title.Text = "设备监控界面";
}



}
}
}

+ 23
- 0
SmartClient.sln View File

@@ -92,6 +92,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.JAKA", "BPAS
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Juicer", "BPASmartClient.Juicer\BPASmartClient.Juicer.csproj", "{C28A88B1-E449-484C-AC67-B5038FF2CA79}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_HQ", "BPASmartClient.MorkT_HQ\BPASmartClient.MorkT_HQ.csproj", "{00C17D87-A323-4A97-BC21-7039E55614DE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DosingSystem", "DosingSystem\DosingSystem.csproj", "{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}"
EndProject
Global
@@ -828,6 +830,26 @@ Global
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|x64.Build.0 = Release|Any CPU
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|x86.ActiveCfg = Release|Any CPU
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|x86.Build.0 = Release|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Debug|ARM.ActiveCfg = Debug|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Debug|ARM.Build.0 = Debug|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Debug|ARM64.Build.0 = Debug|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Debug|x64.ActiveCfg = Debug|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Debug|x64.Build.0 = Debug|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Debug|x86.ActiveCfg = Debug|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Debug|x86.Build.0 = Debug|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|Any CPU.Build.0 = Release|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|ARM.ActiveCfg = Release|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|ARM.Build.0 = Release|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|ARM64.ActiveCfg = Release|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|ARM64.Build.0 = Release|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|x64.ActiveCfg = Release|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|x64.Build.0 = Release|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|x86.ActiveCfg = Release|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|x86.Build.0 = Release|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|ARM.ActiveCfg = Debug|Any CPU
@@ -889,6 +911,7 @@ Global
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625}
{C935435D-6182-4A01-8E59-B832B2FF0D72} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD}
{C28A88B1-E449-484C-AC67-B5038FF2CA79} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD}
{00C17D87-A323-4A97-BC21-7039E55614DE} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution


Loading…
Cancel
Save