master
nodyang@aliyun.com 2 months ago
commit ebf224d565

@ -5,4 +5,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SlnMesnac.TouchSocket\SlnMesnac.TouchSocket.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,75 @@
using SlnMesnac.Model.domain;
using SlnMesnac.TouchSocket;
using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* T14-GEN3-7895
* SlnMesnac.Business
* 1a936e54-f672-4d86-b9bd-2747b75d4732
*
* WenJY
*
* 2024-09-19 9:49:11
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Business
{
public class TagScanBusiness
{
private ApiServer apiServer;
public delegate void RefreshTagScanInfo(ScanLogModel scanLogModel);
public event RefreshTagScanInfo? RefreshTagScanInfoEvent;
public delegate void RefreshDeviceAlarmMessage(string message);
public event RefreshDeviceAlarmMessage? RefreshDeviceAlarmMessageEvent;
public TagScanBusiness(ApiServer apiServer)
{
this.apiServer = apiServer;
this.RefreshScanInfo();
}
private void RefreshScanInfo()
{
//扫描记录刷新
apiServer.ScanLogSocketAction += scan =>
{
RefreshTagScanInfoEvent?.Invoke(scan);
};
//告警状态刷新
apiServer.ScanStatusSocketAction += info =>
{
if (info != null && info.is_alarm == 1)
{
if (info.status_txt != null)
{
foreach (var item in info.status_txt)
{
RefreshDeviceAlarmMessageEvent?.Invoke(item);
}
}
}
};
}
}
}

