@@ -0,0 +1,9 @@ | |||
<Application x:Class="BPACommonClient.App" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:local="clr-namespace:BPACommonClient" | |||
StartupUri="MainWindow.xaml"> | |||
<Application.Resources> | |||
</Application.Resources> | |||
</Application> |
@@ -0,0 +1,17 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Configuration; | |||
using System.Data; | |||
using System.Linq; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
namespace BPACommonClient | |||
{ | |||
/// <summary> | |||
/// Interaction logic for App.xaml | |||
/// </summary> | |||
public partial class App : Application | |||
{ | |||
} | |||
} |
@@ -0,0 +1,10 @@ | |||
using System.Windows; | |||
[assembly: ThemeInfo( | |||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | |||
//(used if a resource is not found in the page, | |||
// or application resource dictionaries) | |||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | |||
//(used if a resource is not found in the page, | |||
// app, or any theme specific resource dictionaries) | |||
)] |
@@ -0,0 +1,10 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<OutputType>WinExe</OutputType> | |||
<TargetFramework>net6.0-windows</TargetFramework> | |||
<Nullable>enable</Nullable> | |||
<UseWPF>true</UseWPF> | |||
</PropertyGroup> | |||
</Project> |
@@ -0,0 +1,12 @@ | |||
<Window x:Class="BPACommonClient.MainWindow" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:local="clr-namespace:BPACommonClient" | |||
mc:Ignorable="d" | |||
Title="MainWindow" Height="450" Width="800"> | |||
<Grid> | |||
</Grid> | |||
</Window> |
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPACommonClient | |||
{ | |||
/// <summary> | |||
/// Interaction logic for MainWindow.xaml | |||
/// </summary> | |||
public partial class MainWindow : Window | |||
{ | |||
public MainWindow() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -8,7 +8,7 @@ | |||
<ItemGroup> | |||
<PackageReference Include="BPA.ApolloClient" Version="1.0.12" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.24" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.26" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" /> | |||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" /> | |||
@@ -45,11 +45,11 @@ namespace BPASmartClient.Business | |||
if (morkOrderPushes.TryDequeue(out MorkOrderPush mork)) | |||
{ | |||
Thread.Sleep(3000); | |||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COOKING, SubOrderId = mork.SuborderId }.Publish(); | |||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COOKING, SubOrderId = mork.SuborderId, GoodName = mork.GoodsName }.Publish(); | |||
Thread.Sleep(5000); | |||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_COOK, SubOrderId = mork.SuborderId }.Publish(); | |||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_COOK, SubOrderId = mork.SuborderId, GoodName = mork.GoodsName }.Publish(); | |||
Thread.Sleep(5000); | |||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_TAKE, SubOrderId = mork.SuborderId }.Publish(); | |||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_TAKE, SubOrderId = mork.SuborderId, GoodName = mork.GoodsName }.Publish(); | |||
Thread.Sleep(2000); | |||
} | |||
} | |||
@@ -122,7 +122,12 @@ namespace BPASmartClient.Business | |||
{ | |||
OrderStatusChangedEvent orderStatusChangedEvent = @event as OrderStatusChangedEvent; | |||
string result = string.Empty; | |||
OrderStatusChange orderStatusChange = new OrderStatusChange() { CookingStatus = orderStatusChangedEvent.Status, SuborderId = orderStatusChangedEvent.SubOrderId }; | |||
OrderStatusChange orderStatusChange = new OrderStatusChange() | |||
{ | |||
CookingStatus = orderStatusChangedEvent.Status, | |||
SuborderId = orderStatusChangedEvent.SubOrderId, | |||
GoodName = orderStatusChangedEvent.GoodName | |||
}; | |||
#region API 订单状态修改 | |||
try | |||
@@ -144,6 +149,7 @@ namespace BPASmartClient.Business | |||
#region MQTT 订单状态修改 | |||
var clientId = Plugin.GetInstance().GetPlugin<ConfigMgr>().ClientId; | |||
var temp = BPAPackage.Make(orderStatusChange, clientId, orderStatusChangedEvent.deviceClientType); | |||
var q = temp.Serialize(false); | |||
Plugin.GetInstance().GetPlugin<MQTTMgr>().Publish(TOPIC.GetInstance.GetAppTopic(clientId.ToString()), temp.Serialize(false)); | |||
#endregion | |||
} | |||
@@ -200,7 +200,7 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.24" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.26" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -0,0 +1,34 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Globalization; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Data; | |||
namespace BPASmartClient.CustomResource.Converters | |||
{ | |||
public class VisibleTypeConverter : IValueConverter | |||
{ | |||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
if (value != null && parameter != null && parameter is string p && value is bool type) | |||
{ | |||
if (p != null) | |||
{ | |||
if (p == "NetworkPort") | |||
return type ? Visibility.Visible : Visibility.Collapsed; | |||
else if (p == "SerialPort") | |||
return !type ? Visibility.Visible : Visibility.Collapsed; | |||
} | |||
} | |||
return Visibility.Collapsed; | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
} | |||
} |
@@ -4,5 +4,15 @@ | |||
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters"> | |||
<!-- 文本框的字体颜色 --> | |||
<SolidColorBrush x:Key="TextBlockForeground" Color="#9934F7F7" /> | |||
<!--<con:StringToIconConverter x:Key="StringToIconConverter"/>--> | |||
<!-- 表格头边框颜色 --> | |||
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" /> | |||
<!-- 表格头字体颜色 --> | |||
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" /> | |||
<!-- 数据表边框颜色 --> | |||
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" /> | |||
</ResourceDictionary> |
@@ -123,6 +123,60 @@ | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3" /> | |||
<SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA" /> | |||
<SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5" /> | |||
<Style TargetType="{x:Type PasswordBox}"> | |||
<Setter Property="PasswordChar" Value="●" /> | |||
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" /> | |||
<Setter Property="BorderBrush" Value="{StaticResource TextBox.Static.Border}" /> | |||
<Setter Property="Foreground" Value="#FF02C9FD" /> | |||
<Setter Property="BorderThickness" Value="1" /> | |||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Left" /> | |||
<Setter Property="FocusVisualStyle" Value="{x:Null}" /> | |||
<Setter Property="AllowDrop" Value="true" /> | |||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" /> | |||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" /> | |||
<Setter Property="CaretBrush" Value="White" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type PasswordBox}"> | |||
<Border | |||
x:Name="border" | |||
BorderBrush="#FF08335F" | |||
BorderThickness="{TemplateBinding BorderThickness}" | |||
SnapsToDevicePixels="True"> | |||
<ScrollViewer | |||
x:Name="PART_ContentHost" | |||
Focusable="false" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden" /> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsEnabled" Value="false"> | |||
<Setter TargetName="border" Property="Opacity" Value="0.56" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource TextBox.MouseOver.Border}" /> | |||
</Trigger> | |||
<Trigger Property="IsKeyboardFocused" Value="true"> | |||
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource TextBox.Focus.Border}" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
<Style.Triggers> | |||
<MultiTrigger> | |||
<MultiTrigger.Conditions> | |||
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true" /> | |||
<Condition Property="IsSelectionActive" Value="false" /> | |||
</MultiTrigger.Conditions> | |||
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}" /> | |||
</MultiTrigger> | |||
</Style.Triggers> | |||
</Style> | |||
<Style x:Key="ExpanderUpHeaderStyle" TargetType="{x:Type ToggleButton}"> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
@@ -538,7 +592,7 @@ | |||
<Setter Property="SelectedDateFormat" Value="Short" /> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<Setter Property="Padding" Value="2" /> | |||
<Setter Property="Height" Value="24"/> | |||
<Setter Property="Height" Value="24" /> | |||
<Setter Property="BorderBrush" Value="#08335f" /> | |||
<Setter Property="BorderThickness" Value="1" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> | |||
@@ -957,7 +957,66 @@ | |||
</Setter> | |||
</Style.Setters> | |||
</Style> | |||
<Style TargetType="Button"> | |||
<Style.Setters> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Cursor" Value="Hand" /> | |||
<Setter Property="Foreground" Value="{DynamicResource foreground}" /> | |||
<Setter Property="Height" Value="25" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="Button"> | |||
<Border x:Name="BD" Cursor="Hand"> | |||
<StackPanel | |||
HorizontalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<!--<Border Width="16" Margin="5"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/顶部切图/返回按钮图标.png" /> | |||
</Border.Background> | |||
</Border>--> | |||
<TextBlock Margin="10,0,10,0" | |||
x:Name="textBlock" | |||
VerticalAlignment="Center" | |||
FontSize="14" | |||
Foreground="#4fade8" | |||
Text="{TemplateBinding Content}" /> | |||
<!-- Text="{TemplateBinding Content}" --> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="BD" Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/顶部切图/返回按钮2.png" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="textBlock" Property="Foreground" Value="#4fade8" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="False"> | |||
<Setter TargetName="BD" Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/顶部切图/返回按钮1.png" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="textBlock" Property="Foreground" Value="#4fade8" /> | |||
</Trigger> | |||
<Trigger Property="IsEnabled" Value="False"> | |||
<Setter TargetName="BD" Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/buttonOn.png" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="textBlock" Property="Foreground" Value="#3afdff" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="CommonBtn_返回" TargetType="Button"> | |||
<Style.Setters> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
@@ -1217,7 +1276,7 @@ | |||
</Style.Setters> | |||
</Style> | |||
<Style TargetType="Button"> | |||
<Style x:Key="Comm8" TargetType="Button"> | |||
<Style.Setters> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Cursor" Value="Hand" /> | |||
@@ -0,0 +1,176 @@ | |||
<UserControl x:Class="BPASmartClient.CustomResource.UserControls.UserKeyBoard" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.CustomResource.UserControls" | |||
mc:Ignorable="d" | |||
d:DesignHeight="180" d:DesignWidth="500" | |||
x:Name="Keyboard" Background="Transparent" > | |||
<UserControl.Resources> | |||
<Style x:Key="btnNum" TargetType="{x:Type Button}"> | |||
<Setter Property="HorizontalContentAlignment" Value="Center"/> | |||
<Setter Property="VerticalContentAlignment" Value="Center"/> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type Button}"> | |||
<Border x:Name="border" BorderBrush="#FF474747" BorderThickness="1" CornerRadius="6"> | |||
<Border.Background> | |||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> | |||
<GradientStop Color="#002A5F"/> | |||
<GradientStop Color="#6495ED" Offset="1"/> | |||
</LinearGradientBrush> | |||
</Border.Background> | |||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" TextElement.Foreground="#4fade8" TextElement.FontSize="16" /> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsPressed" Value="True"> | |||
<Setter Property="Background" TargetName="border" > | |||
<Setter.Value> | |||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> | |||
<GradientStop Color="#FFFF7500"/> | |||
<GradientStop Color="#FFFFC547" Offset="1"/> | |||
</LinearGradientBrush> | |||
</Setter.Value> | |||
</Setter> | |||
</Trigger> | |||
<Trigger Property="IsPressed" Value="False"> | |||
<Setter Property="Background" TargetName="border" > | |||
<Setter.Value> | |||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> | |||
<GradientStop Color="#002A5F"/> | |||
<GradientStop Color="#6495ED" Offset="1"/> | |||
</LinearGradientBrush> | |||
</Setter.Value> | |||
</Setter> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<Style x:Key="btnFunc" TargetType="{x:Type Button}"> | |||
<Setter Property="HorizontalContentAlignment" Value="Center"/> | |||
<Setter Property="VerticalContentAlignment" Value="Center"/> | |||
<!--<Setter Property="Padding" Value="1"/>--> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type Button}"> | |||
<Border x:Name="border" BorderBrush="#FF565656" BorderThickness="1" CornerRadius="6"> | |||
<Border.Background> | |||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> | |||
<GradientStop Color="#002A5F"/> | |||
<GradientStop Color="#6495ED" Offset="1"/> | |||
</LinearGradientBrush> | |||
</Border.Background> | |||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" TextElement.Foreground="White" TextElement.FontSize="18"/> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsPressed" Value="True"> | |||
<Setter Property="Background" TargetName="border"> | |||
<Setter.Value> | |||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> | |||
<GradientStop Color="Gray" Offset="1"/> | |||
<GradientStop Color="#FF2D2D2D" Offset="0"/> | |||
</LinearGradientBrush> | |||
</Setter.Value> | |||
</Setter> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</UserControl.Resources> | |||
<UserControl.Triggers> | |||
<EventTrigger SourceName="Keyboard" RoutedEvent="UserControl.Loaded"> | |||
<BeginStoryboard> | |||
<Storyboard> | |||
<DoubleAnimation Storyboard.TargetName="Keyboard" Storyboard.TargetProperty="Opacity" | |||
From="0" To="1" Duration="0:0:0.2"> | |||
</DoubleAnimation> | |||
</Storyboard> | |||
</BeginStoryboard> | |||
</EventTrigger> | |||
</UserControl.Triggers> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="*"/> | |||
</Grid.RowDefinitions> | |||
<Grid > | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="*" /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="10"/> | |||
<ColumnDefinition Width="*"/> | |||
<ColumnDefinition Width="10"/> | |||
</Grid.ColumnDefinitions> | |||
<Grid x:Name="ButtonGrid" Grid.Row="1" Grid.Column="1" ButtonBase.Click="ButtonGrid_Click"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="80*"/> | |||
<RowDefinition Height="80*"/> | |||
<RowDefinition Height="80*"/> | |||
<RowDefinition Height="80*"/> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="120*"/> | |||
<ColumnDefinition Width="120*"/> | |||
<ColumnDefinition Width="120*"/> | |||
<ColumnDefinition Width="120*"/> | |||
<ColumnDefinition Width="120*"/> | |||
<ColumnDefinition Width="120*"/> | |||
<ColumnDefinition Width="120*"/> | |||
<ColumnDefinition Width="120*"/> | |||
<ColumnDefinition Width="120*"/> | |||
<ColumnDefinition Width="120*"/> | |||
</Grid.ColumnDefinitions> | |||
<Button Margin="2" Grid.Column="0" Grid.Row="0" Content="1" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="1" Grid.Row="0" Content="2" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="2" Grid.Row="0" Content="3" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="3" Grid.Row="0" Content="4" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="4" Grid.Row="0" Content="5" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="5" Grid.Row="0" Content="6" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="6" Grid.Row="0" Content="7" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="7" Grid.Row="0" Content="8" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="8" Grid.Row="0" Content="9" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="9" Grid.Row="0" Content="0" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="0" Grid.Row="1" Content="Q" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="1" Grid.Row="1" Content="W" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="2" Grid.Row="1" Content="E" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="3" Grid.Row="1" Content="R" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="4" Grid.Row="1" Content="T" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="5" Grid.Row="1" Content="Y" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="6" Grid.Row="1" Content="U" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="7" Grid.Row="1" Content="I" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="8" Grid.Row="1" Content="O" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="9" Grid.Row="1" Content="P" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="0" Grid.Row="2" Content="A" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="1" Grid.Row="2" Content="S" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="2" Grid.Row="2" Content="D" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="3" Grid.Row="2" Content="F" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="4" Grid.Row="2" Content="G" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="5" Grid.Row="2" Content="H" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="6" Grid.Row="2" Content="J" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="7" Grid.Row="2" Content="K" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="8" Grid.Row="2" Content="L" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="0" Grid.Row="3" Content="Z" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="1" Grid.Row="3" Content="X" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="2" Grid.Row="3" Content="C" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="3" Grid.Row="3" Content="V" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="4" Grid.Row="3" Content="B" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="5" Grid.Row="3" Content="N" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="6" Grid.Row="3" Content="M" Style="{StaticResource btnNum}"/> | |||
<Button Margin="2" Grid.Column="9" Grid.Row="2" Content="A/a" Style="{StaticResource btnFunc}"/> | |||
<Button Margin="2" Grid.Column="7" Grid.Row="3" Content="DEL" Style="{StaticResource btnFunc}"/> | |||
<Button Margin="2" Grid.Column="8" Grid.Row="3" Content="AC" Style="{StaticResource btnFunc}"/> | |||
<Button Margin="2" Grid.Column="9" Grid.Row="3" Content="确认" Style="{StaticResource btnFunc}"/> | |||
</Grid> | |||
</Grid> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,74 @@ | |||
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.CustomResource.UserControls | |||
{ | |||
/// <summary> | |||
/// UserKeyBoard.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class UserKeyBoard : UserControl | |||
{ | |||
public Action<object> MyKeyDown; | |||
public UserKeyBoard() | |||
{ | |||
InitializeComponent(); | |||
} | |||
//通过判断按钮的content属性来做对应处理 | |||
private void ButtonGrid_Click(object sender, RoutedEventArgs e) | |||
{ | |||
Button clickedButton = (Button)e.OriginalSource; //获取click事件触发源,即按了的按钮 | |||
switch((String)clickedButton.Content) | |||
{ | |||
case "DEL": | |||
MyKeyDown(EKeyitem.DEL); | |||
break; | |||
case "AC": | |||
MyKeyDown(EKeyitem.AC); | |||
break; | |||
case "确认": | |||
MyKeyDown(EKeyitem.OK); | |||
break; | |||
case "A/a": | |||
UIElementCollection grd = ButtonGrid.Children; | |||
int count = grd.Count; | |||
for (int i = 0; i < count; i++) | |||
{ | |||
Button buttonTemp = grd[i] as Button; | |||
String contentTemp = buttonTemp.Content as String; | |||
if (contentTemp == "AC" || contentTemp == "A/a" || contentTemp == "确认" || contentTemp == "DEL") | |||
continue; | |||
buttonTemp.Content = contentTemp[0] > 90 ? contentTemp.ToUpper() : contentTemp.ToLower(); | |||
} | |||
break; | |||
default: | |||
MyKeyDown((String)clickedButton.Content); | |||
break; | |||
} | |||
} | |||
public enum EKeyitem | |||
{ | |||
DEL, | |||
AC, | |||
Shift, | |||
OK, | |||
A | |||
} | |||
} | |||
} |
@@ -2,10 +2,12 @@ | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<BaseOutputPath>bin\</BaseOutputPath> | |||
<DebugType>portable</DebugType> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.24" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.26" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -60,12 +60,13 @@ namespace BPASmartClient.Device | |||
List<DevStatus> StatusALL = new List<DevStatus>(); | |||
foreach (var item in status) | |||
{ | |||
string sta = string.Empty; | |||
string name = item.Key; | |||
string Ms = string.Empty; | |||
string id = string.Empty; | |||
if (item.Key.Contains(".")) | |||
{ | |||
string sta = item.Key.Split('.')[0]; | |||
sta = item.Key.Split('.')[0]; | |||
string sop = item.Key.Split('.')[item.Key.Split('.').Length - 1]; name = sop; | |||
string value = item.Value.ToString(); | |||
if (keyValues.ContainsKey(sta)) sta = keyValues[sta]; | |||
@@ -75,8 +76,9 @@ namespace BPASmartClient.Device | |||
Ms = $"[{sta}]-[{sop}]-[{value}]"; | |||
id = $"[{sta}]-[{sop}]"; | |||
} | |||
StatusALL.Add(new DevStatus { id = id, Name = name, Status = item.Value.ToString(), Ms = Ms }); | |||
StatusALL.Add(new DevStatus { id = id, Name = name, type = sta, Status = item.Value.ToString(), Ms = Ms }); | |||
} | |||
StatusALL = StatusALL?.OrderBy(x => x.type).ToList(); | |||
return new { data = StatusALL }; | |||
} | |||
@@ -88,9 +90,10 @@ namespace BPASmartClient.Device | |||
string name = item.Key; | |||
string Ms = string.Empty; | |||
string id=string.Empty; | |||
string sta=string.Empty; | |||
if (item.Key.Contains(".")) | |||
{ | |||
string sta = item.Key.Split('.')[0]; | |||
sta = item.Key.Split('.')[0]; | |||
string sop = item.Key.Split('.')[item.Key.Split('.').Length - 1]; name = sop; | |||
string value = item.Value.ToString(); | |||
if (keyValues.ContainsKey(sta)) sta = keyValues[sta]; | |||
@@ -100,14 +103,16 @@ namespace BPASmartClient.Device | |||
Ms = $"[{sta}]-[{sop}]-[{value}]"; | |||
id= $"[{sta}]-[{sop}]"; | |||
} | |||
StatusALL.Add(new DevStatus {id= id, Name = name, Status = item.Value.ToString(), Ms = Ms }); | |||
StatusALL.Add(new DevStatus {id= id, Name = name,type=sta, Status = item.Value.ToString(), Ms = Ms }); | |||
} | |||
StatusALL = StatusALL?.OrderBy(x => x.type).ToList(); | |||
return StatusALL; | |||
} | |||
} | |||
public class DevStatus | |||
{ | |||
public string type { get; set; } | |||
public string id { get; set; } | |||
public string Name { get; set; } | |||
private string _status { get; set; } | |||
@@ -0,0 +1,80 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Helper | |||
{ | |||
/// <summary> | |||
/// 创建AES加密解密 add fyf 20211122 | |||
/// </summary> | |||
public class AESHelper | |||
{ | |||
/// <summary> | |||
/// 默认密钥-密钥的长度必须是32 | |||
/// </summary> | |||
private const string PublicKey = "9848461354184618"; | |||
/// <summary> | |||
/// 默认向量 | |||
/// </summary> | |||
private const string Iv = "dfkladnasldnfdcv"; | |||
/// <summary> | |||
/// AES加密 | |||
/// </summary> | |||
/// <param name="str">需要加密字符串</param> | |||
/// <returns>加密后字符串</returns> | |||
public static String Encrypt(string str) | |||
{ | |||
return Encrypt(str, PublicKey); | |||
} | |||
/// <summary> | |||
/// AES解密 | |||
/// </summary> | |||
/// <param name="str">需要解密字符串</param> | |||
/// <returns>解密后字符串</returns> | |||
public static String Decrypt(string str) | |||
{ | |||
return Decrypt(str, PublicKey); | |||
} | |||
/// <summary> | |||
/// AES加密 | |||
/// </summary> | |||
/// <param name="str">需要加密的字符串</param> | |||
/// <param name="key">32位密钥</param> | |||
/// <returns>加密后的字符串</returns> | |||
public static string Encrypt(string str, string key) | |||
{ | |||
Byte[] keyArray = System.Text.Encoding.UTF8.GetBytes(key); | |||
Byte[] toEncryptArray = System.Text.Encoding.UTF8.GetBytes(str); | |||
var rijndael = new System.Security.Cryptography.RijndaelManaged(); | |||
rijndael.Key = keyArray; | |||
rijndael.Mode = System.Security.Cryptography.CipherMode.ECB; | |||
rijndael.Padding = System.Security.Cryptography.PaddingMode.PKCS7; | |||
rijndael.IV = System.Text.Encoding.UTF8.GetBytes(Iv); | |||
System.Security.Cryptography.ICryptoTransform cTransform = rijndael.CreateEncryptor(); | |||
Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); | |||
return Convert.ToBase64String(resultArray, 0, resultArray.Length); | |||
} | |||
/// <summary> | |||
/// AES解密 | |||
/// </summary> | |||
/// <param name="str">需要解密的字符串</param> | |||
/// <param name="key">32位密钥</param> | |||
/// <returns>解密后的字符串</returns> | |||
public static string Decrypt(string str, string key) | |||
{ | |||
Byte[] keyArray = System.Text.Encoding.UTF8.GetBytes(key); | |||
Byte[] toEncryptArray = Convert.FromBase64String(str); | |||
var rijndael = new System.Security.Cryptography.RijndaelManaged(); | |||
rijndael.Key = keyArray; | |||
rijndael.Mode = System.Security.Cryptography.CipherMode.ECB; | |||
rijndael.Padding = System.Security.Cryptography.PaddingMode.PKCS7; | |||
rijndael.IV = System.Text.Encoding.UTF8.GetBytes(Iv); | |||
System.Security.Cryptography.ICryptoTransform cTransform = rijndael.CreateDecryptor(); | |||
Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); | |||
return System.Text.Encoding.UTF8.GetString(resultArray); | |||
} | |||
} | |||
} |
@@ -72,13 +72,13 @@ namespace BPASmartClient.Helper | |||
if (actions.ContainsKey(key)) | |||
if (par == null) | |||
{ | |||
if (actions[key].FuncObj != null) | |||
return actions[key].FuncObj; | |||
//if (actions[key].FuncObj != null) | |||
return actions[key].FuncObj?.Invoke(); | |||
} | |||
else | |||
{ | |||
if (actions[key].FuncPar != null) | |||
return actions[key].FuncPar(par); | |||
//if (actions[key].FuncPar != null) | |||
return actions[key].FuncPar?.Invoke(par); | |||
} | |||
return default; | |||
} | |||
@@ -41,11 +41,13 @@ namespace BPASmartClient.Helper | |||
/// <param name="callback">委托回调</param> | |||
public static void Invoke(this Action action, Action callback) | |||
{ | |||
if (action != null) | |||
{ | |||
action(); | |||
if (callback != null) callback(); | |||
} | |||
action?.Invoke(); | |||
callback?.Invoke(); | |||
//if (action != null) | |||
//{ | |||
// action(); | |||
// if (callback != null) callback(); | |||
//} | |||
} | |||
/// <summary> | |||
@@ -56,20 +58,24 @@ namespace BPASmartClient.Helper | |||
/// <param name="callback">委托回调</param> | |||
public static void Invoke(this Action<object> action, object par, Action callback) | |||
{ | |||
if (action != null) | |||
{ | |||
action(par); | |||
if (callback != null) callback(); | |||
} | |||
action?.Invoke(par); | |||
callback?.Invoke(); | |||
//if (action != null) | |||
//{ | |||
// action(par); | |||
// if (callback != null) callback(); | |||
//} | |||
} | |||
public static void Invokes(this Action<object[]> action, object[] par, Action callback) | |||
{ | |||
if (action != null) | |||
{ | |||
action(par); | |||
if (callback != null) callback(); | |||
} | |||
action?.Invoke(par); | |||
callback?.Invoke(); | |||
//if (action != null) | |||
//{ | |||
// action(par); | |||
// if (callback != null) callback(); | |||
//} | |||
} | |||
@@ -7,10 +7,8 @@ using System.Threading.Tasks; | |||
namespace BPASmartClient.Helper | |||
{ | |||
public class LocaPath:Singleton<LocaPath> | |||
public class LocaPath : Singleton<LocaPath> | |||
{ | |||
public string FilePath { get; set; } = string.Empty; | |||
public string Getpath(string name) | |||
@@ -19,5 +17,14 @@ namespace BPASmartClient.Helper | |||
return $"{AppDomain.CurrentDomain.BaseDirectory}{FilePath}JSON\\{name}.json"; | |||
} | |||
public string GetDeviceConfigPath | |||
{ | |||
get | |||
{ | |||
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DeviceConfig")); | |||
return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\DeviceConfig\\"; | |||
} | |||
} | |||
} | |||
} |
@@ -69,7 +69,7 @@ namespace BPASmartClient.Lebai | |||
public const int SENCE_放冰淇淋位置 = 10043; | |||
//add 新加场景 | |||
public const int SENCE_接咖啡_新 = 10051; | |||
public const int SENCE_接咖啡后回原点 = 10051; | |||
public const int SENCE_咖啡杯回原点 = 10050; | |||
public const int SENCE_冰淇淋杯回原点 = 10049; | |||
public const int SENCE_取咖啡出餐 = 10052; | |||
@@ -5,7 +5,7 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.MQTTClient" Version="1.0.10" /> | |||
<PackageReference Include="BPA.MQTTClient" Version="1.0.11" /> | |||
<PackageReference Include="BPA.MQTTnet" Version="1.0.3" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> | |||
</ItemGroup> | |||
@@ -452,44 +452,6 @@ namespace BPASmartClient.Modbus | |||
master.WriteSingleRegister(slaveAddress, startAddress, value); | |||
} | |||
#endregion | |||
} | |||
public enum ReadType | |||
{ | |||
/// <summary> | |||
/// 读线圈 | |||
/// </summary> | |||
Coils, | |||
/// <summary> | |||
/// 读输入线圈 | |||
/// </summary> | |||
Inputs, | |||
/// <summary> | |||
/// 读保持寄存器 | |||
/// </summary> | |||
HoldingRegisters, | |||
/// <summary> | |||
/// 读输入寄存器 | |||
/// </summary> | |||
InputRegisters, | |||
} | |||
public enum WriteType | |||
{ | |||
/// <summary> | |||
/// 写线圈 | |||
/// </summary> | |||
Coils, | |||
/// <summary> | |||
/// 写保持寄存器 | |||
/// </summary> | |||
HoldingRegisters, | |||
} | |||
public enum CommandType | |||
@@ -15,7 +15,7 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.24" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.26" /> | |||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||
</ItemGroup> | |||
@@ -10,7 +10,7 @@ namespace BPASmartClient.Model | |||
/// <summary> | |||
/// 订单状态改变事件 | |||
/// </summary> | |||
public class OrderStatusChangedEvent:BaseEvent | |||
public class OrderStatusChangedEvent : BaseEvent | |||
{ | |||
/// <summary> | |||
/// 子订单ID | |||
@@ -20,5 +20,10 @@ namespace BPASmartClient.Model | |||
/// 状态 | |||
/// </summary> | |||
public ORDER_STATUS Status { get; set; } | |||
/// <summary> | |||
/// 商品名称 | |||
/// </summary> | |||
public string GoodName { get; set; } | |||
} | |||
} |
@@ -2,6 +2,8 @@ | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<BaseOutputPath>bin\</BaseOutputPath> | |||
<DebugType>portable</DebugType> | |||
</PropertyGroup> | |||
</Project> |
@@ -4,6 +4,8 @@ | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
<BaseOutputPath>bin\</BaseOutputPath> | |||
<DebugType>portable</DebugType> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
@@ -2,6 +2,8 @@ | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<BaseOutputPath>bin\</BaseOutputPath> | |||
<DebugType>portable</DebugType> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
@@ -17,7 +17,7 @@ using System.Reflection; | |||
namespace BPASmartClient.MorkS | |||
{ | |||
public class Control : BaseDevice | |||
public class Control_Morks : BaseDevice | |||
{ | |||
public override DeviceClientType DeviceType => DeviceClientType.MORKS; | |||
GVL_MORKS mORKS = new GVL_MORKS(); | |||
@@ -223,16 +223,19 @@ namespace BPASmartClient.MorkS | |||
mORKS.AllowRun = mORKS.InitComplete; | |||
//IsHealth = mORKS.Error && mORKS.InitComplete; | |||
IsHealth = true; | |||
TakeBowlTask(); | |||
TakeNoodleTask(); | |||
if (mORKS.AllowRun) | |||
{ | |||
TakeBowlTask(); | |||
OutNoodleTask(); | |||
TakeNoodleTask(); | |||
SingleDetect(); | |||
OutNoodleTask(); | |||
TurntableControl(); | |||
SingleDetect(); | |||
TurntableControl(); | |||
} | |||
} | |||
@@ -245,11 +248,39 @@ namespace BPASmartClient.MorkS | |||
{ | |||
if (mORKS.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo)) | |||
{ | |||
mORKS.TakeBowlId = orderLocInfo.SuborderId; | |||
TakeBowlControl(orderLocInfo.Loc); | |||
SetRecipeNumber(orderLocInfo.RecipeNumber); | |||
OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING); | |||
DeviceProcessLogShow($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]"); | |||
ushort BowLoc = 0; | |||
var res = orderMaterialDelivery?.BatchingInfo?.Where(p => p.BatchingId == orderLocInfo.BatchingId).ToList(); | |||
if (res != null) | |||
{ | |||
foreach (var item in res) | |||
{ | |||
if (ushort.TryParse(item.BatchingLoc, out ushort loc)) | |||
{ | |||
if (loc == 10 && alarm.Supply1_LossBowl) | |||
{ | |||
BowLoc = loc; | |||
break; | |||
} | |||
else if (loc == 11 && alarm.Supply2_LossBowl) | |||
{ | |||
BowLoc = loc; | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
if (BowLoc >= 10 && BowLoc <= 11) | |||
{ | |||
mORKS.TakeBowlId = orderLocInfo.SuborderId; | |||
//TakeBowlControl(orderLocInfo.Loc); | |||
TakeBowlControl(BowLoc); | |||
SetRecipeNumber(orderLocInfo.RecipeNumber); | |||
OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING); | |||
DeviceProcessLogShow($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]"); | |||
} | |||
} | |||
mORKS.TakeBowlInterlock = true; | |||
} |
@@ -2,10 +2,12 @@ | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<BaseOutputPath>D:\HBL\Porgram\BPASmartClient\BPASmartClient\bin\Debug\net6.0-windows\Devices</BaseOutputPath> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Lebai\BPASmartClient.Lebai.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" /> | |||
</ItemGroup> | |||
@@ -1,13 +1,19 @@ | |||
using BPASmartClient.Device; | |||
using BPA.Message.Enum; | |||
using BPASmartClient.Device; | |||
using BPASmartClient.EventBus; | |||
using BPASmartClient.GSIceCream; | |||
using BPASmartClient.Lebai; | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Model.冰淇淋.Enum; | |||
using BPASmartClient.Model.单片机; | |||
using BPASmartClient.Model.单片机.Enum; | |||
using BPASmartClient.Peripheral; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using static BPASmartClient.EventBus.EventBus; | |||
@@ -15,12 +21,11 @@ namespace BPASmartClient.MorkT | |||
{ | |||
public class Control_MorkT : BaseDevice | |||
{ | |||
public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKIC; } } | |||
public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKT; } } | |||
GLV_MorkT morkT = new GLV_MorkT(); | |||
public override void DoMain() | |||
{ | |||
ServerInit(); | |||
@@ -30,7 +35,7 @@ namespace BPASmartClient.MorkT | |||
if (morkT.MakeCoffeeOrder != null) | |||
morkT.MakeCoffeeOrder.OrderStatus = 1; | |||
}); | |||
MessageLog.GetInstance.Show("MORKF 设备初始化完成"); | |||
MessageLog.GetInstance.Show("MORKT 设备初始化完成"); | |||
} | |||
public override void ResetProgram() | |||
@@ -41,6 +46,12 @@ namespace BPASmartClient.MorkT | |||
public override void MainTask() | |||
{ | |||
MakeCoffeeProcess(); | |||
if(!LebaiRobot.GetInstance.GetInput())//取餐口有空余位置 | |||
{ | |||
MakeIceCreamProcess(); | |||
MakeCoffeeComplete(); | |||
} | |||
} | |||
public override void ReadData() | |||
@@ -49,7 +60,7 @@ namespace BPASmartClient.MorkT | |||
LebaiRobot.GetInstance.GetRobotModeStatus(); | |||
} | |||
public override void Stop() | |||
{ | |||
@@ -108,7 +119,7 @@ namespace BPASmartClient.MorkT | |||
//获取当前物料所属商品类型 | |||
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc); | |||
} | |||
//获取主料和容器位置 | |||
if (morkT.batchings[res.BatchingLoc].BatchingClass == BATCHING_CLASS.MAIN_MATERIAL) loc_Goods = res.BatchingLoc; | |||
@@ -121,8 +132,10 @@ namespace BPASmartClient.MorkT | |||
{ | |||
SuborderId = order.MorkOrder.SuborderId, | |||
BatchingId = res.BatchingId, | |||
Loc = loc_Goods | |||
}); | |||
Loc = loc_Goods, | |||
GoodsName = order.MorkOrder.GoodsName, | |||
SortNum = order.MorkOrder.SortNum | |||
}) ; | |||
} | |||
break; | |||
case GOODS_TYPE.ICECREAM: | |||
@@ -132,7 +145,9 @@ namespace BPASmartClient.MorkT | |||
{ | |||
SuborderId = order.MorkOrder.SuborderId, | |||
BatchingId = res.BatchingId, | |||
Loc = loc_Goods | |||
Loc = loc_Goods, | |||
GoodsName = order.MorkOrder.GoodsName, | |||
SortNum = order.MorkOrder.SortNum | |||
}); | |||
} | |||
break; | |||
@@ -159,6 +174,308 @@ namespace BPASmartClient.MorkT | |||
} | |||
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); | |||
} | |||
private void Wait(int value = 101) | |||
{ | |||
while (!(morkT.lebai.Ok && morkT.lebai.Value == value)) | |||
{ | |||
Thread.Sleep(5); | |||
} | |||
} | |||
/// <summary> | |||
/// 是否可以开始制作咖啡 | |||
/// </summary> | |||
/// <returns></returns> | |||
private bool CoffeeCanMake() | |||
{ | |||
bool canMake = (IsHealth && morkT.morkOrderPushesCoffee.Count > 0 && !morkT.IsCoffeeMake) ? true : false; | |||
return canMake; | |||
} | |||
/// <summary> | |||
/// 制作咖啡流程 | |||
/// </summary> | |||
private void MakeCoffeeProcess() | |||
{ | |||
if (CoffeeCanMake()) | |||
{ | |||
if (morkT.morkOrderPushesCoffee.TryDequeue(out OrderLocInfo orderLoc)) | |||
{ | |||
DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]"); | |||
GetAndCheeckCoffe(orderLoc); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接咖啡后回原点);//把咖啡杯放到咖啡机机的位置后回原点 | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
new DRCoffee_MakeCoffeeEvent() { DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) }.Publish(); //接咖啡控制 | |||
DeviceProcessLogShow($"发送咖啡机制作{orderLoc.Loc}!"); | |||
morkT.IsCoffeeMake = true; morkT.MakeCoffeeOrder = orderLoc; | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 咖啡机制作完咖啡,取走并放到取餐口,最后回原点 | |||
/// </summary> | |||
private void MakeCoffeeComplete() | |||
{ | |||
if (morkT.IsCoffeeMake && IsHealth) | |||
{ | |||
if (morkT.MakeCoffeeOrder != null && morkT.MakeCoffeeOrder.OrderStatus == 1) | |||
{ | |||
DeviceProcessLogShow($"将咖啡移动到取餐位 [咖啡] 订单[{morkT.MakeCoffeeOrder.SortNum}]"); | |||
DoCoffeeQC(morkT.MakeCoffeeOrder); | |||
morkT.MakeCoffeeOrder = null; | |||
morkT.IsCoffeeMake = false; | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 将咖啡杯从咖啡机 取走到 取餐口 | |||
/// </summary> | |||
private void DoCoffeeQC(OrderLocInfo order) | |||
{ | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡出餐); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
//订单状态改变:完成 | |||
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); | |||
DeviceProcessLogShow($"{order.GoodsName}等待取餐"); | |||
//WaitTakeMealOrder.Enqueue(order); | |||
} | |||
/// <summary> | |||
/// 取咖啡杯&&咖啡杯检测 若检测失败机器人回原点 | |||
/// </summary> | |||
/// <param name="order"></param> | |||
private void GetAndCheeckCoffe(OrderLocInfo order) | |||
{ | |||
LebaiRobot.GetInstance.SetValue(0); | |||
OrderChange(order.SuborderId, ORDER_STATUS.COOKING); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡杯); | |||
Wait(); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制 | |||
Thread.Sleep(500); | |||
DeviceProcessLogShow("尝试取咖啡杯!"); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
int count = 2; | |||
p: | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯检测); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
if (!LebaiRobot.GetInstance.GetInput()) | |||
{ | |||
if (count >= 3) | |||
{ | |||
//退出循环回到初始位置 | |||
DeviceProcessLogShow($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯回原点); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
return; | |||
} | |||
DeviceProcessLogShow("执行二次取咖啡杯"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取咖啡杯); | |||
Wait(); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制 | |||
LebaiRobot.GetInstance.SetValue(1); | |||
count++; | |||
goto p; | |||
} | |||
DeviceProcessLogShow("取咖啡杯完成"); | |||
} | |||
/// <summary> | |||
/// 冰淇淋是否可以开始制作 | |||
/// </summary> | |||
/// <returns></returns> | |||
private bool IceCreamCanMake() | |||
{ | |||
bool canMake = (IsHealth && morkT.morkOrderPushesIceCream.Count > 0) ? true : false; | |||
return canMake; | |||
} | |||
/// <summary> | |||
/// 制作冰淇淋流程 | |||
/// </summary> | |||
private void MakeIceCreamProcess() | |||
{ | |||
if (IceCreamCanMake()) | |||
{ | |||
if (MorkIStatus.GetInstance().CurrentMode != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
if (MorkIStatus.GetInstance().CXB >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 | |||
{ | |||
if (LebaiRobot.GetInstance.GetInput(3)) | |||
{ | |||
if (morkT.IceIsOK) DeviceProcessLogShow("请检查冰淇淋出料口有无遮挡"); | |||
morkT.IceIsOK = false; | |||
} | |||
else if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order)) | |||
{ | |||
morkT.IceIsOK = true; | |||
DeviceProcessLogShow($"开始制作 [冰淇淋] 订单[{order.SortNum}]"); | |||
DoIceCream(order); | |||
} | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 做冰淇淋 | |||
/// </summary> | |||
private void DoIceCream(OrderLocInfo order) | |||
{ | |||
GetIceCreamCup(); | |||
CheckICeCreaCup(); | |||
GetIceCream(order); | |||
PutIceCream(order); | |||
} | |||
/// <summary> | |||
/// 取冰淇淋杯 | |||
/// </summary> | |||
private void GetIceCreamCup() | |||
{ | |||
LebaiRobot.GetInstance.SetValue(0); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取冰淇淋杯); | |||
Wait(); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制 | |||
Thread.Sleep(500); | |||
DeviceProcessLogShow("尝试取冰淇淋杯!"); | |||
} | |||
/// <summary> | |||
/// 冰淇淋杯检测,失败后机器人回到原点 | |||
/// </summary> | |||
private void CheckICeCreaCup() | |||
{ | |||
int count = 2; | |||
LebaiRobot.GetInstance.SetValue(1); | |||
p: | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯检测); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
if (!LebaiRobot.GetInstance.GetInput()) | |||
{ | |||
if (count >= 3) | |||
{ | |||
//退出循环回到初始位置 | |||
DeviceProcessLogShow($"执行{count}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯回原点); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
return; | |||
} | |||
DeviceProcessLogShow($"执行{count}次取冰淇淋杯!"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取冰淇淋杯); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制 | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
count++; | |||
goto p; | |||
} | |||
DeviceProcessLogShow("冰淇淋杯检测完成"); | |||
} | |||
/// <summary> | |||
/// 机器人取接冰淇淋 | |||
/// </summary> | |||
/// <param name="order"></param> | |||
private void GetIceCream(OrderLocInfo order) | |||
{ | |||
//制冷模式 | |||
new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
LebaiRobot.GetInstance.SetValue(0); | |||
OrderChange(order.SuborderId, ORDER_STATUS.COOKING); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接1号冰淇淋); | |||
Wait(); | |||
bool doItResult = true; | |||
//出料 | |||
new GSIceCream_DischargeEvent().Publish(delegate (object[] args) | |||
{ | |||
doItResult = (bool)args[0]; | |||
}); | |||
if (doItResult) | |||
{ | |||
IceCreamCookCheck(); | |||
} | |||
else | |||
{ | |||
int count_1 = 0; | |||
while (MorkIStatus.GetInstance().CXB <= 86) | |||
{ | |||
Thread.Sleep(5); | |||
count_1++; | |||
if (count_1 >= 2000) | |||
break; | |||
} | |||
IceCreamCookCheck(); | |||
} | |||
LebaiRobot.GetInstance.SetValue(1); | |||
} | |||
/// <summary> | |||
/// 把冰淇淋放到取餐位后回原点 | |||
/// </summary> | |||
/// <param name="order"></param> | |||
private void PutIceCream(OrderLocInfo order) | |||
{ | |||
while (LebaiRobot.GetInstance.GetInput()) | |||
{ | |||
Thread.Sleep(500); | |||
} | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_放冰淇淋位置); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
//订单状态改变:完成 | |||
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); | |||
DeviceProcessLogShow($"{order.GoodsName}等待取餐"); | |||
//WaitTakeMealOrder.Enqueue(order); | |||
} | |||
/// <summary> | |||
/// 冰淇淋机器制作冰淇淋 | |||
/// </summary> | |||
public void IceCreamCookCheck() | |||
{ | |||
int retry = 3; | |||
DateTime beginTime = DateTime.Now; | |||
while (!LebaiRobot.GetInstance.GetInput(3)) | |||
{ | |||
if (retry <= 0 && DateTime.Now.Subtract(beginTime).TotalSeconds >= 10) | |||
{ | |||
DeviceProcessLogShow("超时未出料,重试次数用尽"); | |||
break; | |||
} | |||
if (DateTime.Now.Subtract(beginTime).TotalSeconds > 5) | |||
{ | |||
DeviceProcessLogShow("超时未出料,重新发送打料指令"); | |||
new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.打料 }.Publish(); | |||
beginTime = DateTime.Now; | |||
retry--; | |||
} | |||
Thread.Sleep(10); | |||
} | |||
DeviceProcessLogShow("开始等待6s"); | |||
Thread.Sleep(5000); | |||
} | |||
} | |||
} |
@@ -33,5 +33,14 @@ namespace BPASmartClient.MorkT | |||
/// 获取乐百机器人的数据 | |||
/// </summary> | |||
public SignalResult lebai = new SignalResult(); | |||
/// <summary> | |||
/// 咖啡机位置是否有咖啡在制作中 | |||
/// </summary> | |||
public bool IsCoffeeMake = false; | |||
/// <summary> | |||
/// 冰淇淋机器出料口传感器检测 | |||
/// </summary> | |||
public bool IceIsOK = true; | |||
} | |||
} |
@@ -9,11 +9,14 @@ namespace BPASmartClient.MorkT | |||
public class OrderLocInfo | |||
{ | |||
public string SuborderId { get; set; } | |||
public string GoodsName { get; set; } | |||
public string Loc { get; set; } | |||
public ushort RecipeNumber { get; set; } | |||
public int SortNum { get; set; } | |||
public int BatchingId { get; set; } | |||
public int OrderStatus { get; set; } | |||
public OrderLocInfo() | |||
{ | |||
OrderStatus = 0; | |||
@@ -0,0 +1,35 @@ | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.ViewModel | |||
{ | |||
public class AdminstratorsViewModel:ObservableObject | |||
{ | |||
public string Admin { get { return _admin; } set { _admin = value; OnPropertyChanged(); } } | |||
private string _admin; | |||
public string Password { get { return _password; } set { _password = value; OnPropertyChanged(); } } | |||
private string _password; | |||
public string ErrorMessage { get { return _errorMessage; } set { _errorMessage = value; OnPropertyChanged(); } } | |||
private string _errorMessage; | |||
public RelayCommand AdminLoginCommand { get; set; } | |||
public AdminstratorsViewModel() | |||
{ | |||
AdminLoginCommand = new RelayCommand(() => | |||
{ | |||
ActionManage.GetInstance.Send("Lonin"); | |||
}); | |||
} | |||
} | |||
} |
@@ -8,6 +8,8 @@ | |||
<ItemGroup> | |||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | |||
<PackageReference Include="System.IO.Ports" Version="6.0.0" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -132,7 +132,7 @@ namespace BPASmartClient.ViewModel | |||
BookExs.Add(new BookEx(new Book() { Name = "错误日志条件", Tag = "Error" }) { IsChecked = true }); | |||
BookExs.Add(new BookEx(new Book() { Name = "设备告警条件", Tag = "DeviceAlarm" }) { IsChecked = true }); | |||
SelectBookExs = new ObservableCollection<BookEx>(); | |||
ItemPropertyChanged(new BookEx(new Book() { Name = "一般日志条件", Tag = "Info" }) { IsChecked = true },new PropertyChangedEventArgs("IsChecked")); | |||
ItemPropertyChanged(new BookEx(new Book()) { IsChecked = true },new PropertyChangedEventArgs("IsChecked")); | |||
//查询 | |||
QueryCommand = new RelayCommand(() => | |||
{ | |||
@@ -1,12 +1,14 @@ | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.IoT; | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Model; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using Microsoft.Win32; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.ComponentModel; | |||
using System.Diagnostics; | |||
using System.IO; | |||
using System.Linq; | |||
@@ -26,6 +28,7 @@ namespace BPASmartClient.ViewModel | |||
#region 变量 | |||
public DispatcherTimer dispatcherTimer; | |||
public string ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString(); | |||
public ObservableCollection<LogModel> LogDataGridData { get; set; } | |||
private ObservableCollection<LogModel> _LogModels;public ObservableCollection<LogModel> LogDataGrid | |||
{ | |||
get | |||
@@ -68,6 +71,54 @@ namespace BPASmartClient.ViewModel | |||
OnPropertyChanged("TimedClear"); | |||
} | |||
} | |||
private string _SelectedText = ""; | |||
public string SelectedText | |||
{ | |||
get | |||
{ | |||
return _SelectedText; | |||
} | |||
set | |||
{ | |||
if (_SelectedText == value) | |||
return; | |||
_SelectedText = value; | |||
OnPropertyChanged("SelectedText"); | |||
} | |||
} | |||
public ObservableCollection<BookEx> SelectBookExs { set; get; } | |||
private ObservableCollection<BookEx> _books; | |||
public ObservableCollection<BookEx> BookExs | |||
{ | |||
get | |||
{ | |||
if (_books == null) | |||
{ | |||
_books = new ObservableCollection<BookEx>(); | |||
_books.CollectionChanged += (sender, e) => | |||
{ | |||
if (e.OldItems != null) | |||
{ | |||
foreach (BookEx bookEx in e.OldItems) | |||
{ | |||
bookEx.PropertyChanged -= ItemPropertyChanged; | |||
} | |||
} | |||
if (e.NewItems != null) | |||
{ | |||
foreach (BookEx bookEx in e.NewItems) | |||
{ | |||
bookEx.PropertyChanged += ItemPropertyChanged; | |||
} | |||
} | |||
}; | |||
} | |||
return _books; | |||
} | |||
} | |||
#endregion | |||
#region 单一 | |||
@@ -85,14 +136,23 @@ namespace BPASmartClient.ViewModel | |||
/// </summary> | |||
public void Init() | |||
{ | |||
if (LogDataGrid == null) LogDataGrid = new ObservableCollection<LogModel>(); | |||
logHelper.Fun_InitLog(System.AppDomain.CurrentDomain.BaseDirectory); | |||
if (LogDataGrid == null) LogDataGrid = new ObservableCollection<LogModel>(); | |||
if (LogDataGridData == null) LogDataGridData = new ObservableCollection<LogModel>(); | |||
BookExs.Add(new BookEx(new Book() { Name = "一般日志", Tag = "Info" }) { IsChecked = true }); | |||
BookExs.Add(new BookEx(new Book() { Name = "设备日志", Tag = "DeviceLog" }) { IsChecked = true }); | |||
BookExs.Add(new BookEx(new Book() { Name = "错误日志", Tag = "Error" }) { IsChecked = true }); | |||
BookExs.Add(new BookEx(new Book() { Name = "告警日志", Tag = "DeviceAlarm" }) { IsChecked = true }); | |||
SelectBookExs = new ObservableCollection<BookEx>(); | |||
ItemPropertyChanged(new BookEx(new Book()) { IsChecked = true }, new PropertyChangedEventArgs("IsChecked")); | |||
//一般日志 | |||
MessageLog.GetInstance.InfoNotify = new Action<string>((s) => | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
LogDataGrid.Insert(0, new LogModel { message = s, type = "Info" }); | |||
LogModel logModel = new LogModel { message = s, type = "Info" }; | |||
LogDataGridData.Insert(0, logModel); | |||
AddLog(logModel); | |||
logHelper.GetLogConfigInstance().WriteLog(LogLevel.INFO, s); | |||
})); | |||
}); | |||
@@ -101,7 +161,9 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
LogDataGrid.Insert(0, new LogModel { message = s, type = "DeviceLog" }); | |||
LogModel logModel = new LogModel { message = s, type = "DeviceLog" }; | |||
LogDataGridData.Insert(0, logModel); | |||
AddLog(logModel); | |||
logHelper.GetLogConfigInstance().WriteLog(LogLevel.DEBUG, s); | |||
})); | |||
}); | |||
@@ -110,7 +172,9 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
LogDataGrid.Insert(0, new LogModel { message = id, type = "DeviceAlarm" }); | |||
LogModel logModel = new LogModel { message = id, type = "DeviceAlarm" }; | |||
LogDataGridData.Insert(0, logModel); | |||
AddLog(logModel); | |||
logHelper.GetLogConfigInstance().WriteLog(LogLevel.WARN, id); | |||
})); | |||
}); | |||
@@ -119,7 +183,9 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
LogDataGrid.Insert(0, new LogModel { message = s, type = "Error" }); | |||
LogModel logModel = new LogModel { message = s, type = "Error" }; | |||
LogDataGridData.Insert(0, logModel); | |||
AddLog(logModel); | |||
logHelper.GetLogConfigInstance().WriteLog(LogLevel.ERROR, s); | |||
DataVClient.GetInstance().HttpAddLog(new LogTable | |||
{ | |||
@@ -154,9 +220,11 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
if (LogDataGrid.Count > 100) | |||
if (LogDataGridData.Count > 200) | |||
{ | |||
LogDataGrid.RemoveAt(LogDataGrid.Count - 1); | |||
LogModel logModel= LogDataGridData.Last(); | |||
DeleteLog(logModel); | |||
LogDataGridData.Remove(logModel); | |||
} | |||
})); | |||
@@ -164,6 +232,43 @@ namespace BPASmartClient.ViewModel | |||
dispatcherTimer.Interval = TimeSpan.FromSeconds(10); | |||
dispatcherTimer.Start(); | |||
} | |||
/// <summary> | |||
/// 增加日志 | |||
/// </summary> | |||
public void AddLog(LogModel logModel) | |||
{ | |||
BookEx book= SelectBookExs?.ToList().Find(par => par.IsChecked && par.BookN.Tag == logModel.type); | |||
if (book != null) | |||
{ | |||
LogDataGrid.Insert(0, logModel); | |||
} | |||
} | |||
/// <summary> | |||
/// 刷新日志 | |||
/// </summary> | |||
/// <param name="logModel"></param> | |||
public void RefreshLog() | |||
{ | |||
LogDataGrid.Clear(); | |||
LogDataGridData?.ToList().ForEach(b => { | |||
BookEx book = SelectBookExs?.ToList().Find(par => par.IsChecked && par.BookN.Tag == b.type); | |||
if (book != null) | |||
{ | |||
LogDataGrid.Add(b); | |||
} | |||
}); | |||
} | |||
/// <summary> | |||
/// 删除日志 | |||
/// </summary> | |||
public void DeleteLog(LogModel logModel) | |||
{ | |||
LogModel log= LogDataGrid?.ToList().Find(par => par == logModel); | |||
if(log!=null) LogDataGrid.Remove(log); | |||
} | |||
/// <summary> | |||
/// 导出数据 | |||
/// </summary> | |||
@@ -210,6 +315,33 @@ namespace BPASmartClient.ViewModel | |||
System.Windows.MessageBox.Show("无数据!"); | |||
} | |||
/// <summary> | |||
/// 选中改变 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private void ItemPropertyChanged(object sender, PropertyChangedEventArgs e) | |||
{ | |||
if (e.PropertyName == "IsChecked") | |||
{ | |||
BookEx bookEx = sender as BookEx; | |||
if (bookEx != null) | |||
{ | |||
IEnumerable<BookEx> bookExs = BookExs.Where(b => b.IsChecked == true); | |||
StringBuilder builder = new StringBuilder(); | |||
SelectBookExs.Clear(); | |||
foreach (BookEx item in bookExs) | |||
{ | |||
builder.Append(item.BookN.Name.Replace("日志","") + ","); | |||
SelectBookExs.Add((BookEx)item); | |||
} | |||
SelectedText = builder == null ? string.Empty : builder.ToString(); | |||
RefreshLog(); | |||
} | |||
} | |||
} | |||
#endregion | |||
#region Command | |||
@@ -38,6 +38,12 @@ namespace BPASmartClient.ViewModel | |||
OnPropertyChanged("NetworkConnectState"); | |||
} | |||
} | |||
//状态隐藏 | |||
public Visibility VsMenuItem { get { return _vsMenuItem; } set { _vsMenuItem = value; OnPropertyChanged(); } } | |||
private Visibility _vsMenuItem; | |||
public RelayCommand LogoutCommand { get; set; } | |||
/// <summary> | |||
/// 是否告警 | |||
/// </summary> | |||
@@ -52,7 +58,7 @@ namespace BPASmartClient.ViewModel | |||
public MainViewModel() | |||
{ | |||
IsAlarm =new AlarmModel(); | |||
IsAlarm = new AlarmModel(); | |||
OrderStatusViewModel.Init(); | |||
//设备告警日志 | |||
MessageLog.GetInstance.AlarmLogNotify = new Action(() => | |||
@@ -74,7 +80,23 @@ namespace BPASmartClient.ViewModel | |||
}; | |||
dispatcherTimer.Interval = TimeSpan.FromSeconds(1); | |||
dispatcherTimer.Start(); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
VsMenuItem = Visibility.Hidden; | |||
}),"Lonin"); | |||
LogoutCommand = new RelayCommand(() => | |||
{ | |||
VsMenuItem = Visibility.Visible; | |||
}); | |||
} | |||
public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } } | |||
} | |||
public class AlarmModel : ObservableObject | |||
@@ -118,7 +140,7 @@ namespace BPASmartClient.ViewModel | |||
public AlarmModel() | |||
{ | |||
} | |||
} | |||
} |
@@ -5,6 +5,8 @@ using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.ObjectModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using System.Windows; | |||
namespace BPASmartClient.ViewModel.Model | |||
{ | |||
@@ -13,6 +15,7 @@ namespace BPASmartClient.ViewModel.Model | |||
/// </summary> | |||
public class DeviceConfigModel : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 店铺名称 | |||
/// </summary> | |||
@@ -28,7 +31,7 @@ namespace BPASmartClient.ViewModel.Model | |||
/// <summary> | |||
/// 设备集合 | |||
/// </summary> | |||
public ObservableCollection<DeviceModel> deviceModels = new ObservableCollection<DeviceModel>(); | |||
public ObservableCollection<DeviceModel> deviceModels { get; set; } = new ObservableCollection<DeviceModel>(); | |||
} | |||
/// <summary> | |||
@@ -48,6 +51,11 @@ namespace BPASmartClient.ViewModel.Model | |||
public string DeviceModule { get { return _mDeviceModule; } set { _mDeviceModule = value; OnPropertyChanged(); } } | |||
private string _mDeviceModule = string.Empty; | |||
public string Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } } | |||
private string _mId = string.Empty; | |||
/// <summary> | |||
/// 设备ID | |||
/// </summary> | |||
@@ -57,7 +65,7 @@ namespace BPASmartClient.ViewModel.Model | |||
/// <summary> | |||
/// 通讯模块 | |||
/// </summary> | |||
public ObservableCollection<CommunicationModel> communicationDevcies = new ObservableCollection<CommunicationModel>(); | |||
public ObservableCollection<CommunicationModel> communicationDevcies { get; set; } = new ObservableCollection<CommunicationModel>(); | |||
} | |||
@@ -72,6 +80,14 @@ namespace BPASmartClient.ViewModel.Model | |||
public string CommunicationModule { get { return _mCommunicationModule; } set { _mCommunicationModule = value; OnPropertyChanged(); } } | |||
private string _mCommunicationModule = string.Empty; | |||
public string CommunicationName { get { return _mCommunicationName; } set { _mCommunicationName = value; OnPropertyChanged(); } } | |||
private string _mCommunicationName = string.Empty; | |||
public string DeviceModelId { get { return _mDeviceModelId; } set { _mDeviceModelId = value; OnPropertyChanged(); } } | |||
private string _mDeviceModelId = string.Empty; | |||
public CommunicationPar communicationPar { get { return _mcommunicationPar; } set { _mcommunicationPar = value; OnPropertyChanged(); } } | |||
private CommunicationPar _mcommunicationPar = new CommunicationPar(); | |||
} | |||
@@ -81,44 +97,95 @@ namespace BPASmartClient.ViewModel.Model | |||
/// </summary> | |||
public class CommunicationPar : ObservableObject | |||
{ | |||
public CommunicationParType communicationType { get { return _mcommunicationType; } set { _mcommunicationType = value; OnPropertyChanged(); } } | |||
private CommunicationParType _mcommunicationType; | |||
///// <summary> | |||
///// 通讯类型,false:串口,true:网口 | |||
///// </summary> | |||
//public bool CommunicationType { get { return _mCommunicationType; } set { _mCommunicationType = value; OnPropertyChanged(); } } | |||
//private bool _mCommunicationType; | |||
/// <summary> | |||
/// 选择网口通讯 | |||
/// </summary> | |||
public bool IsNetworkPort { get { return _mIsNetworkPort; } set { _mIsNetworkPort = value; OnPropertyChanged(); } } | |||
private bool _mIsNetworkPort = false; | |||
public string CommunicationValue { get { return _mCommunicationValue; } set { _mCommunicationValue = value; OnPropertyChanged(); } } | |||
private string _mCommunicationValue = string.Empty; | |||
/// <summary> | |||
/// 选择串口通讯 | |||
/// </summary> | |||
public bool IsSerialPort { get { return _mIsSerialPort; } set { _mIsSerialPort = value; OnPropertyChanged(); } } | |||
private bool _mIsSerialPort = true; | |||
} | |||
//public Visibility NetworkVisibility { get { return _mNetworkVisibility; } set { _mNetworkVisibility = value; OnPropertyChanged(); } } | |||
//private Visibility _mNetworkVisibility = Visibility.Collapsed; | |||
//public Visibility SerialVisibility { get { return _mSerialVisibility; } set { _mSerialVisibility = value; OnPropertyChanged(); } } | |||
//private Visibility _mSerialVisibility = Visibility.Visible; | |||
public enum CommunicationParType | |||
{ | |||
/// <summary> | |||
/// IP地址 | |||
/// </summary> | |||
IPAddress, | |||
public string IPAddress { get { return _mIPAddress; } set { _mIPAddress = value; OnPropertyChanged(); } } | |||
private string _mIPAddress; | |||
/// <summary> | |||
/// 端口号 | |||
/// IP 端口号 | |||
/// </summary> | |||
Port, | |||
public int IPPort { get { return _mIPPort; } set { _mIPPort = value; OnPropertyChanged(); } } | |||
private int _mIPPort; | |||
/// <summary> | |||
/// 串口端口号 | |||
/// ip 串口 站号 | |||
/// </summary> | |||
SerialPort, | |||
public int StationNo { get { return _mStationNo; } set { _mStationNo = value; OnPropertyChanged(); } } | |||
private int _mStationNo; | |||
/// <summary> | |||
/// 串口单口号 | |||
/// </summary> | |||
public string SerialPort { get { return _mSerialPort; } set { _mSerialPort = value; OnPropertyChanged(); } } | |||
private string _mSerialPort; | |||
/// <summary> | |||
/// 波特率 | |||
/// </summary> | |||
BaudRate, | |||
public int BaudRate { get { return _mBaudRate; } set { _mBaudRate = value; OnPropertyChanged(); } } | |||
private int _mBaudRate; | |||
/// <summary> | |||
/// 数据位 | |||
/// </summary> | |||
DataBits, | |||
public int DataBits { get { return _mDataBits; } set { _mDataBits = value; OnPropertyChanged(); } } | |||
private int _mDataBits = 8; | |||
/// <summary> | |||
/// 停止位 | |||
/// </summary> | |||
StopBits, | |||
public string StopBits { get { return _mStopBits; } set { _mStopBits = value; OnPropertyChanged(); } } | |||
private string _mStopBits = "1"; | |||
/// <summary> | |||
/// 校验位 | |||
/// </summary> | |||
Parity, | |||
public string Parity { get { return _mParity; } set { _mParity = value; OnPropertyChanged(); } } | |||
private string _mParity; | |||
public ObservableCollection<Variable> variables { get; set; } = new ObservableCollection<Variable>(); | |||
} | |||
public class Variable : ObservableObject | |||
{ | |||
public int Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } } | |||
private int _mId; | |||
public string Address { get { return _mAddress; } set { _mAddress = value; OnPropertyChanged(); } } | |||
private string _mAddress; | |||
public int ReadLeng { get { return _mReadLeng; } set { _mReadLeng = value; OnPropertyChanged(); } } | |||
private int _mReadLeng; | |||
} | |||
} |
@@ -3,15 +3,52 @@ using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using Microsoft.Toolkit.Mvvm.Messaging; | |||
using System.Windows; | |||
using System.IO; | |||
namespace BPASmartClient.ViewModel | |||
{ | |||
public class NewShopWindowModel : ObservableObject | |||
{ | |||
public NewShopWindowModel() | |||
{ | |||
CancelCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("CloseWindow"); }); | |||
DefineCommand = new RelayCommand(() => | |||
{ | |||
DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath); | |||
var files = directoryInfo.GetFiles(); | |||
if (files != null && files.FirstOrDefault(p => p.FullName.Contains(ShopName)) != null) | |||
{ | |||
ErrorInfo = "已存在该店铺,请重新输入!"; | |||
return; | |||
} | |||
ActionManage.GetInstance.Send("ShopPar", new string[] { ShopName, ShopId }); | |||
ActionManage.GetInstance.Send("OkCloseWindow"); | |||
}); | |||
} | |||
//public RelayCommand CloseWindowCommand { get; set; } | |||
public RelayCommand CancelCommand { get; set; } | |||
public RelayCommand DefineCommand { get; set; } | |||
public string ShopName { get { return _mShopName; } set { _mShopName = value; OnPropertyChanged(); } } | |||
private string _mShopName; | |||
public string ShopId { get { return _mShopId; } set { _mShopId = value; OnPropertyChanged(); } } | |||
private string _mShopId; | |||
public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } | |||
private string _mErrorInfo; | |||
} | |||
} |
@@ -3,17 +3,238 @@ using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmartClient.ViewModel.Model; | |||
using System.Collections.ObjectModel; | |||
using System.ComponentModel; | |||
using System.Runtime.CompilerServices; | |||
using System.Windows; | |||
using System.IO.Ports; | |||
using System.IO; | |||
using Newtonsoft.Json; | |||
namespace BPASmartClient.ViewModel | |||
{ | |||
public class ShopDeviceConfigViewModel : ObservableObject | |||
{ | |||
private DeviceConfigModel configModel = new DeviceConfigModel(); | |||
string FileName => deviceConfig.Count > 0 ? deviceConfig[0].ShopName : string.Empty; | |||
public ShopDeviceConfigViewModel() | |||
{ | |||
//NewCommand = new Action(() => {ActionManager }); | |||
ActionManage.GetInstance.Register(new Action<object[]>((o) => | |||
{ | |||
if (o != null && o is string[] par) | |||
{ | |||
if (par.Length == 2) | |||
{ | |||
configModel.ShopName = par[0]; | |||
configModel.ShopId = par[1]; | |||
deviceConfig.Clear(); | |||
deviceConfig.Add(configModel); | |||
} | |||
} | |||
}), "ShopPar"); | |||
NewDeviceCommand = new RelayCommand<object>(NewDevice); | |||
RemoveDeviceCommand = new RelayCommand<object>(RemoveDevice); | |||
NewCommunicationCommand = new RelayCommand<object>(NewCommunication); | |||
RemoveCommunicationCommand = new RelayCommand<object>(RemoveCommunication); | |||
DataListInit(); | |||
SaveData = new Action(() => | |||
{ | |||
if (deviceConfig.Count > 0) | |||
{ | |||
File.WriteAllText($"{LocaPath.GetInstance().GetDeviceConfigPath}{FileName}.json", JsonConvert.SerializeObject(deviceConfig)); | |||
} | |||
}); | |||
} | |||
#region 右键菜单按钮操作 | |||
private void RemoveCommunication(object? obj) | |||
{ | |||
if (obj != null && obj is CommunicationModel com) | |||
{ | |||
if (com != null) | |||
{ | |||
int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.Id == com.DeviceModelId); | |||
if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count) | |||
{ | |||
var res = deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.FirstOrDefault(p => p.CommunicationName == com.CommunicationName); | |||
if (res != null) | |||
{ | |||
deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.Remove(res); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
private void NewCommunication(object? obj) | |||
{ | |||
if (obj != null && obj is DeviceModel dm) | |||
{ | |||
if (dm != null) | |||
{ | |||
string CommunicationName = string.Empty; | |||
int num = 1; | |||
while (true) | |||
{ | |||
int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.DeviceName == dm.DeviceName); | |||
if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count) | |||
{ | |||
var res = deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.FirstOrDefault(p => p.CommunicationName.Contains($"Communication_{num}")); | |||
if (res == null) | |||
{ | |||
deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.Add(new CommunicationModel() | |||
{ | |||
CommunicationName = $"Communication_{num}", | |||
DeviceModelId = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == dm.DeviceName)?.Id, | |||
communicationPar = new CommunicationPar() { IsNetworkPort = false } | |||
}); | |||
break; | |||
} | |||
} | |||
else break; | |||
num++; | |||
} | |||
} | |||
} | |||
} | |||
private void RemoveDevice(object? obj) | |||
{ | |||
if (obj != null && deviceConfig.Count == 1) | |||
{ | |||
string DeviceName = obj?.ToString(); | |||
var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == DeviceName); | |||
if (res != null) | |||
deviceConfig.ElementAt(0).deviceModels.Remove(res); | |||
} | |||
} | |||
private void NewDevice(object? obj) | |||
{ | |||
if (obj != null && deviceConfig.Count == 1) | |||
{ | |||
string DeviceName = string.Empty; | |||
int num = 1; | |||
while (true) | |||
{ | |||
var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == $"Device_{num}"); | |||
if (res == null) | |||
{ | |||
deviceConfig.ElementAt(0).deviceModels.Add(new DeviceModel() { DeviceId = "0", DeviceName = $"Device_{num}", Id = Guid.NewGuid().ToString() }); | |||
break; | |||
} | |||
num++; | |||
} | |||
} | |||
} | |||
#endregion | |||
#region Command | |||
/// <summary> | |||
/// 新建设备 | |||
/// </summary> | |||
public RelayCommand<object> NewDeviceCommand { get; set; } | |||
/// <summary> | |||
/// 删除设备 | |||
/// </summary> | |||
public RelayCommand<object> RemoveDeviceCommand { get; set; } | |||
/// <summary> | |||
/// 新建通讯 | |||
/// </summary> | |||
public RelayCommand<object> NewCommunicationCommand { get; set; } | |||
/// <summary> | |||
/// 删除通讯 | |||
/// </summary> | |||
public RelayCommand<object> RemoveCommunicationCommand { get; set; } | |||
public Action SaveData { get; set; } | |||
#endregion | |||
#region 列表集合 | |||
/// <summary> | |||
/// 设备信息列表 | |||
/// </summary> | |||
public static ObservableCollection<DeviceConfigModel> deviceConfig { get; set; } = new ObservableCollection<DeviceConfigModel>(); | |||
/// <summary> | |||
/// 端口号列表 | |||
/// </summary> | |||
public static ObservableCollection<string> Ports { get; set; } = new ObservableCollection<string>(); | |||
/// <summary> | |||
/// 波特率列表 | |||
/// </summary> | |||
public static ObservableCollection<int> BaudRates { get; set; } = new ObservableCollection<int>(); | |||
/// <summary> | |||
/// 奇偶校验列表 | |||
/// </summary> | |||
public static ObservableCollection<string> Paritys { get; set; } = new ObservableCollection<string>(); | |||
/// <summary> | |||
/// 设备模块 | |||
/// </summary> | |||
public static ObservableCollection<string> DeviceModels { get; set; } = new ObservableCollection<string>(); | |||
/// <summary> | |||
/// 通讯模块 | |||
/// </summary> | |||
public static ObservableCollection<string> CommunicationModel { get; set; } = new ObservableCollection<string>(); | |||
/// <summary> | |||
/// 店铺集合 | |||
/// </summary> | |||
public static ObservableCollection<string> Shops { get; set; } = new ObservableCollection<string>(); | |||
private void DataListInit() | |||
{ | |||
Ports.Clear(); | |||
SerialPort.GetPortNames().ToList().ForEach((item) => { Ports.Add(item); }); | |||
BaudRates.Clear(); | |||
int[] rb = new int[] { 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 43000, 57600, 76800, 115200 }; | |||
rb.ToList().ForEach((item) => { BaudRates.Add(item); }); | |||
Paritys.Clear(); | |||
Enum.GetNames(typeof(Parity)).ToList().ForEach((item) => { Paritys.Add(item); }); | |||
DeviceModels.Clear(); | |||
DeviceModels.Add("Morks"); | |||
DeviceModels.Add("Morkt"); | |||
DeviceModels.Add("Morkic"); | |||
DeviceModels.Add("Morkjc"); | |||
CommunicationModel.Clear(); | |||
CommunicationModel.Add("乐百"); | |||
CommunicationModel.Add("节卡"); | |||
CommunicationModel.Add("单片机"); | |||
CommunicationModel.Add("咖啡机"); | |||
CommunicationModel.Add("冰淇淋机"); | |||
Shops.Clear(); | |||
DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath); | |||
var files = directoryInfo.GetFiles(); | |||
foreach (var item in files) | |||
{ | |||
var res = Path.GetFileNameWithoutExtension(item.FullName); | |||
if (res != null && res.Length > 0 && item.FullName.Contains("json")) Shops.Add(res); | |||
} | |||
} | |||
#endregion | |||
public Action NewCommand { get; set; } | |||
} | |||
} |
@@ -3,7 +3,7 @@ | |||
<appSettings> | |||
<!--通用配置--> | |||
<!--1:且时且多冰淇淋咖啡机,2:且时且多煮面机,3:海科煮面机测试店铺--> | |||
<add key="ClientId" value="46"/> | |||
<add key="ClientId" value="777"/> | |||
<!--<add key="ApolloUri" value="http://10.2.1.21:28080"/> | |||
<add key="OrderServiceUri" value="http://10.2.1.26:21527/order/"/> | |||
<add key="StockServiceUri" value="http://10.2.1.26:21527/stock/"/>--> | |||
@@ -12,41 +12,49 @@ | |||
<!--<add key="ClientId" value="2"/>--> | |||
<!--开发环境--> | |||
<!--<add key="ApolloUri" value="http://10.2.1.21:28080"/> | |||
<add key="OrderServiceUri" value="https://bpa.black-pa.com:21527/order/"/> | |||
<add key="StockServiceUri" value="https://bpa.black-pa.com:21527/stock/"/> | |||
<add key="DataVServiceUri" value="https://bpa.black-pa.com:21527/datav"/> | |||
<add key="WebServiceUri" value="https://bpa.black-pa.com:21527"/> | |||
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_Test_SetDevice"/>--> | |||
<add key="AppId" value="order"/> | |||
<add key ="Namespaces" value="TEST1.Config"/> | |||
<add key="IsEnableTest" value="false"/> | |||
<add key="apollouri" value="http://10.2.1.21:28080"/> | |||
<add key="orderserviceuri" value="https://bpa.black-pa.com:21527/order/"/> | |||
<add key="stockserviceuri" value="https://bpa.black-pa.com:21527/stock/"/> | |||
<add key="datavserviceuri" value="https://bpa.black-pa.com:21527/datav"/> | |||
<add key="webserviceuri" value="https://bpa.black-pa.com:21527"/> | |||
<add key="broadcastpubtopic" value="/broadcast/grgpechsl7q/transit_test_setdevice"/> | |||
<add key="AppId" value="dev1_common"/> | |||
<add key ="Namespaces" value="DEV.Config"/> | |||
<add key="IsEnableTest" value="False"/> | |||
<!--测试环境--> | |||
<!--<add key="ApolloUri" value="http://10.2.1.21:28070"/> | |||
<add key="OrderServiceUri" value="https://bpa.black-pa.com:21528/order/"/> | |||
<add key="StockServiceUri" value="https://bpa.black-pa.com:21528/stock/"/> | |||
<add key="DataVServiceUri" value="https://bpa.black-pa.com:21527/datav"/> | |||
<add key="WebServiceUri" value="https://bpa.black-pa.com:21528/stock/"/> | |||
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_Test_SetDevice"/> | |||
<add key="AppId" value="dev1_common"/> | |||
<add key ="Namespaces" value="DEV.test1.Config"/>--> | |||
<!--正式环境--> | |||
<add key="OrderServiceUri" value="https://bpa.black-pa.com:21528/order/"/> | |||
<add key="StockServiceUri" value="https://bpa.black-pa.com:21528/stock/"/> | |||
<add key="DataVServiceUri" value="https://bpa.black-pa.com:21527/datav"/> | |||
<add key="WebServiceUri" value="https://bpa.black-pa.com:21528/stock/"/> | |||
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_Test_SetDevice"/> | |||
<add key="AppId" value="dev1_common"/> | |||
<add key ="Namespaces" value="DEV.test1.Config"/>--> | |||
<!--正式环境--><!-- | |||
<add key="ApolloUri" value="http://47.108.65.220:28080"/> | |||
<add key="OrderServiceUri" value="https://witt.black-pa.com/order/"/> | |||
<add key="StockServiceUri" value="https://witt.black-pa.com/stock/"/> | |||
<add key="DataVServiceUri" value="https://witt.black-pa.com/datav"/> | |||
<add key="WebServiceUri" value="https://witt.black-pa.com"/> | |||
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_SetDevice"/> | |||
<add key="WebServiceUri" value="https://witt.black-pa.com"/> | |||
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_SetDevice"/> | |||
<add key="AppId" value="order"/> | |||
<add key ="Namespaces" value="TEST1.Config"/> | |||
<add key="IsEnableTest" value="False"/>--> | |||
<!--阿里云上报启动方式:API 或者 LOCAL--> | |||
<!--阿里云上报启动方式:API 或者 LOCAL--> | |||
<!--API :通过客户端ID,调用接口查询“设备连接信息”--> | |||
<!--LOCAL:直接使用下方本地“设备连接信息”--> | |||
<add key="StartupMode" value="API"/> | |||
<add key="ProductKey" value="grgpECHSL7q"/> | |||
<add key="DeviceName" value="qsqd"/> | |||
<add key="DeviceSecret" value="3c0f2390943bff4fece523af22655196"/> | |||
<add key="PasswordBox" value="6WrKhYmTIhLV7g24jIH/lg=="/> | |||
<!--外设配置--> | |||
@@ -13,12 +13,15 @@ | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/GlobalStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecComboBox.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecIcoButtonStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecToggleButton.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/BeveledRadioButtonStyle.xaml" /> | |||
<!--<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml"/> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml"/>--> | |||
<ResourceDictionary> | |||
<con:ColorConverter x:Key="ColorConverter" /> | |||
<con:TextConverter x:Key="TextConverter" /> | |||
<con:VisibleTypeConverter x:Key="VisibleTypeConverter" /> | |||
</ResourceDictionary> | |||
<ResourceDictionary> | |||
@@ -0,0 +1,84 @@ | |||
<UserControl x:Class="BPASmartClient.Control.AdminstratorsView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.Control" | |||
xmlns:uc="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:helper ="clr-namespace:BPASmartClient.Control.Helper" | |||
xmlns:vm ="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel" | |||
mc:Ignorable="d" | |||
d:DesignHeight="600" d:DesignWidth="800" Loaded="UserControl_Loaded"> | |||
<UserControl.DataContext> | |||
<vm:AdminstratorsViewModel/> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<Style x:Key="TxLogin" TargetType="TextBlock" > | |||
<Setter Property="FontSize" Value="20"/> | |||
<Setter Property="Foreground" Value="#ddd"/> | |||
<Setter Property="HorizontalAlignment" Value="Center"/> | |||
<Setter Property="VerticalAlignment" Value="Center"/> | |||
</Style> | |||
</UserControl.Resources> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="7*"/> | |||
<ColumnDefinition Width="10*"/> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="10*"/> | |||
<RowDefinition Height="5*"/> | |||
<RowDefinition Height="4*"/> | |||
<RowDefinition Height="8*"/> | |||
<RowDefinition Height="20*"/> | |||
</Grid.RowDefinitions> | |||
<TextBlock Text="账号:" | |||
VerticalAlignment="Bottom" HorizontalAlignment="Right" | |||
Margin="20" | |||
Style="{StaticResource TxLogin}" | |||
/> | |||
<TextBlock Text="密码:" Grid.Row="1" | |||
VerticalAlignment="Top" HorizontalAlignment="Right" | |||
Margin="20" | |||
Style="{StaticResource TxLogin}"/> | |||
<TextBox x:Name="tbx_admin" Grid.Row="0" Grid.Column="1" | |||
Text="{Binding Admin, Mode=TwoWay}" | |||
Foreground="#F8F8FF" FontSize="20" | |||
Width="180" Height="28" | |||
VerticalAlignment="Bottom" HorizontalAlignment="Left" | |||
VerticalContentAlignment="Top" HorizontalContentAlignment="Center" | |||
Margin="20" | |||
Background="Transparent" | |||
BorderBrush="White" BorderThickness="0,0,0,1" | |||
GotFocus="TextBox_GotFocus"> | |||
</TextBox> | |||
<PasswordBox x:Name="password" Grid.Row="1" Grid.Column="1" | |||
FontSize="20" Foreground="#F8F8FF" | |||
Width="180" Margin="20" | |||
Background="Transparent" | |||
VerticalAlignment="Top" HorizontalAlignment="Left" | |||
VerticalContentAlignment="Top" HorizontalContentAlignment="Center" | |||
BorderBrush="White" BorderThickness="0,0,0,1" CaretBrush="White" | |||
helper:PasswordBoxHelper.PasswordContent="{Binding Password ,Mode=TwoWay}" | |||
GotFocus="Password_GotFocus"/> | |||
<TextBlock Text="{Binding ErrorMessage}" | |||
Grid.Row="2" Grid.ColumnSpan="2" | |||
VerticalAlignment="Top" HorizontalAlignment="Center" | |||
FontFamily="楷体" | |||
FontSize="16" | |||
Foreground="#FFE2415C" | |||
TextWrapping="Wrap" /> | |||
<Button Grid.Row="3" Grid.ColumnSpan="2" | |||
FontSize="28" Foreground="#9934F7F7" | |||
Width="120" Height="40" | |||
Background="Transparent" | |||
VerticalAlignment="Top" | |||
BorderBrush="#ff19b7ec" BorderThickness="2" | |||
Content="登 录" | |||
Command="{Binding AdminLoginCommand}" IsDefault="True"/> | |||
<uc:UserKeyBoard x:Name="myKeyboard" Grid.Row="4" Grid.ColumnSpan="2" Margin="100,10,100,50" Focusable="False"/> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,91 @@ | |||
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; | |||
using static BPASmartClient.CustomResource.UserControls.UserKeyBoard; | |||
namespace BPASmartClient.Control | |||
{ | |||
/// <summary> | |||
/// AdministratorsView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class AdminstratorsView : UserControl | |||
{ | |||
public AdminstratorsView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
private void UserControl_Loaded(object sender, RoutedEventArgs e) | |||
{ | |||
this.tbx_admin.Focus(); | |||
} | |||
private void MyKeyDown_Admin(object _key) | |||
{ | |||
EKeyitem key = EKeyitem.A; | |||
if (_key.GetType() == typeof(EKeyitem)) key = (EKeyitem)_key; | |||
switch(key) | |||
{ | |||
case EKeyitem.DEL: | |||
if (tbx_admin.Text.Length > 0) | |||
{ | |||
tbx_admin.Text = tbx_admin.Text.Substring(0, tbx_admin.Text.Length - 1); | |||
} | |||
break; | |||
case EKeyitem.AC: | |||
tbx_admin.Text = string.Empty; | |||
break; | |||
case EKeyitem.OK: | |||
break; | |||
default: | |||
tbx_admin.Text += _key.ToString(); | |||
break; | |||
} | |||
this.tbx_admin.Focus(); | |||
} | |||
private void MyKeyDown_Password(object _key) | |||
{ | |||
EKeyitem key = EKeyitem.A; | |||
if (_key.GetType() == typeof(EKeyitem)) key = (EKeyitem)_key; | |||
switch (key) | |||
{ | |||
case EKeyitem.DEL: | |||
if (password.Password.Length > 0) | |||
{ | |||
password.Password = password.Password.Substring(0, password.Password.Length - 1); | |||
} | |||
break; | |||
case EKeyitem.AC: | |||
password.Password = string.Empty; | |||
break; | |||
case EKeyitem.OK: | |||
break; | |||
default: | |||
password.Password += _key.ToString(); | |||
break; | |||
} | |||
} | |||
private void TextBox_GotFocus(object sender, RoutedEventArgs e) | |||
{ | |||
myKeyboard.MyKeyDown = MyKeyDown_Admin; | |||
} | |||
private void Password_GotFocus(object sender, RoutedEventArgs e) | |||
{ | |||
myKeyboard.MyKeyDown = MyKeyDown_Password; | |||
} | |||
} | |||
} |
@@ -16,9 +16,11 @@ | |||
</UserControl.Resources> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="*"></ColumnDefinition> | |||
<ColumnDefinition Width="0.8*"></ColumnDefinition> | |||
<ColumnDefinition Width="2*"></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<StackPanel Grid.Column="0" Margin="10"> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" FontSize="12">API查询地址:</TextBlock> | |||
@@ -73,15 +75,15 @@ | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0" > | |||
<Button Margin="80,0,0,0" Tag="Add" Click="Button_Click" Style="{DynamicResource CommonBtn_返回}" Width="45">增加</Button> | |||
<Button Margin="20,0,0,0" Tag="Update" Click="Button_Click" Style="{DynamicResource CommonBtn_返回}" Width="45">修改</Button> | |||
<Button Margin="20,0,0,0" Tag="Delete" Click="Button_Click" Style="{DynamicResource CommonBtn_返回}" Width="45">删除</Button> | |||
<Button Margin="80,0,0,0" Tag="Add" Click="Button_Click" Width="45">增加</Button> | |||
<Button Margin="20,0,0,0" Tag="Update" Click="Button_Click" Width="45">修改</Button> | |||
<Button Margin="20,0,0,0" Tag="Delete" Click="Button_Click" Width="45">删除</Button> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,20,0,0" > | |||
<Button Margin="80,0,0,0" Tag="Save" Click="Button_Click" Style="{DynamicResource CommonBtn_返回}" Width="73">保存text</Button> | |||
<Button Margin="20,0,0,0" Tag="Insert" Click="Button_Click" Style="{DynamicResource CommonBtn_返回}" Width="73" Cursor="Hand">导入text</Button> | |||
<Button Margin="80,0,0,0" Tag="Save" Click="Button_Click" >保存text</Button> | |||
<Button Margin="20,0,0,0" Tag="Insert" Click="Button_Click" >导入text</Button> | |||
</StackPanel> | |||
</StackPanel> | |||
@@ -149,5 +151,13 @@ | |||
</DataGrid> | |||
</Grid> | |||
<Grid x:Name="Pass" Grid.ColumnSpan="2" Background="#99020202"> | |||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<TextBlock Width="80" FontSize="16" Margin="0,0,0,5">密码解锁:</TextBlock> | |||
<PasswordBox x:Name="passbox" Width="180" Height="22" ></PasswordBox> | |||
<Button HorizontalAlignment="Right" Margin="0,5,0,0" Tag="OkPass" Click="Button_Click" IsDefault="True">确定</Button> | |||
</StackPanel> | |||
</Grid> | |||
</Grid> | |||
</UserControl> |
@@ -1,5 +1,6 @@ | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.IoT; | |||
using BPASmartClient.ViewModel; | |||
using DataVAPI.Tool.IOT; | |||
@@ -18,6 +19,7 @@ using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
using System.Windows.Threading; | |||
namespace BPASmartClient.Control | |||
{ | |||
@@ -26,10 +28,24 @@ namespace BPASmartClient.Control | |||
/// </summary> | |||
public partial class DataVView : UserControl | |||
{ | |||
string OnPass=string.Empty; | |||
public DispatcherTimer dispatcherTimer; | |||
public DataVView() | |||
{ | |||
InitializeComponent(); | |||
OnPass = AESHelper.Decrypt(System.Configuration.ConfigurationManager.AppSettings["PasswordBox"].ToString()); | |||
this.DataContext = DataVViewModel.GetInstance(); | |||
dispatcherTimer = new DispatcherTimer(); | |||
dispatcherTimer.Tick += delegate | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
Pass.Visibility = Visibility.Visible; | |||
dispatcherTimer.Stop(); | |||
})); | |||
}; | |||
dispatcherTimer.Interval = TimeSpan.FromSeconds(120); | |||
} | |||
private void Button_Click(object sender, RoutedEventArgs e) | |||
@@ -107,7 +123,16 @@ namespace BPASmartClient.Control | |||
DataVViewModel.GetInstance().Refresh(); | |||
} | |||
} | |||
break; | |||
case "OkPass": | |||
if (passbox.Password == OnPass) | |||
{ | |||
Pass.Visibility = Visibility.Collapsed; | |||
passbox.Password = ""; | |||
dispatcherTimer.Start(); | |||
} | |||
else | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, MainViewModel.GetInstance().window, "提示", $"密码输入错误!"); | |||
break; | |||
} | |||
} | |||
@@ -0,0 +1,40 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
namespace BPASmartClient.Control.Helper | |||
{ | |||
/// <summary> | |||
/// 为PasswordBox控件的Password增加绑定功能 | |||
/// </summary> | |||
public static class PasswordBoxHelper | |||
{ | |||
public static string GetPasswordContent(DependencyObject obj) => (string)obj.GetValue(PasswordContentProperty); | |||
public static void SetPasswordContent(DependencyObject obj, string value) => obj.SetValue(PasswordContentProperty, value); | |||
public static readonly DependencyProperty PasswordContentProperty = | |||
DependencyProperty.RegisterAttached("PasswordContent", typeof(string), typeof(PasswordBoxHelper), | |||
new PropertyMetadata(string.Empty, OnPasswordContentPropertyChanged)); | |||
private static void OnPasswordContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||
{ | |||
var box = d as PasswordBox; | |||
box.PasswordChanged -= OnPasswordChanged; | |||
var password = (string)e.NewValue; | |||
if (box != null && box.Password != password) | |||
box.Password = password; | |||
box.PasswordChanged += OnPasswordChanged; | |||
} | |||
private static void OnPasswordChanged(object sender, RoutedEventArgs e) | |||
{ | |||
var box = sender as PasswordBox; | |||
SetPasswordContent(box, box.Password); | |||
} | |||
} | |||
} |
@@ -0,0 +1,16 @@ | |||
<UserControl x:Class="BPASmartClient.Control.IOTView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.Control" | |||
xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<Grid> | |||
<wv2:WebView2 | |||
Name="webView" | |||
Width="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualWidth}" | |||
Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualHeight}" /> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,29 @@ | |||
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.Control | |||
{ | |||
/// <summary> | |||
/// IOTView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class IOTView : UserControl | |||
{ | |||
public IOTView() | |||
{ | |||
InitializeComponent(); | |||
webView.Source = new Uri("http://iot.black-pa.com"); | |||
} | |||
} | |||
} |
@@ -34,8 +34,8 @@ | |||
</ComboBox.ItemTemplate> | |||
</ComboBox> | |||
<DatePicker Margin="10,0,10,0" Text="{Binding DateTimeStr,Mode=TwoWay,NotifyOnTargetUpdated=True}"></DatePicker> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding QueryCommand}" Style="{DynamicResource CommonBtn_返回}" Width="75">查询数据</Button> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding OpenCommand}" Style="{DynamicResource CommonBtn_返回}" Width="102">打开文件目录</Button> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding QueryCommand}" >查询数据</Button> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding OpenCommand}" >打开文件目录</Button> | |||
</StackPanel> | |||
<!-- 表格栏 --> | |||
@@ -3,6 +3,7 @@ | |||
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:k="clr-namespace:BPASmartClient.Model;assembly=BPASmartClient.Model" | |||
xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel" | |||
xmlns:local="clr-namespace:BPASmartClient.Control" | |||
mc:Ignorable="d" | |||
@@ -25,10 +26,15 @@ | |||
<!--查询按钮栏--> | |||
<StackPanel Orientation="Horizontal" Margin="10,0,10,0"> | |||
<!--<CheckBox Margin="10,0,0,0" IsChecked="{Binding RealTimeModel, UpdateSourceTrigger=PropertyChanged}" >实时模式</CheckBox> | |||
<CheckBox Margin="10,0,0,0" IsChecked="{Binding TimedClear, UpdateSourceTrigger=PropertyChanged}">定时清除</CheckBox>--> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding ExcelCommand}" Style="{DynamicResource CommonBtn_返回}" Width="75">导出日志</Button> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding OpenCommand}" Style="{DynamicResource CommonBtn_返回}" Width="75">打开文件</Button> | |||
<ComboBox Width="100" Text="{Binding SelectedText}" IsEditable="True" ItemsSource="{Binding Path=BookExs}"> | |||
<ComboBox.ItemTemplate> | |||
<DataTemplate DataType="{x:Type k:BookEx}"> | |||
<CheckBox Width="95" IsChecked="{Binding IsChecked}" Content="{Binding BookN.Name}" /> | |||
</DataTemplate> | |||
</ComboBox.ItemTemplate> | |||
</ComboBox> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding ExcelCommand}" >导出日志</Button> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding OpenCommand}" >打开文件</Button> | |||
</StackPanel> | |||
<!--表格栏--> | |||
@@ -54,7 +60,7 @@ | |||
<DataGridTemplateColumn Header="日志类型" Width="300"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding type, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Foreground="{Binding foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding type, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Foreground="{Binding foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
@@ -1,5 +1,7 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.IO; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
@@ -13,6 +15,10 @@ using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
using BPASmartClient.DialogWindow; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.ViewModel; | |||
using BPASmartClient.ViewModel.Model; | |||
using Newtonsoft.Json; | |||
namespace BPASmartClient.Control | |||
{ | |||
@@ -29,7 +35,134 @@ namespace BPASmartClient.Control | |||
private void IcoButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) | |||
{ | |||
NewShopWindow newShopWindow = new NewShopWindow(); | |||
newShopWindow.ShowDialog(); | |||
var res = newShopWindow.ShowDialog(); | |||
if (res != null && res == true) | |||
{ | |||
VisibilityControl(); | |||
} | |||
} | |||
private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) | |||
{ | |||
Refresh(); | |||
} | |||
private void Refresh() | |||
{ | |||
if (this.tv.SelectedValue is DeviceConfigModel deviceConfigModel) | |||
{ | |||
} | |||
else if (this.tv.SelectedValue is DeviceModel deviceModel) | |||
{ | |||
this.Device.Visibility = Visibility.Visible; | |||
this.CommType.Visibility = Visibility.Collapsed; | |||
this.VarTab.Visibility = Visibility.Collapsed; | |||
this.Serial.Visibility = Visibility.Collapsed; | |||
this.Network.Visibility = Visibility.Collapsed; | |||
this.GridCommunication.Visibility = Visibility.Collapsed; | |||
} | |||
else if (this.tv.SelectedValue is CommunicationModel communicationModel) | |||
{ | |||
this.Device.Visibility = Visibility.Collapsed; | |||
this.CommType.Visibility = Visibility.Visible; | |||
this.VarTab.Visibility = Visibility.Visible; | |||
this.GridCommunication.Visibility = Visibility.Visible; | |||
this.Serial.Visibility = (bool)this.rbSerial.IsChecked ? Visibility.Visible : Visibility.Collapsed; | |||
this.Network.Visibility = (bool)this.rbNetwork.IsChecked ? Visibility.Visible : Visibility.Collapsed; | |||
if (ShopDeviceConfigViewModel.deviceConfig.Count > 0) | |||
{ | |||
int index = Array.FindIndex(ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.Id == communicationModel.DeviceModelId); | |||
if (index >= 0 && index < ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.Count) | |||
{ | |||
int commIndex = Array.FindIndex(ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ToArray(), p => p.DeviceModelId == communicationModel.DeviceModelId); | |||
if (commIndex >= 0 && commIndex < ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.Count) | |||
{ | |||
if (ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).communicationPar.variables.Count <= 0) | |||
{ | |||
for (int i = 0; i < 20; i++) | |||
{ | |||
ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).communicationPar.variables.Add(new Variable() | |||
{ | |||
Id = ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).communicationPar.variables.Count, | |||
Address = string.Empty, | |||
ReadLeng = 0 | |||
}); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
private void rbNetwork_Checked(object sender, RoutedEventArgs e) | |||
{ | |||
rbVisibility(); | |||
} | |||
private void rbSerial_Checked(object sender, RoutedEventArgs e) | |||
{ | |||
rbVisibility(); | |||
} | |||
private void rbVisibility() | |||
{ | |||
this.Network.Visibility = (bool)this.rbNetwork.IsChecked ? Visibility.Visible : Visibility.Collapsed; | |||
this.Serial.Visibility = (bool)this.rbSerial.IsChecked ? Visibility.Visible : Visibility.Collapsed; | |||
} | |||
private void ComboBox_DropDownOpened(object sender, EventArgs e) | |||
{ | |||
ShopDeviceConfigViewModel.Shops.Clear(); | |||
DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath); | |||
var files = directoryInfo.GetFiles(); | |||
foreach (var item in files) | |||
{ | |||
var res = System.IO.Path.GetFileNameWithoutExtension(item.FullName); | |||
if (res != null && res.Length > 0 && item.FullName.Contains("json")) ShopDeviceConfigViewModel.Shops.Add(res); | |||
} | |||
} | |||
private void shop_SelectionChanged(object sender, SelectionChangedEventArgs e) | |||
{ | |||
var text = TextHelper.GetInstance.ReadTextInfo("StartShop", "DeviceConfig"); | |||
if (this.shop.Items.Contains(text)) this.shop.SelectedValue = text; | |||
DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath); | |||
var files = directoryInfo.GetFiles(); | |||
if (files != null && this.shop.SelectedValue != null && this.shop.SelectedValue.ToString().Length > 0) | |||
{ | |||
var file = files.FirstOrDefault(p => p.FullName.Contains(this.shop.SelectedValue.ToString())); | |||
if (file != null && File.Exists(file.FullName)) | |||
{ | |||
string JsonString = File.ReadAllText(file.FullName); | |||
var result = JsonConvert.DeserializeObject<ObservableCollection<DeviceConfigModel>>(JsonString); | |||
if (result != null) | |||
{ | |||
ShopDeviceConfigViewModel.deviceConfig.Clear(); | |||
foreach (var item in result) | |||
{ | |||
ShopDeviceConfigViewModel.deviceConfig.Add(item); | |||
} | |||
VisibilityControl(); | |||
} | |||
} | |||
} | |||
TextHelper.GetInstance.WriteTextInfo(this.shop.SelectedValue?.ToString(), "StartShop", "DeviceConfig"); | |||
} | |||
private void VisibilityControl() | |||
{ | |||
if (this.Device != null) this.Device.Visibility = Visibility.Collapsed; | |||
if (this.CommType != null) this.CommType.Visibility = Visibility.Collapsed; | |||
if (this.VarTab != null) this.VarTab.Visibility = Visibility.Collapsed; | |||
if (this.Serial != null) this.Serial.Visibility = Visibility.Collapsed; | |||
if (this.Network != null) this.Network.Visibility = Visibility.Collapsed; | |||
if (this.GridCommunication != null) this.GridCommunication.Visibility = Visibility.Collapsed; | |||
} | |||
} | |||
} |
@@ -38,18 +38,16 @@ | |||
</Peripherals> | |||
</Device> | |||
<!--<Device Name="Morks" Module="BPASmartClient.MorkS.Control" DeviceId="2"> | |||
<Device Name="Morks" Module="BPASmartClient.MorkS.Control_Morks" DeviceId="28"> | |||
<Peripherals> | |||
<Peripheral Module="BPASmartClient.PLC.MorksMachine"> | |||
<Parameters> | |||
<IpAddress>127.0.0.1</IpAddress> | |||
<Port>502</Port> | |||
<PLCReadAddress>M,M550.0,16;M,M0.1,1;M,M1.0,8;M,M2.0,9;M,M8.0,4;M,M13.5,1;M,M16.0,7;</PLCReadAddress> | |||
<IpAddress>192.168.1.11</IpAddress> | |||
<Port>508</Port> | |||
<PLCReadAddress>M,M550.0,16;M,M0.3,3;M,M100.0,16;M,M235.0,1;M,M102.0,7;M,M103.0,6;VW,VW372,1</PLCReadAddress> | |||
</Parameters> | |||
</Peripheral> | |||
</Peripherals> | |||
</Device>--> | |||
</Device> | |||
</BPADevices> |
@@ -8,8 +8,8 @@ | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel" | |||
Title="NewShopWindow" | |||
Width="850" | |||
Height="450" | |||
Width="400" | |||
Height="300" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Opacity="0.8" | |||
@@ -85,7 +85,6 @@ | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="35" /> | |||
<RowDefinition /> | |||
<RowDefinition Height="50" /> | |||
</Grid.RowDefinitions> | |||
<!--#region 标题栏设置--> | |||
@@ -126,238 +125,111 @@ | |||
Visibility="Hidden" /> | |||
<Button | |||
Name="ButClose" | |||
Command="{Binding CloseCommand}" | |||
Content="" | |||
Command="{Binding CancelCommand}" | |||
Content="X" | |||
FontSize="30" | |||
Style="{StaticResource TitleBarStyle}" /> | |||
</UniformGrid> | |||
<!--#endregion--> | |||
<!--#region 表单数据--> | |||
<Grid Grid.Row="1"> | |||
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"> | |||
<Grid Margin="10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="100" /> | |||
<RowDefinition Height="200" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!-- 店铺信息 --> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid> | |||
<pry:TitleTextBlock /> | |||
<TextBlock | |||
Margin="5" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontFamily="雅黑" | |||
FontSize="20" | |||
Foreground="Yellow" | |||
Text="店铺信息" /> | |||
</Grid> | |||
<Grid Grid.Row="1"> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请输入店铺名称:" /> | |||
<TextBox | |||
Width="100" | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#FF23CACA" | |||
CaretBrush="Aqua" | |||
FontFamily="楷体" | |||
FontSize="21" | |||
Foreground="#ff34f7f7" | |||
Text="{Binding Minute}" /> | |||
</Grid> | |||
<Grid Grid.Row="2"> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请输入店铺ID:" /> | |||
<TextBox | |||
Width="100" | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#FF23CACA" | |||
CaretBrush="Aqua" | |||
FontFamily="楷体" | |||
FontSize="21" | |||
Foreground="#ff34f7f7" | |||
Text="{Binding Minute}" /> | |||
</Grid> | |||
</Grid> | |||
<!-- 设备信息 --> | |||
<Grid Grid.Row="1"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid> | |||
<pry:TitleTextBlock /> | |||
<TextBlock | |||
Margin="5" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontFamily="雅黑" | |||
FontSize="20" | |||
Foreground="Yellow" | |||
Text="设备信息" /> | |||
</Grid> | |||
<!--#region 使用列表包裹--> | |||
<Grid Grid.Row="1"> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请输入设备名称:" /> | |||
<TextBox | |||
Width="100" | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#FF23CACA" | |||
CaretBrush="Aqua" | |||
FontFamily="楷体" | |||
FontSize="21" | |||
Foreground="#ff34f7f7" | |||
Text="{Binding Minute}" /> | |||
</Grid> | |||
<Grid Grid.Row="2"> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请输入设备ID:" /> | |||
<TextBox | |||
Width="100" | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#FF23CACA" | |||
CaretBrush="Aqua" | |||
FontFamily="楷体" | |||
FontSize="21" | |||
Foreground="#ff34f7f7" | |||
Text="{Binding Minute}" /> | |||
</Grid> | |||
<Grid Grid.Row="3"> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请选择启动模块:" /> | |||
<ComboBox | |||
Grid.Column="5" | |||
Margin="170,0,20,0" | |||
VerticalAlignment="Center" | |||
BorderBrush="#FF23CACA" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#ff23caca" | |||
IsEditable="False" | |||
ItemsSource="{Binding Path=Device.PlcTypes}" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding Path=Device.PlcType}" /> | |||
</Grid> | |||
<Grid Grid.Row="4"> | |||
<TextBlock | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请选择通讯模块:" /> | |||
<ComboBox | |||
Grid.Column="5" | |||
Margin="170,0,20,0" | |||
VerticalAlignment="Center" | |||
BorderBrush="#FF23CACA" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#ff23caca" | |||
IsEditable="False" | |||
ItemsSource="{Binding Path=Device.PlcTypes}" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding Path=Device.PlcType}" /> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--<pry:IcoButton | |||
Grid.Row="4" | |||
Content="添加设备" | |||
FontSize="16" | |||
Foreground="{StaticResource TextBlockForeground}" | |||
IcoText="" | |||
Style="{StaticResource NewButtonStyle}" />--> | |||
</Grid> | |||
<Grid Margin="10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="60" /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid Grid.Row="0"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.6*" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请输入店铺名称:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#FF23CACA" | |||
CaretBrush="Aqua" | |||
FontFamily="楷体" | |||
FontSize="21" | |||
Foreground="#ff34f7f7" | |||
Text="{Binding ShopName}" /> | |||
</Grid> | |||
<Grid Grid.Row="2"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.6*" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="请输入店铺ID:" /> | |||
<TextBox | |||
Grid.Column="1" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#FF23CACA" | |||
CaretBrush="Aqua" | |||
FontFamily="楷体" | |||
FontSize="21" | |||
Foreground="#ff34f7f7" | |||
Text="{Binding ShopId}" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Row="3" | |||
Margin="10,0,0,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="Red" | |||
Text="{Binding ErrorInfo}" /> | |||
<Grid Grid.Row="4"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Button | |||
Grid.Column="0" | |||
VerticalAlignment="Center" | |||
Command="{Binding CancelCommand}" | |||
Content="取消" | |||
Style="{StaticResource buttonStyle}" /> | |||
<Button | |||
Grid.Column="1" | |||
VerticalAlignment="Center" | |||
Command="{Binding DefineCommand}" | |||
Content="确认" | |||
Style="{StaticResource buttonStyle}" /> | |||
</Grid> | |||
</ScrollViewer> | |||
</Grid> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 信息取--> | |||
<Grid Grid.Row="2" Background="#11dddddd"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<!--<ColumnDefinition Width="0.2*" /> | |||
<ColumnDefinition Width="0.2*" />--> | |||
</Grid.ColumnDefinitions> | |||
<!--<TextBlock | |||
Margin="10,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="Yellow" | |||
Text="请选择需要继续制作的订单,取消或关闭将删除所有订单。" />--> | |||
<Button | |||
Grid.Column="0" | |||
VerticalAlignment="Center" | |||
Command="{Binding CancelCommand}" | |||
Content="取消" | |||
Style="{StaticResource buttonStyle}" /> | |||
<Button | |||
Grid.Column="1" | |||
VerticalAlignment="Center" | |||
Command="{Binding ConfirmCommand}" | |||
Content="确认" | |||
Style="{StaticResource buttonStyle}" /> | |||
</Grid> | |||
<!--#endregion--> | |||
</Grid> | |||
@@ -1,4 +1,6 @@ | |||
using System; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Messaging; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
@@ -27,14 +29,28 @@ namespace BPASmartClient.DialogWindow | |||
this.DragMove(); | |||
}; | |||
//WeakReferenceMessenger.Default.Register<string, string>(this, "Close", (o, e) => | |||
//{ | |||
// App.Current.Dispatcher.Invoke(new Action(() => | |||
// { | |||
// this.DialogResult = Convert.ToBoolean(e); | |||
// this.Close(); | |||
// })); | |||
//}); | |||
ActionManage.GetInstance.CancelRegister("CloseWindow"); | |||
ActionManage.GetInstance.CancelRegister("OkCloseWindow"); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
this.DialogResult = false; | |||
this.Close(); | |||
})); | |||
}), "CloseWindow"); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
this.DialogResult = true; | |||
this.Close(); | |||
})); | |||
}), "OkCloseWindow"); | |||
} | |||
@@ -50,7 +50,7 @@ | |||
Margin="20,0,0,0" | |||
VerticalAlignment="Center" | |||
Style="{DynamicResource imagetop_Title}" /> | |||
<Grid Grid.Column="1"> | |||
<Grid Grid.Column="1" Visibility="{Binding VsMenuItem}" > | |||
<Menu> | |||
<MenuItem Header="功能列表"> | |||
<MenuItem | |||
@@ -108,17 +108,11 @@ | |||
Header="设备监视" | |||
Tag="DeviceMonitorView" /> | |||
<Separator /> | |||
<MenuItem | |||
Click="MenuItem_Click" | |||
FontSize="12" | |||
Header="告警监视" | |||
Tag="LogView" /> | |||
<Separator /> | |||
<MenuItem | |||
Click="MenuItem_Click" | |||
FontSize="12" | |||
Header="IOT监视" | |||
Tag="LogView" /> | |||
Tag="IOTView" /> | |||
<Separator /> | |||
</MenuItem> | |||
<MenuItem Header="综合查询"> | |||
@@ -239,9 +233,8 @@ | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Click="Button_Click" | |||
Content="返回" | |||
Cursor="Hand" | |||
Style="{DynamicResource CommonBtn_返回}" /> | |||
Content="测试" | |||
Cursor="Hand" /> | |||
<Button | |||
Grid.Row="0" | |||
Width="100" | |||
@@ -250,10 +243,9 @@ | |||
VerticalAlignment="Top" | |||
Click="Button_Click_1" | |||
Content="测试消息弹窗" | |||
Cursor="Hand" | |||
Style="{DynamicResource CommonBtn_返回}" /> | |||
Cursor="Hand"/> | |||
<Button | |||
<!--<Button | |||
Name="save" | |||
Grid.Row="0" | |||
Width="100" | |||
@@ -263,19 +255,23 @@ | |||
Click="Button_Click_2" | |||
Content="保存订单数据" | |||
Cursor="Hand" | |||
Style="{DynamicResource CommonBtn_返回}" /> | |||
Style="{DynamicResource CommonBtn_返回}" />--> | |||
<Button | |||
Name="init" | |||
Grid.Row="0" | |||
Width="90" | |||
Margin="350,0,0,0" | |||
Margin="230,0,0,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Click="init_Click" | |||
Content="初始化设备" | |||
Cursor="Hand" | |||
Style="{DynamicResource CommonBtn_返回}" /> | |||
Cursor="Hand"/> | |||
<CheckBox | |||
Margin="350,0,0,0" | |||
Content="开机启动" | |||
IsChecked="{Binding AutoStart}" /> | |||
<TextBlock | |||
x:Name="Title" | |||
@@ -284,6 +280,29 @@ | |||
Foreground="#feffff"> | |||
日志监控界面 | |||
</TextBlock> | |||
<Button | |||
Name="login" | |||
Grid.Row="0" | |||
Width="45" | |||
Margin="0,0,60,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Top" | |||
Click="Button_Login" | |||
Content="登录" | |||
Cursor="Hand" | |||
Style="{DynamicResource CommonBtn_返回}" /> | |||
<Button | |||
Name="logout" | |||
Grid.Row="0" | |||
Width="45" | |||
Margin="350,0,0,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Top" | |||
Click="Button_LogOut" | |||
Content="注销" | |||
Cursor="Hand" | |||
Style="{DynamicResource CommonBtn_返回}" | |||
Command="{Binding LogoutCommand}"/> | |||
</Grid> | |||
<!--#region 底部窗体栏--> | |||
@@ -1,5 +1,6 @@ | |||
using BPA.Message; | |||
using BPASmartClient.Business; | |||
using BPASmartClient.Control; | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.Device; | |||
@@ -36,7 +37,7 @@ namespace BPASmartClient | |||
{ | |||
public MainWindow() | |||
{ | |||
InitializeComponent(); | |||
InitializeComponent(); | |||
MainViewModel.GetInstance().window = this; | |||
this.DataContext = MainViewModel.GetInstance(); | |||
Initialize(); | |||
@@ -58,7 +59,7 @@ namespace BPASmartClient | |||
else if (this.WindowState == WindowState.Normal) | |||
this.WindowState = WindowState.Maximized; | |||
} | |||
this.DragMove(); | |||
if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); | |||
}; | |||
MenuItem_Click(new MenuItem() { Tag = "LogView", Header = "日志监视" }, null); | |||
@@ -160,7 +161,7 @@ namespace BPASmartClient | |||
private void Button_Click_2(object sender, RoutedEventArgs e) | |||
{ | |||
this.save.IsEnabled = false; | |||
//this.save.IsEnabled = false; | |||
Task.Run(new Action(() => | |||
{ | |||
var res = Json<KeepDataBase>.Data.orderLists.FirstOrDefault(p => p.DeviceId == "2")?.morkOrderPushes; | |||
@@ -186,7 +187,7 @@ namespace BPASmartClient | |||
count = 0; | |||
} | |||
} | |||
App.Current.Dispatcher.Invoke(new Action(() => { this.save.IsEnabled = true; })); | |||
//App.Current.Dispatcher.Invoke(new Action(() => { this.save.IsEnabled = true; })); | |||
})); | |||
@@ -196,5 +197,28 @@ namespace BPASmartClient | |||
{ | |||
ActionManage.GetInstance.Send("InitDevice"); | |||
} | |||
private void Button_Login(object sender, RoutedEventArgs e) | |||
{ | |||
try | |||
{ | |||
Type type = Type.GetType($"BPASmartClient.Control.AdminstratorsView"); | |||
if (type == null) { MenuClick((sender as MenuItem).Tag?.ToString()); return; } | |||
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes); | |||
contentRegion.Content = (FrameworkElement)cti.Invoke(null); | |||
Title.Text = "管理员登录界面"; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient 中引发错误,MainWindow.xaml.cs 类MenuItem_Click(),描述:[{ex.Message}]"); | |||
} | |||
} | |||
private void Button_LogOut(object sender, RoutedEventArgs e) | |||
{ | |||
} | |||
} | |||
} |
@@ -2,10 +2,12 @@ | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<BaseOutputPath>bin\</BaseOutputPath> | |||
<DebugType>portable</DebugType> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.24" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.26" /> | |||
<PackageReference Include="BPA.Models" Version="1.0.10" /> | |||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" /> | |||
</ItemGroup> | |||
@@ -1,28 +1,25 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Configuration; | |||
using System.Linq; | |||
using System.Threading; | |||
using BPA.Message; | |||
using Robotc; | |||
using System.Collections.Concurrent; | |||
using System.Diagnostics; | |||
using BPA.Message; | |||
using BPA.Message.Enum; | |||
using BPA.Message.IOT; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Device; | |||
using BPA.Message.Enum; | |||
using BPASmartClient.DRCoffee; | |||
using BPASmartClient.EventBus; | |||
using BPASmartClient.GSIceCream; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Lebai; | |||
using BPASmartClient.EventBus; | |||
using BPASmartClient.Model.咖啡机.Enum; | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Model.冰淇淋.Enum; | |||
using BPASmartClient.Model.单片机; | |||
using BPASmartClient.Model.单片机.Enum; | |||
using BPASmartClient.Model.咖啡机.Enum; | |||
using BPASmartClient.SCChip; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Model.单片机; | |||
using Robotc; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Threading; | |||
using static BPASmartClient.EventBus.EventBus; | |||
namespace BPASmartClient.MORKIC | |||
@@ -53,7 +50,7 @@ namespace BPASmartClient.MORKIC | |||
/// <summary> | |||
/// 咖啡位置是否有东西 | |||
/// </summary> | |||
private bool IsCoffeeMake=false; | |||
private bool IsCoffeeMake = false; | |||
private bool enableFunny = false; | |||
private DateTime lastRecvdOrder = DateTime.Now; | |||
@@ -79,41 +76,41 @@ namespace BPASmartClient.MORKIC | |||
/// <summary> | |||
/// 等待取餐的订单,只有一个 | |||
/// </summary> | |||
ConcurrentQueue<SimOrderData> WaitTakeMealOrder= new ConcurrentQueue<SimOrderData>(); | |||
ConcurrentQueue<SimOrderData> WaitTakeMealOrder = new ConcurrentQueue<SimOrderData>(); | |||
public void Init() | |||
{ | |||
ActionManage.GetInstance.Register(new Action<object>((s) => | |||
{ | |||
if (s is DrCoffeeDrinksCode cf) | |||
{ | |||
DoCoffee(new SimOrderData { Loc = ((int)cf).ToString() }); | |||
} | |||
else if (s is Dictionary<string, string> ms) | |||
{ | |||
if (ms.ContainsKey("Button")) | |||
{ | |||
switch (ms["Button"]) | |||
{ | |||
case "启动示教": | |||
LebaiRobot.GetInstance.StartTeachMode(); | |||
break; | |||
case "停止示教": | |||
LebaiRobot.GetInstance.EndtTeachMode(); | |||
break; | |||
case "启动机器人": | |||
LebaiRobot.GetInstance.StartRobot(); | |||
break; | |||
case "急停": | |||
LebaiRobot.GetInstance.EStopRobot(); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
} | |||
}),"SimCoffee"); | |||
ActionManage.GetInstance.Register(new Action<object>((s) => | |||
{ | |||
if (s is DrCoffeeDrinksCode cf) | |||
{ | |||
DoCoffee(new SimOrderData { Loc = ((int)cf).ToString() }); | |||
} | |||
else if (s is Dictionary<string, string> ms) | |||
{ | |||
if (ms.ContainsKey("Button")) | |||
{ | |||
switch (ms["Button"]) | |||
{ | |||
case "启动示教": | |||
LebaiRobot.GetInstance.StartTeachMode(); | |||
break; | |||
case "停止示教": | |||
LebaiRobot.GetInstance.EndtTeachMode(); | |||
break; | |||
case "启动机器人": | |||
LebaiRobot.GetInstance.StartRobot(); | |||
break; | |||
case "急停": | |||
LebaiRobot.GetInstance.EStopRobot(); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
} | |||
}), "SimCoffee"); | |||
//构建所有商品物料信息 | |||
batchings = PolymerBatching.BuildAll(); | |||
@@ -162,13 +159,13 @@ namespace BPASmartClient.MORKIC | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
while (IsHealth &&(morkOrderPushesCoffee.Count > 0 || morkOrderPushesIceCream.Count>0 || IsCoffeeMake)) | |||
while (IsHealth && (morkOrderPushesCoffee.Count > 0 || morkOrderPushesIceCream.Count > 0 || IsCoffeeMake)) | |||
{ | |||
working = true; NoOrderTime = 0; | |||
//1.有咖啡订单 取杯去制作 | |||
if (!IsCoffeeMake)//位置无杯子 | |||
{ | |||
if (morkOrderPushesCoffee.Count>0 && morkOrderPushesCoffee.TryDequeue(out SimOrderData simOrder)) | |||
if (morkOrderPushesCoffee.Count > 0 && morkOrderPushesCoffee.TryDequeue(out SimOrderData simOrder)) | |||
{ | |||
IsCoffeeMake = true; MakeCoffeeOrder = simOrder; | |||
MessageLog.GetInstance.Show($"开始制作 [咖啡] 订单[{simOrder.morkOrder.SortNum}]"); | |||
@@ -180,20 +177,20 @@ namespace BPASmartClient.MORKIC | |||
{ | |||
//取餐位的订单完成 | |||
if (WaitTakeMealOrder.TryDequeue(out SimOrderData waitOrder)) OrderChange(waitOrder.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
//1.制作冰淇淋 | |||
if (morkOrderPushesIceCream.Count>0 && MorkIStatus.GetInstance().CurrentMode!= MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
if (morkOrderPushesIceCream.Count > 0 && MorkIStatus.GetInstance().CurrentMode != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
if (MorkIStatus.GetInstance().CXB >= 86 && morkOrderPushesIceCream.Count > 0)//成型比大于80 我才会制作 | |||
{ | |||
if (LebaiRobot.GetInstance.GetInput(3)) | |||
{ | |||
if(IceIsOK) MessageLog.GetInstance.Show("请擦拭冰淇淋机出口"); | |||
if (IceIsOK) MessageLog.GetInstance.Show("请擦拭冰淇淋机出口"); | |||
IceIsOK = false; | |||
} | |||
else if(morkOrderPushesIceCream.TryDequeue(out SimOrderData order)) | |||
else if (morkOrderPushesIceCream.TryDequeue(out SimOrderData order)) | |||
{ | |||
IceIsOK = true; | |||
MessageLog.GetInstance.Show($"开始制作 [冰淇淋] 订单[{order.morkOrder.SortNum}]"); | |||
@@ -216,7 +213,7 @@ namespace BPASmartClient.MORKIC | |||
working = false; | |||
lastRecvdOrder = DateTime.Now; | |||
} | |||
if (IsHealth == false && (morkOrderPushesCoffee.Count > 0 || morkOrderPushesIceCream.Count > 0 || IsCoffeeMake)) | |||
{ | |||
MessageLog.GetInstance.Show($"机器连接问题 订单,不允许制作,请检查设备连接后尝试," + | |||
@@ -237,8 +234,8 @@ namespace BPASmartClient.MORKIC | |||
} | |||
Thread.Sleep(1000); | |||
}),"订单制作"); | |||
Thread.Sleep(1000); | |||
}), "订单制作"); | |||
} | |||
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) | |||
@@ -273,7 +270,7 @@ namespace BPASmartClient.MORKIC | |||
} | |||
//LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_欢迎); | |||
}), "MORK-IC欢迎"); | |||
} | |||
public void DataParse<T>(T order) | |||
@@ -313,10 +310,10 @@ namespace BPASmartClient.MORKIC | |||
switch (currentGoodsType) | |||
{ | |||
case GOODS_TYPE.COFFEE: | |||
morkOrderPushesCoffee.Enqueue(new SimOrderData { Loc = loc_coffe,morkOrder = morkOrderPush }); | |||
morkOrderPushesCoffee.Enqueue(new SimOrderData { Loc = loc_coffe, morkOrder = morkOrderPush }); | |||
break; | |||
case GOODS_TYPE.ICECREAM: | |||
morkOrderPushesIceCream.Enqueue(new SimOrderData { Loc = loc_coffe,morkOrder = morkOrderPush }); | |||
morkOrderPushesIceCream.Enqueue(new SimOrderData { Loc = loc_coffe, morkOrder = morkOrderPush }); | |||
break; | |||
case GOODS_TYPE.NEITHER: | |||
MessageLog.GetInstance.Show("未知的商品类型"); | |||
@@ -356,7 +353,7 @@ namespace BPASmartClient.MORKIC | |||
int checkeNum = 0; | |||
// are.Reset(); | |||
LebaiRobot.GetInstance.SetValue(0); | |||
OrderChange(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
OrderChange(order.morkOrder.SuborderId, ORDER_STATUS.COOKING); | |||
//SimpleFactory.GetInstance.OrderChanged(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡杯); | |||
Wait(); | |||
@@ -370,19 +367,19 @@ namespace BPASmartClient.MORKIC | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯检测); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
if (!LebaiRobot.GetInstance.GetInput()) | |||
{ | |||
if (count >= 3) | |||
{ | |||
//退出循环回到初始位置 | |||
MessageLog.GetInstance.Show($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!"); | |||
DeviceProcessLogShow($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯回原点); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
return; | |||
} | |||
MessageLog.GetInstance.Show("执行二次取咖啡杯"); | |||
DeviceProcessLogShow("执行二次取咖啡杯"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取咖啡杯); | |||
Wait(); | |||
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制 | |||
@@ -391,13 +388,13 @@ namespace BPASmartClient.MORKIC | |||
goto p; | |||
} | |||
MessageLog.GetInstance.Show("咖啡杯取杯完成"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接咖啡_新); | |||
DeviceProcessLogShow("咖啡杯取杯完成"); | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接咖啡后回原点); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
//加场景 回初始位置 | |||
new DRCoffee_MakeCoffeeEvent() { DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(order.Loc) }.Publish(); //接咖啡控制 | |||
MessageLog.GetInstance.Show($"发送咖啡机制作{order.Loc}!"); | |||
DeviceProcessLogShow($"发送咖啡机制作{order.Loc}!"); | |||
#endregion | |||
} | |||
@@ -413,7 +410,7 @@ namespace BPASmartClient.MORKIC | |||
//订单状态改变:完成 | |||
OrderChange(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK); | |||
//SimpleFactory.GetInstance.OrderChanged(order.morkOrder.SuborderId,BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK); | |||
MessageLog.GetInstance.Show($"{order.morkOrder.GoodsName}等待取餐"); | |||
DeviceProcessLogShow($"{order.morkOrder.GoodsName}等待取餐"); | |||
WaitTakeMealOrder.Enqueue(order); | |||
} | |||
@@ -427,7 +424,7 @@ namespace BPASmartClient.MORKIC | |||
// MessageLog.GetInstance.Show("请擦拭冰淇淋机出口"); | |||
// return; | |||
//} | |||
#region 且时且多入场设备程序 | |||
int checkeNum = 0; | |||
//are.Reset(); | |||
@@ -443,7 +440,7 @@ namespace BPASmartClient.MORKIC | |||
p: | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯检测); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
if (!LebaiRobot.GetInstance.GetInput()) | |||
{ | |||
@@ -499,13 +496,13 @@ namespace BPASmartClient.MORKIC | |||
} | |||
LebaiRobot.GetInstance.SetValue(1); | |||
#endregion | |||
while (LebaiRobot.GetInstance.GetInput()) | |||
{ | |||
Thread.Sleep(500); | |||
} | |||
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_放冰淇淋位置); | |||
Wait(); | |||
LebaiRobot.GetInstance.SetValue(1); | |||
//订单状态改变:完成 | |||
@@ -514,7 +511,7 @@ namespace BPASmartClient.MORKIC | |||
MessageLog.GetInstance.Show($"{order.morkOrder.GoodsName}等待取餐"); | |||
WaitTakeMealOrder.Enqueue(order); | |||
#endregion | |||
} | |||
/// <summary> | |||
@@ -568,7 +565,7 @@ namespace BPASmartClient.MORKIC | |||
public void SimOrder<T>(T simOrder) | |||
{ | |||
} | |||
/// <summary> | |||
@@ -603,7 +600,7 @@ namespace BPASmartClient.MORKIC | |||
public override void DoMain() | |||
{ | |||
} | |||
public override void Stop() | |||
@@ -641,7 +638,7 @@ namespace BPASmartClient.MORKIC | |||
public SimOrderData() | |||
{ | |||
id = Guid.NewGuid().ToString(); | |||
OrderStatus=0; | |||
OrderStatus = 0; | |||
} | |||
} | |||
} |