pry há 2 anos
ascendente
cometimento
6821a14c33
14 ficheiros alterados com 1566 adições e 578 eliminações
  1. +13
    -0
      BPASmartClient.Lebai/LebaiRobot.cs
  2. +53
    -0
      BPASmartClient.LebaiRobot/LebaiHelper.cs
  3. +49
    -19
      BPASmartClient.Model/果汁机/JuicerModel.cs
  4. +11
    -1
      BPASmartClient.MorkT.Lebai.JC/BPASmartClient.MorkTLebaiJC.csproj
  5. +486
    -452
      BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs
  6. +75
    -0
      BPASmartClient.MorkT.Lebai.JC/GVL_MorkTLebeiJC.cs
  7. +17
    -0
      BPASmartClient.MorkT.Lebai.JC/OrderLocInfo.cs
  8. +399
    -0
      BPASmartClient.MorkT.Lebai.JC/View/DebugView.xaml
  9. +37
    -0
      BPASmartClient.MorkT.Lebai.JC/View/DebugView.xaml.cs
  10. +235
    -0
      BPASmartClient.MorkT.Lebai.JC/ViewModel/DebugViewModel.cs
  11. +94
    -0
      BPASmartClient.MorkT.Lebai.JC/ViewModel/MonitorViewModel.cs
  12. +13
    -11
      BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml
  13. +2
    -0
      BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml.cs
  14. +82
    -95
      BPASmartClient.Morkt.JAKA.JC/ViewModel/DebugViewModel.cs

+ 13
- 0
BPASmartClient.Lebai/LebaiRobot.cs Ver ficheiro

@@ -52,6 +52,7 @@ namespace BPASmartClient.Lebai
status["RobotValue1"] = LebaiHelper.GetInstance().GetValueAsync(1).Value;
status["GetInput"] = LebaiHelper.GetInstance().GetInput();
status["GetInput2"] = LebaiHelper.GetInstance().GetInput(2);
if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] = LebaiHelper.GetInstance().robotData.RobotMode.Mode;
LebaiHelper.GetInstance().GetRobotModeStatus();
Thread.Sleep(10);
@@ -117,6 +118,12 @@ namespace BPASmartClient.Lebai
case "机器人急停":
LebaiHelper.GetInstance().EStopRobot();
break;
case "暂停":
LebaiHelper.GetInstance().pauseMode();
break;
case "恢复":
LebaiHelper.GetInstance().resumeMode();
break;
default:
break;
}
@@ -149,6 +156,12 @@ namespace BPASmartClient.Lebai

public override void WriteData(string address, object value)
{
}
public void SetDO(bool value, int Ch=0)
{
LebaiHelper.GetInstance().SetOutput(value,Ch);
}
}
}

+ 53
- 0
BPASmartClient.LebaiRobot/LebaiHelper.cs Ver ficheiro

@@ -189,6 +189,42 @@ namespace BPASmartClient.LebaiRobot
MessageLog.GetInstance.ShowEx(ex.ToString());
}
}
/// <summary>
/// 暂停
/// </summary>
public async void pauseMode()
{
try
{
if (robotData != null)
{
await client.Pause();
MessageLog.GetInstance.Show("机器人切换为暂停模式.");
}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx(ex.ToString());
}
}
/// <summary>
/// 恢复
/// </summary>
public async void resumeMode()
{
try
{
if (robotData != null)
{
await client.Resume();
MessageLog.GetInstance.Show("机器人切换为暂停后恢复模式.");
}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx(ex.ToString());
}
}