@ -6,10 +6,10 @@
xmlns:local="clr-namespace:SlnMesnac.WPF"
mc:Ignorable="d"
Title="MainWindow" Height="1080" Width="1920"
WindowState="Maximized" WindowStyle="None" ResizeMode="NoResize" Topmost="False">
<Window.Background>
WindowState="Maximized" WindowStyle="None" ResizeMode="NoResize" Topmost="False" Background="#E0E9F2">
<!--<Window.Background>
<ImageBrush ImageSource="/Templates/image/background.jpg" />
</Window.Background>
</Window.Background>-->
<Border Margin="5" Background="Transparent" CornerRadius="10">
<Border.Effect>
@ -18,143 +18,37 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.6*"/>
<RowDefinition Height="7*"/>
<RowDefinition Height="0.7*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="Red" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="2,2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="7*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text="生产控制系统" FontSize="50" Foreground="White" FontWeight="Bold"/>
</StackPanel>
<StackPanel Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="白班" FontSize="25" Foreground="White" FontWeight="Bold" Margin="0,0,30,0"/>
<TextBlock Grid.Column="1" Text="|" FontSize="25" Foreground="White" FontWeight="Bold" Margin="0,0,30,0"/>
<TextBlock Grid.Column="2" Text="SCADA" FontSize="25" Foreground="White" FontWeight="Bold" Margin="0,0,10,0"/>
</Grid>
</StackPanel>
</Grid>
<Border Grid.Row="0" BorderBrush="Red" BorderThickness="0" CornerRadius="5" Background="#EBF4FD" Margin="10,0">
<TextBlock Text="RFID+ATR+OCR 中间件监控系统" FontSize="35" Foreground="#31446E" FontWeight="Bold" Margin="20,0,0,0" VerticalAlignment="Center"/>
</Border>
<Border Grid.Row="1" BorderBrush="Red" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="2,25,2,2">
<Border Grid.Row="1" BorderBrush="Red" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="0,10">
<ContentControl Content="{Binding UserContent}"/>
</Border>
<Border Grid.Row="2" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="6,2,6,7">
<Border.Effect>
<DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
</Border.Effect>
<Border Grid.Row="2" Background="Transparent" Margin="6,2,6,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
<Button Content="首 页" x:Name="Index" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=Index}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="10,0,10,0"/>
<Button Content="首 页" x:Name="Index" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=Index}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#5095F3" BorderBrush="#5095F3" Margin="10,0,10,0"/>
<Button Content="数据记录" x:Name="History" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=History}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="日志信息" x:Name="Log" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=Log}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="系统版本" x:Name="Version" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=Version}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="键 盘" Command="{Binding OpenSystemKeyboardCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="最小化" x:Name="Minimized" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,10,0"/>
<Button Content="退 出" x:Name="Exit" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF0033" BorderBrush="#FF0033" Margin="0,0,10,0"/>
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Orientation="Horizontal">
<!--多行状态显示-->
<!--<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="0,0,0,0" VerticalAlignment="Center">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="1">
<TextBlock Text="连接状态" FontSize="15" Foreground="Black" Margin="2,0,10,0"/>
</StackPanel>
<StackPanel Grid.Column="0">
<Ellipse Width="20" Height="20">
<Ellipse.Style>
<Style TargetType="Ellipse">
<Style.Triggers>
<DataTrigger Binding="{Binding PresentColor}" Value="0">
<Setter Property="Shape.Fill" Value="Orange"/>
</DataTrigger>
<DataTrigger Binding="{Binding PresentColor}" Value="1">
<Setter Property="Shape.Fill" Value="Green"/>
</DataTrigger>
<DataTrigger Binding="{Binding PresentColor}" Value="2">
<Setter Property="Shape.Fill" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
</Ellipse>
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</StackPanel>
<StackPanel Grid.Row="1" Margin="0,10,0,0" VerticalAlignment="Center">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="1">
<TextBlock Text="连接状态" FontSize="15" Foreground="Black" Margin="2,0,10,0"/>
</StackPanel>
<StackPanel Grid.Column="0">
<Ellipse Width="20" Height="20">
<Ellipse.Style>
<Style TargetType="Ellipse">
<Style.Triggers>
<DataTrigger Binding="{Binding PresentColor}" Value="0">
<Setter Property="Shape.Fill" Value="Orange"/>
</DataTrigger>
<DataTrigger Binding="{Binding PresentColor}" Value="1">
<Setter Property="Shape.Fill" Value="Green"/>
</DataTrigger>
<DataTrigger Binding="{Binding PresentColor}" Value="2">
<Setter Property="Shape.Fill" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
</Ellipse>
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</StackPanel>
</Grid>-->
<!--单行状态显示-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
@ -188,7 +82,7 @@
</Ellipse>
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Text="箱壳扫码器" FontSize="15" Foreground="#FFFFFF" Margin="2,0,10,0"/>
<TextBlock Text="RFID状态" FontSize="15" Foreground="#31446E" Margin="2,0,10,0"/>
</StackPanel>
</Grid>
</StackPanel>
@ -219,41 +113,11 @@
</Ellipse>
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Text="内胆扫码器" FontSize="15" Foreground="#FFFFFF" Margin="2,0,10,0"/>
<TextBlock Text="相机状态" FontSize="15" Foreground="#31446E" Margin="2,0,10,0"/>
</StackPanel>
</Grid>
</StackPanel>
<StackPanel Grid.Column="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<Ellipse Width="30" Height="30">
<Ellipse.Style>
<Style TargetType="Ellipse">
<Style.Triggers>
<DataTrigger Binding="{Binding PlcStatus}" Value="0">
<Setter Property="Shape.Fill" Value="Orange"/>
</DataTrigger>
<DataTrigger Binding="{Binding PlcStatus}" Value="1">
<Setter Property="Shape.Fill" Value="Green"/>
</DataTrigger>
<DataTrigger Binding="{Binding PlcStatus}" Value="2">
<Setter Property="Shape.Fill" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
</Ellipse>
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Text="PLC状态" FontSize="15" Foreground="#FFFFFF" Margin="2,0,10,0"/>
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</StackPanel>

