Просмотр исходного кода

更新集装箱morkT代码

样式分支
pengliangyang 2 лет назад
Родитель
Сommit
229dac8d5e
31 измененных файлов: 2897 добавлений и 275 удалений
  1. +10
    -1
      BPASmartClient.Device/VariableMonitor.cs
  2. +17
    -1
      BPASmartClient.IceMaker/IceMakerMachine.cs
  3. +17
    -0
      BPASmartClient.IceMaker/IceMakerStatus.cs
  4. +2
    -1
      BPASmartClient.Juicer/JuicerMachine.cs
  5. +7
    -5
      BPASmartClient.Lebai/LebaiRobot.cs
  6. +16
    -0
      BPASmartClient.Model/果汁机/IceMaker.cs
  7. +17
    -0
      BPASmartClient.Model/订单/MorkTSimOrder.cs
  8. +0
    -1
      BPASmartClient.MorkT/ViewModel/DebugViewModel.cs
  9. +10
    -4
      BPASmartClient.MorkT_BarCounter/BPASmartClient.MorkT_BarCounter.csproj
  10. +417
    -174
      BPASmartClient.MorkT_BarCounter/Control_MorkT_BarCounter.cs
  11. +80
    -14
      BPASmartClient.MorkT_BarCounter/GVL_MorkT.cs
  12. +1
    -1
      BPASmartClient.MorkT_BarCounter/OrderLocInfo.cs
  13. +0
    -18
      BPASmartClient.MorkT_BarCounter/SendToPlc.cs
  14. +440
    -0
      BPASmartClient.MorkT_BarCounter/View/DebugView.xaml
  15. +37
    -0
      BPASmartClient.MorkT_BarCounter/View/DebugView.xaml.cs
  16. +385
    -0
      BPASmartClient.MorkT_BarCounter/ViewModel/DebugViewModel.cs
  17. +94
    -0
      BPASmartClient.MorkT_BarCounter/ViewModel/MonitorViewModel.cs
  18. +9
    -2
      BPASmartClient.MorkT_Container/BPASmartClient.MorkT_Container.csproj
  19. +244
    -25
      BPASmartClient.MorkT_Container/Control_MorkT_Container.cs
  20. +76
    -2
      BPASmartClient.MorkT_Container/GVL_MorkT.cs
  21. +1
    -0
      BPASmartClient.MorkT_Container/OrderLocInfo.cs
  22. +0
    -0
      BPASmartClient.MorkT_Container/PolymerBatching.cs
  23. +443
    -0
      BPASmartClient.MorkT_Container/View/DebugView.xaml
  24. +37
    -0
      BPASmartClient.MorkT_Container/View/DebugView.xaml.cs
  25. +393
    -0
      BPASmartClient.MorkT_Container/ViewModel/DebugViewModel.cs
  26. +92
    -0
      BPASmartClient.MorkT_Container/ViewModel/MonitorViewModel.cs
  27. +7
    -2
      BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml
  28. +4
    -0
      BPASmartClient.Socket/BPASmartClient.Socket.csproj
  29. +24
    -24
      SmartClient.sln
  30. +8
    -0
      WpfLibrary1/Class1.cs
  31. +9
    -0
      WpfLibrary1/WpfLibrary1.csproj

+ 10
- 1
BPASmartClient.Device/VariableMonitor.cs Просмотреть файл

@@ -48,7 +48,16 @@ namespace BPASmartClient.Device
}
}
private string _mCurrentValue;

public bool SwitchValue
{
get { return _sWitchValue; }
set
{
_sWitchValue = value;
OnPropertyChanged();
}
}
private bool _sWitchValue;
public object StatusColor { get; set; }
}
}

+ 17
- 1
BPASmartClient.IceMaker/IceMakerMachine.cs Просмотреть файл

@@ -23,7 +23,8 @@ namespace BPASmartClient.Icemoker
IsWork = true;
if (status != null)
{
SetStatus("GetDeviceStatus", iceMakerHelper.GetDeviceStatus());
SetStatus("MakeIceDeviceStatus", iceMakerHelper.GetDeviceStatus());
SetStatus("MakeIceConnected", IsConnected);
}
Thread.Sleep(500);
}
@@ -40,6 +41,21 @@ namespace BPASmartClient.Icemoker
if (@event == null) return;
iceMakerHelper.EndCook();
});
EventBus.EventBus.GetInstance().Subscribe<PumpMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (@event == null) return;
iceMakerHelper.pump();
});
EventBus.EventBus.GetInstance().Subscribe<StandbyMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (@event == null) return;
iceMakerHelper.Standby();
});
EventBus.EventBus.GetInstance().Subscribe<PowerOnMakeIce>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (@event == null) return;
iceMakerHelper.PowerOn();
});
EventBus.EventBus.GetInstance().Subscribe<SetIceNumber>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (@event == null) return;


+ 17
- 0
BPASmartClient.IceMaker/IceMakerStatus.cs Просмотреть файл

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

namespace BPASmartClient.IceMaker
{
public enum IceMakerStatus
{
关机状态=0x01,
制冰状态=0x02,
电机故障=0x04,
缺水=0x08,
冰满=0x16
}
}

+ 2
- 1
BPASmartClient.Juicer/JuicerMachine.cs Просмотреть файл

@@ -23,7 +23,8 @@ namespace BPASmartClient.Juicer
IsWork = true;
if (status != null)
{
SetStatus("GetDeviceStatus", juicerHelper.GetDeviceStatus());
SetStatus("GetJuicerDeviceStatus", juicerHelper.GetDeviceStatus());
SetStatus("GetJuicerConnected", IsConnected);
}
Thread.Sleep(500);
}


+ 7
- 5
BPASmartClient.Lebai/LebaiRobot.cs Просмотреть файл

@@ -50,9 +50,11 @@ namespace BPASmartClient.Lebai
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["GetInput"] = LebaiHelper.GetInstance().GetInput();
status["GetInput2"] = LebaiHelper.GetInstance().GetInput(2);
status["LeibaiGetTcpInput"] = LebaiHelper.GetInstance().GetTcpInput();
status["LeibaiGetInput1"] = LebaiHelper.GetInstance().GetInput(1);
status["LeibaiGetInput2"] = LebaiHelper.GetInstance().GetInput(2);
status["LeibaiGetInput3"] = LebaiHelper.GetInstance().GetInput(3);
status["LeibaiGetInput4"] = LebaiHelper.GetInstance().GetInput(4);
if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] = LebaiHelper.GetInstance().robotData.RobotMode.Mode;
LebaiHelper.GetInstance().GetRobotModeStatus();
Thread.Sleep(10);
@@ -105,7 +107,7 @@ namespace BPASmartClient.Lebai
{
switch (lebaiControlEvent.LebaiControl)
{
case "机器人启动":
case "启动":
LebaiHelper.GetInstance().StartRobot();
break;
case "启动示教":
@@ -114,7 +116,7 @@ namespace BPASmartClient.Lebai
case "停止示教":
LebaiHelper.GetInstance().EndtTeachMode();
break;
case "机器人急停":
case "急停":
LebaiHelper.GetInstance().EStopRobot();
break;
case "暂停":


+ 16
- 0
BPASmartClient.Model/果汁机/IceMaker.cs Просмотреть файл

@@ -18,9 +18,25 @@ namespace BPASmartClient.Model
public class StopMakeIce : BaseEvent
{

}
public class PumpMakeIce : BaseEvent
{

}
public class PowerOnMakeIce : BaseEvent
{

}
public class StandbyMakeIce : BaseEvent
{

}
public class SetIceNumber : WriteModel
{

}
public class IceMakerState : ReadModel
{

}
}

+ 17
- 0
BPASmartClient.Model/订单/MorkTSimOrder.cs Просмотреть файл

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

using BPASmartClient.Model.咖啡机.Enum;
namespace BPASmartClient.Model
{
public class MorkTSimOrder : BaseEvent
{
public int OrderNum { get; set; }
public DrCoffeeDrinksCode DrinkCode { get; set; }
public int JuiceList { get; set; }
public string JuiceMakeID{ get; set; }
}
}

+ 0
- 1
BPASmartClient.MorkT/ViewModel/DebugViewModel.cs Просмотреть файл

@@ -317,7 +317,6 @@ namespace BPASmartClient.MorkT.ViewModel
CXB = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器成型比").CurrentValue;
DLCompleted = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器打料完成")?.CurrentValue == "True" ? "打料完成" : "打料中";
}
Thread.Sleep(500);
}), "MorkT-状态刷新");
}


+ 10
- 4
BPASmartClient.MorkT_BarCounter/BPASmartClient.MorkT_BarCounter.csproj Просмотреть файл

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

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
@@ -17,4 +17,10 @@
<ProjectReference Include="..\BPASmartClient.MCU\BPASmartClient.MCU.csproj" />
</ItemGroup>

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

</Project>

+ 417
- 174
BPASmartClient.MorkT_BarCounter/Control_MorkT_BarCounter.cs
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 80
- 14
BPASmartClient.MorkT_BarCounter/GVL_MorkT.cs Просмотреть файл

@@ -5,6 +5,9 @@ using System.Text;
using System.Threading.Tasks;
using BPASmartClient.Device;
using System.Collections.Concurrent;
using BPASmartClient.LebaiRobot;
using BPASmartClient.DRCoffee;
using BPASmartClient.IceMaker;