/// <summary>
/// 机器人急停
@@ -266,7 +302,24 @@ namespace BPASmartClient.LebaiRobot
}
return false;
}
/// <summary>
/// 设置DO输出
/// </summary>
/// <param name="pin"></param>
/// <returns></returns>
public void SetOutput(bool bDO, int pin = 0)
{
try
{
if (client == null) { return; }
var res = client.SetDIO(new DIO() { Pin = pin, Value = bDO ? 1 : 0 });

}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx(ex.ToString());
}
}
public bool GetTcpInput(int pin = 1)
{
try


+ 49
- 19
BPASmartClient.Model/果汁机/JuicerModel.cs Ver ficheiro

@@ -10,26 +10,56 @@ namespace BPASmartClient.Model
public class JuicerModel
{
#region 果汁机设备MORKT2 Lebai机器人
public const int JUICE2_初始位 = 10021;
public const int JUICE2_检测位回原点 = 10023;
public const int JUICE2_取纸杯 = 10006;
public const int JUICE2_二次取杯 = 10008;
public const int JUICE2_纸杯检测 = 10007;
//public const int JUICE2_初始位 = 10021;
//public const int JUICE2_检测位回原点 = 10023;
//public const int JUICE2_取纸杯 = 10006;
//public const int JUICE2_二次取杯 = 10008;
//public const int JUICE2_纸杯检测 = 10007;
//public const int JUICE2_再检测 = 10024;
//public const int JUICE2_接咖啡 = 10009;
//public const int JUICE2_放咖啡杯 = 10010;

//public const int JUICE2_接茶叶 = 10017;
//public const int JUICE2_接茶水 = 10018;
//public const int JUICE2_接水 = 10020;
//public const int JUICE2_放水杯 = 10019;

//public const int JUICE2_接果汁公共位 = 10011;
//public const int JUICE2_接1号果汁 = 10012;
//public const int JUICE2_接2号果汁 = 10013;
//public const int JUICE2_接3号果汁 = 10014;
//public const int JUICE2_接4号果汁 = 10015;
//public const int JUICE2_放果汁杯 = 10016;

public const int JUICE2_初始位 = 10001;
public const int JUICE2_检测位回原点 = 10001;
public const int JUICE2_取空杯过渡位 = 10004;
public const int JUICE2_取纸杯 = 10002;
public const int JUICE2_取纸杯检测 = 10003;
public const int JUICE2_再检测 = 10024;
public const int JUICE2_接咖啡 = 10009;
public const int JUICE2_放咖啡杯 = 10010;

public const int JUICE2_接茶叶 = 10017;
public const int JUICE2_接茶水 = 10018;
public const int JUICE2_接水 = 10020;
public const int JUICE2_放水杯 = 10019;

public const int JUICE2_接果汁公共位 = 10011;
public const int JUICE2_接1号果汁 = 10012;
public const int JUICE2_接2号果汁 = 10013;
public const int JUICE2_接3号果汁 = 10014;
public const int JUICE2_接4号果汁 = 10015;
public const int JUICE2_放果汁杯 = 10016;
public const int JUICE2_二次取杯 = 10008;

//public const int JUICE2_取杯完成后接饮料过渡位 = 10004;

public const int JUICE2_接咖啡 = 10004;
//public const int JUICE2_接咖啡放杯过渡位 = 10004;
public const int JUICE2_接果汁1 = 10004;
public const int JUICE2_接果汁2 = 10004;
public const int JUICE2_接果汁3 = 10004;
public const int JUICE2_接果汁4 = 10004;

public const int JUICE2_接茶叶 = 10004;
public const int JUICE2_接茶水 = 10004;
public const int JUICE2_接开水 = 10004;
//public const int JUICE2_接开水_茶水放杯过渡位 = 10004;

public const int JUICE2_放咖啡杯 = 10004;//放咖啡杯包括取接好咖啡的流程
public const int JUICE2_放果汁杯1 = 10004;
public const int JUICE2_放果汁杯2 = 10004;
public const int JUICE2_放果汁杯3 = 10004;
public const int JUICE2_放果汁杯4 = 10004;
public const int JUICE2_放水杯 = 10004;

#endregion

#region 果汁机设备 MORKT1 JAKA机器人


+ 11
- 1
BPASmartClient.MorkT.Lebai.JC/BPASmartClient.MorkTLebaiJC.csproj Ver ficheiro

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

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
@@ -7,10 +7,20 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" />
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" />
<ProjectReference Include="..\BPASmartClient.DRCoffee\BPASmartClient.DRCoffee.csproj" />
<ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" />
<ProjectReference Include="..\BPASmartClient.Juicer\BPASmartClient.Juicer.csproj" />
<ProjectReference Include="..\BPASmartClient.Lebai\BPASmartClient.Lebai.csproj" />
<ProjectReference Include="..\BPASmartClient.MCU\BPASmartClient.MCU.csproj" />
</ItemGroup>

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

</Project>

+ 486
- 452
BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs
A apresentação das diferenças no ficheiro foi suprimida por ser demasiado grande
Ver ficheiro


+ 75
- 0
BPASmartClient.MorkT.Lebai.JC/GVL_MorkTLebeiJC.cs Ver ficheiro

@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.Device;
using System.Collections.Concurrent;

namespace BPASmartClient.MorkTLebaiJC
{
public class GVL_MorkTLebaiJC : IStatus
{
/// <summary>
/// <summary>
/// 咖啡订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesCoffee = new ConcurrentQueue<OrderLocInfo>();
/// <summary>
/// 是否有咖啡杯
/// </summary>
public bool IsHaveCoffeeCup = false;

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

/// <summary>
/// 果汁订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesJuicer = new ConcurrentQueue<OrderLocInfo>();
/// <summary>
/// 果汁是否在制作中
/// </summary>
public bool IsHaveJuiceCup = false;
/// <summary>
/// 咖啡是否制作完成
/// </summary>
public bool MakeJuiceEnd = false;

/// <summary>
/// 做茶订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesTea = new ConcurrentQueue<OrderLocInfo>();
/// <summary>
/// 茶或水是否在制作中
/// </summary>
public bool IsHaveTeaWaterCup = false;
/// <summary>
/// 咖啡是否制作完成
/// </summary>
public bool MakeTeaEnd = false;

/// <summary>
/// 做开水订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesWater = new ConcurrentQueue<OrderLocInfo>();

/// <summary>
/// 等待取餐订单
/// </summary>
public OrderLocInfo waitMorkOrder = new OrderLocInfo();

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

/// <summary>
/// 订单ID
/// </summary>
public string SuborderId = null;
}
}

+ 17
- 0
BPASmartClient.MorkT.Lebai.JC/OrderLocInfo.cs Ver ficheiro

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

namespace BPASmartClient.MorkTLebaiJC
{
public class OrderLocInfo
{
public string SuborderId { get; set; }
public ushort Loc { get; set; }
public ushort RecipeNumber { get; set; }
public int BatchingId { get; set; }
public string GoodName { get; set; }
}
}

+ 399
- 0
BPASmartClient.MorkT.Lebai.JC/View/DebugView.xaml Ver ficheiro

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

<GroupBox Grid.ColumnSpan="2"
FontFamily="楷体"
FontSize="20"
Header=" 乐白机器人 ">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding RobotConnected}"
Margin="40,0"/>
<TextBlock Text="机器人模式:"/>
<TextBlock Text="{Binding RobotMode}"
Margin="40,0"/>
</StackPanel>
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding RobotConnected}"
Margin="120,0,0,0"/>
<ListBox Grid.Row="2" Background="Transparent" Margin="0,0,0,-9">
<ListBox.Template>
<ControlTemplate TargetType="{x:Type ListBox}">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<WrapPanel Orientation="Horizontal" IsItemsHost="True" ScrollViewer.CanContentScroll="True"/>
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
<Button Content="机器人启动"
Margin="20,5" Width="80" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人启动">
</Button>
<Button Content="启动示教"
Margin="20,5" Width="80" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="启动示教"/>
<Button Content="停止示教"
Margin="20,5" Width="80" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="停止示教"/>
<Button Content="机器人急停"
Margin="20,5" Width="80" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人急停"/>
<Button Content="暂停"
Margin="10,5" Width="40" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="暂停"/>
<Button Content="恢复"
Margin="10,5" Width="40" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="恢复"/>
</ListBox>
<Grid Margin="629,-24,19,0" Grid.RowSpan="3">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<TextBlock>DI</TextBlock>
<CheckBox Margin="50,0,0,0" IsEnabled="false" Name="Robot_DI0">DI0</CheckBox>
<CheckBox Margin="120,0,0,0" IsEnabled="false" Name="Robot_DI1">DI1</CheckBox>
<CheckBox Margin="190,0,0,0" IsEnabled="false" Name="Robot_DI2">DI2</CheckBox>
<CheckBox Margin="260,0,0,0" IsEnabled="false" Name="Robot_DI3">DI3</CheckBox>
</Grid>
<Grid Grid.Row="1">
<TextBlock Width="50">DO</TextBlock>
<ComboBox Width="70" Margin="50,12,268,10" SelectedIndex="{Binding Lebai_DO_CH}">
<ComboBoxItem IsSelected="true">DO0</ComboBoxItem>
<ComboBoxItem>DO1</ComboBoxItem>
<ComboBoxItem>DO2</ComboBoxItem>
<ComboBoxItem>DO3</ComboBoxItem>
</ComboBox>
<ComboBox Margin="142,12,108,10" Width="70" SelectedIndex="{Binding Lebai_DO_Value}">
<ComboBoxItem IsSelected="true">true</ComboBoxItem>
<ComboBoxItem>false</ComboBoxItem>
</ComboBox>
<Button Width="50" Margin="260,12,10,10" Command="{Binding Button_LebaiDOuputCommand}" >输出</Button>
</Grid>
</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2"
FontFamily="楷体"
FontSize="20"
Header=" 果汁机 ">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding JuicerConnected}"
Margin="120,0,0,0"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="设备状态" />
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Name="Heating" HorizontalAlignment="Center">制热</TextBlock>
<TextBlock Grid.Column="1" Name="cooling" HorizontalAlignment="Center">制冷</TextBlock>
<TextBlock Grid.Column="2" Name="LackOfWater" HorizontalAlignment="Center">缺水</TextBlock>
<TextBlock Grid.Column="3" Name="ChildLocks" HorizontalAlignment="Center">童锁</TextBlock>
<TextBlock Grid.Column="4" Name="Use" HorizontalAlignment="Center">使用</TextBlock>
</Grid>