@ -0,0 +1,55 @@
<UserControl x:Class="SlnMesnac.WPF.Page.History.HistoryControl"
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:SlnMesnac.WPF.Page.History"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="14*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="#EBF4FD" BorderThickness="2" CornerRadius="10" Background="#EBF4FD" Margin="10,10">
<StackPanel Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
<TextBlock Text="RFID" FontSize="18" Foreground="#31446E" Margin="10,3"/>
<TextBox Text="{Binding TagCode}" FontSize="24" Grid.Row="1" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5">
<TextBox.Template>
<ControlTemplate TargetType="TextBox">
<Border Background="White" BorderBrush="White" BorderThickness="1" CornerRadius="5">
<ScrollViewer x:Name="PART_ContentHost" />
</Border>
</ControlTemplate>
</TextBox.Template>
</TextBox>
<TextBlock Text="扫描时间" FontSize="18" Foreground="#31446E" Margin="20,3,10,0"/>
<DatePicker x:Name="BeginTimeDatePicker" Width="120" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock Text="-" FontSize="18" Foreground="#31446E" Margin="10,3"/>
<DatePicker x:Name="EndTimeDatePicker" Width="120" VerticalAlignment="Center" Margin="0,0,5,0"/>
<Button Content="查 询" Command="{Binding QueryCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#5095F3" BorderBrush="#5095F3" Margin="10,0,10,0"/>
<Button Content="导 出" Command="{Binding ExportCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
</StackPanel>
</Border>
<Border Grid.Row="1" BorderBrush="#EBF4FD" BorderThickness="2" CornerRadius="10" Background="#EBF4FD" Margin="10,10">
<DataGrid Grid.Row="0" ItemsSource="{Binding ScanItems}" Background="Transparent"
FontSize="18" ColumnHeaderHeight="35"
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="#31446E" x:Name="dataGrid" Margin="0,10,0,0" >
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding CreateTime ,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="记录时间" Width="1.5*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Rfid}" Header="RFID" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Code}" Header="ATR" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Ocr}" Header="OCR" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding url}" Header="图像路径" Width="2*" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
</Border>
</Grid>
</UserControl>

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace SlnMesnac.WPF.Page.History
{
/// <summary>
/// HistoryControl.xaml 的交互逻辑
/// </summary>
public partial class HistoryControl : UserControl
{
public HistoryControl()
{
InitializeComponent();
}
}
}

@ -0,0 +1,177 @@
<UserControl x:Class="SlnMesnac.WPF.Page.IndexControl"
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:SlnMesnac.WPF.Page"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent">
<UserControl.Resources>
<DataTemplate x:Key="LogMsgTemplate">
<TextBlock Text="{Binding}" FontSize="16" Foreground="#31446E" TextWrapping="Wrap" MaxWidth="400"/>
</DataTemplate>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="5*"/>
<RowDefinition Height="6*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" CornerRadius="10" Margin="3">
<Border.Background>
<ImageBrush ImageSource="/Templates/image/left.png"/>
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="条码信息" FontSize="24" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="30,0,0,0"/>
<TextBox Text="{Binding TagCode}" FontSize="24" Grid.Row="1" Width="240" Height="70" Margin="10" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5">
<TextBox.Template>
<ControlTemplate TargetType="TextBox">
<Border Background="White" BorderBrush="White" BorderThickness="1" CornerRadius="10">
<ScrollViewer x:Name="PART_ContentHost" />
</Border>
</ControlTemplate>
</TextBox.Template>
</TextBox>
</Grid>
</Border>
<Border Grid.Column="1" CornerRadius="10" Margin="3">
<Border.Background>
<ImageBrush ImageSource="/Templates/image/right.png"/>
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="条码总数" FontSize="24" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="30,0,0,0"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="{Binding TagAmount}" FontSize="24" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock Text="个" FontSize="24" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel>
</Grid>
</Border>
</Grid>
</Border>
<Border Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" CornerRadius="10" Background="#EBF4FD" Margin="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="14*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="识别率" FontSize="18" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20,0,0,0"/>
<Border Grid.Row="1" BorderBrush="Red" BorderThickness="0" Margin="5,5">
<lvc:Gauge Margin="5" Uses360Mode="True" From="0" To="100" Value="{Binding PassRate}" Foreground="#0288d1"/>
</Border>
</Grid>
</Border>
<Border Grid.Column="1" CornerRadius="10" Background="#EBF4FD" Margin="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="14*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="效率" FontSize="18" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20,0,0,0"/>
<Border Grid.Row="1" BorderBrush="Red" BorderThickness="0" Margin="10,5">
<lvc:CartesianChart Series="{Binding RecogEfficiency, UpdateSourceTrigger=PropertyChanged}">
<lvc:CartesianChart.AxisX>
<lvc:Axis Labels="{Binding AxisX}" FontSize="15" Foreground="#0288d1" MinValue="0"/>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="15" Foreground="#0288d1"/>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
</Border>
</Grid>
</Border>
</Grid>
</Border>
</Grid>
</Border>
<Border Grid.Column="1" CornerRadius="10" Background="#EBF4FD" Margin="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="22*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="全景图像" FontSize="18" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20,0,0,0"/>
<Border Grid.Row="1" BorderBrush="Red" BorderThickness="0" Margin="5,10">
<Image Grid.Row="1" Source="{Binding ImagePath}" />
</Border>
</Grid>
</Border>
</Grid>
</Border>
<Border Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="7*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" CornerRadius="10" Background="#EBF4FD" Margin="10">
<DataGrid Grid.Row="0" ItemsSource="{Binding ScanItems}" Background="Transparent"
FontSize="16" ColumnHeaderHeight="35"
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="#31446E" x:Name="dataGrid" Margin="10,0,10,0">
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding CreateTime ,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="记录时间" Width="1.5*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Rfid}" Header="RFID" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Code}" Header="ATR" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Ocr}" Header="OCR" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Url}" Header="图像路径" Width="2*" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
</Border>
<Border Grid.Column="1" CornerRadius="10" Background="#EBF4FD" Margin="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="14*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="设备监控日志" FontSize="18" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20,0,0,0"/>
<Border Grid.Row="1" BorderBrush="#E0E9F2" BorderThickness="0,2,0,0" Margin="5,5">
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding LogMessages}" ItemTemplate="{StaticResource LogMsgTemplate}" />
</ScrollViewer>
</Border>
</Grid>
</Border>
</Grid>
</Border>
</Grid>
</UserControl>