namespace BPASmartClient.MorkT_BarCounter
{
@@ -79,9 +82,8 @@ namespace BPASmartClient.MorkT_BarCounter
/// 是否有咖啡杯
/// </summary>
public bool IsHaveCoffeeCup = false;

/// <summary>
/// 咖啡是否制作完成
/// 咖啡完成,是否取咖啡杯
/// </summary>
public bool MakeCoffeeEnd = false;

@@ -90,11 +92,11 @@ namespace BPASmartClient.MorkT_BarCounter
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesJuicer = new ConcurrentQueue<OrderLocInfo>();
/// <summary>
/// 果汁是否在制作中
/// 是否有果汁杯
/// </summary>
public bool IsHaveJuiceCup = false;
/// <summary>
/// 咖啡是否制作完成
/// 出果汁完成,是否去取果汁
/// </summary>
public bool MakeJuiceEnd = false;

@@ -103,11 +105,11 @@ namespace BPASmartClient.MorkT_BarCounter
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesTea = new ConcurrentQueue<OrderLocInfo>();
/// <summary>
/// 茶或水是否在制作中
/// 接水口是否有茶水杯
/// </summary>
public bool IsHaveTeaWaterCup = false;
/// <summary>
/// 咖啡是否制作完成
/// 水已经接完,是否去取水杯
/// </summary>
public bool MakeTeaEnd = false;

@@ -131,15 +133,79 @@ namespace BPASmartClient.MorkT_BarCounter
/// </summary>
public string SuborderId = null;

#region PLC的变量交互
/// <summary>
///
/// </summary>
public bool sensorGetCup { get; set; }
public bool sensorPutCup { get; set; }

#region

[VariableMonitor("机器人连接状态")]
public bool RobotIsConnected { get; set; }
[VariableMonitor("机器人状态")]
public ELebaiRModel RobotMode { get; set; }
[VariableMonitor("机器人TCP输入状态")]
public bool RobotGetTcpInput { get; set; }
[VariableMonitor("机器人输入0状态")]
public bool RobotGetInput0{ get; set; }
[VariableMonitor("机器人输入1状态")]
public bool RobotGetInput1 { get; set; }
[VariableMonitor("机器人输入2状态")]
public bool RobotGetInput2 { get; set; }
[VariableMonitor("机器人输入3状态")]
public bool RobotGetInput3 { 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; }
[VariableMonitor("单片机输入0状态")]
public bool SCChipInput0 { get; set; }
[VariableMonitor("单片机输入1状态")]
public bool SCChipInput1 { get; set; }
[VariableMonitor("单片机输入2状态")]
public bool SCChipInput2 { get; set; }
[VariableMonitor("单片机输入3状态")]
public bool SCChipInput3 { get; set; }
[VariableMonitor("单片机输入4状态")]
public bool SCChipInput4 { get; set; }
[VariableMonitor("单片机输入5状态")]
public bool SCChipInput5 { get; set; }
[VariableMonitor("单片机输入6状态")]
public bool SCChipInput6 { get; set; }
[VariableMonitor("单片机输入7状态")]
public bool SCChipInput7 { get; set; }



[VariableMonitor("制冰机连接状态")]
public bool IceMakerConnect { get; set; }
[VariableMonitor("制冰机设备状态")]
public byte IceMakerState { get; set; }


[VariableMonitor("果汁机连接状态")]
public bool JuicerConnected { get; set; }

public int[] JuicerState{ get; set; }

[VariableMonitor("果汁机制热")]
public bool JuiceState_Heating { get; set; }
[VariableMonitor("果汁机制冷")]
public bool JuiceState_Cooling { get; set; }
[VariableMonitor("果汁机缺水")]
public bool JuiceState_LackOfWater { get; set; }
[VariableMonitor("果汁机童锁")]
public bool JuiceState_ChildLocks { get; set; }
[VariableMonitor("果汁机使用")]
public bool JuiceState_Using { get; set; }
#endregion
}
}

+ 1
- 1
BPASmartClient.MorkT_BarCounter/OrderLocInfo.cs Просмотреть файл

@@ -13,6 +13,6 @@ namespace BPASmartClient.MorkT_BarCounter
public ushort RecipeNumber { get; set; }
public int BatchingId { get; set; }
public string GoodName { get; set; }
public int MakeID { get; set; }
public string makeID { get; set; }
}
}

+ 0
- 18
BPASmartClient.MorkT_BarCounter/SendToPlc.cs Просмотреть файл

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

namespace BPASmartClient.MorkT_BarCounter
{
public enum SendToPlc
{
取杯,
咖啡,
果汁,
开水,
落茶,
制冰,
}
}

+ 440
- 0
BPASmartClient.MorkT_BarCounter/View/DebugView.xaml Просмотреть файл

@@ -0,0 +1,440 @@
<UserControl x:Class="BPASmartClient.MorkT_BarCounter.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_BarCounter.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.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="15*"/>
</Grid.RowDefinitions>
<Border BorderThickness="0,0,1,1" BorderBrush="DodgerBlue" Grid.Row="0" Grid.Column="0"></Border>
<Border BorderThickness="0,0,1,1" BorderBrush="DodgerBlue" Grid.Row="1" Grid.Column="0"></Border>
<Border BorderThickness="0,0,1,0" BorderBrush="DodgerBlue" Grid.Row="2" Grid.Column="0"></Border>
<Border BorderThickness="0,0,0,1" BorderBrush="DodgerBlue" Grid.Row="0" Grid.Column="1"></Border>
<Border BorderThickness="0,0,0,1" BorderBrush="DodgerBlue" Grid.Row="1" Grid.Column="1"></Border>
<Border BorderThickness="0,0,0,0" BorderBrush="DodgerBlue" Grid.Row="2" Grid.Column="1"></Border>
<GroupBox Grid.Row="0" Grid.Column="0"
FontFamily="楷体"
FontSize="20"
Header=" 乐白机器人 ">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="连接状态:" />
<TextBlock Text="{Binding RobotConnected}"
Margin="40,0"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<StackPanel Orientation="Horizontal">
<TextBlock Text="当前模式:" Margin="0,1"/>
<TextBlock Text="{Binding RobotMode}"
Margin="40,0"/>
</StackPanel>
</Grid>
<Grid Grid.Row="2">
<DockPanel>
<Button Content="启动" Width="50" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人启动">
</Button>
<Button Content="暂停" Width="50" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="暂停"/>
<Button Content="恢复" Width="50" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="恢复"/>
<Button Content="急停" Width="50" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人急停"/>
</DockPanel>
</Grid>
<Grid Grid.Row="0" Grid.Column="1" >
<StackPanel Orientation="Horizontal" >
<TextBlock>TCP DI:</TextBlock>
<CheckBox IsEnabled="false" IsChecked="{Binding Robot_TCPDI0}" FontSize="14">DI0</CheckBox>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.Column="1" >
<StackPanel Orientation="Horizontal" >
<TextBlock>DI:</TextBlock>
<CheckBox IsEnabled="false" Name="Robot_DI0" FontSize="14" IsChecked="{Binding Robot_DI0}">DI0</CheckBox>
<CheckBox IsEnabled="false" Name="Robot_DI1" FontSize="14" IsChecked="{Binding Robot_DI1}">DI1</CheckBox>
<CheckBox IsEnabled="false" Name="Robot_DI2" FontSize="14" IsChecked="{Binding Robot_DI2}">DI2</CheckBox>
<CheckBox IsEnabled="false" Name="Robot_DI3" FontSize="14" IsChecked="{Binding Robot_DI3}">DI3</CheckBox>
</StackPanel>
</Grid>
<Grid Grid.Row="2" Grid.Column="1">
<StackPanel Orientation="Horizontal" >
<TextBlock>DO:</TextBlock>
<ComboBox SelectedIndex="{Binding Robot_DOutput_Pin}">
<ComboBoxItem IsSelected="true">DO0</ComboBoxItem>
<ComboBoxItem>DO1</ComboBoxItem>
<ComboBoxItem>DO2</ComboBoxItem>
<ComboBoxItem>DO3</ComboBoxItem>
</ComboBox>
<ComboBox SelectedIndex="{Binding Robot_DOutput_Value}">
<ComboBoxItem IsSelected="true">true</ComboBoxItem>
<ComboBoxItem>false</ComboBoxItem>
</ComboBox>
<Button Content="输出" Command="{Binding Robot_DOutput}"/>
</StackPanel>
</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="1" Grid.Column="0"
Header="单片机控制"
FontSize="18"
FontFamily="楷体">
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0">
<StackPanel Orientation="Horizontal">
<TextBlock >连接状态:</TextBlock>
<TextBlock Text="{Binding MCUConnected}" />
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="12">DI:</TextBlock>
<CheckBox FontSize="12" IsEnabled="false" IsChecked="{Binding CH0}">DI0</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH1">DI1</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH2">DI2</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH3">DI3</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH4">DI4</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH5">DI5</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH6">DI6</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH7">DI7</CheckBox>
</StackPanel>
</Grid>
<Grid Grid.Row="2" Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="12" HorizontalAlignment="Center">DO输出</TextBlock>
<ComboBox Width="50" FontSize="12" HorizontalAlignment="Center" SelectedIndex="{Binding MCU_DO_CH}">
<ComboBoxItem IsSelected="true">DO0</ComboBoxItem>
<ComboBoxItem>DO1</ComboBoxItem>
<ComboBoxItem>DO2</ComboBoxItem>
<ComboBoxItem>DO3</ComboBoxItem>
<ComboBoxItem>DO4</ComboBoxItem>
<ComboBoxItem>DO5</ComboBoxItem>
<ComboBoxItem>DO6</ComboBoxItem>
<ComboBoxItem>DO7</ComboBoxItem>
</ComboBox>
<ComboBox FontSize="12" HorizontalAlignment="Center" SelectedIndex="{Binding MCU_DO_CH}">
<ComboBoxItem IsSelected="true">True</ComboBoxItem>
<ComboBoxItem>False</ComboBoxItem>
</ComboBox>
<Button Width="50" Command="{Binding Button_MCUDOuputCommand}">输出</Button>
</StackPanel>
</Grid>
<Grid Grid.Column="1">
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="12" HorizontalAlignment="Center">舵机控制</TextBlock>
<ComboBox Margin="0,0,0,0" FontSize="12" Width="60" SelectedIndex="{Binding MCU_PWM_CH}">
<ComboBoxItem IsSelected="true">舵机1</ComboBoxItem>
<ComboBoxItem>舵机2</ComboBoxItem>
<ComboBoxItem>舵机3</ComboBoxItem>
<ComboBoxItem>舵机4</ComboBoxItem>
</ComboBox>
<TextBox Width="50" Text="{Binding PWMInputNumber}"></TextBox>
<Button FontSize="15" HorizontalAlignment="Center" Command="{Binding Button_MCUOuputCommand}">输出</Button>
</StackPanel>
</Grid>
</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2" Grid.Column="0"
FontFamily="楷体"
FontSize="20"
Header=" 果汁机 ">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<Grid>
<TextBlock Text="连接状态:" />
</Grid>
<Grid Grid.Column="1">
<TextBlock Text="{Binding JuicerConnected}"
Margin="120,0,0,0"/>
</Grid>
<Grid Grid.Row="1">
<TextBlock Text="设备状态:" />
</Grid>
<Grid Grid.Column="1" Grid.Row="1">
<StackPanel Orientation="Horizontal" >
<Button IsEnabled="False" Command="{Binding JuiceState_Heating}" >制热</Button>
<Button IsEnabled="False" Command="{Binding JuiceState_Cooling}" >制冷</Button>
<Button IsEnabled="False" Command="{Binding JuiceState_LackOfWater}" >缺水</Button>
<Button IsEnabled="False" Command="{Binding JuiceState_ChildLocks}" >童锁</Button>
<Button IsEnabled="False" Command="{Binding JuiceState_Using}" >使用</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="2">
<TextBlock>果汁:</TextBlock>
</Grid>
<Grid Grid.Column="1" Grid.Row="2">
<StackPanel Orientation="Horizontal">
<ComboBox SelectedItem="{Binding MakeJuice_Index}">
<ComboBoxItem IsSelected="true">0</ComboBoxItem>
<ComboBoxItem>1</ComboBoxItem>
<ComboBoxItem>2</ComboBoxItem>
<ComboBoxItem>3</ComboBoxItem>
<ComboBoxItem>4</ComboBoxItem>
<ComboBoxItem>5</ComboBoxItem>
<ComboBoxItem>6</ComboBoxItem>
<ComboBoxItem>7</ComboBoxItem>
</ComboBox>
<Button Command="{Binding Button_MakeJuiceCommand}" Content="制作" />
</StackPanel>
</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="0" Grid.Column="1"
Header="订单模拟"
FontSize="18"
FontFamily="楷体">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.Column="0">
<StackPanel Orientation="Horizontal">
<TextBlock>咖啡:</TextBlock>
<ComboBox Margin="10,0"
Width="100"
ItemsSource="{Binding Coffees}"
SelectedItem="{Binding SimOrderCoffeeList}" />
<Button Command="{Binding SimOrderMakeCoffee}">制作</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.Column="0">
<StackPanel Orientation="Horizontal">
<TextBlock>果汁:</TextBlock>
<ComboBox SelectedIndex="{Binding SimOrder_JuiceList}">
<ComboBoxItem IsSelected="true" >饮品1</ComboBoxItem>
<ComboBoxItem>饮品2</ComboBoxItem>
<ComboBoxItem>饮品3</ComboBoxItem>
<ComboBoxItem>饮品4</ComboBoxItem>
</ComboBox>
<ComboBox SelectedItem="{Binding SimOrder_JuiceMakeID}">
<ComboBoxItem IsSelected="true">热饮</ComboBoxItem>
<ComboBoxItem>常温</ComboBoxItem>
<ComboBoxItem>冷饮</ComboBoxItem>
</ComboBox>
<Button Command="{Binding SimOrderMakeJuice}">制作</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<StackPanel Orientation="Horizontal">
<TextBlock>开水:</TextBlock>
<Button Command="{Binding SimOrderMakeWater}">制作</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.Column="1">
<StackPanel Orientation="Horizontal">
<TextBlock>茶水:</TextBlock>
<Button Command="{Binding SimOrderMakeTea}">制作</Button>
</StackPanel>
</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="1" Grid.Column="1"
Header="制冰机控制"
FontSize="18"
FontFamily="楷体">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<StackPanel Orientation="Horizontal" >
<TextBlock>连接状态:</TextBlock>
<TextBlock Text="{Binding IceMakerConnected}" />
</StackPanel>
</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<StackPanel Orientation="Horizontal">
<Button Command="{Binding IceMaker_BtnPowerOn}">开机</Button>
<Button Command="{Binding IceMaker_BtnStandby}">待机</Button>
<Button Command="{Binding IceMaker_BtnPump}" >抽水</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.ColumnSpan="2">
<StackPanel Orientation="Horizontal" >
<TextBlock>设备状态:</TextBlock>
<TextBlock Text="{Binding IceMakerState}" />
<Button IsEnabled="False" Name="IceMaker_State1" >开机状态</Button>
<Button IsEnabled="False" Name="IceMaker_State2" >待机状态</Button>
<Button IsEnabled="False" Name="IceMaker_State3" >电机故障</Button>
<Button IsEnabled="False" Name="IceMaker_State4" >冰满</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="2" Grid.Column="0">
<StackPanel Orientation="Horizontal">
<TextBlock>控制:</TextBlock>
<Button Command="{Binding IceMaker_BtnStart}">开始出冰</Button>
<Button Command="{Binding IceMaker_BtnEnd}">结束出冰</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="2" Grid.Column="01">
<StackPanel Orientation="Horizontal" >
<TextBlock>出冰时间:</TextBlock>
<TextBox Width="50" Text="{Binding IceMaker_IceTime}"></TextBox>
<TextBlock>s</TextBlock>
<Button Command="{Binding IceMaker_BtnSetIceTime}">设置</Button>
</StackPanel>
</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2" Grid.Column="1"
FontFamily="楷体"
FontSize="20"
Header=" 咖啡机">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0">
<TextBlock Text="连接状态" />
</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<TextBlock Text="{Binding CoffeeConnected}"
Margin="120,0,0,0"/>
</Grid>
<Grid Grid.Row="1" Grid.RowSpan="2" Grid.ColumnSpan="2">
<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>
<Grid Grid.Row="3" Grid.ColumnSpan="2">
<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="{Binding Button_MakeCoffeeCommand }"
Content="制作"/>
<Button Margin="10,0"
Command="{Binding Button_StopMakeCoffeCommand}"
Content="停止制作"/>
</StackPanel>
</Grid>
<Grid Grid.Row="4" Grid.ColumnSpan="2">
<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="{Binding Button_CoffeeModeSetCommand}"
Content="设置" Cursor="Hand"/>
</StackPanel>
</Grid>
</Grid>
</GroupBox>
</Grid>
</UserControl>