</Grid>


<StackPanel Grid.Row="2" Orientation="Vertical">
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>果汁</TextBlock>
<ComboBox Margin="100,0,0,0"
Width="100" >
<ComboBoxItem IsSelected="true">饮品1</ComboBoxItem>
<ComboBoxItem>饮品2</ComboBoxItem>
<ComboBoxItem>饮品3</ComboBoxItem>
<ComboBoxItem>饮品4</ComboBoxItem>
</ComboBox>
<ComboBox Margin="20,0,0,0" Width="100">
<ComboBoxItem IsSelected="true">冷饮</ComboBoxItem>
<ComboBoxItem>热饮</ComboBoxItem>
</ComboBox>
<Button Command="{Binding Button_MakeIceCreamCommand}"
Margin="20,0"
Content="制作" />
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">

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

</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<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>
</Grid>
<Grid Grid.Row="1" Grid.Column="0">
<Button FontSize="15" HorizontalAlignment="Center" Command="{Binding Button_MCUOuputCommand}">输出</Button>
</Grid>
<Grid Grid.Row="1" Grid.Column="1" Width="60" >
<TextBox Text="{Binding PWMInputNumber}"></TextBox>
</Grid>
</Grid>
</Grid>
<Grid Grid.Column="2" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="0" >
<TextBlock FontSize="12" HorizontalAlignment="Center">DI输入</TextBlock>
</Grid>
<Grid Grid.Row="1" Grid.Column="0" Width="400">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<CheckBox FontSize="12" IsEnabled="false" IsChecked="{Binding CH0}">DI0</CheckBox>
</Grid>
<Grid Grid.Column="1">
<CheckBox FontSize="12" IsEnabled="false" Name="CH1">DI1</CheckBox>
</Grid>
<Grid Grid.Column="2">
<CheckBox FontSize="12" IsEnabled="false" Name="CH2">DI2</CheckBox>
</Grid>
<Grid Grid.Column="3">
<CheckBox FontSize="12" IsEnabled="false" Name="CH3">DI3</CheckBox>
</Grid>
<Grid Grid.Column="4">
<CheckBox FontSize="12" IsEnabled="false" Name="CH4">DI4</CheckBox>
</Grid>
<Grid Grid.Column="5">
<CheckBox FontSize="12" IsEnabled="false" Name="CH5">DI5</CheckBox>
</Grid>
<Grid Grid.Column="6">
<CheckBox FontSize="12" IsEnabled="false" Name="CH6">DI6</CheckBox>
</Grid>
<Grid Grid.Column="7">
<CheckBox FontSize="12" IsEnabled="false" Name="CH7">DI7</CheckBox>
</Grid>
</Grid>