@ -0,0 +1,32 @@
using SlnMesnac.Model.domain;
using SlnMesnac.WPF.ViewModel;
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 SlnMesnac.WPF.Page
{
/// <summary>
/// IndexControl.xaml 的交互逻辑
/// </summary>
public partial class IndexControl : UserControl
{
public IndexControl()
{
InitializeComponent();
this.DataContext = new IndexViewModel();
}
}
}

@ -10,6 +10,8 @@
<ItemGroup>
<None Remove="appsettings.json" />
<None Remove="Templates\image\background.jpg" />
<None Remove="Templates\image\left.png" />
<None Remove="Templates\image\right.png" />
</ItemGroup>
<ItemGroup>
@ -33,7 +35,10 @@
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.1" />
<PackageReference Include="Lierda.WPFHelper" Version="1.0.3" />
<PackageReference Include="LiveCharts" Version="0.9.7" />
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
<PackageReference Include="MvvmLightLibs" Version="5.4.1.1" />
<PackageReference Include="NVelocity" Version="1.2.0" />
<PackageReference Include="WindowsAPICodePack-Shell" Version="1.1.1" />
@ -41,10 +46,8 @@
<ItemGroup>
<Resource Include="Templates\image\background.jpg" />
</ItemGroup>
<ItemGroup>
<Folder Include="Page\" />
<Resource Include="Templates\image\left.png" />
<Resource Include="Templates\image\right.png" />
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

@ -0,0 +1,213 @@