+ 37
- 0
BPASmartClient.MorkT_BarCounter/View/DebugView.xaml.cs Просмотреть файл

@@ -0,0 +1,37 @@
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_BarCounter.View
{
/// <summary>
/// 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-传感器监视");

}
}

}

+ 385
- 0
BPASmartClient.MorkT_BarCounter/ViewModel/DebugViewModel.cs Просмотреть файл

@@ -0,0 +1,385 @@
using BPASmartClient.Business;
using BPASmartClient.Device;
using BPASmartClient.DRCoffee;
using BPASmartClient.EventBus;
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_BarCounter.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; }

public RelayCommand Robot_DOutput { get; set; }
/// <summary>
/// 机器人控制
/// </summary>
/// <param name="o"></param>
private void Button_RobotControl(object o)
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiControlEvent { DeviceId = DeviceId, LebaiControl = o.ToString() });
}
private void Button_RobotDoutput()
{
bool DO_Value =int.Parse(Robot_DOutput_Value) == 0;
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetOutPutEvent { Pin = int.Parse(Robot_DOutput_Pin), Value = DO_Value });
}
public string Robot_TCPDI0 { get { return _robot_TCPDI0; } set { _robot_TCPDI0 = value;OnPropertyChanged(); } }
private string _robot_TCPDI0;

public string Robot_DI0 { get { return _robot_DI0; } set { _robot_DI0 = value; OnPropertyChanged(); } }
private string _robot_DI0;
public string Robot_DI1 { get { return _robot_DI1; } set { _robot_DI1 = value; OnPropertyChanged(); } }
private string _robot_DI1;
public string Robot_DI2 { get { return _robot_DI2; } set { _robot_DI2 = value; OnPropertyChanged(); } }
private string _robot_DI2;
public string Robot_DI3 { get { return _robot_DI3; } set { _robot_DI3 = value; OnPropertyChanged(); } }
private string _robot_DI3;

public string Robot_DOutput_Pin { get { return _robot_DOutput_Pin; } set { _robot_DOutput_Pin = value; OnPropertyChanged(); } }
private string _robot_DOutput_Pin { get; set; }
public string Robot_DOutput_Value { get { return _robot_DOutput_Valuet; } set { _robot_DOutput_Valuet = value; OnPropertyChanged(); } }
private string _robot_DOutput_Valuet { get; set; }
#endregion
#region 单片机
public string MCUConnected { get { return _mcuConnected; } set { _mcuConnected = value; OnPropertyChanged(); } }
private string _mcuConnected { get; set; }

public string MCUDI0 { get { return _mCUDI0; } set { _mCUDI0 = value; OnPropertyChanged(); } }
private string _mCUDI0 { get; set; }
public string MCUDI1 { get { return _mCUDI1; } set { _mCUDI1 = value; OnPropertyChanged(); } }
private string _mCUDI1 { get; set; }
public string MCUDI2 { get { return _mCUDI2; } set { _mCUDI2 = value; OnPropertyChanged(); } }
private string _mCUDI2 { get; set; }
public string MCUDI3 { get { return _mCUDI3; } set { _mCUDI3 = value; OnPropertyChanged(); } }
private string _mCUDI3 { get; set; }
public string MCUDI4 { get { return _mCUDI4; } set { _mCUDI4 = value; OnPropertyChanged(); } }
private string _mCUDI4 { get; set; }
public string MCUDI5 { get { return _mCUDI5; } set { _mCUDI5 = value; OnPropertyChanged(); } }
private string _mCUDI5 { get; set; }
public string MCUDI6 { get { return _mCUDI6; } set { _mCUDI6 = value; OnPropertyChanged(); } }
private string _mCUDI6 { get; set; }
public string MCUDI7 { get { return _mCUDI7; } set { _mCUDI7 = value; OnPropertyChanged(); } }
private string _mCUDI7 { get; set; }

public RelayCommand Button_MCUOuputCommand { get; set; }
public RelayCommand Button_MCUDOuputCommand { get; set; }

public int MCU_PWM_CH { get { return _choosePWM; } set { _choosePWM = value; OnPropertyChanged(); } }
private int _choosePWM = 1;
public int PWMInputNumber { get { return _pwmInputNumber; } set { _pwmInputNumber = value; OnPropertyChanged(); } }
private int _pwmInputNumber = 1;

private int[] DICH { get { return _diCH; } set { _diCH = value; OnPropertyChanged(); } }
private int[] _diCH = new int[8];

public int MCU_DO_CH { get { return _mcuDO_CH; } set { _mcuDO_CH = value; OnPropertyChanged(); } }
private int _mcuDO_CH = 1;
public bool MCU_DO_Value { get { return _mcu_DO_Valuer; } set { _mcu_DO_Valuer = value; OnPropertyChanged(); } }
private bool _mcu_DO_Valuer = true;

private void Button_McuPWMOutput()
{
string sChoosePWM = Convert.ToString(MCU_PWM_CH + 1);
new WriteMcu() { TagName = "ServoControl", Address = sChoosePWM, Value = PWMInputNumber }.Publish();
}
private void Button_McuDOutput()
{
string sChooseDO = Convert.ToString(MCU_DO_CH + 1);
new WriteMcu() { TagName = "OutputControl", Address = sChooseDO, Value = MCU_DO_Value }.Publish();
}
#endregion
#region 果汁机
/// <summary>
/// 果汁机的连接状态
/// </summary>
public string JuicerConnected { get { return _JuicerConnected; } set { _JuicerConnected = value; OnPropertyChanged(); } }
private string _JuicerConnected { get; set; }

public string JuiceState_Heating { get { return _juiceState_Heating; } set { _juiceState_Heating = value;OnPropertyChanged(); } }
public string _juiceState_Heating { get; set; }
public string JuiceState_Cooling { get { return _juiceState_Cooling; } set { _juiceState_Cooling = value; OnPropertyChanged(); } }
public string _juiceState_Cooling { get; set; }
public string JuiceState_LackOfWater { get { return _juiceState_LackOfWater; } set { _juiceState_LackOfWater = value; OnPropertyChanged(); } }
public string _juiceState_LackOfWater { get; set; }
public string JuiceState_ChildLocks { get { return _juiceState_ChildLocks; } set { _juiceState_ChildLocks = value; OnPropertyChanged(); } }
public string _juiceState_ChildLocks { get; set; }
public string JuiceState_Using { get { return _juiceState_Using; } set { _juiceState_Using = value; OnPropertyChanged(); } }
public string _juiceState_Using { get; set; }

public string MakeJuice_Index { get { return _makeJuice_Index; } set { _makeJuice_Index = value; OnPropertyChanged(); } }
public string _makeJuice_Index { get; set; }
public RelayCommand Button_MakeJuiceCommand { get; set; }

public void Button_MakeJuice()
{
new WriteJuicer() { Value = MakeJuice_Index }.Publish();
}
#endregion
#region 制冰机
public string IceMakerConnect { get { return _iceMakerConnect; } set { _iceMakerConnect = value;OnPropertyChanged(); } }
private string _iceMakerConnect { get; set; }
public string IceMakerState { get { return _iceMakerState; } set { _iceMakerState = value; OnPropertyChanged(); } }
private string _iceMakerState { get; set; }
public int IceMaker_IceTime { get { return _iceMaker_IceTime; } set { _iceMaker_IceTime = value; OnPropertyChanged(); } }
private int _iceMaker_IceTime = 3;