</Grid>
</Grid>
</Grid>

<Grid Grid.Column="3" >
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<TextBlock FontSize="12" HorizontalAlignment="Center">DO输出</TextBlock>
</Grid>
<Grid Grid.Column="1" Grid.Row="0">
<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>
</Grid>
<Grid Grid.Column="0" Grid.Row="1">
<Button Width="50" Command="{Binding Button_MCUDOuputCommand}">输出</Button>
</Grid>
<Grid Grid.Column="1" Grid.Row="1">
<RadioButton FontSize="12" IsChecked="{Binding MCU_DO_Value}">True</RadioButton>
<RadioButton Margin="50,0,0,0" FontSize="12">false</RadioButton>
</Grid>
</Grid>
</Grid>
</GroupBox>
</Grid>
</UserControl>

+ 37
- 0
BPASmartClient.MorkT.Lebai.JC/View/DebugView.xaml.cs Ver ficheiro

@@ -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.MorkTJAKAJC.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-传感器监视");

}
}

}

+ 235
- 0
BPASmartClient.MorkT.Lebai.JC/ViewModel/DebugViewModel.cs Ver ficheiro

@@ -0,0 +1,235 @@
using BPASmartClient.Business;
using BPASmartClient.Device;
using BPASmartClient.DRCoffee;
using BPASmartClient.EventBus;
using BPASmartClient.GSIceCream;
using BPASmartClient.Helper;
using BPASmartClient.LebaiRobot;
using BPASmartClient.Message;
using BPASmartClient.Model;
using BPASmartClient.Model.乐白机器人;
using BPASmartClient.Model.冰淇淋.Enum;
using BPASmartClient.Model.单片机;
using BPASmartClient.Model.单片机.Enum;
using BPASmartClient.Model.咖啡机.Enum;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
namespace BPASmartClient.MorkTLebaiJC.ViewModel;
public class DebugViewModel : ObservableObject
{
#region 乐白机器人
/// <summary>
/// 乐白机器人连接状态
/// </summary>
public string RobotConnected { get { return _robotConnected; } set { _robotConnected = value; OnPropertyChanged(); } }
private string _robotConnected { get; set; }
/// <summary>
/// 乐白机器人的模式状态
/// </summary>
public string RobotMode { get { return _robotMode; } set { _robotMode = value; OnPropertyChanged(); } }
private string _robotMode { get; set; }
/// <summary>
/// 机器人控制指令
/// </summary>
public RelayCommand<object> Button_RobotControlCommand { get; set; }
/// <summary>
/// 机器人控制
/// </summary>
/// <param name="o"></param>
private void Button_RobotControl(object o)
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiControlEvent { DeviceId = DeviceId, LebaiControl = o.ToString() });
}