using CommunityToolkit.Mvvm.ComponentModel;
using LiveCharts;
using LiveCharts.Wpf;
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Business;
using SlnMesnac.Model.domain;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* T14-GEN3-7895
* SlnMesnac.WPF.ViewModel
* 9e7a55b1-ef98-4957-9a44-16dd251c4b5c
*
* WenJY
*
* 2024-09-18 10:46:52
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.WPF.ViewModel
{
public class IndexViewModel : ObservableObject
{
private TagScanBusiness tagScanBusiness;
public IndexViewModel()
{
tagScanBusiness = App.ServiceProvider.GetService<TagScanBusiness>();
this.Init();
this.RefreshScanInfo();
}
private void Init()
{
PassRate = 30;
// 初始化数据
RecogEfficiency = new SeriesCollection
{
new LineSeries
{
Title = "Achievement",
Values = new ChartValues<double> { 3, 5, 7, 2 } // 示例数据
}
};
AxisX = new ObservableCollection<string> { "8", "12", "16", "20" };
RefreshLogMessage($"1#站台任务下发站台任务下发站台任务下发站台任务下发站台任务下发站台任务下发");
ScanItems = new ObservableCollection<ScanLogModel>();
}
/// <summary>
/// 条码信息
/// </summary>
public string _tagCode;
public string TagCode
{
get => _tagCode;
set => SetProperty(ref _tagCode, value);
}
/// <summary>
/// 条码总数
/// </summary>
public int _tagAmount;
public int TagAmount
{
get => _tagAmount;
set => SetProperty(ref _tagAmount, value);
}
/// <summary>
/// 合格率
/// </summary>
public int _passRate;
public int PassRate
{
get => _passRate;
set => SetProperty(ref _passRate, value);
}
/// <summary>
/// 效率数值
/// </summary>
private SeriesCollection _recogEfficiency;
public SeriesCollection RecogEfficiency
{
get => _recogEfficiency;
set => SetProperty(ref _recogEfficiency, value);
}
/// <summary>
/// 效率曲线X坐标
/// </summary>
private ObservableCollection<string> _axisX;
public ObservableCollection<string> AxisX
{
get => _axisX;
set => SetProperty(ref _axisX, value);
}
/// <summary>
/// 图像路径
/// </summary>
private string _imagePath;
public string ImagePath
{
get => _imagePath;
set => SetProperty(ref _imagePath, value);
}
/// <summary>
/// 日志信息
/// </summary>
private ObservableCollection<string> _logMessages = new ObservableCollection<string>();
public ObservableCollection<string> LogMessages
{
get => _logMessages;
set => SetProperty(ref _logMessages, value);
}
/// <summary>
/// 扫描记录
/// </summary>
private ObservableCollection<ScanLogModel> _scanItems = new ObservableCollection<ScanLogModel>();
public ObservableCollection<ScanLogModel> ScanItems
{
get => _scanItems;
set => SetProperty(ref _scanItems, value);
}
private void RefreshScanInfo()
{
tagScanBusiness.RefreshTagScanInfoEvent += info =>
{
App.Current.Dispatcher.Invoke(() =>
{
TagCode = info.Rfid;
ImagePath = info.Url;
string fileName = Path.GetFileName(info.Url);
info.Url = fileName;
ScanItems.Add(info);
TagAmount++;
});
};
}
private ObservableCollection<string> listItems = new ObservableCollection<string>();
/// <summary>
/// 系统运行日志输出
/// </summary>
/// <param name="message"></param>
private async void RefreshLogMessage(string message)
{
await Task.Run(() =>
{
try
{
string formattedMessage = $"{DateTime.Now.ToString("HH:mm:ss.ss")} ==> {message}";
lock (listItems)
{
listItems.Add(formattedMessage);
while (listItems.Count > 120)
{
listItems.RemoveAt(0);
}
var orderedList = listItems.OrderByDescending(x => x).ToList(); // 排序后转为 List
App.Current.Dispatcher.Invoke(() =>
{
LogMessages = new ObservableCollection<string>(orderedList); // 更新 UI
});
}
}
catch (Exception ex)
{
//_logger.LogError($"日志数据绑定异常:{ex.Message}");
}
});
}
}
}

@ -2,6 +2,8 @@
using GalaSoft.MvvmLight.Command;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SlnMesnac.WPF.Page;
using SlnMesnac.WPF.Page.History;
using System;
using System.Windows;
@ -11,6 +13,9 @@ namespace SlnMesnac.WPF.ViewModel
{
private readonly ILogger<MainWindowViewModel> _logger;
private IndexControl indexControl = new IndexControl();
private HistoryControl historyControl = new HistoryControl();
#region 参数定义
/// <summary>
/// PLC设备状态
@ -82,6 +87,8 @@ namespace SlnMesnac.WPF.ViewModel
ControlOnClickCommand = new RelayCommand<object>(obj => ControlOnClick(obj));
FormControlCommand = new RelayCommand<object>(x => FormControl(x));
UserContent = indexControl;
}
/// <summary>
@ -139,7 +146,15 @@ namespace SlnMesnac.WPF.ViewModel
try
{
string info = obj as string;
//UserContent = inStoreInfoControl;
switch (info)
{
case "Index":
UserContent = indexControl; break;
case "History":
UserContent = historyControl; break;
//historyControl
default: break;
}
}
catch (Exception ex)
{

@ -8,7 +8,7 @@
},
"AllowedHosts": "*",
"AppConfig": {
"logPath": "E:\\桌面\\SlnMesnac\\SlnMesnac.WPF\\bin\\Debug\\net6.0-windows",
"logPath": "F:\\桌面\\RFID+ATR识别项目\\日志信息",
"SqlConfig": [
{
"configId": "mes",

Loading…
Cancel
Save