#region 订单模拟
public RelayCommand SimOrderMakeCoffee { get; set; }
public RelayCommand SimOrderMakeJuice { get; set; }
public RelayCommand SimOrderMakeTea { get; set; }
public RelayCommand SimOrderMakeWater { get; set; }

public int SimOrder_JuiceList { get { return _simOrder_JuiceList; } set { _simOrder_JuiceList = value; OnPropertyChanged(); } }
public int _simOrder_JuiceList { get; set; }
public string SimOrder_JuiceMakeID { get { return _simOrder_JuiceMakeID; } set { _simOrder_JuiceMakeID = value; OnPropertyChanged(); } }
public string _simOrder_JuiceMakeID { get; set; }
#endregion

public RelayCommand IceMaker_BtnPowerOn { get; set; }
public RelayCommand IceMaker_BtnStandby { get; set;}
public RelayCommand IceMaker_BtnPump { get; set;}

public RelayCommand IceMaker_BtnStart { get; set; }
public RelayCommand IceMaker_BtnEnd { get; set; }
public RelayCommand IceMaker_BtnSetIceTime { get; set; }

private void IceMaker_BtnPowerOnCommand()
{
new PowerOnMakeIce().Publish();
}
private void IceMaker_BtnStandbyCommand()
{
new StandbyMakeIce().Publish();
}
private void IceMaker_BtnPumpCommand()
{
new PumpMakeIce().Publish();
}
private void IceMaker_BtnStartCommand()
{
new StartMakeIce().Publish();
}
private void IceMaker_BtnEndCommand()
{
new StopMakeIce().Publish();
}
private void IceMaker_BtnSetIceTimeCommand()
{
new SetIceNumber{ Value= IceMaker_IceTime }.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 { return _selectedCoffee; } set { _selectedCoffee = value; OnPropertyChanged(); } }
public string _selectedCoffee { get; set; }

public List<string> CoffeeCmds { get; set; } = new List<string>();
public string SelectedCoffeeCmd { get; set; }

public string SimOrderCoffeeList { get { return _simOrderCoffeeList; } set { _simOrderCoffeeList = value; OnPropertyChanged(); } }
public string _simOrderCoffeeList { 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
/// <summary>
/// 设备ID
/// </summary>
public int DeviceId { get; set; }
/// <summary>
/// 设备数据
/// </summary>
public ObservableCollection<VariableMonitor> variableMonitors { get; set; }
public DebugViewModel()
{
SimOrderMakeCoffee = new RelayCommand(() =>
{
new MorkTSimOrder() { OrderNum = 1, DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SimOrderCoffeeList) }.Publish();
});
SimOrderMakeJuice = new RelayCommand(() =>
{
new MorkTSimOrder() { OrderNum = 2, JuiceList = SimOrder_JuiceList, JuiceMakeID = SimOrder_JuiceMakeID }.Publish();
});
SimOrderMakeTea = new RelayCommand(() =>
{
new MorkTSimOrder() { OrderNum = 3 }.Publish();
});
SimOrderMakeWater = new RelayCommand(() =>
{
new MorkTSimOrder() { OrderNum = 4 }.Publish();
});
Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl);
Robot_DOutput = new RelayCommand(Button_RobotDoutput);

Button_MakeCoffeeCommand = new RelayCommand(Button_MakeCoffee);
Button_StopMakeCoffeCommand = new RelayCommand(Button_StopMakeCoffe);
Button_CoffeeModeSetCommand = new RelayCommand(Button_CoffeeModeSet);
Button_MCUOuputCommand = new RelayCommand(Button_McuPWMOutput);
Button_MCUDOuputCommand = new RelayCommand(Button_McuDOutput);

Button_MakeJuiceCommand = new RelayCommand(Button_MakeJuice);

IceMaker_BtnPowerOn = new RelayCommand(IceMaker_BtnPowerOnCommand);
IceMaker_BtnStandby = new RelayCommand(IceMaker_BtnStandbyCommand);
IceMaker_BtnPump = new RelayCommand(IceMaker_BtnPumpCommand);
IceMaker_BtnStart = new RelayCommand(IceMaker_BtnStartCommand);
IceMaker_BtnEnd = new RelayCommand(IceMaker_BtnEndCommand);
IceMaker_BtnSetIceTime = new RelayCommand(IceMaker_BtnSetIceTimeCommand);
foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode)))
{
Coffees.Add(code.ToString());
}
SelectedCoffee = Coffees[0];
SimOrderCoffeeList = Coffees[0];
foreach (DrCoffeeCommCmd code in Enum.GetValues(typeof(DrCoffeeCommCmd)))
{
CoffeeCmds.Add(code.ToString());
}
SelectedCoffeeCmd = CoffeeCmds[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)
{
#region 机器人
RobotConnected = variableMonitors.FirstOrDefault(p => p.Notes == "机器人连接状态").CurrentValue == "True" ? "已连接" : "未连接";
RobotMode = variableMonitors.FirstOrDefault(p => p.Notes == "机器人状态").CurrentValue;
Robot_TCPDI0 = variableMonitors.FirstOrDefault(p => p.Notes == "机器人TCP输入状态").CurrentValue;
Robot_DI0 = variableMonitors.FirstOrDefault(p => p.Notes == "机器人输入0状态").CurrentValue;
Robot_DI1 = variableMonitors.FirstOrDefault(p => p.Notes == "机器人输入1状态").CurrentValue;
Robot_DI2 = variableMonitors.FirstOrDefault(p => p.Notes == "机器人输入2状态").CurrentValue;
Robot_DI3 = variableMonitors.FirstOrDefault(p => p.Notes == "机器人输入3状态").CurrentValue;

#endregion

#region 咖啡机
CoffeeConnected = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
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;
#endregion

#region 单片机
MCUConnected = variableMonitors.FirstOrDefault(p => p.Notes == "单片机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
MCUDI0 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入0状态").CurrentValue;
MCUDI1 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入1状态").CurrentValue;
MCUDI2 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入2状态").CurrentValue;
MCUDI3 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入3状态").CurrentValue;
MCUDI4 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入4状态").CurrentValue;
MCUDI5 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入5状态").CurrentValue;
MCUDI6 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入6状态").CurrentValue;
MCUDI7 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入7状态").CurrentValue;
#endregion

#region 制冰机
IceMakerConnect = variableMonitors.FirstOrDefault(p => p.Notes == "制冰机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
IceMakerState = variableMonitors.FirstOrDefault(p => p.Notes == "制冰机设备状态").CurrentValue;
#endregion

#region 果汁机
JuicerConnected = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
JuiceState_Heating = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机制热").CurrentValue;
JuiceState_Cooling = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机制冷").CurrentValue;
JuiceState_LackOfWater = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机缺水").CurrentValue;
JuiceState_ChildLocks = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机童锁").CurrentValue;
JuiceState_Using = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机使用").CurrentValue;

#endregion
}
Thread.Sleep(500);
}), "MorkT-状态刷新");
}
}


+ 94
- 0
BPASmartClient.MorkT_BarCounter/ViewModel/MonitorViewModel.cs Просмотреть файл

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

}

BPASmartClient.MorkT_Show/BPASmartClient.MorkT_Container.csproj → BPASmartClient.MorkT_Container/BPASmartClient.MorkT_Container.csproj Просмотреть файл

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

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
@@ -17,4 +17,11 @@
<ProjectReference Include="..\BPASmartClient.MCU\BPASmartClient.MCU.csproj" />
</ItemGroup>

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

</Project>

BPASmartClient.MorkT_Show/Control_MorkT_Container.cs → BPASmartClient.MorkT_Container/Control_MorkT_Container.cs Просмотреть файл

@@ -18,6 +18,8 @@ using BPASmartClient.Message;
using BPASmartClient.Model.乐白机器人;
using BPASmartClient.Model.单片机;
using BPASmartClient.Model.PLC;
using BPASmartClient.DRCoffee;
using BPASmartClient.LebaiRobot;

namespace BPASmartClient.MorkT_Container
{
@@ -59,7 +61,6 @@ namespace BPASmartClient.MorkT_Container
serverInit();
DataParse();
ActionManage.GetInstance.Register(new Action<object>((o) => { SimOrder(o); }), "SimOrder");//模拟订单委托注册
}

private void serverInit()
@@ -133,6 +134,7 @@ namespace BPASmartClient.MorkT_Container
BatchingId = res.BatchingId,
Loc = ushort.Parse(mainMaterialLoc),
GoodName = order.MorkOrder.GoodsName,
makeID = order.MorkOrder.MakeID,
});
}
break;
@@ -197,6 +199,7 @@ namespace BPASmartClient.MorkT_Container
}
else if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 18 && bFirstTrig_Coffee == true)
{
DeviceProcessLogShow("接咖啡超时,接咖啡结束,等待取咖啡");
bFirstTrig_Coffee = false;
if (morkTLebaiJC.IsHaveCoffeeCup)
morkTLebaiJC.MakeCoffeeEnd = true;
@@ -229,6 +232,7 @@ namespace BPASmartClient.MorkT_Container
}
else if (DateTime.Now.Subtract(delayTimeOut_Juice).TotalSeconds > 3 && bFirstTrig_Juice == true)
{
DeviceProcessLogShow("接果汁超时,接果汁结束,等待取果汁");
bFirstTrig_Juice = false;
morkTLebaiJC.MakeJuiceEnd = true;
}
@@ -243,6 +247,7 @@ namespace BPASmartClient.MorkT_Container
}
else if (DateTime.Now.Subtract(delayTimeOut_Water).TotalSeconds >= 5 && bFirstTrig_TeaWater == true)//接水超过50s后,启动接水完成标志,开启接水程序
{
DeviceProcessLogShow("接茶或水延迟时间结束");
bFirstTrig_TeaWater = false;
morkTLebaiJC.MakeTeaEnd = true;
}
@@ -301,7 +306,6 @@ namespace BPASmartClient.MorkT_Container
{
new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Pin = pin,Value=value }.Publish();
}