#endregion

#region 果汁机
/// <summary>
/// 果汁机的连接状态
/// </summary>
public string JuicerConnected { get { return _JuicerConnected; } set { _JuicerConnected = value; OnPropertyChanged(); } }
private string _JuicerConnected { get; set; }
/// <summary>
/// 果汁机的状态
/// </summary>
public string JuicerState { get { return _JuicerState; } set { _JuicerState = value; OnPropertyChanged(); } }
private string _JuicerState { get; set; }
#endregion

#region 咖啡机
/// <summary>
/// 咖啡机连接状态
/// </summary>
public string CoffeeConnected { get { return _coffeeConnected; } set { _coffeeConnected = value; OnPropertyChanged(); } }
private string _coffeeConnected { get; set; }
/// <summary>
/// 咖啡机状态
/// </summary>
public string CoffeeStatus { get { return _coffeeStatus; } set { _coffeeStatus = value; OnPropertyChanged(); } }
private string _coffeeStatus { get; set; }
/// <summary>
/// 应用状态
/// </summary>
public string AppStatus { get { return _appStatus; } set { _appStatus = value; OnPropertyChanged(); } }
private string _appStatus { get; set; }
/// <summary>
/// 告警
/// </summary>
public string Warning { get { return _warning; } set { _warning = value; OnPropertyChanged(); } }
public string _warning { get; set; }
/// <summary>
/// 故障信息
/// </summary>
public string CaffeeFault { get { return _caffeeFault; } set { _caffeeFault = value; OnPropertyChanged(); } }
public string _caffeeFault { get; set; }

public List<string> Coffees { get; set; } = new List<string>();
public string SelectedCoffee { get; set; }

public List<string> CoffeeCmds { get; set; } = new List<string>();
public string SelectedCoffeeCmd { get; set; }
/// <summary>
/// 制作咖啡
/// </summary>
public RelayCommand Button_MakeCoffeeCommand { get; set; }
/// <summary>
/// 停止制作咖啡
/// </summary>
public RelayCommand Button_StopMakeCoffeCommand { get; set; }
/// <summary>
/// 咖啡模式设置
/// </summary>
public RelayCommand Button_CoffeeModeSetCommand { get; set; }

private void Button_MakeCoffee()
{
EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee)});
}
private void Button_StopMakeCoffe()
{
EventBus.EventBus.GetInstance().Publish(new DRCoffee_CancelMakeCoffeeEvent() { DeviceId = DeviceId });
}
private void Button_CoffeeModeSet()
{
EventBus.EventBus.GetInstance().Publish(new DRCoffee_CoffeeCommCmdEvent() { DeviceId = DeviceId, CommCmd = (DrCoffeeCommCmd)Enum.Parse(typeof(DrCoffeeCommCmd), SelectedCoffeeCmd)});
}
#endregion

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