private T GetStatus<T>(string key)
{
if (peripheralStatus.ContainsKey(key))
@@ -385,17 +389,17 @@ namespace BPASmartClient.MorkT_Container
{
if (IsMakeJuice())
{
switch (morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).Loc)
switch (morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).makeID)
{
case 1:
case "1":
GuMake = true;
IsAddIce = false;
break;
case 2:
case "2":
GuMake = false;
IsAddIce = false;
break;
case 3:
case "3":
GuMake = false;
IsAddIce = true;
break;
@@ -435,8 +439,8 @@ namespace BPASmartClient.MorkT_Container
try
{
PutWaterCup();
DeviceProcessLogShow("-------------茶 制作完成------------");
OrderChange(morkTLebaiJC.morkOrderPushesTea.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
DeviceProcessLogShow("-------------茶 制作完成------------");
morkTLebaiJC.IsHaveTeaWaterCup = false;
morkTLebaiJC.MakeTeaEnd = false;
morkTLebaiJC.morkOrderPushesTea.TryDequeue(out OrderLocInfo orderLoc);
@@ -460,8 +464,8 @@ namespace BPASmartClient.MorkT_Container
try
{
PutWaterCup();
DeviceProcessLogShow("-------------开水 制作完成------------");
OrderChange(morkTLebaiJC.morkOrderPushesWater.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
DeviceProcessLogShow("-------------开水 制作完成------------");
morkTLebaiJC.IsHaveTeaWaterCup = false;
morkTLebaiJC.MakeTeaEnd = false;
morkTLebaiJC.morkOrderPushesWater.TryDequeue(out OrderLocInfo orderLoc);
@@ -485,7 +489,7 @@ namespace BPASmartClient.MorkT_Container
outCupCheck = false;
OrderChange(morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
if (resultTakeCup == 1 || true)
{
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(GVL_MorkT.机器人安全位);
@@ -498,14 +502,14 @@ namespace BPASmartClient.MorkT_Container
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(GVL_MorkT.接咖啡);
//Wait();
new DRCoffee_MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水
new DRCoffee_MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)(morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).Loc)}.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水
}
else
{
/*DeviceProcessLogShow("取杯失败 回到初始位,请及时处理!!");
DeviceProcessLogShow("取杯失败 回到初始位,请及时处理!!");
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(GVL_MorkT.机器人初始位);
//Wait();*/
//Wait();
}
}
}
@@ -530,7 +534,7 @@ namespace BPASmartClient.MorkT_Container
Sence(GVL_MorkT.放咖啡杯);
//Wait();
OrderChange(morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
DeviceProcessLogShow($"-------------{morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).GoodName}果汁 制作完成------------");
DeviceProcessLogShow($"-------------{morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).GoodName}制作完成------------");
}
#endregion
#region 做开水流程
@@ -544,7 +548,7 @@ namespace BPASmartClient.MorkT_Container
{
OrderChange(morkTLebaiJC.morkOrderPushesWater.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
if (resultTakeCup == 1 || true)
{
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(GVL_MorkT.接开水);
@@ -582,7 +586,7 @@ namespace BPASmartClient.MorkT_Container
{
OrderChange(morkTLebaiJC.morkOrderPushesTea.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
if (resultTakeCup == 1 || true)
{
DeviceProcessLogShow("取茶杯完成");
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
@@ -658,8 +662,10 @@ namespace BPASmartClient.MorkT_Container
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(GVL_MorkT.接冰块);
//Wait();
new StartMakeIce() { }.Publish();

if (Math.Pow(1, GetStatus<byte>("GetMakeIceDeviceStatus")) == 0)//制冰机在待机状态才可以制作冰
{
new StartMakeIce() { }.Publish();
}
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(GVL_MorkT.接冰_机器人安全位);
//Wait();
@@ -680,8 +686,8 @@ namespace BPASmartClient.MorkT_Container
{
OrderChange(morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
JuiceCH = int.Parse(mainMaterialLoc);
if (resultTakeCup == 1)
JuiceCH = morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).Loc;
if (resultTakeCup == 1 ||true )
{
getIce();
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
@@ -846,9 +852,8 @@ namespace BPASmartClient.MorkT_Container
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(GVL_MorkT.取纸杯检测);
//Wait();
}
Thread.Sleep(1000);
Thread.Sleep(100);
}
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(GVL_MorkT.取杯位_机器人安全位);
@@ -914,13 +919,204 @@ namespace BPASmartClient.MorkT_Container

public override void ReadData()
{
GetStatus("", new Action<object>((obj) =>
#region 乐白机器人状态
GetStatus("RobotIsConnected", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.RobotIsConnected = b;
}
}));
GetStatus("RobotMode", new Action<object>((o) =>
{
if (o is ELebaiRModel eLebaiRModel)
{
morkTLebaiJC.RobotMode = eLebaiRModel;
}
}));
GetStatus("LeibaiGetTcpInput", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.RobotGetTcpInput = b;
}
}));
GetStatus("LeibaiGetInput1", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.RobotGetInput0 = b;
}
}));
GetStatus("LeibaiGetInput2", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.RobotGetInput1 = b;
}
}));
GetStatus("LeibaiGetInput3", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.RobotGetInput2 = b;
}
}));
GetStatus("LeibaiGetInput4", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.RobotGetInput3 = b;
}
}));

#endregion
#region 制冰机状态
GetStatus("MakeIceConnected", new Action<object>((o) =>
{
if (o is bool bt)
{
morkTLebaiJC.IceMakerConnect = bt;
}
}));
GetStatus("MakeIceDeviceStatus", new Action<object>((o) =>
{
if (o is byte bt)
{
morkTLebaiJC.IceMakerState = bt;
}
}));
#endregion
#region 咖啡机状态
GetStatus("CoffeeIsConnected", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.CoffeeIsConnected = b;
}
}));

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

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

GetStatus("CoffeeWarning", new Action<object>((o) =>
{
if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 24)
if (o is DrCoffeeWarning coffeeWarning)
{
morkTLebaiJC.CoffeeWarning = coffeeWarning;
}
}));
GetStatus("CoffeeFault", new Action<object>((o) =>
{
if (o is DrCoffeeFault coffeeFault)
{
morkTLebaiJC.CaffeeFault = coffeeFault;
}
}));
#endregion
#region 单片机状态
EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput0" });
EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput1" });
EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput2" });
EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput3" });
EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput4" });
EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput5" });
EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput6" });
EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput7" });
GetStatus("SCChipIsConnect", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.SCChipIsConnect = b;
}
}));
GetStatus("SCChipGetInput0", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.SCChipInput0 = b;
}
}));
GetStatus("SCChipGetInput1", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.SCChipInput1 = b;
}
}));
GetStatus("SCChipGetInput2", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.SCChipInput2 = b;
}
}));
GetStatus("SCChipGetInput3", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.SCChipInput3 = b;
}
}));
GetStatus("SCChipGetInput4", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.SCChipInput4 = b;
}
}));
GetStatus("SCChipGetInput5", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.SCChipInput5 = b;
}
}));
GetStatus("SCChipGetInput6", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.SCChipInput6 = b;
}
}));
GetStatus("SCChipGetInput7", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.SCChipInput7 = b;
}
}));

#endregion
#region 果汁机
GetStatus("GetJuicerConnected", new Action<object>((o) =>
{
if (o is bool b)
{
morkTLebaiJC.JuicerConnected = b;
}
}));
GetStatus("GetJuicerDeviceStatus", new Action<object>((o) =>
{
if (o is int[] b)
{
morkTLebaiJC.JuicerState = b;
}
}));
#endregion
}
#endregion
public override void Stop()
@@ -935,7 +1131,30 @@ namespace BPASmartClient.MorkT_Container

public override void SimOrder()
{

EventBus.EventBus.GetInstance().Subscribe<MorkTSimOrder>(0, delegate (IEvent @event, EventCallBackHandle callBackHandle)
{
string guid = Guid.NewGuid().ToString();
if (@event != null && @event is MorkTSimOrder msm)
{
DeviceProcessLogShow("----开始模拟订单----");
if (msm.OrderNum == 1)
{
morkTLebaiJC.morkOrderPushesCoffee.Enqueue(new OrderLocInfo() { Loc =(ushort)msm.DrinkCode, SuborderId = guid, GoodName="模拟咖啡订单" });
}
else if (msm.OrderNum == 2)
{
morkTLebaiJC.morkOrderPushesJuicer.Enqueue(new OrderLocInfo() { Loc = (ushort) (msm.JuiceList + 51), makeID = msm.JuiceMakeID, SuborderId = guid, GoodName = "模拟果汁订单" });
}
else if (msm.OrderNum == 3)
{
morkTLebaiJC.morkOrderPushesTea.Enqueue(new OrderLocInfo() { SuborderId = guid, GoodName = "模拟茶水订单" });
}
else if (msm.OrderNum == 4)
{
morkTLebaiJC.morkOrderPushesWater.Enqueue(new OrderLocInfo() { SuborderId = guid, GoodName = "模拟开水订单" });
}
}
});
}
}
}

BPASmartClient.MorkT_Show/GVL_MorkT.cs → BPASmartClient.MorkT_Container/GVL_MorkT.cs Просмотреть файл

@@ -5,6 +5,9 @@ using System.Text;
using System.Threading.Tasks;
using BPASmartClient.Device;
using System.Collections.Concurrent;
using BPASmartClient.LebaiRobot;
using BPASmartClient.DRCoffee;
using BPASmartClient.IceMaker;

namespace BPASmartClient.MorkT_Container
{
@@ -131,7 +134,78 @@ namespace BPASmartClient.MorkT_Container
public string SuborderId = null;



#region

[VariableMonitor("机器人连接状态")]
public bool RobotIsConnected { get; set; }
[VariableMonitor("机器人状态")]
public ELebaiRModel RobotMode { get; set; }
[VariableMonitor("机器人TCP输入状态")]
public bool RobotGetTcpInput { get; set; }
[VariableMonitor("机器人输入0状态")]
public bool RobotGetInput0{ get; set; }
[VariableMonitor("机器人输入1状态")]
public bool RobotGetInput1 { get; set; }
[VariableMonitor("机器人输入2状态")]
public bool RobotGetInput2 { get; set; }
[VariableMonitor("机器人输入3状态")]
public bool RobotGetInput3 { 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; }
[VariableMonitor("单片机输入0状态")]
public bool SCChipInput0 { get; set; }
[VariableMonitor("单片机输入1状态")]
public bool SCChipInput1 { get; set; }
[VariableMonitor("单片机输入2状态")]
public bool SCChipInput2 { get; set; }
[VariableMonitor("单片机输入3状态")]
public bool SCChipInput3 { get; set; }
[VariableMonitor("单片机输入4状态")]
public bool SCChipInput4 { get; set; }
[VariableMonitor("单片机输入5状态")]
public bool SCChipInput5 { get; set; }
[VariableMonitor("单片机输入6状态")]
public bool SCChipInput6 { get; set; }
[VariableMonitor("单片机输入7状态")]
public bool SCChipInput7 { get; set; }



[VariableMonitor("制冰机连接状态")]
public bool IceMakerConnect { get; set; }
[VariableMonitor("制冰机设备状态")]
public byte IceMakerState { get; set; }


[VariableMonitor("果汁机连接状态")]
public bool JuicerConnected { get; set; }

public int[] JuicerState{ get; set; }

[VariableMonitor("果汁机制热")]
public bool JuiceState_Heating { get; set; }
[VariableMonitor("果汁机制冷")]
public bool JuiceState_Cooling { get; set; }
[VariableMonitor("果汁机缺水")]
public bool JuiceState_LackOfWater { get; set; }
[VariableMonitor("果汁机童锁")]
public bool JuiceState_ChildLocks { get; set; }
[VariableMonitor("果汁机使用")]
public bool JuiceState_Using { get; set; }
#endregion
}
}

BPASmartClient.MorkT_Show/OrderLocInfo.cs → BPASmartClient.MorkT_Container/OrderLocInfo.cs Просмотреть файл