public RelayCommand Button_MCUOuputCommand { get; set; }
public RelayCommand Button_MCUDOuputCommand { get; set; }
public RelayCommand Button_LebaiDOuputCommand { get; set; }
public int PWMInputNumber { get { return _pwmInputNumber; } set { _pwmInputNumber = value; OnPropertyChanged(); } }
private int _pwmInputNumber = 1;

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

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

public int Lebai_DO_CH { get { return _lebaiDO_CH; } set { _lebaiDO_CH = value; OnPropertyChanged(); } }
private int _lebaiDO_CH = 1;

public int Lebai_DO_Value { get { return _lebaiDO_Value; } set { _lebaiDO_Value = value; OnPropertyChanged(); } }
private int _lebaiDO_Value = 1;

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

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_McuOutput()
{
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();
}
private void Button_LebaiDOutput()
{
string sChooseDO = Convert.ToString(Lebai_DO_CH + 1);
}
#endregion

/// <summary>
/// 设备ID
/// </summary>
public int DeviceId { get; set; }
/// <summary>
/// 设备数据
/// </summary>
public ObservableCollection<VariableMonitor> variableMonitors { get; set; }
public DebugViewModel()
{
Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl);
Button_MakeCoffeeCommand = new RelayCommand(Button_MakeCoffee);
Button_StopMakeCoffeCommand = new RelayCommand(Button_StopMakeCoffe);
Button_CoffeeModeSetCommand = new RelayCommand(Button_CoffeeModeSet);

Button_MCUOuputCommand = new RelayCommand(Button_McuOutput);
Button_MCUDOuputCommand = new RelayCommand(Button_McuDOutput);
Button_LebaiDOuputCommand = new RelayCommand(Button_LebaiDOutput);
foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode)))
{
Coffees.Add(code.ToString());
}
SelectedCoffee = Coffees[0];
foreach (DrCoffeeCommCmd code in Enum.GetValues(typeof(DrCoffeeCommCmd)))
{
CoffeeCmds.Add(code.ToString());
}
SelectedCoffeeCmd = CoffeeCmds[0];

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



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

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

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

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

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


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


+ 94
- 0
BPASmartClient.MorkT.Lebai.JC/ViewModel/MonitorViewModel.cs Ver ficheiro

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

}

+ 13
- 11
BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml Ver ficheiro

@@ -79,11 +79,11 @@
<Button Content="暂停"
Margin="10,5" Width="40" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人急停"/>
CommandParameter="停"/>
<Button Content="恢复"
Margin="10,5" Width="40" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人急停"/>
CommandParameter="恢复"/>
</ListBox>
<Grid Margin="629,-24,19,0" Grid.RowSpan="3">
<Grid.RowDefinitions>
@@ -125,7 +125,7 @@
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding IceCreamConnected}"
<TextBlock Text="{Binding JuicerConnected}"
Margin="120,0,0,0"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
@@ -273,6 +273,8 @@
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" >
<TextBlock FontSize="12">连接状态</TextBlock>
<TextBlock Text="{Binding MCUConnected}"
Margin="70,0,0,0"/>
<TextBlock FontSize="12"></TextBlock>
</Grid>
<Grid Grid.Column="1" >
@@ -290,7 +292,7 @@