@@ -13,5 +13,6 @@ namespace BPASmartClient.MorkT_Container
public ushort RecipeNumber { get; set; }
public int BatchingId { get; set; }
public string GoodName { get; set; }
public string makeID { get; set; }
}
}

BPASmartClient.MorkT_Show/PolymerBatching.cs → BPASmartClient.MorkT_Container/PolymerBatching.cs Просмотреть файл


+ 443
- 0
BPASmartClient.MorkT_Container/View/DebugView.xaml Просмотреть файл

@@ -0,0 +1,443 @@
<UserControl x:Class="BPASmartClient.MorkT_Container.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_Container.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.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="15*"/>
</Grid.RowDefinitions>
<Border BorderThickness="0,0,1,1" BorderBrush="DodgerBlue" Grid.Row="0" Grid.Column="0"></Border>
<Border BorderThickness="0,0,1,1" BorderBrush="DodgerBlue" Grid.Row="1" Grid.Column="0"></Border>
<Border BorderThickness="0,0,1,0" BorderBrush="DodgerBlue" Grid.Row="2" Grid.Column="0"></Border>
<Border BorderThickness="0,0,0,1" BorderBrush="DodgerBlue" Grid.Row="0" Grid.Column="1"></Border>
<Border BorderThickness="0,0,0,1" BorderBrush="DodgerBlue" Grid.Row="1" Grid.Column="1"></Border>
<Border BorderThickness="0,0,0,0" BorderBrush="DodgerBlue" Grid.Row="2" Grid.Column="1"></Border>
<GroupBox Grid.Row="0" Grid.Column="0"
FontFamily="楷体"
FontSize="20"
Header=" 乐白机器人 ">

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="连接状态:" />
<TextBlock Text="{Binding RobotConnected}"
Margin="40,0"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<StackPanel Orientation="Horizontal">
<TextBlock Text="当前模式:" Margin="0,1"/>
<TextBlock Text="{Binding RobotMode}"
Margin="40,0"/>
</StackPanel>
</Grid>
<Grid Grid.Row="2">
<DockPanel>
<Button Content="启动" Width="50" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人启动">
</Button>
<Button Content="暂停" Width="50" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="暂停"/>
<Button Content="恢复" Width="50" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="恢复"/>
<Button Content="急停" Width="50" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人急停"/>
</DockPanel>
</Grid>
<Grid Grid.Row="0" Grid.Column="1" >
<StackPanel Orientation="Horizontal" >
<TextBlock>TCP DI:</TextBlock>
<CheckBox IsEnabled="false" IsChecked="{Binding Robot_TCPDI0}" FontSize="14">DI0</CheckBox>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.Column="1" >
<StackPanel Orientation="Horizontal" >
<TextBlock>DI:</TextBlock>
<CheckBox IsEnabled="false" Name="Robot_DI0" FontSize="14" IsChecked="{Binding Robot_DI0}">DI0</CheckBox>
<CheckBox IsEnabled="false" Name="Robot_DI1" FontSize="14" IsChecked="{Binding Robot_DI1}">DI1</CheckBox>
<CheckBox IsEnabled="false" Name="Robot_DI2" FontSize="14" IsChecked="{Binding Robot_DI2}">DI2</CheckBox>
<CheckBox IsEnabled="false" Name="Robot_DI3" FontSize="14" IsChecked="{Binding Robot_DI3}">DI3</CheckBox>
</StackPanel>
</Grid>
<Grid Grid.Row="2" Grid.Column="1">
<StackPanel Orientation="Horizontal" >
<TextBlock>DO:</TextBlock>
<ComboBox SelectedIndex="{Binding Robot_DOutput_Pin}">
<ComboBoxItem IsSelected="true">DO0</ComboBoxItem>
<ComboBoxItem>DO1</ComboBoxItem>
<ComboBoxItem>DO2</ComboBoxItem>
<ComboBoxItem>DO3</ComboBoxItem>
</ComboBox>
<ComboBox SelectedIndex="{Binding Robot_DOutput_Value}">
<ComboBoxItem IsSelected="true">true</ComboBoxItem>
<ComboBoxItem>false</ComboBoxItem>
</ComboBox>
<Button Content="输出" Command="{Binding Robot_DOutput}"/>
</StackPanel>

</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="1" Grid.Column="0"
Header="单片机控制"
FontSize="18"
FontFamily="楷体">
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0">
<StackPanel Orientation="Horizontal">
<TextBlock >连接状态:</TextBlock>
<TextBlock Text="{Binding MCUConnected}" />
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="12">DI:</TextBlock>
<CheckBox FontSize="12" IsEnabled="false" IsChecked="{Binding CH0}">DI0</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH1">DI1</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH2">DI2</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH3">DI3</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH4">DI4</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH5">DI5</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH6">DI6</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" Name="CH7">DI7</CheckBox>
</StackPanel>
</Grid>
<Grid Grid.Row="2" Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="12" HorizontalAlignment="Center">DO输出</TextBlock>
<ComboBox Width="50" FontSize="12" HorizontalAlignment="Center" SelectedIndex="{Binding MCU_DO_CH}">
<ComboBoxItem IsSelected="true">DO0</ComboBoxItem>
<ComboBoxItem>DO1</ComboBoxItem>
<ComboBoxItem>DO2</ComboBoxItem>
<ComboBoxItem>DO3</ComboBoxItem>
<ComboBoxItem>DO4</ComboBoxItem>
<ComboBoxItem>DO5</ComboBoxItem>
<ComboBoxItem>DO6</ComboBoxItem>
<ComboBoxItem>DO7</ComboBoxItem>
</ComboBox>
<ComboBox FontSize="12" HorizontalAlignment="Center" SelectedIndex="{Binding MCU_DO_CH}">
<ComboBoxItem IsSelected="true">True</ComboBoxItem>
<ComboBoxItem>False</ComboBoxItem>
</ComboBox>
<Button Width="50" Command="{Binding Button_MCUDOuputCommand}">输出</Button>
</StackPanel>
</Grid>
<Grid Grid.Column="1">
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="12" HorizontalAlignment="Center">舵机控制</TextBlock>
<ComboBox Margin="0,0,0,0" FontSize="12" Width="60" SelectedIndex="{Binding MCU_PWM_CH}">
<ComboBoxItem IsSelected="true">舵机1</ComboBoxItem>
<ComboBoxItem>舵机2</ComboBoxItem>
<ComboBoxItem>舵机3</ComboBoxItem>
<ComboBoxItem>舵机4</ComboBoxItem>
</ComboBox>
<TextBox Width="50" Text="{Binding PWMInputNumber}"></TextBox>
<Button FontSize="15" HorizontalAlignment="Center" Command="{Binding Button_MCUOuputCommand}">输出</Button>
</StackPanel>
</Grid>
</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2" Grid.Column="0"
FontFamily="楷体"
FontSize="20"
Header=" 果汁机 ">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<Grid>
<TextBlock Text="连接状态:" />
</Grid>
<Grid Grid.Column="1">
<TextBlock Text="{Binding JuicerConnected}"
Margin="120,0,0,0"/>
</Grid>
<Grid Grid.Row="1">
<TextBlock Text="设备状态:" />
</Grid>
<Grid Grid.Column="1" Grid.Row="1">
<StackPanel Orientation="Horizontal" >
<Button IsEnabled="False" Visibility="{Binding JuiceState_Heating}" >制热</Button>
<Button IsEnabled="False" Visibility="{Binding JuiceState_Cooling}" >制冷</Button>
<Button IsEnabled="False" Visibility="{Binding JuiceState_LackOfWater}" >缺水</Button>
<Button IsEnabled="False" Visibility="{Binding JuiceState_ChildLocks}" >童锁</Button>
<Button IsEnabled="False" Visibility="{Binding JuiceState_Using}" >使用</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="2">
<TextBlock>果汁:</TextBlock>
</Grid>
<Grid Grid.Column="1" Grid.Row="2">
<StackPanel Orientation="Horizontal">
<ComboBox SelectedItem="{Binding MakeJuice_Index}">
<ComboBoxItem IsSelected="true">0</ComboBoxItem>
<ComboBoxItem>1</ComboBoxItem>
<ComboBoxItem>2</ComboBoxItem>
<ComboBoxItem>3</ComboBoxItem>
<ComboBoxItem>4</ComboBoxItem>
<ComboBoxItem>5</ComboBoxItem>
<ComboBoxItem>6</ComboBoxItem>
<ComboBoxItem>7</ComboBoxItem>
</ComboBox>
<Button Command="{Binding Button_MakeJuiceCommand}" Content="制作" />
</StackPanel>
</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="0" Grid.Column="1"
Header="订单模拟"
FontSize="18"
FontFamily="楷体">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.Column="0">
<StackPanel Orientation="Horizontal">
<TextBlock>咖啡:</TextBlock>
<ComboBox Margin="10,0"
Width="100"
ItemsSource="{Binding Coffees}"
SelectedItem="{Binding SimOrderCoffeeList}" />
<Button Command="{Binding SimOrderMakeCoffee}">制作</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.Column="0">
<StackPanel Orientation="Horizontal">
<TextBlock>果汁:</TextBlock>
<ComboBox SelectedIndex="{Binding SimOrder_JuiceList}">
<ComboBoxItem IsSelected="true" >饮品1</ComboBoxItem>
<ComboBoxItem>饮品2</ComboBoxItem>
<ComboBoxItem>饮品3</ComboBoxItem>
<ComboBoxItem>饮品4</ComboBoxItem>
</ComboBox>
<ComboBox SelectedItem="{Binding SimOrder_JuiceMakeID}">
<ComboBoxItem IsSelected="true">热饮</ComboBoxItem>
<ComboBoxItem>常温</ComboBoxItem>
<ComboBoxItem>冷饮</ComboBoxItem>
</ComboBox>
<Button Command="{Binding SimOrderMakeJuice}">制作</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<StackPanel Orientation="Horizontal">
<TextBlock>开水:</TextBlock>
<Button Command="{Binding SimOrderMakeWater}">制作</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.Column="1">
<StackPanel Orientation="Horizontal">
<TextBlock>茶水:</TextBlock>
<Button Command="{Binding SimOrderMakeTea}">制作</Button>
</StackPanel>
</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="1" Grid.Column="1"
Header="制冰机控制"
FontSize="18"
FontFamily="楷体">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<StackPanel Orientation="Horizontal" >
<TextBlock>连接状态:</TextBlock>
<TextBlock Text="{Binding IceMakerConnect}" />
</StackPanel>
</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<StackPanel Orientation="Horizontal">
<Button Command="{Binding IceMaker_BtnPowerOn}">开机</Button>
<Button Command="{Binding IceMaker_BtnStandby}">待机</Button>
<Button Command="{Binding IceMaker_BtnPump}" >抽水</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="22*"/>
<ColumnDefinition Width="39*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.ColumnSpan="2" >
<TextBlock>设备状态:</TextBlock>
<Button IsEnabled="False" Command="{Binding IceMaker_State}" >开机状态</Button>
<Button IsEnabled="False" Command="{Binding IceMaker_State}">待机状态</Button>
<Button IsEnabled="False" Command="{Binding IceMaker_State}" >电机故障</Button>
<Button IsEnabled="False" Command="{Binding IceMaker_State}">冰满</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="2" Grid.Column="0">
<StackPanel Orientation="Horizontal">
<TextBlock>控制:</TextBlock>
<Button Command="{Binding IceMaker_BtnStart}">开始出冰</Button>
<Button Command="{Binding IceMaker_BtnEnd}">结束出冰</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="2" Grid.Column="01">
<StackPanel Orientation="Horizontal" >
<TextBlock>出冰时间:</TextBlock>
<TextBox Width="50" Text="{Binding IceMaker_IceTime}"></TextBox>
<TextBlock>s</TextBlock>
<Button Command="{Binding IceMaker_BtnSetIceTime}">设置</Button>
</StackPanel>
</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2" Grid.Column="1"
FontFamily="楷体"
FontSize="20"
Header=" 咖啡机">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0">
<TextBlock Text="连接状态" />
</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<TextBlock Text="{Binding CoffeeConnected}"
Margin="120,0,0,0"/>
</Grid>
<Grid Grid.Row="1" Grid.RowSpan="2" Grid.ColumnSpan="2">
<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>
<Grid Grid.Row="3" Grid.ColumnSpan="2">
<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="{Binding Button_MakeCoffeeCommand }"
Content="制作"/>
<Button Margin="10,0"
Command="{Binding Button_StopMakeCoffeCommand}"
Content="停止制作"/>
</StackPanel>
</Grid>
<Grid Grid.Row="4" Grid.ColumnSpan="2">
<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="{Binding Button_CoffeeModeSetCommand}"
Content="设置" Cursor="Hand"/>
</StackPanel>
</Grid>
</Grid>
</GroupBox>
</Grid>
</UserControl>