</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<ComboBox Margin="0,0,0,0" FontSize="12" Width="60">
<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>
@@ -298,10 +300,10 @@
</ComboBox>
</Grid>
<Grid Grid.Row="1" Grid.Column="0">
<Button FontSize="15" HorizontalAlignment="Center">输出</Button>
<Button FontSize="15" HorizontalAlignment="Center" Command="{Binding Button_MCUOuputCommand}">输出</Button>
</Grid>
<Grid Grid.Row="1" Grid.Column="1" Width="60">
<TextBox>1</TextBox>
<Grid Grid.Row="1" Grid.Column="1" Width="60" >
<TextBox Text="{Binding PWMInputNumber}"></TextBox>
</Grid>
</Grid>
</Grid>
@@ -330,7 +332,7 @@
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<CheckBox FontSize="12" IsEnabled="false" Name="CH0">DI0</CheckBox>
<CheckBox FontSize="12" IsEnabled="false" IsChecked="{Binding CH0}">DI0</CheckBox>
</Grid>
<Grid Grid.Column="1">
<CheckBox FontSize="12" IsEnabled="false" Name="CH1">DI1</CheckBox>
@@ -372,7 +374,7 @@
<TextBlock FontSize="12" HorizontalAlignment="Center">DO输出</TextBlock>
</Grid>
<Grid Grid.Column="1" Grid.Row="0">
<ComboBox Width="50" FontSize="12" HorizontalAlignment="Center">
<ComboBox Width="50" FontSize="12" HorizontalAlignment="Center" SelectedIndex="{Binding MCU_DO_CH}">
<ComboBoxItem IsSelected="true">DO0</ComboBoxItem>
<ComboBoxItem>DO1</ComboBoxItem>
<ComboBoxItem>DO2</ComboBoxItem>
@@ -384,10 +386,10 @@
</ComboBox>
</Grid>
<Grid Grid.Column="0" Grid.Row="1">
<Button Width="50">输出</Button>
<Button Width="50" Command="{Binding Button_MCUDOuputCommand}">输出</Button>
</Grid>
<Grid Grid.Column="1" Grid.Row="1">
<RadioButton FontSize="12" IsChecked="true">True</RadioButton>
<RadioButton FontSize="12" IsChecked="{Binding MCU_DO_Value}">True</RadioButton>
<RadioButton Margin="50,0,0,0" FontSize="12">false</RadioButton>
</Grid>
</Grid>


+ 2
- 0
BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml.cs Ver ficheiro

@@ -30,6 +30,8 @@ namespace BPASmartClient.MorkTJAKAJC.View
{
ThreadManage.GetInstance().StopTask("MorkT-状态刷新");
ThreadManage.GetInstance().StopTask("MorkT-传感器监视");

}
}

}

+ 82
- 95
BPASmartClient.Morkt.JAKA.JC/ViewModel/DebugViewModel.cs Ver ficheiro

@@ -19,7 +19,6 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;

namespace BPASmartClient.MorkTJAKAJC.ViewModel;
public class DebugViewModel : ObservableObject
{
@@ -65,109 +64,104 @@ namespace BPASmartClient.MorkTJAKAJC.ViewModel;
public string JuicerState { get { return _JuicerState; } set { _JuicerState = value; OnPropertyChanged(); } }
private string _JuicerState { get; set; }
#endregion
#endregion

#region 咖啡机
/// <summary>
/// 咖啡机连接状态
/// </summary>
public string CoffeeConnected { get { return _coffeeConnected; } set { _coffeeConnected = value; OnPropertyChanged(); } }
private string _coffeeConnected { get; set; }
/// <summary>
/// 咖啡机状态
/// </summary>
public string CoffeeStatus { get { return _coffeeStatus; } set { _coffeeStatus = value; OnPropertyChanged(); } }
private string _coffeeStatus { get; set; }
/// <summary>
/// 应用状态
/// </summary>
public string AppStatus { get { return _appStatus; } set { _appStatus = value; OnPropertyChanged(); } }
private string _appStatus { get; set; }
/// <summary>
/// 告警
/// </summary>
public string Warning { get { return _warning; } set { _warning = value; OnPropertyChanged(); } }
public string _warning { get; set; }
/// <summary>
/// 故障信息
/// </summary>
public string CaffeeFault { get { return _caffeeFault; } set { _caffeeFault = value; OnPropertyChanged(); } }
public string _caffeeFault { get; set; }

public List<string> Coffees { get; set; } = new List<string>();
public string SelectedCoffee { get; set; }

public List<string> CoffeeCmds { get; set; } = new List<string>();
public string SelectedCoffeeCmd { get; set; }
/// <summary>
/// 制作咖啡
/// </summary>
public RelayCommand Button_MakeCoffeeCommand { get; set; }
/// <summary>
/// 停止制作咖啡
/// </summary>
public RelayCommand Button_StopMakeCoffeCommand { get; set; }
/// <summary>
/// 咖啡模式设置
/// <summary>
/// 咖啡机连接状态
/// </summary>
public RelayCommand Button_CoffeeModeSetCommand { get; set; }

private void Button_MakeCoffee()
{
EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee)});
}
private void Button_StopMakeCoffe()
{
EventBus.EventBus.GetInstance().Publish(new DRCoffee_CancelMakeCoffeeEvent() { DeviceId = DeviceId });
}
private void Button_CoffeeModeSet()
{
EventBus.EventBus.GetInstance().Publish(new DRCoffee_CoffeeCommCmdEvent() { DeviceId = DeviceId, CommCmd = (DrCoffeeCommCmd)Enum.Parse(typeof(DrCoffeeCommCmd), SelectedCoffeeCmd)});
}
#endregion

#region 单片机
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 RelayCommand<object> Button_CupControlCommand { get; set; }
public string Warning { get { return _warning; } set { _warning = value; OnPropertyChanged(); } }
public string _warning { get; set; }
/// <summary>
/// 单片机冰淇淋机器制冷
/// 故障信息
/// </summary>
public RelayCommand Button_SCChipRefrigerationCommand { get; set; }
public string CaffeeFault { get { return _caffeeFault; } set { _caffeeFault = value; OnPropertyChanged(); } }
public string _caffeeFault { get; set; }

public List<string> Coffees { get; set; } = new List<string>();
public string SelectedCoffee { get; set; }

public List<string> CoffeeCmds { get; set; } = new List<string>();
public string SelectedCoffeeCmd { get; set; }
/// <summary>
/// 单片机冰淇淋机器打料
/// 制作咖啡
/// </summary>
public RelayCommand Button_SCChipDischargeCommand { get; set; }
public RelayCommand Button_MakeCoffeeCommand { get; set; }
/// <summary>
/// 模拟测试
/// 停止制作咖啡
/// </summary>
public RelayCommand Button_SCChipTestCommand { get; set; }
public RelayCommand Button_StopMakeCoffeCommand { get; set; }
/// <summary>
/// 咖啡模式设置
/// </summary>
public RelayCommand Button_CoffeeModeSetCommand { get; set; }

private void Button_CupControl(object CupType)
private void Button_MakeCoffee()
{
EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent() { DeviceId = DeviceId, Cup = (IC_CUP)Enum.Parse(typeof(IC_CUP), CupType.ToString()) });
EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee)});
}

private void Button_SCChipRefrigeration()
private void Button_StopMakeCoffe()
{
EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = true });
Thread.Sleep(500);
EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = false });
EventBus.EventBus.GetInstance().Publish(new DRCoffee_CancelMakeCoffeeEvent() { DeviceId = DeviceId });
}

private void Button_SCChipDischarge()
private void Button_CoffeeModeSet()
{
EventBus.EventBus.GetInstance().Publish(new SCChip_MakeIceCreamEvent { DeviceId = DeviceId, SteeringEngine = IC_SE.SE_2 });
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; }
#region 单片机
public string MCUConnected { get { return _mcuConnected; } set { _mcuConnected = value; OnPropertyChanged(); } }
private string _mcuConnected { get; set; }

public RelayCommand Button_MCUOuputCommand { get; set; }
public RelayCommand Button_MCUDOuputCommand { get; set; }
public int PWMInputNumber { get { return _pwmInputNumber; } set { _pwmInputNumber = value; OnPropertyChanged(); } }
private int _pwmInputNumber = 1;

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

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

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

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_McuOutput()
{
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

/// <summary>
/// 设备ID
/// </summary>
public int DeviceId { get; set; }
/// <summary>
/// 设备数据
/// </summary>
@@ -180,15 +174,8 @@ namespace BPASmartClient.MorkTJAKAJC.ViewModel;
Button_StopMakeCoffeCommand = new RelayCommand(Button_StopMakeCoffe);
Button_CoffeeModeSetCommand = new RelayCommand(Button_CoffeeModeSet);

Button_CupControlCommand = new RelayCommand<object>(Button_CupControl);
Button_SCChipRefrigerationCommand = new RelayCommand(Button_SCChipRefrigeration);
Button_SCChipDischargeCommand = new RelayCommand(Button_SCChipDischarge);
Button_SCChipTestCommand = new RelayCommand(() =>
{
Button_SCChipRefrigeration();
Thread.Sleep(50);
Button_SCChipDischarge();
});
Button_MCUOuputCommand = new RelayCommand(Button_McuOutput);
Button_MCUDOuputCommand = new RelayCommand(Button_McuDOutput);

foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode)))
{
@@ -216,9 +203,10 @@ namespace BPASmartClient.MorkTJAKAJC.ViewModel;

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

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

@@ -229,7 +217,6 @@ namespace BPASmartClient.MorkTJAKAJC.ViewModel;


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


Carregando…
Cancelar
Guardar