+ 37
- 0
BPASmartClient.MorkT_Container/View/DebugView.xaml.cs Просмотреть файл

@@ -0,0 +1,37 @@
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_Container.View
{
/// <summary>
/// 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-传感器监视");*/

}
}

}

+ 393
- 0
BPASmartClient.MorkT_Container/ViewModel/DebugViewModel.cs Просмотреть файл

@@ -0,0 +1,393 @@
using BPASmartClient.Business;
using BPASmartClient.Device;
using BPASmartClient.DRCoffee;
using BPASmartClient.EventBus;
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_Container.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; }
public RelayCommand<object> IceMaker_State { get; set; }
public RelayCommand Robot_DOutput { get; set; }
/// <summary>
/// 机器人控制
/// </summary>
/// <param name="o"></param>
private void Button_RobotControl(object o)
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiControlEvent { DeviceId = DeviceId, LebaiControl = o.ToString() });
}
private void IceMaker_StateCommand(object o)
{
if (IceMakerState != null)
{
}
}

private void Button_RobotDoutput()
{
bool DO_Value =int.Parse(Robot_DOutput_Value) == 0;
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetOutPutEvent { Pin = int.Parse(Robot_DOutput_Pin), Value = DO_Value });
}
public bool Robot_TCPDI0 { get { return _robot_TCPDI0; } set { _robot_TCPDI0 = value;OnPropertyChanged(); } }
private bool _robot_TCPDI0;

public bool Robot_DI0 { get { return _robot_DI0; } set { _robot_DI0 = value; OnPropertyChanged(); } }
private bool _robot_DI0;
public bool Robot_DI1 { get { return _robot_DI1; } set { _robot_DI1 = value; OnPropertyChanged(); } }
private bool _robot_DI1;
public bool Robot_DI2 { get { return _robot_DI2; } set { _robot_DI2 = value; OnPropertyChanged(); } }
private bool _robot_DI2;
public bool Robot_DI3 { get { return _robot_DI3; } set { _robot_DI3 = value; OnPropertyChanged(); } }
private bool _robot_DI3;

public string Robot_DOutput_Pin { get { return _robot_DOutput_Pin; } set { _robot_DOutput_Pin = value; OnPropertyChanged(); } }
private string _robot_DOutput_Pin { get; set; }
public string Robot_DOutput_Value { get { return _robot_DOutput_Valuet; } set { _robot_DOutput_Valuet = value; OnPropertyChanged(); } }
private string _robot_DOutput_Valuet { get; set; }
#endregion
#region 单片机
public string MCUConnected { get { return _mcuConnected; } set { _mcuConnected = value; OnPropertyChanged(); } }
private string _mcuConnected { get; set; }

public bool MCUDI0 { get { return _mCUDI0; } set { _mCUDI0 = value; OnPropertyChanged(); } }
private bool _mCUDI0 { get; set; }
public bool MCUDI1 { get { return _mCUDI1; } set { _mCUDI1 = value; OnPropertyChanged(); } }
private bool _mCUDI1 { get; set; }
public bool MCUDI2 { get { return _mCUDI2; } set { _mCUDI2 = value; OnPropertyChanged(); } }
private bool _mCUDI2 { get; set; }
public bool MCUDI3 { get { return _mCUDI3; } set { _mCUDI3 = value; OnPropertyChanged(); } }
private bool _mCUDI3 { get; set; }
public bool MCUDI4 { get { return _mCUDI4; } set { _mCUDI4 = value; OnPropertyChanged(); } }
private bool _mCUDI4 { get; set; }
public bool MCUDI5 { get { return _mCUDI5; } set { _mCUDI5 = value; OnPropertyChanged(); } }
private bool _mCUDI5 { get; set; }
public bool MCUDI6 { get { return _mCUDI6; } set { _mCUDI6 = value; OnPropertyChanged(); } }
private bool _mCUDI6 { get; set; }
public bool MCUDI7 { get { return _mCUDI7; } set { _mCUDI7 = value; OnPropertyChanged(); } }
private bool _mCUDI7 { get; set; }

public RelayCommand Button_MCUOuputCommand { get; set; }
public RelayCommand Button_MCUDOuputCommand { get; set; }

public int MCU_PWM_CH { get { return _choosePWM; } set { _choosePWM = value; OnPropertyChanged(); } }
private int _choosePWM = 1;
public int PWMInputNumber { get { return _pwmInputNumber; } set { _pwmInputNumber = value; OnPropertyChanged(); } }
private int _pwmInputNumber = 1;

private int[] DICH { get { return _diCH; } set { _diCH = value; OnPropertyChanged(); } }
private int[] _diCH = new int[8];

public int MCU_DO_CH { get { return _mcuDO_CH; } set { _mcuDO_CH = value; OnPropertyChanged(); } }
private int _mcuDO_CH = 1;
public bool MCU_DO_Value { get { return _mcu_DO_Valuer; } set { _mcu_DO_Valuer = value; OnPropertyChanged(); } }
private bool _mcu_DO_Valuer = true;

private void Button_McuPWMOutput()
{
string sChoosePWM = Convert.ToString(MCU_PWM_CH + 1);
new WriteMcu() { TagName = "ServoControl", Address = sChoosePWM, Value = PWMInputNumber }.Publish();
}
private void Button_McuDOutput()
{
string sChooseDO = Convert.ToString(MCU_DO_CH + 1);
new WriteMcu() { TagName = "OutputControl", Address = sChooseDO, Value = MCU_DO_Value }.Publish();
}
#endregion
#region 果汁机
/// <summary>
/// 果汁机的连接状态
/// </summary>
public string JuicerConnected { get { return _JuicerConnected; } set { _JuicerConnected = value; OnPropertyChanged(); } }
private string _JuicerConnected { get; set; }

public System.Windows.Visibility JuiceState_Heating { get { return _juiceState_Heating; } set { _juiceState_Heating = value;OnPropertyChanged(); } }
public System.Windows.Visibility _juiceState_Heating { get; set; }
public System.Windows.Visibility JuiceState_Cooling { get { return _juiceState_Cooling; } set { _juiceState_Cooling = value; OnPropertyChanged(); } }
public System.Windows.Visibility _juiceState_Cooling { get; set; }
public System.Windows.Visibility JuiceState_LackOfWater { get { return _juiceState_LackOfWater; } set { _juiceState_LackOfWater = value; OnPropertyChanged(); } }
public System.Windows.Visibility _juiceState_LackOfWater { get; set; }
public System.Windows.Visibility JuiceState_ChildLocks { get { return _juiceState_ChildLocks; } set { _juiceState_ChildLocks = value; OnPropertyChanged(); } }
public System.Windows.Visibility _juiceState_ChildLocks { get; set; }
public System.Windows.Visibility JuiceState_Using { get { return _juiceState_Using; } set { _juiceState_Using = value; OnPropertyChanged(); } }
public System.Windows.Visibility _juiceState_Using { get; set; }

public string MakeJuice_Index { get { return _makeJuice_Index; } set { _makeJuice_Index = value; OnPropertyChanged(); } }
public string _makeJuice_Index { get; set; }
public RelayCommand Button_MakeJuiceCommand { get; set; }

public void Button_MakeJuice()
{
new WriteJuicer() { Value = MakeJuice_Index }.Publish();
}
#endregion
#region 制冰机
public string IceMakerConnect { get { return _iceMakerConnect; } set { _iceMakerConnect = value;OnPropertyChanged(); } }
private string _iceMakerConnect { get; set; }
public string IceMakerState { get { return _iceMakerState; } set { _iceMakerState = value; OnPropertyChanged(); } }
private string _iceMakerState { get; set; }
public int IceMaker_IceTime { get { return _iceMaker_IceTime; } set { _iceMaker_IceTime = value; OnPropertyChanged(); } }
private int _iceMaker_IceTime = 3;

#region 订单模拟
public RelayCommand SimOrderMakeCoffee { get; set; }
public RelayCommand SimOrderMakeJuice { get; set; }
public RelayCommand SimOrderMakeTea { get; set; }
public RelayCommand SimOrderMakeWater { get; set; }

public int SimOrder_JuiceList { get { return _simOrder_JuiceList; } set { _simOrder_JuiceList = value; OnPropertyChanged(); } }
public int _simOrder_JuiceList { get; set; }
public string SimOrder_JuiceMakeID { get { return _simOrder_JuiceMakeID; } set { _simOrder_JuiceMakeID = value; OnPropertyChanged(); } }
public string _simOrder_JuiceMakeID { get; set; }
#endregion

public RelayCommand IceMaker_BtnPowerOn { get; set; }
public RelayCommand IceMaker_BtnStandby { get; set;}
public RelayCommand IceMaker_BtnPump { get; set;}

public RelayCommand IceMaker_BtnStart { get; set; }
public RelayCommand IceMaker_BtnEnd { get; set; }
public RelayCommand IceMaker_BtnSetIceTime { get; set; }

private void IceMaker_BtnPowerOnCommand()
{
new PowerOnMakeIce().Publish();
}
private void IceMaker_BtnStandbyCommand()
{
new StandbyMakeIce().Publish();
}
private void IceMaker_BtnPumpCommand()
{
new PumpMakeIce().Publish();
}
private void IceMaker_BtnStartCommand()
{
new StartMakeIce().Publish();
}
private void IceMaker_BtnEndCommand()
{
new StopMakeIce().Publish();
}
private void IceMaker_BtnSetIceTimeCommand()
{
new SetIceNumber{ Value= IceMaker_IceTime }.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 { return _selectedCoffee; } set { _selectedCoffee = value; OnPropertyChanged(); } }
public string _selectedCoffee { get; set; }

public List<string> CoffeeCmds { get; set; } = new List<string>();
public string SelectedCoffeeCmd { get; set; }

public string SimOrderCoffeeList { get { return _simOrderCoffeeList; } set { _simOrderCoffeeList = value; OnPropertyChanged(); } }
public string _simOrderCoffeeList { 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
/// <summary>
/// 设备ID
/// </summary>
public int DeviceId { get; set; }
/// <summary>
/// 设备数据
/// </summary>
public ObservableCollection<VariableMonitor> variableMonitors { get; set; }
public DebugViewModel()
{
SimOrderMakeCoffee = new RelayCommand(() =>
{
new MorkTSimOrder() { OrderNum = 1, DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SimOrderCoffeeList) }.Publish();
});
SimOrderMakeJuice = new RelayCommand(() =>
{
new MorkTSimOrder() { OrderNum = 2, JuiceList = SimOrder_JuiceList, JuiceMakeID = SimOrder_JuiceMakeID }.Publish();
});
SimOrderMakeTea = new RelayCommand(() =>
{
new MorkTSimOrder() { OrderNum = 3 }.Publish();
});
SimOrderMakeWater = new RelayCommand(() =>
{
new MorkTSimOrder() { OrderNum = 4 }.Publish();
});
Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl);
Robot_DOutput = new RelayCommand(Button_RobotDoutput);

Button_MakeCoffeeCommand = new RelayCommand(Button_MakeCoffee);
Button_StopMakeCoffeCommand = new RelayCommand(Button_StopMakeCoffe);
Button_CoffeeModeSetCommand = new RelayCommand(Button_CoffeeModeSet);
Button_MCUOuputCommand = new RelayCommand(Button_McuPWMOutput);
Button_MCUDOuputCommand = new RelayCommand(Button_McuDOutput);

Button_MakeJuiceCommand = new RelayCommand(Button_MakeJuice);

IceMaker_BtnPowerOn = new RelayCommand(IceMaker_BtnPowerOnCommand);
IceMaker_BtnStandby = new RelayCommand(IceMaker_BtnStandbyCommand);
IceMaker_BtnPump = new RelayCommand(IceMaker_BtnPumpCommand);
IceMaker_BtnStart = new RelayCommand(IceMaker_BtnStartCommand);
IceMaker_BtnEnd = new RelayCommand(IceMaker_BtnEndCommand);
IceMaker_BtnSetIceTime = new RelayCommand(IceMaker_BtnSetIceTimeCommand);
IceMaker_State = new RelayCommand<object>(IceMaker_StateCommand);

foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode)))
{
Coffees.Add(code.ToString());
}
SelectedCoffee = Coffees[0];
SimOrderCoffeeList = Coffees[0];
foreach (DrCoffeeCommCmd code in Enum.GetValues(typeof(DrCoffeeCommCmd)))
{
CoffeeCmds.Add(code.ToString());
}
SelectedCoffeeCmd = CoffeeCmds[0];

Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device =>
{
if (device.Name == "Container") 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)
{
#region 机器人
RobotConnected = variableMonitors.FirstOrDefault(p => p.Notes == "机器人连接状态").CurrentValue == "True" ? "已连接" : "未连接";
RobotMode = variableMonitors.FirstOrDefault(p => p.Notes == "机器人状态").CurrentValue;
Robot_TCPDI0 = variableMonitors.FirstOrDefault(p => p.Notes == "机器人TCP输入状态").SwitchValue;
Robot_DI0 = variableMonitors.FirstOrDefault(p => p.Notes == "机器人输入0状态").SwitchValue;
Robot_DI1 = variableMonitors.FirstOrDefault(p => p.Notes == "机器人输入1状态").SwitchValue;
Robot_DI2 = variableMonitors.FirstOrDefault(p => p.Notes == "机器人输入2状态").SwitchValue;
Robot_DI3 = variableMonitors.FirstOrDefault(p => p.Notes == "机器人输入3状态").SwitchValue;

#endregion

#region 咖啡机
CoffeeConnected = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
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;
#endregion

#region 单片机
MCUConnected = variableMonitors.FirstOrDefault(p => p.Notes == "单片机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
MCUDI0 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入0状态").SwitchValue;
MCUDI1 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入1状态").SwitchValue;
MCUDI2 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入2状态").SwitchValue;
MCUDI3 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入3状态").SwitchValue;
MCUDI4 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入4状态").SwitchValue;
MCUDI5 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入5状态").SwitchValue;
MCUDI6 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入6状态").SwitchValue;
MCUDI7 = variableMonitors.FirstOrDefault(p => p.Notes == "单片机输入7状态").SwitchValue;
#endregion

#region 制冰机
IceMakerConnect = variableMonitors.FirstOrDefault(p => p.Notes == "制冰机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
IceMakerState = variableMonitors.FirstOrDefault(p => p.Notes == "制冰机设备状态").CurrentValue;
#endregion

#region 果汁机
JuicerConnected = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
JuiceState_Heating = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机制热").CurrentValue== "True"? System.Windows.Visibility.Visible: System.Windows.Visibility.Hidden;
JuiceState_Cooling = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机制冷").CurrentValue == "True" ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;
JuiceState_LackOfWater = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机缺水").CurrentValue == "True" ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;
JuiceState_ChildLocks = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机童锁").CurrentValue == "True" ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;
JuiceState_Using = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机使用").CurrentValue == "True" ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;
#endregion
}
Thread.Sleep(500);
}), "MorkT-状态刷新");
}
}


+ 92
- 0
BPASmartClient.MorkT_Container/ViewModel/MonitorViewModel.cs Просмотреть файл

@@ -0,0 +1,92 @@
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_Container.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();
}
}

}

+ 7
- 2
BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml Просмотреть файл

@@ -165,13 +165,18 @@
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>果汁</TextBlock>
<ComboBox Margin="100,0,0,0"
Width="100" >
Width="80" >
<ComboBoxItem IsSelected="true">饮品1</ComboBoxItem>
<ComboBoxItem>饮品2</ComboBoxItem>
<ComboBoxItem>饮品3</ComboBoxItem>
<ComboBoxItem>饮品4</ComboBoxItem>
</ComboBox>
<ComboBox Margin="20,0,0,0" Width="100">
<ComboBox Margin="20,0,0,0"
Width="80" >
<ComboBoxItem IsSelected="true">加冰</ComboBoxItem>
<ComboBoxItem>不加冰</ComboBoxItem>
</ComboBox>
<ComboBox Margin="20,0,0,0" Width="80">
<ComboBoxItem IsSelected="true">冷饮</ComboBoxItem>
<ComboBoxItem>热饮</ComboBoxItem>
</ComboBox>


+ 4
- 0
BPASmartClient.Socket/BPASmartClient.Socket.csproj Просмотреть файл

@@ -4,4 +4,8 @@
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.SerialPort\BPASmartClient.SerialPort.csproj" />
</ItemGroup>

</Project>

+ 24
- 24
SmartClient.sln Просмотреть файл

@@ -100,11 +100,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTJuicer"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.AGV", "BPASmartClient.AGV\BPASmartClient.AGV.csproj", "{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_Container", "BPASmartClient.MorkT_Show\BPASmartClient.MorkT_Container.csproj", "{3653724D-3683-4722-B978-EB88DD4AE5DB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.IceMaker", "BPASmartClient.IceMaker\BPASmartClient.IceMaker.csproj", "{F61AC179-156D-4075-BFEB-355862231F48}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkT_BarCounter", "BPASmartClient.MorkT_BarCounter\BPASmartClient.MorkT_BarCounter.csproj", "{048FED78-4BFA-4FCD-8FF2-905E9CA4D7DD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_BarCounter", "BPASmartClient.MorkT_BarCounter\BPASmartClient.MorkT_BarCounter.csproj", "{048FED78-4BFA-4FCD-8FF2-905E9CA4D7DD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_Container", "BPASmartClient.MorkT_Container\BPASmartClient.MorkT_Container.csproj", "{EFE6E0AB-5218-436A-B1F3-8861AF28F785}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -920,26 +920,6 @@ Global
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}.Release|x64.Build.0 = Release|Any CPU
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}.Release|x86.ActiveCfg = Release|Any CPU
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}.Release|x86.Build.0 = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|ARM.ActiveCfg = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|ARM.Build.0 = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|ARM64.Build.0 = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|x64.ActiveCfg = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|x64.Build.0 = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|x86.ActiveCfg = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|x86.Build.0 = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|Any CPU.Build.0 = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|ARM.ActiveCfg = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|ARM.Build.0 = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|ARM64.ActiveCfg = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|ARM64.Build.0 = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x64.ActiveCfg = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x64.Build.0 = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x86.ActiveCfg = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x86.Build.0 = Release|Any CPU
{F61AC179-156D-4075-BFEB-355862231F48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F61AC179-156D-4075-BFEB-355862231F48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F61AC179-156D-4075-BFEB-355862231F48}.Debug|ARM.ActiveCfg = Debug|Any CPU
@@ -980,6 +960,26 @@ Global
{048FED78-4BFA-4FCD-8FF2-905E9CA4D7DD}.Release|x64.Build.0 = Release|Any CPU
{048FED78-4BFA-4FCD-8FF2-905E9CA4D7DD}.Release|x86.ActiveCfg = Release|Any CPU
{048FED78-4BFA-4FCD-8FF2-905E9CA4D7DD}.Release|x86.Build.0 = Release|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|ARM.ActiveCfg = Debug|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|ARM.Build.0 = Debug|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|ARM64.Build.0 = Debug|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|x64.ActiveCfg = Debug|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|x64.Build.0 = Debug|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|x86.ActiveCfg = Debug|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Debug|x86.Build.0 = Debug|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|Any CPU.Build.0 = Release|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|ARM.ActiveCfg = Release|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|ARM.Build.0 = Release|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|ARM64.ActiveCfg = Release|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|ARM64.Build.0 = Release|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|x64.ActiveCfg = Release|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|x64.Build.0 = Release|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|x86.ActiveCfg = Release|Any CPU
{EFE6E0AB-5218-436A-B1F3-8861AF28F785}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1025,9 +1025,9 @@ Global
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
{724087A3-E7E7-4494-B844-414FF5CD1D40} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625}
{3653724D-3683-4722-B978-EB88DD4AE5DB} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{F61AC179-156D-4075-BFEB-355862231F48} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD}
{048FED78-4BFA-4FCD-8FF2-905E9CA4D7DD} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{EFE6E0AB-5218-436A-B1F3-8861AF28F785} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC}


+ 8
- 0
WpfLibrary1/Class1.cs Просмотреть файл

@@ -0,0 +1,8 @@
using System;

namespace WpfLibrary1
{
public class Class1
{
}
}

+ 9
- 0
WpfLibrary1/WpfLibrary1.csproj Просмотреть файл

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

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>

</Project>

Загрузка…
Отмена
Сохранить