From 15492363f898704b51afce5f1c88fa3b754cbabc Mon Sep 17 00:00:00 2001
From: C3032 <C3032@BC3032>
Date: 星期六, 20 十二月 2025 16:25:31 +0800
Subject: [PATCH] 添加项目文件。
---
IDViewer_2D/软件需求规格说明书.md | 339 +
IDViewer_2D/Image/Currency/刷新.png | 0
IDViewer_2D/Image/testImages/20220719092357348.jpg | 0
IDViewer_2D/LoadingWindow.xaml.cs | 27
IDViewer_2D/Image/Currency/logo_02.png | 0
IDViewer_2D/Image/ICON/camera-switch-fill.png | 0
IDViewer_2D/ImageDisplayWindow .xaml.cs | 125
IDViewer_2D/LBProjService.cs | 131
IDViewer_2D/IDViewerSDK1.cs | 230
IDViewer_2D/OperateLog/OperateLogView.xaml.cs | 60
IDViewer_2D/Properties/AssemblyInfo.cs | 55
TCP通讯数据格式说明.xlsx | 0
IDViewer_2D/LogAutoSaveService.cs | 284 +
IDViewer_2D/Image/Currency/logo_01.png | 0
IDViewer_2D/ViewModel/LogViewModel.cs | 182
IDViewer_2D/TcpServerManager.cs | 272 +
IDViewer_2D/DownloadData.xaml.cs | 309 +
IDViewer_2D/IDViewer2D.ico | 0
IDViewer_2D/Properties/Settings.settings | 45
IDViewer_2D/AppRestartHelper.cs | 102
IDViewer_2D/Image/Currency/单张抓图.png | 0
IDViewer_2D/Image/Currency/连接.png | 0
IDViewer_2D/Image/ICON/folder-2-fill.png | 0
IDViewer_2D/ResultJudge.xaml | 68
SmartScanner.sln | 37
IDViewer_2D/SmartScanner.csproj | 365 +
IDViewer_2D/Image/ICON/folder-open-fill.png | 0
IDViewer_2D/Image/testImages/20220706201152065.jpg | 0
IDViewer_2D/Image/Currency/连续抓图.png | 0
IDViewer_2D/IDViewerSDK2.cs | 54
.vsconfig | 44
IDViewer_2D/Properties/Resources.resx | 117
IDViewer_2D/OperateLog/OperateLogService.cs | 69
IDViewer_2D/ImageService/ImageCleanupService.cs | 94
IDViewer_2D/ProductManager.xaml.cs | 216
IDViewer_2D/LoginWindow.xaml | 29
IDViewer_2D/Image/testImages/20221018190453100.jpg | 0
IDViewer_2D/Image/Currency/暂停.png | 0
IDViewer_2D/Image/Currency/logo.png | 0
IDViewer_2D/OperateLog/OperateLogView.xaml | 19
IDViewer_2D/MainWindow.xaml.cs | 3494 ++++++++++++++
IDViewer_2D/Image/testImages/20221013101729295.jpg | 0
IDViewer_2D/App.xaml.cs | 17
IDViewer_2D/MainWindow.xaml | 915 +++
IDViewer_2D/Image/ICON/import-fill.png | 0
IDViewer_2D/ResultJudge.xaml.cs | 384 +
IDViewer_2D/ImageDisplayWindow .xaml | 41
IDViewer_2D/LoadingWindow.xaml | 14
IDViewer_2D/Image/Currency/采集.png | 0
IDViewer_2D/User.cs | 50
IDViewer_2D/IDViewerDemo.csproj | 79
IDViewer_2D/Properties/Settings.Designer.cs | 182
IDViewer_2D/IDViewerDefines.cs | 2259 +++++++++
IDViewer_2D/DownloadData.xaml | 216
IDViewer_2D/LogAutoSaveService_Optimized.cs | 284 +
IDViewer_2D/$null | 1
IDViewer_2D/Image/Currency/删除.png | 0
安装脚本.iss | 58
IDViewer_2D/IDViewerDefines1.cs | 452 +
集成相机软件功能列表.xlsx | 0
IDViewer_2D/LBProtect.cs | 134
IDViewer_2D/Image/ICON/link-m.png | 0
IDViewer_2D/ModbusTCPClient.cs | 197
IDViewer_2D/VersionHelper.cs | 95
IDViewer_2D/ExcelResultRecorder.cs | 198
IDViewer_2D/Properties/Resources.Designer.cs | 63
IDViewer_2D/App.config | 70
IDViewer_2D/App.xaml | 9
IDViewer_2D/Image/Currency/开始采集.jpg | 0
IDViewer_2D/Image/Currency/宣传图.png | 0
IDViewer_2D/Image/Currency/存储图片.png | 0
IDViewer_2D/Image/Currency/断开.png | 0
IDViewer_2D/Image/testImages/20220706201141516.jpg | 0
版本说明.txt | 99
IDViewer_2D/ProductManager.xaml | 60
IDViewer_2D/Image/Currency/打开文件.png | 0
IDViewer_2D/LoginWindow.xaml.cs | 50
IDViewer_2D/IDViewerSDK.cs | 1030 ++++
IDViewer_2D/Settings.cs | 28
IDViewer_2D/ImageService/MemoryAlarmCheck.cs | 24
IDViewer_2D/Program.cs | 266 +
IDViewer_2D/Image/Currency/MTV3Dlogo.ico | 0
软件功能列表.xlsx | 0
IDViewer_2D/packages.config | 23
84 files changed, 14,065 insertions(+), 0 deletions(-)
diff --git a/.vsconfig b/.vsconfig
new file mode 100644
index 0000000..2d418d2
--- /dev/null
+++ b/.vsconfig
@@ -0,0 +1,44 @@
+{
+ "version": "1.0",
+ "components": [
+ "Microsoft.VisualStudio.Component.CoreEditor",
+ "Microsoft.VisualStudio.Workload.CoreEditor",
+ "Microsoft.VisualStudio.Component.NuGet",
+ "Microsoft.Net.Component.4.6.1.TargetingPack",
+ "Microsoft.VisualStudio.Component.Roslyn.Compiler",
+ "Microsoft.VisualStudio.Component.Roslyn.LanguageServices",
+ "Microsoft.VisualStudio.Component.FSharp",
+ "Microsoft.ComponentGroup.ClickOnce.Publish",
+ "Microsoft.NetCore.Component.DevelopmentTools",
+ "Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions",
+ "Microsoft.Net.Component.4.8.SDK",
+ "Microsoft.Net.Component.4.7.2.TargetingPack",
+ "Microsoft.Net.ComponentGroup.DevelopmentPrerequisites",
+ "Microsoft.VisualStudio.Component.TypeScript.4.3",
+ "Microsoft.VisualStudio.Component.JavaScript.TypeScript",
+ "Microsoft.Component.MSBuild",
+ "Microsoft.VisualStudio.Component.TextTemplating",
+ "Microsoft.VisualStudio.Component.Common.Azure.Tools",
+ "Microsoft.VisualStudio.Component.SQL.CLR",
+ "Microsoft.VisualStudio.Component.ManagedDesktop.Core",
+ "Microsoft.Net.Component.4.5.2.TargetingPack",
+ "Microsoft.Net.Component.4.5.TargetingPack",
+ "Microsoft.Net.Component.4.TargetingPack",
+ "Microsoft.Net.Component.4.5.1.TargetingPack",
+ "Microsoft.Net.Component.4.6.TargetingPack",
+ "Microsoft.Net.ComponentGroup.TargetingPacks.Common",
+ "Microsoft.VisualStudio.Component.DiagnosticTools",
+ "Microsoft.VisualStudio.Component.EntityFramework",
+ "Microsoft.VisualStudio.Component.Debugger.JustInTime",
+ "Component.Microsoft.VisualStudio.LiveShare",
+ "Microsoft.VisualStudio.Component.IntelliCode",
+ "Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites",
+ "Microsoft.ComponentGroup.Blend",
+ "Microsoft.VisualStudio.Component.DotNetModelBuilder",
+ "Microsoft.VisualStudio.Workload.ManagedDesktop",
+ "Microsoft.Component.ClickOnce"
+ ],
+ "extensions": [
+ "https://marketplace.visualstudio.com/items?itemName=VisualStudioClient.MicrosoftVisualStudio2017InstallerProjects"
+ ]
+}
\ No newline at end of file
diff --git a/IDViewer_2D/$null b/IDViewer_2D/$null
new file mode 100644
index 0000000..ce3e5ba
--- /dev/null
+++ b/IDViewer_2D/$null
@@ -0,0 +1 @@
+Active code page: 65001
diff --git a/IDViewer_2D/App.config b/IDViewer_2D/App.config
new file mode 100644
index 0000000..dc924ad
--- /dev/null
+++ b/IDViewer_2D/App.config
@@ -0,0 +1,70 @@
+锘�<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <configSections>
+ <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <section name="SmartScanner.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
+ </startup>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Syncfusion.Licensing" publicKeyToken="632609b4d040f6b4" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-29.1462.37.0" newVersion="29.1462.37.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Drawing.Common" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+ <userSettings>
+ <SmartScanner.Properties.Settings>
+ <setting name="LastConfigFilePath" serializeAs="String">
+ <value />
+ </setting>
+ <setting name="DataSavingRoad" serializeAs="String">
+ <value />
+ </setting>
+ <setting name="ImageDeleteEnabled" serializeAs="String">
+ <value>False</value>
+ </setting>
+ <setting name="DeleteImageDays" serializeAs="String">
+ <value>30</value>
+ </setting>
+ <setting name="ImageSaveEnabled" serializeAs="String">
+ <value>True</value>
+ </setting>
+ <setting name="CompressionRatio" serializeAs="String">
+ <value>0</value>
+ </setting>
+ <setting name="ImageFormatSelect" serializeAs="String">
+ <value>0</value>
+ </setting>
+ <setting name="MemoryAlarmSetting" serializeAs="String">
+ <value>20</value>
+ </setting>
+ <setting name="MemoryAlarmEnabled" serializeAs="String">
+ <value>False</value>
+ </setting>
+ <setting name="OutputCheckBoxEnable" serializeAs="String">
+ <value>False</value>
+ </setting>
+ <setting name="DefaultPort" serializeAs="String">
+ <value>"8080"</value>
+ </setting>
+ <setting name="SelectedPort" serializeAs="String">
+ <value>8080</value>
+ </setting>
+ <setting name="LastConfigFilePath_Proj" serializeAs="String">
+ <value />
+ </setting>
+ </SmartScanner.Properties.Settings>
+ </userSettings>
+</configuration>
diff --git a/IDViewer_2D/App.xaml b/IDViewer_2D/App.xaml
new file mode 100644
index 0000000..b324d8f
--- /dev/null
+++ b/IDViewer_2D/App.xaml
@@ -0,0 +1,9 @@
+锘�<Application x:Class="SmartScanner.App"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:local="clr-namespace:SmartScanner"
+ StartupUri="MainWindow.xaml">
+ <Application.Resources>
+
+ </Application.Resources>
+</Application>
diff --git a/IDViewer_2D/App.xaml.cs b/IDViewer_2D/App.xaml.cs
new file mode 100644
index 0000000..342681a
--- /dev/null
+++ b/IDViewer_2D/App.xaml.cs
@@ -0,0 +1,17 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SmartScanner
+{
+ /// <summary>
+ /// App.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ public partial class App : Application
+ {
+ }
+}
diff --git a/IDViewer_2D/AppRestartHelper.cs b/IDViewer_2D/AppRestartHelper.cs
new file mode 100644
index 0000000..46505d5
--- /dev/null
+++ b/IDViewer_2D/AppRestartHelper.cs
@@ -0,0 +1,102 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SmartScanner
+{
+ public static class AppRestartHelper
+ {
+ private const string TaskName = "MyApp_Restart_Task";
+
+ public static async Task RestartAsync()
+ {
+ try
+ {
+ // 1. 鍒涘缓涓存椂鎵瑰鐞嗘枃浠�
+ string batPath = CreateRestartBatchFile();
+
+ // 2. 鍒涘缓浠诲姟璁″垝
+ CreateScheduledTask(batPath);
+
+ // 3. 寤惰繜纭繚浠诲姟宸叉敞鍐�
+ await Task.Delay(500);
+
+ // 4. 鎵ц浠诲姟骞堕��鍑哄綋鍓嶅疄渚�
+ ExecuteRestartTask();
+
+ Application.Current.Shutdown();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"閲嶅惎澶辫触: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private static string CreateRestartBatchFile()
+ {
+ string tempPath = Path.GetTempPath();
+ string batPath = Path.Combine(tempPath, $"{Guid.NewGuid()}_restart.bat");
+
+ string exePath = Process.GetCurrentProcess().MainModule.FileName;
+ string workingDir = Path.GetDirectoryName(exePath);
+
+ string batContent = $@"
+@echo off
+timeout /t 1 /nobreak > nul
+cd /d ""{workingDir}""
+start """" ""{exePath}""
+del ""%~f0""
+";
+
+ File.WriteAllText(batPath, batContent);
+ return batPath;
+ }
+
+ private static void CreateScheduledTask(string batPath)
+ {
+ // 鍒犻櫎鍙兘瀛樺湪鐨勬棫浠诲姟
+ DeleteExistingTask();
+
+ // 鍒涘缓鏂颁换鍔�
+ ProcessStartInfo psi = new ProcessStartInfo
+ {
+ FileName = "schtasks.exe",
+ Arguments = $"/Create /TN \"{TaskName}\" /TR \"{batPath}\" /SC ONCE /ST {DateTime.Now.AddSeconds(1):HH:mm:ss} /F",
+ WindowStyle = ProcessWindowStyle.Hidden,
+ CreateNoWindow = true
+ };
+
+ Process.Start(psi)?.WaitForExit(2000);
+ }
+
+ private static void ExecuteRestartTask()
+ {
+ Process.Start(new ProcessStartInfo
+ {
+ FileName = "schtasks.exe",
+ Arguments = $"/Run /TN \"{TaskName}\"",
+ WindowStyle = ProcessWindowStyle.Hidden,
+ CreateNoWindow = true
+ })?.WaitForExit(1000);
+
+ // 鍒犻櫎浠诲姟
+ DeleteExistingTask();
+ }
+
+ private static void DeleteExistingTask()
+ {
+ Process.Start(new ProcessStartInfo
+ {
+ FileName = "schtasks.exe",
+ Arguments = $"/Delete /TN \"{TaskName}\" /F",
+ WindowStyle = ProcessWindowStyle.Hidden,
+ CreateNoWindow = true
+ })?.WaitForExit(1000);
+ }
+ }
+}
diff --git a/IDViewer_2D/DownloadData.xaml b/IDViewer_2D/DownloadData.xaml
new file mode 100644
index 0000000..3e3e675
--- /dev/null
+++ b/IDViewer_2D/DownloadData.xaml
@@ -0,0 +1,216 @@
+锘�<Window x:Class="SmartScanner.DownloadData"
+ 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:SmartScanner"
+ xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
+ xmlns:Properties="clr-namespace:SmartScanner.Properties"
+ mc:Ignorable="d"
+ Width="490" Height="320"
+ Title="鍥惧儚璁剧疆">
+
+ <Grid Background="#3C3C3C">
+ <Grid.Resources>
+ <Style x:Key="TextBoxStyle" TargetType="TextBox">
+ <Style.Setters>
+ <Setter Property="VerticalContentAlignment" Value="Center"/>
+ <Setter Property="HorizontalContentAlignment" Value="Right"/>
+ <Setter Property="Background" Value="#6C6C6C"/>
+ <Setter Property="BorderBrush" Value="#1F0000"/>
+ <Setter Property="Foreground" Value="White"/>
+ <Setter Property="BorderThickness" Value="1"/>
+ </Style.Setters>
+ </Style>
+ <Style TargetType="RadioButton" x:Key="RadioButtonStyle">
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="RadioButton">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+ <VisualStateManager.VisualStateGroups>
+ <VisualStateGroup x:Name="CheckStates">
+ <VisualState x:Name="Checked">
+ <Storyboard>
+ <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="contentPresenter">
+ <EasingColorKeyFrame KeyTime="0" Value="White"/>
+ </ColorAnimationUsingKeyFrames>
+ </Storyboard>
+ </VisualState>
+ <VisualState x:Name="Unchecked"/>
+ <VisualState x:Name="Indeterminate"/>
+ </VisualStateGroup>
+ </VisualStateManager.VisualStateGroups>
+ <Ellipse Width="{Binding ActualHeight, ElementName=contentPresenter}" Height="{Binding ActualHeight, ElementName=contentPresenter}" Fill="{TemplateBinding Background}"/>
+ <ContentPresenter x:Name="contentPresenter" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+ </Grid>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+ <Style x:Key="BtnLabelStyle">
+ <Style.Triggers>
+ <Trigger Property="Button.IsFocused" Value="False">
+ <Setter Property="Button.Background" Value="Transparent"/>
+ <Setter Property="Button.BorderThickness" Value="0"/>
+ </Trigger>
+ <Trigger Property="Button.IsFocused" Value="True">
+ <Setter Property="Button.Background" Value="#4D0000"/>
+ <Setter Property="Button.BorderThickness" Value="0"/>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ <Style x:Key="LabelStyle">
+ <Style.Triggers>
+ <Trigger Property="Label.IsFocused" Value="False">
+ <Setter Property="Label.Background" Value="Transparent"/>
+ <Setter Property="Label.Foreground" Value="White"/>
+ </Trigger>
+ <Trigger Property="Label.IsFocused" Value="True">
+ <Setter Property="Label.Background" Value="#FFBEE6FD"/>
+ <Setter Property="Label.Foreground" Value="#4F4F4F"/>
+ </Trigger>
+ <Trigger Property="Label.IsMouseOver" Value="True">
+ <Setter Property="Label.Background" Value="#FFBEE6FD"/>
+ <Setter Property="Label.Foreground" Value="#4F4F4F"/>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ <Style x:Key="FocusVisual">
+ <Setter Property="Control.Template">
+ <Setter.Value>
+ <ControlTemplate>
+ <Rectangle Margin="2" StrokeDashArray="1 2" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" SnapsToDevicePixels="true" StrokeThickness="1"/>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+ <!--鎸夐挳闈欐�佹椂鑳屾櫙棰滆壊-->
+ <SolidColorBrush x:Key="Button.Static.Background" Color="#4F4F4F"/>
+ <!--鎸夐挳闈欐�佹椂杈规棰滆壊-->
+ <SolidColorBrush x:Key="Button.Static.Border" Color="#2F0000"/>
+ <!--鎸夐挳闈欐�佹椂鏂囧瓧棰滆壊-->
+ <SolidColorBrush x:Key="Button.Static.Foreground" Color="White"/>
+ <!--榧犳爣绉诲叆鏃惰儗鏅鑹�-->
+ <SolidColorBrush x:Key="Button.MouseOver.Background" Color="#4D0000"/>
+ <!--榧犳爣绉诲叆鏃惰竟妗嗛鑹�-->
+ <SolidColorBrush x:Key="Button.MouseOver.Border" Color="#2F0000"/>
+ <!--榧犳爣鎸変笅鏃惰儗鏅鑹�-->
+ <SolidColorBrush x:Key="Button.Pressed.Background" Color="#4D0000"/>
+ <!--榧犳爣鎸変笅鏃惰竟妗嗛鑹�-->
+ <SolidColorBrush x:Key="Button.Pressed.Border" Color="#2F0000"/>
+ <!--鎸夐挳涓嶄娇鐢ㄦ椂鑳屾櫙棰滆壊-->
+ <SolidColorBrush x:Key="Button.Disabled.Background" Color="Gray"/>
+ <!--鎸夐挳涓嶄娇鐢ㄦ椂杈规棰滆壊-->
+ <SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/>
+ <!--鎸夐挳涓嶄娇鐢ㄦ椂鏂囧瓧棰滆壊-->
+ <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="White"/>
+ <Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
+ <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
+ <Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
+ <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
+ <Setter Property="Foreground" Value="{StaticResource Button.Static.Foreground}"/>
+ <Setter Property="BorderThickness" Value="1"/>
+ <!--杈规瀹藉害锛岃缃负0 鍗筹細鏃犺竟妗�-->
+ <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" CornerRadius="5" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true">
+ <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+ </Border>
+ <!--瑙﹀彂鍣細鏍规嵁渚濊禆灞炴�х殑鍊煎幓鎺у埗鎺т欢鐨勭姸鎬�-->
+ <ControlTemplate.Triggers>
+ <!--榛樿灞炴��-->
+ <Trigger Property="IsDefaulted" Value="true">
+ <!--<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>-->
+ <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Static.Background}"/>
+ <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Static.Border}"/>
+ <Setter Property="TextElement.Foreground" TargetName="border" Value="{StaticResource Button.Static.Foreground}"/>
+ </Trigger>
+ <!--榧犳爣绉诲叆灞炴��-->
+ <Trigger Property="IsMouseOver" Value="true">
+ <Setter Property="Background" TargetName="border" Value="{StaticResource Button.MouseOver.Background}"/>
+ <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/>
+ </Trigger>
+ <!--榧犳爣鎸変笅灞炴��-->
+ <Trigger Property="IsPressed" Value="true">
+ <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
+ <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
+ </Trigger>
+ <!--鎸夐挳鍙敤鐘舵�佸睘鎬�-->
+ <Trigger Property="IsEnabled" Value="false">
+ <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
+ <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
+ <!--<Setter Property="Foreground" TargetName="border" Value="{StaticResource Button.Disabled.Foreground}"/>-->
+ <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
+ </Trigger>
+ </ControlTemplate.Triggers>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+ </Grid.Resources>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="70"/>
+ <RowDefinition Height="160"/>
+ <RowDefinition Height="40"/>
+ </Grid.RowDefinitions>
+ <StackPanel Grid.Row="0">
+ <Label Content="璺緞閫夋嫨:" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White" Height="35"/>
+ <StackPanel Orientation="Horizontal" Height="35">
+ <TextBox Name="SetDataSavingRoad" Text="{Binding Source={x:Static Properties:Settings.Default}, Path=DataSavingRoad, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
+ HorizontalContentAlignment="Left" Height="30" FontSize="14" ToolTip="鏂囦欢瀛樺偍璺緞" Width="400" Margin="10,0,0,0" MouseDoubleClick="SetDataSavingRoad_MouseDoubleClick"/>
+ <Button Name="SelectFilePath" Content="娴忚鈥�" Width="50" Height="30" Click="SelectFilePath_Click" Style="{DynamicResource ButtonStyle}"/>
+ </StackPanel>
+ </StackPanel>
+ <StackPanel Grid.Row="1">
+ <StackPanel Orientation="Horizontal" Height="35">
+ <Label Content="淇濆瓨璁剧疆:" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White" Width="100"/>
+ </StackPanel>
+ <StackPanel Orientation="Horizontal" Height="35">
+ <CheckBox Name="ImageDeleteCheck" Content="瀹氭湡娓呭浘" IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=ImageDeleteEnabled, Mode=TwoWay}" Unchecked="ImageDeleteCheck_Unchecked" Checked="ImageDeleteCheck_Checked" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White" Width="130" Margin="20,0,0,0"/>
+ <toolkit:IntegerUpDown x:Name="Data_deleteImage" FormatString="N" Increment="1" Maximum="200000"
+ Value="{Binding Source={x:Static Properties:Settings.Default}, Path=DeleteImageDays, Mode=TwoWay}"
+ LostFocus="Data_deleteImage_LostFocus" Width="100" Height="25"/>
+ <Label Content="澶�" Foreground="White" VerticalAlignment="Center"/>
+ </StackPanel>
+ <StackPanel Orientation="Horizontal" Height="35">
+ <StackPanel Orientation="Horizontal" Width="300">
+ <CheckBox Name="ImageSaveCheck" Content="鍚敤鍥惧儚淇濆瓨" IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=ImageSaveEnabled, Mode=TwoWay}"
+ Unchecked="ImageSaveCheck_Unchecked" Checked="ImageSaveCheck_Checked"
+ HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White" Width="130" Margin="20,0,0,0"/>
+ <Label Content="淇濆瓨鏍煎紡" Foreground="White" VerticalAlignment="Center"/>
+ <ComboBox Name="ImageFormat" SelectedIndex="{Binding Source={x:Static Properties:Settings.Default}, Path=ImageFormatSelect, Mode=TwoWay}"
+ Height="25" SelectionChanged="ImageFormat_SelectionChanged" LostFocus="ImageFormat_LostFocus">
+ <ComboBoxItem Content=".BMP"/>
+ <ComboBoxItem Content=".JPG"/>
+ <ComboBoxItem Content=".PNG"/>
+ </ComboBox>
+ </StackPanel>
+ <StackPanel x:Name="CompressionVisible" Orientation="Horizontal" Visibility="Visible">
+ <Label Content="鍘嬬缉姣旂巼" Foreground="White" VerticalAlignment="Center"/>
+ <toolkit:IntegerUpDown x:Name="ImageCompressionRatio" FormatString="N" Increment="1" Maximum="10" Minimum="0" UpdateValueOnEnterKey="True"
+ Value="{Binding Source={x:Static Properties:Settings.Default}, Path=CompressionRatio, Mode=TwoWay}"
+ Watermark="鍙栧�糩0-10]" Width="85" Height="25" LostFocus="ImageCompressionRatio_LostFocus"/>
+ </StackPanel>
+ </StackPanel>
+ <StackPanel Orientation="Horizontal" Height="35">
+ <CheckBox Name="MemoryAlarmCheck" Content="瀛樺偍绌洪棿棰勮" IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=MemoryAlarmEnabled, Mode=TwoWay}"
+ Unchecked="MemoryAlarmCheck_Unchecked" Checked="MemoryAlarmCheck_Checked" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White" Width="130" Margin="20,0,0,0"/>
+ <toolkit:IntegerUpDown x:Name="MemoryAlarm" FormatString="N" Maximum="90" Minimum="10" UpdateValueOnEnterKey="True"
+ Value="{Binding Source={x:Static Properties:Settings.Default}, Path=MemoryAlarmSetting, Mode=TwoWay}"
+ Width="100" Height="25" LostFocus="MemoryAlarm_LostFocus"/>
+ <Label Content="%" Foreground="White" VerticalAlignment="Center"/>
+ </StackPanel>
+ </StackPanel>
+ <StackPanel Grid.Row="2">
+ <Button Content="纭畾" Width="300" Height="30" Name="Confirm_Btn" Click="Confirm_Btn_Click" Margin="5" Style="{DynamicResource ButtonStyle}"/>
+ </StackPanel>
+ </Grid>
+</Window>
diff --git a/IDViewer_2D/DownloadData.xaml.cs b/IDViewer_2D/DownloadData.xaml.cs
new file mode 100644
index 0000000..f0204e2
--- /dev/null
+++ b/IDViewer_2D/DownloadData.xaml.cs
@@ -0,0 +1,309 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.IO;
+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 SmartScanner.OperateLog;
+using Microsoft.Win32;
+
+namespace SmartScanner
+{
+ /// <summary>
+ /// DownloadData.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ public partial class DownloadData : Window
+ {
+ public static bool ImageSave;//鍥惧儚淇濆瓨
+ public static string ImageSavingPath;//淇濆瓨璺緞
+ public static int ImageCompressionRatio_main;//鍥惧儚鍘嬬缉姣旂巼
+ public static int ImageDeleteData_main;//鍥惧儚瀹氭湡鍒犻櫎
+ public static string ImageFormat_main;//鍥惧儚淇濆瓨鏍煎紡
+ public static bool MemoryAlarm_main;//瀛樺偍绌洪棿鎶ヨ
+ public static int ImageMemoryAlarm_main;//瀛樺偍绌洪棿鎶ヨ
+ private bool isF = false;
+ public static bool isOP = true;
+ public DownloadData()
+ {
+ InitializeComponent();
+ isF = true;
+ Init();
+ // 绐楀彛鍏抽棴鏃朵繚瀛樿缃�
+ this.Closed += (s, e) => Properties.Settings.Default.Save();
+ }
+ public void SetControlsEnabled(bool isEnabled)
+ {
+ // 绂佺敤鎴栧惎鐢ㄦ墍鏈夊彲缂栬緫鐨勬帶浠�
+ //LoadConfig_RJ.IsEnabled = isEnabled;
+ SelectFilePath.IsEnabled = isEnabled;
+ ImageDeleteCheck.IsEnabled = isEnabled;
+ Data_deleteImage.IsEnabled = isEnabled;
+ ImageSaveCheck.IsEnabled = isEnabled;
+ ImageFormat.IsEnabled = isEnabled;
+ ImageCompressionRatio.IsEnabled = isEnabled;
+ MemoryAlarmCheck.IsEnabled = isEnabled;
+ MemoryAlarm.IsEnabled = isEnabled;
+ SetDataSavingRoad.IsEnabled = isEnabled;
+ // ... 鍏朵粬闇�瑕佹帶鍒剁殑鎺т欢
+ }
+ public void Init()
+ {
+ ImageSave = (bool)ImageSaveCheck.IsChecked;
+ MemoryAlarm_main = (bool)MemoryAlarmCheck.IsChecked;
+ ImageMemoryAlarm_main = (int)MemoryAlarm.Value;
+ ImageSavingPath = SetDataSavingRoad.Text;
+ ImageCompressionRatio_main = (int)ImageCompressionRatio.Value;
+ ImageDeleteData_main = (int)Data_deleteImage.Value;
+ switch (ImageFormat.SelectedIndex)
+ {
+ case 0:
+ ImageFormat_main = ".BMP";
+ break;
+ case 1:
+ ImageFormat_main = ".JPG";
+ break;
+ case 2:
+ ImageFormat_main = ".PNG";
+ break;
+ default:
+ break;
+ }
+ if (ImageFormat.SelectedIndex == 0)
+ {
+ CompressionVisible.Visibility = Visibility.Collapsed;
+ }
+ else
+ {
+ CompressionVisible.Visibility = Visibility.Visible;
+ }
+ }
+ private void SetDataSavingRoad_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+ {
+ var folderDialog = new System.Windows.Forms.FolderBrowserDialog
+ {
+ Description = "閫夋嫨鍥惧儚瀛樺偍璺緞",
+ SelectedPath = Properties.Settings.Default.DataSavingRoad
+ };
+
+ if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ {
+ Properties.Settings.Default.DataSavingRoad = folderDialog.SelectedPath;
+ SetDataSavingRoad.Text = folderDialog.SelectedPath;
+ }
+ // 璁板綍鏃ュ織
+ OperateLogService.LogOperation(
+ "鍥惧儚瀛樺偍璺緞淇敼",
+ $"璺緞淇敼涓�: {folderDialog.SelectedPath}",
+ null);
+ }
+
+ private void SelectFilePath_Click(object sender, RoutedEventArgs e)
+ {
+ var folderDialog = new System.Windows.Forms.FolderBrowserDialog
+ {
+ Description = "閫夋嫨鍥惧儚瀛樺偍璺緞",
+ SelectedPath = Properties.Settings.Default.DataSavingRoad
+ };
+
+ if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ {
+ Properties.Settings.Default.DataSavingRoad = folderDialog.SelectedPath;
+ SetDataSavingRoad.Text = folderDialog.SelectedPath;
+ }
+ // 璁板綍鏃ュ織
+ OperateLogService.LogOperation(
+ "鍥惧儚瀛樺偍璺緞淇敼",
+ $"璺緞淇敼涓�: {folderDialog.SelectedPath}",
+ null);
+ }
+
+ private void ImageDeleteCheck_Unchecked(object sender, RoutedEventArgs e)
+ {
+
+ }
+
+ private void ImageDeleteCheck_Checked(object sender, RoutedEventArgs e)
+ {
+
+ }
+
+ private void ImageSaveCheck_Unchecked(object sender, RoutedEventArgs e)
+ {
+ ImageSave = false;
+ // 璁板綍鏃ュ織
+ OperateLogService.LogOperation(
+ "鍥惧儚鏄惁淇濆瓨淇敼",
+ $"淇敼涓�: 涓嶄繚瀛�",
+ null);
+ }
+
+ private void ImageSaveCheck_Checked(object sender, RoutedEventArgs e)
+ {
+ ImageSave = true;
+ // 璁板綍鏃ュ織
+ OperateLogService.LogOperation(
+ "鍥惧儚鏄惁淇濆瓨淇敼",
+ $"淇敼涓�: 淇濆瓨",
+ null);
+ }
+
+ private void Confirm_Btn_Click(object sender, RoutedEventArgs e)
+ {
+ Properties.Settings.Default.Save();
+ MessageBox.Show("璁剧疆鎴愬姛 娉細瀹氭湡娓呭浘鍔熻兘闇�閲嶅惎杞欢鍚庣敓鏁�", "鎴愬姛", MessageBoxButton.OK, MessageBoxImage.Asterisk);
+ }
+
+ private void ImageCompressionRatio_LostFocus(object sender, RoutedEventArgs e)
+ {
+ if (ImageCompressionRatio.Value == null) { return; }
+ ImageCompressionRatio_main = (int)ImageCompressionRatio.Value;
+ // 璁板綍鏃ュ織
+ OperateLogService.LogOperation(
+ "鍥惧儚鍘嬬缉姣旂巼淇敼",
+ $"淇敼涓�: {ImageCompressionRatio_main}",
+ null);
+ }
+
+ private void Data_deleteImage_LostFocus(object sender, RoutedEventArgs e)
+ {
+ if (Data_deleteImage.Value == null) { return; }
+ ImageDeleteData_main = (int)Data_deleteImage.Value;
+ // 璁板綍鏃ュ織
+ OperateLogService.LogOperation(
+ "娓呭浘鍛ㄦ湡淇敼",
+ $"淇敼涓�: {ImageDeleteData_main}",
+ null);
+ }
+
+ private void ImageFormat_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (!isF) return;
+ switch (ImageFormat.SelectedIndex)
+ {
+ case 0:
+ ImageFormat_main = ".BMP";
+ break;
+ case 1:
+ ImageFormat_main = ".JPG";
+ break;
+ case 2:
+ ImageFormat_main = ".PNG";
+ break;
+ default:
+ break;
+
+ }
+ if (ImageFormat.SelectedIndex == 0)
+ {
+ CompressionVisible.Visibility = Visibility.Collapsed;
+ }
+ else
+ {
+ CompressionVisible.Visibility = Visibility.Visible;
+ }
+ // 璁板綍鏃ュ織
+ OperateLogService.LogOperation(
+ "鍥剧墖淇濆瓨鏍煎紡淇敼",
+ $"淇敼涓�: {ImageFormat_main}",
+ null);
+ }
+
+ private void ImageFormat_LostFocus(object sender, RoutedEventArgs e)
+ {
+ if (!isF) return;
+ switch (ImageFormat.SelectedIndex)
+ {
+ case 0:
+ ImageFormat_main = ".BMP";
+ break;
+ case 1:
+ ImageFormat_main = ".JPG";
+ break;
+ case 2:
+ ImageFormat_main = ".PNG";
+ break;
+ default:
+ break;
+ }
+ if (ImageFormat.SelectedIndex == 0)
+ {
+ CompressionVisible.Visibility = Visibility.Collapsed;
+ }
+ else
+ {
+ CompressionVisible.Visibility = Visibility.Visible;
+ }
+ // 璁板綍鏃ュ織
+ OperateLogService.LogOperation(
+ "鍥剧墖淇濆瓨鏍煎紡淇敼",
+ $"淇敼涓�: {ImageFormat_main}",
+ null);
+ }
+
+ private void MemoryAlarmCheck_Unchecked(object sender, RoutedEventArgs e)
+ {
+ MemoryAlarm_main = false;
+ }
+
+ private void MemoryAlarmCheck_Checked(object sender, RoutedEventArgs e)
+ {
+ MemoryAlarm_main = true;
+ }
+
+ private void MemoryAlarm_LostFocus(object sender, RoutedEventArgs e)
+ {
+ if (MemoryAlarm.Value == null) { return; }
+ ImageMemoryAlarm_main = (int)MemoryAlarm.Value;
+ }
+
+ private (double usedPercentage, string driveName) GetDriveUsage()
+ {
+ // 鑾峰彇绯荤粺鐩�
+ DownloadData downloadData = new DownloadData();
+ DriveInfo drive = new DriveInfo($"{downloadData.SetDataSavingRoad.Text}");
+ double totalSpace = drive.TotalSize;
+ double freeSpace = drive.AvailableFreeSpace;
+ double usedPercentage = 100 - (freeSpace / totalSpace * 100);
+
+ return (usedPercentage, drive.Name);
+ }
+ public async void CheckStorage()
+ {
+ while (isOP)
+ {
+ if (MemoryAlarm_main)
+ {
+ var (usedPercentage, driveName) = GetDriveUsage();
+ int threshold = 100 - (int)MemoryAlarm.Value;
+ Dispatcher.Invoke(() =>
+ {
+ if (usedPercentage >= threshold)
+ {
+ // 鎶ヨ锛氭樉绀虹孩鑹茶鍛�
+ MessageBox.Show($"{driveName} 鐩樺凡浣跨敤 {usedPercentage:F1}%锛�", "璀﹀憡", MessageBoxButton.OK, MessageBoxImage.Warning);
+
+ }
+ else
+ {
+ Console.WriteLine($"{driveName} 鐩樺凡浣跨敤 {usedPercentage:F1}%锛�");
+ }
+ });
+ await Task.Delay(10000);
+ }
+ else
+ {
+ await Task.Delay(10000);
+ }
+ }
+ }
+ }
+}
diff --git a/IDViewer_2D/ExcelResultRecorder.cs b/IDViewer_2D/ExcelResultRecorder.cs
new file mode 100644
index 0000000..f9dad43
--- /dev/null
+++ b/IDViewer_2D/ExcelResultRecorder.cs
@@ -0,0 +1,198 @@
+锘縰sing SmartScanner.ViewModel;
+using OfficeOpenXml;
+using OfficeOpenXml.Style;
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Timers;
+
+namespace SmartScanner
+{
+ public static class ExcelResultRecorder
+ {
+ private static readonly string reportDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Reports");
+ private static readonly string reportFileName = $"DetectionResults_{DateTime.Now:yyyyMMdd}.xlsx";
+ private static readonly List<DetectionRecord> _pendingRecords = new List<DetectionRecord>();
+ private static readonly object _lock = new object();
+ private static Timer _autoFlushTimer;
+ static ExcelResultRecorder()
+ {
+ try
+ {
+ // 纭繚鎶ュ憡鐩綍瀛樺湪
+ if (!Directory.Exists(reportDirectory))
+ {
+ Directory.CreateDirectory(reportDirectory);
+ }
+ // 璁剧疆EPPlus璁稿彲璇佷笂涓嬫枃
+ //ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
+ ExcelPackage.License.SetNonCommercialPersonal("Lanbao");
+ InitializeAutoFlush();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"ExcelResultRecorder鍒濆鍖栧け璐�: {ex.Message}");
+ throw;
+ }
+ }
+
+ public static void RecordDetectionResult(int sequence, string result, string qrCode = "N/A")
+ {
+ lock (_lock)
+ {
+ _pendingRecords.Add(new DetectionRecord
+ {
+ QrCode = qrCode,
+ Sequence = sequence,
+ Result = result,
+ Operator = UserManager.CurrentUser?.Username ?? "Unknown"
+ });
+
+ // 姣�10鏉¤褰曟垨姣忛殧20绉掕嚜鍔ㄤ繚瀛樹竴娆�
+ if (_pendingRecords.Count >= 10)
+ {
+ Task.Run(() => FlushRecords());
+ }
+ }
+ }
+
+ public static void FlushRecords()
+ {
+ lock (_lock)
+ {
+ if (_pendingRecords.Count == 0) return;
+
+ try
+ {
+ string filePath = Path.Combine(reportDirectory, reportFileName);
+
+ using (var package = new ExcelPackage(new FileInfo(filePath)))
+ {
+ ExcelWorksheet worksheet = package.Workbook.Worksheets["妫�娴嬬粨鏋�"] ??
+ package.Workbook.Worksheets.Add("妫�娴嬬粨鏋�");
+
+ // 鍒濆鍖栬〃澶达紙濡傛灉鏂囦欢鏄柊鍒涘缓鐨勶級
+ if (worksheet.Dimension == null)
+ {
+ CreateHeader(worksheet);
+ }
+
+ // 鎵惧埌绗竴涓┖琛�
+ int startRow = worksheet.Dimension?.End.Row + 1 ?? 2;
+ // 鎵归噺鍐欏叆鏁版嵁
+ for (int i = 0; i < _pendingRecords.Count; i++)
+ {
+ var record = _pendingRecords[i];
+ int currentRow = startRow + i;
+
+ worksheet.Cells[currentRow, 1].Value = record.QrCode;
+ worksheet.Cells[currentRow, 2].Value = $"鐐逛綅 {record.Sequence}";
+ worksheet.Cells[currentRow, 3].Value = record.Result;
+ worksheet.Cells[currentRow, 4].Value = record.DetectionTime.ToString("yyyy-MM-dd HH:mm:ss");
+ worksheet.Cells[currentRow, 5].Value = record.Operator;
+ // 鏍规嵁缁撴灉璁剧疆鍗曞厓鏍艰儗鏅壊
+ var resultCell = worksheet.Cells[currentRow, 3];
+ resultCell.Style.Fill.PatternType = ExcelFillStyle.Solid;
+ resultCell.Style.Fill.BackgroundColor.SetColor(
+ record.Result == "OK" ? Color.LightGreen : Color.Red);
+ }
+ // 鑷姩璋冩暣鍒楀
+ worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
+
+ // 淇濆瓨鏂囦欢
+ package.Save();
+ EnhancedLogViewModel.Instance.AddLog($"{_pendingRecords.Count}鏉℃娴嬬粨鏋滃凡淇濆瓨鑷硔reportFileName}");
+ }
+ _pendingRecords.Clear();
+ }
+ catch (Exception ex)
+ {
+ // 璁板綍閿欒骞朵繚鐣欐湭鍐欏叆鐨勮褰�
+ Console.WriteLine($"璁板綍妫�娴嬬粨鏋滃埌Excel澶辫触: {ex.Message}");
+ EnhancedLogViewModel.Instance.AddLog($"{_pendingRecords.Count}鏉℃娴嬬粨鏋滀繚瀛樺け璐ワ紝璇峰叧闂瓄reportFileName}鍚庨噸璇�", "ERROR");
+ }
+ }
+ }
+
+ private static void CreateHeader(ExcelWorksheet worksheet)
+ {
+ // 璁剧疆琛ㄥご
+ worksheet.Cells["A1"].Value = "浜岀淮鐮�";
+ worksheet.Cells["B1"].Value = "妫�娴嬬偣浣�";
+ worksheet.Cells["C1"].Value = "妫�娴嬬粨鏋�";
+ worksheet.Cells["D1"].Value = "妫�娴嬫椂闂�";
+ worksheet.Cells["E1"].Value = "鎿嶄綔浜哄憳";
+
+ // 璁剧疆琛ㄥご鏍峰紡
+ using (var range = worksheet.Cells["A1:E1"])
+ {
+ range.Style.Font.Bold = true;
+ range.Style.Border.Top.Style = ExcelBorderStyle.Thin;
+ range.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
+ range.Style.Border.Left.Style = ExcelBorderStyle.Thin;
+ range.Style.Border.Right.Style = ExcelBorderStyle.Thin;
+ range.Style.Fill.PatternType = ExcelFillStyle.Solid;
+ range.Style.Fill.BackgroundColor.SetColor(Color.LightGray);
+ range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
+ }
+ }
+ public static void OpenReportFolder()
+ {
+ try
+ {
+ if (Directory.Exists(reportDirectory))
+ {
+ System.Diagnostics.Process.Start("explorer.exe", reportDirectory);
+ }
+ else
+ {
+ Console.WriteLine("鎶ュ憡鐩綍涓嶅瓨鍦�");
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"鎵撳紑鎶ュ憡鏂囦欢澶瑰け璐�: {ex.Message}");
+ }
+ }
+
+ // 瀹氭椂淇濆瓨浠诲姟
+ public static void InitializeAutoFlush()
+ {
+ // 濡傛灉瀹氭椂鍣ㄥ凡瀛樺湪锛屽厛鍋滄骞堕噴鏀�
+ if (_autoFlushTimer != null)
+ {
+ _autoFlushTimer.Stop();
+ _autoFlushTimer.Dispose();
+ }
+
+ // 鍒涘缓鏂扮殑瀹氭椂鍣�
+ _autoFlushTimer = new Timer(20000);
+ _autoFlushTimer.Elapsed += (s, e) =>
+ {
+ try
+ {
+ Task.Run(() => FlushRecords());
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"瀹氭椂淇濆瓨璁板綍澶辫触: {ex.Message}");
+ }
+ };
+ _autoFlushTimer.AutoReset = true;
+ _autoFlushTimer.Start();
+ }
+
+ private class DetectionRecord
+ {
+ public string QrCode { get; set; }
+ public int Sequence { get; set; }
+ public string Result { get; set; }
+ public DateTime DetectionTime { get; } = DateTime.Now;
+ public string Operator { get; set; }
+ }
+ }
+}
diff --git a/IDViewer_2D/IDViewer2D.ico b/IDViewer_2D/IDViewer2D.ico
new file mode 100644
index 0000000..b27325f
--- /dev/null
+++ b/IDViewer_2D/IDViewer2D.ico
Binary files differ
diff --git a/IDViewer_2D/IDViewerDefines.cs b/IDViewer_2D/IDViewerDefines.cs
new file mode 100644
index 0000000..7931fc7
--- /dev/null
+++ b/IDViewer_2D/IDViewerDefines.cs
@@ -0,0 +1,2259 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+using static SmartScanner.IDViewerDefines;
+using System.Dynamic;
+using System.Net;
+
+namespace SmartScanner
+{
+ class IDViewerDefines
+ {
+ // 浣跨敤鏋氫妇琛ㄧず鍥炶皟娑堟伅ID
+ public enum CallbackMessageID
+ {
+ DeviceConnectionEstablished = 1,
+ DeviceConnectionClosed = 2
+ }
+
+ public enum ErrorCodes
+ {
+ ID_OK = 0, //鎴愬姛
+ ID_ERROR_ALREADY_INIT = 146000010, //宸茬粡鍒濆鍖�
+ ID_ERROR_NOT_INIT = 146000011, //鏈垵濮嬪寲
+ ID_ERRORREATE_DEVICE_INFO_NOT_EXSIST = 146000012, //褰撳墠鍒涘缓璁惧涓嶅瓨鍦�
+ ID_ERROR_SET_IP_DEVICE_ALREADYREATED = 146000013, //褰撳墠璁剧疆IP璁惧宸茬粡鍒涘缓
+ ID_ERROR_DEVICE_HAVE_OPENED = 146000014, //璁惧宸茬粡鎵撳紑
+ ID_ERROR_OPEN_DEVICEONNECT_PARAMS_ERROR = 146000015, //鎵撳紑璁惧杩炴帴鍙傛暟閿欒
+ ID_ERROR_OPEN_DEVICEONNECT_ISREATE = 146000016, //鎵撳紑璁惧杩炴帴宸茬粡鍒涘缓
+ ID_ERROR_OPEN_DEVICEONNECT_SOCKET_FAILED = 146000017, //鎵撳紑璁惧杩炴帴寤虹珛澶辫触
+ ID_ERROR_OPEN_DEVICEONNECT_FAILED = 146000018, //鎵撳紑璁惧杩炴帴澶辫触
+ ID_ERROR_DEVICE_NOT_OPEN = 146000019, //璁惧鏈墦寮�
+ ID_ERROR_DEVICE_IS_RUNNING = 146000020, //璁惧宸茬粡鍦ㄨ繍琛屾ā寮�
+ ID_ERROR_DEVICE_IS_DEBUGGING = 146000021, //璁惧宸茬粡鍦ㄨ皟璇曟ā寮�
+ ID_ERROR_DEVICE_QUERY_HARDWARE_INFO_FAILED = 146000022, //鑾峰彇璁惧纭欢淇℃伅澶辫触
+ ID_ERROR_OPEN_DEVICEREATE_DATA_RECEIVED_FAILED = 146000023, //鎵撳紑璁惧鎺ユ敹鏁版嵁鏈嶅姟鍒涘缓澶辫触
+ ID_ERROR_OPEN_DEVICE_SOLUTION_MANAGERONNECTION_FAILED = 146000024, //鎵撳紑璁惧鏃惰繛鎺ユ柟妗堢鐞嗗伐鍏峰け璐�
+ ID_ERROR_SOLUTION_MANAGER_TIMEOUT = 146000025, //鏂规绠$悊绫昏秴鏃�
+ ID_ERROR_SOLUTION_MANAGERAN_NOT_DELETEURRENT_SOLUTION = 146000026, //涓嶈兘鍒犻櫎褰撳墠鏂规
+ ID_ERROR_SOLUTION_MANAGERURRENT_SOLUTION_NOT_EXISTED = 146000027, //褰撳墠鏂规涓嶅瓨鍦�
+ ID_ERROR_SET_IP_ADDRESS_INVALID = 146000028, //璁剧疆IP鍦板潃涓嶅悎娉�
+ ID_ERROR_SET_IP_MASK_INVALID = 146000029, //璁剧疆瀛愮綉鎺╃爜鍦板潃涓嶅悎娉�
+ ID_ERROR_SET_IP_GATEWAY_INVALID = 146000030, //璁剧疆缃戝叧鍦板潃涓嶅悎娉�
+ ID_ERROR_SET_IP_ADDRESS_GATEWAY_NOT_IN_SAME_SUBNET = 146000031, //璁剧疆鐨処P鍦板潃鍜岀綉鍏充笉鍦ㄥ悓涓�缃戞
+ ID_ERROR_SET_IP_ADDRESS_ALREADY_EXISTED = 146000032, //璁剧疆鐨処P宸茬粡瀛樺湪
+ ID_ERROR_SOLUTION_MANAGER_SOLUTION_NAME_INVALID = 46000033, //鏂规鍚嶇О闈炴硶,涓嶈兘鍖呭惈<>:\"/\\|?*
+ ID_ERROR_SET_PARAMS_CAN_NOT_WHEN_RUNNING = 146000034, //杩愯涓笉鑳借缃鍙傛暟
+ ID_ERROR_SET_PARAMS_ROI_NOT_EXISTED = 146000035, //鍒犻櫎鐨凴OI涓嶅瓨鍦�
+ ID_ERROR_DEBUG_RESPONSE_TYPE_ERROR = 146000036, //璋冭瘯鍙嶉淇℃伅绫诲瀷涓嶅尮閰�
+ ID_ERROR_DEVICE_TYPE_NO_SUCH_FUNCTION = 146000037, //褰撳墠璁惧绫诲瀷娌℃湁璇ュ姛鑳�
+ ID_ERROR_DEBUG_GET_FOCUS_FAILED = 146000038, //鑾峰彇鐒﹁窛澶辫触
+ ID_ERROR_DEBUG_AUTO_FOCUS_FAILED = 146000039, //鑷姩瀵圭劍澶辫触
+ ID_ERROR_SOLUTION_LOAD_CONTENT_ERROR = 146000040, //鏂规鍐呭瑙f瀽澶辫触
+ ID_ERROR_SOLUTION_PARAMS_INDEX_ERROR = 146000041, //鍙傛暟缁勯敊璇�
+ ID_ERROR_SOLUTION_ILLUMINAN_INDEX_ERROR = 146000042, //鍏夋簮閫氶亾閿欒
+ ID_ERROR_SOLUTION_ILLUMINAN_BRIGHTNESS_VALUE_ERROR = 146000043, //鍏夋簮閫氶亾浜害閿欒
+ ID_ERROR_SOLUTION_DOWNLOAD_ERROR = 146000044, //褰撳墠鏂规涓嬭浇澶辫触
+ ID_ERROR_IMAGE_CAPTURE_TIMEOUT = 146000045, //鎶撳浘瓒呮椂
+ ID_ERROR_ROI_ADD_LIMIT_REACHED = 146000046, //ROI娣诲姞涓婇檺宸茶揪鍒�
+ ID_ERROR_SET_PARAMS_CODETYPE_NOT_EXISTED = 146000047, //鍒犻櫎鐨勭爜鍒朵笉瀛樺湪
+ ID_ERROR_DEVICE_NOT_IN_FREE_ACQUISITION_MODE = 146000048, //鐩告満鏈浜庤嚜鐢遍噰闆嗘ā寮�
+ ID_ERROR_SET_PARAMS_OCR_NOT_EXISTED = 146000049, //鍒犻櫎鐨凮CR涓嶅瓨鍦�
+ ID_ERROR_CONFIG_LOAD_CONTENT_ERROR = 146000050, //閰嶇疆鍐呭瑙f瀽澶辫触
+ ID_ERROR_CONFIG_ITEM_NOT_EXISTED = 146000051, //閰嶇疆椤逛笉瀛樺湪
+ ID_ERROR_CONFIG_ITEM_SET_FAILED = 146000052, //閰嶇疆椤硅缃け璐�
+ ID_ERROR_CONFIG_ITEM_GET_FAILED = 146000053, //閰嶇疆椤硅幏鍙栧け璐�
+ ID_ERROR_DO_ADD_LIMIT_RECHED = 146000054, //DO娣诲姞涓婇檺宸茶揪鍒�
+ ID_ERROR_TRIGGER_SOURCE_NO_EXISTED = 146000055, //瑙﹀彂婧愪笉瀛樺湪
+ ID_ERROR_PARAM_NO_FOUND = 146000056, //鍙傛暟涓嶅瓨鍦�
+ ID_ERROR_PARAM_POSITION_INVALID = 146000057, //鍙傛暟鍧愭爣寮傚父
+ ID_ERROR_SET_PARAMS_CAN_NOT_WHEN_DEBUGING = 146000058, //璋冭瘯涓笉鑳借缃鍙傛暟
+ ID_ERROR_DI_ADD_LIMIT_RECHED = 146000059, //DI娣诲姞涓婇檺宸茶揪鍒�
+
+ }
+
+ public enum IDImageType
+ {
+ ID_IMAGE_8U = 0, // 8浣嶆棤绗﹀彿绫诲瀷
+ ID_IMAGE_8S, // 8浣嶆湁绗﹀彿绫诲瀷
+ ID_IMAGE_16U, // 16浣嶆棤绗﹀彿绫诲瀷
+ ID_IMAGE_16S, // 16浣嶆湁绗﹀彿绫诲瀷
+ ID_IMAGE_32S, // 32浣嶆湁绗﹀彿绫诲瀷
+ ID_IMAGE_32F, // 32浣嶆诞鐐圭被鍨�
+ ID_IMAGE_64F // 64浣嶆诞鐐圭被鍨�
+ }
+
+ /*
+ *瑙﹀彂妯″紡
+ */
+ public enum IDTriggerModel
+ {
+ ID_TRIGGER_HOLD_MODEL_SINGLE_FRAME = 0, //鍗曞抚瑙﹀彂
+ ID_TRIGGER_HOLD_MODEL_MULTI_FRAME = 1, //澶氬抚瑙﹀彂
+ ID_TRIGGER_HOLD_MODEL_HOLD = 2, //瑙﹀彂淇濇寔
+ ID_TRIGGER_HOLD_MODEL_READ_SUCCESS = 3 //璇诲彇鎴愬姛杈撳嚭
+ }
+
+ /*
+ *淇″彿鎸佺画鏉′欢
+ */
+ public enum IDTriggerSignalHoldCondition
+ {
+ ID_TRIGGER_HOLDONDITION_TIMES = 0, //鏃堕棿
+ ID_TRIGGER_HOLDONDITION_FRAMES, //閲囬泦甯ф暟
+ }
+
+ /*
+ *瑙﹀彂婧�
+ */
+ public enum IDTriggerSource
+ {
+ //ID_TRIGGER_SOURCE_TCP_SERVER = 2, //tcp鏈嶅姟鍣ㄨЕ鍙�
+ //ID_TRIGGER_SOURCE_TCPLIENT = 3, //tcp瀹㈡埛绔Е鍙�
+ //ID_TRIGGER_SOURCE_UDP = 4, //UDP瑙﹀彂
+ //ID_TRIGGER_SOURCE_SERIAL_PORT = 5, //涓插彛瑙﹀彂
+ //ID_TRIGGER_SOURCE_HARDWARE = 13 //纭欢瑙﹀彂
+
+ ID_TRIGGER_SOURCE_SOFT = 0, //杞Е鍙�
+ ID_TRIGGER_SOURCE_AUTO, //鑷姩瑙﹀彂
+ ID_TRIGGER_SOURCE_TCP_SERVER, //tcp鏈嶅姟鍣ㄨЕ鍙�
+ ID_TRIGGER_SOURCE_TCP_CLIENT, //tcp瀹㈡埛绔Е鍙�
+ ID_TRIGGER_SOURCE_UDP, //UDP瑙﹀彂
+ ID_TRIGGER_SOURCE_SERIAL_PORT, //涓插彛瑙﹀彂
+ ID_TRIGGER_SOURCE_MODBUS, //modbus瑙﹀彂
+ ID_TRIGGER_SOURCE_EIP, //EIP瑙﹀彂
+ ID_TRIGGER_SOURCE_PROFINET, //profinet瑙﹀彂
+ ID_TRIGGER_SOURCE_FINS, //Fins鍗忚瑙﹀彂
+ ID_TRIGGER_SOURCE_MC, //MC瑙﹀彂
+ ID_TRIGGER_SOURCE_ETHERCAT, //Ethercat
+ ID_TRIGGER_SOURCE_NETWORKING, //缁勭綉瑙﹀彂
+ ID_TRIGGER_SOURCE_HARDWARE, //纭欢瑙﹀彂
+ ID_TRIGGER_SOURCE_SENSING //鎰熷簲妯″紡
+ }
+
+ /*
+ *瑙﹀彂鍙傛暟
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDTriggerParams
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool triggerStatus; //瑙﹀彂鐘舵��
+ public uint triggerDelay; //瑙﹀彂寤惰繜ms
+ public IDTriggerModel triggerModel; //瑙﹀彂妯″紡
+ public IDTriggerSignalHoldCondition conditionMode; //==淇″彿淇濇寔鏉′欢妯″紡 娉細鍙湁瑙﹀彂妯″紡閫夋嫨鈥滃甯р�濄�佲�滆鍙栨垚鍔熻緭鍑衡�濇椂鏈夋晥
+ public uint triggerFrames; //==瑙﹀彂閲囬泦甯ф暟 娉細鍙湁鍦ㄤ俊鍙蜂繚鎸佹潯浠舵ā寮忛�夋嫨鈥滈噰闆嗗抚鏁扳�濇椂鏈夋晥
+ public uint triggerDuration; //瑙﹀彂鎸佺画鏃堕棿 娉細鍙湁鍦ㄤ俊鍙蜂繚鎸佹潯浠朵负鏃垛�滄椂闂粹�濇湁鏁�
+ public uint triggerCodeNum; //璇诲彇鏉$爜鏁� 娉細鍙湁瑙﹀彂妯″紡閫夋嫨鈥滆鍙栨垚鍔熻緭鍑衡�濇椂鏈夋晥
+ public IDTriggerSource triggerSource; //瑙﹀彂婧�
+ public uint triggerInterval; //杞Е鍙戦棿闅攎s
+ [MarshalAs(UnmanagedType.I1)]
+ public bool statisticByCodeNum; //鐮佹暟鐩粺璁′娇鑳�(鍙湁瑙﹀彂妯″紡閫夋嫨鈥滆鍙栨垚鍔熻緭鍑衡�濇椂鏈夋晥)
+ }
+
+ public class IDTriggerParamsCreate
+ {
+ public IDTriggerParams createIDTriggerParams()
+ {
+ IDTriggerParams idtriParams = new IDTriggerParams();
+ idtriParams.triggerStatus = false;
+ idtriParams.triggerDelay = 0;
+ idtriParams.triggerModel = IDTriggerModel.ID_TRIGGER_HOLD_MODEL_SINGLE_FRAME;
+ idtriParams.conditionMode = IDTriggerSignalHoldCondition.ID_TRIGGER_HOLDONDITION_TIMES;
+ idtriParams.triggerFrames = 1;
+ idtriParams.triggerDuration = 2000;
+ idtriParams.triggerCodeNum = 1;
+ idtriParams.triggerSource = IDTriggerSource.ID_TRIGGER_SOURCE_TCP_SERVER;
+ idtriParams.triggerInterval = 500;
+ idtriParams.statisticByCodeNum = false;
+ return idtriParams;
+ }
+ }
+ /*
+ *纭欢瑙﹀彂鏋佹��
+ */
+ public enum IDTriggerPolarity
+ {
+ ID_HARDWARE_TRRIGER_LOW_LEVEL = 0, //浣庣數骞�
+ ID_HARDWARE_TRRIGER_HIGH_LEVEL = 1, //楂樼數骞�
+ ID_HARDWARE_TRRIGER_RISING_EDEG = 2, //涓婂崌娌�
+ ID_HARDWARE_TRRIGER_FALLING_EDEG = 3 //涓嬮檷娌�
+ }
+ /*
+ *纭欢瑙﹀彂鍙傛暟
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDHardwareTrigger
+ {
+ public uint debounceTime; //娑堟姈鏃堕棿us
+ public IDTriggerPolarity triggerPolarity; //瑙﹀彂鏋佹��
+ [MarshalAs(UnmanagedType.I1)]
+ public bool restrictCodeNum; //鍚敤鏈�澶цВ鐮佹暟
+ public uint triggerCodeNum; //鐮佹暟鐩�
+ public uint triggerTimeout; //瑙﹀彂瓒呮椂ms
+ [MarshalAs(UnmanagedType.I1)]
+ public bool elecLevelStatisticByCodeNum; //楂樹綆鐢靛钩鐮佹暟鐩粺璁′娇鑳�(楂樹綆鐢靛钩鍚敤鏈�澶цВ鐮佹暟寮�鍚墠鐢熸晥)
+ }
+
+
+ public class IDHardwareTriggerCreate
+ {
+ public IDHardwareTrigger createIDHardwareTrigger()
+ {
+ IDHardwareTrigger IDhardwareTrigger = new IDHardwareTrigger();
+ IDhardwareTrigger.debounceTime = 100;
+ IDhardwareTrigger.triggerPolarity = IDTriggerPolarity.ID_HARDWARE_TRRIGER_RISING_EDEG; //榛樿楂樼數骞充笂鍗囨部瑙﹀彂
+ IDhardwareTrigger.restrictCodeNum = false;
+ IDhardwareTrigger.triggerCodeNum = 1;
+ IDhardwareTrigger.triggerTimeout = 0;
+ IDhardwareTrigger.elecLevelStatisticByCodeNum = false;
+ return IDhardwareTrigger;
+ }
+ }
+ /*
+ *TCP鏈嶅姟鍣ㄨЕ鍙�
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDTcpServerTrigger
+ {
+ public uint port; //鏈嶅姟鍣ㄧ鍙�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string startCommand; //寮�濮嬫寚浠�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string endCommand; //缁撴潫鎸囦护
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enableHEX; //鍚敤16杩涘埗
+
+ }
+
+
+ public class IDTcpServerTriggerCreate
+ {
+ public IDTcpServerTrigger createIDTcpServerTrigger()
+ {
+ IDTcpServerTrigger temTcpServer = new IDTcpServerTrigger();
+ temTcpServer.port = 1024;
+ temTcpServer.startCommand = "start";
+ temTcpServer.endCommand = "stop";
+ temTcpServer.enableHEX = false;
+ return temTcpServer;
+ }
+ }
+
+ /*
+ *TCP瀹㈡埛绔Е鍙�
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDTcpClientTrigger
+ {
+ public uint port; //鏈嶅姟鍣ㄧ鍙�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string ipAddress; //鏈嶅姟鍣↖P鍦板潃
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string startCommand; //寮�濮嬫寚浠�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string endCommand; //缁撴潫鎸囦护
+ [MarshalAs(UnmanagedType.I1)]
+ public bool heartBeatEnable; //蹇冭烦浣胯兘
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string heartBeatCmd; //蹇冭烦鎸囦护
+ public uint heartBeatPeriod; //蹇冭烦鍛ㄦ湡(ms)鏈�灏忓��50ms
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enableHEX; //鍚敤16杩涘埗
+ }
+
+
+ public class IDTcpClientTriggerCreate
+ {
+ public IDTcpClientTrigger createIDTcpClientTrigger()
+ {
+ IDTcpClientTrigger temIDTcpClient = new IDTcpClientTrigger();
+ temIDTcpClient.port = 1024;
+ temIDTcpClient.ipAddress = "127.0.0.1";
+ temIDTcpClient.startCommand = "start";
+ temIDTcpClient.endCommand = "stop";
+ temIDTcpClient.heartBeatEnable = false;
+ temIDTcpClient.heartBeatCmd = "heartBeat";
+ temIDTcpClient.heartBeatPeriod = 500;
+ temIDTcpClient.enableHEX = false;
+ return temIDTcpClient;
+ }
+ }
+
+ /*
+ *涓插彛瑙﹀彂閰嶇疆,瀵瑰簲涓插彛鍙傛暟閰嶇疆浣跨敤涓插彛閫氳涓暟鎹�
+ */
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDSerialPortTrigger
+ {
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string startCommand; //寮�濮嬫寚浠�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string endCommand; //缁撴潫鎸囦护
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enableHEX; //鍚敤16杩涘埗
+ }
+
+ public class IDSerialPortTriggerCreate
+ {
+ public IDSerialPortTrigger createIDSerialPortTrigger()
+ {
+ IDSerialPortTrigger temIDSerialPort = new IDSerialPortTrigger();
+
+ temIDSerialPort.startCommand = "start";
+ temIDSerialPort.endCommand = "stop";
+ temIDSerialPort.enableHEX = false;
+ return temIDSerialPort;
+ }
+ }
+
+ /*
+ *UDP瑙﹀彂
+ */
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDUDPTrigger
+ {
+ public uint port; //绔彛
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string startCommand; //寮�濮嬫寚浠�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string endCommand; //缁撴潫鎸囦护
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enableHEX; //鍚敤16杩涘埗
+
+ }
+ public class IDUDPTriggerCreate
+ {
+ public IDUDPTrigger createIDUDPTrigger()
+ {
+ IDUDPTrigger temIDUDP = new IDUDPTrigger();
+ temIDUDP.port = 1025;
+ temIDUDP.startCommand = "start";
+ temIDUDP.endCommand = "stop";
+ temIDUDP.enableHEX = false;
+ return temIDUDP;
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDFilterInfo
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool preventDuplicatEnable; //棰勯槻閲嶅璇诲彇
+ [MarshalAs(UnmanagedType.I1)]
+ public bool removeDuplicateEnable; //鍘婚櫎閲嶅浣胯兘
+ [MarshalAs(UnmanagedType.I1)]
+ public bool historyTimesEnable; //鍘嗗彶杩囨护浣胯兘
+ [MarshalAs(UnmanagedType.I1)]
+ public bool readThresholdEnable; //璇诲彇闃堝�间娇鑳�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool frameDuplicateEnable; //閫愬抚鍘婚噸浣胯兘
+ [MarshalAs(UnmanagedType.I1)]
+ public bool angleEnable; //瑙掑害杩囨护寮�鍏�
+
+ public uint preventDuplicate; //棰勯槻閲嶅璇诲彇鏃堕棿
+ public uint historyTimes; //鍘嗗彶杩囨护甯ф暟
+ public uint readCountThreshold; //璇诲彇娆℃暟闃堟鏁�
+ public uint angleInit;
+ public uint angleOffset;
+
+ }
+
+
+ public class IDFilterInfoCreate
+ {
+ public IDFilterInfo createIDFilterInfo()
+ {
+ IDFilterInfo temIDFilterInfo = new IDFilterInfo
+ {
+ preventDuplicatEnable = false,
+ historyTimesEnable = false,
+ readThresholdEnable = false,
+ angleEnable = false,
+ removeDuplicateEnable = true,
+ frameDuplicateEnable = true,
+ preventDuplicate = 20,
+ historyTimes = 1,
+ readCountThreshold = 1,
+ angleInit = 0,
+ angleOffset = 0,
+ };
+
+ return temIDFilterInfo;
+ }
+ }
+
+ public enum IDFilterMode
+ {
+ ID_FILTER_MODE_REGULAR_C = 0, //鏅�氳繃婊�
+ ID_FILTER_MODE_REGEX_C //姝e垯琛ㄨ揪寮�
+ }
+
+ //姣忎釜ROI鐨刢odex鐨勮鍒�
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDFilterRules
+ {
+
+ public int minlength; //鏈�灏忔潯鐮侀暱搴�
+ public int maxlength; //鏈�澶ф潯鐮侀暱搴�
+ public long minvalue; //鏈�灏忓��
+ public long maxvalue; //鏈�澶у��
+
+ [MarshalAs(UnmanagedType.I1)]
+ public bool caseSensitive; //鍖归厤澶у皬鍐�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool onlyDigital; //绾暟瀛�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool onlyAlpha; //绾瓧姣�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string startstring; //浠ユ寚瀹氬瓧绗︿覆寮�濮�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string endstring; //浠ユ寚瀹氬瓧绗︿覆缁撴潫
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string constring; //鍖呭惈鎸囧畾瀛楃涓�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string NotConstring; //涓嶅寘鍚寚瀹氬瓧绗︿覆
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string wildcardstring;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string rule_str; //瑙勫垯鍚嶇О
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
+ public string regexPattern;
+
+ public IDFilterMode filterMode;
+ }
+
+ public class IDFilterRulesCreate
+ {
+ public IDFilterRules createIDFilterRules()
+ {
+ IDFilterRules temIDFilterRules = new IDFilterRules();
+ temIDFilterRules.minlength = 0;
+ temIDFilterRules.maxlength = 0;
+ temIDFilterRules.minvalue = 0;
+ temIDFilterRules.maxvalue = 0;
+ temIDFilterRules.startstring = "";
+ temIDFilterRules.endstring = "";
+ temIDFilterRules.constring = "";
+ temIDFilterRules.NotConstring = "";
+ temIDFilterRules.wildcardstring = "";
+ temIDFilterRules.caseSensitive = true;
+ temIDFilterRules.onlyDigital = false;
+ temIDFilterRules.onlyAlpha = false;
+
+ return temIDFilterRules;
+ }
+ }
+
+ public enum IDSortOrder
+ {
+ ID_SORT_ORDER_ROI_ASC_C = 0, // ROI 鍗囧簭
+ ID_SORT_ORDER_ROI_DESC_C, // ROI 闄嶅簭
+ ID_SORT_ORDER_CENTERX_ASC_C, // 涓績鍧愭爣 X 鍗囧簭
+ ID_SORT_ORDER_CENTERX_DESC_C, // 涓績鍧愭爣 X 闄嶅簭
+ ID_SORT_ORDER_CENTERY_ASC_C, // 涓績鍧愭爣 Y 鍗囧簭
+ ID_SORT_ORDER_CENTERY_DESC_C, // 涓績鍧愭爣 Y 闄嶅簭
+ ID_SORT_ORDER_CODEVALUE_ASC_C, // 鐮佺粨鏋滄暟鍊煎崌搴�
+ ID_SORT_ORDER_CODEVALUE_DESC_C // 鐮佺粨鏋滄暟鍊奸檷搴�
+ }
+ /*
+ *杈撳嚭鏁版嵁鏍煎紡閰嶇疆
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDDataConfig
+ {
+ public IDSortOrder positionRules;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool noreadStatus; //鏃犺琛ラ綈浣胯兘
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] noreadString; //鏃犺琛ラ綈
+ [MarshalAs(UnmanagedType.I1)]
+ public bool conditionEnable; //杈撳嚭鏉′欢浣胯兘
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] conditionInfo; //杈撳嚭鏉′欢
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] formatInfo; //鏍煎紡鍖栦俊鎭�
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] headInfo; //澶撮儴鎻掑叆
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] tailInfo; //灏鹃儴鎻掑叆
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enterEnable; //鍥炶溅浣胯兘
+ [MarshalAs(UnmanagedType.I1)]
+ public bool lineFeedEnable; //鎹㈣浣胯兘
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] falseInfo; //鏉′欢false鏃惰緭鍑�
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] busyInfo; //BUSY鏃惰緭鍑�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool emptySendEnabel; //鍙戦�佺┖缁撴灉浣胯兘
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enableHEX; //鍚敤16杩涘埗
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enableInstantOutput; //鍚敤绔嬪嵆杈撳嚭
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enableOneByOne; //鍚敤OneByOne
+ public uint oneByOnePeriod; //OneByOne鍛ㄦ湡(ms),鑼冨洿锛�20---10000
+
+ }
+
+
+ public class IDDataConfigCreate
+ {
+ public IDDataConfig createIDDataConfig()
+ {
+ IDDataConfig temIDDataConfig = new IDDataConfig();
+ temIDDataConfig.noreadStatus = false;
+ string noreadString = "NG";
+ temIDDataConfig.noreadString = noreadString.ToCharArray();
+ temIDDataConfig.conditionEnable = false;
+ string formatInfo = "<Code*String>";
+ temIDDataConfig.formatInfo = formatInfo.ToCharArray();
+ string headInfo = "";
+ temIDDataConfig.headInfo = headInfo.ToCharArray();
+ string tailInfo = "";
+ temIDDataConfig.tailInfo = tailInfo.ToCharArray();
+ temIDDataConfig.enterEnable = false;
+ temIDDataConfig.lineFeedEnable = false;
+ string falseInfo = "";
+ temIDDataConfig.falseInfo = falseInfo.ToCharArray();
+ string busyInfo = "";
+ temIDDataConfig.busyInfo = busyInfo.ToCharArray();
+ temIDDataConfig.emptySendEnabel = false;
+ temIDDataConfig.enableHEX = false;
+ temIDDataConfig.enableInstantOutput = false;
+ temIDDataConfig.enableOneByOne = false;
+ temIDDataConfig.oneByOnePeriod = 100;
+ return temIDDataConfig;
+ }
+ }
+ /*
+ *tcp鏈嶅姟鍣ㄩ�氳閰嶇疆
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDTcpServerCommunication
+ {
+ public uint port;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool status;
+ }
+
+
+ public class IDTcpServerCommunicationCreate
+ {
+ public IDTcpServerCommunication createIDTcpServerCommunication()
+ {
+ IDTcpServerCommunication temIDTcpServerCommunication = new IDTcpServerCommunication();
+
+ temIDTcpServerCommunication.status = false;
+ temIDTcpServerCommunication.port = 1024;
+ return temIDTcpServerCommunication;
+ }
+ }
+
+ /*
+ *TCP瀹㈡埛绔�氳
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDTcpClientCommunication
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool status;
+ public uint port;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string ipAdress;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool heartBeatEnable; //蹇冭烦浣胯兘
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string heartBeatCmd; //蹇冭烦鎸囦护
+ public uint heartBeatPeriod; //蹇冭烦鍛ㄦ湡(ms)鏈�灏忓��50ms
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enableHEX; //鍚敤16杩涘埗
+
+ }
+
+
+ public class IDTcpClientCommunicationCreate
+ {
+ public IDTcpClientCommunication createIDTcpClientCommunication()
+ {
+ IDTcpClientCommunication temIDTcpClientCommunication = new IDTcpClientCommunication();
+ temIDTcpClientCommunication.status = false;
+ temIDTcpClientCommunication.port = 1024;
+ temIDTcpClientCommunication.ipAdress = "127.0.0.1";
+
+ temIDTcpClientCommunication.heartBeatEnable = false;
+ temIDTcpClientCommunication.heartBeatCmd = "heartBeat";
+
+ temIDTcpClientCommunication.heartBeatPeriod = 500;
+ temIDTcpClientCommunication.enableHEX = false;
+ return temIDTcpClientCommunication;
+ }
+ }
+
+ /*
+ *涓插彛娉㈢壒鐜�
+ */
+ public enum IDBaud
+ {
+ ID_BAUDBR_110 = 0,
+ ID_BAUDBR_300 = 1,
+ ID_BAUDBR_600 = 2,
+ ID_BAUDBR_1200 = 3,
+ ID_BAUDBR_2400 = 4,
+ ID_BAUDBR_4800 = 5,
+ ID_BAUDBR_9600 = 6,
+ ID_BAUDBR_14400,
+ ID_BAUDBR_19200 = 8,
+ ID_BAUDBR_38400 = 9,
+ ID_BAUDBR_56000,
+ ID_BAUDBR_57600 = 11,
+ ID_BAUDBR_115200 = 12,
+ ID_BAUDBR_128000,
+ ID_BAUDBR_256000
+ }
+
+
+ /*
+ *涓插彛鏍¢獙浣�
+ */
+ public enum IDParity
+ {
+ ID_PARITY_NONE = 0, //鏃�
+ ID_PARITY_ODD, //濂囨牎楠�
+ ID_PARITY_EVEN //鍋舵牎楠�
+ }
+
+
+ /*
+ *涓插彛鏁版嵁浣�
+ */
+ public enum IDDatabits
+ {
+ ID_DATABITS_5BIT = 0,
+ ID_DATABITS_6BIT = 1,
+ ID_DATABITS_7BIT = 2,
+ ID_DATABITS_8BIT = 3
+ }
+
+
+ /*
+ *涓插彛鍋滄浣�
+ */
+ public enum IDStopbits
+ {
+ ID_STOPBITS_ONE = 0,
+ ID_STOPBITS_TWO = 1
+ }
+
+ /*
+ *涓插彛閫氳閰嶇疆
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDSerialPortCommunication
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool status;
+ public IDBaud baudRate; //娉㈢壒鐜�
+ public IDParity parity; //鏍¢獙浣�
+ public IDDatabits databits; //鏁版嵁浣�
+ public IDStopbits stopbits; //鍋滄浣�
+
+ }
+
+ public class IDSerialPortCommunicationCreate
+ {
+ public IDSerialPortCommunication createIDSerialPortCommunication()
+ {
+ IDSerialPortCommunication temIDSerialPortCommunication = new IDSerialPortCommunication();
+ temIDSerialPortCommunication.status = false;
+ temIDSerialPortCommunication.baudRate = IDBaud.ID_BAUDBR_9600;
+ temIDSerialPortCommunication.parity = IDParity.ID_PARITY_NONE;
+ temIDSerialPortCommunication.databits = IDDatabits.ID_DATABITS_8BIT;
+ temIDSerialPortCommunication.stopbits = IDStopbits.ID_STOPBITS_ONE;
+
+ return temIDSerialPortCommunication;
+ }
+ }
+
+ /*
+ *閿洏杈撳嚭
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDKeyboardConfig
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool status;
+ }
+
+
+
+ /*
+ *EIP閰嶇疆
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDEipConfig
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enable;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool resultSwap;//缁撴灉浜ゆ崲
+ public uint inputSize;//杈撳叆缁勪欢澶у皬
+ public uint outputSize;//杈撳嚭缁勪欢澶у皬
+ public uint resultTimeout;//缁撴灉瓒呮椂
+
+ }
+
+ public class IDEipConfigCreate
+ {
+ public IDEipConfig createIDEipConfig()
+ {
+ IDEipConfig temIDEipConfig = new IDEipConfig();
+ temIDEipConfig.enable = false;
+ temIDEipConfig.resultSwap = false;
+ temIDEipConfig.inputSize = 200;
+ temIDEipConfig.outputSize = 200;
+ temIDEipConfig.resultTimeout = 1000;
+
+ return temIDEipConfig;
+ }
+ }
+
+ /*
+ *modbus瑙掕壊
+ */
+ public enum IDModbusRole
+ {
+ ID_MODBUS_ROLE_MASTER = 0,
+ ID_MODBUS_ROLE_SLAVE = 1
+ }
+
+
+ /*
+ *modbus杩炴帴绫诲瀷
+ */
+ public enum IDModbusConnectionType
+ {
+ ID_MODBUSONNECTION_TCP = 0,
+ ID_MODBUSONNECTIONOM_RTU
+ }
+
+
+ /*
+ *modbus鍔熻兘妯″潡
+ */
+ public enum IDModbusFunction
+ {
+ ID_MODBUS_FUNCTIONOILS = 2, //绾垮湀
+ ID_MODBUS_FUNCTION_HOLDING_REGISTERS = 4 //淇濇寔瀵勫瓨鍣�
+ }
+
+
+ /*
+ *modbus閫氳閰嶇疆,瀵瑰簲涓插彛鍙傛暟閰嶇疆浣跨敤涓插彛閫氳涓暟鎹�
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDModbusConfig
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool status; //浣胯兘
+ public IDModbusRole role; //瑙掕壊,涓荤珯/浠庣珯
+ public IDModbusConnectionType connectionType; //杩炴帴绫诲瀷
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string tcpServerIp; //鍋氫富绔欐槸杩炴帴浠庣珯IP
+ public uint tcpPort; //tcp绔彛
+ public uint timeout; //瓒呮椂鏃堕棿
+ public uint retriesNum; //閲嶈瘯娆℃暟
+ public uint serverAddress; //鏈嶅姟鍣ㄥ湴鍧�
+ public IDModbusFunction function; //鏁版嵁鍔熻兘妯″潡
+ public uint startAddress; //寮�濮嬪湴鍧�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool resultSwap; //鏁版嵁浜ゆ崲
+ public uint resultTimeout; //缁撴灉瓒呮椂
+
+ }
+
+
+ public class IDModbusConfigCreate
+ {
+ public IDModbusConfig createIDModbusConfig()
+ {
+ IDModbusConfig temIDModbusConfig = new IDModbusConfig();
+ temIDModbusConfig.status = false;
+ temIDModbusConfig.role = IDModbusRole.ID_MODBUS_ROLE_MASTER;
+ temIDModbusConfig.connectionType = IDModbusConnectionType.ID_MODBUSONNECTION_TCP;
+ temIDModbusConfig.tcpServerIp = "127.0.0.1";
+ temIDModbusConfig.tcpPort = 512;
+ temIDModbusConfig.timeout = 3000;
+ temIDModbusConfig.retriesNum = 300;
+ temIDModbusConfig.serverAddress = 0;
+ temIDModbusConfig.function = IDModbusFunction.ID_MODBUS_FUNCTION_HOLDING_REGISTERS;
+ temIDModbusConfig.startAddress = 0;
+ temIDModbusConfig.resultSwap = false;
+ temIDModbusConfig.resultTimeout = 1000;
+
+ return temIDModbusConfig;
+ }
+ }
+
+
+ /*
+ *profinet閫氳閰嶇疆
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDProfinetConfig
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enable; //浣胯兘
+ [MarshalAs(UnmanagedType.I1)]
+ public bool serialModule; //涓插彛妯″潡
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string ipAddress; //閰嶇疆鍚�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool resultSwap; //鏁版嵁浜ゆ崲
+ public uint resultSize; //缁撴灉澶у皬(瀛楄妭Bytes)
+ public uint resultTimeout; //缁撴灉瓒呮椂鏃堕棿(ms)
+
+ }
+
+ public class IDProfinetConfigCreate
+ {
+ public IDProfinetConfig createIDProfinetConfig()
+ {
+ IDProfinetConfig temIDProfinetConfig = new IDProfinetConfig();
+
+ temIDProfinetConfig.enable = false;
+ temIDProfinetConfig.serialModule = false;
+ temIDProfinetConfig.ipAddress = "127.0.0.1";
+ temIDProfinetConfig.resultSwap = false;
+ temIDProfinetConfig.resultSize = 200;
+ temIDProfinetConfig.resultTimeout = 1000;
+ return temIDProfinetConfig;
+ }
+ }
+
+ /*
+ *鍥惧儚鏍煎紡
+ */
+ public enum IDImageFormat
+ {
+ ID_IMAGE_FORMAT_JPG = 0,
+ ID_IMAGE_FORMAT_PNG,
+ ID_IMAGE_FORMAT_BMP,
+ ID_IMAGE_FORMAT_RANDERING_JPG, //娓叉煋鍥綣PG
+ ID_IMAGE_FORMAT_RANDERING_PNG, //娓叉煋鍥綪NG
+ ID_IMAGE_FORMAT_RANDERING_BMP //娓叉煋鍥綠MP
+ }
+
+
+ public enum IDFtpSendModel
+ {
+ ID_FTP_SEND_MODEL_NOT = 0, //涓嶄繚瀛�
+ ID_FTP_SEND_MODEL_NG, //NG淇濆瓨
+ ID_FTP_SEND_MODEL_ALL, //鍏ㄤ繚瀛�
+ ID_FTP_SEND_MODELONDITION //鎸囧畾鏉′欢
+ }
+
+ public enum IDFtpSaveStrategy
+ {
+ ID_FTP_SAVE_STRATEGY_ALL_C = 0, // 鍏ㄩ儴甯�
+ ID_FTP_SAVE_STRATEGY_LATEST_C, // 鏈�鏂板抚
+ ID_FTP_SAVE_STRATEGY_SPECIFIC_INDEX_C, // 鎸囧畾甯�
+ ID_FTP_SAVE_STRATEGY_SPECIFIC_RANGE_C, // 鎸囧畾鑼冨洿
+ }
+
+ public struct IDFTPSavePolicy
+ {
+ public IDFtpSaveStrategy saveStrategy; // 淇濆瓨绛栫暐
+ public int frameIndex; // 鎸囧畾甯у彿锛堜粎褰撶瓥鐣ヤ负淇濆瓨鎸囧畾甯ф椂浣跨敤锛�
+ public int rangeStartFrame; // 璧峰甯у彿锛堜粎褰撶瓥鐣ヤ负淇濆瓨鎸囧畾鑼冨洿甯ф椂浣跨敤锛�
+ public int rangeEndFrame; // 缁撴潫甯у彿锛堜粎褰撶瓥鐣ヤ负淇濆瓨鎸囧畾鑼冨洿甯ф椂浣跨敤锛�
+
+ }
+
+
+ /*
+ *FTP閰嶇疆淇℃伅
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDFtpConfig
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool status; //浣胯兘
+ [MarshalAs(UnmanagedType.I1)]
+ public bool isLocal; //鏈湴淇濆瓨
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string iPAddress; //鏈嶅姟鍣↖P
+ public uint port; //鏈嶅姟鍣ㄧ鍙�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string username; //鐢ㄦ埛鍚�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string password; //瀵嗙爜
+ public IDImageFormat imageformat; //鍥惧儚鏍煎紡
+ public uint compressionRate; //鍘嬬缉鐜�
+ public uint maxImageCount; //鏈�澶т繚瀛樺紶鏁�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string filePath; //鍥惧儚璺緞
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string defaultFileName; //榛樿鏂囦欢鍚�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string localSavePath; //鏈湴淇濆瓨璺緞
+ [MarshalAs(UnmanagedType.I1)]
+ public bool containsBarcodeDateEnable; //鍖呭惈鏃堕棿鎴�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool containsNumberEnable; //鍖呭惈搴忓彿
+ [MarshalAs(UnmanagedType.I1)]
+ public bool containsFrameNumberEnable;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool isDecodingResultNaming; //鍖呭惈缁撴灉
+ [MarshalAs(UnmanagedType.I1)]
+ public bool containsBarcodeIDEnable; //ID鍛藉悕
+ [MarshalAs(UnmanagedType.I1)]
+ public bool containsTriggerSequenceEnable;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string sendCondition; //鍙戦�佹潯浠�
+ public IDFTPSavePolicy savePolicy;
+
+ [MarshalAs(UnmanagedType.I1)]
+ public bool resultRenderingEnable;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool boundingBoxRenderingEnable;
+ }
+
+ public class IDFtpConfigCreate
+ {
+ public IDFtpConfig createIDFtpConfig()
+ {
+ IDFtpConfig temIDFtpConfig = new IDFtpConfig();
+
+ temIDFtpConfig.status = false;
+ temIDFtpConfig.isLocal = true;
+
+ temIDFtpConfig.iPAddress = "127.0.0.1";
+
+
+ temIDFtpConfig.port = 2121;
+ temIDFtpConfig.username = "ftp";
+
+
+ temIDFtpConfig.password = "123456";
+
+
+
+ temIDFtpConfig.imageformat = IDImageFormat.ID_IMAGE_FORMAT_BMP;
+ temIDFtpConfig.compressionRate = 6;
+ temIDFtpConfig.maxImageCount = 50;
+
+ temIDFtpConfig.filePath = "";
+
+
+ temIDFtpConfig.localSavePath = "/root/solution/NG_Image";
+
+
+ temIDFtpConfig.defaultFileName = "image";
+
+ temIDFtpConfig.containsBarcodeDateEnable = true;
+ temIDFtpConfig.containsNumberEnable = false;
+ temIDFtpConfig.isDecodingResultNaming = false;
+ temIDFtpConfig.containsBarcodeIDEnable = false;
+ temIDFtpConfig.sendCondition = "NG send";
+
+
+ //temIDFtpConfig.sendModel = IDFtpSendModel.ID_FTP_SEND_MODEL_NG;
+
+ return temIDFtpConfig;
+ }
+ }
+ /*
+ *鐩戞帶HTTP閰嶇疆
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDWebpageConfig
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool status; //浣胯兘
+ public int port; //绔彛
+ public int imageQuality; //鍥惧儚璐ㄩ噺
+ [MarshalAs(UnmanagedType.I1)]
+ public bool resultDispaly; //缁撴灉灞曠ず
+ [MarshalAs(UnmanagedType.I1)]
+ public bool imageDisplay; //鍥惧儚灞曠ず
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
+ public string displayInfo; //鏄剧ず淇℃伅
+
+ }
+
+ public class IDWebpageConfigCreate
+ {
+ public IDWebpageConfig createIDWebpageConfig()
+ {
+ IDWebpageConfig temIDWebpageConfig = new IDWebpageConfig();
+ temIDWebpageConfig.status = false;
+ temIDWebpageConfig.port = 8080;
+ temIDWebpageConfig.imageQuality = 60;
+ temIDWebpageConfig.resultDispaly = true;
+ temIDWebpageConfig.imageDisplay = true;
+ temIDWebpageConfig.displayInfo = "";
+
+ return temIDWebpageConfig;
+ }
+
+ }
+ /*
+ * FINS閫氳閰嶇疆
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDFinsConfig
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool status; //浣胯兘
+ [MarshalAs(UnmanagedType.I1)]
+ public bool isTcp; //TCP/UDP
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string serverIp; //鏈嶅姟鍣↖P
+ public uint port; //鏈嶅姟鍣ㄧ鍙�
+ public uint startAddress; //寮�濮嬪湴鍧�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool resultSwap; //鏁版嵁浜ゆ崲
+ public uint resultSize; //缁撴灉澶у皬(瀛楄妭Bytes)
+ public uint resultTimeout; //缁撴灉瓒呮椂(ms)
+
+ }
+
+ public class IDFinsConfigCreate
+ {
+ public IDFinsConfig createIDFinsConfig()
+ {
+ IDFinsConfig temIDFinsConfig = new IDFinsConfig();
+
+ temIDFinsConfig.status = false;
+ temIDFinsConfig.isTcp = true;
+ temIDFinsConfig.serverIp = "0.0.0.0";
+ temIDFinsConfig.port = 9600;
+ temIDFinsConfig.startAddress = 0;
+ temIDFinsConfig.resultSwap = false;
+ temIDFinsConfig.resultSize = 200;
+ temIDFinsConfig.resultTimeout = 1000;
+ return temIDFinsConfig;
+ }
+ }
+ /*
+ *HTTP鍙戦�佹柟寮�
+ */
+ public enum IDHttpMethod
+ {
+ ID_HTTP_METHOD_POST = 0,
+ ID_HTTP_METHOD_GET
+ }
+
+
+ /*
+ * Http閫氳閰嶇疆
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDHttpConfig
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool status;
+ public IDHttpMethod method;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
+ public string httpURL;
+
+ }
+
+ public class IDHttpConfigCreate
+ {
+ public IDHttpConfig createIDHttpConfig()
+ {
+ IDHttpConfig temIDHttpConfig = new IDHttpConfig();
+
+ temIDHttpConfig.status = false;
+ temIDHttpConfig.method = IDHttpMethod.ID_HTTP_METHOD_POST;
+ temIDHttpConfig.httpURL = "";
+ return temIDHttpConfig;
+ }
+ }
+
+ /*
+ *缁勭綉鏁版嵁閰嶇疆
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDNetworkingConfig
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool networkingEnable; //缁勭綉鍚敤
+ [MarshalAs(UnmanagedType.I1)]
+ public bool isMaster; //鏄惁鏄富鏈�
+ public uint communitionPort; //杩炴帴绔彛
+ public uint masterTimeout; //涓绘満瓒呮椂
+ public uint masterMaxConnectNumber; //涓绘満鏈�澶ц杩炴帴鏁�
+ public uint slaveID; //浠庢満ID
+ [MarshalAs(UnmanagedType.I1)]
+ public bool isTriggerSlave; //鏄惁瑙﹀彂浠庢満
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string masterIP; //涓绘満IP
+ [MarshalAs(UnmanagedType.I1)]
+ public bool isReceiveTrigger; //鏄惁鎺ュ彈涓绘満瑙﹀彂
+
+ public uint triggerDelayTime; //瑙﹀彂寤舵椂
+
+ [MarshalAs(UnmanagedType.I1)]
+ public bool ConnectionStatus; //杩炴帴鐘舵��
+ [MarshalAs(UnmanagedType.I1)]
+ public bool deviceRoiPlaceholder; //璁惧ROI琛ラ綈鍗犱綅
+
+ }
+
+ public class IDNetworkingConfigCreate
+ {
+ public IDNetworkingConfig createIDNetworkingConfig()
+ {
+ IDNetworkingConfig temIDNetworkingConfig = new IDNetworkingConfig();
+
+ temIDNetworkingConfig.networkingEnable = false;
+ temIDNetworkingConfig.isMaster = true;
+ temIDNetworkingConfig.communitionPort = 5128;
+ temIDNetworkingConfig.masterTimeout = 1500;
+ temIDNetworkingConfig.masterMaxConnectNumber = 8;
+ temIDNetworkingConfig.slaveID = 1;
+ temIDNetworkingConfig.isTriggerSlave = false;
+ temIDNetworkingConfig.masterIP = "127.0.0.1";
+ temIDNetworkingConfig.isReceiveTrigger = false;
+ temIDNetworkingConfig.triggerDelayTime = 1;
+ temIDNetworkingConfig.ConnectionStatus = false;
+ temIDNetworkingConfig.deviceRoiPlaceholder = false;
+ return temIDNetworkingConfig;
+ }
+ }
+
+ //鏉$爜绫诲瀷鏋氫妇
+ public enum IDCodeType
+ {
+ IDODETYPE_UNKNOWN = 0x0,
+ IDODETYPEODE39 = 0x1,
+ IDODETYPEODE128 = 0x2,
+ IDODETYPE_EAN8 = 0x4,
+ IDODETYPE_EAN13 = 0x8,
+ IDODETYPE_UPC_A = 0x10,
+ IDODETYPE_UPC_E = 0x20,
+ IDODETYPEODE93 = 0x40,
+ IDODETYPE_ITF = 0x80,
+ IDODETYPE_GS1_128 = 0x100,
+ IDODETYPE_GS1_DATABAR_EXPANDED = 0x200,
+ IDODETYPE_GS1_DATABAR = 0x400,
+ IDODETYPE_GS1_DATABAR_STACKED = 0x600,
+ IDODETYPE_GS1_DATABAR_EXPANDED_STACKED = 0x800,
+ IDODETYPE_GS1_DATABAR_LINITED = 0x1000,
+ IDODETYPE_PHARMACODE = 0x2000,
+ IDODETYPE_MSI = 0x4000,
+ IDODETYPE_PLESSEY = 0x8000,
+ IDODETYPEODEBAR = 0x10000,
+ IDODETYPE_INT2OF5 = 0x20000,
+ IDODETYPE_STD2OF5 = 0x40000,
+ IDODETYPE_MTX2OF5 = 0x80000,
+ IDODETYPE_DATAMATRIX = 0x04000000,
+ IDODETYPE_QRCODE = 0x08000000,
+ IDODETYPE_PDF417 = 0x010000000,
+ IDODETYPE_MICROQR = 0x020000000,
+ IDODETYPE_AZTEC = 0x040000000,
+ ID_CODETYPE_VERICODEC = 0x070000000
+ }
+
+ /*
+ *MC閫氫俊PLC鍨嬪彿
+ */
+ public enum IDMcBrandModel
+ {
+ ID_MC_BRAND_L_C = 0,
+ ID_MC_BRAND_Q_C = 1,
+ ID_MC_BRAND_R_C = 2,
+ ID_MC_BRAND_A_C = 4,
+ ID_MC_BRAND_FX3U_C = 5,
+ ID_MC_BRAND_FX5U_C = 6
+ }
+
+
+ /*
+ *MC閫氫俊鏁版嵁鏍煎紡
+ */
+ public enum IDMcDataFormat
+ {
+ ID_MC_DATA_BIN_C = 0,
+ ID_MC_DATA_ASCII_C
+ }
+
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDDeviceInfo
+ {
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string networkIP;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string networkMask;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string networkGateway;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string networkAdapterFriendName;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string networkMac;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
+ public string cameraIP;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string cameraNetMask;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string cameraGateWay;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string cameraMac;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string cameraSN;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string cameraModel;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string cameraManufucturer;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string cameraSoftwareVersion;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string cameraFirmwareVersion;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string cameraAlias;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string cameraType;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
+ public string deviceFullType; //璁惧瀹屾暣鍨嬪彿
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
+ public string cameraChipType; //鐩告満鑺墖绫诲瀷
+ public uint cameraImageWidth; //鐩告満鍥惧儚瀹藉害
+ public uint cameraImageHeight; //鐩告満鍥惧儚楂樺害
+ [MarshalAs(UnmanagedType.I1)]
+ public bool isRTDevice; //鏄惁涓哄疄鏃惰澶�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool globalExposure; //鍏ㄥ眬鏇濆厜
+ [MarshalAs(UnmanagedType.I1)]
+ public bool autoFocus; //鑷姩瀵圭劍
+ public uint lightChannelNum; //鍏夋簮閫氶亾鏁�
+ public uint diNum; //DI寮曡剼鏁�
+ public uint doNum; //DO寮曡剼鏁�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool blueToothInterface; //钃濈墮璁惧
+ [MarshalAs(UnmanagedType.I1)]
+ public bool serialPortInterface; //涓插彛鎺ュ彛
+ [MarshalAs(UnmanagedType.I1)]
+ public bool usbInterface; //USB鎺ュ彛
+ [MarshalAs(UnmanagedType.I1)]
+ public bool wirelessInterface; //WIFI鎺ュ彛
+ [MarshalAs(UnmanagedType.I1)]
+ public bool ethernetInterface; //浠ュお缃戞帴鍙�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool busyState; //蹇欑鐘舵��
+ }
+
+ //纭欢淇℃伅閫氱敤鑺傜偣缁撴瀯浣�
+ public struct IDNodeParam
+ {
+ public float maxValue;
+ public float minValue;
+ public float value;
+ public int type;
+ }
+
+ public IDNodeParam createIDNodeParam()
+ {
+ IDNodeParam param;
+ param.maxValue = 0;
+ param.minValue = 0;
+ param.value = 0;
+ param.type = 0;
+ return param;
+ }
+
+
+ //纭欢淇℃伅缁撴瀯浣�
+ public struct IDDeviceHarewareParams
+ {
+ public int imageWidth;
+ public int imageHight;
+ public IDNodeParam exposureStep;
+ public IDNodeParam exposure;
+ public IDNodeParam gamma;
+ public IDNodeParam gain;
+ public IDNodeParam illuminanatInerval;
+
+ public IDNodeParam focusingLocation;
+ public IDNodeParam DICount;
+ public IDNodeParam DOCount;
+ public IDNodeParam isOpenSightingDevice;
+ }
+
+
+ public IDDeviceHarewareParams createID_DEVICE_HARDWARE_PARAMS()
+ {
+ IDDeviceHarewareParams HarewareParams;
+ HarewareParams.imageWidth = 0;
+ HarewareParams.imageHight = 0;
+ HarewareParams.exposureStep = createIDNodeParam();
+ HarewareParams.exposure = createIDNodeParam();
+ HarewareParams.gamma = createIDNodeParam();
+ HarewareParams.gain = createIDNodeParam();
+ HarewareParams.illuminanatInerval = createIDNodeParam();
+
+ HarewareParams.focusingLocation = createIDNodeParam();
+ HarewareParams.DICount = createIDNodeParam();
+ HarewareParams.DOCount = createIDNodeParam();
+ HarewareParams.isOpenSightingDevice = createIDNodeParam();
+
+ return HarewareParams;
+
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ //鐐圭被鍨嬬粨鏋勪綋
+ public struct IDPoint
+ {
+ public double x;
+ public double y;
+ }
+
+
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDROIInfo
+ {
+
+ public IDPoint topLeftPoint;
+ public IDPoint bottomRightPoint;
+ public IDCodeType codeType;
+ public uint roiIndex;
+ public uint codeNum;
+ public uint timeout;
+ }
+
+ public class IDDeviceROI
+ {
+ // 鍒涘缓IDROIInfo鐨勬柟娉�
+ public IDROIInfo CreateIDROIInfo()
+ {
+ IDROIInfo temROIInfo = new IDROIInfo
+ {
+ codeNum = 1,
+ timeout = 500,
+
+ };
+
+ return temROIInfo;
+ }
+ }
+
+
+
+ //璐ㄩ噺璇勪及杈撳嚭缁撴灉
+ //ISO IEC 15416-2016 涓�缁寸爜
+ public struct IDQuality15416
+ {
+ public float overallQuality; //鎬昏川閲�
+ public float decode; //鍙В鐮佹��
+ public float edgeDetermination; //杈圭紭纭畾
+ public float symbolContrast; //瀛楃瀵规瘮搴�
+ public float minReflectance; //鏈�灏忓弽灏勭巼
+ public float minEdgeContrast; //鏈�灏忚竟缂樺姣斿害
+ public float modulation; //璋冨埗
+ public float quietZone; //闈欐鍖�
+ public float decodability; //瑙g爜瀹归敊搴�
+ public float defects; //缂洪櫡
+ }
+
+
+ //ISO_IEC15415-2011 QR
+ public struct IDQualityQR15415
+ {
+ public float overallQuality; //鎬昏川閲�
+ public float decode; //鍙В鐮佹��
+ public float symbolContrast; //瀛楃瀵规瘮搴�
+ public float fixedPatternDamage; //鍥哄畾妯″潡鎹熷潖
+ public float modulation; //璋冨埗
+ public float reflectanceMargin; //鍙嶅皠瑁曞害
+ public float unusedErrCorrection; //鏈娇鐢ㄧ籂閿欑爜
+ public float axialNonuniformity; //杞村悜涓嶅潎鍖�鎬�
+ public float gridNonuniformity; //缃戞牸涓嶅潎鍖�鎬�
+ public float formatInformation; //鏍煎紡淇℃伅
+ public float versionInformation; //鐗堟湰淇℃伅
+ public float contrastUniformity;
+ public float printGrowth;
+ public float aperture;
+ }
+
+ //DM 15415鐮佽川閲�
+ public struct IDQualityDM15415
+ {
+ public float overallQuality; //鎬昏川閲�
+ public float decode; //鍙В鐮佹��
+ public float symbolContrast; //瀛楃瀵规瘮搴�
+ public float fixedPatternDamage; //鍥哄畾妯″潡鎹熷潖
+ public float modulation; //璋冨埗
+ public float reflectanceMargin; //鍙嶅皠瑁曞害
+ public float unusedErrCorrection; //鏈娇鐢ㄧ籂閿欑爜
+ public float axialNonuniformity; //杞村悜涓嶅潎鍖�鎬�
+ public float gridNonuniformity; //缃戞牸涓嶅潎鍖�鎬�
+ public float contrastUniformity;
+ public float printGrowth;
+ public float aperture;
+ }
+
+
+ //ISO IEC TR 29158-2011(AIM-DPM-1-2006)
+ public struct IDQualityDM29518
+ {
+ public float overallQuality; //鎬昏川閲�
+ public float decode; //鍙В鐮佹��
+ public float cellContrast; //鍗曞厓瀵规瘮搴�
+ public float cellModulation; //鍗曞厓璋冨埗
+ public float reflectanceMargin; //鍙嶅皠瑁曞害
+ public float fixedPatternDamage; //鍥哄畾妯″潡鎹熷潖
+ public float axialNonuniformity; //杞村悜涓嶅潎鍖�鎬�
+ public float gridNonuniformity; //缃戞牸涓嶅潎鍖�鎬�
+ public float unusedErrCorrection; //鏈娇鐢ㄧ籂閿欑爜
+ public float contrastUniformity;
+ public float meanLight;
+ public float printGrowth;
+ public float aperture;
+ }
+
+ //QR 29158缁撴瀯浣�
+ public struct IDQualityQR29518
+ {
+ public float overallQuality; //鎬昏川閲�
+ public float decode; //鍙В鐮佹��
+ public float cellContrast; //鍗曞厓瀵规瘮搴�
+ public float cellModulation; //鍗曞厓璋冨埗
+ public float reflectanceMargin; //鍙嶅皠瑁曞害
+ public float fixedPatternDamage; //鍥哄畾妯″潡鎹熷潖
+ public float axialNonuniformity; //杞村悜涓嶅潎鍖�鎬�
+ public float gridNonuniformity; //缃戞牸涓嶅潎鍖�鎬�
+ public float unusedErrCorrection; //鏈娇鐢ㄧ籂閿欑爜
+ public float formatInformation; //鏍煎紡淇℃伅
+ public float versionInformation; //鐗堟湰淇℃伅
+ public float contrastUniformity;
+ public float meanLight;
+ public float printGrowth;
+ public float aperture;
+ }
+
+ //PDF417 15415褰撳墠绠楁硶鏆備笉鏀寔
+ public struct IDQualityPDF417_15415
+ {
+ public float overallQuality;
+ public float decode;
+ public float symbolContrast;
+ public float fixPattern;
+ public float modulation;
+ public float unusedErrCorrection;
+ public float axialNonuniformity;
+ public float gridNonuniformity;
+ public float startStopPattern;
+ public float codewordYield;
+ public float defects;
+ public float aperture;
+ }
+
+
+
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 36)]
+ public struct IDDecodeInfo
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool decodeStatus; //瑙g爜缁撴灉鐘舵�丱K/NG
+ public float runtime; //瑙g爜鑰楁椂
+ public uint hardParamIndex;
+ public uint successCount; //瑙g爜鎴愬姛鏁�
+ public uint failedCount; //瑙g爜澶辫触鏁�
+ public uint decodeCount; //鎬昏В鐮佹暟
+ public double decodeRate; //瑙g爜鐜�
+ public uint IDDecodeROIInfoLength; //ROI鐨勪釜鏁�
+ }
+
+
+ //褰撳墠ROI瑙g爜缁撴灉
+ public struct IDDecodeROIInfo
+ {
+
+ public int roiIndex; //绗嚑涓猂OI
+ public int decodeReusltLength; //鐩墠鍙細鏈変竴涓爜鍒讹紝缁撴灉涓�1锛屽悗缁繚鐣欏彲鎵╁睍鎬�
+ }
+
+
+ //褰撳墠瑙g爜绫诲瀷,鍙湁涓�涓爜鍒舵湁鏁版嵁
+ public struct IDDecodeResult
+ {
+ public int conbination;
+ public int dmResultsLength;
+ public int qrResultsLength;
+ public int pdf417ResultsLength;
+ public int barcodeResultsLength;
+ }
+
+ //DM瑙g爜缁撴灉
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDDMCodeResult
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool state; // 褰撳墠缁撴灉瑙g爜鐘舵��
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] subType; // 瀛愮被鍨�
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] codeString; // 瑙g爜缁撴灉
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] polarity; // 鏋佹��
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] shape; // 鏍峰紡
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] mirror; // 闀滃儚
+ public int contrast; // 瀵规瘮搴�
+ public float moduleSize;
+ public float orientation;
+
+ }
+
+
+
+ //QR瑙g爜缁撴灉
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDQRCodeResult
+ {
+
+ [MarshalAs(UnmanagedType.I1)]
+ public bool state; //褰撳墠缁撴灉瑙g爜鐘舵��
+ //IDCodeType codeType; //鏉$爜绫诲瀷
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] codeString; //瑙g爜缁撴灉
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] subType;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] polarity;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] errorLevel;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] mirror; //闀滃儚
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] version; //鐗堟湰淇℃伅
+ public int contrast;
+ public float moduleSize;
+ public float orientation; //瑙掑害
+ }
+
+ //PDF417瑙g爜缁撴灉
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDPDF417CodeResult
+ {
+
+ [MarshalAs(UnmanagedType.I1)]
+ public bool state; //褰撳墠缁撴灉瑙g爜鐘舵��
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] codeString; //瑙g爜缁撴灉
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] subType; //瀛愮被鍨�
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] polarity; //鏋佹��
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] mirror; //闀滃儚
+ public int symbolRows;
+ public int symbolCols;
+ public int errorLevel;
+ public int contrast;
+ public float moduleHeight;
+ public float pixelPerModule; //moduleWidth
+ public float moduleRatio;
+ public float orientation; //瑙掑害
+
+ //IDQualityPDF417_15415 quality15415;
+ }
+
+
+ //barcode瑙g爜缁撴灉
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDBarCodeResult
+ {
+
+ [MarshalAs(UnmanagedType.I1)]
+ public bool state; //褰撳墠缁撴灉瑙g爜鐘舵��
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] codeString; //瑙g爜缁撴灉
+ public float orientation; //瑙掑害
+ public float pixelPerModule;
+
+ }
+
+ public unsafe struct StringList
+ {
+ public char* items;
+ public int size;
+ public int capacity;
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDQRCodeParam
+ {
+ public int modeType; //妯″紡
+ public int polarity; //鏋佹��
+ public int version; //鐗堟湰
+ public int sampleRate; //闄嶉噰鏍�
+ public int edgeThreshod; //闃堝��
+ public int mirror; //闀滃儚
+ public int codeNum; //鐮佹暟
+ public int timeOut; //绠楁硶瓒呮椂
+ [MarshalAs(UnmanagedType.I1)]
+ public bool outCandidate;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool outModuleArray;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enable15415; //15415鐮佽瘎绾�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enable29158; //29158鐮佽瘎绾�
+ }
+
+ public class IDQRCodeParamCreate
+ {
+ public IDQRCodeParam create()
+ {
+ IDQRCodeParam idQRCodeParam;
+
+ idQRCodeParam.modeType = 0; //妯″紡, 0,1,2
+ idQRCodeParam.polarity = 0; //鏋佹�� 0,1,2
+ idQRCodeParam.version = 0; //鐗堟湰 0~40
+ idQRCodeParam.sampleRate = 0;//闄嶉噰鏍峰�嶇巼 0~6
+ idQRCodeParam.edgeThreshod = 30; //杈圭紭闃堝�� 1~255
+ idQRCodeParam.mirror = 0; //闀滃儚, 0,1,2
+ idQRCodeParam.codeNum = 0; //鏉$爜涓暟 澶т簬绛変簬1
+ idQRCodeParam.timeOut = 500; //瓒呮椂 澶т簬绛変簬0
+ idQRCodeParam.outCandidate = false;//杈撳嚭鍊欓�夊尯
+ idQRCodeParam.outModuleArray = false; //杈撳嚭妯″潡淇℃伅
+ idQRCodeParam.enable15415 = false;
+ idQRCodeParam.enable29158 = false;
+
+ return idQRCodeParam;
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDBarCodeParam
+ {
+ public uint Type;
+ public int polarity;
+ public int sampleRate;
+ public int minContrast;
+ public int decodeDirection;
+ public int codeNum;
+ public int timeOut;
+ public int code39Check;
+ public int ITFCheck;
+ public int CodaBarCheck;
+ public int sendStartEnd;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enable15416;
+ public int decodeThreshod;
+ }
+
+ public class IDBarCodeParamCreate
+ {
+ public IDBarCodeParam create()
+ {
+ IDBarCodeParam tmpIDBarCodeParam;
+ tmpIDBarCodeParam.Type = 0;//鏉$爜绫诲瀷 鎸変綅鍙栧��
+ tmpIDBarCodeParam.polarity = 0;//鏋佹�� 0锛�1锛�2
+ tmpIDBarCodeParam.sampleRate = 0;//闄嶉噰鏍� 0~2
+ tmpIDBarCodeParam.minContrast = 2; //鍙栧�艰寖鍥�0鍒�3,0锛氳〃绀烘瀬浣庡姣斿害锛�1锛氫綆瀵规瘮搴︼紝2锛氫腑绛夊姣斿害锛�3锛氶珮瀵规瘮搴�
+ tmpIDBarCodeParam.decodeDirection = 0;//瑙g爜鏂瑰悜 Pharmacode涓撶敤锛屽彇鍊硷細0锛氫粠宸﹀埌鍙筹紝1锛氫粠鍙冲埌宸︼紝2:浠庝笂鍒颁笅, 3:浠庝笅鍒颁笂
+ tmpIDBarCodeParam.codeNum = 1; //鏉$爜涓暟 澶т簬绛変簬1
+ tmpIDBarCodeParam.timeOut = 500; //瓒呮椂 澶т簬绛変簬0
+ tmpIDBarCodeParam.code39Check = 0;
+ tmpIDBarCodeParam.ITFCheck = 0;
+ tmpIDBarCodeParam.CodaBarCheck = 0;//0:涓嶆牎楠岋紝1锛氭牎楠屼笉鍙戦�侊紝2锛氭牎楠屽彂閫�
+ tmpIDBarCodeParam.sendStartEnd = 0;//鏄惁鍙戦�佽捣濮嬬粓姝㈢锛孋odaBar涓撶敤
+ tmpIDBarCodeParam.enable15416 = false;
+ tmpIDBarCodeParam.decodeThreshod = 0;
+
+ return tmpIDBarCodeParam;
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDDMCodeParam
+ {
+
+ public int polarity; //鏋佹��
+ public int style; //寮�濮嬩綅缃�
+ public int sampleRate; //闄嶉噰鏍�
+ public int minContrast; //鏍峰紡
+ public int mirror; //闀滃儚
+ public int codeNum; //鐮佹暟鐩�
+ public int timeOut; //绠楁硶瓒呮椂
+ [MarshalAs(UnmanagedType.I1)]
+ public bool outCandidate;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool outModuleArray;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enable15415; //15415绠楁硶璇勭骇
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enable29158; //29158绠楁硶璇勭骇
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enableAS9132; //AS9132绠楁硶璇勭骇
+
+
+ }
+ public class IDDMCodeParamCreate
+ {
+ public IDDMCodeParam create()
+ {
+ IDDMCodeParam tmpIDDMCodeParam;
+
+ tmpIDDMCodeParam.polarity = 0;//鏋佹�� 0锛�1锛�2
+ tmpIDDMCodeParam.style = -1; //鏍峰紡 -3锛�-2锛�-1锛�0....29
+ tmpIDDMCodeParam.sampleRate = 0; //闄嶉噰鏍� 0~5
+ tmpIDDMCodeParam.minContrast = 30; //鏈�灏忓姣斿害 1~255
+ tmpIDDMCodeParam.mirror = 0; //闀滃儚, 0,1,2
+ tmpIDDMCodeParam.codeNum = 0; //鏉$爜涓暟 澶т簬绛変簬1
+ tmpIDDMCodeParam.timeOut = 500; //瓒呮椂
+ tmpIDDMCodeParam.outCandidate = false;//杈撳嚭鍊欓�夊尯
+ tmpIDDMCodeParam.outModuleArray = false; //杈撳嚭妯″潡淇℃伅
+ tmpIDDMCodeParam.enable15415 = false;
+ tmpIDDMCodeParam.enable29158 = false;
+ tmpIDDMCodeParam.enableAS9132 = false;
+ return tmpIDDMCodeParam;
+ }
+
+ }
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDPDF417CodeParam
+ {
+ public int polarity; //鏋佹��
+ public int pdfRows; //
+ public int pdfCols; //
+ public int mirror; //闀滃儚
+ public int codeNum; //鐮佹暟鐩�
+ public int timeOut; //绠楁硶瓒呮椂
+ [MarshalAs(UnmanagedType.I1)]
+ public bool outCandidate;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enable15415; //15415绠楁硶璇勭骇
+ }
+
+ public class IDPDF417CodeParamCreate
+ {
+ public IDPDF417CodeParam create()
+ {
+ IDPDF417CodeParam tmpIDPDF417CodeParam_C;
+ tmpIDPDF417CodeParam_C.polarity = 0;//鏋佹�� 0锛�1锛�2
+ tmpIDPDF417CodeParam_C.pdfRows = 0; //琛屾暟锛�0銆乕3, 90], 鍏朵腑0琛ㄧず鑷姩
+ tmpIDPDF417CodeParam_C.pdfCols = 0; //鍒楁暟锛歔0, 30], 鍏朵腑0琛ㄧず鑷姩
+ tmpIDPDF417CodeParam_C.mirror = 0; //闀滃儚, 0,1,2,鏆備笉鏀寔
+ tmpIDPDF417CodeParam_C.codeNum = 0; //鏉$爜涓暟 澶т簬绛変簬1
+ tmpIDPDF417CodeParam_C.timeOut = 500; //瓒呮椂
+ tmpIDPDF417CodeParam_C.outCandidate = false;//杈撳嚭鍊欓�夊尯,鏆備笉鏀寔
+ tmpIDPDF417CodeParam_C.enable15415 = false;//鏆備笉鏀寔
+ return tmpIDPDF417CodeParam_C;
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDMicroQRParam
+ {
+ public int polarity; // 鏋佹��
+ public int version; // 鐗堟湰
+ public int mirror; // 闀滃儚
+ public int codeNum; // 鏉$爜涓暟锛屽繀椤诲ぇ浜庣瓑浜�1
+ public int timeOut; // 瓒呮椂鏃堕棿锛屽繀椤诲ぇ浜庣瓑浜�0
+ public int outCandidate; // 杈撳嚭鍊欓�夐」
+ public int outModuleArray; // 杈撳嚭妯″潡鏁扮粍
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enable15415; // 鏄惁鍚敤15415鏍囧噯
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enable29158; // 鏄惁鍚敤29158鏍囧噯
+
+
+ }
+
+ public class IDMicroQRParamCreate
+ {
+ public IDMicroQRParam create()
+ {
+ IDMicroQRParam tmpIDMicroQRParam_C;
+ tmpIDMicroQRParam_C.polarity = 0; // 鍒濆鍖栦负榛樿鏋佹��
+ tmpIDMicroQRParam_C.version = 0; // 鍒濆鍖栦负榛樿鐗堟湰
+ tmpIDMicroQRParam_C.mirror = 0; // 鍒濆鍖栦负榛樿鏃犻暅鍍�
+ tmpIDMicroQRParam_C.codeNum = 1; // 鏉$爜涓暟锛岄粯璁よ嚦灏戜负1
+ tmpIDMicroQRParam_C.timeOut = 500; // 瓒呮椂锛岄粯璁�500ms
+ tmpIDMicroQRParam_C.outCandidate = 0; // 榛樿鏃犲�欓�夐」
+ tmpIDMicroQRParam_C.outModuleArray = 0; // 榛樿鏃犳ā鍧楁暟缁�
+ tmpIDMicroQRParam_C.enable15415 = false; // 榛樿涓嶅惎鐢�15415鏍囧噯
+ tmpIDMicroQRParam_C.enable29158 = false; // 榛樿涓嶅惎鐢�29158鏍囧噯
+
+ return tmpIDMicroQRParam_C;
+ }
+ }
+
+ // 鏉$爜绫诲埆
+ public enum IDCodeCategory
+ {
+ ID_CATEGORY_UNKNOWN_C = 0x0, // 鏈煡绫诲瀷
+ ID_CATEGORY_LINEAR_BARCODE_C = 0x1, // 涓�缁存潯鐮� (Linear Barcode)
+ ID_CATEGORY_QR_CODE_C = 0x2, // QR 浜岀淮鐮� (QR Code)
+ ID_CATEGORY_MICROQR_CODE_C = 0x3, // MicroQR 浜岀淮鐮� (MicroQR)
+ ID_CATEGORY_DATAMATRIX_CODE_C = 0x4, // Data Matrix 浜岀淮鐮� (Data Matrix Code)
+ ID_CATEGORY_STACKED_BARCODE_C = 0x8 // 鍫嗗彔鏉$爜 (Stacked Barcode)
+ }
+
+ public enum IDGeneralParamsType
+ {
+ GP_UNDEFINED_C = 0,
+ GP_NUM_C,
+ GP_STRING_C,
+ GP_BOOL_C,
+ GP_POINT_C,
+ GP_NUM_ARRAY_C,
+ GP_STRING_ARRAY_C,
+ GP_BOOL_ARRAY_C,
+ GP_POINT_ARRAY_C,
+ GP_UCHAR_C,
+ GP_FLOAT_C,
+ GP_USHORT_C,
+ GP_UINT_C,
+ GP_ULONG_C,
+ GP_SHORT_C,
+ GP_INT_C,
+ GP_FLAGS_C,
+ GP_LONG_C
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDImageROI
+ {
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024)]
+ public char[] name;
+ public IDPoint topLeftPoint;
+ public IDPoint bottomRightPoint;
+ public IDCodeType codeType;
+ public uint mode;
+ public uint id;
+ public uint roiIndex;
+ public uint codeNum;
+ public uint timeout;
+
+ }
+
+ public class IDImageROICreate
+ {
+ public IDImageROI create()
+ {
+ IDImageROI temIDImageROI_C = new IDImageROI();
+ temIDImageROI_C.codeNum = 1;
+ temIDImageROI_C.timeout = 500;
+ return temIDImageROI_C;
+ }
+
+ }
+
+ //鍥惧儚鍙傛暟
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDSolutionImage
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool autoExposureEnabled; // 鑷姩鏇濆厜浣胯兘
+ [MarshalAs(UnmanagedType.I1)]
+ public bool autoGainEnabled; // 鑷姩澧炵泭浣胯兘
+ public int IDSolutionImageParamsLength;
+ }
+
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDSolutionImageParams
+ {
+
+ public int paramIndex;
+ public double exposure;
+ public int gain;
+ public double gamma;
+ public int focusLocation;
+ public int rowCount; //琛屾暟
+ public int rowFrequence; //琛岄(hz)
+ public int illuminantsCount; //鍏夋簮閫氶亾鍙傛暟
+ }
+
+ //鍏夋簮閫氶亾鍙傛暟
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDSolutionImageIlluminant
+ {
+ public int channel;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool enable;
+ public int brightness;
+ }
+
+
+ public enum IDDiInputSource
+ {
+ INPUT_SOURCE_TRIGGER_C = 0, // 瑙﹀彂妯″紡
+ INPUT_SOURCE_PRESET_COMPARE_C = 1, // 瀵规瘮棰勮杈撳叆妯″紡
+ INPUT_SOURCE_DISABLE = 2 // 绂佺敤
+ }
+ /*
+ * IO杈撳叆鍙傛暟
+
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDDIParams
+ {
+
+ public IDDiInputSource inputSource; // 瑙﹀彂绫诲瀷锛屽彇鍊硷細0锛氳Е鍙戯紝1锛氬姣旈璁捐緭鍏�
+ public uint pin; // DI瀵瑰簲鐨勫紩鑴氬彿
+ }
+
+
+ public class IDDIParamsCreate
+ {
+ public IDDIParams createSTRUCT_ID_DI_PARAMS()
+ {
+ IDDIParams tmpIDDIParams_C;
+ tmpIDDIParams_C.inputSource = IDDiInputSource.INPUT_SOURCE_TRIGGER_C;
+ tmpIDDIParams_C.pin = 0;
+ return tmpIDDIParams_C;
+ }
+ }
+
+ /*
+ *IO浜嬩欢婧�
+ */
+ public enum IDDoEventSource
+ {
+ EVENT_SOURCE_OFF_C = 0, // 鏃�
+ EVENT_SOURCE_ACQUISITION_START_C, // 閲囧浘寮�濮�
+ EVENT_SOURCE_ACQUISITION_STOP_C, // 閲囧浘缁撴潫
+ EVENT_SOURCE_EXPOSURE_START_C, // 鏇濆厜寮�濮�
+ EVENT_SOURCE_NOCODE_READ_C, // 瑙g爜 NG 鏃�
+ EVENT_SOURCE_READ_SUCCESS_C, // 瑙g爜 OK 鏃�
+ EVENT_SOURCE_CONDITION_SELECTED_C, // 鏉′欢閫夋嫨
+ EVENT_SOURCE_DATA_COMPARE_SUCCESS_C, // 鏁版嵁瀵规瘮鎴愬姛
+ EVENT_SOURCE_DATA_COMPARE_FAIL_C // 鏁版嵁瀵规瘮澶辫触
+ }
+
+ /*
+ * IO杈撳嚭鍙傛暟
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDDOParams
+ {
+ public uint status; // DO鐘舵�侊紙鍚敤鎴栫鐢級
+ public uint pin; // DO瀵瑰簲鐨勫紩鑴氬彿
+ public uint doModel; // 杈撳嚭鐢靛钩
+ public uint durationTime; // 鎸佺画鏃堕棿锛坢s锛�
+ public IDDoEventSource doSource; // 浜嬩欢婧愶紙鏉ヨ嚜鍏朵粬妯″潡锛�
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string condition;
+
+ }
+
+ public class IDDOParamsCreate
+ {
+ public IDDOParams create()
+ {
+ IDDOParams tmpIDDOParams_C;
+ tmpIDDOParams_C.status = 0;
+ tmpIDDOParams_C.pin = 0;
+ tmpIDDOParams_C.doModel = 0;
+ tmpIDDOParams_C.durationTime = 0;
+ tmpIDDOParams_C.doSource = IDDoEventSource.EVENT_SOURCE_OFF_C;
+ tmpIDDOParams_C.condition = "";
+ return tmpIDDOParams_C;
+ }
+ }
+ /*
+ * mcConfig 閰嶇疆
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDMcConfig
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool isEnabled; // 浣胯兘
+ [MarshalAs(UnmanagedType.I1)]
+ public bool isUdpCommunication; // UDP 閫氫俊
+ public int brandModel; // 鍝佺墝鍨嬪彿
+ public int dataFormat; // 鏁版嵁鏍煎紡
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string ipAddress; // IP 鍦板潃
+ public int port; // 绔彛
+ public int startAddress; // 寮�濮嬪湴鍧�
+ [MarshalAs(UnmanagedType.I1)]
+ public bool isResultSwapped; // 缁撴灉浜ゆ崲
+ public uint resultSizeBytes; // 缁撴灉澶у皬锛堝瓧鑺傦級
+ public uint resultTimeoutMs; // 缁撴灉瓒呮椂锛堟绉掞級
+
+ }
+
+ public class IDMcConfigCreate
+ {
+ public IDMcConfig create()
+ {
+ IDMcConfig tmpIDMcConfig_C;
+ tmpIDMcConfig_C.isEnabled = false;
+ tmpIDMcConfig_C.isUdpCommunication = false;
+ tmpIDMcConfig_C.brandModel = 0;
+ tmpIDMcConfig_C.dataFormat = 0;
+ tmpIDMcConfig_C.ipAddress = "";
+ tmpIDMcConfig_C.port = 0;
+ tmpIDMcConfig_C.startAddress = 0;
+ tmpIDMcConfig_C.isResultSwapped = false;
+ tmpIDMcConfig_C.resultSizeBytes = 0;
+ tmpIDMcConfig_C.resultTimeoutMs = 0;
+ return tmpIDMcConfig_C;
+ }
+ }
+
+ /*
+ * udpConfig 閰嶇疆
+ */
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDUdpConfig
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool isEnabled; // 浣胯兘
+ public int port; // 绔彛
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string ipAddress; // IP 鍦板潃
+
+
+ }
+
+ public class IDUdpConfigCreate
+ {
+ public IDUdpConfig create()
+ {
+ IDUdpConfig tmpIDUdpConfig_C;
+ tmpIDUdpConfig_C.isEnabled = false;
+ tmpIDUdpConfig_C.port = 0;
+ tmpIDUdpConfig_C.ipAddress = "";
+ return tmpIDUdpConfig_C;
+ }
+ }
+
+ public enum IDGeneralParamsName
+ {
+ ID_PARAM_FILTER_PREVENT_DUPLICATE = 0, //閲嶅杩囨护
+ ID_PARAM_FILTER_PREVENT_DUPLICATE_ENABLE, //閲嶅杩囨护浣胯兘
+ ID_PARAM_FILTER_HISTORY_TIMES, //鍘嗗彶杩囨护
+ ID_PARAM_FILTER_HISTORY_TIMES_ENABLE, //鍘嗗彶杩囨护浣胯兘
+ ID_PARAM_FILTER_READ_THRESHOLD, //闃堝�艰繃婊�
+ ID_PARAM_FILTER_READ_THRESHOLD_ENABLE, //闃堝�艰繃婊や娇鑳�
+ ID_PARAM_FILTER_REMOVE_DUPLICATE_ENABLE, //鍘婚櫎閲嶅浣胯兘
+ ID_PARAM_FILTER_FRAME_DUPLICATE_ENABLE, //閫愬抚杩囨护浣胯兘
+ ID_PARAM_FILTER_ANGLE_INIT, //瑙掑害鍒濆鍊�
+ ID_PARAM_FILTER_ANGLE_OFFSET, //瑙掑害鍋忕Щ鍊�
+ ID_PARAM_FILTER_ANGLE_ENABLE, //瑙掑害浣胯兘
+ ID_PARAM_COMPARE_CONTROL_ENABLE, //姣斿浣胯兘
+ ID_PARAM_COMPARE_RULE, //姣斿瑙勫垯
+ ID_PARAM_COMPARE_PRESET_DATA, //棰勮鏁版嵁
+ ID_PARAM_COMPARE_START_POSITION, //璧峰浣嶇疆
+ ID_PARAM_COMPARE_DIGITS, //姣斿鏁�
+ ID_PARAM_DATACONFIG_NOREAD, //鏃犺琛ラ綈閰嶇疆
+ ID_PARAM_DATACONFIG_NOREAD_ENABLE, //鏃犺琛ラ綈浣胯兘
+ ID_PARAM_DATACONFIG_CONDITION, //杈撳嚭鏉′欢
+ ID_PARAM_DATACONFIG_CONDITION_ENABLE, //杈撳嚭鏉′欢浣胯兘
+ ID_PARAM_DATACONFIG_FORMAT_INFO, //鏁版嵁澶勭悊鏍煎紡鍖栧唴瀹�
+ ID_PARAM_DATACONFIG_HEAD_INFO, //璧峰鎻掑叆
+ ID_PARAM_DATACONFIG_TAIL_INFO, //缁撳熬鎻掑叆
+ ID_PARAM_DATACONFIG_ENTER_ENABLE, //缁撴潫鍥炶溅绗︿娇鑳�
+ ID_PARAM_DATACONFIG_LINEFEED_ENABLE, //缁撴潫鎹㈣绗︿娇鑳�
+ ID_PARAM_DATACONFIG_FALSE_INFO, //杈撳嚭鏉′欢涓嶆弧瓒虫椂杈撳嚭
+ ID_PARAM_DATACONFIG_HEX_ENABLE, //杈撳嚭16杩涘埗浣胯兘
+ ID_PARAM_DATACONFIG_EMPTY_SEND_ENABLE, //鍙戦�佺┖缁撴灉浣胯兘
+ ID_PARAM_DATACONFIG_INSTANT_OUTPUT_ENABLE, //绔嬪嵆杈撳嚭浣胯兘
+ ID_PARAM_DATACONFIG_POSITION_RULES, //鎺掑簭瑙勫垯
+ ID_PARAM_DATACONFIG_ONE_BY_ONE_ENABLE, //OneByOne浣胯兘
+ ID_PARAM_DATACONFIG_ONE_BY_ONE_PERIOD, //OneByOne鍛ㄦ湡
+ ID_PARAM_QUALITY_BARCODE_15416, //鏉″舰鐮佽川閲� (15416 鏍囧噯)
+ ID_PARAM_QUALITY_QR_CODE_15415, //浜岀淮鐮佽川閲� (15415 鏍囧噯)
+ ID_PARAM_QUALITY_QR_CODE_29158, //浜岀淮鐮佽川閲� (29158 鏍囧噯)
+ ID_PARAM_QUALITY_DATAMATRIX_15415, //鏁版嵁鐭╅樀璐ㄩ噺 (15415 鏍囧噯)
+ ID_PARAM_QUALITY_DATAMATRIX_29158, //鏁版嵁鐭╅樀璐ㄩ噺 (29158 鏍囧噯)
+ ID_PARAM_QUALITY_DATAMATRIX_9132, //鏁版嵁鐭╅樀璐ㄩ噺 (9132 鏍囧噯)
+ ID_PARAM_QUALITY_DATAMATRIX_T100701, //鏁版嵁鐭╅樀璐ㄩ噺 (T100701 鏍囧噯)
+ ID_PARAM_QUALITY_PDF417_15415, //PDF417 鏉$爜璐ㄩ噺 (15415 鏍囧噯)
+ ID_PARAM_QUALITY_MODE, //鏉$爜鍒诲嵃楠岃瘉妯″紡锛屽彇鍊硷細0锛氭爣鍑嗘ā寮忥紝1锛歄PT妯″紡
+ ID_PARAM_TRIGGER_STATUS, //瑙﹀彂鐘舵��
+ ID_PARAM_TRIGGER_DELAY, //瑙﹀彂寤舵椂
+ ID_PARAM_TRIGGER_MODLE, //瑙﹀彂妯″紡
+ ID_PARAM_TRIGGER_DURATION, //瑙﹀彂鎸佺画鏃堕棿
+ ID_PARAM_TRIGGER_CODE_NUM, //瑙﹀彂瑙g爜鏁�
+ ID_PARAM_TRIGGER_SOURCE, //瑙﹀彂婧�
+ ID_PARAM_TRIGGER_STATISTIC_BY_NUM_ENABLE, //鐮佹暟鐩粺璁′娇鑳�
+ ID_PARAM_TRIGGER_CONDITION_MODE, //鎸夋椂闂�/甯цЕ鍙�
+ ID_PARAM_TRIGGER_TRIGGER_INTERVAL, //鑷姩瑙﹀彂闂撮殧
+ ID_PARAM_TRIGGER_CACHE_ENABLE, //瑙﹀彂缂撳瓨浣胯兘
+ ID_PARAM_TRIGGER_ENABLE_CODE_NUM_RESTRICT, //鐮佹暟鐩檺鍒跺紑鍚�
+ ID_PARAM_TRIGGER_FRAMES, //甯ф暟
+ ID_PARAM_HARDWARE_TRIGGER_DEBOUNCETIME, //娑堟姈鏃堕棿
+ ID_PARAM_HARDWARE_TRIGGER_POLARITY, //瑙﹀彂鏋佹��
+ ID_PARAM_HARDWARE_TRIGGER_CODE_NUM_ENABLE, //鍚敤鏈�澶х爜鏁扮洰浣胯兘
+ ID_PARAM_HARDWARE_TRIGGER_CODE_NUM, //瑙g爜鏁�
+ ID_PARAM_HARDWARE_TRIGGER_TIMEOUT, //瓒呮椂鏃堕棿
+ ID_PARAM_HARDWARE_TRIGGER_STATISTIC_BY_NUM_ENABLE, //纭欢瑙﹀彂鐮佹暟鐩娇鑳�
+ ID_PARAM_TCPSEVER_TRIGGER_PORT, //tcp鏈嶅姟鍣ㄧ鍙�
+ ID_PARAM_TCPSEVER_TRIGGER_START_CMD, //tcp鏈嶅姟鍣ㄥ紑濮嬭Е鍙戞寚浠�
+ ID_PARAM_TCPSEVER_TRIGGER_STOP_CMD, //tcp鏈嶅姟鍣ㄥ仠姝㈣Е鍙戞寚浠�
+ ID_PARAM_TCPSEVER_TRIGGER_IS_FUZZY_MATCH_ENABLE_CMD, //tcp鏈嶅姟鍣ㄥ惎鐢ㄦā绯婂尮閰�
+ ID_PARAM_TCPSEVER_TRIGGER_HEX_ENABLE, //tcp鏈嶅姟鍣�16杩涘埗浣胯兘
+ ID_PARAM_TCPCLIENT_TRIGGER_PORT, //tcp瀹㈡埛绔鍙�
+ ID_PARAM_TCPCLIENT_TRIGGER_IP, //tcp瀹㈡埛绔疘P
+ ID_PARAM_TCPCLIENT_TRIGGER_START_CMD, //tcp瀹㈡埛绔紑濮嬭Е鍙戞寚浠�
+ ID_PARAM_TCPCLIENT_TRIGGER_STOP_CMD, //tcp瀹㈡埛绔仠姝㈣Е鍙戞寚浠�
+ ID_PARAM_TCPCLIENT_TRIGGER_HEARTBEAT_ENABLE, //tcp瀹㈡埛绔績璺充娇鑳�
+ ID_PARAM_TCPCLIENT_TRIGGER_HEARTBEAT_CMD, //tcp瀹㈡埛绔績璺虫寚浠�
+ ID_PARAM_TCPCLIENT_TRIGGER_HEARTBEAT_PERIOD, //tcp瀹㈡埛绔績璺冲懆鏈�
+ ID_PARAM_TCPCLIENT_TRIGGER_IS_FUZZY_MATCH_ENABLE_CMD, //tcp瀹㈡埛绔惎鐢ㄦā绯婂尮閰�
+ ID_PARAM_TCPCLIENT_TRIGGER_HEX_ENABLE, //tcp瀹㈡埛绔�16杩涘埗浣胯兘
+ ID_PARAM_UDP_TRIGGER_PORT, //udp瑙﹀彂绔彛
+ ID_PARAM_UDP_TRIGGER_START_CMD, //udp瑙﹀彂寮�濮嬫寚浠�
+ ID_PARAM_UDP_TRIGGER_STOP_CMD, //udp瑙﹀彂鍋滄鎸囦护
+ ID_PARAM_UDP_TRIGGER_IS_FUZZY_MATCH_ENABLE_CMD, //udp瑙﹀彂鍚敤妯$硦鍖归厤
+ ID_PARAM_UDP_TRIGGER_HEX_ENABLE, //udp16杩涘埗浣胯兘
+ ID_PARAM_SERIAL_TRIGGER_START_CMD, //涓插彛寮�濮嬭Е鍙戞寚浠�
+ ID_PARAM_SERIAL_TRIGGER_STOP_CMD, //涓插彛鍋滄瑙﹀彂鎸囦护
+ ID_PARAM_SERIAL_TRIGGER_IS_FUZZY_MATCH_ENABLE_CMD, //涓插彛鍚敤妯$硦鍖归厤
+ ID_PARAM_SERIAL_TRIGGER_HEX_ENABLE, //涓插彛16杩涘埗浣胯兘
+ ID_PARAM_ENCODER_CTRL_PARAMS_ENABLE, //缂栫爜鎺у埗鍣ㄧ姸鎬侊紙鍚敤鎴栫鐢級
+ ID_PARAM_ENCODER_CTRL_PARAMS_DIRECTION, //鎺у埗鏂瑰悜
+ ID_PARAM_BUZZER_STATUS, //铚傞福鍣ㄧ姸鎬侊紙鍚敤鎴栫鐢級
+ ID_PARAM_BUZZER_CONDITION, //鎸佺画鏃堕棿锛堟绉掞級
+ ID_PARAM_BUZZER_DURATION_TIME, //鏉′欢锛堟寚瀹氳Е鍙戞潯浠讹級
+ ID_PARAM_SENSING_SENSITIVITY, //鎰熷簲鐏垫晱搴�
+ ID_PARAM_SENSING_WAITTIME, //鎰熷簲绛夊緟鏃堕棿
+ ID_PARAM_OUTPUT_TCPSEVER_PORT, //TCP鏈嶅姟鍣ㄨ緭鍑虹鍙�
+ ID_PARAM_OUTPUT_TCPSEVER_ENABLE, //TCP鏈嶅姟鍣ㄨ緭鍑轰娇鑳�
+ ID_PARAM_OUTPUT_TCPCLIENT_ENABLE, //TCP瀹㈡埛绔緭鍑轰娇鑳�
+ ID_PARAM_OUTPUT_TCPCLIENT_PORT, //TCP瀹㈡埛绔緭鍑虹鍙�
+ ID_PARAM_OUTPUT_TCPCLIENT_IP, //TCP瀹㈡埛绔緭鍑哄湴鍧�
+ ID_PARAM_OUTPUT_TCPCLIENT_HEARTBEAT_ENABLE, //TCP瀹㈡埛绔績璺充娇鑳�
+ ID_PARAM_OUTPUT_TCPCLIENT_HEARTBEAT_CMD, //TCP瀹㈡埛绔績璺虫寚浠�
+ ID_PARAM_OUTPUT_TCPCLIENT_HEARTBEAT_PERIOD, //TCP瀹㈡埛绔績璺冲懆鏈�
+ ID_PARAM_OUTPUT_TCPCLIENT_HEX_ENABLE, //TCP瀹㈡埛绔�16杩涘埗浣胯兘
+ ID_PARAM_OUTPUT_SERIALPORT_ENABLE, //涓插彛杈撳嚭浣胯兘
+ ID_PARAM_OUTPUT_SERIALPORT_BAUDRATE, //涓插彛娉㈢壒鐜�
+ ID_PARAM_OUTPUT_SERIALPORT_PARITY, //涓插彛鏍¢獙浣�
+ ID_PARAM_OUTPUT_SERIALPORT_DATABIT, //涓插彛鏁版嵁浣�
+ ID_PARAM_OUTPUT_SERIALPORT_STOPBITS, //涓插彛鍋滄浣�
+ ID_PARAM_OUTPUT_SERIALPORT_FLOWCTRL, //涓插彛娴佹帶鍒�
+ ID_PARAM_OUTPUT_KEYBOARD_ENABLE, //閿洏杈撳嚭浣胯兘
+ ID_PARAM_OUTPUT_EIP_ENABLE, //EIP浣胯兘
+ ID_PARAM_OUTPUT_EIP_RESULT_SWAP_ENABLE, //EIP缁撴灉浜ゆ崲浣胯兘
+ ID_PARAM_OUTPUT_EIP_INPUT_SIZE, //EIP杈撳叆缁勪欢澶у皬
+ ID_PARAM_OUTPUT_EIP_OUTPUT_SIZE, //EIP杈撳嚭缁勪欢澶у皬
+ ID_PARAM_OUTPUT_EIP_RESULT_TIMEOUT, //EIP缁撴灉瓒呮椂
+ ID_PARAM_OUTPUT_MODBUS_ENABLE, //MODBUS浣胯兘
+ ID_PARAM_OUTPUT_MODBUS_ROLE, //MODBUS瑙掕壊涓荤珯/浠庣珯
+ ID_PARAM_OUTPUT_MODBUS_CONNECTIONTYPE, //MODBUS杩炴帴绫诲瀷TCP/Serial
+ ID_PARAM_OUTPUT_MODBUS_TCPSEVER_IP, //MODBUS tcp鏈嶅姟鍣↖P
+ ID_PARAM_OUTPUT_MODBUS_TCPSEVER_PORT, //MODBUS tcp绔彛
+ ID_PARAM_OUTPUT_MODBUS_TIMEOUT, //MODBUS 瓒呮椂鏃堕棿
+ ID_PARAM_OUTPUT_MODBUS_FUNCATION, //MODBUS function
+ ID_PARAM_OUTPUT_MODBUS_SERVER_ADDRESS, //MODBUS 鏈嶅姟鍣ㄥ湴鍧�
+ ID_PARAM_OUTPUT_MODBUS_STARTADDRESS, //MODBUS 瀵勫瓨鍣ㄨ捣濮嬪湴鍧�
+ ID_PARAM_OUTPUT_MODBUS_RESULT_SWAP_ENABLE, //MODBUS 缁撴灉浜ゆ崲浣胯兘
+ ID_PARAM_OUTPUT_MODBUS_RETRIES_NUM, //MODBUS 閲嶈瘯娆℃暟
+ ID_PARAM_OUTPUT_MODBUS_RESULT_TIMEOUT, //MODBUS 缁撴灉瓒呮椂
+ ID_PARAM_OUTPUT_FTP_ENABLE, //FTP浣胯兘
+ ID_PARAM_OUTPUT_FTP_LOCAL_ENABLE, //FTP 鏈湴瀛樺浘浣胯兘
+ ID_PARAM_OUTPUT_FTP_IP, //FTP IP鍦板潃
+ ID_PARAM_OUTPUT_FTP_PORT, //FTP 绔彛
+ ID_PARAM_OUTPUT_FTP_USERNAME, //FTP璐﹀彿
+ ID_PARAM_OUTPUT_FTP_PWD, //FTP瀵嗙爜
+ ID_PARAM_OUTPUT_FTP_IMAGE_FORMAT, //FTP瀛樺浘鏍煎紡
+ ID_PARAM_OUTPUT_FTP_COMPRESSRATE, //FTP瀛樺浘鍘嬬缉鐜�
+ ID_PARAM_OUTPUT_FTP_FILEPATH, //FTP瀛樺浘璺緞
+ ID_PARAM_OUTPUT_FTP_DEFAULT_FILENAME, //FTP榛樿鏂囦欢鍚�
+ ID_PARAM_OUTPUT_FTP_LOCAL_PATH, //FTP鏈湴淇濆瓨璺緞
+ ID_PARAM_OUTPUT_FTP_LOCAL_MAX_COUNT, //FTP鏈湴淇濆瓨鏈�澶ф暟閲�
+ ID_PARAM_OUTPUT_FTP_CONTAINS_DATE, //FTP鍛藉悕鍖呭惈鏃堕棿缂�
+ ID_PARAM_OUTPUT_FTP_CONTAINS_INDEX, //FTP鍛藉悕鍖呭惈搴忓彿
+ ID_PARAM_OUTPUT_FTP_CONTAINS_RESULT, //FTP鍛藉悕鍖呭惈缁撴灉
+ ID_PARAM_OUTPUT_FTP_CONTAINS_FRAME_NUMBER, //FTP鍛藉悕鍖呭惈甯у彿
+ ID_PARAM_OUTPUT_FTP_CONTAINS_BARCODE_ID_ENABLE, //FTP鐢熸垚璇荤爜鍣↖D鏂囦欢澶�
+ ID_PARAM_OUTPUT_FTP_CONTAINS_TRIGGER_SEQUENCE_ENABLE, //FTP鐢熸垚瑙﹀彂鍙锋枃浠跺す
+ ID_PARAM_OUTPUT_FTP_RESULT_RENDERING, //FTP缁撴灉娓叉煋浣胯兘
+ ID_PARAM_OUTPUT_FTP_BOUNDINGBOX_RENDERING, //FTP瀹氫綅妗嗘覆鏌撲娇鑳�
+ ID_PARAM_OUTPUT_FTP_SAVE_SRATEGY, //FTP瀛樺浘绛栫暐
+ ID_PARAM_OUTPUT_FTP_SAVE_POLICY_FRAME_INDEX, //FTP鎸夋寚瀹氬抚鍙峰瓨鍥�
+ ID_PARAM_OUTPUT_FTP_FTP_SAVE_POLICY_RANGE_START_FRAME, //FTP鎸夎寖鍥村瓨鍥捐捣濮嬪抚鍙�
+ ID_PARAM_OUTPUT_FTP_FTP_SAVE_POLICY_RANGE_END_FRAME, //FTP鎸夎寖鍥村瓨鍥剧粨鏉熷抚鍙�
+ ID_PARAM_OUTPUT_FTP_CONDITION, //FTP淇濆瓨鏉′欢
+ ID_PARAM_OUTPUT_WEB_ENABLE, //WEB椤甸潰浣胯兘
+ ID_PARAM_OUTPUT_WEB_PORT, //WEB椤甸潰绔彛
+ ID_PARAM_OUTPUT_WEB_IMAGE_QUALITY, //WEB鍥惧儚璐ㄩ噺
+ ID_PARAM_OUTPUT_WEB_RESULT_ENABLE, //WEB鏄剧ず缁撴灉浣胯兘
+ ID_PARAM_OUTPUT_WEB_IMAGE_ENABLE, //WEB鏄剧ず鍥惧儚浣胯兘
+ ID_PARAM_OUTPUT_WEB_DISPLAY_INFO_FORMAT, //WEB鏄剧ず鏁版嵁鏍煎紡鍖�
+ ID_PARAM_OUTPUT_NETWORKING_ENABLE, //缁勭綉浣胯兘
+ ID_PARAM_OUTPUT_NETWORKING_MASTER_ENABLE, //鏄惁鏄痬aster
+ ID_PARAM_OUTPUT_NETWORKING_PORT, //缁勭綉閫氫俊绔彛
+ ID_PARAM_OUTPUT_NETWORKING_MASTER_IP, //缁勭綉涓绘満IP
+ ID_PARAM_OUTPUT_NETWORKING_MASTER_TIMEOUT, //缁勭綉涓绘満瓒呮椂鏃堕棿
+ ID_PARAM_OUTPUT_NETWORKING_SLAVE_ID, //缁勭綉浠庢満ID
+ ID_PARAM_OUTPUT_NETWORKING_MASTER_MAX_CONNECT_NUM, //缁勭綉涓绘満鏈�澶ц繛鎺ヤ粠鏈烘暟
+ ID_PARAM_OUTPUT_NETWORKING_TRIGGER_SLAVE_ENABLE, //缁勭綉涓绘満瑙﹀彂浠庢満浣胯兘
+ ID_PARAM_OUTPUT_NETWORKING_SLAVE_RECEIVE_TRIGGER_ENABLE, //缁勭綉浠庢満鎺ユ敹涓绘満瑙﹀彂浣胯兘
+ ID_PARAM_OUTPUT_NETWORKING_SLAVE_TRIGGER_DELAY, //缁勭綉浠庢満瑙﹀彂寤惰繜
+ ID_PARAM_OUTPUT_NETWORKING_SLAVE_TRIGGER_CONNECTION_STATUS, //缁勭綉杩炴帴鐘舵��
+ ID_PARAM_OUTPUT_NETWORKING_DEVICE_ROI_ENABLE, //缁勭綉璁惧ROI琛ラ綈浣胯兘
+ ID_PARAM_OUTPUT_PROFINET_ENABLE, //PROFINET浣胯兘
+ ID_PARAM_OUTPUT_PROFINET_RESULT_MODEL_SIZE, //PROFINET缁撴灉妯″潡澶у皬
+ ID_PARAM_OUTPUT_PROFINET_NAME, //PROFINET閰嶇疆鍚�
+ ID_PARAM_OUTPUT_PROFINET_RESULT_SWAP_ENABLE, //PROFINET缁撴灉瀛楄妭浜ゆ崲浣胯兘
+ ID_PARAM_OUTPUT_PROFINET_RESULT_SIZE, //PROFINET缁撴灉澶у皬
+ ID_PARAM_OUTPUT_PROFINET_RESULT_TIMEOUT, //PROFINET缁撴灉瓒呮椂
+ ID_PARAM_OUTPUT_FINS_ENABLE, //FINS浣胯兘
+ ID_PARAM_OUTPUT_FINS_IS_TCP, //FINS鏄惁鍚敤TCP
+ ID_PARAM_OUTPUT_FINS_IP, //FINS涓婁綅鏈篒P
+ ID_PARAM_OUTPUT_FINS_PROT, //FINS涓婁綅鏈虹鍙�
+ ID_PARAM_OUTPUT_FINS_STARTADDRESS, //FINS鏁版嵁璧峰鍦板潃
+ ID_PARAM_OUTPUT_FINS_RESULT_SWAP_ENABLE, //FINS缁撴灉浜ゆ崲浣胯兘
+ ID_PARAM_OUTPUT_FINS_RESULT_SIZE, //FINS缁撴灉鏁版嵁澶у皬
+ ID_PARAM_OUTPUT_FINS_RESULT_TIMEOUT, //FINS缁撴灉瓒呮椂鏃堕棿
+ ID_PARAM_OUTPUT_HTTP_ENABLE, //HTTP浣胯兘
+ ID_PARAM_OUTPUT_HTTP_URL, //HTTP鍙戦�佸湴鍧�
+ ID_PARAM_OUTPUT_MC_CONFIG_ENABLE, //MC浣胯兘
+ ID_PARAM_OUTPUT_MC_CONFIG_UDP_COMMUNICATION, //MC UDP閫氳浣胯兘
+ ID_PARAM_OUTPUT_MC_CONFIG_BRAND_MODEL, //MC鍝佺墝鍨嬪彿
+ ID_PARAM_OUTPUT_MC_CONFIG_DATA_FORMAT, //MC鏁版嵁鏍煎紡
+ ID_PARAM_OUTPUT_MC_CONFIG_IP_ADDRESS, //MC IP鍦板潃
+ ID_PARAM_OUTPUT_MC_CONFIG_PORT, //MC绔彛
+ ID_PARAM_OUTPUT_MC_CONFIG_START_ADDRESS, //MC璧峰鍦板潃
+ ID_PARAM_OUTPUT_MC_CONFIG_RESULT_SWAP, //MC缁撴灉浜ゆ崲
+ ID_PARAM_OUTPUT_MC_CONFIG_RESULT_SIZE, //MC缁撴灉澶у皬
+ ID_PARAM_OUTPUT_MC_CONFIG_RESULT_TIMEOUT, //MC缁撴灉瓒呮椂
+ ID_PARAM_OUTPUT_UDP_CONFIG_ENABLE, //UDP浣胯兘
+ ID_PARAM_OUTPUT_UDP_CONFIG_PORT, //UDP绔彛
+ ID_PARAM_OUTPUT_UDP_CONFIG_IP_ADDRESS //UDP IP鍦板潃
+ }
+
+ }
+}
diff --git a/IDViewer_2D/IDViewerDefines1.cs b/IDViewer_2D/IDViewerDefines1.cs
new file mode 100644
index 0000000..05b7762
--- /dev/null
+++ b/IDViewer_2D/IDViewerDefines1.cs
@@ -0,0 +1,452 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace IDViewer_2D
+{
+ class IDViewerDefines
+ {
+ // 浣跨敤鏋氫妇琛ㄧず鍥炶皟娑堟伅ID
+ public enum CallbackMessageID
+ {
+ DeviceConnectionEstablished = 1,
+ DeviceConnectionClosed = 2
+ }
+
+ public enum ErrorCodes
+ {
+ ID_OK = 0, //鎴愬姛
+ ID_ERROR_ALREADY_INIT = 146000010, //宸茬粡鍒濆鍖�
+ ID_ERROR_NOT_INIT = 146000011, //鏈垵濮嬪寲
+ ID_ERROR_CREATE_DEVICE_INFO_NOT_EXSIST = 146000012, //褰撳墠鍒涘缓璁惧涓嶅瓨鍦�
+ ID_ERROR_SET_IP_DEVICE_ALREADY_CREATED = 146000013, //褰撳墠璁剧疆IP璁惧宸茬粡鍒涘缓
+ ID_ERROR_DEVICE_HAVE_OPENED = 146000014, //璁惧宸茬粡鎵撳紑
+ ID_ERROR_OPEN_DEVICE_CONNECT_PARAMS_ERROR = 146000015, //鎵撳紑璁惧杩炴帴鍙傛暟閿欒
+ ID_ERROR_OPEN_DEVICE_CONNECT_IS_CREATE = 146000016, //鎵撳紑璁惧杩炴帴宸茬粡鍒涘缓
+ ID_ERROR_OPEN_DEVICE_CONNECT_SOCKET_FAILED = 146000017, //鎵撳紑璁惧杩炴帴寤虹珛澶辫触
+ ID_ERROR_OPEN_DEVICE_CONNECT_FAILED = 146000018, //鎵撳紑璁惧杩炴帴澶辫触
+ ID_ERROR_DEVICE_NOT_OPEN = 146000019, //璁惧鏈墦寮�
+ ID_ERROR_DEVICE_IS_RUNNING = 146000020, //璁惧宸茬粡鍦ㄨ繍琛屾ā寮�
+ ID_ERROR_DEVICE_IS_DEBUGGING = 146000021, //璁惧宸茬粡鍦ㄨ皟璇曟ā寮�
+ ID_ERROR_DEVICE_QUERY_HARDWARE_INFO_FAILED = 146000022, //鑾峰彇璁惧纭欢淇℃伅澶辫触
+ ID_ERROR_OPEN_DEVICE_CREATE_DATA_RECEIVED_FAILED = 146000023, //鎵撳紑璁惧鎺ユ敹鏁版嵁鏈嶅姟鍒涘缓澶辫触
+ ID_ERROR_OPEN_DEVICE_SOLUTION_MANAGER_CONNECTION_FAILED = 146000024, //鎵撳紑璁惧鏃惰繛鎺ユ柟妗堢鐞嗗伐鍏峰け璐�
+ ID_ERROR_SOLUTION_MANAGER_TIMEOUT = 146000025, //鏂规绠$悊绫昏秴鏃�
+ ID_ERROR_SOLUTION_MANAGER_CAN_NOT_DELETE_CURRENT_SOLUTION = 146000026, //涓嶈兘鍒犻櫎褰撳墠鏂规
+ ID_ERROR_SOLUTION_MANAGER_CURRENT_SOLUTION_NOT_EXISTED = 146000027, //褰撳墠鏂规涓嶅瓨鍦�
+ ID_ERROR_SET_IP_ADDRESS_INVALID = 146000028, //璁剧疆IP鍦板潃涓嶅悎娉�
+ ID_ERROR_SET_IP_MASK_INVALID = 146000029, //璁剧疆瀛愮綉鎺╃爜鍦板潃涓嶅悎娉�
+ ID_ERROR_SET_IP_GATEWAY_INVALID = 146000030, //璁剧疆缃戝叧鍦板潃涓嶅悎娉�
+ ID_ERROR_SET_IP_ADDRESS_GATEWAY_NOT_IN_SAME_SUBNET = 146000031, //璁剧疆鐨処P鍦板潃鍜岀綉鍏充笉鍦ㄥ悓涓�缃戞
+ ID_ERROR_SET_IP_ADDRESS_ALREADY_EXISTED = 146000032, //璁剧疆鐨処P宸茬粡瀛樺湪
+ ID_ERROR_SOLUTION_MANAGER_SOLUTION_NAME_INVALID = 46000033 //鏂规鍚嶇О闈炴硶,涓嶈兘鍖呭惈<>:\"/\\|?*
+
+ }
+
+ public enum IDImageType
+ {
+ ID_IMAGE_8U_C = 0, // 8浣嶆棤绗﹀彿绫诲瀷
+ ID_IMAGE_8S_C, // 8浣嶆湁绗﹀彿绫诲瀷
+ ID_IMAGE_16U_C, // 16浣嶆棤绗﹀彿绫诲瀷
+ ID_IMAGE_16S_C, // 16浣嶆湁绗﹀彿绫诲瀷
+ ID_IMAGE_32S_C, // 32浣嶆湁绗﹀彿绫诲瀷
+ ID_IMAGE_32F_C, // 32浣嶆诞鐐圭被鍨�
+ ID_IMAGE_64F_C // 64浣嶆诞鐐圭被鍨�
+ }
+
+ //鏉$爜绫诲瀷鏋氫妇
+ public enum IDCodeType
+ {
+ ID_CODETYPE_UNKNOWN_C = 0x0,
+ ID_CODETYPE_CODE39_C = 0x1,
+ ID_CODETYPE_CODE128_C = 0x2,
+ ID_CODETYPE_EAN8_C = 0x4,
+ ID_CODETYPE_EAN13_C = 0x8,
+ ID_CODETYPE_UPC_A_C = 0x10,
+ ID_CODETYPE_UPC_E_C = 0x20,
+ ID_CODETYPE_CODE93_C = 0x40,
+ ID_CODETYPE_ITF_C = 0x80,
+ ID_CODETYPE_GS1_128_C = 0x100,
+ ID_CODETYPE_GS1_DATABAR_EXPANDED_C = 0x200,
+ ID_CODETYPE_GS1_DATABAR_C = 0x400,
+ ID_CODETYPE_GS1_DATABAR_STACKED_C = 0x600,
+ ID_CODETYPE_GS1_DATABAR_EXPANDED_STACKED_C = 0x800,
+ ID_CODETYPE_GS1_DATABAR_LINITED_C = 0x1000,
+ ID_CODETYPE_PHARMACODE_C = 0x2000,
+ ID_CODETYPE_MSI_C = 0x4000,
+ ID_CODETYPE_PLESSEY_C = 0x8000,
+ ID_CODETYPE_CODEBAR_C = 0x10000,
+ ID_CODETYPE_INT2OF5_C = 0x20000,
+ ID_CODETYPE_STD2OF5_C = 0x40000,
+ ID_CODETYPE_MTX2OF5_C = 0x80000,
+ ID_CODETYPE_DATAMATRIX_C = 0x04000000,
+ ID_CODETYPE_QRCODE_C = 0x08000000,
+ ID_CODETYPE_PDF417_C = 0x010000000,
+ ID_CODETYPE_MICROQR_C = 0x020000000,
+ ID_CODETYPE_AZTEC_C = 0x040000000,
+ //ID_CODETYPE_VERICODE_C = 0x080000000
+ }
+
+
+ public struct IDDeviceInfo
+ {
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
+ public char[] networkIP;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] networkMask;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] networkGateway;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string networkAdapterFriendName;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] networkMac;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
+ public char[] cameraIP;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] cameraNetMask;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] cameraGateWay;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] cameraMac;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] cameraSN;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] cameraModel;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] cameraManufucturer;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] cameraSoftwareVersion;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] cameraFirmwareVersion;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string cameraAlias;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] cameraType;
+ }
+
+ //纭欢淇℃伅閫氱敤鑺傜偣缁撴瀯浣�
+ public struct IDNodeParam
+ {
+ public float maxValue;
+ public float minValue;
+ public float value;
+ public int type;
+ }
+
+ public IDNodeParam createIDNodeParam_C() {
+ IDNodeParam param;
+ param.maxValue = 0;
+ param.minValue = 0;
+ param.value = 0;
+ param.type = 0;
+ return param;
+ }
+
+
+ //纭欢淇℃伅缁撴瀯浣�
+ public struct IDDeviceHarewareParams
+ {
+ public int imageWidth;
+ public int imageHight;
+ public IDNodeParam exposureStep;
+ public IDNodeParam exposure;
+ public IDNodeParam gamma;
+ public IDNodeParam gain;
+ public IDNodeParam illuminanatInerval;
+
+ public IDNodeParam focusingLocation;
+ public IDNodeParam DICount;
+ public IDNodeParam DOCount;
+ public IDNodeParam isOpenSightingDevice;
+ }
+
+
+ public IDDeviceHarewareParams createID_DEVICE_HARDWARE_PARAMS()
+ {
+ IDDeviceHarewareParams HarewareParams;
+ HarewareParams.imageWidth = 0;
+ HarewareParams.imageHight = 0;
+ HarewareParams.exposureStep = createIDNodeParam_C();
+ HarewareParams.exposure = createIDNodeParam_C();
+ HarewareParams.gamma = createIDNodeParam_C();
+ HarewareParams.gain = createIDNodeParam_C();
+ HarewareParams.illuminanatInerval = createIDNodeParam_C();
+
+ HarewareParams.focusingLocation = createIDNodeParam_C();
+ HarewareParams.DICount = createIDNodeParam_C();
+ HarewareParams.DOCount = createIDNodeParam_C();
+ HarewareParams.isOpenSightingDevice = createIDNodeParam_C();
+
+ return HarewareParams;
+
+ }
+
+ //鐐圭被鍨嬬粨鏋勪綋
+ public struct IDPoint
+ {
+ public double x;
+ public double y;
+ }
+
+ //璐ㄩ噺璇勪及杈撳嚭缁撴灉
+ //ISO IEC 15416-2016
+ public struct IDQuality15416
+ {
+ public float overallQuality;
+ public float decode;
+ public float edgeDetermination;
+ public float symbolContrast;
+ public float minReflectance;
+ public float minEdgeContrast;
+ public float modulation;
+ public float quietZone;
+ public float decodability;
+ public float defects;
+ }
+
+ //ISO_IEC15415-2011 QR
+ public struct IDQualityQR15415
+ {
+ public float overallQuality;
+ public float decode;
+ public float symbolContrast;
+ public float fixedPatternDamage;
+ public float modulation;
+ public float reflectanceMargin;
+ public float unusedErrCorrection;
+ public float axialNonuniformity;
+ public float gridNonuniformity;
+ public float formatInformation;
+ public float versionInformation;
+ public float contrastUniformity;
+ public float printGrowth;
+ public float aperture;
+ }
+
+ //DM 15415鐮佽川閲�
+ public struct IDQualityDM15415
+ {
+ public float overallQuality;
+ public float decode;
+ public float symbolContrast;
+ public float fixedPatternDamage;
+ public float modulation;
+ public float reflectanceMargin;
+ public float unusedErrCorrection;
+ public float axialNonuniformity;
+ public float gridNonuniformity;
+ public float contrastUniformity;
+ public float printGrowth;
+ public float aperture;
+ }
+
+
+ //ISO IEC TR 29158-2011(AIM-DPM-1-2006)
+ public struct IDQualityDM29518
+ {
+ public float overallQuality;
+ public float decode;
+ public float cellContrast;
+ public float cellModulation;
+ public float reflectanceMargin;
+ public float fixedPatternDamage;
+ public float axialNonuniformity;
+ public float gridNonuniformity;
+ public float unusedErrCorrection;
+ public float contrastUniformity;
+ public float meanLight;
+ public float printGrowth;
+ public float aperture;
+ }
+
+ //QR 29158缁撴瀯浣�
+ public struct IDQualityQR29518
+ {
+ public float overallQuality;
+ public float decode;
+ public float cellContrast;
+ public float cellModulation;
+ public float fixedPatternDamage;
+ public float reflectanceMargin;
+ public float unusedErrCorrection;
+ public float axialNonuniformity;
+ public float gridNonuniformity;
+ public float formatInformation;
+ public float versionInformation;
+ public float contrastUniformity;
+ public float meanLight;
+ public float printGrowth;
+ public float aperture;
+ }
+
+
+ public struct IDQualityPDF417_15415
+ {
+ public float overallQuality;
+ public float decode;
+ public float symbolContrast;
+ public float fixPattern;
+ public float modulation;
+ public float unusedErrCorrection;
+ public float axialNonuniformity;
+ public float gridNonuniformity;
+ public float startStopPattern;
+ public float codewordYield;
+ public float defects;
+ public float aperture;
+ }
+
+
+
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 36)]
+ public struct IDDecodeInfo
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool decodeStatus; //瑙g爜缁撴灉鐘舵�丱K/NG
+ public float runtime; //瑙g爜鑰楁椂
+ public uint hardParamIndex;
+ public uint successCount; //瑙g爜鎴愬姛鏁�
+ public uint failedCount; //瑙g爜澶辫触鏁�
+ public uint decodeCount; //鎬昏В鐮佹暟
+ public double decodeRate; //瑙g爜鐜�
+ public uint IDDecodeROIInfoLength; //ROI瑙g爜淇℃伅鏁扮粍鐨勯暱搴�
+ }
+
+
+ //褰撳墠ROI瑙g爜缁撴灉
+ public struct IDDecodeROIInfo
+ {
+
+ public int roiIndex; //ROI缂栧彿
+ public int decodeReusltLength;
+ }
+
+
+ //褰撳墠瑙g爜缁撴灉,褰撳墠鐗堟湰姣忎釜瑙g爜缁撴灉涓殑闆嗗悎,鍙湁涓�涓爜鍒舵湁缁撴灉锛岄噷闈㈢殑闀垮害浠h〃鐨勬槸褰撳墠鐮佺被鍨嬬殑瑙g爜涓暟
+ public struct IDDecodeResult {
+ public int conbination;
+ public int dmResultsLength;
+ public int qrResultsLength;
+ public int pdf417ResultsLength;
+ public int barcodeResultsLength;
+ }
+
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi,Pack = 1)]
+ public struct IDDMCodeResult
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool state; // 褰撳墠缁撴灉瑙g爜鐘舵��
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256 )]
+ public char[] subType; // 瀛愮被鍨�
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] codeString; // 瑙g爜缁撴灉
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] polarity; // 鏋佹��
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] shape; // 鏍峰紡
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] mirror; // 闀滃儚
+ public int contrast; // 瀵规瘮搴�
+ public float moduleSize;
+ public float orientation;
+
+ }
+
+
+
+ //QR瑙g爜缁撴灉
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDQRCodeResult {
+
+ [MarshalAs(UnmanagedType.I1)]
+ public bool state; //褰撳墠缁撴灉瑙g爜鐘舵��
+ //IDCodeType codeType; //鏉$爜绫诲瀷
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] codeString; //瑙g爜缁撴灉
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] subType;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] polarity;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] errorLevel;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] mirror; //闀滃儚
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] version; //鐗堟湰淇℃伅
+ public int contrast;
+ public float moduleSize;
+ public float orientation; //瑙掑害
+ }
+
+
+
+
+ //PDF417瑙g爜缁撴灉
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDPDF417CodeResult {
+
+ [MarshalAs(UnmanagedType.I1)]
+ public bool state; //褰撳墠缁撴灉瑙g爜鐘舵��
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] codeString; //瑙g爜缁撴灉
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] subType; //瀛愮被鍨�
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] polarity; //鏋佹��
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] mirror; //闀滃儚
+ public int symbolRows;
+ public int symbolCols;
+ public int errorLevel;
+ public int contrast;
+ public float moduleHeight;
+ public float pixelPerModule; //moduleWidth
+ public float moduleRatio;
+ public float orientation; //瑙掑害
+
+ //IDQualityPDF417_15415 quality15415;
+ }
+
+
+ //barcode瑙g爜缁撴灉
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
+ public struct IDBarCodeResult {
+
+ [MarshalAs(UnmanagedType.I1)]
+ public bool state; //褰撳墠缁撴灉瑙g爜鐘舵��
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
+ public char[] codeString; //瑙g爜缁撴灉
+ public float orientation; //瑙掑害
+ public float pixelPerModule;
+
+ }
+
+ public unsafe struct StringList
+ {
+ public char** items;
+ public int size;
+ public int capacity;
+ }
+
+ }
+}
diff --git a/IDViewer_2D/IDViewerDemo.csproj b/IDViewer_2D/IDViewerDemo.csproj
new file mode 100644
index 0000000..c043921
--- /dev/null
+++ b/IDViewer_2D/IDViewerDemo.csproj
@@ -0,0 +1,79 @@
+锘�<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{72CF1572-12CD-4648-BAA8-1A27421191C4}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>IDViewerDemo</RootNamespace>
+ <AssemblyName>IDViewerDemo</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <OutputPath>bin\x64\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="IDViewerDefines.cs" />
+ <Compile Include="IDViewerSDK.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
diff --git a/IDViewer_2D/IDViewerSDK.cs b/IDViewer_2D/IDViewerSDK.cs
new file mode 100644
index 0000000..3ae38de
--- /dev/null
+++ b/IDViewer_2D/IDViewerSDK.cs
@@ -0,0 +1,1030 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+using static SmartScanner.IDViewerDefines;
+using System.Reflection;
+
+
+namespace SmartScanner
+{
+ class IDViewerSDK
+ {
+ public class Node
+ {
+ public IDViewerDefines.IDDeviceInfo data;
+ public Node next;
+ }
+
+ public struct LinkedList
+ {
+ public Node head;
+ [MarshalAs(UnmanagedType.SysInt)]
+ public int size;
+ }
+
+ /****************************************
+ IDImage
+ *****************************************/
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Init", CharSet = CharSet.Ansi)]
+ public static extern long IDImage_Init(ref IntPtr imagePtr);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Destroy", CharSet = CharSet.Ansi)]
+ public static extern void IDImage_Destroy(ref IntPtr imagePtr); //
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Width", CharSet = CharSet.Ansi)]
+ public static extern long IDImage_Width(IntPtr imageHandle); //鍥剧墖瀹藉害
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Height", CharSet = CharSet.Ansi)]
+ public static extern long IDImage_Height(IntPtr imageHandle); //鍥剧墖楂樺害
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Step", CharSet = CharSet.Ansi)]
+ public static extern long IDImage_Step(IntPtr imageHandle); //姝ラ暱
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_BitDepth", CharSet = CharSet.Auto)]
+ public static extern long IDImage_BitDepth(IntPtr imageHandle, ref IntPtr imageType); //浣嶆繁
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Channels", CharSet = CharSet.Ansi)]
+ public static extern long IDImage_Channels(IntPtr imageHandle); //閫氶亾鏁�
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_ImageData", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDImage_ImageData(IntPtr imageHandle); //娴呮嫹璐�
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_SaveImage", CharSet = CharSet.Ansi)]
+ public static extern long IDImage_SaveImage(IntPtr imageHandle, string filePath, int compression); //淇濆瓨
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_SaveImageW", CharSet = CharSet.Unicode)]
+ public static extern long IDImage_SaveImageW(IntPtr imageHandle, string filePath, int compression); //瀹藉瓧鑺備繚瀛�
+
+ /*
+ * VarPoint
+ */
+
+ // 鏋勯�犲嚱鏁板0鏄�
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "VarPoint_Create", CharSet = CharSet.Ansi)]
+ public static extern long VarPoint_Create(ref IntPtr handle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "VarPoint_CreateWithValues", CharSet = CharSet.Ansi)]
+ public static extern long VarPoint_CreateWithValues(ref IntPtr handle, double xPoint, double yPoint);
+
+ // 鏋愭瀯鍑芥暟澹版槑
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "VarPoint_Destroy", CharSet = CharSet.Ansi)]
+ public static extern void VarPoint_Destroy(ref IntPtr handle);
+
+ /*
+ * VarFlags
+ */
+
+
+ // 鏋勯�犲嚱鏁�
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "VarFlags_Create", CharSet = CharSet.Ansi)]
+ public static extern long VarFlags_Create(ref IntPtr handle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "VarFlags_CreateWithFlags", CharSet = CharSet.Ansi)]
+ public static extern long VarFlags_CreateWithFlags(ref IntPtr handle, uint flags);
+
+ // 鎴愬憳鍑芥暟
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "VarFlags_Set", CharSet = CharSet.Ansi)]
+ public static extern void VarFlags_Set(ref IntPtr handle, uint flag);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "VarFlags_Unset", CharSet = CharSet.Ansi)]
+ public static extern void VarFlags_Unset(ref IntPtr handle, uint flag);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "VarFlags_Reset", CharSet = CharSet.Ansi)]
+ public static extern void VarFlags_Reset(ref IntPtr handle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "VarFlags_Check", CharSet = CharSet.Ansi)]
+ public static extern bool VarFlags_Check(ref IntPtr handle, uint flag);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "VarFlags_Get", CharSet = CharSet.Ansi)]
+ public static extern uint VarFlags_Get(ref IntPtr handle);
+
+ // 鏋愭瀯鍑芥暟
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "VarFlags_Destroy", CharSet = CharSet.Ansi)]
+ public static extern void VarFlags_Destroy(ref IntPtr handle);
+
+ /*
+ * IDVariable
+ */
+ // 鍒涘缓 IDVariable 瀹炰緥
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariab_CreateIDVariable", CharSet = CharSet.Ansi)]
+
+ public static extern IntPtr IDVariab_CreateIDVariable();
+
+ // 閲婃斁 IDVariable 瀹炰緥
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariab_DestroyIDVariable", CharSet = CharSet.Ansi)]
+ public static extern void IDVariab_DestroyIDVariable(IntPtr IDVariableHandle);
+ // 璁剧疆 double 鏁版嵁
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariab_SetDataDouble", CharSet = CharSet.Ansi)]
+ public static extern void IDVariab_SetDataDouble(IntPtr IDVariableHandle, double data, bool setInit);
+
+ // 璁剧疆 string 鏁版嵁
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariab_SetDataChar", CharSet = CharSet.Ansi)]
+ public static extern void IDVariab_SetDataChar(IntPtr IDVariableHandle, string data, bool setInit);
+ // 璁剧疆 string 鏁版嵁
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariab_SetDataString", CharSet = CharSet.Ansi)]
+ public static extern void IDVariab_SetDataString(IntPtr IDVariableHandle, string data, bool setInit);
+
+ // 璁剧疆 bool 鏁版嵁
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariab_SetDataBool", CharSet = CharSet.Ansi)]
+ public static extern void IDVariab_SetDataBool(IntPtr IDVariableHandle, bool data, bool setInit);
+ // 璁剧疆 uint 鏁版嵁
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariab_SetDataUnsignedInt", CharSet = CharSet.Ansi)]
+ public static extern void IDVariab_SetDataUnsignedInt(IntPtr IDVariableHandle, uint data, bool setInit = false);
+ // 璁剧疆 VarPoint 鏁版嵁
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariab_SetDataVarPoint", CharSet = CharSet.Ansi)]
+ public static extern void IDVariab_SetDataVarPoint(IntPtr IDVariableHandle, ref double data, bool setInit = false);
+ // 璁剧疆vector<double> data鏁版嵁
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariab_SetDataVectorDouble", CharSet = CharSet.Ansi)]
+ public static extern void IDVariab_SetDataVectorDouble(IntPtr IDVariableHandle, IntPtr data, int size, bool setInit = false);
+ // 璁剧疆vector<string> data 鏁版嵁
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariab_SetDataStringArray", CharSet = CharSet.Ansi)]
+
+ public static extern void IDVariab_SetDataStringArray(IntPtr IDVariableHandle, string[] data, int size, bool setInit = false);
+
+ // 灏唙ector<bool>杞崲
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariab_SetDataBoolVector", CharSet = CharSet.Ansi)]
+ public static extern void IDVariab_SetDataBoolVector(IntPtr IDVariableHandle, ref bool data, int size, bool setInit = false);
+
+ // 灏唙ector<bool>杞崲涓篊椋庢牸鐨勬帴鍙�
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariab_SetDataVarFlags", CharSet = CharSet.Ansi)]
+ public static extern void IDVariab_SetDataVarFlags(IntPtr IDVariableHandle, ref IntPtr handle, bool setInit = false);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariable_ToNumber", CharSet = CharSet.Ansi)]
+ public static extern double IDVariable_ToNumber(IntPtr IDVariableHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariable_ToBool", CharSet = CharSet.Ansi)]
+ public static extern bool IDVariable_ToBool(IntPtr IDVariableHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariable_ToFlags", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDVariable_ToFlags(IntPtr IDVariableHandle);
+
+ /*
+ * class IDCodeParam
+ */
+ // 鏋勯�犲嚱鏁扮殑灏佽
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_Create", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDCodeParam_Create();
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_CreateCopy", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDCodeParam_CreateCopy(IntPtr IDCodeParamHandle);
+
+ // 浣跨敤涓嶅悓鍙傛暟鏋勯�犲嚱鏁扮殑灏佽
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_CreateFromQRCodeParam", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDCodeParam_CreateFromQRCodeParam(ref IDQRCodeParam qrCodeParam);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_CreateFromDMCodeParam", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDCodeParam_CreateFromDMCodeParam(ref IDDMCodeParam dmCodeParam);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_CreateFromPDF417CodeParam", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDCodeParam_CreateFromPDF417CodeParam(ref IDPDF417CodeParam pdf417CodeParam);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_CreateFromBarCodeParam", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDCodeParam_CreateFromBarCodeParam(ref IDBarCodeParam barCodeParam);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_CreateFromMicroQRParam", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDCodeParam_CreateFromMicroQRParam(ref IDMicroQRParam microQRParam);
+
+ // 璧嬪�兼搷浣滅鐨勫皝瑁�
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_Assign", CharSet = CharSet.Ansi)]
+ public static extern void IDCodeParam_Assign(IntPtr self, IntPtr IDCodeParamHandle);
+
+ // 璁剧疆鍜岃幏鍙栧弬鏁扮殑鍑芥暟灏佽
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_SetQRCodeParam", CharSet = CharSet.Ansi)]
+ public static extern void IDCodeParam_SetQRCodeParam(IntPtr self, ref IDQRCodeParam param);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_GetQRCodeParam", CharSet = CharSet.Ansi)]
+ public static extern ref IDQRCodeParam IDCodeParam_GetQRCodeParam(IntPtr self);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_SetDMCodeParam", CharSet = CharSet.Ansi)]
+ public static extern void IDCodeParam_SetDMCodeParam(IntPtr self, ref IDDMCodeParam param);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_GetDMCodeParam", CharSet = CharSet.Ansi)]
+ public static extern ref IDDMCodeParam IDCodeParam_GetDMCodeParam(IntPtr self);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_SetStackedCodeParam", CharSet = CharSet.Ansi)]
+ public static extern void IDCodeParam_SetStackedCodeParam(IntPtr self, ref IDQRCodeParam param);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_GetStackedCodeParam", CharSet = CharSet.Ansi)]
+ public static extern ref IDPDF417CodeParam IDCodeParam_GetStackedCodeParam(IntPtr self);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_SetBarCodeParam", CharSet = CharSet.Ansi)]
+
+ public static extern void IDCodeParam_SetBarCodeParam(IntPtr self, ref IDBarCodeParam param);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_GetBarCodeParam", CharSet = CharSet.Ansi)]
+ public static extern ref IDBarCodeParam IDCodeParam_GetBarCodeParam(IntPtr self);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_SetMicroQRParam", CharSet = CharSet.Ansi)]
+
+ public static extern void IDCodeParam_SetMicroQRParam(IntPtr self, ref IDMicroQRParam param);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_GetMicroQRParam", CharSet = CharSet.Ansi)]
+ public static extern ref IDMicroQRParam IDCodeParam_GetMicroQRParam(IntPtr self);
+
+ // 鑾峰彇绫诲瀷鐨勫皝瑁�
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCodeParam_GetType", CharSet = CharSet.Ansi)]
+ public static extern IDCodeCategory IDCodeParam_GetType(IntPtr self);
+
+
+ /**
+ * @brief setFilterRules 璁剧疆杩囨护瑙勫垯
+ * @param filterRules 杩囨护瑙勫垯
+ * @return
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetFilterRules", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_SetFilterRules(IntPtr deviceHandle, IDFilterRules filterRules);
+
+ /**
+ * @brief setFilterRules 鍒犻櫎杩囨护瑙勫垯
+ * @return
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_RemoveFilterRules", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_RemoveFilterRules(IntPtr deviceHandle);
+
+ /**
+ * @brief addEnvironmentVariable 娣诲姞涓�涓幆澧冨彉閲�
+ * @param varName 鐜鍙橀噺鍚嶇О
+ * @param varValue 鐜鍙橀噺瀵瑰簲鐨勫��
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_AddEnvironmentVariable", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_AddEnvironmentVariable(IntPtr deviceHandle, string varName, IntPtr varValue);
+
+ /**
+ * @brief deleteEnvironmentVariable 鍒犻櫎鎸囧畾鐜鍙橀噺
+ * @param varName 瑕佸垹闄ょ殑鐜鍙橀噺鍚嶇О
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_DeleteEnvironmentVariable", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_DeleteEnvironmentVariable(IntPtr deviceHandle, string varName);
+
+
+ /**
+ * @brief getEnvironmentVariableNames 鑾峰彇鎵�鏈夌幆澧冨彉閲忓悕
+ * @param varNames 鐜鍙橀噺鍚嶅垪琛�
+ * @return
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetEnvironmentVariableNamesEX", CharSet = CharSet.Ansi)] //浣跨敤鍚庨渶瑕佽皟鐢↖DDevice_FreeSolutionList 閲婃斁StringList
+ public static extern ref StringList IDDevice_GetEnvironmentVariableNamesEX(IntPtr deviceHandle);
+
+ /**
+ * @brief getEnvironmentVariable 鏍规嵁鍙橀噺鍚嶈幏鍙栫幆澧冨彉閲忕殑鍊�
+ * @param varName 鐜鍙橀噺鍚嶇О
+ * @param varValue 鐜鍙橀噺瀵瑰簲鐨勫��
+ * @return
+*/
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetEnvironmentVariable", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetEnvironmentVariable(IntPtr deviceHandle, ref string varName, IntPtr varValue);
+
+ /**
+ * @brief getParamValue 鑾峰彇鏂规鍙傛暟
+ * @param paramName 鍙傛暟鍚嶆灇涓惧��
+ * @param generalParam 鍙傛暟鍙栧��
+ * @return
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetParamValue", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetParamValue(IntPtr deviceHandle, IDGeneralParamsName paramName, IntPtr generalParam);
+
+
+ /**
+ * @brief getParamValue 璁剧疆鏂规鍙傛暟
+ * @param paramName 鍙傛暟鍚嶆灇涓惧��
+ * @param generalParam 鍙傛暟鍙栧��
+ * @return
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetParamValue", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_SetParamValue(IntPtr deviceHandle, IDGeneralParamsName paramName, IntPtr generalParam);
+ //class IDGeneralParam
+ // 鍒涘缓绌哄璞�
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create();
+
+ // 鍩虹绫诲瀷
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_Bool", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_Bool(bool data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_Char", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_Char(string data);
+
+
+ // 鏁板�肩被鍨�
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_UnsignedChar", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_UnsignedChar(char data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_Float", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_Float(float data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_UnsignedShort", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_UnsignedShort(ushort data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_UnsignedInt", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_UnsignedInt(uint data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_UnsignedLong", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_UnsignedLong(ulong data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_Long", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_Long(long data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_Int", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_Int(int data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_Short", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_Short(short data);
+
+ // 鐗规畩绫诲瀷
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_VarPoint", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_VarPoint(IntPtr data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_VarFlags", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_VarFlags(IntPtr data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_VectorDouble", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_VectorDouble(ref double data, int size);
+
+ /*
+ string[] data = new string[] { "data1", "data2", "data3" };
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_VectorString", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_VectorString(string[] data, int size);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_VectorBool", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_VectorBool(ref bool data, int size);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_UChar", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_UChar(char data);
+
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_UShort", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_UShort(ushort data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_UInt", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_UInt(uint data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_Create_ULong", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDGeneralParam_Create_ULong(ulong data);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_SetName", CharSet = CharSet.Ansi)]
+
+ public static extern void IDGeneralParam_SetName(IntPtr generalParamHandle, string name);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_GetName", CharSet = CharSet.Ansi)]
+ public static extern void IDGeneralParam_GetName(IntPtr generalParamHandle, string name);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_GetType", CharSet = CharSet.Ansi)]
+
+ public static extern IDGeneralParamsType IDGeneralParam_GetType(IntPtr generalParamHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_SetComment", CharSet = CharSet.Ansi)]
+ public static extern void IDGeneralParam_SetComment(IntPtr generalParamHandle, string comment);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_GetComment", CharSet = CharSet.Ansi)]
+
+ public static extern void IDGeneralParam_GetComment(IntPtr generalParamHandle, string comment);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_GetID", CharSet = CharSet.Ansi)]
+
+ public static extern int IDGeneralParam_GetID(IntPtr generalParamHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_SetID", CharSet = CharSet.Ansi)]
+
+ public static extern void IDGeneralParam_SetID(IntPtr generalParamHandle, int id);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_ToInt", CharSet = CharSet.Ansi)]
+
+ public static extern int IDGeneralParam_ToInt(IntPtr generalParamHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_ToNumber", CharSet = CharSet.Ansi)] //PLC鍙橀噺绫诲瀷鏄疦um
+
+ public static extern double IDGeneralParam_ToNumber(IntPtr generalParamHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_ToBool", CharSet = CharSet.Ansi)]
+
+ public static extern bool IDGeneralParam_ToBool(IntPtr generalParamHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_ToChar", CharSet = CharSet.Ansi)]
+
+ public static extern char IDGeneralParam_ToChar(IntPtr generalParamHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_ToFloat", CharSet = CharSet.Ansi)]
+
+ public static extern float IDGeneralParam_ToFloat(IntPtr generalParamHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_ToCharItr", CharSet = CharSet.Ansi)]
+
+ public static extern IntPtr IDGeneralParam_ToCharItr(IntPtr generalParamHandle); //瀛楃涓茬被鍨嬭幏鍙栧悗蹇呴』浣跨敤IDGeneralParam_FreeCharItr 瀵规寚閽堣繘琛岄噴鏀撅紱
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_FreeCharItr", CharSet = CharSet.Ansi)]
+
+ public static extern void IDGeneralParam_FreeCharItr(IntPtr ptr); //鍜屼笂闈DGeneralParam_ToCharItr閰嶅浣跨敤瀹屽悗杩涜閲婃斁锛�
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_ToUShort", CharSet = CharSet.Ansi)]
+ public static extern ushort IDGeneralParam_ToUShort(IntPtr generalParamHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_ToUInt", CharSet = CharSet.Ansi)]
+ public static extern uint IDGeneralParam_ToUInt(IntPtr generalParamHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_ToULong", CharSet = CharSet.Ansi)]
+ public static extern ulong IDGeneralParam_ToULong(IntPtr generalParamHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDGeneralParam_ToShort", CharSet = CharSet.Ansi)]
+ public static extern short IDGeneralParam_ToShort(IntPtr generalParamHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVariable_ToFlags", CharSet = CharSet.Ansi)]
+ public static extern long IDGeneralParam_ToLong(IntPtr generalParamHandle);
+
+ /****************************************
+ IDDevice
+ *****************************************/
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_Open", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_Open(IntPtr deviceHandle); //鎵撳紑璁惧
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_IsOpen", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_IsOpen(IntPtr deviceHandle); //鎵撳紑鐘舵��
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_StartRunning", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_StartRunning(IntPtr deviceHandle); //榛樿 娉ㄥ唽鍥炶皟 杩愯璁惧
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_StartDebugging", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_StartDebugging(IntPtr deviceHandle); //鍚姩璋冭瘯
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_IsDebugging", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_IsDebugging(IntPtr deviceHandle); //璋冭瘯鐘舵��
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_IsRunning", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_IsRunning(IntPtr deviceHandle); //杩愯鐘舵��
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_IsConnected", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_IsConnected(IntPtr deviceHandle); //杩炴帴鐘舵��
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_Stop", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_Stop(IntPtr deviceHandle); //鍋滄
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_Close", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_Close(IntPtr deviceHandle); //鍏抽棴
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_CaptureImage", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_CaptureImage(IntPtr deviceHandle, IntPtr imageHandle); //閲囬泦涓�娆�
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetLasersightEnable", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_SetLasersightEnable(IntPtr deviceHandle, bool enable); //璁剧疆浣胯兘鐬勫噯鍣�
+
+
+ /****************************************
+ DeviceInfo
+ *****************************************/
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetDeviceInfo", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetDeviceInfo(IntPtr deviceHandle, ref IDDeviceInfo DeviceInfoHandel); //鑾峰彇璁惧淇℃伅(SN/MAC/IP/MODEL)
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetHardWareParams", CharSet = CharSet.Ansi)]
+ public static extern IDViewerDefines.IDDeviceHarewareParams IDDevice_GetHardWareParams(IntPtr deviceHandle);
+
+ //姝ゆ帴鍙i渶瑕乂S2019浠ヤ笂鐨勭増鏈紝C#7.0鏂板寮曞叆浜嗘柊鐨勮娉時ef return鍜宺ef locals锛屽厑璁稿嚱鏁扮殑杩斿洖鍊间篃鍙互琚0鏄庝负寮曠敤
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetSolutionList", CharSet = CharSet.Ansi)]
+ public static extern ref StringList IDDevice_GetSolutionList(IntPtr deviceHandle, int timeout = 2000);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetRunningSolution", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_SetRunningSolution(IntPtr deviceHandle, string solutionName, int timeout = 2000);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetRunningSolution", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetRunningSolution(IntPtr deviceHandle, byte[] solutionName, int timeout = 2000);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_DeleteSolution", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_DeleteSolution(IntPtr deviceHandle, string solutionName, int timeout = 2000);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_Release", CharSet = CharSet.Ansi)]
+ public static extern void IDDevice_Release(IntPtr deviceHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_FreeSolutionList", CharSet = CharSet.Ansi)]
+ public static extern void IDDevice_FreeSolutionList(StringList solutionList);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_getROIInfoLength", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_getROIInfoLength(IntPtr deviceHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_getROIInfo", CharSet = CharSet.Ansi)] //鑾峰彇ROI
+ public static extern IDViewerDefines.IDROIInfo IDDevice_getROIInfo(IntPtr deviceHandle, int roiIndex);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_DeleteROI", CharSet = CharSet.Ansi)] //鍒犻櫎ROI
+ public static extern long IDDevice_DeleteROI(IntPtr deviceHandle, int roiIndex);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_AddROI", CharSet = CharSet.Ansi)] //娣诲姞ROI
+ public static extern long IDDevice_AddROI(IntPtr deviceHandle, IDViewerDefines.IDROIInfo roiInfo);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_ModifyROI", CharSet = CharSet.Ansi)] //淇敼ROI
+ public static extern long IDDevice_ModifyROI(IntPtr deviceHandle, int roiIndex, IDViewerDefines.IDPoint topLeftPoint, IDViewerDefines.IDPoint bottomRightPoint);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetFocusLocation", CharSet = CharSet.Ansi)]
+ public static unsafe extern long IDDevice_GetFocusLocation(IntPtr deviceHandle, int* focusLocation); //鑾峰彇鐒﹁窛浣嶇疆
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_AutoFocus", CharSet = CharSet.Ansi)] //鑷姩瀵圭劍
+ public static unsafe extern long IDDevice_AutoFocus(IntPtr deviceHandle, int paramIndex, ref int focusLocation);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetFocusLocation", CharSet = CharSet.Ansi)] //璁剧疆鐒﹁窛浣嶇疆
+ public static extern long IDDevice_SetFocusLocation(IntPtr deviceHandle, int paramIndex, int focusLocation);
+
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetExposure", CharSet = CharSet.Ansi)] //璁剧疆鏇濆厜
+ public static extern long IDDevice_SetExposure(IntPtr deviceHandle, int paramIndex, double exposure);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetGain", CharSet = CharSet.Ansi)] //璁剧疆澧炵泭
+ public static extern long IDDevice_SetGain(IntPtr deviceHandle, int paramIndex, int gain);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetGamma", CharSet = CharSet.Ansi)] //璁剧疆浼介┈
+ public static extern long IDDevice_SetGamma(IntPtr deviceHandle, int paramIndex, double gamma);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetIlluminate", CharSet = CharSet.Ansi)] //璁剧疆閫氶亾浜害锛氶�氶亾鏁帮紝璁剧疆-1鎴栧皬浜�0锛岃〃绀哄悓鏃惰缃墍鏈夐�氶亾
+ public static extern long IDDevice_SetIlluminate(IntPtr deviceHandle, int paramIndex, int channel, int value);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetIlluminateEnable", CharSet = CharSet.Ansi)] //璁剧疆閫氶亾浣胯兘锛氶�氶亾鏁帮紝璁剧疆-1鎴栧皬浜�0锛岃〃绀哄悓鏃惰缃墍鏈夐�氶亾
+ public static extern long IDDevice_SetIlluminateEnable(IntPtr deviceHandle, int paramIndex, int channel, bool enable);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetIlluminanatbrightnessLength", CharSet = CharSet.Ansi)]//鑾峰彇illuminanatbrightness 鏁伴噺
+ public static extern long IDDevice_GetIlluminanatbrightnessLength(IntPtr deviceHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetIlluminanatbrightness", CharSet = CharSet.Ansi)] //鑾峰彇illuminanatbrightness
+ public static extern IDNodeParam IDDevice_GetIlluminanatbrightness(IntPtr deviceHandle, uint index);
+
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetTriggerAllParams", CharSet = CharSet.Ansi)] //鑾峰彇鎵�鏈夎Е鍙戝弬鏁�
+ public static extern long IDDevice_GetTriggerAllParams(IntPtr deviceHandle, ref IDTriggerParams triggerParams, ref IDHardwareTrigger hardwareTrigger,
+ ref IDTcpServerTrigger tcpServerTrigger, ref IDTcpClientTrigger tcpClientTrigger, ref IDSerialPortTrigger serialPortTrigger, ref IDUDPTrigger udpTrigger);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetDataconfigAllParams", CharSet = CharSet.Ansi)] //鑾峰彇鎵�鏈夋暟鎹鐞嗗弬鏁�
+ public static extern long IDDevice_GetDataconfigAllParams(IntPtr deviceHandle, ref IDFilterInfo filterInfo, ref IDFilterRules filterRules, ref IDDataConfig dataConfig);
+
+ //[DllImport("IDViewerCSDK.dll", EntryPoint = "getTriggerAllParams", CharSet = CharSet.Ansi)]
+ //public static extern long getTriggerAllParams(IntPtr deviceHandle, IDTriggerParams triggerParams, IDHardwareTrigger hardwareTrigger,
+ // IDTcpServerTrigger tcpServerTrigger, IDTcpClientTrigger tcpClientTrigger, IDSerialPortTrigger serialPortTrigger, IDUDPTrigger udpTrigger);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetCommunicationAllParams", CharSet = CharSet.Ansi)] //鑾峰彇鎵�鏈夐�氫俊鍙傛暟
+ public static extern long IDDevice_GetCommunicationAllParams(IntPtr deviceHandle, ref IDTcpServerCommunication tcpServerInfo, ref IDTcpClientCommunication tcpClientInfo, ref IDSerialPortCommunication serialPortInfo,
+ ref IDKeyboardConfig keyboardInfo, ref IDEipConfig eipConfig, ref IDModbusConfig modbusConfig, ref IDProfinetConfig profinetConfig, ref IDFtpConfig ftpConfig, ref IDWebpageConfig webpageConfig,
+ ref IDFinsConfig finsConfig, ref IDHttpConfig httpConfig, ref IDNetworkingConfig networkingConfig);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetCommunicationAllParams_V2", CharSet = CharSet.Ansi)] //鑾峰彇鎵�鏈夐�氫俊鍙傛暟
+ public static extern long IDDevice_GetCommunicationAllParams_V2(IntPtr deviceHandle, ref IDTcpServerCommunication tcpServerInfo, ref IDTcpClientCommunication tcpClientInfo, ref IDSerialPortCommunication serialPortInfo,
+ ref IDKeyboardConfig keyboardInfo, ref IDEipConfig eipConfig, ref IDModbusConfig modbusConfig, ref IDProfinetConfig profinetConfig, ref IDFtpConfig ftpConfig, ref IDWebpageConfig webpageConfig,
+ ref IDFinsConfig finsConfig, ref IDHttpConfig httpConfig, ref IDNetworkingConfig networkingConfig, ref IDMcConfig mcConfig, ref IDUdpConfig iDUdpConfig);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_DownLoadCurrentSolution", CharSet = CharSet.Ansi)] //涓嬭浇褰撳墠鏂规 鍙傛暟璁剧疆涓轰复鏃惰缃紝闇�瑕佽皟鐢ㄨ鏂规硶鎵嶈兘淇濆瓨鍒拌澶囩绾跨敓鏁�
+ public static extern long IDDevice_DownLoadCurrentSolution(IntPtr deviceHandle);
+
+
+
+ /**
+ * @brief uploadSolution 涓婁紶鏂规
+ * @param solutionData 鏂规鏁版嵁
+ * @param solutionName 鏂规鍚嶇О
+ * @param timeout 瓒呮椂鏃堕棿
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_UploadSolution", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_UploadSolution(IntPtr deviceHandle, string solutionData, string solutionName, int timeout = 3000);
+ /**
+ * @brief downLoadSolution 涓嬭浇鏂规
+ * @param solutionData 鏂规鏁版嵁
+ * @param solutionName 鏂规鍚嶇О
+ * @param timeout 瓒呮椂鏃堕棿
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_DownLoadSolution", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_DownLoadSolution(IntPtr deviceHandle, ref string solutionData, string solutionName, int timeout = 3000);
+
+ /**
+ * @brief openMC 鎵撳紑MC
+ * @param mode MC 鍝佺墝鍨嬪彿锛堝彇鍊艰寖鍥达細(Mitsubishi_L:0,Mitsubishi_Q:1,Mitsubishi_R:2,Mitsubishi_A:4,Mitsubishi_Fx3U:5,Mitsubishi_Fx5U:6)锛�
+ * @param format MC 鏍煎紡 锛堝彇鍊艰寖鍥达細BIN:0,ASCII:1锛�
+ * @param ip MC IP鍦板潃
+ * @param port MC 绔彛
+ * @param startAddress MC 璧峰鍦板潃
+ * @param resultSwap MC 缁撴灉浜ゆ崲
+ * @param resultSize MC 缁撴灉澶у皬
+ * @param timeout MC MC缁撴灉瓒呮椂
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_OpenMC", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_OpenMC(IntPtr deviceHandle, IDMcBrandModel mode, IDMcDataFormat format, string ip, int port, int startAddress, bool resultSwap, int resultSize, int timeout);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_CloseMC", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_CloseMC(IntPtr deviceHandle);
+
+ /**
+ * @brief getMcInfo 鑾峰彇褰撳墠MC杩炴帴閰嶇疆淇℃伅
+ * @param mode MC鍝佺墝鍨嬪彿
+ * @param format MC鏍煎紡锛圔IN/ASCII锛�
+ * @param ip MC鐨処P鍦板潃
+ * @param port MC鐨勭鍙�
+ * @param startAddress MC璧峰鍦板潃
+ * @param resultSwap MC缁撴灉浜ゆ崲閰嶇疆
+ * @param resultSize MC缁撴灉澶у皬
+ * @param timeout MC缁撴灉瓒呮椂鏃堕棿
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetMcInfo", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetMcInfo(IntPtr deviceHandle, ref IDMcBrandModel mode, ref IDMcDataFormat format, ref string ip, ref int port, ref int startAddress, ref bool resultSwap, ref int resultSize, ref int timeout);
+
+ /*
+ * 2025.2.15 鏂板IDDevice绫绘帴鍙�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_ClearROI", CharSet = CharSet.Ansi)] //娓呴櫎鎵�鏈塕OI
+ public static extern long IDDevice_ClearROI(IntPtr deviceHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_AddImageROI", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_AddImageROI(IntPtr deviceHandle, ref IDImageROI roiInfos); //娣诲姞鍥惧儚ROI
+
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_DeleteImageROI", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_DeleteImageROI(IntPtr deviceHandle, int roiIndex); //鍒犻櫎鍥惧儚ROI
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetROICodeNum", CharSet = CharSet.Ansi)] //璁剧疆鎸囧畾 ROI 鐨勭爜鏁扮洰
+ public static extern long IDDevice_SetROICodeNum(IntPtr deviceHandle, int roiIndex, int codeNum);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_ModifyImageROI", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_ModifyImageROI(IntPtr deviceHandle, int roiIndex, IDPoint topLeftPoint, IDPoint bottomRightPoint);//鏇存柊鍥惧儚ROI
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetImageROIsLength", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetImageROIsLength(IntPtr deviceHandle);//鑾峰彇鍥惧儚ROI鍒楄〃闀垮害
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetImageROIsInfo", CharSet = CharSet.Ansi)]
+ public static extern IDImageROI IDDevice_GetImageROIsInfo(IntPtr deviceHandle, uint index);//鑾峰彇鍥惧儚ROI
+
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_ClearImageROI", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_ClearImageROI(IntPtr deviceHandle);//娓呴櫎鎵�鏈夊浘鍍廟OI
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_AddCodeType", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_AddCodeType(IntPtr deviceHandle, IDCodeType type);//娣诲姞鐮佸埗
+
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_DeleteCodeType", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_DeleteCodeType(IntPtr deviceHandle, IDCodeType type);//鍒犻櫎鐮佸埗
+
+ /**
+ * @brief clearCodeType 娓呴櫎鎵�鏈夌爜鍒�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_ClearCodeType", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_ClearCodeType(IntPtr deviceHandle);
+
+ /**
+ * @brief getImageROIs 鑾峰彇鐮佸埗淇℃伅鍒楄〃闀垮害
+ * @param
+ * @return 鑾峰彇鐮佸埗淇℃伅鍒楄〃闀垮害
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetCodeTypesLength", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetCodeTypesLength(IntPtr deviceHandle);
+
+ /**
+ * @brief getImageROIs 鑾峰彇鐮佸埗淇℃伅
+ * @param index 绗嚑涓狪DCodeType_C淇℃伅
+ * @return IDCodeType_C
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetCodeTypesInfo", CharSet = CharSet.Ansi)]
+ public static extern IDCodeType IDDevice_GetCodeTypesInfo(IntPtr deviceHandle, uint index);
+
+
+ /**
+ * @brief setCodeCategoryParam 璁剧疆鏉$爜绠楁硶鍙傛暟
+ * @param codeType 鏉$爜绫诲瀷
+ * @param codeParam 鏉$爜鍙傛暟淇℃伅
+ * @return 閿欒鐮�
+*/
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetCodeCategoryParam", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_SetCodeCategoryParam(IntPtr deviceHandle, IDCodeCategory codeType, IntPtr codeParam);
+
+
+
+ /**
+ * @brief getSolutionImageParams 鑾峰彇褰撳墠鏂规鍥惧儚璁剧疆椤靛弬鏁�
+ * @param solutionImage 鍥惧儚椤靛弬鏁� //鍥惧儚鍙傛暟
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetSolutionImage", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetSolutionImage(IntPtr deviceHandle, ref IDSolutionImage solutionImage);
+
+ /**
+ * @brief getSolutionImageParams 鑾峰彇鍥惧儚鍙傛暟缁勯儴鍒嗗弬鏁�
+ * @param solutionImageParams 鍥惧儚鍙傛暟缁勯儴鍒嗗弬鏁�
+ * @param index 鍙傛暟缁勭鍑犱釜鍙傛暟
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetSolutionImageParams", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetSolutionImageParams(IntPtr deviceHandle, int index, ref IDSolutionImageParams solutionImageParams);
+
+
+ /**
+ * @brief getSolutionImageParams 鑾峰彇鍥惧儚鍏夋簮閫氶亾鍙傛暟
+ * @param solutionImageParams 鍥惧儚鍙傛暟缁勯儴鍒嗗弬鏁�
+ * @param index 鍙傛暟缁勭鍑犱釜鍙傛暟
+ * @param illIndex 鍙傛暟缁勭鍑犱釜鍙傛暟鐨勭鍑犱釜鍏夋簮閫氶亾鍙傛暟
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetSolutionImageIlluminant", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetSolutionImageIlluminant(IntPtr deviceHandle, int index, int illIndex, ref IDSolutionImageIlluminant solutionImageIlluminant);
+
+
+ /**
+ * @brief appendLastImageParam 鍩轰簬鏈�鍚庝竴涓弬鏁拌妭鐐规柊澧炲浘鍍忓弬鏁扮粍
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_AppendLastImageParam", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_AppendLastImageParam(IntPtr deviceHandle);
+
+ /**
+ * @brief deleteImageParamAtIndex 鍒犻櫎鍥惧儚鍙傛暟缁�
+ * @param paramIndex 鍙傛暟缁勫簭鍙�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_DeleteImageParamAtIndex", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_DeleteImageParamAtIndex(IntPtr deviceHandle, int paramIndex);
+
+
+ /**
+ * @brief setAutoExposureEnabled 璁剧疆浣胯兘鑷姩鏇濆厜
+ * @param enabled 鏄惁鍚敤鑷姩鏇濆厜锛宍true` 涓哄惎鐢紝`false` 涓虹鐢�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetAutoExposureEnabled", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_SetAutoExposureEnabled(IntPtr deviceHandle, bool enabled);
+
+ /**
+ * @brief getExposure 鑾峰彇褰撳墠鏇濆厜
+ * @param exposure 鏇濆厜鍊�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetExposure", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetExposure(IntPtr deviceHandle, ref double exposure);
+
+ /**
+ * @brief setAutoGainEnabled 璁剧疆浣胯兘鑷姩澧炵泭
+ * @param enabled 鏄惁鍚敤鑷姩澧炵泭锛宍true` 涓哄惎鐢紝`false` 涓虹鐢�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetAutoGainEnabled", CharSet = CharSet.Ansi)]
+
+ public static extern long IDDevice_SetAutoGainEnabled(IntPtr deviceHandle, bool enabled);
+
+ /**
+ * @brief getGainCount 鑾峰彇澧炵泭鍒楄〃涓暟
+ * @param count 澧炵泭鍒楄〃涓暟
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetGainCount", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetGainCount(IntPtr deviceHandle, ref int count);
+
+ /**
+ * @brief getGain 鑾峰彇褰撳墠澧炵泭
+ * @param gain 澧炵泭
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetGain", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetGain(IntPtr deviceHandle, ref int gain);
+
+ /**
+ * @brief getGain 鑾峰彇褰撳墠澧炵泭
+ * @param paramIndex 鍙傛暟缁�
+ * @param gain 澧炵泭鍊�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetGain_1330", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetGain_1330(IntPtr deviceHandle, int paramIndex, ref double gain);
+
+ /**
+ * @brief getGain 鑾峰彇澧炵泭鍒楄〃涓寚瀹氫笅鏍囧搴旂殑澧炵泭鍊�
+ * @param index 澧炵泭鍊煎湪鍒楄〃涓殑绱㈠紩
+ * @param gain 澧炵泭鍊�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetGainValueByIndex_1330", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetGainValueByIndex_1330(IntPtr deviceHandle, int paramIndex, ref double gain);
+
+ /**
+ * @brief getGamma 鑾峰彇褰撳墠浼介┈
+ * @param gamma 浼介┈鍊�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetGamma", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetGamma(IntPtr deviceHandle, ref double gamma);
+
+ /**
+ * @brief setDIParam 璁剧疆DI鍙傛暟
+ * @param pin 寮曡剼缂栧彿
+ * @param params DI鍙傛暟淇℃伅
+ * @return
+ */
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetDIParam", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_SetDIParam(IntPtr deviceHandle, uint pin, ref IDDIParams iDDIParams);
+
+
+ /**
+ * @brief setDOParam 璁剧疆DO鍙傛暟
+ * @param pin 寮曡剼缂栧彿
+ * @param params DO鍙傛暟淇℃伅
+ * @return
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetDOParam", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_SetDOParam(IntPtr deviceHandle, uint pin, IDDOParams iDDOParams);
+
+
+
+ /*
+ * @brief getIOConfigAllParams 鑾峰彇鎵�鏈塈O杈撳叆鍙傛暟淇℃伅闀垮害
+ * @
+ * @
+ * @return
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "getIOConfigInputParamsLength", CharSet = CharSet.Ansi)]
+ public static extern long getIOConfigInputParamsLength(IntPtr deviceHandle);
+
+ /*
+ * 鑾峰彇IO杈撳叆鍙傛暟淇℃伅
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "getIOConfigInputParamsInfo", CharSet = CharSet.Ansi)]
+ public static extern long getIOConfigInputParamsInfo(IntPtr deviceHandle, uint index, ref IDDIParams IDDIParams);
+
+ /* @brief getIOConfigAllParams 鑾峰彇鎵�鏈塈O杈撳嚭鍙傛暟淇℃伅闀垮害
+ * @
+ * @
+ * @return
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "getIOConfigOutputParamsLength", CharSet = CharSet.Ansi)]
+ public static extern long getIOConfigOutputParamsLength(IntPtr deviceHandle);
+
+ /**
+ * @brief addDOParam 娣诲姞DO鍙傛暟
+ * @param params DO鍙傛暟淇℃伅
+ * @return
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "addDOParam", CharSet = CharSet.Ansi)]
+ public static extern long addDOParam(IntPtr deviceHandle, ref IDDOParams iDDOParams);
+
+ /*
+ * 鑾峰彇IO杈撳嚭鍙傛暟淇℃伅
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "getIOConfigOutputParamsInfo", CharSet = CharSet.Ansi)]
+ public static extern long getIOConfigOutputParamsInfo(IntPtr deviceHandle, uint index, ref IDDOParams IDDOParams);
+
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_ResultNotify_")]
+ public static extern void IDCallback_ResultNotify_(IntPtr deviceHandle, IntPtr resCallback); // 缁撴灉鍥炶皟鍑芥暟
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_ResultNotify_Image_")]
+ public static extern void IDCallback_ResultNotify_Image_(IntPtr deviceHandle, IntPtr resCallback); // 鍥剧墖鍥炶皟鍑芥暟
+ //[DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDecodeInfo")]
+ //public extern static IntPtr IDCallback_GetIDDecodeInfo(IntPtr decodeInfoHandel); //IDCallback_GetIDDecodeInfo
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDecodeInfo_A")]
+ public extern static long IDCallback_GetIDDecodeInfo_A(IntPtr decodeInfoHandel, ref IDDecodeInfo info); //IDCallback_GetIDDecodeInfo
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDecodeROIInfo", CharSet = CharSet.Ansi)]
+ public static extern IDDecodeROIInfo IDCallback_GetIDDecodeROIInfo(IntPtr decodeInfoHandel, uint index);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDecodeResult", CharSet = CharSet.Ansi)]
+ public static extern IDDecodeResult IDCallback_GetIDDecodeResult(IntPtr decodeInfoHandel, uint decodeROIInfoIndex, uint index);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDMCodeResult", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetIDDMCodeResult(IntPtr decodeInfoHandel, uint decodeROIInfoIndex, //DM瑙g爜鏁版嵁
+ uint index, ref IDDMCodeResult IDDMCodeResultData);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_CheckDeCodeTypeResult", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_CheckDeCodeTypeResult(IntPtr decodeInfoHandel, uint decodeType, uint decodeROIInfoIndex); //璇︾粏鐮佺被鍨嬬殑缁撴灉闀垮害 ,0琛ㄧず娌℃湁瑙g爜缁撴灉锛�-1 琛ㄧずroi涓嶅瓨鍦�
+
+ //[DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetID_QRODE_Result", CharSet = CharSet.Ansi)]
+ //public static extern long IDCallback_GetID_QRODE_Result(IntPtr decodeInfoHandel, uint decodeROIInfoIndex, //QR瑙g爜鏁版嵁
+ // uint index, ref IDQRCodeResult iDQRCodeResult);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDMCodeResult_QualityDM15415", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetIDDMCodeResult_QualityDM15415(IntPtr decodeInfoHandel, uint decodeROIInfoIndex, //15414dm鐮佽川閲�
+ uint index, ref IDQualityDM15415 iDQualityDM15415);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDMCodeResult_QUALITY_DM_29158", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetIDDMCodeResult_QUALITY_DM_29158(IntPtr decodeInfoHandel, uint decodeROIInfoIndex, //29158dm鐮佽川閲�
+ uint index, ref IDQualityDM29518 iDQualityDM29518);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDPDF417CodeResult", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetIDPDF417CodeResult(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
+ uint index, ref IDPDF417CodeResult iDPDF417CodeResultData);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetID_QR_CODE_Result", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetID_QR_CODE_Result(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
+ uint index, ref IDQRCodeResult iDQRCodeResult);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetID_QR_CODE_Result_IDQualityQR15415", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetID_QR_CODE_Result_IDQualityQR15415(IntPtr decodeInfoHandel, uint decodeROIInfoIndex, //15414qr鐮佽川閲�
+ uint index, ref IDQualityQR15415 iDQualityQR15415);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetID_QR_CODE_Result_IDQualityQR29518", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetID_QR_CODE_Result_IDQualityQR29518(IntPtr decodeInfoHandel, uint decodeROIInfoIndex, //29518qr鐮佽川閲�
+ uint index, ref IDQualityQR29518 iDQualityQR29518);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDPDF417CodeResult_IDQualityPDF417_15415", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetIDPDF417CodeResult_IDQualityPDF417_15415(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
+ uint index, ref IDQualityPDF417_15415 iDQualityPDF417_15415);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDBarCodeResult", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetIDBarCodeResult(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
+ uint index, ref IDBarCodeResult iDBarCodeResultData);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDBarCodeResult_IDQuality15416", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetIDBarCodeResult_IDQuality15416(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
+ uint index, ref IDQuality15416 iDQuality15416);
+
+ /*
+ * decodeInfoHandel 鍙ユ焺
+ * decodeType 瑙g爜绫诲瀷 姣斿 1dm 锛�2 qr锛�3 pdf417,4 barcode
+ * decodeROIInfoIndex roi 绗嚑涓猺oi
+ * index 绗嚑涓叿浣撹В鐮佺被鍨嬬粨鏋�
+ * pointIndex绗嚑涓偣
+ * Position 鐐规暟鎹�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDResultPosition", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetIDResultPosition(IntPtr decodeInfoHandel, uint decodeType, uint decodeROIInfoIndex,
+ uint index, uint pointIndex, ref IDPoint iDPoint);
+
+ /**
+ * @brief IDVIEWER_Init 浣跨敤SDK鍏朵粬鍔熻兘鍓嶉渶瑕佸厛璋冪敤璇ュ垵濮嬪寲鏂规硶
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_Init_", CharSet = CharSet.Ansi)]
+ public extern static long IDVIEWER_Init_();
+
+ /**
+ * @brief IDVIEWER_DiscoveryDevices 鎵弿璁惧鍒楄〃
+ * @param deviceList 杩斿洖鑾峰彇鐨勮澶囧垪琛�
+ * @param discoveryTime 鎵弿鍛ㄦ湡,榛樿200(鍗曚綅姣)
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_DiscoveryDevices_", CharSet = CharSet.Ansi)]
+ public extern static IntPtr IDVIEWER_DiscoveryDevices_(uint discoveryTime = 1000);
+
+ /**
+ * @brief IDVIEWER_GetDevicesLength_ 璁惧鍒楄〃闀垮害
+ * @param deviceList 杩斿洖鑾峰彇鐨勮澶囧垪琛ㄩ暱搴�
+ *
+ * @return 闀垮害
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_GetDevicesLength_", CharSet = CharSet.Ansi)]
+ public extern static long IDVIEWER_GetDevicesLength_(IntPtr DevicesList);
+
+ /**
+ * @brief IDVIEWER_SelectIDDeviceInfo_ 鑾峰彇鏌愪釜搴忓彿鐨勮澶�
+ * @param DevicesList 褰撳墠璁惧鍒楄〃鎸囬拡
+ * @param index 璁惧鍒楄〃鐨勫簭鍙�
+
+ * @return 璁惧淇℃伅
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_SelectIDDeviceInfo_", CharSet = CharSet.Ansi)]
+ public extern static long IDVIEWER_SelectIDDeviceInfo_(IntPtr DevicesList, ref IDDeviceInfo IDDeviceInfoHandel, uint index);
+
+ /**
+ * @brief IDVIEWER_SetIP 璁剧疆IP 璁剧疆IP鍚庨渶瑕侀噸鏂版壂鎻�
+ * @param deviceInfo 褰撳墠璁惧淇℃伅
+ * @param iPv4 鏂扮殑IP鍦板潃
+ * @param mask 鏂扮殑MASK鍦板潃
+ * @param gateway 鏂扮殑缃戝叧鍦板潃
+ * @param isStatic 鏄惁璁剧疆闈欐�両P(false涓轰复鏃禝P)
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_SetIP_", CharSet = CharSet.Ansi)]
+ public static extern long IDVIEWER_SetIP_(ref IDViewerDefines.IDDeviceInfo deviceInfo, string iPv4, string mask, string gateway, bool isStatic);
+
+ /**
+ * @brief IDVIEWER_CreateDevice CreateDevice 鍒涘缓璁惧
+ * @param deviceInfo 褰撳墠璁惧淇℃伅
+ * @param device 鍒涘缓鐨勮澶囨寚閽�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_CreateDevice_", CharSet = CharSet.Ansi)]
+ public static extern long IDVIEWER_CreateDevice_(ref IDViewerDefines.IDDeviceInfo deviceInfo, ref IntPtr deviceHandle);
+
+ /**
+ * @brief IDVIEWERreateDevice IDVIEWERreateDeviceBySN 鏇村姞SN鍒涘缓璁惧
+ * @param cameraSN 褰撳墠璁惧SN
+ * @param device 鍒涘缓鐨勮澶囨寚閽�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_CreateDeviceBySN_", CharSet = CharSet.Ansi)]
+ public static extern long IDVIEWER_CreateDeviceBySN_(string cameraSN, ref IntPtr deviceHandle);
+
+ /**
+ * @brief IDVIEWERreateDevice IDVIEWERreateDeviceByIP 鏇村姞SN鍒涘缓璁惧
+ * @param cameraIP 褰撳墠璁惧IP
+ * @param device 鍒涘缓鐨勮澶囨寚閽�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_CreateDeviceByIP_", CharSet = CharSet.Ansi)]
+ public static extern long IDVIEWER_CreateDeviceByIP_(string cameraIP, ref IntPtr deviceHandle);
+ /**
+ * @brief IDVIEWER_UnInit 浣跨敤瀹孲DK鍚庤皟鐢ㄩ噴鏀捐祫婧�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_UnInit_", CharSet = CharSet.Ansi)]
+ public static extern long IDVIEWER_UnInit_(IntPtr deviceList);
+
+ }
+}
+
+
+
diff --git a/IDViewer_2D/IDViewerSDK1.cs b/IDViewer_2D/IDViewerSDK1.cs
new file mode 100644
index 0000000..4f8fa5e
--- /dev/null
+++ b/IDViewer_2D/IDViewerSDK1.cs
@@ -0,0 +1,230 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+using static IDViewer_2D.IDViewerDefines;
+
+namespace IDViewer_2D
+{
+ class IDViewerSDK
+ {
+ public class Node
+ {
+ public IDViewerDefines.IDDeviceInfo data;
+ public Node next;
+ }
+
+ public struct LinkedList
+ {
+ public Node head;
+ [MarshalAs(UnmanagedType.SysInt)]
+ public int size;
+ }
+ /****************************************
+ IDImage
+ //*****************************************/
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Init", CharSet = CharSet.Ansi)]
+ public static extern long IDImage_Init(ref IntPtr imagePtr);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Destroy", CharSet = CharSet.Ansi)]
+ public static extern void IDImage_Destroy(ref IntPtr imagePtr);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Width", CharSet = CharSet.Ansi)]
+ public static extern long IDImage_Width(IntPtr imageHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Height", CharSet = CharSet.Ansi)]
+ public static extern long IDImage_Height(IntPtr imageHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Step", CharSet = CharSet.Ansi)]
+ public static extern long IDImage_Step(IntPtr imageHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_BitDepth", CharSet = CharSet.Auto)]
+ public static extern long IDImage_BitDepth(IntPtr imageHandle,ref IntPtr imageType);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_Channels", CharSet = CharSet.Ansi)]
+ public static extern long IDImage_Channels(IntPtr imageHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_ImageData", CharSet = CharSet.Ansi)]
+ public static extern IntPtr IDImage_ImageData(IntPtr imageHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_SaveImage", CharSet = CharSet.Ansi)]
+ public static extern long IDImage_SaveImage(IntPtr imageHandle, string filePath, int compression);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDImage_SaveImageW", CharSet = CharSet.Unicode)]
+ public static extern long IDImage_SaveImageW(IntPtr imageHandle, string filePath, int compression);
+
+
+ /****************************************
+ IDDevice
+ *****************************************/
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_Open", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_Open(IntPtr deviceHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_IsOpen", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_IsOpen(IntPtr deviceHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_StartRunning", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_StartRunning(IntPtr deviceHandle,int isCallBack); //isCallBack>0 娉ㄥ唽鍥炶皟锛岀瓑浜�0 涓嶆敞鍐屽洖璋�
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_StartDebugging", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_StartDebugging(IntPtr deviceHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_IsRunning", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_IsRunning(IntPtr deviceHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_IsConnected", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_IsConnected(IntPtr deviceHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_Stop", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_Stop(IntPtr deviceHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_Close", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_Close(IntPtr deviceHandle);
+
+ /****************************************
+ DeviceInfo
+ *****************************************/
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetDeviceInfo", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetDeviceInfo(IntPtr deviceHandle, ref IDDeviceInfo DeviceInfoHandel);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetHardWareParams", CharSet = CharSet.Ansi)]
+ public static extern IDViewerDefines.IDDeviceHarewareParams IDDevice_GetHardWareParams(IntPtr deviceHandle);
+
+ //姝ゆ帴鍙i渶瑕乂S2019浠ヤ笂鐗堟湰锛孋#7.0鏇存柊鏀寔寮曞叆浜嗘柊鐨勮娉時ef return鍜宺ef locals锛屽厑璁稿嚱鏁扮殑杩斿洖鍊间篃鍙互琚0鏄庝负寮曠敤
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetSolutionList", CharSet = CharSet.Ansi)]
+ public static extern ref StringList IDDevice_GetSolutionList(IntPtr deviceHandle, int timeout = 2000);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_SetRunningSolution", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_SetRunningSolution(IntPtr deviceHandle,byte[] solutionName, int timeout = 2000);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetRunningSolution", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetRunningSolution(IntPtr deviceHandle, byte[] solutionName, int timeout = 2000);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_DeleteSolution", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_DeleteSolution(IntPtr deviceHandle, string solutionName, int timeout = 2000);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_Release", CharSet = CharSet.Ansi)]
+ public static extern void IDDevice_Release(IntPtr deviceHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_FreeSolutionList", CharSet = CharSet.Ansi)]
+ public static extern void IDDevice_FreeSolutionList(StringList solutionList);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetIlluminanatbrightnessLength", CharSet = CharSet.Ansi)]
+ public static extern long IDDevice_GetIlluminanatbrightnessLength(IntPtr deviceHandle);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDDevice_GetIlluminanatbrightness", CharSet = CharSet.Ansi)]
+ public static extern IDNodeParam IDDevice_GetIlluminanatbrightness(IntPtr deviceHandle, uint index);
+
+ //鍥炶皟鍑芥暟
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_ResultNotify_")]
+ public static extern void IDCallback_ResultNotify_(IntPtr deviceHandle, IntPtr resCallback);
+
+ //[DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDecodeInfo")]
+ //public extern static IntPtr IDCallback_GetIDDecodeInfo(IntPtr decodeInfoHandel); //IDCallback_GetIDDecodeInfo
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDecodeInfo_A")]
+ public extern static long IDCallback_GetIDDecodeInfo_A(IntPtr decodeInfoHandel,ref IDDecodeInfo info); //IDCallback_GetIDDecodeInfo
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDecodeROIInfo", CharSet = CharSet.Ansi)]
+ public static extern IDDecodeROIInfo IDCallback_GetIDDecodeROIInfo(IntPtr decodeInfoHandel, uint index);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDecodeResult", CharSet = CharSet.Ansi)]
+ public static extern IDDecodeResult IDCallback_GetIDDecodeResult(IntPtr decodeInfoHandel, uint decodeROIInfoIndex, uint index);
+
+ /*
+ *decodeROIInfoIndex 绗嚑涓猂OI
+ *decodeResultIndex 鍏堝拷鐣ワ紝
+ *index ROI鍐呯殑绗嚑涓垚鍔熻В鐮佺粨鏋�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDDMCodeResult", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetIDDMCodeResult(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
+ uint decodeResultIndex, uint index, ref IDDMCodeResult IDDMCodeResultData);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetID_QR_CODE_Result", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetID_QR_CODE_Result(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
+ uint decodeResultIndex, uint index, ref IDQRCodeResult ID_QR_CODE_RESULTData);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDPDF417CodeResult", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetIDPDF417CodeResult(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
+ uint decodeResultIndex, uint index, ref IDPDF417CodeResult IDPDF417CodeResultData);
+
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDCallback_GetIDBarCodeResult", CharSet = CharSet.Ansi)]
+ public static extern long IDCallback_GetIDBarCodeResult(IntPtr decodeInfoHandel, uint decodeROIInfoIndex,
+ uint decodeResultIndex, uint index, ref IDBarCodeResult IDBarCodeResultData);
+ /**
+ * @brief IDVIEWER_Init 浣跨敤SDK鍏朵粬鍔熻兘鍓嶉渶瑕佸厛璋冪敤璇ュ垵濮嬪寲鏂规硶
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_Init_", CharSet = CharSet.Ansi)]
+ public extern static long IDVIEWER_Init_();
+
+ /**
+ * @brief IDVIEWER_DiscoveryDevices 鎵弿璁惧鍒楄〃
+ * @param deviceList 杩斿洖鑾峰彇鐨勮澶囧垪琛�
+ * @param discoveryTime 鎵弿鍛ㄦ湡,榛樿200(鍗曚綅姣)
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_DiscoveryDevices_", CharSet = CharSet.Ansi)]
+ public extern static IntPtr IDVIEWER_DiscoveryDevices_(uint discoveryTime = 200);
+
+ /**
+ * @brief IDVIEWER_GetDevicesLength_ 璁惧鍒楄〃闀垮害
+ * @param deviceList 杩斿洖鑾峰彇鐨勮澶囧垪琛ㄩ暱搴�
+ *
+ * @return 闀垮害
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_GetDevicesLength_", CharSet = CharSet.Ansi)]
+ public extern static long IDVIEWER_GetDevicesLength_(IntPtr DevicesList);
+
+ /**
+ * @brief IDVIEWER_SelectIDDeviceInfo_ 鑾峰彇鏌愪釜搴忓彿鐨勮澶�
+ * @param DevicesList 褰撳墠璁惧鍒楄〃鎸囬拡
+ * @param index 璁惧鍒楄〃鐨勫簭鍙�
+
+ * @return 璁惧淇℃伅
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_SelectIDDeviceInfo_", CharSet = CharSet.Ansi)]
+ public extern static long IDVIEWER_SelectIDDeviceInfo_(IntPtr DevicesList, ref IDDeviceInfo IDDeviceInfoHandel, uint index);
+
+ /**
+ * @brief IDVIEWER_SetIP 璁剧疆IP 璁剧疆IP鍚庨渶瑕侀噸鏂版壂鎻�
+ * @param deviceInfo 褰撳墠璁惧淇℃伅
+ * @param iPv4 鏂扮殑IP鍦板潃
+ * @param mask 鏂扮殑MASK鍦板潃
+ * @param gateway 鏂扮殑缃戝叧鍦板潃
+ * @param isStatic 鏄惁璁剧疆闈欐�両P(false涓轰复鏃禝P)
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_SetIP_", CharSet = CharSet.Ansi)]
+ public static extern long IDVIEWER_SetIP_(ref IDViewerDefines.IDDeviceInfo deviceInfo, string iPv4, string mask, string gateway, bool isStatic);
+
+
+ /**
+ * @brief IDVIEWER_CreateDevice IDVIEWER_CreateDeviceBySN 鏇村姞SN鍒涘缓璁惧
+ * @param cameraSN 褰撳墠璁惧SN
+ * @param device 鍒涘缓鐨勮澶囨寚閽�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_CreateDeviceBySN_", CharSet = CharSet.Ansi)]
+ public static extern long IDVIEWER_CreateDeviceBySN_(string cameraSN, ref IntPtr deviceHandle);
+
+ /**
+ * @brief IDVIEWER_CreateDevice IDVIEWER_CreateDeviceByIP 鏇村姞SN鍒涘缓璁惧
+ * @param cameraIP 褰撳墠璁惧IP
+ * @param device 鍒涘缓鐨勮澶囨寚閽�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_CreateDeviceByIP_", CharSet = CharSet.Ansi)]
+ public static extern long IDVIEWER_CreateDeviceByIP_(string cameraIP, ref IntPtr deviceHandle);
+ /**
+ * @brief IDVIEWER_UnInit 浣跨敤瀹孲DK鍚庤皟鐢ㄩ噴鏀捐祫婧�
+ * @return 閿欒鐮�
+ */
+ [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_UnInit_", CharSet = CharSet.Ansi)]
+ public static extern long IDVIEWER_UnInit_(IntPtr deviceList);
+ }
+}
+
+
+
diff --git a/IDViewer_2D/IDViewerSDK2.cs b/IDViewer_2D/IDViewerSDK2.cs
new file mode 100644
index 0000000..1e5f826
--- /dev/null
+++ b/IDViewer_2D/IDViewerSDK2.cs
@@ -0,0 +1,54 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+using static SmartScanner.IDViewerDefines;
+using System.IO;
+using System.Drawing;
+
+namespace SmartScanner
+{
+ class IDViewerSDK2
+ {
+ [DllImport("yolov8_ov_infer.dll", EntryPoint = "CreateDetector_CPU", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr CreateDetector_CPU();
+
+ [DllImport("yolov8_ov_infer.dll", EntryPoint = "InitializeDetector_CPU", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool InitializeDetector_CPU(IntPtr m_yolov8, string device_char, string model_path_char);
+ [DllImport("yolov8_ov_infer.dll", EntryPoint = "PredictDetector_CPU", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void PredictDetector_CPU(IntPtr m_yolov8,
+ byte[] image_batch,
+ float[] x1_ptr,
+ float[] y1_ptr,
+ float[] x2_ptr,
+ float[] y2_ptr,
+ float[] prob_ptr,
+ int[] class_ptr,
+ int[] num_boxes,
+ int buffer_size,
+ int width,
+ int height,
+ int batch_size,
+ float conf_thresh,
+ float nms_thres,
+ int is_Saved,
+ int sequence);
+
+ [DllImport("yolov8_ov_infer.dll", EntryPoint = "DisposeDetector_CPU", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void DisposeDetector_CPU(IntPtr m_yolov8);
+
+ [DllImport("yolov8_ov_infer.dll", EntryPoint = "ConvertSingletoThreeChannels", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void ConvertSingletoThreeChannels(IntPtr m_yolov8, byte[] input, int width, int height, byte[] output);
+
+
+ //OPT鎻愪緵鐨凜++SDK
+ [DllImport("optSDK.dll", EntryPoint = "IDImage_Create", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr IDImage_Create();
+ [DllImport("IDViewerSDK.dll", EntryPoint = "IDImage", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+ public static extern long IDImage(byte[] srcImageData, int step, int rows, int cols, int channel, IDImageType depth);
+ [DllImport("IDViewerSDK.dll", EntryPoint = "captureImage", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+ public static extern long captureImage(IntPtr image);
+ }
+}
diff --git a/IDViewer_2D/Image/Currency/MTV3Dlogo.ico b/IDViewer_2D/Image/Currency/MTV3Dlogo.ico
new file mode 100644
index 0000000..28cbe0c
--- /dev/null
+++ b/IDViewer_2D/Image/Currency/MTV3Dlogo.ico
Binary files differ
diff --git a/IDViewer_2D/Image/Currency/logo.png b/IDViewer_2D/Image/Currency/logo.png
new file mode 100644
index 0000000..e9ddfe2
--- /dev/null
+++ b/IDViewer_2D/Image/Currency/logo.png
Binary files differ
diff --git a/IDViewer_2D/Image/Currency/logo_01.png b/IDViewer_2D/Image/Currency/logo_01.png
new file mode 100644
index 0000000..f4634fe
--- /dev/null
+++ b/IDViewer_2D/Image/Currency/logo_01.png
Binary files differ
diff --git a/IDViewer_2D/Image/Currency/logo_02.png b/IDViewer_2D/Image/Currency/logo_02.png
new file mode 100644
index 0000000..7deb39d
--- /dev/null
+++ b/IDViewer_2D/Image/Currency/logo_02.png
Binary files differ
diff --git "a/IDViewer_2D/Image/Currency/\345\210\240\351\231\244.png" "b/IDViewer_2D/Image/Currency/\345\210\240\351\231\244.png"
new file mode 100644
index 0000000..ab6732b
--- /dev/null
+++ "b/IDViewer_2D/Image/Currency/\345\210\240\351\231\244.png"
Binary files differ
diff --git "a/IDViewer_2D/Image/Currency/\345\210\267\346\226\260.png" "b/IDViewer_2D/Image/Currency/\345\210\267\346\226\260.png"
new file mode 100644
index 0000000..0070559
--- /dev/null
+++ "b/IDViewer_2D/Image/Currency/\345\210\267\346\226\260.png"
Binary files differ
diff --git "a/IDViewer_2D/Image/Currency/\345\215\225\345\274\240\346\212\223\345\233\276.png" "b/IDViewer_2D/Image/Currency/\345\215\225\345\274\240\346\212\223\345\233\276.png"
new file mode 100644
index 0000000..63f2b32
--- /dev/null
+++ "b/IDViewer_2D/Image/Currency/\345\215\225\345\274\240\346\212\223\345\233\276.png"
Binary files differ
diff --git "a/IDViewer_2D/Image/Currency/\345\255\230\345\202\250\345\233\276\347\211\207.png" "b/IDViewer_2D/Image/Currency/\345\255\230\345\202\250\345\233\276\347\211\207.png"
new file mode 100644
index 0000000..0bd0c55
--- /dev/null
+++ "b/IDViewer_2D/Image/Currency/\345\255\230\345\202\250\345\233\276\347\211\207.png"
Binary files differ
diff --git "a/IDViewer_2D/Image/Currency/\345\256\243\344\274\240\345\233\276.png" "b/IDViewer_2D/Image/Currency/\345\256\243\344\274\240\345\233\276.png"
new file mode 100644
index 0000000..60d8ad0
--- /dev/null
+++ "b/IDViewer_2D/Image/Currency/\345\256\243\344\274\240\345\233\276.png"
Binary files differ
diff --git "a/IDViewer_2D/Image/Currency/\345\274\200\345\247\213\351\207\207\351\233\206.jpg" "b/IDViewer_2D/Image/Currency/\345\274\200\345\247\213\351\207\207\351\233\206.jpg"
new file mode 100644
index 0000000..cf78618
--- /dev/null
+++ "b/IDViewer_2D/Image/Currency/\345\274\200\345\247\213\351\207\207\351\233\206.jpg"
Binary files differ
diff --git "a/IDViewer_2D/Image/Currency/\346\211\223\345\274\200\346\226\207\344\273\266.png" "b/IDViewer_2D/Image/Currency/\346\211\223\345\274\200\346\226\207\344\273\266.png"
new file mode 100644
index 0000000..b976ccf
--- /dev/null
+++ "b/IDViewer_2D/Image/Currency/\346\211\223\345\274\200\346\226\207\344\273\266.png"
Binary files differ
diff --git "a/IDViewer_2D/Image/Currency/\346\226\255\345\274\200.png" "b/IDViewer_2D/Image/Currency/\346\226\255\345\274\200.png"
new file mode 100644
index 0000000..8974e54
--- /dev/null
+++ "b/IDViewer_2D/Image/Currency/\346\226\255\345\274\200.png"
Binary files differ
diff --git "a/IDViewer_2D/Image/Currency/\346\232\202\345\201\234.png" "b/IDViewer_2D/Image/Currency/\346\232\202\345\201\234.png"
new file mode 100644
index 0000000..6fd9e1c
--- /dev/null
+++ "b/IDViewer_2D/Image/Currency/\346\232\202\345\201\234.png"
Binary files differ
diff --git "a/IDViewer_2D/Image/Currency/\350\277\236\346\216\245.png" "b/IDViewer_2D/Image/Currency/\350\277\236\346\216\245.png"
new file mode 100644
index 0000000..1b46be5
--- /dev/null
+++ "b/IDViewer_2D/Image/Currency/\350\277\236\346\216\245.png"
Binary files differ
diff --git "a/IDViewer_2D/Image/Currency/\350\277\236\347\273\255\346\212\223\345\233\276.png" "b/IDViewer_2D/Image/Currency/\350\277\236\347\273\255\346\212\223\345\233\276.png"
new file mode 100644
index 0000000..a7036b8
--- /dev/null
+++ "b/IDViewer_2D/Image/Currency/\350\277\236\347\273\255\346\212\223\345\233\276.png"
Binary files differ
diff --git "a/IDViewer_2D/Image/Currency/\351\207\207\351\233\206.png" "b/IDViewer_2D/Image/Currency/\351\207\207\351\233\206.png"
new file mode 100644
index 0000000..98baf35
--- /dev/null
+++ "b/IDViewer_2D/Image/Currency/\351\207\207\351\233\206.png"
Binary files differ
diff --git a/IDViewer_2D/Image/ICON/camera-switch-fill.png b/IDViewer_2D/Image/ICON/camera-switch-fill.png
new file mode 100644
index 0000000..3bdb2fb
--- /dev/null
+++ b/IDViewer_2D/Image/ICON/camera-switch-fill.png
Binary files differ
diff --git a/IDViewer_2D/Image/ICON/folder-2-fill.png b/IDViewer_2D/Image/ICON/folder-2-fill.png
new file mode 100644
index 0000000..998fcbf
--- /dev/null
+++ b/IDViewer_2D/Image/ICON/folder-2-fill.png
Binary files differ
diff --git a/IDViewer_2D/Image/ICON/folder-open-fill.png b/IDViewer_2D/Image/ICON/folder-open-fill.png
new file mode 100644
index 0000000..400f9b9
--- /dev/null
+++ b/IDViewer_2D/Image/ICON/folder-open-fill.png
Binary files differ
diff --git a/IDViewer_2D/Image/ICON/import-fill.png b/IDViewer_2D/Image/ICON/import-fill.png
new file mode 100644
index 0000000..3d230a3
--- /dev/null
+++ b/IDViewer_2D/Image/ICON/import-fill.png
Binary files differ
diff --git a/IDViewer_2D/Image/ICON/link-m.png b/IDViewer_2D/Image/ICON/link-m.png
new file mode 100644
index 0000000..4e7fa5f
--- /dev/null
+++ b/IDViewer_2D/Image/ICON/link-m.png
Binary files differ
diff --git a/IDViewer_2D/Image/testImages/20220706201141516.jpg b/IDViewer_2D/Image/testImages/20220706201141516.jpg
new file mode 100644
index 0000000..7f0807d
--- /dev/null
+++ b/IDViewer_2D/Image/testImages/20220706201141516.jpg
Binary files differ
diff --git a/IDViewer_2D/Image/testImages/20220706201152065.jpg b/IDViewer_2D/Image/testImages/20220706201152065.jpg
new file mode 100644
index 0000000..89d3810
--- /dev/null
+++ b/IDViewer_2D/Image/testImages/20220706201152065.jpg
Binary files differ
diff --git a/IDViewer_2D/Image/testImages/20220719092357348.jpg b/IDViewer_2D/Image/testImages/20220719092357348.jpg
new file mode 100644
index 0000000..dc02cce
--- /dev/null
+++ b/IDViewer_2D/Image/testImages/20220719092357348.jpg
Binary files differ
diff --git a/IDViewer_2D/Image/testImages/20221013101729295.jpg b/IDViewer_2D/Image/testImages/20221013101729295.jpg
new file mode 100644
index 0000000..40cfaf1
--- /dev/null
+++ b/IDViewer_2D/Image/testImages/20221013101729295.jpg
Binary files differ
diff --git a/IDViewer_2D/Image/testImages/20221018190453100.jpg b/IDViewer_2D/Image/testImages/20221018190453100.jpg
new file mode 100644
index 0000000..08a30fc
--- /dev/null
+++ b/IDViewer_2D/Image/testImages/20221018190453100.jpg
Binary files differ
diff --git a/IDViewer_2D/ImageDisplayWindow .xaml b/IDViewer_2D/ImageDisplayWindow .xaml
new file mode 100644
index 0000000..d42d1ab
--- /dev/null
+++ b/IDViewer_2D/ImageDisplayWindow .xaml
@@ -0,0 +1,41 @@
+锘�<Window x:Class="SmartScanner.ImageDisplayWindow"
+ 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:opencvsharp1="http://schemas.microsoft.com/netfx/2009/xaml/presentation"
+ mc:Ignorable="d"
+ Title="ImageDisplayWindow" Height="450" Width="800">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*"/>
+ <ColumnDefinition Width="10*"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+ <opencvsharp1:Image x:Name="ResultImage" Grid.Column="1" Grid.Row="0" Stretch="Uniform"/>
+ <!--<StackPanel Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Center">-->
+ <Button x:Name="PrevButton" Content="<" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch"
+ BorderThickness="0" FontSize="48" Click="PrevButton_Click" Background="{x:Null}" BorderBrush="{x:Null}" >
+ <!--<TextBox Text="<" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="48" BorderBrush="{x:Null}">
+ </TextBox>-->
+ </Button>
+ <!--</StackPanel>-->
+ <!--<StackPanel Grid.Row="0" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Center">-->
+ <Button x:Name="NextButton" Content=">" Click="NextButton_Click" FontSize="48"
+ BorderThickness="0" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Stretch" Background="White" BorderBrush="{x:Null}" >
+ <!--<TextBox Text=">" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="48" BorderBrush="{x:Null}">
+ </TextBox>-->
+ </Button>
+ <!--</StackPanel>-->
+ </Grid>
+ <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
+ <!--<Button x:Name="PrevButton" Content="涓婁竴寮�" Width="80" Margin="10" Click="PrevButton_Click"/>-->
+ <!--<Button x:Name="NextButton" Content="涓嬩竴寮�" Width="80" Margin="10" Click="NextButton_Click"/>-->
+ </StackPanel>
+ </Grid>
+</Window>
diff --git a/IDViewer_2D/ImageDisplayWindow .xaml.cs b/IDViewer_2D/ImageDisplayWindow .xaml.cs
new file mode 100644
index 0000000..d33ec06
--- /dev/null
+++ b/IDViewer_2D/ImageDisplayWindow .xaml.cs
@@ -0,0 +1,125 @@
+锘縰sing OpenCvSharp;
+using OpenCvSharp.WpfExtensions;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.IO;
+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.Shapes;
+
+namespace SmartScanner
+{
+ /// <summary>
+ /// ImageDisplayWindow.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ public partial class ImageDisplayWindow : System.Windows.Window
+ {
+ private List<string> _imagePaths = new List<string>();
+ private int _currentIndex = -1;
+ public ImageDisplayWindow()
+ {
+ InitializeComponent();
+ }
+ public void AddImage(List<string> imagePath)
+ {
+ for (int i = 0; i < imagePath.Count; i++)
+ {
+ if (!File.Exists(imagePath[i]))
+ {
+ MessageBox.Show($"鍥剧墖涓嶅瓨鍦�: {imagePath}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ }
+ // 娣诲姞鍒板垪琛�
+ //_imagePaths = imagePath;
+ _imagePaths = new List<string>(imagePath);
+ ShowImage(0);
+ }
+
+ private void ShowImage(int index)
+ {
+ if (index < 0 || index >= _imagePaths.Count) return;
+
+ _currentIndex = index;
+ string imagePath = _imagePaths[index];
+
+ try
+ {
+ // 浣跨敤OpenCvSharp璇诲彇鍥剧墖
+ using (Mat image = Cv2.ImRead(imagePath, ImreadModes.Color))
+ {
+ if (image.Empty())
+ {
+ throw new Exception("鍥剧墖鍔犺浇澶辫触");
+ }
+
+ // 浣跨敤Dispatcher纭繚UI绾跨▼鏇存柊
+ Dispatcher.Invoke(() =>
+ {
+ ResultImage.Source = image.ToBitmapSource();
+ Title = $"鍥剧墖鏌ョ湅 ({index + 1}/{_imagePaths.Count}) - {System.IO.Path.GetFileName(imagePath)}";
+
+ // 鏇存柊鎸夐挳鐘舵��
+ PrevButton.IsEnabled = index > 0;
+ NextButton.IsEnabled = index < _imagePaths.Count - 1;
+ });
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"鍔犺浇鍥剧墖澶辫触: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void PrevButton_Click(object sender, RoutedEventArgs e)
+ {
+ ShowImage(_currentIndex - 1);
+ }
+
+ private void NextButton_Click(object sender, RoutedEventArgs e)
+ {
+ ShowImage(_currentIndex + 1);
+ }
+ public bool ShowImage_main(string imagePath)
+ {
+ try
+ {
+ // 浣跨敤OpenCvSharp璇诲彇鍥剧墖
+ using (Mat image = Cv2.ImRead(imagePath, ImreadModes.Color))
+ {
+ if (image.Empty())
+ {
+ return false;
+ }
+
+ // 浣跨敤Dispatcher纭繚UI绾跨▼鏇存柊
+ Dispatcher.Invoke(() =>
+ {
+ ResultImage.Source = image.ToBitmapSource();
+ Title = $"鍥剧墖鏌ョ湅:{System.IO.Path.GetFileName(imagePath)}";
+
+ // 鏇存柊鎸夐挳鐘舵��
+ PrevButton.IsEnabled = false;
+ NextButton.IsEnabled = false;
+ });
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"鍔犺浇鍥剧墖澶辫触: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ return false;
+ }
+ return true;
+ }
+ }
+}
diff --git a/IDViewer_2D/ImageService/ImageCleanupService.cs b/IDViewer_2D/ImageService/ImageCleanupService.cs
new file mode 100644
index 0000000..1a62b54
--- /dev/null
+++ b/IDViewer_2D/ImageService/ImageCleanupService.cs
@@ -0,0 +1,94 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace SmartScanner
+{
+ class ImageCleanupService
+ {
+ private readonly string _imageDirectory;
+ private readonly int _retentionDays;
+ private Timer _cleanupTimer;
+ private bool _isRunning;
+
+ public ImageCleanupService(string imageDirectory, int retentionDays)
+ {
+ _imageDirectory = imageDirectory;
+ _retentionDays = retentionDays;
+ }
+
+ public void Start()
+ {
+ if (_isRunning) return;
+
+ // 绔嬪嵆鎵ц涓�娆℃竻鐞�
+ Task.Run(() => CleanupOldImages());
+
+ // 璁剧疆姣忓ぉ鍑屾櫒2鐐规墽琛屾竻鐞�
+ var now = DateTime.Now;
+ var nextRunTime = new DateTime(now.Year, now.Month, now.Day, 2, 0, 0).AddDays(1);
+ var dueTime = nextRunTime - now;
+
+ _cleanupTimer = new Timer(_ => CleanupOldImages(), null, dueTime, TimeSpan.FromDays(1));
+ _isRunning = true;
+ }
+
+ public void Stop()
+ {
+ _cleanupTimer?.Dispose();
+ _isRunning = false;
+ }
+
+ private void CleanupOldImages()
+ {
+ try
+ {
+ if (!Directory.Exists(_imageDirectory)) return;
+
+ var cutoffDate = DateTime.Now.AddDays(-_retentionDays);
+ var searchOption = SearchOption.AllDirectories;
+
+ foreach (var file in Directory.EnumerateFiles(_imageDirectory, "*.*", searchOption))
+ {
+ try
+ {
+ var fileInfo = new FileInfo(file);
+ if (fileInfo.LastWriteTime < cutoffDate)
+ {
+ File.Delete(file);
+ // 鍙�夛細璁板綍鍒犻櫎鏃ュ織
+ LogDeletion(file);
+ }
+ }
+ catch (Exception ex)
+ {
+ // 璁板綍閿欒浣嗙户缁鐞嗗叾浠栨枃浠�
+ LogError($"鍒犻櫎鏂囦欢澶辫触: {file}", ex);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogError("娓呯悊鏃у浘鍍忔椂鍙戠敓閿欒", ex);
+ }
+ }
+
+ private void LogDeletion(string filePath)
+ {
+ // 瀹炵幇鏃ュ織璁板綍锛屽彲浠ュ啓鍏ユ枃浠舵垨鏁版嵁搴�
+ string logMessage = $"{DateTime.Now}: 宸插垹闄よ繃鏈熷浘鍍� - {filePath}";
+ System.Diagnostics.Debug.WriteLine(logMessage);
+ }
+
+ private void LogError(string message, Exception ex)
+ {
+ // 瀹炵幇閿欒鏃ュ織璁板綍
+ string errorMessage = $"{DateTime.Now}: {message} - {ex.Message}";
+ System.Diagnostics.Debug.WriteLine(errorMessage);
+ }
+ }
+}
diff --git a/IDViewer_2D/ImageService/MemoryAlarmCheck.cs b/IDViewer_2D/ImageService/MemoryAlarmCheck.cs
new file mode 100644
index 0000000..cf747d5
--- /dev/null
+++ b/IDViewer_2D/ImageService/MemoryAlarmCheck.cs
@@ -0,0 +1,24 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SmartScanner.ImageService
+{
+ class MemoryAlarmCheck
+ {
+ private (double usedPercentage, string driveName) GetDriveUsage()
+ {
+ // 鑾峰彇绯荤粺鐩�
+ DownloadData downloadData = new DownloadData();
+ DriveInfo drive = new DriveInfo($"{downloadData.SetDataSavingRoad.Text}");
+ double totalSpace = drive.TotalSize;
+ double freeSpace = drive.AvailableFreeSpace;
+ double usedPercentage = 100 - (freeSpace / totalSpace * 100);
+
+ return (usedPercentage, drive.Name);
+ }
+ }
+}
diff --git a/IDViewer_2D/LBProjService.cs b/IDViewer_2D/LBProjService.cs
new file mode 100644
index 0000000..f99e467
--- /dev/null
+++ b/IDViewer_2D/LBProjService.cs
@@ -0,0 +1,131 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.IO.Compression;
+
+namespace SmartScanner
+{
+ public static class LBProjService
+ {
+ private const string ConfigFileName = "config.json";
+ private const string ModelNameFileName = "model_name.txt";
+ private const string ModelDir = "model"; // 鍥哄畾妯″瀷鐩綍
+
+ /// <summary>
+ /// 鍒涘缓涓存椂鐩綍
+ /// </summary>
+ private static string CreateTempDirectory()
+ {
+ string tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
+ Directory.CreateDirectory(tempDir);
+ return tempDir;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎵�鏈夊彲鐢ㄦā鍨�
+ /// </summary>
+ public static string[] GetAvailableModels()
+ {
+ string modelPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ModelDir);
+
+ if (!Directory.Exists(modelPath))
+ {
+ Directory.CreateDirectory(modelPath);
+ return Array.Empty<string>();
+ }
+
+ return Directory.GetFiles(modelPath, "*.lb")
+ .Select(Path.GetFileName)
+ .ToArray();
+ }
+
+ /// <summary>
+ /// 鍒涘缓宸ョ▼鏂囦欢
+ /// </summary>
+ public static (bool Success, string Message) CreateLBProj(
+ string paramFilePath,
+ string modelFileName,
+ string outputPath)
+ {
+ try
+ {
+ // 楠岃瘉妯″瀷鏄惁瀛樺湪
+ string fullModelPath = Path.Combine(ModelDir, modelFileName);
+ if (!File.Exists(fullModelPath))
+ {
+ return (false, $"妯″瀷鏂囦欢 {modelFileName} 涓嶅瓨鍦ㄤ簬 {ModelDir} 鐩綍");
+ }
+
+ // 鍒涘缓涓存椂鐩綍骞舵墦鍖�
+ string tempDir = CreateTempDirectory();
+ try
+ {
+ // 1. 淇濆瓨鍙傛暟鏂囦欢
+ File.Copy(paramFilePath, Path.Combine(tempDir, ConfigFileName), true);
+
+ // 2. 淇濆瓨妯″瀷鏂囦欢鍚嶏紙闈炶矾寰勶級
+ File.WriteAllText(Path.Combine(tempDir, ModelNameFileName), modelFileName);
+
+ // 3. 鍒涘缓ZIP鍖�
+ ZipFile.CreateFromDirectory(tempDir, outputPath);
+ return (true, "宸ョ▼鏂囦欢鍒涘缓鎴愬姛");
+ }
+ finally
+ {
+ Directory.Delete(tempDir, true);
+ }
+ }
+ catch (Exception ex)
+ {
+ return (false, $"鍒涘缓澶辫触: {ex.Message}");
+ }
+ }
+
+ /// <summary>
+ /// 鍔犺浇宸ョ▼鏂囦欢
+ /// </summary>
+ public static (string ModelName, string configPath, string ConfigContent, string Message) LoadLBProj(string projectFilePath)
+ {
+ try
+ {
+ string tempDir = CreateTempDirectory();
+ try
+ {
+ ZipFile.ExtractToDirectory(projectFilePath, tempDir);
+
+ // 1. 璇诲彇妯″瀷鏂囦欢鍚�
+ string modelNameFile = Path.Combine(tempDir, ModelNameFileName);
+ if (!File.Exists(modelNameFile))
+ {
+ return (null, null, null, "宸ョ▼鏂囦欢涓己灏戞ā鍨嬪悕绉拌褰�");
+ }
+ string modelName = File.ReadAllText(modelNameFile);
+
+ // 2. 楠岃瘉妯″瀷鏄惁瀛樺湪
+ string fullModelPath = Path.Combine(ModelDir, modelName);
+ if (!File.Exists(fullModelPath))
+ {
+ return (null, null, null, $"妯″瀷 {modelName} 涓嶅瓨鍦ㄤ簬 {ModelDir} 鐩綍");
+ }
+
+ // 3. 璇诲彇閰嶇疆
+ string configPath = Path.Combine(tempDir, ConfigFileName);
+ string configContent = File.ReadAllText(configPath);
+
+ return (modelName, configPath, configContent, "鍔犺浇鎴愬姛");
+ }
+ finally
+ {
+ Directory.Delete(tempDir, true);
+ }
+ }
+ catch (Exception ex)
+ {
+ return (null, null, null, $"鍔犺浇澶辫触: 璇疯緭鍏ユ纭殑宸ョ▼鏂囦欢璺緞: {ex.Message}");
+ }
+ }
+ }
+}
diff --git a/IDViewer_2D/LBProtect.cs b/IDViewer_2D/LBProtect.cs
new file mode 100644
index 0000000..da53fdb
--- /dev/null
+++ b/IDViewer_2D/LBProtect.cs
@@ -0,0 +1,134 @@
+锘縰sing Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Management;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SmartScanner
+{
+ class LBProtect
+ {
+ //绉侀挜
+ private static readonly string privateKey = "<RSAKeyValue><Modulus>zM7HeOAK8nORTQ56zl4IInkg7Y5k3Zf2FtXaHwu4nSCJOdWmABnbIbTlIt9y9gmLnDHG0maUXlaxZrbUGeAScrmI6kD4qlDypf9qKO7iB5K9xf0MD7ecioeljLXJtG8ahPo6pqiyg9Sx0Czue2pg672ssPtbGL81iFrgwy+Zgok=</Modulus><Exponent>AQAB</Exponent><P>zUb5vO3p4iqncynb+WGVyO1d73M/bXrqLG7cCaZN4gk7XxeWWyfIk2flCCI2veAdp4MKpdG3j4W+Y7+8xq5fzw==</P><Q>/2oalvvC/i1YtJNGCZk4+k83asfBZZpElTp/t+U4FC8vGGKE8slfBzflSps8PTJ67/MKZ8sgD0pW9Vp2e4j2Jw==</Q><DP>sU5v4edh0C9liUyLq2DFvtKAA5Z5H7g+UnjC6DbUKLwuoxk9jqjTT7c6lYbv35uYIZtHdCirs3UjGQeBJ99v8w==</DP><DQ>taKxEhosSzHYWWI6dmz+dhOLp2YzBJw2laEqXo6l2MTNSxwUy8ukxq9bYjkPF74kayt9hN6RCA6n1Ifmpmd6FQ==</DQ><InverseQ>AxT3HFNQY9mBI/fe68ACR56ARDIUCXb62REnjbJDA0/7Ti/n5NN+yaELwVDZpw2LVlqePyYdmMJgUAJGBjHl4A==</InverseQ><D>YtiRsScAYY+hWv1YC+2aI3kuiTimOcSzwsWnpkAz87HWSRFyMq5H8nap+DC7/T8SIGptuPJFPVq9+ALZTzuz6siESv1EtND58nyrR6HnUKXlhiGuoG9vXL2rP71BnZA+H+lnIFrG48orFKP/8kA2Hy9cP9l4b1pBXEZJHQHG1hk=</D></RSAKeyValue>";
+
+ private static readonly RSACryptoServiceProvider cryptoServiceProvider = new RSACryptoServiceProvider();
+
+ // 瑙e瘑
+ public static string RsaDecrypt(string textRsa)
+ {
+ cryptoServiceProvider.FromXmlString(privateKey);
+ byte[] inputBytes = Convert.FromBase64String(textRsa);
+ byte[] decryptedBytes = cryptoServiceProvider.Decrypt(inputBytes, false);
+ return Encoding.UTF8.GetString(decryptedBytes);
+ }
+
+
+ // 鑾峰彇纭欢鎸囩汗
+ public static string GetHardwareFingerprint()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ // CPU ID
+ sb.Append(GetWmiInfo("Win32_Processor", "ProcessorId"));
+
+ // 涓绘澘搴忓垪鍙�
+ sb.Append(GetWmiInfo("Win32_BaseBoard", "SerialNumber"));
+
+ // 涓荤‖鐩樺簭鍒楀彿
+ sb.Append(GetFixedDiskSerialNumber());
+
+ // 璁$畻SHA256鍝堝笇
+ using (SHA256 sha256 = SHA256.Create())
+ {
+ byte[] hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(sb.ToString()));
+ return BitConverter.ToString(hash).Replace("-", "").Substring(0, 16);
+ }
+ }
+
+ private static string GetWmiInfo(string className, string propertyName)
+ {
+ try
+ {
+ using (ManagementClass mc = new ManagementClass(className))
+ using (ManagementObjectCollection moc = mc.GetInstances())
+ {
+ foreach (ManagementObject mo in moc)
+ {
+ return mo[propertyName]?.ToString() ?? string.Empty;
+ }
+ }
+ }
+ catch { }
+ return string.Empty;
+ }
+
+ // 楠岃瘉纭欢鎸囩汗
+ public static bool ValidateFingerprint()
+ {
+ string sRsaVal = "";
+ string currentConfigDirectory = Directory.GetCurrentDirectory() + "\\config";
+ string currentFingerprint = GetHardwareFingerprint();
+
+ try
+ {
+ if (!Directory.Exists(currentConfigDirectory))
+ Directory.CreateDirectory(currentConfigDirectory);
+
+ string sRsa = File.ReadAllText(currentConfigDirectory + "\\" + currentFingerprint + ".lic");
+ sRsaVal = RsaDecrypt(sRsa);
+ }
+ catch
+ { }
+
+ bool bSame = true;
+ if (currentFingerprint != sRsaVal)
+ {
+ bSame = false;
+ File.WriteAllText(currentConfigDirectory + "\\MachineId.txt", currentFingerprint);
+ }
+
+
+ return bSame;
+ }
+ // 鑾峰彇鍥哄畾纭洏搴忓垪鍙凤紙鎺掗櫎鍙Щ鍔ㄨ澶囷級
+ private static string GetFixedDiskSerialNumber()
+ {
+ try
+ {
+ // 鏌ユ壘鍥哄畾纭洏
+ using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT SerialNumber, MediaType FROM Win32_DiskDrive WHERE MediaType = 'Fixed hard disk media'"))
+ using (ManagementObjectCollection moc = searcher.Get())
+ {
+ foreach (ManagementObject mo in moc)
+ {
+ string serialNumber = mo["SerialNumber"]?.ToString()?.Trim() ?? string.Empty;
+ if (!string.IsNullOrEmpty(serialNumber))
+ return serialNumber;
+ }
+ }
+
+ // 鏌ユ壘闈濽SB鎺ュ彛鐨勮澶�
+ using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT SerialNumber, InterfaceType FROM Win32_DiskDrive WHERE InterfaceType != 'USB'"))
+ using (ManagementObjectCollection moc = searcher.Get())
+ {
+ foreach (ManagementObject mo in moc)
+ {
+ string serialNumber = mo["SerialNumber"]?.ToString()?.Trim() ?? string.Empty;
+ if (!string.IsNullOrEmpty(serialNumber))
+ return serialNumber;
+ }
+ }
+ }
+ catch { }
+
+ return string.Empty;
+ }
+
+
+ }
+}
diff --git a/IDViewer_2D/LoadingWindow.xaml b/IDViewer_2D/LoadingWindow.xaml
new file mode 100644
index 0000000..7da14b6
--- /dev/null
+++ b/IDViewer_2D/LoadingWindow.xaml
@@ -0,0 +1,14 @@
+锘�<Window x:Class="SmartScanner.LoadingWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ Title="Loading..." Height="150" Width="300" WindowStyle="None"
+ AllowsTransparency="True" Background="Transparent"
+ WindowStartupLocation="CenterScreen">
+ <Border Background="#3C3C3C" CornerRadius="10">
+ <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
+ <TextBlock x:Name="Loading" Text="杞欢鍔犺浇涓� 路 路" Foreground="White"
+ FontSize="16" Margin="0,10,0,10" />
+ <ProgressBar IsIndeterminate="True" Width="250" Height="20"/>
+ </StackPanel>
+ </Border>
+</Window>
diff --git a/IDViewer_2D/LoadingWindow.xaml.cs b/IDViewer_2D/LoadingWindow.xaml.cs
new file mode 100644
index 0000000..315534d
--- /dev/null
+++ b/IDViewer_2D/LoadingWindow.xaml.cs
@@ -0,0 +1,27 @@
+锘縰sing 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.Shapes;
+
+namespace SmartScanner
+{
+ /// <summary>
+ /// LoadingWindow.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ public partial class LoadingWindow : Window
+ {
+ public LoadingWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/IDViewer_2D/LogAutoSaveService.cs b/IDViewer_2D/LogAutoSaveService.cs
new file mode 100644
index 0000000..cab1ed5
--- /dev/null
+++ b/IDViewer_2D/LogAutoSaveService.cs
@@ -0,0 +1,284 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using SmartScanner.ViewModel;
+
+namespace SmartScanner
+{
+ /// <summary>
+ /// 浼樺寲鐨勬棩蹇楄嚜鍔ㄤ繚瀛樻湇鍔�
+ /// 鍔熻兘锛氭壒閲忎繚瀛�48灏忔椂鍐呮瘡涓�鏉℃棩蹇楀埌D鐩�02 LBLog鏂囦欢澶�
+ /// 瑙﹀彂鏉′欢锛氭渶澶�300鏉℃垨鍗佸垎閽熸壒閲忎繚瀛樹竴娆�
+ /// </summary>
+ public class LogAutoSaveService
+ {
+ private readonly ObservableCollection<LogEntry> _logEntries;
+ private Timer _cleanupTimer;
+ private Timer _batchSaveTimer;
+ private const int CLEANUP_INTERVAL_MS = 60 * 60 * 1000; // 1灏忔椂娓呯悊涓�娆�
+ private const int BATCH_SAVE_INTERVAL_MS = 600000; // 鍗佸垎閽熸壒閲忎繚瀛樹竴娆�
+ private const int MAX_BATCH_SIZE = 300; // 鏈�澶�300鏉℃棩蹇楁壒閲忎繚瀛�
+ private readonly string _logDirectory = @"D:\02 LBLog";
+ private bool _isSaving = false;
+ private readonly object _fileLock = new object();
+ private readonly object _bufferLock = new object();
+ private string _currentLogFilePath;
+ private readonly Queue<LogEntry> _logBuffer = new Queue<LogEntry>(); // 鏃ュ織缂撳啿鍖�
+ private int _bufferCount = 0; // 缂撳啿鍖鸿鏁�
+
+ public LogAutoSaveService(ObservableCollection<LogEntry> logEntries)
+ {
+ _logEntries = logEntries ?? throw new ArgumentNullException(nameof(logEntries));
+
+ // 鍒涘缓鏃ュ織鐩綍
+ if (!Directory.Exists(_logDirectory))
+ {
+ Directory.CreateDirectory(_logDirectory);
+ }
+
+ // 鍒濆鍖栧綋鍓嶆棩蹇楁枃浠惰矾寰�
+ InitializeCurrentLogFile();
+
+ // 鍚姩鎵归噺淇濆瓨瀹氭椂鍣�
+ _batchSaveTimer = new Timer(OnBatchSaveTimerElapsed, null, BATCH_SAVE_INTERVAL_MS, BATCH_SAVE_INTERVAL_MS);
+
+ // 鍚姩娓呯悊瀹氭椂鍣�
+ _cleanupTimer = new Timer(OnCleanupTimerElapsed, null, CLEANUP_INTERVAL_MS, CLEANUP_INTERVAL_MS);
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栧綋鍓嶆棩蹇楁枃浠惰矾寰�
+ /// </summary>
+ private void InitializeCurrentLogFile()
+ {
+ string currentDate = DateTime.Now.ToString("yyyyMMdd");
+ string fileName = $"Log_{currentDate}.txt";
+ _currentLogFilePath = Path.Combine(_logDirectory, fileName);
+ }
+
+ /// <summary>
+ /// 娣诲姞鏃ュ織鍒扮紦鍐插尯锛屽欢杩熸壒閲忎繚瀛�
+ /// </summary>
+ public void LogAdded(LogEntry logEntry)
+ {
+ if (_isSaving) return;
+
+ lock (_bufferLock)
+ {
+ _logBuffer.Enqueue(logEntry);
+ _bufferCount++;
+
+ // 濡傛灉缂撳啿鍖鸿揪鍒版渶澶уぇ灏忥紝绔嬪嵆瑙﹀彂淇濆瓨
+ if (_bufferCount >= MAX_BATCH_SIZE)
+ {
+ Task.Run(() => SaveBatchAsync());
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鎵归噺淇濆瓨瀹氭椂鍣ㄥ洖璋�
+ /// </summary>
+ private void OnBatchSaveTimerElapsed(object state)
+ {
+ if (!_isSaving && _bufferCount > 0)
+ {
+ Task.Run(() => SaveBatchAsync());
+ }
+ }
+
+ /// <summary>
+ /// 寮傛鎵归噺淇濆瓨鏃ュ織
+ /// </summary>
+ private async Task SaveBatchAsync()
+ {
+ if (_isSaving) return;
+
+ _isSaving = true;
+
+ try
+ {
+ // 妫�鏌ユ槸鍚﹂渶瑕佸垏鎹㈠埌鏂版枃浠�
+ await CheckAndSwitchLogFileAsync();
+
+ // 鑾峰彇缂撳啿鍖轰腑鐨勬墍鏈夋棩蹇�
+ List<LogEntry> batchToSave;
+ lock (_bufferLock)
+ {
+ if (_bufferCount == 0)
+ {
+ _isSaving = false;
+ return;
+ }
+
+ batchToSave = new List<LogEntry>(_logBuffer);
+ _logBuffer.Clear();
+ _bufferCount = 0;
+ }
+
+ // 鎵归噺淇濆瓨鍒版枃浠�
+ await SaveBatchToFileAsync(batchToSave);
+
+ Console.WriteLine($"鎵归噺淇濆瓨浜� {batchToSave.Count} 鏉℃棩蹇楀埌鏂囦欢");
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"鎵归噺淇濆瓨澶辫触: {ex.Message}");
+ }
+ finally
+ {
+ _isSaving = false;
+ }
+ }
+
+ /// <summary>
+ /// 鎵归噺淇濆瓨鏃ュ織鍒版枃浠�
+ /// </summary>
+ private async Task SaveBatchToFileAsync(List<LogEntry> batch)
+ {
+ await Task.Run(() =>
+ {
+ lock (_fileLock)
+ {
+ try
+ {
+ using (StreamWriter writer = new StreamWriter(_currentLogFilePath, true, Encoding.UTF8))
+ {
+ foreach (var entry in batch)
+ {
+ string logLine = $"[{entry.Timestamp:yyyy-MM-dd HH:mm:ss.fff}] [{entry.Level}] {entry.Message}";
+ writer.WriteLine(logLine);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"鎵归噺淇濆瓨鍒版枃浠跺け璐�: {ex.Message}");
+ }
+ }
+ });
+ }
+
+ /// <summary>
+ /// 妫�鏌ユ槸鍚﹂渶瑕佸垏鎹㈠埌鏂扮殑鏃ュ織鏂囦欢
+ /// </summary>
+ private async Task CheckAndSwitchLogFileAsync()
+ {
+ await Task.Run(() =>
+ {
+ string currentDate = DateTime.Now.ToString("yyyyMMdd");
+ string fileName = $"Log_{currentDate}.txt";
+ string newFilePath = Path.Combine(_logDirectory, fileName);
+
+ // 濡傛灉鏃ユ湡鍙樺寲锛屽垏鎹㈠埌鏂版枃浠�
+ if (_currentLogFilePath != newFilePath)
+ {
+ _currentLogFilePath = newFilePath;
+ }
+ });
+ }
+
+ private void OnCleanupTimerElapsed(object state)
+ {
+ // 娓呯悊瓒呰繃48灏忔椂鐨勬棩蹇楁枃浠�
+ if (!_isSaving)
+ {
+ Task.Run(() => CleanupOldLogFilesAsync());
+ }
+ }
+
+ /// <summary>
+ /// 娓呯悊瓒呰繃48灏忔椂鐨勬棩蹇楁枃浠�
+ /// </summary>
+ private async Task CleanupOldLogFilesAsync()
+ {
+ await Task.Run(() =>
+ {
+ try
+ {
+ if (Directory.Exists(_logDirectory))
+ {
+ var files = Directory.GetFiles(_logDirectory, "Log_*.txt");
+ DateTime cutoffTime = DateTime.Now.AddHours(-48);
+
+ foreach (string file in files)
+ {
+ try
+ {
+ FileInfo fileInfo = new FileInfo(file);
+ if (fileInfo.LastWriteTime < cutoffTime)
+ {
+ File.Delete(file);
+ Console.WriteLine($"娓呯悊杩囨湡鏃ュ織鏂囦欢: {file}");
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"娓呯悊鏂囦欢澶辫触 {file}: {ex.Message}");
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"娓呯悊杩囨湡鏃ュ織鏂囦欢澶辫触: {ex.Message}");
+ }
+ });
+ }
+
+ /// <summary>
+ /// 鎵嬪姩淇濆瓨褰撳墠鎵�鏈夋棩蹇�
+ /// </summary>
+ public void ForceSave()
+ {
+ if (!_isSaving)
+ {
+ Task.Run(() => SaveBatchAsync());
+ }
+ }
+
+ /// <summary>
+ /// 鍋滄鏈嶅姟
+ /// </summary>
+ public void Stop()
+ {
+ _batchSaveTimer?.Dispose();
+ _batchSaveTimer = null;
+ _cleanupTimer?.Dispose();
+ _cleanupTimer = null;
+
+ // 淇濆瓨鏈�鍚庣殑鏃ュ織
+ if (!_isSaving && _bufferCount > 0)
+ {
+ ForceSave();
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇淇濆瓨缁熻淇℃伅
+ /// </summary>
+ public string GetStatus()
+ {
+ try
+ {
+ string currentFileInfo = "";
+ if (File.Exists(_currentLogFilePath))
+ {
+ FileInfo fileInfo = new FileInfo(_currentLogFilePath);
+ currentFileInfo = $", 褰撳墠鏂囦欢澶у皬: {fileInfo.Length / 1024} KB";
+ }
+
+ return $"鑷姩淇濆瓨鏈嶅姟杩愯涓� - 缂撳啿鍖�: {_bufferCount} 鏉currentFileInfo}";
+ }
+ catch
+ {
+ return $"鑷姩淇濆瓨鏈嶅姟杩愯涓� - 缂撳啿鍖�: {_bufferCount} 鏉�";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/IDViewer_2D/LogAutoSaveService_Optimized.cs b/IDViewer_2D/LogAutoSaveService_Optimized.cs
new file mode 100644
index 0000000..9354708
--- /dev/null
+++ b/IDViewer_2D/LogAutoSaveService_Optimized.cs
@@ -0,0 +1,284 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using SmartScanner.ViewModel;
+
+namespace SmartScanner
+{
+ /// <summary>
+ /// 浼樺寲鐨勬棩蹇楄嚜鍔ㄤ繚瀛樻湇鍔�
+ /// 鍔熻兘锛氭壒閲忎繚瀛�24灏忔椂鍐呮瘡涓�鏉℃棩蹇楀埌D鐩�02 LBLog鏂囦欢澶�
+ /// 瑙﹀彂鏉′欢锛氭渶澶�100鏉℃垨5绉掑唴鎵归噺淇濆瓨涓�娆�
+ /// </summary>
+ public class LogAutoSaveService
+ {
+ private readonly ObservableCollection<LogEntry> _logEntries;
+ private Timer _cleanupTimer;
+ private Timer _batchSaveTimer;
+ private const int CLEANUP_INTERVAL_MS = 60 * 60 * 1000; // 1灏忔椂娓呯悊涓�娆�
+ private const int BATCH_SAVE_INTERVAL_MS = 5000; // 5绉掓壒閲忎繚瀛樹竴娆�
+ private const int MAX_BATCH_SIZE = 100; // 鏈�澶�100鏉℃棩蹇楁壒閲忎繚瀛�
+ private readonly string _logDirectory = @"D:\02 LBLog";
+ private bool _isSaving = false;
+ private readonly object _fileLock = new object();
+ private readonly object _bufferLock = new object();
+ private string _currentLogFilePath;
+ private readonly Queue<LogEntry> _logBuffer = new Queue<LogEntry>(); // 鏃ュ織缂撳啿鍖�
+ private int _bufferCount = 0; // 缂撳啿鍖鸿鏁�
+
+ public LogAutoSaveService(ObservableCollection<LogEntry> logEntries)
+ {
+ _logEntries = logEntries ?? throw new ArgumentNullException(nameof(logEntries));
+
+ // 鍒涘缓鏃ュ織鐩綍
+ if (!Directory.Exists(_logDirectory))
+ {
+ Directory.CreateDirectory(_logDirectory);
+ }
+
+ // 鍒濆鍖栧綋鍓嶆棩蹇楁枃浠惰矾寰�
+ InitializeCurrentLogFile();
+
+ // 鍚姩鎵归噺淇濆瓨瀹氭椂鍣�
+ _batchSaveTimer = new Timer(OnBatchSaveTimerElapsed, null, BATCH_SAVE_INTERVAL_MS, BATCH_SAVE_INTERVAL_MS);
+
+ // 鍚姩娓呯悊瀹氭椂鍣�
+ _cleanupTimer = new Timer(OnCleanupTimerElapsed, null, CLEANUP_INTERVAL_MS, CLEANUP_INTERVAL_MS);
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栧綋鍓嶆棩蹇楁枃浠惰矾寰�
+ /// </summary>
+ private void InitializeCurrentLogFile()
+ {
+ string currentDate = DateTime.Now.ToString("yyyyMMdd");
+ string fileName = $"Log_{currentDate}.txt";
+ _currentLogFilePath = Path.Combine(_logDirectory, fileName);
+ }
+
+ /// <summary>
+ /// 娣诲姞鏃ュ織鍒扮紦鍐插尯锛屽欢杩熸壒閲忎繚瀛�
+ /// </summary>
+ public void LogAdded(LogEntry logEntry)
+ {
+ if (_isSaving) return;
+
+ lock (_bufferLock)
+ {
+ _logBuffer.Enqueue(logEntry);
+ _bufferCount++;
+
+ // 濡傛灉缂撳啿鍖鸿揪鍒版渶澶уぇ灏忥紝绔嬪嵆瑙﹀彂淇濆瓨
+ if (_bufferCount >= MAX_BATCH_SIZE)
+ {
+ Task.Run(() => SaveBatchAsync());
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鎵归噺淇濆瓨瀹氭椂鍣ㄥ洖璋�
+ /// </summary>
+ private void OnBatchSaveTimerElapsed(object state)
+ {
+ if (!_isSaving && _bufferCount > 0)
+ {
+ Task.Run(() => SaveBatchAsync());
+ }
+ }
+
+ /// <summary>
+ /// 寮傛鎵归噺淇濆瓨鏃ュ織
+ /// </summary>
+ private async Task SaveBatchAsync()
+ {
+ if (_isSaving) return;
+
+ _isSaving = true;
+
+ try
+ {
+ // 妫�鏌ユ槸鍚﹂渶瑕佸垏鎹㈠埌鏂版枃浠�
+ await CheckAndSwitchLogFileAsync();
+
+ // 鑾峰彇缂撳啿鍖轰腑鐨勬墍鏈夋棩蹇�
+ List<LogEntry> batchToSave;
+ lock (_bufferLock)
+ {
+ if (_bufferCount == 0)
+ {
+ _isSaving = false;
+ return;
+ }
+
+ batchToSave = new List<LogEntry>(_logBuffer);
+ _logBuffer.Clear();
+ _bufferCount = 0;
+ }
+
+ // 鎵归噺淇濆瓨鍒版枃浠�
+ await SaveBatchToFileAsync(batchToSave);
+
+ Console.WriteLine($"鎵归噺淇濆瓨浜� {batchToSave.Count} 鏉℃棩蹇楀埌鏂囦欢");
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"鎵归噺淇濆瓨澶辫触: {ex.Message}");
+ }
+ finally
+ {
+ _isSaving = false;
+ }
+ }
+
+ /// <summary>
+ /// 鎵归噺淇濆瓨鏃ュ織鍒版枃浠�
+ /// </summary>
+ private async Task SaveBatchToFileAsync(List<LogEntry> batch)
+ {
+ await Task.Run(() =>
+ {
+ lock (_fileLock)
+ {
+ try
+ {
+ using (StreamWriter writer = new StreamWriter(_currentLogFilePath, true, Encoding.UTF8))
+ {
+ foreach (var entry in batch)
+ {
+ string logLine = $"[{entry.Timestamp:yyyy-MM-dd HH:mm:ss.fff}] [{entry.Level}] {entry.Message}";
+ writer.WriteLine(logLine);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"鎵归噺淇濆瓨鍒版枃浠跺け璐�: {ex.Message}");
+ }
+ }
+ });
+ }
+
+ /// <summary>
+ /// 妫�鏌ユ槸鍚﹂渶瑕佸垏鎹㈠埌鏂扮殑鏃ュ織鏂囦欢
+ /// </summary>
+ private async Task CheckAndSwitchLogFileAsync()
+ {
+ await Task.Run(() =>
+ {
+ string currentDate = DateTime.Now.ToString("yyyyMMdd");
+ string fileName = $"Log_{currentDate}.txt";
+ string newFilePath = Path.Combine(_logDirectory, fileName);
+
+ // 濡傛灉鏃ユ湡鍙樺寲锛屽垏鎹㈠埌鏂版枃浠�
+ if (_currentLogFilePath != newFilePath)
+ {
+ _currentLogFilePath = newFilePath;
+ }
+ });
+ }
+
+ private void OnCleanupTimerElapsed(object state)
+ {
+ // 娓呯悊瓒呰繃48灏忔椂鐨勬棩蹇楁枃浠�
+ if (!_isSaving)
+ {
+ Task.Run(() => CleanupOldLogFilesAsync());
+ }
+ }
+
+ /// <summary>
+ /// 娓呯悊瓒呰繃48灏忔椂鐨勬棩蹇楁枃浠�
+ /// </summary>
+ private async Task CleanupOldLogFilesAsync()
+ {
+ await Task.Run(() =>
+ {
+ try
+ {
+ if (Directory.Exists(_logDirectory))
+ {
+ var files = Directory.GetFiles(_logDirectory, "Log_*.txt");
+ DateTime cutoffTime = DateTime.Now.AddHours(-48);
+
+ foreach (string file in files)
+ {
+ try
+ {
+ FileInfo fileInfo = new FileInfo(file);
+ if (fileInfo.LastWriteTime < cutoffTime)
+ {
+ File.Delete(file);
+ Console.WriteLine($"娓呯悊杩囨湡鏃ュ織鏂囦欢: {file}");
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"娓呯悊鏂囦欢澶辫触 {file}: {ex.Message}");
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"娓呯悊杩囨湡鏃ュ織鏂囦欢澶辫触: {ex.Message}");
+ }
+ });
+ }
+
+ /// <summary>
+ /// 鎵嬪姩淇濆瓨褰撳墠鎵�鏈夋棩蹇�
+ /// </summary>
+ public void ForceSave()
+ {
+ if (!_isSaving)
+ {
+ Task.Run(() => SaveBatchAsync());
+ }
+ }
+
+ /// <summary>
+ /// 鍋滄鏈嶅姟
+ /// </summary>
+ public void Stop()
+ {
+ _batchSaveTimer?.Dispose();
+ _batchSaveTimer = null;
+ _cleanupTimer?.Dispose();
+ _cleanupTimer = null;
+
+ // 淇濆瓨鏈�鍚庣殑鏃ュ織
+ if (!_isSaving && _bufferCount > 0)
+ {
+ ForceSave();
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇淇濆瓨缁熻淇℃伅
+ /// </summary>
+ public string GetStatus()
+ {
+ try
+ {
+ string currentFileInfo = "";
+ if (File.Exists(_currentLogFilePath))
+ {
+ FileInfo fileInfo = new FileInfo(_currentLogFilePath);
+ currentFileInfo = $", 褰撳墠鏂囦欢澶у皬: {fileInfo.Length / 1024} KB";
+ }
+
+ return $"鑷姩淇濆瓨鏈嶅姟杩愯涓� - 缂撳啿鍖�: {_bufferCount} 鏉currentFileInfo}";
+ }
+ catch
+ {
+ return $"鑷姩淇濆瓨鏈嶅姟杩愯涓� - 缂撳啿鍖�: {_bufferCount} 鏉�";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/IDViewer_2D/LoginWindow.xaml b/IDViewer_2D/LoginWindow.xaml
new file mode 100644
index 0000000..7c4a807
--- /dev/null
+++ b/IDViewer_2D/LoginWindow.xaml
@@ -0,0 +1,29 @@
+锘�<Window x:Class="SmartScanner.LoginWindow"
+ 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:SmartScanner"
+ mc:Ignorable="d"
+ Title="鏉冮檺楠岃瘉" Height="200" Width="300" ResizeMode="NoResize">
+ <Grid Margin="10">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="AUto"/>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="AUTO"/>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+
+ <Label Grid.Row="0" Content="鐢ㄦ埛鍚�:"/>
+ <ComboBox Grid.Row="1" x:Name="cmbUsername" ItemsSource="{Binding UserList}" Height="25" DisplayMemberPath="Username"/>
+
+ <Label Grid.Row="2" Content="瀵嗙爜:"/>
+ <PasswordBox Grid.Row="3" x:Name="txtPassword" Height="25"/>
+
+ <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Right">
+ <Button Content="鐧诲綍" Width="80" Margin="5" Click="BtnLogin_Click"/>
+ <Button Content="鍙栨秷" Width="80" Margin="5" Click="BtnCancel_Click"/>
+ </StackPanel>
+ </Grid>
+</Window>
diff --git a/IDViewer_2D/LoginWindow.xaml.cs b/IDViewer_2D/LoginWindow.xaml.cs
new file mode 100644
index 0000000..78e0fb4
--- /dev/null
+++ b/IDViewer_2D/LoginWindow.xaml.cs
@@ -0,0 +1,50 @@
+锘縰sing 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.Shapes;
+
+namespace SmartScanner
+{
+ /// <summary>
+ /// LoginWindow.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ public partial class LoginWindow : Window
+ {
+ public LoginWindow()
+ {
+ InitializeComponent();
+ cmbUsername.ItemsSource = UserManager.UserList;
+ cmbUsername.SelectedIndex = 0;
+ }
+ private void BtnLogin_Click(object sender, RoutedEventArgs e)
+ {
+ var selectedUser = cmbUsername.SelectedItem as User;
+ if (selectedUser == null) return;
+
+ if (UserManager.Authenticate(selectedUser.Username, txtPassword.Password))
+ {
+ DialogResult = true;
+ Close();
+ }
+ else
+ {
+ MessageBox.Show("鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒", "鐧诲綍澶辫触", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void BtnCancel_Click(object sender, RoutedEventArgs e)
+ {
+ DialogResult = false;
+ Close();
+ }
+ }
+}
diff --git a/IDViewer_2D/MainWindow.xaml b/IDViewer_2D/MainWindow.xaml
new file mode 100644
index 0000000..58fe5ca
--- /dev/null
+++ b/IDViewer_2D/MainWindow.xaml
@@ -0,0 +1,915 @@
+锘�<Window x:Class="SmartScanner.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:SmartScanner"
+ xmlns:Properties="clr-namespace:SmartScanner.Properties"
+ mc:Ignorable="d"
+ Title="SmartScanner" Height="768" Width="1240">
+ <Grid Background="#3C3C3C">
+ <Grid.Resources>
+ <Style x:Key="SimpleLabeledToggleSwitchStyle" TargetType="{x:Type ToggleButton}">
+ <Setter Property="Background" Value="#E0E0E0"/>
+ <Setter Property="Foreground" Value="White"/>
+ <Setter Property="BorderBrush" Value="Transparent"/>
+ <Setter Property="BorderThickness" Value="0"/>
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="{x:Type ToggleButton}">
+ <Grid>
+ <VisualStateManager.VisualStateGroups>
+ <!-- 浠呬繚鐣橮ressed鍜孌isabled鐘舵�� -->
+ <VisualStateGroup x:Name="CommonStates">
+ <VisualState x:Name="Normal"/>
+ <VisualState x:Name="MouseOver">
+ <Storyboard>
+ <DoubleAnimation Storyboard.TargetName="SwitchThumb"
+ Storyboard.TargetProperty="Opacity"
+ To="0.8" Duration="0:0:0.1"/>
+ </Storyboard>
+ </VisualState>
+ <VisualState x:Name="Pressed">
+ <Storyboard>
+ <!-- 鎸変笅鏃剁殑婊戝潡鏀惧ぇ鏁堟灉 -->
+ <DoubleAnimation Storyboard.TargetName="SwitchThumb"
+ Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
+ To="1.2" Duration="0:0:0.1"/>
+ <DoubleAnimation Storyboard.TargetName="SwitchThumb"
+ Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
+ To="1.2" Duration="0:0:0.1"/>
+ </Storyboard>
+ </VisualState>
+ <VisualState x:Name="Disabled">
+ <Storyboard>
+ <ColorAnimation Storyboard.TargetName="SwitchTrack"
+ Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
+ To="#EEEEEE" Duration="0"/>
+ <ColorAnimation Storyboard.TargetName="SwitchThumb"
+ Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
+ To="#BDBDBD" Duration="0"/>
+ <ColorAnimation Storyboard.TargetName="TextLabel"
+ Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
+ To="#BDBDBD" Duration="0"/>
+ </Storyboard>
+ </VisualState>
+ </VisualStateGroup>
+
+ <!-- 寮�鍏崇姸鎬侊紙淇濇寔涓嶅彉锛� -->
+ <VisualStateGroup x:Name="CheckStates">
+ <VisualState x:Name="Checked">
+ <Storyboard>
+ <ThicknessAnimation Storyboard.TargetName="SwitchThumb"
+ Storyboard.TargetProperty="Margin"
+ To="26,0,0,0" Duration="0:0:0.2"/>
+ <ColorAnimation Storyboard.TargetName="SwitchTrack"
+ Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
+ To="#4CAF50" Duration="0:0:0.2"/>
+ <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel"
+ Storyboard.TargetProperty="Text">
+ <DiscreteObjectKeyFrame KeyTime="0" Value="鍗曠偣ON"/>
+ </ObjectAnimationUsingKeyFrames>
+ <ColorAnimation Storyboard.TargetName="TextLabel"
+ Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
+ To="#4CAF50" Duration="0:0:0.2"/>
+ </Storyboard>
+ </VisualState>
+ <VisualState x:Name="Unchecked">
+ <Storyboard>
+ <ThicknessAnimation Storyboard.TargetName="SwitchThumb"
+ Storyboard.TargetProperty="Margin"
+ To="0,0,0,0" Duration="0:0:0.2"/>
+ <ColorAnimation Storyboard.TargetName="SwitchTrack"
+ Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
+ To="#E0E0E0" Duration="0:0:0.2"/>
+ <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel"
+ Storyboard.TargetProperty="Text">
+ <DiscreteObjectKeyFrame KeyTime="0" Value="鍗曠偣OFF"/>
+ </ObjectAnimationUsingKeyFrames>
+ <ColorAnimation Storyboard.TargetName="TextLabel"
+ Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
+ To="#757575" Duration="0:0:0.2"/>
+ </Storyboard>
+ </VisualState>
+ </VisualStateGroup>
+ </VisualStateManager.VisualStateGroups>
+
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+
+ <!-- 寮�鍏宠建閬� -->
+ <Border x:Name="SwitchTrack"
+ Grid.Column="0"
+ Background="{TemplateBinding Background}"
+ CornerRadius="10"
+ Width="50"
+ Height="24"
+ Margin="0,0,10,0">
+ <Border x:Name="SwitchThumb"
+ Background="{TemplateBinding Foreground}"
+ CornerRadius="10"
+ Width="24"
+ Height="24"
+ HorizontalAlignment="Left"
+ Margin="0,0,0,0">
+ <Border.RenderTransform>
+ <TransformGroup>
+ <ScaleTransform/>
+ </TransformGroup>
+ </Border.RenderTransform>
+ </Border>
+ </Border>
+
+ <!-- 鏂囧瓧鏍囩 -->
+ <TextBlock x:Name="TextLabel"
+ Grid.Column="1"
+ Text="OFF"
+ VerticalAlignment="Center"
+ Foreground="#757575"
+ FontWeight="SemiBold"/>
+ </Grid>
+
+ <ControlTemplate.Triggers>
+ <Trigger Property="IsEnabled" Value="False">
+ <Setter TargetName="SwitchTrack" Property="Opacity" Value="0.6"/>
+ <Setter TargetName="TextLabel" Property="Opacity" Value="0.6"/>
+ </Trigger>
+ </ControlTemplate.Triggers>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+ <Style x:Key="TabItemStyle">
+ <Style.Triggers>
+ <Trigger Property="TabItem.IsSelected" Value="True">
+ <Setter Property="TabItem.Background" Value="#6C6C6C"/>
+ <Setter Property="TabItem.Foreground" Value="Black"/>
+ </Trigger>
+ <Trigger Property="TabItem.IsSelected" Value="False">
+ <Setter Property="TabItem.Background" Value="#6C6C6C"/>
+ <Setter Property="TabItem.Foreground" Value="White"/>
+ </Trigger>
+ <Trigger Property="TabItem.IsMouseOver" Value="True">
+ <Setter Property="TabItem.Background" Value="#6C6C6C"/>
+ <Setter Property="TabItem.Foreground" Value="Black"/>
+ </Trigger>
+ <!--<Trigger Property="TabItem.IsMouseOver" Value="False">
+ <Setter Property="TabItem.Background" Value="#6C6C6C"/>
+ <Setter Property="TabItem.Foreground" Value="White"/>
+ </Trigger>-->
+ <!--<Trigger Property="TabItem.IsFocused" Value="True">
+ <Setter Property="TabItem.Background" Value="#4D0000"/>
+ <Setter Property="TabItem.Foreground" Value="#930000"/>
+ </Trigger>-->
+ <!--<Trigger Property="TabItem.IsFocused" Value="False">
+ <Setter Property="TabItem.Background" Value="#6C6C6C"/>
+ <Setter Property="TabItem.Foreground" Value="White"/>
+ </Trigger>-->
+ </Style.Triggers>
+ </Style>
+ <Style x:Key="FocusVisual">
+ <Setter Property="Control.Template">
+ <Setter.Value>
+ <ControlTemplate>
+ <Rectangle Margin="2" StrokeDashArray="1 2" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" SnapsToDevicePixels="true" StrokeThickness="1"/>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+ <!--鎸夐挳闈欐�佹椂鑳屾櫙棰滆壊-->
+ <SolidColorBrush x:Key="Button.Static.Background" Color="#4F4F4F"/>
+ <!--鎸夐挳闈欐�佹椂杈规棰滆壊-->
+ <SolidColorBrush x:Key="Button.Static.Border" Color="#2F0000"/>
+ <!--鎸夐挳闈欐�佹椂鏂囧瓧棰滆壊-->
+ <SolidColorBrush x:Key="Button.Static.Foreground" Color="White"/>
+ <!--榧犳爣绉诲叆鏃惰儗鏅鑹�-->
+ <SolidColorBrush x:Key="Button.MouseOver.Background" Color="#4D0000"/>
+ <!--榧犳爣绉诲叆鏃惰竟妗嗛鑹�-->
+ <SolidColorBrush x:Key="Button.MouseOver.Border" Color="#2F0000"/>
+ <!--榧犳爣鎸変笅鏃惰儗鏅鑹�-->
+ <SolidColorBrush x:Key="Button.Pressed.Background" Color="#4D0000"/>
+ <!--榧犳爣鎸変笅鏃惰竟妗嗛鑹�-->
+ <SolidColorBrush x:Key="Button.Pressed.Border" Color="#2F0000"/>
+ <!--鎸夐挳涓嶄娇鐢ㄦ椂鑳屾櫙棰滆壊-->
+ <SolidColorBrush x:Key="Button.Disabled.Background" Color="Gray"/>
+ <!--鎸夐挳涓嶄娇鐢ㄦ椂杈规棰滆壊-->
+ <SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/>
+ <!--鎸夐挳涓嶄娇鐢ㄦ椂鏂囧瓧棰滆壊-->
+ <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="White"/>
+ <Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
+ <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
+ <Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
+ <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
+ <Setter Property="Foreground" Value="White"/>
+ <Setter Property="BorderThickness" Value="1"/>
+ <!--杈规瀹藉害锛岃缃负0 鍗筹細鏃犺竟妗�-->
+ <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" CornerRadius="5" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true">
+ <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+ </Border>
+ <!--瑙﹀彂鍣細鏍规嵁渚濊禆灞炴�х殑鍊煎幓鎺у埗鎺т欢鐨勭姸鎬�-->
+ <ControlTemplate.Triggers>
+ <!--榛樿灞炴��-->
+ <Trigger Property="IsDefaulted" Value="true">
+ <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
+ </Trigger>
+ <!--榧犳爣绉诲叆灞炴��-->
+ <Trigger Property="IsMouseOver" Value="true">
+ <Setter Property="Background" TargetName="border" Value="{StaticResource Button.MouseOver.Background}"/>
+ <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/>
+ </Trigger>
+ <!--榧犳爣鎸変笅灞炴��-->
+ <Trigger Property="IsPressed" Value="true">
+ <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
+ <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
+ </Trigger>
+ <!--鎸夐挳鍙敤鐘舵�佸睘鎬�-->
+ <Trigger Property="IsEnabled" Value="false">
+ <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
+ <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
+ <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
+ </Trigger>
+ </ControlTemplate.Triggers>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
+ <!--鏂囨湰妗嗘牱寮�-->
+ <SolidColorBrush x:Key="TextBox.Background" Color="#6C6C6C"/>
+ <SolidColorBrush x:Key="TextBox.BorderBrush" Color="#1F0000"/>
+ <SolidColorBrush x:Key="TextBox.Foreground" Color="White"/>
+ <Style x:Key="TextStyle" TargetType="{x:Type TextBox}">
+ <Setter Property="Background" Value="{StaticResource TextBox.Background}"/>
+ <Setter Property="BorderBrush" Value="{StaticResource TextBox.BorderBrush}"/>
+ <Setter Property="Foreground" Value="{StaticResource TextBox.Foreground}"/>
+ <Setter Property="VerticalContentAlignment" Value="Center"/>
+ <Setter Property="VerticalAlignment" Value="Center"/>
+ <Setter Property="BorderThickness" Value="1"/>
+ <Setter Property="HorizontalContentAlignment" Value="Right"/>
+ </Style>
+ <!-- 杩欎細褰卞搷鎵�鏈夊伐鍏锋爮鐨勬孩鍑鸿彍鍗� -->
+ <SolidColorBrush x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ToolBar}, ResourceId=ToolBarMenuBackground}"
+ Color="#3C3C3C"/>
+ </Grid.Resources>
+
+ <!--<Grid.ColumnDefinitions>
+ <ColumnDefinition Width="231*"/>
+ <ColumnDefinition Width="169*"/>
+ </Grid.ColumnDefinitions>-->
+ <Grid.RowDefinitions>
+ <RowDefinition Height="50"/>
+ <RowDefinition Height="15*"/>
+ </Grid.RowDefinitions>
+ <Grid Grid.Row="0" Grid.ColumnSpan="2">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="160"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+ <StackPanel Grid.Column="0" Height="50" Width="150" Margin="5,0,5,0.4" Grid.RowSpan="2">
+ <Image Stretch="Fill" Source="/Image/Currency/logo_01.png"/>
+ </StackPanel>
+ <ToolBarTray Grid.Column="1" Orientation="Horizontal" Background="#3C3C3C" Margin="0,0,-0.4,0.4" Grid.RowSpan="2">
+ <ToolBar Grid.Column="1" Margin="0,0,-0.4,0.4" Grid.RowSpan="2" Background="#3C3C3C" Height="50">
+ <Button x:Name="Refresh_Btn" Background="#7B7B7B" BorderThickness="0" ToolTip="鍒锋柊璁惧鍒楄〃骞惰繛鎺ヨ澶�" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Click="Refresh_Btn_Click" Margin="5,0,5,0">
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
+ <Image x:Name="Refresh_BtnImage" Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality" Source="\Image\ICON\link-m.png"/>
+ <TextBlock Text="鍒锋柊杩炴帴" VerticalAlignment="Center" Foreground="white"/>
+ </StackPanel>
+ </Button>
+ <!--<Button x:Name="IsConnect_Btn" Click="IsConnect_Btn_Click" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Margin="5,0,5,0">
+ <Label Content="杩炴帴" Foreground="White" />
+ </Button>-->
+ <Button x:Name="ProductMaanager_Btn" Click="ProductMaanager_Btn_Click" ToolTip="鎵撳紑璁惧绠$悊鍒楄〃" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Margin="5,0,5,0">
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
+ <Image x:Name="ProductMaanager_BtnImage" Source="\Image\ICON\camera-switch-fill.png" RenderOptions.BitmapScalingMode="HighQuality" Stretch="Fill"/>
+ <TextBlock Text="璁惧绠$悊" VerticalAlignment="Center" Foreground="White" />
+ </StackPanel>
+ </Button>
+ <!--<Button x:Name="Disconnect_Btn" Click="Disconnect_Btn_Click" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" IsEnabled="False" Style="{DynamicResource ButtonStyle}" Margin="5,0,5,0" Visibility="Collapsed">
+ <Label Content="鏂紑杩炴帴" Foreground="White" />
+ </Button>-->
+ <Button x:Name="ResultJudge_Btn" Click="ResultJudge_Btn_Click" ToolTip="鎵撳紑妫�娴嬫柟妗堥厤缃櫒" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Margin="5,0,5,0">
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
+ <Image x:Name="ResultJudge_BtnImage" Source="\Image\ICON\folder-2-fill.png" RenderOptions.BitmapScalingMode="HighQuality" Stretch="Fill"/>
+ <TextBlock Text="妫�娴嬫柟妗�" VerticalAlignment="Center" Foreground="White" />
+ </StackPanel>
+ </Button>
+ <Button x:Name="ImageSetup_Btn" Click="ImageSetup_Btn_Click" ToolTip="鎵撳紑鍥惧儚瀛樺偍璁剧疆" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Margin="5,0,5,0">
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
+ <Image x:Name="ImageSetup_BtnImage" Source="\Image\ICON\import-fill.png" RenderOptions.BitmapScalingMode="HighQuality" Stretch="Fill"/>
+ <TextBlock Text="瀛樺浘璁剧疆" VerticalAlignment="Center" Foreground="White"/>
+ </StackPanel>
+ </Button>
+ <CheckBox Name="OutputCheckBox" Content="鍗曠偣杈撳嚭" VerticalAlignment="Center" Foreground="White" HorizontalAlignment="Center" IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=OutputCheckBoxEnable, Mode=TwoWay}"
+ Checked="OutputCheckBox_Checked" Unchecked="OutputCheckBox_Unchecked" Style="{DynamicResource SimpleLabeledToggleSwitchStyle}"/>
+ <!--<Button x:Name="Start_Detector_Btn" Visibility="Hidden" Click="Start_Detector_Btn_Click" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Margin="5,0,5,0">
+ <Label Content="寮�濮嬫娴�" Foreground="White" />
+ </Button>-->
+
+ <Button x:Name="Write" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Click="Write_Click" Margin="5,0,5,0">
+ <Label Content="閫氳娴嬭瘯" Foreground="White" />
+ </Button>
+ <Button x:Name="Read" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Click="Read_Click" Margin="5,0,5,0">
+ <Label Content="鎵嬪姩閲囬泦" Foreground="White" />
+ </Button>
+ <Button x:Name="Reset" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Click="ReSet_Click" Margin="5,0,5,0">
+ <Label Content="鐣岄潰閲嶇疆" Foreground="White" />
+ </Button>
+ <Button x:Name="btnViewReports" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Click="btnViewReports_Click" Margin="5,0,5,0">
+ <Label Content="鏌ョ湅妫�娴嬫姤鍛�" Foreground="White" />
+ </Button>
+ <Button x:Name="btnViewLogs" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Click="btnViewLogs_Click" Margin="5,0,5,0">
+ <Label Content="鏌ョ湅鏃ュ織" Foreground="White" />
+ </Button>
+ <Button x:Name="RestartButton" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Click="RestartButton_Click" Margin="5,0,5,0">
+ <Label Content="涓�閿噸鍚�" Foreground="White" />
+ </Button>
+ <Button x:Name="VersionButton" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Click="VersionButton_Click" Margin="5,0,5,0">
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
+ <Label Content="鐗堟湰璇存槑" VerticalAlignment="Center" Foreground="White" Margin="5,0,0,0"/>
+ </StackPanel>
+ </Button>
+ <!--<Button x:Name="LogTest" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Click="AddTestLog_Click" Margin="5,0,5,0">
+ <Label Content="鏃ュ織娴嬭瘯" Foreground="White" />
+ </Button>-->
+ </ToolBar>
+ </ToolBarTray>
+ </Grid>
+ <Grid Grid.Row="1">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="1*"></ColumnDefinition>
+ <ColumnDefinition Width="0.05*"></ColumnDefinition>
+ <ColumnDefinition Width="5*"></ColumnDefinition>
+ <ColumnDefinition Width="0.05*"></ColumnDefinition>
+ <ColumnDefinition Width="Auto"></ColumnDefinition>
+ </Grid.ColumnDefinitions>
+ <Grid Grid.Column="0">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="0.11*"/>
+ <RowDefinition Height="1*"/>
+ <RowDefinition Height="0.11*"/>
+ <RowDefinition Height="1*"/>
+ </Grid.RowDefinitions>
+ <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center">
+ <!--<Button x:Name="IPSet" Content="IP璁剧疆" Foreground="White" Background="#7B7B7B" BorderThickness="0" Height="30" Width="100" Style="{DynamicResource ButtonStyle}" Click="IPSet_Click"></Button>-->
+ <Label Content="璁惧鍒楄〃" HorizontalAlignment="Center" FontSize="20" FontFamily="Yu Gothic UI" Foreground="White"/>
+ </StackPanel>
+ <Grid Grid.Row="1">
+ <Border Grid.Row="0" BorderBrush="Black" BorderThickness="1" CornerRadius="5" Background="White">
+ <ListBox x:Name="DeviceListBox" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontSize="20" FontFamily="Yu Gothic UI" SelectionChanged="DeviceListBox_SelectionChanged">
+ </ListBox>
+ </Border>
+ </Grid>
+ <StackPanel Grid.Row="2">
+ <Label Content="璁惧淇℃伅" HorizontalAlignment="Center" FontSize="20" FontFamily="Yu Gothic UI" Foreground="White"/>
+ </StackPanel>
+ <Border Grid.Row="3" BorderBrush="Black" BorderThickness="1" CornerRadius="5" Background="White">
+ <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
+ <Grid x:Name="ProductInformation">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ </Grid.RowDefinitions>
+ <StackPanel Orientation="Horizontal" Grid.Row="0" VerticalAlignment="Center">
+ <TextBlock Text="IP鍦板潃:" Foreground="Black" FontSize="14"/>
+ <TextBlock Name="CameraIP" Text="" Margin="5,0,0,0" Foreground="Black" FontSize="14"/>
+ </StackPanel>
+ <StackPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" >
+ <TextBlock Text="瀛愮綉:" Foreground="Black" FontSize="14"/>
+ <TextBlock Name="CameraNetMask" Text="" Margin="5,0,0,0" Foreground="Black" FontSize="14"/>
+ </StackPanel>
+ <StackPanel Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Center">
+ <TextBlock Text="缃戝叧:" Foreground="Black" FontSize="14"/>
+ <TextBlock Name="CameraGateWay" Text="" Margin="5,0,0,0" Foreground="Black" FontSize="14"/>
+ </StackPanel>
+ <StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Center">
+ <TextBlock Text="鍥轰欢鐗堟湰:" Foreground="Black" FontSize="14"/>
+ <TextBlock Name="CameraFirmwareVersion" Text="" Margin="5,0,0,0" Foreground="Black" FontSize="14"/>
+ </StackPanel>
+ <StackPanel Grid.Row="4" Orientation="Horizontal" VerticalAlignment="Center">
+ <TextBlock Text="璁惧鍨嬪彿:" Foreground="Black" FontSize="14"/>
+ <TextBlock Name="CameraModel" Text="" Margin="5,0,0,0" Foreground="Black" FontSize="14"/>
+ </StackPanel>
+ <StackPanel Grid.Row="5" Orientation="Horizontal" VerticalAlignment="Center">
+ <TextBlock Text="璁惧鍚�:" Foreground="Black" FontSize="14"/>
+ <TextBlock Name="CameraAlias" Text="" Margin="5,0,0,0" Foreground="Black" FontSize="14"/>
+ </StackPanel>
+ </Grid>
+ </ScrollViewer>
+ </Border>
+ </Grid>
+ <Grid Grid.Column="2">
+ <!--缁撴灉鏄剧ず-->
+ <Grid.RowDefinitions>
+ <RowDefinition Height="auto"/>
+ <RowDefinition Height="11.5*"/>
+ <RowDefinition Height="3.5*"/>
+ </Grid.RowDefinitions>
+ <DockPanel Grid.Row="0" VerticalAlignment="Center">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ </Grid.RowDefinitions>
+ <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" DockPanel.Dock="Left">
+ <TextBlock Text="妫�娴嬬姸鎬侊細" Foreground="White" FontSize="23"/>
+ <TextBlock x:Name="DetectState" Text="鏈湪妫�娴�" FontSize="23" Foreground="red"/>
+ </StackPanel>
+
+ <StackPanel Grid.Row="0" Grid.Column="2" Orientation="Horizontal" >
+ <TextBlock Text="閫氳鐘舵�侊細" Foreground="White" FontSize="23"/>
+ <TextBlock x:Name="LinkState" Text="鏈繛鎺�" FontSize="23" Foreground="red"/>
+ </StackPanel>
+ <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal">
+ <TextBlock Text="妫�娴嬫柟妗堬細" Foreground="White" FontSize="23"/>
+ <TextBlock x:Name="ProjectState" Text="鏈姞杞�" FontSize="23" Foreground="red"/>
+ </StackPanel>
+ <StackPanel Grid.Row="1" Grid.Column="2" Orientation="Horizontal">
+ <TextBlock Text="妫�娴嬫ā鍨嬶細" Foreground="White" FontSize="23"/>
+ <TextBlock x:Name="ModelState" Text="鏈姞杞�" FontSize="23" Foreground="red"/>
+ </StackPanel>
+ </Grid>
+ </DockPanel>
+ <Grid Grid.Row="1">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*"/>
+ <ColumnDefinition Width="*"/>
+ <ColumnDefinition Width="*"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+ <Border x:Name="finall_result0" MouseLeftButtonDown="finall_result0_MouseLeftButtonDown" Grid.Row="0" Grid.Column="0" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias0" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName0" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ <!--<Button x:Name="finall_result0_Btn" Click="finall_result0_Btn_Click" Background="#7B7B7B"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result0" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ <!--缁撴灉鏄剧ず1-->
+ </Border>
+ <Border x:Name="finall_result1" MouseLeftButtonDown="finall_result1_MouseLeftButtonDown" Grid.Row="0" Grid.Column="1" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず2-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias1" Text="" Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName1" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result1" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result2" MouseLeftButtonDown="finall_result2_MouseLeftButtonDown" Grid.Row="0" Grid.Column="2" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず3-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias2" Text="" Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName2" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result2" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result3" MouseLeftButtonDown="finall_result3_MouseLeftButtonDown" Grid.Row="0" Grid.Column="3" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず4-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias3" Text="" Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName3" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result3" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result4" MouseLeftButtonDown="finall_result4_MouseLeftButtonDown" Grid.Row="1" Grid.Column="0" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず5-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias4" Text="" Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName4" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result4" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result5" Grid.Row="1" MouseLeftButtonDown="finall_result5_MouseLeftButtonDown" Grid.Column="1" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず6-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias5" Text="" Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName5" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result5" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result6" Grid.Row="1" MouseLeftButtonDown="finall_result6_MouseLeftButtonDown" Grid.Column="2" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず7-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias6" Text="" Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName6" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result6" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result7" Grid.Row="1" MouseLeftButtonDown="finall_result7_MouseLeftButtonDown" Grid.Column="3" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず8-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias7" Text="" Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName7" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result7" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result8" MouseLeftButtonDown="finall_result8_MouseLeftButtonDown" Grid.Row="2" Grid.Column="0" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず9-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias8" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName8" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result8" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result9" MouseLeftButtonDown="finall_result9_MouseLeftButtonDown" Grid.Row="2" Grid.Column="1" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず10-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias9" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName9" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result9" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result10" MouseLeftButtonDown="finall_result10_MouseLeftButtonDown" Grid.Row="2" Grid.Column="2" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず11-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias10" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName10" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result10" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result11" MouseLeftButtonDown="finall_result11_MouseLeftButtonDown" Grid.Row="2" Grid.Column="3" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず12-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias11" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName11" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result11" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result12" MouseLeftButtonDown="finall_result12_MouseLeftButtonDown" Grid.Row="3" Grid.Column="0" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず13-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias12" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName12" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result12" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result13" MouseLeftButtonDown="finall_result13_MouseLeftButtonDown" Grid.Row="3" Grid.Column="1" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず14-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias13" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName13" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result13" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result14" MouseLeftButtonDown="finall_result14_MouseLeftButtonDown" Grid.Row="3" Grid.Column="2" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず15-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias14" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName14" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result14" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result15" MouseLeftButtonDown="finall_result15_MouseLeftButtonDown" Grid.Row="3" Grid.Column="3" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず16-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias15" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName15" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result15" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result16" MouseLeftButtonDown="finall_result16_MouseLeftButtonDown" Grid.Row="4" Grid.Column="0" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず17-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias16" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName16" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result16" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result17" MouseLeftButtonDown="finall_result17_MouseLeftButtonDown" Grid.Row="4" Grid.Column="1" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず18-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias17" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName17" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result17" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result18" MouseLeftButtonDown="finall_result18_MouseLeftButtonDown" Grid.Row="4" Grid.Column="2" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず19-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias18" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName18" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result18" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result19" MouseLeftButtonDown="finall_result19_MouseLeftButtonDown" Grid.Row="4" Grid.Column="3" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず20-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias19" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName19" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result19" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result20" MouseLeftButtonDown="finall_result20_MouseLeftButtonDown" Grid.Row="5" Grid.Column="0" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず21-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias20" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName20" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result20" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result21" MouseLeftButtonDown="finall_result21_MouseLeftButtonDown" Grid.Row="5" Grid.Column="1" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず22-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias21" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName21" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result21" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result22" MouseLeftButtonDown="finall_result22_MouseLeftButtonDown" Grid.Row="5" Grid.Column="2" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず23-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias22" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName22" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result22" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ <Border x:Name="finall_result23" MouseLeftButtonDown="finall_result23_MouseLeftButtonDown" Grid.Row="5" Grid.Column="3" Background="#7B7B7B" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+ <!--缁撴灉鏄剧ず24-->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock x:Name="cameraAlias23" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></TextBlock>
+ <!--<TextBlock x:Name="deviceName23" Text=" " Height="30" Foreground="White" FontSize="15" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"/>-->
+ </StackPanel>
+ <Label x:Name="Finall_result23" Content="" Foreground="White" FontSize="30" FontFamily="Microsoft YaHei UI" FontWeight="Bold" HorizontalAlignment="Center"></Label>
+ </StackPanel>
+ </Border>
+ </Grid>
+ <Grid Grid.Row="2">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="1*"/>
+ <RowDefinition Height="3*"/>
+ </Grid.RowDefinitions>
+ <StackPanel Grid.Row="0" >
+ <Label Content="妫�娴嬫棩蹇�" HorizontalAlignment="Center" FontSize="20" FontFamily="Yu Gothic UI" Foreground="White"/>
+ </StackPanel >
+ <Border Grid.Row="1" BorderBrush="White" BorderThickness="2" CornerRadius="5">
+ <ListView x:Name="LogListView" ItemsSource="{Binding LogEntries}" VirtualizingStackPanel.IsVirtualizing="True" BorderThickness="0" >
+ <!--<ListView.Template>
+ <ControlTemplate TargetType="ListView">
+ <ScrollViewer x:Name="ScrollViewer" VerticalScrollBarVisibility="Auto">
+ <ItemsPresenter/>
+ </ScrollViewer>
+ </ControlTemplate>
+ </ListView.Template>-->
+ <ListView.View>
+ <GridView>
+ <GridViewColumn Header="鏃堕棿" Width="80">
+ <GridViewColumn.CellTemplate>
+ <DataTemplate>
+ <TextBlock Text="{Binding Timestamp, StringFormat='HH:mm:ss'}"
+ Foreground="{Binding Foreground}"/>
+ </DataTemplate>
+ </GridViewColumn.CellTemplate>
+ </GridViewColumn>
+ <GridViewColumn Header="绾у埆" Width="80">
+ <GridViewColumn.CellTemplate>
+ <DataTemplate>
+ <TextBlock Text="{Binding Level}" Foreground="{Binding Foreground}"/>
+ </DataTemplate>
+ </GridViewColumn.CellTemplate>
+ </GridViewColumn>
+ <GridViewColumn Header="娑堟伅" Width="600">
+ <GridViewColumn.CellTemplate>
+ <DataTemplate>
+ <TextBlock Text="{Binding Message}"
+ TextWrapping="Wrap"
+ Foreground="{Binding Foreground}"/>
+ </DataTemplate>
+ </GridViewColumn.CellTemplate>
+ </GridViewColumn>
+ </GridView>
+ </ListView.View>
+ </ListView>
+ </Border>
+ <!--<Border Grid.Row="1" BorderBrush="White" BorderThickness="2" CornerRadius="5" Background="#3C3C3C">
+ <TextBox Name="Log1" VerticalScrollBarVisibility="Hidden" Foreground="Black" BorderThickness="0"/>
+ </Border>-->
+ </Grid>
+ </Grid>
+
+ <Grid Grid.Column="4">
+ <!--鍙傛暟璁剧疆-->
+ <Grid.RowDefinitions>
+ <RowDefinition Height="1.5*"/>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="1.5*"/>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="1.5*"/>
+ <RowDefinition Height="5*"/>
+ </Grid.RowDefinitions>
+
+ <StackPanel Grid.Row="0">
+ <Label Content="宸ョ▼璁剧疆" HorizontalAlignment="Center" FontSize="20" FontFamily="Yu Gothic UI" Foreground="White"/>
+ </StackPanel>
+ <Grid Grid.Row="1">
+ <Border Grid.Row="0" BorderBrush="White" BorderThickness="2" CornerRadius="5" Background="#3C3C3C">
+ <ScrollViewer VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Hidden">
+ <StackPanel>
+ <!-- 杈撳嚭璁剧疆 -->
+ <GroupBox Header="绗憼姝ワ細妫�娴嬫柟妗堥�夋嫨" Foreground="White" Margin="0,0,0,10" FontSize="14">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <ComboBox Name="cmbDetectionPlans" DisplayMemberPath="FileName" SelectedValuePath="FullPath" Height="20" Width="100" HorizontalContentAlignment="Left" FontSize="12"/>
+ <Button Name="ResultJudge_Path" Content="閫夋嫨" Click="BtnSelectParam_Click" Width="50" Height="30" Margin="5,0,0,0" Style="{DynamicResource ButtonStyle}"/>
+ </StackPanel>
+ </GroupBox>
+
+ <!-- 鎺ㄧ悊寮曟搸閫夋嫨 -->
+ <GroupBox Header="绗憽姝ワ細妯″瀷閫夋嫨" Margin="0,0,0,10" Foreground="White" FontSize="14">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <ComboBox Name="cmbModels" DisplayMemberPath="FileName" SelectedValuePath="FullPath" Height="20" Width="100" HorizontalContentAlignment="Left" FontSize="12"/>
+ <Button Name="Model_Path" Click="BtnConfirmModel_Click" Content="纭畾" Width="50" Height="30" Margin="5,0,0,0" Style="{DynamicResource ButtonStyle}"/>
+ </StackPanel>
+ </GroupBox>
+
+ <!-- 宸ョ▼鏂囦欢瀵煎嚭 -->
+ <GroupBox Header="绗憿姝ワ細宸ョ▼鏂囦欢瀵煎嚭" Foreground="White" FontSize="14">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <Button Name="Proj" Content="瀵煎嚭" Click="BtnExport_Click" Width="60" Height="30" Style="{DynamicResource ButtonStyle}"/>
+ </StackPanel>
+ </GroupBox>
+
+ <!-- 宸ョ▼鏂囦欢鍔犺浇 -->
+ <GroupBox Header="绗懀姝ワ細宸ョ▼鏂囦欢鍔犺浇" Foreground="White" FontSize="14">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <ComboBox Name="cmbProjects" DisplayMemberPath="FileName" SelectedValuePath="FullPath" Height="20" Width="100" HorizontalContentAlignment="Left" FontSize="12" Margin="0,0,5,0"/>
+ <Button Content="鍔犺浇" Click="BtnLoad_Click" Width="60" Height="30" Style="{DynamicResource ButtonStyle}"/>
+ </StackPanel>
+ </GroupBox>
+
+ <!-- 鍒锋柊鎸夐挳 -->
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
+ <Button Content="鍒锋柊" Click="BtnRefreshModels_Click" Width="60" Height="30" Style="{DynamicResource ButtonStyle}"/>
+ </StackPanel>
+ </StackPanel>
+ </ScrollViewer>
+ </Border>
+ </Grid>
+
+ <StackPanel Grid.Row="2">
+ <Label Content="閫氳璁剧疆" HorizontalAlignment="Center" FontSize="20" FontFamily="Yu Gothic UI" Foreground="White"/>
+ </StackPanel>
+ <Border Grid.Row="3" BorderBrush="White" BorderThickness="2" CornerRadius="5" Background="#3C3C3C">
+ <Grid>
+ <Grid.RowDefinitions>
+ <!--<RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="*"/>-->
+ </Grid.RowDefinitions>
+ <TabControl HorizontalAlignment="Center" Background="#3C3C3C" BorderThickness="0">
+ <TabItem Header="ModBus" IsSelected="True" Width="80" Background="#7B7B7B" Style="{StaticResource TabItemStyle}">
+ <StackPanel Margin="10">
+ <TextBlock Text="鏈嶅姟鍣↖P:" HorizontalAlignment="Center" Foreground="White"/>
+ <ComboBox x:Name="Client_ServerIpComboBox" Width="140" IsEditable="True" SelectedIndex="0">
+ <ComboBoxItem Content="192.168.0.20" Width="120"/>
+ </ComboBox>
+ <TextBlock Text="绔彛鍙�:" HorizontalAlignment="Center" Foreground="White"/>
+ <ComboBox x:Name="Client_PortComboBox" Width="140" SelectedIndex="0">
+ <ComboBoxItem Content="502" Width="120" />
+ </ComboBox>
+ <TextBlock Background="#3C3C3C" Height="10"></TextBlock>
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <Button x:Name="Client_connect" Content="杩炴帴" Click="Client_Connect_Click" Style="{DynamicResource ButtonStyle}" Width="50" Height="25" Background="#7B7B7B"/>
+ <!--<Button x:Name="Client_disconnect" Content="鏂紑" Click="Client_Disconnect_Click" Style="{DynamicResource ButtonStyle}" Width="50" Height="25" Background="#7B7B7B"/>-->
+ <Button Content="娓呯┖" Click="Client_ClearClientLogs_Click" Style="{DynamicResource ButtonStyle}" Width="50" Height="25" Background="#7B7B7B"/>
+ </StackPanel>
+ <!--<TextBlock Text="鏁版嵁鍙戦��:" HorizontalAlignment="Center" />
+ <TextBox x:Name="Client_DataToSendTextBox" Width="200"/>
+ <Button Content="鍙戦��" Click="Client_SendData_Click" />-->
+
+ <!--<TextBlock Text="娑堟伅:" HorizontalAlignment="Center" Foreground="White"/>-->
+ <ScrollViewer VerticalScrollBarVisibility="Hidden">
+ <TextBox x:Name="Client_LogsTextBox" Height="80" IsReadOnly="True" TextWrapping="Wrap" FontSize="11"/>
+ </ScrollViewer>
+ </StackPanel>
+ </TabItem>
+
+ <TabItem Header="TCP/IP" Width="80" Background="#7B7B7B" Style="{StaticResource TabItemStyle}" >
+ <ScrollViewer VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Hidden">
+ <StackPanel Margin="10">
+ <TextBlock Text="鏈嶅姟鍣↖P:" HorizontalAlignment="Center" Foreground="White"/>
+ <ComboBox x:Name="TCPServer_IpComboBox" SelectedIndex="0">
+ <ComboBoxItem Content="127.0.0.1" />
+ <ComboBoxItem Content="0.0.0.0" />
+ </ComboBox>
+
+ <TextBlock Text="绔彛鍙�:" HorizontalAlignment="Center" Foreground="White"/>
+ <ComboBox x:Name="TCPServer_PortComboBox" SelectedIndex="0" IsEditable="True"
+ Text="{Binding Source={x:Static Properties:Settings.Default}, Path=DefaultPort, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ SelectedValue="{Binding Source={x:Static Properties:Settings.Default}, Path=SelectedPort, Mode=TwoWay}">
+ <ComboBoxItem Content="5011" Width="120"/>
+ <ComboBoxItem Content="8080" Width="120"/>
+ </ComboBox>
+
+ <CheckBox x:Name="TCPServer_EnableHeartbeat" Content="寮�鍚績璺虫娴�" Checked="TCPServer_EnableHeartbeat_Checked" Unchecked="TCPServer_EnableHeartbeat_Unchecked" Foreground="White" Margin="0,10,0,0"/>
+
+ <StackPanel x:Name="TCPServer_HeartbeatPanel" Margin="0,5,0,0" Visibility="Collapsed">
+ <TextBlock Text="蹇冭烦鎸囦护:" HorizontalAlignment="Center" Foreground="White"/>
+ <TextBox x:Name="TCPServer_HeartbeatCommand" Text="heartBeat" HorizontalAlignment="Center"/>
+
+ <TextBlock Text="蹇冭烦鍛ㄦ湡(ms):" HorizontalAlignment="Center" Foreground="White" Margin="0,5,0,0"/>
+ <TextBox x:Name="TCPServer_HeartbeatInterval" Text="1000" HorizontalAlignment="Center"/>
+ </StackPanel>
+
+ <TextBlock Background="#3C3C3C" Height="10"></TextBlock>
+
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <Button x:Name="TCPServer_Start" Content="寮�鍚�" ToolTip="鏈嶅姟鍣ㄥ紑鍚睛鍚�" Click="TCPServer_Start_Click" Style="{DynamicResource ButtonStyle}" Width="50" Height="25" Background="#7B7B7B"/>
+ <Button x:Name="TCPServer_Stop" Content="鍋滄" ToolTip="鏈嶅姟鍣ㄥ仠姝睛鍚�" Click="TCPServer_Stop_Click" Style="{DynamicResource ButtonStyle}" Width="50" Height="25" Background="#7B7B7B" Margin="5,0,0,0"/>
+ </StackPanel>
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <Button x:Name="RefreshIpButton" Content="鍒锋柊" ToolTip="鍒锋柊鍙敤IP鍒楄〃" Click="RefreshIpButton_Click" Style="{DynamicResource ButtonStyle}" Width="50" Height="25" Background="#7B7B7B"/>
+ <Button Content="娓呯┖" Click="TCPServer_ClearLogs_Click" ToolTip="娓呯┖鏃ュ織鏍�" Style="{DynamicResource ButtonStyle}" Width="50" Height="25" Background="#7B7B7B" Margin="5,0,0,0"/>
+ </StackPanel>
+
+ <ScrollViewer VerticalScrollBarVisibility="Disabled" Height="80" Margin="0,5,0,0">
+ <TextBox x:Name="TCPServer_LogsTextBox" IsReadOnly="True" TextWrapping="Wrap" FontSize="11" MaxWidth="150"/>
+ </ScrollViewer>
+ </StackPanel>
+ </ScrollViewer>
+ </TabItem>
+ </TabControl>
+
+ </Grid>
+ </Border>
+
+ <StackPanel Grid.Row="4">
+ <Label Content="鏃ュ織" HorizontalAlignment="Center" FontSize="20" FontFamily="Yu Gothic UI" Foreground="White"/>
+ </StackPanel>
+
+ <Border Grid.Row="5" BorderBrush="White" BorderThickness="2" CornerRadius="5" Background="#3C3C3C">
+ <TextBox Name="Log" VerticalScrollBarVisibility="Hidden" Foreground="Black" BorderThickness="0"/>
+ </Border>
+ </Grid>
+ </Grid>
+ </Grid>
+</Window>
diff --git a/IDViewer_2D/MainWindow.xaml.cs b/IDViewer_2D/MainWindow.xaml.cs
new file mode 100644
index 0000000..debfd97
--- /dev/null
+++ b/IDViewer_2D/MainWindow.xaml.cs
@@ -0,0 +1,3494 @@
+锘�
+using System;
+using System.Runtime.InteropServices;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Threading;
+using static SmartScanner.IDViewerDefines;
+using static SmartScanner.IDViewerSDK;
+using static SmartScanner.IDViewerSDK2;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Windows.Media.Imaging;
+using System.IO;
+using System.Runtime;
+using OpenCvSharp;
+using System.Windows.Media.Media3D;
+using System.Collections.Generic;
+using System.Threading;
+using System.Net.Sockets;
+using System.Text;
+using static System.Net.Mime.MediaTypeNames;
+using System.Net;
+using System.Threading.Tasks;
+using static OpenCvSharp.XImgProc.CvXImgProc;
+using System.Diagnostics;
+using System.Linq;
+using System.Text.RegularExpressions;
+using Newtonsoft.Json;
+using SmartScanner.ViewModel;
+using SmartScanner.OperateLog;
+using System.Windows.Input;
+using System.Timers;
+using System.Net.NetworkInformation;
+
+namespace SmartScanner
+{
+ /// <summary>
+ /// MainWindow.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ ///
+ public partial class MainWindow : System.Windows.Window
+ {
+ //璁惧鐨勫彞鏌�
+ private readonly Dictionary<int, IntPtr> _deviceHandles = new Dictionary<int, IntPtr>();
+
+ //鍥惧儚鍙ユ焺
+ private readonly Dictionary<int, IntPtr> _imagePtr = new Dictionary<int, IntPtr>();
+
+ //妯″瀷鍖归厤
+ private readonly Dictionary<int, IntPtr> _DetectorSelect = new Dictionary<int, IntPtr>();
+
+ //閫夋嫨鐨勮澶�
+ public int selectedIndex;
+
+ //璁惧缂栧彿
+ public int[] deviceIndex = new int[100];
+
+ //杩炴帴璁惧涓暟
+ int IsConnected = 0;
+
+ public IntPtr devicesListHandle;
+
+ //鑰楁椂璁$畻
+ Stopwatch stopwatch = new Stopwatch();
+
+ ModbusTCPClient modbusTCPClient = new ModbusTCPClient();
+
+ //瀹炰緥鍖杔og绫�
+ //EnhancedLogViewModel EnhancedLogViewModel.Instance = new EnhancedLogViewModel();
+
+ //璁惧淇℃伅缁撴瀯浣撳彞鏌�
+ IDDeviceInfo[] deviceInfo = new IDDeviceInfo[100];
+
+ delegate void IDViewerCallBack(IntPtr device, IntPtr image);
+ delegate void IDViewerCallBack1(IntPtr device, IntPtr image);
+
+ //妫�娴嬭繛鎺ョ姸鎬佸畾鏃跺櫒
+ private System.Threading.Timer deviceStatusTimer;
+ private int deviceStatusInterval = 3000; // 3绉�
+
+ //鍥炶皟濮旀墭
+ static IDViewerCallBack[] callbackDelegate;
+
+ IDNodeParam iDNodeParam;
+
+ //鍒涘缓妫�娴嬪櫒
+ public IntPtr detector = new IntPtr();
+ public static string filePath = ".\\detector.txt";
+ string Detector_Device = File.ReadAllText(filePath);
+
+ //淇″彿淇濇寔鏃堕棿
+ public static string holdtime = ".\\HoldTime.txt";
+ public string Hold_Time = File.ReadAllText(holdtime);
+
+ //淇″彿淇濇寔鏃堕棿
+ public static string selflockingtime = ".\\SelflockingTime.txt";
+ public string Selflocking_Time = File.ReadAllText(holdtime);
+ //string Detector_Device = "CPU";
+ //string modelPath = ".\\model\\best.onnx";
+
+ //TCP閫氳鍙傛暟
+ //private TcpListener _server;
+ //private TcpClient _client;
+ //private NetworkStream _stream;
+ private TcpServerManager _tcpServerManager;
+
+ //鍥惧儚瀛楄妭鏁扮粍
+ int batchSize = 2;
+ byte[] imgBatch1 = null;
+ byte[] imgBatch2 = null;
+
+ //杈撳嚭缁撴灉鏁扮粍
+ public bool[] outputs = new bool[20];
+ private TextBlock[] cameraAliasLabels;
+ private TextBlock[] deviceNames;
+
+ //NG鍥剧墖璺緞闆嗗悎
+ public List<string> Image_NG = new List<string>();
+
+ //瀵勫瓨鍣ㄦ帶鍒跺彉閲�
+ public int[] usOutput = new int[16];
+ public int[] usOutput2 = new int[4];
+ public bool USOUT = true;
+ public int[] usOutput_tcp;
+ //杈撳嚭妯″紡鎺у埗
+ bool IsSignleOutput = false;
+
+ //鏂规閰嶇疆鍙傛暟
+ public string json;
+ public ResultJudge.JudgmentConfiguration config = new ResultJudge.JudgmentConfiguration();
+
+ //ModBus蹇冭烦瀹氭椂鍣�
+ private System.Threading.Timer heartbeatTimer;
+ private int heartbeatInterval = 30000; // 30绉�
+
+ //Modbus閲嶈繛鍙傛暟
+ private int _reconnectAttempts = 0;//閲嶈繛灏濊瘯娆℃暟
+ private const int MAX_RECONNECT_ATTEMPTS = 5; //鏈�澶ч噸杩炲皾璇曟鏁�
+ private bool _isReconnecting = false;//鏄惁姝e湪閲嶈繛
+ private System.Threading.Timer _reconnectTimer;//閲嶈繛瀹氭椂鍣�
+ private const int RECONNECT_INTERVAL = 2000; // 閲嶈繛闂撮殧鏃堕棿(姣)
+ private string _lastIpAddress = ""; // 鏈�鍚庤繛鎺ョ殑IP鍦板潃
+ private int _lastPort = 502; // 鏈�鍚庤繛鎺ョ殑绔彛
+
+ //缁撴灉淇″彿瀹氭椂鍣�
+ private System.Timers.Timer OutputTimer;
+
+ //瀹氭湡鍒犻櫎鍥惧儚
+ private ImageCleanupService _cleanupService;
+
+ public MainWindow()
+ {
+ if (!LBProtect.ValidateFingerprint())
+ {
+ MessageBox.Show("杞欢鏈巿鏉冨湪姝ょ‖浠朵笂杩愯锛�");
+ Close();
+ return;
+ }
+ InitializeComponent();
+ DataContext = EnhancedLogViewModel.Instance;
+ // 瀹氭湡娓呭浘鏈嶅姟鍒濆鍖�
+ InitializeCleanupService();
+
+ LoadDataAsync();
+ // SDK鍒濆鍖�
+ InitSDK();
+ // 缁撴灉鏄剧ず鐣岄潰鍒濆鍖�
+ InitUI();
+ // 鐢ㄦ埛鍋忓ソ璁剧疆鍒濆鍖�
+ InitUserConfig();
+ for (int i = 0; i < outputs.Length; i++)
+ {
+ outputs[i] = false;
+ }
+ // 榛樿鍔犺浇涓婃妫�娴嬫柟妗�
+ LoadLastUsedConfiguration(true);
+ this.Closing += MainWindow_Closing;
+ // 鑾峰彇ListView涓殑ScrollViewer寮曠敤
+ // 鑾峰彇ScrollViewer寮曠敤骞朵紶閫掔粰ViewModel
+ Loaded += (sender, e) =>
+ {
+ if (FindVisualChild<ScrollViewer>(LogListView) is ScrollViewer scrollViewer)
+ {
+ EnhancedLogViewModel.Instance.LogScrollViewer = scrollViewer;
+ }
+ };
+ this.WindowState = WindowState.Maximized;
+ Loaded += (s, e) => RefreshIpButton_Click(null, null); // 鑷姩鍔犺浇IP
+ RefreshModelList(); // 鑷姩鍔犺浇妯″瀷鍒楄〃
+ RefreshDetectionPlanList(); // 鑷姩鍔犺浇妫�娴嬫柟妗堝垪琛�
+ RefreshProjectList(); // 鑷姩鍔犺浇宸ョ▼鏂囦欢鍒楄〃
+ }
+ private async void LoadDataAsync()
+ {
+ LoadingWindow loadingWindow = new LoadingWindow();
+ loadingWindow.Show();
+ await Task.Delay(2000);
+ loadingWindow.Close();
+ }
+
+ #region 鍒濆鍖�
+ //SDK鍒濆鍖�
+ private void InitSDK()
+ {
+ try
+ {
+ long result = IDVIEWER_Init_();
+ if (result != 0)
+ {
+ MessageBox.Show("SDK鍒濆鍖栧け璐ワ紝閿欒鐮侊細" + result);
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ }
+ }
+ //鐣岄潰鍒濆鍖�
+ private void InitUI()
+ {
+ cameraAliasLabels = new TextBlock[30];
+ //deviceNames = new TextBlock[30];
+ cameraAliasLabels[0] = cameraAlias0;
+ cameraAliasLabels[1] = cameraAlias1;
+ cameraAliasLabels[2] = cameraAlias2;
+ cameraAliasLabels[3] = cameraAlias3;
+ cameraAliasLabels[4] = cameraAlias4;
+ cameraAliasLabels[5] = cameraAlias5;
+ cameraAliasLabels[6] = cameraAlias6;
+ cameraAliasLabels[7] = cameraAlias7;
+ cameraAliasLabels[8] = cameraAlias8;
+ cameraAliasLabels[9] = cameraAlias9;
+ cameraAliasLabels[10] = cameraAlias10;
+ cameraAliasLabels[11] = cameraAlias11;
+ cameraAliasLabels[12] = cameraAlias12;
+ cameraAliasLabels[13] = cameraAlias13;
+ cameraAliasLabels[14] = cameraAlias14;
+ cameraAliasLabels[15] = cameraAlias15;
+ cameraAliasLabels[16] = cameraAlias16;
+ cameraAliasLabels[17] = cameraAlias17;
+ cameraAliasLabels[18] = cameraAlias18;
+ cameraAliasLabels[19] = cameraAlias19;
+ cameraAliasLabels[20] = cameraAlias20;
+ cameraAliasLabels[21] = cameraAlias21;
+ cameraAliasLabels[22] = cameraAlias22;
+ cameraAliasLabels[23] = cameraAlias23;
+ //deviceNames[0] = deviceName0;
+ //deviceNames[1] = deviceName1;
+ //deviceNames[2] = deviceName2;
+ //deviceNames[3] = deviceName3;
+ //deviceNames[4] = deviceName4;
+ //deviceNames[5] = deviceName5;
+ //deviceNames[6] = deviceName6;
+ //deviceNames[7] = deviceName7;
+ //deviceNames[8] = deviceName8;
+ //deviceNames[9] = deviceName9;
+ //deviceNames[10] = deviceName10;
+ //deviceNames[11] = deviceName11;
+ //deviceNames[12] = deviceName12;
+ //deviceNames[13] = deviceName13;
+ //deviceNames[14] = deviceName14;
+ //deviceNames[15] = deviceName15;
+ //deviceNames[16] = deviceName16;
+ //deviceNames[17] = deviceName17;
+ //deviceNames[18] = deviceName18;
+ //deviceNames[19] = deviceName19;
+ //deviceNames[20] = deviceName20;
+ //deviceNames[21] = deviceName21;
+ //deviceNames[22] = deviceName22;
+ //deviceNames[23] = deviceName23;
+ }
+ //鐢ㄦ埛閰嶇疆鍒濆鍖�
+ private void InitUserConfig()
+ {
+ DownloadData downloadData = new DownloadData();
+ downloadData.Init();
+ if (DownloadData.MemoryAlarm_main)
+ {
+ downloadData.CheckStorage();
+ }
+ IsSignleOutput = (bool)OutputCheckBox.IsChecked;
+ //TCP绔彛鍒濆鍖�
+ // 濡傛灉浠庢湭璁剧疆杩囷紝浣跨敤榛樿鍊�
+ if (string.IsNullOrEmpty(Properties.Settings.Default.DefaultPort))
+ {
+ Properties.Settings.Default.DefaultPort = "8080";
+ Properties.Settings.Default.SelectedPort = 8080;
+ }
+
+ // 纭繚绔彛鍦ㄥ悎娉曡寖鍥村唴
+ if (Properties.Settings.Default.SelectedPort < 1 ||
+ Properties.Settings.Default.SelectedPort > 65535)
+ {
+ Properties.Settings.Default.SelectedPort = 8080;
+ }
+
+ // 灏濊瘯閫変腑宸蹭繚瀛樼殑绔彛
+ foreach (ComboBoxItem item in TCPServer_PortComboBox.Items)
+ {
+ if (int.TryParse(item.Content.ToString(), out int port) &&
+ port == Properties.Settings.Default.SelectedPort)
+ {
+ TCPServer_PortComboBox.SelectedItem = item;
+ return;
+ }
+ }
+
+ // 濡傛灉淇濆瓨鐨勭鍙d笉鍦ㄩ璁惧垪琛ㄤ腑锛屾樉绀哄湪缂栬緫妗�
+ TCPServer_PortComboBox.Text = Properties.Settings.Default.SelectedPort.ToString();
+ }
+ //瀹氭湡娓呭浘鏈嶅姟鍒濆鍖�
+ private void InitializeCleanupService()
+ {
+ // 浠庤缃腑鑾峰彇鍙傛暟
+ string imageDir = Properties.Settings.Default.DataSavingRoad;
+ int retentionDays = Properties.Settings.Default.DeleteImageDays;
+ bool isEnabled = Properties.Settings.Default.ImageDeleteEnabled;
+
+ if (isEnabled && !string.IsNullOrWhiteSpace(imageDir))
+ {
+ _cleanupService = new ImageCleanupService(imageDir, retentionDays);
+ _cleanupService.Start();
+ }
+ }
+ protected override void OnClosed(EventArgs e)
+ {
+ _cleanupService?.Stop();
+ ExcelResultRecorder.FlushRecords();
+ base.OnClosed(e);
+ }
+ private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ DownloadData.isOP = false; // 绐楀彛鍏抽棴鏃舵墽琛屾搷浣�
+ // 鍙�夛細鍙栨秷鍏抽棴锛堥�氳繃 e.Cancel = true锛�
+ deviceStatusTimer?.Dispose();
+ deviceStatusTimer = null;
+
+ // 娓呯悊Modbus鐩稿叧瀹氭椂鍣�
+ heartbeatTimer?.Dispose();
+ heartbeatTimer = null;
+ _reconnectTimer?.Dispose();
+ _reconnectTimer = null;
+
+ // 鍋滄鏃ュ織鑷姩淇濆瓨鏈嶅姟
+ EnhancedLogViewModel.Instance?.StopAutoSaveService();
+
+ DisposeDetector_CPU(detector);
+ if (devicesListHandle != IntPtr.Zero)
+ {
+ long result = IDVIEWER_UnInit_(devicesListHandle);
+ }
+ //TCP绔彛閰嶇疆
+ // 楠岃瘉褰撳墠绔彛鍊�
+ if (int.TryParse(TCPServer_PortComboBox.Text, out int port) &&
+ port >= 1 && port <= 65535)
+ {
+ Properties.Settings.Default.SelectedPort = port;
+ Properties.Settings.Default.DefaultPort = port.ToString();
+ }
+ else
+ {
+ // 鎭㈠涓洪粯璁ゅ��
+ Properties.Settings.Default.SelectedPort = 8080;
+ Properties.Settings.Default.DefaultPort = "8080";
+ }
+
+ Properties.Settings.Default.Save();
+ foreach (System.Windows.Window window in System.Windows.Application.Current.Windows.OfType<DownloadData>().ToList())
+ {
+ window.Close();
+ }
+ Process.GetCurrentProcess().Kill();
+ }
+ // 褰撹缃彉鏇存椂閲嶆柊鍒濆鍖栨湇鍔�
+ private void OnSettingsChanged(object sender, EventArgs e)
+ {
+ _cleanupService?.Stop();
+ InitializeCleanupService();
+ }
+ // 杈呭姪鏂规硶锛氭煡鎵捐瑙夋爲涓殑瀛愬厓绱�
+ private static T FindVisualChild<T>(DependencyObject obj) where T : DependencyObject
+ {
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
+ {
+ DependencyObject child = VisualTreeHelper.GetChild(obj, i);
+ if (child is T result)
+ return result;
+
+ var childResult = FindVisualChild<T>(child);
+ if (childResult != null)
+ return childResult;
+ }
+ return null;
+ }
+
+ #endregion
+ #region 璁惧鍒锋柊涓庤繛鎺�
+ private async void Refresh_Btn_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ Refresh_Btn.IsEnabled = false;
+ IsConnected = 0;
+ // 鍔犺浇鐩告満杩炴帴椤哄簭鏄犲皠琛�
+ var productManager = new ProductManager();
+ var mapping = productManager.LoadConfig();
+ bool Bl = true;
+
+ if (mapping.Count == 0)
+ {
+ MessageBox.Show("鏄犲皠琛ㄤ负绌猴紝璇峰厛閰嶇疆椤哄簭鍜孖P", "鎻愮ず", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+ LoadingWindow loadingWindow = new LoadingWindow();
+ loadingWindow.Show();
+ loadingWindow.Loading.Text = "璁惧杩炴帴涓紝璇风◢鍊�";
+
+ await Task.Run(() =>
+ {
+ // 鍒锋柊鐩告満鍒楄〃
+ RefreshDeviceList();
+
+ // 鎸夌収鏄犲皠琛ㄩ『搴忚繛鎺ョ浉鏈�
+ foreach (var item in mapping.OrderBy(x => x.Key))
+ {
+ int sequence = item.Key;
+ string ip = item.Value;
+ ConnectDeviceByIP(sequence, ip);
+ }
+ Bl = false;
+ });
+ await Task.Run(() =>
+ {
+ while (true)
+ {
+ if (!Bl)
+ {
+ this.Dispatcher.Invoke(new Action(() =>
+ {
+ Refresh_Btn.IsEnabled = true;
+ }));
+ break;
+ }
+ }
+ });
+
+ loadingWindow.Close();
+ // 鍒涘缓瀹氭椂鍣紝瀹氭椂妫�娴嬭澶囪繛鎺ョ姸鎬�
+ deviceStatusTimer = new System.Threading.Timer(DeviceConnectbeatCallback, null, Timeout.Infinite, deviceStatusInterval);
+ // 鍚姩瀹氭椂鍣紝绔嬪嵆寮�濮嬪苟姣忛殧MemoryAlarmInterval姣鎵ц涓�娆�
+ deviceStatusTimer.Change(0, deviceStatusInterval);
+ GetMessage($"璁惧宸插叏閮ㄨ繛鎺ュ畬鎴怽n杩炴帴鍙版暟锛歿IsConnected}");
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"璇峰厛閰嶇疆鐩告満杩炴帴椤哄簭锛歿ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+ // 鍒锋柊鐩告満鍒楄〃
+ private void RefreshDeviceList()
+ {
+ try
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ DeviceListBox.Items.Clear();
+
+ }));
+ // 鑾峰彇璁惧鍒楄〃鍙ユ焺
+ devicesListHandle = IDVIEWER_DiscoveryDevices_(500);
+ Console.WriteLine($"鑾峰彇璁惧鍒楄〃鍙ユ焺");
+
+ // 鑾峰彇璁惧鎬绘暟
+ int deviceCount = (int)IDVIEWER_GetDevicesLength_(devicesListHandle);
+ Console.WriteLine($"鑾峰彇璁惧鎬绘暟锛歿deviceCount}");
+ Task.Run(() => GetMessage($"妫�娴嬪埌 {deviceCount} 鍙拌澶�"));
+
+ // 鑾峰彇鐩告満IP鍒楄〃
+ for (int i = 0; i < deviceCount; i++)
+ {
+ IDViewerSDK.IDVIEWER_SelectIDDeviceInfo_(devicesListHandle, ref deviceInfo[i], (uint)i);
+ string deviceIP = deviceInfo[i].cameraIP.Trim();
+
+ // 灏嗙浉鏈烘坊鍔犲埌鐣岄潰鍒楄〃
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ DeviceListBox.Items.Add(deviceIP);
+
+ }));
+
+
+ }
+
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"璁惧妫�娴嬪け璐ワ細{ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ // 閫氳繃IP杩炴帴鐩告満
+ private void ConnectDeviceByIP(int sequence, string ip)
+ {
+ IntPtr deviceHandle = IntPtr.Zero;
+ IntPtr imagePtr = IntPtr.Zero;
+ try
+ {
+ // 鍒涘缓璁惧鍙ユ焺
+ IDVIEWER_CreateDeviceByIP_(ip, ref deviceHandle);
+ if (deviceHandle == IntPtr.Zero)
+ {
+ MessageBox.Show($"鏈悳绱㈠埌璇ヨ澶�:{ip}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ // 鎵撳紑璁惧
+ IDDevice_Open(deviceHandle);
+ // 璇昏澶囧綋鍓嶅悇椤瑰弬鏁�
+ double getGain = 0.0;
+ long resultGetGain_1330 = IDDevice_GetGain_1330(deviceHandle, 0, ref getGain);
+
+ IDDeviceHarewareParams iDDeviceHarewareParams;
+ iDDeviceHarewareParams = IDDevice_GetHardWareParams(deviceHandle);
+ IDNodeParam focusingLocation1 = iDDeviceHarewareParams.exposure;
+ IDNodeParam focusingLocation2 = iDDeviceHarewareParams.gamma;
+
+ float getexposure = focusingLocation1.value;
+ float getgamma = focusingLocation2.value;
+
+ Console.WriteLine($"{sequence}鍙疯澶囧綋鍓嶆洕鍏�:{getexposure}");
+ Console.WriteLine($"{sequence}鍙疯澶囧綋鍓嶅鐩�:{getGain}");
+ Console.WriteLine($"{sequence}鍙疯澶囧綋鍓嶄冀椹�:{getgamma}");
+ Console.WriteLine($"璁惧{sequence}杩炴帴鎴愬姛");
+
+ // 妫�鏌ヨ澶囨槸鍚﹁繛鎺ユ垚鍔�
+ long isConnected = IDDevice_IsConnected(deviceHandle);
+ if (isConnected != 1)
+ {
+ MessageBox.Show($"璁惧杩炴帴澶辫触锛歿ip}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ DeviceListBox.Items.Remove(ip);
+
+ }));
+ return;
+ }
+ // 鍒濆鍖栧浘鍍忓彞鏌�
+ long result = IDImage_Init(ref imagePtr);
+ // 瀛樺偍璁惧鍜屽浘鍍忓彞鏌�
+ _deviceHandles[sequence] = deviceHandle;
+ _imagePtr[sequence] = imagePtr;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ cameraAliasLabels[sequence - 1].Text = sequence.ToString();
+ //deviceNames[sequence - 1].Text = deviceInfo[sequence - 1].cameraAlias;
+ }));
+ IsConnected++;
+ // SDK瀛樺湪BUG锛岀浉鏈鸿繛鎺ュ悗鍙栫殑鍓嶅嚑寮犲浘寮傚父锛屼复鏃惰В鍐虫柟妗�
+ // 杩炴帴鍚庡彇3寮犲浘涓㈠純
+ //for (int i = 0; i <= 3; i++)
+ //{
+ // IDDevice_CaptureImage(deviceHandle, imagePtr);
+ //}
+ Refresh_ImageParameter(deviceHandle);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"杩炴帴璁惧鏃跺嚭閿欙細{ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ DeviceListBox.Items.Remove(ip);
+
+ }));
+ }
+ }
+ static List<double> gainList = new List<double>();
+ static IDDOParamsCreate iDDOParamsCreate = new IDDOParamsCreate();
+ static IDDOParams iDDOParams = iDDOParamsCreate.create();
+ static void Refresh_ImageParameter(IntPtr device)
+ {
+ /******鑾峰彇澧炵泭******/
+ int count = 0;
+ long resultCount = IDDevice_GetGainCount(device, ref count);
+ double getAtGain = 0.0;
+ IDDevice_GetGain_1330(device, 0, ref getAtGain);
+
+ double Gain = 0.0;
+ for (int i = 0; i < count; i++)
+ {
+ IDDevice_SetGain(device, 0, i);
+ long ii = IDDevice_GetGain_1330(device, 0, ref Gain);
+ if (ii == 0)
+ {
+ gainList.Add(Gain);
+ }
+ }
+
+ double searchValue = getAtGain;
+ // 鍦� List 涓煡鎵捐澧炵泭鍊�
+ int index = gainList.IndexOf(searchValue);
+
+ if (index >= 0)
+ {
+ IDDevice_SetGain(device, 0, index);
+ }
+
+ IDDeviceHarewareParams iDDeviceHarewareParams;
+ iDDeviceHarewareParams = IDDevice_GetHardWareParams(device);
+ IDNodeParam focusingLocation = iDDeviceHarewareParams.focusingLocation;
+ IDNodeParam focusingLocation1 = iDDeviceHarewareParams.exposure;
+ IDNodeParam focusingLocation2 = iDDeviceHarewareParams.gamma;
+
+ float maxValue = focusingLocation.maxValue;
+ float CurrentValue = focusingLocation.value;
+ float getexposure = focusingLocation1.value;
+ float getgamma = focusingLocation2.value;
+
+ //娣诲姞DO鍒版柟妗堬紝鍙渶鎵ц涓�娆°��
+ for (int i = 0; i <= 2; i++)
+ {
+ iDDOParams.pin = (uint)i;
+ iDDOParams.status = 0;
+ iDDOParams.doModel = 0;
+ iDDOParams.durationTime = 2000;
+ iDDOParams.doSource = IDDoEventSource.EVENT_SOURCE_OFF_C;
+ long retm8 = addDOParam(device, ref iDDOParams);
+ Console.WriteLine("褰撳墠娣诲姞绗�" + i + "缁勶紝ret锛�" + retm8);
+ }
+
+ /******灏嗚幏鍙栫殑鍙傛暟璁剧疆涓�娆�******/
+ //double getexposure1 = getexposure;
+ //double getgamma1 = getgamma;
+ //int CurrentValue1 = (int)CurrentValue;
+
+ //long g1 = IDDevice_SetExposure(device, 0, getexposure1);
+ //long g3 = IDDevice_SetGamma(device, 0, getgamma1);
+ //long g4 = IDDevice_SetFocusLocation(device, 0, CurrentValue1);
+ }
+ #endregion
+ #region 璁惧淇℃伅鏄剧ず
+ private void DeviceListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (DeviceListBox.SelectedIndex != -1)
+ {
+ CameraIP.Text = deviceInfo[DeviceListBox.SelectedIndex].cameraIP.Trim();
+ CameraNetMask.Text = deviceInfo[DeviceListBox.SelectedIndex].cameraNetMask.Trim();
+ CameraGateWay.Text = deviceInfo[DeviceListBox.SelectedIndex].cameraGateWay.Trim();
+ CameraFirmwareVersion.Text = deviceInfo[DeviceListBox.SelectedIndex].cameraFirmwareVersion.Trim();
+ CameraAlias.Text = deviceInfo[DeviceListBox.SelectedIndex].cameraAlias;
+ CameraModel.Text = deviceInfo[DeviceListBox.SelectedIndex].cameraModel.Trim();
+ }
+ else { return; }
+ }
+ #endregion
+ #region 鏃ュ織鏄剧ず
+ //鏃ュ織鏄剧ず
+ private void GetMessage(string obj)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Log.AppendText(obj + Environment.NewLine);
+ Log.ScrollToEnd();
+ }));
+ }
+ //ModBus鏃ュ織鏄剧ず
+ private void GetMessage_Modbus(string obj)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Client_LogsTextBox.AppendText(obj + Environment.NewLine);
+ Client_LogsTextBox.ScrollToEnd();
+ }));
+ }
+ #endregion
+ //娣卞害瀛︿範妯″瀷鎺ㄧ悊妯″潡
+ private void Reasoning_AI(IntPtr detector, byte[] ImageBath, int Image_Width, int Image_Height, out int[] classIds, out int[] numBoxes, out float[] prob,
+ out float[] x1, out float[] y1, out float[] x2, out float[] y2, int sequence)
+ {
+ // 鍒濆鍖栬緭鍑哄弬鏁�
+ batchSize = 1;
+ x1 = new float[100];
+ y1 = new float[100];
+ x2 = new float[100];
+ y2 = new float[100];
+ prob = new float[100];
+ classIds = new int[100];
+ numBoxes = new int[batchSize];
+
+ try
+ {
+ // 妫�鏌� detector 鎸囬拡鏄惁鏈夋晥
+ if (detector == IntPtr.Zero)
+ {
+ throw new ArgumentNullException(nameof(detector), "Detector pointer is null (IntPtr.Zero)");
+ }
+ // 妫�鏌� ImageBath 鏄惁涓虹┖鎴栧ぇ灏忎笉姝g‘
+ if (ImageBath == null || ImageBath.Length == 0)
+ {
+ throw new ArgumentException("Image batch data is null or empty", nameof(ImageBath));
+ }
+ // 妫�鏌ュ浘鍍忓昂瀵告槸鍚﹀悎鐞�
+ if (Image_Width <= 0 || Image_Height <= 0)
+ {
+ throw new ArgumentException($"Invalid image dimensions: Width={Image_Width}, Height={Image_Height}");
+ }
+ // 妫�鏌� batchSize 鏄惁鍚堢悊
+ if (batchSize <= 0)
+ {
+ throw new InvalidOperationException($"Invalid batch size: {batchSize}");
+ }
+ // 妫�鏌ヨ緭鍑虹紦鍐插尯鏄惁瓒冲澶�
+ if (x1.Length < 100 || y1.Length < 100 || x2.Length < 100 || y2.Length < 100 || prob.Length < 100 || classIds.Length < 100)
+ {
+ throw new InvalidOperationException("Output buffer size is too small (must be at least 100)");
+ }
+ // 璋冪敤 C++ API
+ PredictDetector_CPU(
+ detector,
+ ImageBath,
+ x1, y1, x2, y2,
+ prob,
+ classIds,
+ numBoxes,
+ 100,
+ Image_Width,
+ Image_Height,
+ batchSize,
+ 0.25f,
+ 0.3f,
+ 1,
+ sequence
+ );
+ }
+ catch (SEHException ex)
+ {
+ // 璁板綍璇︾粏鐨勯敊璇俊鎭�
+ Console.Error.WriteLine($"SEHException in PredictDetector_CPU: {ex.Message}");
+ Console.Error.WriteLine($"Detector: {detector}");
+ Console.Error.WriteLine($"ImageBatch Length: {ImageBath?.Length ?? 0}");
+ Console.Error.WriteLine($"Image Size: {Image_Width}x{Image_Height}");
+ Console.Error.WriteLine($"Batch Size: {batchSize}");
+
+ // 鍙互閫夋嫨閲嶆柊鎶涘嚭鎴栬繑鍥為粯璁ゅ��
+ throw new InvalidOperationException("Failed to run AI reasoning due to native code error", ex);
+ }
+ catch (Exception ex)
+ {
+ Console.Error.WriteLine($"Error in Reasoning_AI: {ex.Message}");
+ throw;
+ }
+ }
+
+
+ // 娴嬭瘯鏂规硶
+ private void Start_Detector_Btn_Click(object sender, RoutedEventArgs e)
+ {
+ string images_path = "D:\\01 LBImage\\20241010\\10_59_24_2.bmp";
+ Mat mat = Cv2.ImRead(images_path);
+ int width = mat.Width;
+ int height = mat.Height;
+ int channel = mat.Channels();
+ byte[] imgBatch = new byte[width * height * channel];
+ int batchSize = 1;
+ float[] x1 = new float[1000], y1 = new float[1000], x2 = new float[1000], y2 = new float[1000];
+ float[] prob = new float[1000];
+ int[] classIds = new int[1000];
+ int[] numBoxes = new int[batchSize];
+ Marshal.Copy(mat.Data, imgBatch, 0, imgBatch.Length);
+ PredictDetector_CPU(detector, imgBatch, x1, y1, x2, y2, prob, classIds, numBoxes, 100, width, height, batchSize, 0.25f, 0.3f, 1, 1);
+ for (int i = 0; i < batchSize; i++)
+ {
+ for (int j = 0; j < numBoxes[i]; j++)
+ {
+ float x1Val = x1[j];
+ float y1Val = y1[j];
+ float x2Val = x2[j];
+ float y2Val = y2[j];
+ float probVal = prob[j];
+ int classId = classIds[j];
+ }
+ }
+ }
+
+ #region ModBus閫氳璁剧疆涓庢娴嬫ā鍧�
+ #region 鍔犺浇绔彛
+ private void LoadPorts()
+ {
+ //Server_PortComboBox.ItemsSource = new[] { "8000", "8001", "8002" };
+ //Client_PortComboBox.ItemsSource = new[] { "8000", "8001", "8002" };
+ Client_PortComboBox.ItemsSource = new[] { "502" };
+ }
+ #endregion
+ #region ModBus閫氳妯″潡
+ private void Client_Connect_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ if (Client_ServerIpComboBox.Text != "" && Client_PortComboBox.SelectedItem != null)
+ {
+ string ipAddress = Client_ServerIpComboBox.Text;
+ int port = int.Parse(Client_PortComboBox.Text);
+
+ // 淇濆瓨杩炴帴淇℃伅鐢ㄤ簬閲嶈繛
+ _lastIpAddress = ipAddress;
+ _lastPort = port;
+
+ modbusTCPClient.ModbudTCP_Connect(ipAddress, port);
+ if (modbusTCPClient._client == null)
+ {
+ //MessageBox.Show("杩炴帴鍒版湇鍔″櫒澶辫触锛岃妫�鏌ヨ繛鎺ュ悗閲嶈瘯");
+ return;
+ }
+
+ // 鍒濆鍖栭噸杩炲畾鏃跺櫒
+ InitializeReconnectTimer();
+
+ // 鍒涘缓瀹氭椂鍣紝浣滀负ModBus蹇冭烦淇″彿
+ heartbeatTimer = new System.Threading.Timer(HeartbeatCallback, null, Timeout.Infinite, heartbeatInterval);
+ // 鍚姩瀹氭椂鍣紝绔嬪嵆寮�濮嬪苟姣忛殧heartbeatInterval姣鎵ц涓�娆�
+ heartbeatTimer.Change(0, heartbeatInterval);
+ // 寮�濮嬩睛鍚鎴风瑙﹀彂淇″彿
+ Task.Run(() => ClientListen());
+ GetMessage_Modbus($"杩炴帴鎴愬姛 {ipAddress}:{port}\n");
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ LinkState.Text = "ModBus宸茶繛鎺�";
+ LinkState.Foreground = System.Windows.Media.Brushes.LightGreen;
+ }));
+ }
+ else
+ {
+ MessageBox.Show("璇疯緭鍏ユ纭殑IP鍜岀鍙�");
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ LinkState.Text = "鏈繛鎺�";
+ LinkState.Foreground = System.Windows.Media.Brushes.Red;
+ }));
+ return;
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("鍦板潃鍜岀鍙e凡琚崰鐢�");
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ LinkState.Text = "鏈繛鎺�";
+ LinkState.Foreground = System.Windows.Media.Brushes.Red;
+ }));
+ return;
+ }
+ }
+ //ModBus鏂紑杩炴帴
+ private void Client_Disconnect_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ // 鍋滄鎵�鏈夊畾鏃跺櫒
+ heartbeatTimer?.Change(Timeout.Infinite, Timeout.Infinite);
+ _reconnectTimer?.Change(Timeout.Infinite, Timeout.Infinite);
+
+ if (modbusTCPClient._client != null && modbusTCPClient._client.Connected)
+ {
+ modbusTCPClient._client?.Close();
+ modbusTCPClient._client = null;
+ GetMessage_Modbus("杩炴帴宸叉柇寮�\n");
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ LinkState.Text = "鏈繛鎺�";
+ LinkState.Foreground = System.Windows.Media.Brushes.Red;
+ }));
+ }
+
+ // 閲嶇疆閲嶈繛鐘舵��
+ _reconnectAttempts = 0;
+ _isReconnecting = false;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("杩炴帴鏂紑");
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ LinkState.Text = "鏈繛鎺�";
+ LinkState.Foreground = System.Windows.Media.Brushes.Red;
+ }));
+ }
+ }
+
+ private void Client_ClearClientLogs_Click(object sender, RoutedEventArgs e)
+ {
+ Client_LogsTextBox.Clear();
+ }
+ #endregion
+ #region 鍥惧儚閲囬泦涓庡鐞嗘ā鍧�
+ //鑾峰彇鍥惧儚骞跺鐞�
+ private void GetImage()
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ DetectState.Text = "姝e湪妫�娴嬩腑銆傘�傘��";
+ DetectState.Foreground = System.Windows.Media.Brushes.LightGreen;
+ }));
+ //璁℃椂鍣ㄥ惎鍔�
+ stopwatch.Reset();
+ stopwatch.Start();
+ Console.WriteLine($"璁℃椂鍣ㄥ惎鍔�!");
+ //鍔犺浇涓婃瑙e喅鏂规
+ bool isL = LoadLastUsedConfiguration(false);
+ if (!isL)
+ {
+ stopwatch.Stop();
+ long F_elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
+ Console.WriteLine($"绯荤粺鍝嶅簲鏃堕棿涓猴細{F_elapsedMilliseconds}ms");
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ DetectState.Text = "鏈湪妫�娴�";
+ DetectState.Foreground = System.Windows.Media.Brushes.Red;
+ }));
+ return;
+ }
+ for (int i = 0; i < DeviceListBox.Items.Count; i++)
+ {
+ //閲囬泦鍥惧儚
+ GetIDDevice_CaptureImage(i + 1);
+ }
+ for (int i = 0; i < DeviceListBox.Items.Count; i++)
+ {
+ //澶勭悊鍥惧儚
+ Reasoning_Image(i + 1);
+ }
+ stopwatch.Stop();
+ long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
+ Console.WriteLine($"绯荤粺鍝嶅簲鏃堕棿涓猴細{elapsedMilliseconds}ms");
+ EnhancedLogViewModel.Instance.AddLog($"绯荤粺鍝嶅簲鏃堕棿涓猴細{elapsedMilliseconds}ms");
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ DetectState.Text = "鏈湪妫�娴�";
+ DetectState.Foreground = System.Windows.Media.Brushes.Red;
+ }));
+ //NG鍥惧儚寮圭獥鏄剧ず涓庝繚瀛�
+ if (Image_NG.Count != 0)
+ {
+ Task.Run(() =>
+ {
+ List<string> Image_NG_Save = new List<string>(Image_NG);
+
+ // NG鍥惧儚寮圭獥鏄剧ず
+ OnDetectionCompleted(Image_NG);
+ // NG鍥惧儚鑷姩淇濆瓨
+ int savedCount = AutoSaveNGImages(Image_NG_Save);
+ EnhancedLogViewModel.Instance.AddLog($"鎴愬姛淇濆瓨浜� {savedCount} 寮燦G鍥剧墖");
+ Image_NG_Save.Clear();
+ });
+
+ }
+
+ //妫�娴嬬粨鏋滈�氳繃ModBus瀛樺叆瀵勫瓨鍣�
+ try
+ {
+ if (modbusTCPClient._client != null)
+ {
+ if (!IsSignleOutput)
+ {
+ // 灏嗕簩杩涘埗鏁扮粍杞崲涓簎short
+ ushort value = BinaryToUshort_MSBFirst(usOutput);//1鍙�-16鍙风浉鏈�
+ ushort value2 = BinaryToUshort_MSBFirst(usOutput2);//17-20鍙风浉鏈�
+ // 灏唘short瀛樺偍鍦╱short鏁扮粍涓�
+ ushort[] test = new ushort[] { value };
+ ushort[] test2 = new ushort[] { value2 };
+ modbusTCPClient.MultipleRegistersWrite(3, test);//1鍙�-16鍙风浉鏈�
+ modbusTCPClient.MultipleRegistersWrite(4, test2);//17-20鍙风浉鏈�
+ EnhancedLogViewModel.Instance.AddLog($"妫�娴嬬粨鏋滀繚鎸亄Hold_Time}绉�");
+ if (double.TryParse(Hold_Time, out double interval))
+ {
+ OutputTimer = new System.Timers.Timer(interval * 1000);
+ }
+ else
+ {
+ MessageBox.Show("淇濇寔鏃堕棿鏍煎紡閿欒锛岃妫�鏌ラ厤缃�", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ OutputTimer.Elapsed += OnTimedEvent;
+ OutputTimer.AutoReset = false; // 璁剧疆涓篺alse琛ㄧず鍙Е鍙戜竴娆�
+ OutputTimer.Start();
+ }
+ else
+ {
+ if (USOUT)
+ {
+ modbusTCPClient.MultipleRegistersWrite(3, new ushort[] { 1 });
+ EnhancedLogViewModel.Instance.AddLog($"妫�娴嬬粨鏋滀繚鎸�5绉�");
+ OutputTimer = new System.Timers.Timer(5000);
+ OutputTimer.Elapsed += OnTimedEvent;
+ OutputTimer.AutoReset = false; // 璁剧疆涓篺alse琛ㄧず鍙Е鍙戜竴娆�
+ OutputTimer.Start();
+ }
+ else
+ {
+ modbusTCPClient.MultipleRegistersWrite(3, new ushort[] { 0 });
+ }
+
+ }
+ }
+ else if (TcpServerManager._isRunning)
+ {
+ //usOutput_tcp
+ }
+ else
+ {
+ // 鑾峰彇褰撳墠鏃ユ湡
+ DateTime currentDate = DateTime.Now;
+ // 鏍煎紡鍖栨椂闂翠负 "HHmmss"
+ string timeFileName = currentDate.ToString("HH:mm:ss");
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ LinkState.Text = "鏈繛鎺�";
+ LinkState.Foreground = System.Windows.Media.Brushes.Red;
+ }));
+ //MessageBox.Show($"ModBus鏈繛鎺�", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ GetMessage_Modbus($"{timeFileName} ModBus鏈繛鎺�");
+ }
+ USOUT = true;
+ }
+ catch (NullReferenceException ex)
+ {
+ MessageBox.Show($"ModBus鏈繛鎺ワ細{ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ USOUT = true;
+ }
+ private ImageDisplayWindow _imageDisplayWindow;
+
+ //NG鍥惧儚寮圭獥鏄剧ず
+ private void OnDetectionCompleted(List<string> imagePath)
+ {
+ if (imagePath.Count != 0)
+ {
+ // 浣跨敤Dispatcher纭繚UI绾跨▼鎿嶄綔
+ Dispatcher.Invoke(() =>
+ {
+ // 妫�鏌ョ獥鍙f槸鍚﹀凡瀛樺湪
+ if (_imageDisplayWindow == null || !_imageDisplayWindow.IsLoaded)
+ {
+ _imageDisplayWindow = new ImageDisplayWindow();
+ _imageDisplayWindow.Closed += (s, e) => { _imageDisplayWindow = null; };
+ _imageDisplayWindow.Show();
+ _imageDisplayWindow.Topmost = true;
+ }
+
+ // 娣诲姞鍥剧墖鍒版煡鐪嬪櫒
+ _imageDisplayWindow.AddImage(imagePath);
+ });
+ Image_NG.Clear();
+ }
+ }
+ //鍥惧儚澶勭悊
+ private void Reasoning_Image(int Sequence)
+ {
+ IntPtr deviceHandle = _deviceHandles[Sequence];
+ IntPtr imagePtr = _imagePtr[Sequence];
+
+ int[] classIds; //鐩爣鐗╃被鍒�
+ int[] numBoxes; //鐩爣鐗╂暟閲�
+ float[] prob; //鐩爣鐗╁緱鍒�
+ float[] x1 = new float[100], y1 = new float[100], x2 = new float[100], y2 = new float[100];
+ if (imagePtr == IntPtr.Zero)
+ {
+ GetMessage($"璁惧{Sequence}杩炴帴宸叉柇寮�");
+ EnhancedLogViewModel.Instance.AddLog($"璁惧{Sequence}杩炴帴宸叉柇寮�", "ERROR");
+ return;
+ }
+ long Image_Width = IDImage_Width(imagePtr);
+ long Image_Height = IDImage_Height(imagePtr);
+ long Image_Channels = IDImage_Channels(imagePtr);
+ long dataLength = Image_Width * Image_Height * Image_Channels;
+ byte[] Imagedata = new byte[dataLength];
+ byte[] bytes = new byte[Image_Width * Image_Height * 3];
+ IntPtr Image_ImageData = IDImage_ImageData(imagePtr);
+
+ if (imagePtr == IntPtr.Zero)
+ {
+ MessageBox.Show("鍥惧儚鍙ユ焺鏃犳晥");
+ }
+ if (dataLength != 0)
+ {
+ Console.WriteLine($"鑾峰彇鏃ユ湡");
+ // 鑾峰彇褰撳墠鏃ユ湡
+ DateTime currentDate = DateTime.Now;
+
+ // 鏍煎紡鍖栨棩鏈熶负 "yyyyMMdd"
+ string datePath = currentDate.ToString("yyyyMMdd");
+
+ // 鏍煎紡鍖栨椂闂翠负 "HHmmss"
+ string timeFileName = currentDate.ToString("HH_mm_ss");
+
+ // 鏋勫缓瀹屾暣璺緞
+ string folderPath = $@"{DownloadData.ImageSavingPath}\{datePath}";
+ string filePath = Path.Combine(folderPath, $"{timeFileName + "_" + Sequence + DownloadData.ImageFormat_main}");
+
+ // 妫�鏌ユ枃浠跺す鏄惁瀛樺湪锛屽鏋滀笉瀛樺湪鍒欏垱寤�
+ if (!Directory.Exists(folderPath))
+ {
+ Directory.CreateDirectory(folderPath);
+ }
+ Console.WriteLine($"鍥惧儚鍙ユ焺杞崲涓哄瓧鑺傛暟鎹�");
+ Marshal.Copy(Image_ImageData, Imagedata, 0, (int)dataLength); //鍥惧儚鍙ユ焺杞崲涓哄瓧鑺傛暟鎹�
+ ConvertSingletoThreeChannels(detector, Imagedata, (int)Image_Width, (int)Image_Height, bytes);
+ //鍘熷浘淇濆瓨鑷虫湰鍦�
+ if (DownloadData.ImageSave)
+ {
+ IDImage_SaveImage(imagePtr, filePath, DownloadData.ImageCompressionRatio_main);
+ EnhancedLogViewModel.Instance.AddLog($"璁惧{Sequence}鍥惧儚宸蹭繚瀛樿嚦{filePath}");
+ }
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛歿Sequence}鍙疯澶囧浘鍍忛澶勭悊瀹屾垚锛屽紑濮嬭繘琛岀畻娉曟帹鐞�");
+ //娣卞害瀛︿範鎺ㄧ悊妯″瀷
+ Reasoning_AI(detector, bytes, (int)Image_Width, (int)Image_Height, out classIds, out numBoxes, out prob, out x1, out y1, out x2, out y2, Sequence);
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛歿Sequence}鍙疯澶囩畻娉曟帹鐞嗗畬鎴愶紝寮�濮嬭繘琛岀粨鏋滃垽鏂�");
+ //缁撴灉鍒ゆ柇
+ switch (Sequence)
+ {
+ case 1:
+ int isPass1 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass1;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass1;
+
+ if (isPass1 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result0.Content = "OK";
+ finall_result0.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result0.Content = "NG";
+ finall_result0.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 2:
+ int isPass2 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass2;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass2;
+ if (isPass2 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result1.Content = "OK";
+ finall_result1.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result1.Content = "NG";
+ finall_result1.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 3:
+ int isPass3 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass3;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass3;
+ if (isPass3 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result2.Content = "OK";
+ finall_result2.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result2.Content = "NG";
+ finall_result2.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 4:
+ int isPass4 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass4;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass4;
+ if (isPass4 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result3.Content = "OK";
+ finall_result3.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result3.Content = "NG";
+ finall_result3.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 5:
+ int isPass5 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass5;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass5;
+ if (isPass5 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result4.Content = "OK";
+ finall_result4.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result4.Content = "NG";
+ finall_result4.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 6:
+ int isPass6 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass6;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass6;
+ if (isPass6 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result5.Content = "OK";
+ finall_result5.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ //Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result5.Content = "NG";
+ finall_result5.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 7:
+ int isPass7 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass7;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass7;
+ if (isPass7 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result6.Content = "OK";
+ finall_result6.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ //Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result6.Content = "NG";
+ finall_result6.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 8:
+ int isPass8 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass8;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass8;
+ if (isPass8 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result7.Content = "OK";
+ finall_result7.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ //Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result7.Content = "NG";
+ finall_result7.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 9:
+ int isPass9 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass9;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass9;
+ if (isPass9 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result8.Content = "OK";
+ finall_result8.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ //Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result8.Content = "NG";
+ finall_result8.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 10:
+ int isPass10 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass10;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass10;
+ if (isPass10 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result9.Content = "OK";
+ finall_result9.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ //Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result9.Content = "NG";
+ finall_result9.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 11:
+ int isPass11 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass11;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass11;
+ if (isPass11 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result10.Content = "OK";
+ finall_result10.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ //Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result10.Content = "NG";
+ finall_result10.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 12:
+ int isPass12 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass12;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass12;
+ if (isPass12 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result11.Content = "OK";
+ finall_result11.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ //Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result11.Content = "NG";
+ finall_result11.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 13:
+ int isPass13 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass13;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass13;
+ if (isPass13 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result12.Content = "OK";
+ finall_result12.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result12.Content = "NG";
+ finall_result12.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 14:
+ int isPass14 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass14;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass14;
+ if (isPass14 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result13.Content = "OK";
+ finall_result13.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result13.Content = "NG";
+ finall_result13.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 15:
+ int isPass15 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass15;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass15;
+ if (isPass15 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result14.Content = "OK";
+ finall_result14.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result14.Content = "NG";
+ finall_result14.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 16:
+ int isPass16 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput[Sequence - 1] = isPass16;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass16;
+ if (isPass16 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result15.Content = "OK";
+ finall_result15.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result15.Content = "NG";
+ finall_result15.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 17:
+ int isPass17 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput2[Sequence - 17] = isPass17;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass17;
+ if (isPass17 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result16.Content = "OK";
+ finall_result16.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result16.Content = "NG";
+ finall_result16.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 18:
+ int isPass18 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput2[Sequence - 17] = isPass18;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass18;
+ if (isPass18 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result17.Content = "OK";
+ finall_result17.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result17.Content = "NG";
+ finall_result17.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 19:
+ int isPass19 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput2[Sequence - 17] = isPass19;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass19;
+ if (isPass19 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result18.Content = "OK";
+ finall_result18.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result18.Content = "NG";
+ finall_result18.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ case 20:
+ int isPass20 = config.JudgeDetectionResult(Sequence, numBoxes, classIds, prob);
+ usOutput2[Sequence - 17] = isPass20;
+ if (TcpServerManager._isRunning && usOutput_tcp != null) usOutput_tcp[Sequence - 1] = isPass20;
+ if (isPass20 == 1)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result19.Content = "OK";
+ finall_result19.Background = System.Windows.Media.Brushes.Green;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬮�氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬮�氳繃");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "OK");
+ });
+ }
+ else
+ {
+ USOUT = false;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result19.Content = "NG";
+ finall_result19.Background = System.Windows.Media.Brushes.Red;
+ }));
+ Console.WriteLine($"鐐逛綅 {Sequence} 妫�娴嬩笉閫氳繃");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氱偣浣� {Sequence} 妫�娴嬩笉閫氳繃", "ERROR");
+ Image_NG.Add($".\\vino_res\\result_{Sequence}.jpg");
+ Task.Run(() =>
+ {
+ // 璁板綍鍒癊xcel锛堟壒閲忓啓鍏ワ級
+ ExcelResultRecorder.RecordDetectionResult(Sequence, "NG");
+ });
+ }
+ break;
+ }
+ }
+ }
+ //鍥惧儚閲囬泦
+ private void GetIDDevice_CaptureImage(int Sequence)
+ {
+ IntPtr deviceHandle = _deviceHandles[Sequence];
+ IntPtr imagePtr = _imagePtr[Sequence];
+
+ // 寮�濮嬮噰闆嗗浘鍍�
+ Console.WriteLine($"{Sequence}鍙疯澶囧紑濮嬮噰闆嗗浘鍍�");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛歿Sequence}鍙疯澶囧紑濮嬮噰闆嗗浘鍍�");
+ long rel = IDDevice_IsOpen(deviceHandle);
+ if (rel == 0)
+ {
+ MessageBox.Show($"璁惧{Sequence}杩炴帴宸叉柇寮�", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ EnhancedLogViewModel.Instance.AddLog($"璁惧{Sequence}杩炴帴宸叉柇寮�", "ERROR");
+ _imagePtr[Sequence] = IntPtr.Zero;
+ return;
+ }
+
+ IDDevice_CaptureImage(deviceHandle, imagePtr);
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛歿Sequence}鍙疯澶囧浘鍍忛噰闆嗙粨鏉燂紝寮�濮嬭繘琛屽浘鍍忛澶勭悊");
+ }
+ #endregion
+ // 鏁版嵁杞崲
+ static ushort BinaryToUshort_MSBFirst(int[] binaryArray)
+ {
+ if (binaryArray.Length > 16)
+ throw new ArgumentException("Binary array cannot exceed 16 bits.");
+
+ ushort result = 0;
+ for (int i = 0; i < binaryArray.Length; i++)
+ {
+ if (binaryArray[i] == 1)
+ result |= (ushort)(1 << i); // 浣庝綅鍦ㄥ墠
+ else if (binaryArray[i] != 0)
+ throw new ArgumentException("Binary array can only contain 0s and 1s.");
+ }
+ return result;
+ }
+ /// <summary>
+ /// 鑷姩淇濆瓨NG鍥剧墖鍒版寚瀹氭棩鏈熺洰褰�
+ /// 淇濆瓨璺緞鏍煎紡锛欴:\01 LBImage_NG\(褰撳墠鏃ユ湡)\
+ /// 濡傛灉鐩綍涓嶅瓨鍦ㄤ細鑷姩鍒涘缓锛屾敮鎸佹壒閲忎繚瀛樻搷浣�
+ /// </summary>
+ /// <param name="ngImagePaths">NG鍥剧墖璺緞闆嗗悎</param>
+ /// <returns>鎴愬姛淇濆瓨鐨勫浘鐗囨暟閲�</returns>
+ public int AutoSaveNGImages(List<string> ngImagePaths)
+ {
+ // 鏍¢獙杈撳叆鍙傛暟
+ if (ngImagePaths == null || ngImagePaths.Count == 0)
+ {
+ EnhancedLogViewModel.Instance.AddLog($"NG鍥剧墖璺緞闆嗗悎涓虹┖锛屾棤闇�淇濆瓨鎿嶄綔銆�");
+ return 0;
+ }
+
+ int successCount = 0; // 鎴愬姛淇濆瓨鐨勮鏁板櫒
+ string baseDirectory = @"D:\01 LBImage_NG"; // 鍩虹淇濆瓨鐩綍
+
+ try
+ {
+ // 鑾峰彇褰撳墠绯荤粺鏃ユ湡锛屾牸寮忓寲涓簓yyyMMdd
+ string dateFolderName = DateTime.Now.ToString("yyyyMMdd");
+
+ // 鏋勫缓瀹屾暣鐨勭洰鏍囩洰褰曡矾寰�
+ string targetDirectory = Path.Combine(baseDirectory, dateFolderName);
+
+ // 濡傛灉鐩爣鐩綍涓嶅瓨鍦紝鍒欏垱寤�
+ if (!Directory.Exists(targetDirectory))
+ {
+ Directory.CreateDirectory(targetDirectory);
+ }
+
+ // 閬嶅巻鎵�鏈塏G鍥剧墖璺緞
+ foreach (string sourcePath in ngImagePaths)
+ {
+ try
+ {
+ // 妫�鏌ユ簮鏂囦欢鏄惁瀛樺湪
+ if (!File.Exists(sourcePath))
+ {
+ Console.WriteLine($"鏂囦欢涓嶅瓨鍦紝璺宠繃: {sourcePath}");
+ continue;
+ }
+
+ // 鑾峰彇鏂囦欢鍚嶏紙鍖呭惈鎵╁睍鍚嶏級
+ string fileName = Path.GetFileName(sourcePath);
+
+ // 鏋勫缓鐩爣鏂囦欢瀹屾暣璺緞
+ string destinationPath = Path.Combine(targetDirectory, fileName);
+
+ // 濡傛灉鐩爣鏂囦欢宸插瓨鍦紝娣诲姞鏃堕棿鎴抽伩鍏嶈鐩�
+ if (File.Exists(destinationPath))
+ {
+ string timeStamp = DateTime.Now.ToString("HHmmss");
+ string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
+ string extension = Path.GetExtension(fileName);
+ fileName = $"{fileNameWithoutExtension}_{timeStamp}{extension}";
+ destinationPath = Path.Combine(targetDirectory, fileName);
+ }
+
+ // 澶嶅埗鏂囦欢鍒扮洰鏍囩洰褰�
+ File.Copy(sourcePath, destinationPath, true);
+ successCount++;
+
+ Console.WriteLine($"鎴愬姛淇濆瓨: {sourcePath} -> {destinationPath}");
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"淇濆瓨鏂囦欢澶辫触 {sourcePath}: {ex.Message}");
+ }
+ }
+
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"淇濆瓨杩囩▼涓彂鐢熼敊璇�: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+
+ return successCount;
+ }
+ //榛樿鍔犺浇涓婃妫�娴嬫柟妗�
+ public bool LoadLastUsedConfiguration(bool bl)
+ {
+ bool isLoad = true;
+ try
+ {
+ if (!string.IsNullOrEmpty(ResultJudge.AppSettings.LastConfigFilePath_Proj) && File.Exists(ResultJudge.AppSettings.LastConfigFilePath_Proj))
+ {
+ bool isLoadModel;
+ //json = File.ReadAllText(ResultJudge.AppSettings.LastConfigFilePath);
+ var (modelName, configPath, configContent, message) = LBProjService.LoadLBProj(ResultJudge.AppSettings.LastConfigFilePath_Proj);
+ config = JsonConvert.DeserializeObject<ResultJudge.JudgmentConfiguration>(configContent);
+
+ if (bl)
+ {
+ if (detector != IntPtr.Zero)
+ {
+ DisposeDetector_CPU(detector);
+ }
+ Task.Run(() =>
+ {
+ // 妯″瀷鎺ㄧ悊寮曟搸閫夋嫨
+ detector = CreateDetector_CPU();
+ isLoadModel = InitializeDetector_CPU(detector, Detector_Device, $".\\model\\{modelName}");
+ while (true)
+ {
+ if (isLoadModel)
+ {
+ EnhancedLogViewModel.Instance.AddLog($"妯″瀷缂栬瘧鎴愬姛");
+ break;
+ }
+ }
+ });
+ MessageBox.Show($"宸茶嚜鍔ㄥ姞杞戒笂娆′娇鐢ㄧ殑宸ョ▼鏂囦欢: {ResultJudge.AppSettings.LastConfigFilePath_Proj}",
+ "鎴愬姛", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ ProjectState.Foreground = System.Windows.Media.Brushes.LightGreen;
+ ModelState.Foreground = System.Windows.Media.Brushes.LightGreen;
+ ProjectState.Text = ResultJudge.AppSettings.LastConfigFilePath_Proj;
+ ModelState.Text = modelName;
+ }));
+ EnhancedLogViewModel.Instance.AddLog($"褰撳墠宸ョ▼鏂囦欢: {ResultJudge.AppSettings.LastConfigFilePath_Proj}锛屾ā鍨嬶細{modelName}");
+ isLoad = true;
+ }
+ else
+ {
+ if (!string.IsNullOrEmpty(ResultJudge.AppSettings.LastConfigFilePath) && File.Exists(ResultJudge.AppSettings.LastConfigFilePath))
+ {
+ json = File.ReadAllText(ResultJudge.AppSettings.LastConfigFilePath);
+ config = JsonConvert.DeserializeObject<ResultJudge.JudgmentConfiguration>(json);
+ if (bl)
+ {
+ MessageBox.Show($"宸茶嚜鍔ㄥ姞杞戒笂娆′娇鐢ㄧ殑妫�娴嬫柟妗�: {ResultJudge.AppSettings.LastConfigFilePath}",
+ "鎴愬姛", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ EnhancedLogViewModel.Instance.AddLog($"褰撳墠妫�娴嬫柟妗�: {ResultJudge.AppSettings.LastConfigFilePath}");
+ isLoad = true;
+ }
+ else
+ {
+ MessageBox.Show("娌℃湁鎵惧埌涓婃浣跨敤鐨勬娴嬫柟妗堬紝璇锋墜鍔ㄥ姞杞�",
+ "鎻愮ず", MessageBoxButton.OK, MessageBoxImage.Information);
+ EnhancedLogViewModel.Instance.AddLog($"娌℃湁鎵惧埌涓婃浣跨敤鐨勬娴嬫柟妗堬紝璇锋墜鍔ㄥ姞杞�", "WARN");
+ isLoad = false;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ isLoad = false;
+ MessageBox.Show($"鑷姩鍔犺浇宸ョ▼鏃跺嚭閿欙紝璇锋墜鍔ㄥ姞杞�: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ return isLoad;
+ }
+ #endregion
+ #region Modbus Tcp閫氳璁剧疆
+ //璁板綍鏈�鍚庝竴娆¤Е鍙戞椂闂�
+ private DateTime _lastTriggerTime = DateTime.MinValue;
+ //瑙﹀彂淇″彿鐩戝惉
+ private void ClientListen()
+ {
+ try
+ {
+ int num = 0;
+ while (modbusTCPClient._client == null || modbusTCPClient._client.Connected == false || modbusTCPClient._master == null)
+ {
+ if (_isReconnecting) return; // 濡傛灉姝e湪閲嶈繛锛岀洿鎺ヨ繑鍥�
+
+ modbusTCPClient.ModbudTCP_Connect(_lastIpAddress, _lastPort);
+ if (num++ > 3)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ MessageBox.Show("Modbus master 鏈垵濮嬪寲銆傛棤娉曡繛鎺LC");
+ }));
+ break;
+ }
+ }
+
+ while (modbusTCPClient._client != null && modbusTCPClient._client.Connected) //鎸佺画鐩戞帶
+ {
+ //modbusTCPClient.currentValus_ROIModel = modbusTCPClient.InputRegistersRead(3);
+ while (modbusTCPClient._client != null && modbusTCPClient._client.Connected)
+ {
+ modbusTCPClient.currentValus_trigger = modbusTCPClient.InputRegistersRead(3);
+ if (modbusTCPClient.previousValus_trigger[0] == 0 && modbusTCPClient.currentValus_trigger[0] == 1)
+ {
+ // 妫�鏌ヨ窛绂讳笂娆¤Е鍙戞槸鍚﹁秴杩�5绉�
+ if ((DateTime.Now - _lastTriggerTime).TotalSeconds >= double.Parse(Selflocking_Time))
+ {
+ _lastTriggerTime = DateTime.Now;
+ modbusTCPClient.istrigger = true;
+ Dispatcher.Invoke(() =>
+ {
+ DateTime currentDate = DateTime.Now;
+ string timeFileName = currentDate.ToString("HH:mm:ss");
+ GetMessage_Modbus($"妫�娴嬪埌瑙﹀彂淇″彿:{modbusTCPClient.currentValus_trigger[0]}");
+ GetMessage_Modbus($"{timeFileName}\n");
+ });
+ Console.WriteLine($"妫�娴嬪埌瑙﹀彂淇″彿:{modbusTCPClient.currentValus_trigger[0]}");
+ modbusTCPClient.MultipleRegistersWrite(3, new ushort[] { 0 });
+ Console.WriteLine($"瀵勫瓨鍣ㄧ疆0");
+ ReSetUI();
+ Task.Run(() => GetImage());
+ }
+ else
+ {
+ Console.WriteLine($"蹇界暐瑙﹀彂淇″彿锛岃窛绂讳笂娆¤Е鍙戜笉瓒硔Selflocking_Time}绉�");
+ modbusTCPClient.MultipleRegistersWrite(3, new ushort[] { 0 });
+ }
+ }
+ modbusTCPClient.previousValus_trigger = modbusTCPClient.currentValus_trigger;
+ modbusTCPClient.istrigger = false;
+ break;
+ }
+ modbusTCPClient.previousValus_ROIModel = modbusTCPClient.currentValus_ROIModel;
+ }
+ }
+ catch (Exception e)
+ {
+ // 濡傛灉姝e湪閲嶈繛锛屼笉鏄剧ず閿欒娑堟伅
+ if (!_isReconnecting)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ // 涓嶅啀寮圭獥锛屽彧鍦ㄦ棩蹇椾腑璁板綍
+ GetMessage_Modbus("Modbus杩炴帴鏂紑锛屽紑濮嬪皾璇曢噸杩�...\n");
+ }));
+ }
+ }
+ }
+ //ModBus蹇冭烦淇″彿
+ private void HeartbeatCallback(object state)
+ {
+ try
+ {
+ // 璇诲彇淇濇寔瀵勫瓨鍣�1鐨勫��
+ modbusTCPClient.HoldingRegisterRead(1);
+ Console.WriteLine("蹇冭烦淇″彿鏀跺彂姝e父");
+
+ // 蹇冭烦姝e父锛岄噸缃噸杩炲皾璇曟鏁�
+ _reconnectAttempts = 0;
+ }
+ catch (Exception ex)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ LinkState.Text = "鏈繛鎺�";
+ LinkState.Foreground = System.Windows.Media.Brushes.Red;
+ GetMessage_Modbus("妫�娴嬪埌Modbus杩炴帴寮傚父锛屽噯澶囬噸杩�...\n");
+ }));
+ Console.WriteLine($"Heartbeat failed: {ex.Message}");
+
+ // 绔嬪嵆鍚姩閲嶈繛鏈哄埗
+ StartReconnect();
+ }
+ }
+ // 鐢ㄦ埛鐐瑰嚮纭畾璺熻釜鏍囧織浣�
+ private bool _disconnectAlertShown = false;
+ // 璁惧杩炴帴鐘舵�佹娴�
+ private void DeviceConnectbeatCallback(object state)
+ {
+ try
+ {
+ for (int i = 0; i < DeviceListBox.Items.Count; i++)
+ {
+ IntPtr deviceHandle = _deviceHandles[i + 1];
+ long rel = IDDevice_IsOpen(deviceHandle);
+ if (rel == 0)
+ {
+ if (!_disconnectAlertShown)
+ {
+ _disconnectAlertShown = true;
+ System.Windows.Application.Current.Dispatcher.Invoke(() =>
+ {
+ MessageBox.Show($"璁惧{i + 1}杩炴帴鏂紑,璇烽噸鏂拌繛鎺�", "閿欒",
+ MessageBoxButton.OK, MessageBoxImage.Error);
+ _disconnectAlertShown = false; // 鐢ㄦ埛鐐瑰嚮纭畾鍚庨噸缃爣蹇�
+ });
+
+ _imagePtr[i + 1] = IntPtr.Zero;
+ // 褰诲簳閲婃斁瀹氭椂鍣�
+ deviceStatusTimer?.Dispose();
+ deviceStatusTimer = null;
+ }
+ return;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"璁惧鏈寜鐓ф槧灏勮〃杩炴帴: {ex.Message}");
+ }
+ }
+ #endregion
+
+ #region Modbus閲嶈繛鏈哄埗
+
+ // 鍒濆鍖栭噸杩炲畾鏃跺櫒
+ private void InitializeReconnectTimer()
+ {
+ // 濡傛灉瀹氭椂鍣ㄥ凡瀛樺湪锛屽厛閲婃斁
+ _reconnectTimer?.Dispose();
+
+ // 鍒涘缓鏂扮殑閲嶈繛瀹氭椂鍣�
+ _reconnectTimer = new System.Threading.Timer(ReconnectCallback, null, Timeout.Infinite, RECONNECT_INTERVAL);
+ }
+
+ // 鍚姩閲嶈繛
+ private void StartReconnect()
+ {
+ if (_isReconnecting) return;
+
+ // 鍋滄蹇冭烦瀹氭椂鍣�
+ heartbeatTimer?.Change(Timeout.Infinite, Timeout.Infinite);
+
+ // 鍚姩閲嶈繛瀹氭椂鍣�
+ _reconnectTimer?.Change(0, RECONNECT_INTERVAL);
+ }
+
+ // 鍋滄閲嶈繛
+ private void StopReconnect()
+ {
+ // 鍋滄閲嶈繛瀹氭椂鍣�
+ _reconnectTimer?.Change(Timeout.Infinite, Timeout.Infinite);
+
+ // 閲嶅惎蹇冭烦瀹氭椂鍣�
+ heartbeatTimer?.Change(0, heartbeatInterval);
+ }
+
+ // 閲嶈繛鍥炶皟
+ private void ReconnectCallback(object state)
+ {
+ if (_isReconnecting) return;
+
+ _isReconnecting = true;
+
+ try
+ {
+ // 妫�鏌ユ槸鍚﹁秴杩囨渶澶ч噸杩炴鏁�
+ if (_reconnectAttempts >= MAX_RECONNECT_ATTEMPTS)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ GetMessage_Modbus($"閲嶈繛澶辫触锛屽凡杈惧埌鏈�澶ч噸杩炴鏁� ({MAX_RECONNECT_ATTEMPTS})\n");
+ // 鍙湁瓒呰繃鏈�澶ч噸杩炴鏁版椂鎵嶅脊绐�
+ MessageBox.Show("Modbus閲嶈繛澶辫触锛屽凡杈惧埌鏈�澶ч噸杩炴鏁�", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }));
+
+ // 鍋滄閲嶈繛瀹氭椂鍣�
+ _reconnectTimer?.Change(Timeout.Infinite, Timeout.Infinite);
+ return;
+ }
+
+ _reconnectAttempts++;
+
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ GetMessage_Modbus($"灏濊瘯绗� {_reconnectAttempts} 娆¢噸杩�...\n");
+ }));
+
+ // 灏濊瘯閲嶈繛
+ bool reconnectSuccess = modbusTCPClient.Reconnect(_lastIpAddress, _lastPort);
+
+ if (reconnectSuccess)
+ {
+ // 閲嶈繛鎴愬姛
+ _reconnectAttempts = 0;
+ _isReconnecting = false;
+
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ GetMessage_Modbus("閲嶈繛鎴愬姛\n");
+ LinkState.Text = "ModBus宸茶繛鎺�";
+ LinkState.Foreground = System.Windows.Media.Brushes.LightGreen;
+ }));
+
+ // 鍋滄閲嶈繛锛屾仮澶嶅績璺�
+ StopReconnect();
+
+ // 閲嶆柊鍚姩鐩戝惉浠诲姟
+ Task.Run(() => ClientListen());
+ }
+ else
+ {
+ // 閲嶈繛澶辫触锛岀户缁皾璇曪紝涓嶅湪UI涓婂脊绐楋紝鍙湪鏃ュ織涓褰�
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ GetMessage_Modbus($"绗� {_reconnectAttempts} 娆¢噸杩炲け璐n");
+ }));
+
+ _isReconnecting = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ GetMessage_Modbus($"閲嶈繛杩囩▼涓彂鐢熼敊璇�: {ex.Message}\n");
+ }));
+
+ _isReconnecting = false;
+ }
+ }
+
+ #endregion
+
+ // 閫氳娴嬭瘯锛宒ebug鐢�
+ private void Write_Click(object sender, RoutedEventArgs e)
+ {
+ EnhancedLogViewModel.Instance.AddLog("寮�濮婱odBus閫氳娴嬭瘯锛屾墍鏈夊瘎瀛樺櫒鍐欏叆楂樼數骞�2s鍚庣疆闆�", "DEBUG");
+ if (modbusTCPClient._client == null)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ LinkState.Text = "鏈繛鎺�";
+ LinkState.Foreground = System.Windows.Media.Brushes.Red;
+ }));
+ MessageBox.Show("杩炴帴鍒版湇鍔″櫒澶辫触锛岃妫�鏌ヨ繛鎺ュ悗閲嶈瘯");
+ return;
+ }
+ //ushort[] test = new ushort[] { 0x8001 };
+ //modbusTCPClient.MultipleRegistersWrite(3, test);
+ //outputs[0] = true;
+ //outputs[15] = true;
+ //ushort value = BoolsToUshort(outputs);
+ // 鍋囪鏈変竴涓寘鍚�16涓�0鍜�1鐨勬暟缁�
+ int[] binaryDigits = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
+ int[] binaryDigits2 = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
+
+ // 灏嗕簩杩涘埗鏁扮粍杞崲涓簎short
+ ushort value = BinaryToUshort_MSBFirst(binaryDigits);
+ ushort value2 = BinaryToUshort_MSBFirst(binaryDigits2);
+
+ // 灏唘short瀛樺偍鍦╱short鏁扮粍涓�
+ ushort[] test = new ushort[] { value };
+ ushort[] test2 = new ushort[] { value2 };
+
+ modbusTCPClient.MultipleRegistersWrite(3, test);
+ modbusTCPClient.MultipleRegistersWrite(4, test2);
+ Thread.Sleep(2000);
+ modbusTCPClient.MultipleRegistersWrite(3, new ushort[] { 0 });
+ modbusTCPClient.MultipleRegistersWrite(4, new ushort[] { 0 });
+ }
+ private void OnTimedEvent(object source, ElapsedEventArgs e)
+ {
+ // 瀹氭椂鍣ㄨЕ鍙戞椂鎵ц鐨勪唬鐮�
+ modbusTCPClient.MultipleRegistersWrite(3, new ushort[] { 0 });
+ modbusTCPClient.MultipleRegistersWrite(4, new ushort[] { 0 });
+ EnhancedLogViewModel.Instance.AddLog($"Modbus宸茬疆闆�");
+ Console.WriteLine("Modbus宸茬疆闆�");
+
+ }
+ // 鎵嬪姩閲囬泦鍥惧儚
+ private void Read_Click(object sender, RoutedEventArgs e)
+ {
+ EnhancedLogViewModel.Instance.AddLog("寮�濮嬫墜鍔ㄩ噰闆嗗浘鍍�", "DEBUG");
+ ReSetUI();
+ Task.Run(() =>
+ {
+ GetImage();
+ });
+ }
+ private void ReSetUI()
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ Finall_result0.Content = "";
+ finall_result0.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result1.Content = "";
+ finall_result1.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result2.Content = "";
+ finall_result2.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result3.Content = "";
+ finall_result3.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result4.Content = "";
+ finall_result4.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result5.Content = "";
+ finall_result5.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result6.Content = "";
+ finall_result6.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result7.Content = "";
+ finall_result7.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result8.Content = "";
+ finall_result8.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result9.Content = "";
+ finall_result9.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result10.Content = "";
+ finall_result10.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result11.Content = "";
+ finall_result11.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result12.Content = "";
+ finall_result12.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result13.Content = "";
+ finall_result13.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result14.Content = "";
+ finall_result14.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result15.Content = "";
+ finall_result15.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result16.Content = "";
+ finall_result16.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result17.Content = "";
+ finall_result17.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result18.Content = "";
+ finall_result18.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result19.Content = "";
+ finall_result19.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result20.Content = "";
+ finall_result20.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result21.Content = "";
+ finall_result21.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result22.Content = "";
+ finall_result22.Background = System.Windows.Media.Brushes.Gray;
+ Finall_result23.Content = "";
+ finall_result23.Background = System.Windows.Media.Brushes.Gray;
+ }));
+ }
+ private void ReSet_Click(object sender, RoutedEventArgs e)
+ {
+ ReSetUI();
+ }
+ //璁惧绠$悊
+ SmartScanner.ProductManager productManager = null;
+ private void ProductMaanager_Btn_Click(object sender, RoutedEventArgs e)
+ {
+ var loginWindow = new LoginWindow();
+ if (loginWindow.ShowDialog() == true)
+ {
+ if (productManager == null || !productManager.IsLoaded)
+ {
+ productManager = new ProductManager();
+ productManager.Closed += (s, args) => { productManager = null; };
+ productManager.SetControlsEnabled(UserManager.HasAdministratorPrivilege());
+ productManager.ShowDialog();
+ }
+ else
+ {
+ if (productManager.WindowState == WindowState.Minimized)
+ {
+ productManager.WindowState = WindowState.Normal; // 鎭㈠绐楀彛鐘舵��
+ }
+ productManager.Activate(); // 濡傛灉绐楀彛宸插瓨鍦紝鍒欐縺娲诲畠
+ }
+ }
+ }
+ //妫�娴嬫柟妗�
+ SmartScanner.ResultJudge resultJudge = null;
+ private void ResultJudge_Btn_Click(object sender, RoutedEventArgs e)
+ {
+ var loginWindow = new LoginWindow();
+ if (loginWindow.ShowDialog() == true)
+ {
+ if (resultJudge == null || !resultJudge.IsLoaded)
+ {
+ resultJudge = new ResultJudge();
+ resultJudge.Closed += (s, args) => { resultJudge = null; };
+ resultJudge.SetControlsEnabled(UserManager.HasAdministratorPrivilege());
+ resultJudge.ShowDialog();
+ }
+ else
+ {
+ if (resultJudge.WindowState == WindowState.Minimized)
+ {
+ resultJudge.WindowState = WindowState.Normal; // 鎭㈠绐楀彛鐘舵��
+ }
+ resultJudge.Activate(); // 濡傛灉绐楀彛宸插瓨鍦紝鍒欐縺娲诲畠
+ }
+ }
+ }
+ #region 杈撳嚭妯″紡閫夋嫨
+ private void OutputCheckBox_Checked(object sender, RoutedEventArgs e)
+ {
+ IsSignleOutput = true;
+ // 璁板綍鏃ュ織
+ OperateLogService.LogOperation(
+ "缁撴灉杈撳嚭妯″紡",
+ $"淇敼涓�: 鍗曠偣杈撳嚭",
+ null);
+ }
+
+ private void OutputCheckBox_Unchecked(object sender, RoutedEventArgs e)
+ {
+ IsSignleOutput = false;
+ // 璁板綍鏃ュ織
+ OperateLogService.LogOperation(
+ "缁撴灉杈撳嚭妯″紡",
+ $"淇敼涓�: 澶氱偣杈撳嚭",
+ null);
+ }
+ #endregion
+ // 鍥惧儚淇濆瓨璁剧疆
+ SmartScanner.DownloadData downloadData = null;
+ private void ImageSetup_Btn_Click(object sender, RoutedEventArgs e)
+ {
+ var loginWindow = new LoginWindow();
+ if (loginWindow.ShowDialog() == true)
+ {
+ if (downloadData == null || !downloadData.IsLoaded)
+ {
+ downloadData = new DownloadData();
+ downloadData.Closed += (s, args) => { downloadData = null; };
+ downloadData.SetControlsEnabled(UserManager.HasAdministratorPrivilege());
+ downloadData.ShowDialog();
+ }
+ else
+ {
+ if (downloadData.WindowState == WindowState.Minimized)
+ {
+ downloadData.WindowState = WindowState.Normal; // 鎭㈠绐楀彛鐘舵��
+ }
+ downloadData.Activate(); // 濡傛灉绐楀彛宸插瓨鍦紝鍒欐縺娲诲畠
+ }
+ }
+ }
+ private void AddTestLog_Click(object sender, RoutedEventArgs e)
+ {
+ EnhancedLogViewModel.Instance.AddLog("杩欐槸涓�鏉℃櫘閫氫俊鎭�");
+ EnhancedLogViewModel.Instance.AddLog("杩欐槸涓�鏉¤鍛婁俊鎭�", "WARN");
+ EnhancedLogViewModel.Instance.AddLog("杩欐槸涓�鏉¢敊璇俊鎭�", "ERROR");
+ EnhancedLogViewModel.Instance.AddLog("杩欐槸涓�鏉¤皟璇曚俊鎭�", "DEBUG");
+ }
+ private void TCPClient_Connect_Click(object sender, RoutedEventArgs e)
+ {
+
+ }
+
+ private void TCPClient_ClearClientLogs_Click(object sender, RoutedEventArgs e)
+ {
+
+ }
+
+ private void btnViewLogs_Click(object sender, RoutedEventArgs e)
+ {
+ var operateLogView = new OperateLogView();
+ operateLogView.ShowDialog();
+ }
+
+ private void btnViewReports_Click(object sender, RoutedEventArgs e)
+ {
+ ExcelResultRecorder.OpenReportFolder();
+ }
+
+ private async void RestartButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (MessageBox.Show("纭畾瑕侀噸鍚簲鐢ㄧ▼搴忓悧锛�", "纭閲嶅惎",
+ MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
+ {
+ Mouse.OverrideCursor = Cursors.Wait;
+ try
+ {
+ await AppRestartHelper.RestartAsync();
+ }
+ finally
+ {
+ Mouse.OverrideCursor = null;
+ }
+ }
+ }
+ #region 鐣岄潰鍥剧墖鏄剧ず鎸夐挳
+ private ImageDisplayWindow displayWindow;
+
+ private void finall_result0_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_1.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_2.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result2_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_3.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+
+ }
+
+ private void finall_result3_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_4.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result4_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_5.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result5_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_6.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result6_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_7.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result7_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_8.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result8_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_9.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+
+ }
+
+ private void finall_result9_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_10.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result10_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_11.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result11_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_12.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result12_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_13.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+
+ }
+
+ private void finall_result13_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_14.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+
+ }
+
+ private void finall_result14_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_15.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result15_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_16.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+
+ }
+
+ private void finall_result16_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_17.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+
+ }
+
+ private void finall_result17_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_18.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+
+ }
+
+ private void finall_result18_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_19.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result19_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_20.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+
+ }
+
+ private void finall_result20_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_21.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result21_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_22.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void finall_result22_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_23.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+
+ }
+
+ private void finall_result23_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ displayWindow = new ImageDisplayWindow();
+ bool isShow = displayWindow.ShowImage_main(".\\vino_res\\result_24.jpg");
+ if (isShow)
+ {
+ displayWindow.Show();
+ }
+ else
+ {
+ return;
+ }
+
+ }
+ #endregion
+ #region TCP/IP閫氳妯″潡
+ private void TCPServer_Start_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ var ip = GetSelectedIP();
+ var port = GetSelectedPort();
+ var enableHeartbeat = TCPServer_EnableHeartbeat.IsChecked ?? false;
+ var heartbeatCommand = TCPServer_HeartbeatCommand.Text.Trim();
+ var heartbeatInterval = int.Parse(TCPServer_HeartbeatInterval.Text);
+ var outputIOCount = DeviceListBox.Items.Count;
+
+ // 楠岃瘉蹇冭烦璁剧疆
+ if (enableHeartbeat)
+ {
+ if (string.IsNullOrWhiteSpace(heartbeatCommand))
+ {
+ MessageBox.Show("璇疯緭鍏ユ湁鏁堢殑蹇冭烦鎸囦护");
+ return;
+ }
+
+ if (heartbeatInterval <= 0)
+ {
+ MessageBox.Show("蹇冭烦闂撮殧蹇呴』澶т簬0");
+ return;
+ }
+ }
+
+ _tcpServerManager = new TcpServerManager(
+ enableHeartbeat,
+ heartbeatCommand,
+ heartbeatInterval,
+ GetImageAndProcess,
+ outputIOCount);
+
+ _tcpServerManager.LogMessage += msg => Dispatcher.Invoke(() =>
+ {
+ TCPServer_LogsTextBox.AppendText($"{DateTime.Now:HH:mm:ss:fff} {msg}\n");
+ TCPServer_LogsTextBox.ScrollToEnd();
+ });
+
+ _ = _tcpServerManager.StartAsync(ip, port);
+
+ TCPServer_Start.IsEnabled = false;
+ TCPServer_Stop.IsEnabled = true;
+ LinkState.Text = "TCP宸插惎鍔�";
+ LinkState.Foreground = System.Windows.Media.Brushes.LightGreen;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"鍚姩鏈嶅姟鍣ㄥけ璐�: {ex.Message}");
+ }
+ }
+ private async Task<int[]> GetImageAndProcess()
+ {
+ try
+ {
+ usOutput_tcp = new int[DeviceListBox.Items.Count];
+ return await Task.Run(() =>
+ {
+ GetImage();
+ return usOutput_tcp; // 杩斿洖缁撴灉
+ }).ConfigureAwait(false);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"鍥惧儚澶勭悊寮傚父: {ex.Message}");
+ throw; // 閲嶆柊鎶涘嚭浠ヨЕ鍙慣CP灞傜殑閿欒澶勭悊
+ }
+ }
+ private void TCPServer_Stop_Click(object sender, RoutedEventArgs e)
+ {
+ _tcpServerManager?.Stop();
+ TCPServer_Start.IsEnabled = true;
+ TCPServer_Stop.IsEnabled = false;
+ LinkState.Text = "鏈繛鎺�";
+ LinkState.Foreground = System.Windows.Media.Brushes.Red;
+ }
+
+ private void TCPServer_EnableHeartbeat_Checked(object sender, RoutedEventArgs e)
+ {
+ TCPServer_HeartbeatPanel.Visibility = Visibility.Visible;
+ }
+
+ private void TCPServer_EnableHeartbeat_Unchecked(object sender, RoutedEventArgs e)
+ {
+ TCPServer_HeartbeatPanel.Visibility = Visibility.Collapsed;
+ }
+
+ private void TCPServer_ClearLogs_Click(object sender, RoutedEventArgs e)
+ {
+ Dispatcher.Invoke(() =>
+ TCPServer_LogsTextBox.Clear());
+ }
+
+
+ private void RefreshIpButton_Click(object sender, RoutedEventArgs e)
+ {
+ TCPServer_IpComboBox.Items.Clear();
+
+ // 娣诲姞榛樿閫夐」
+ TCPServer_IpComboBox.Items.Add(new ComboBoxItem
+ {
+ Content = "0.0.0.0 (All Interfaces)"
+ });
+ TCPServer_IpComboBox.Items.Add(new ComboBoxItem
+ {
+ Content = "127.0.0.1 (Loopback)"
+ });
+
+ // 娣诲姞瀹為檯IP鍦板潃
+ foreach (var ip in GetAvailableIPs())
+ {
+ var item = new ComboBoxItem
+ {
+ Content = $"{ip} ({GetNetworkInterfaceName(ip)})",
+ Tag = ip // 瀛樺偍瀹為檯IP瀵硅薄
+ };
+ TCPServer_IpComboBox.Items.Add(item);
+ }
+
+ TCPServer_IpComboBox.SelectedIndex = 0;
+ }
+ private string GetNetworkInterfaceName(IPAddress ip)
+ {
+ foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
+ {
+ foreach (UnicastIPAddressInformation addr in nic.GetIPProperties().UnicastAddresses)
+ {
+ if (addr.Address.Equals(ip))
+ {
+ return nic.Name;
+ }
+ }
+ }
+ return "Unknown";
+ }
+ private List<IPAddress> GetAvailableIPs()
+ {
+ var ips = new List<IPAddress>();
+
+ // 鑾峰彇鎵�鏈夋椿鍔ㄧ殑缃戠粶鎺ュ彛
+ foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
+ {
+ // 鍙幏鍙栧凡鍚敤涓旈潪铏氭嫙鐨勬帴鍙�
+ if (nic.OperationalStatus != OperationalStatus.Up ||
+ nic.NetworkInterfaceType == NetworkInterfaceType.Loopback)
+ continue;
+
+ // 鑾峰彇IPv4鍦板潃
+ foreach (UnicastIPAddressInformation ip in nic.GetIPProperties().UnicastAddresses)
+ {
+ if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
+ {
+ ips.Add(ip.Address);
+ }
+ }
+ }
+
+ return ips;
+ }
+ /// <summary>
+ /// 鑾峰彇褰撳墠閫夋嫨鐨処P鍦板潃瀛楃涓�
+ /// </summary>
+ /// <returns>
+ /// "0.0.0.0" - 鎵�鏈夋帴鍙�
+ /// "127.0.0.1" - 鐜洖鍦板潃
+ /// "192.168.1.100" - 鍏蜂綋IP
+ /// </returns>
+ public string GetSelectedIP()
+ {
+ // 鎯呭喌1锛氱敤鎴锋墜鍔ㄨ緭鍏ワ紙IsEditable=true鏃讹級
+ if (!string.IsNullOrWhiteSpace(TCPServer_IpComboBox.Text))
+ {
+ if (IsValidIP(TCPServer_IpComboBox.Text))
+ return TCPServer_IpComboBox.Text.Trim();
+ }
+
+ // 鎯呭喌2锛氫粠涓嬫媺椤归�夋嫨
+ if (TCPServer_IpComboBox.SelectedItem is ComboBoxItem item)
+ {
+ // 澶勭悊鐗规畩閫夐」
+ if (item.Content.ToString().Contains("0.0.0.0"))
+ return "0.0.0.0";
+ if (item.Content.ToString().Contains("127.0.0.1"))
+ return "127.0.0.1";
+
+ // 浠庡唴瀹逛腑鎻愬彇IP閮ㄥ垎锛堟牸寮忥細"IP (鎻忚堪)"锛�
+ var ipPart = item.Content.ToString().Split().FirstOrDefault();
+ if (IsValidIP(ipPart))
+ return ipPart;
+ }
+
+ // 榛樿杩斿洖"0.0.0.0"
+ return "0.0.0.0";
+ }
+
+ // IP鍦板潃楠岃瘉鏂规硶
+ private bool IsValidIP(string ipString)
+ {
+ return IPAddress.TryParse(ipString, out _);
+ }
+ /// <summary>
+ /// 瀹夊叏鑾峰彇閫夋嫨鐨勭鍙e彿
+ /// </summary>
+ /// <returns>
+ /// 鎴愬姛杩斿洖鏈夋晥绔彛(1-65535)锛屽け璐ヨ繑鍥�-1骞舵樉绀洪敊璇彁绀�
+ /// </returns>
+ public int GetSelectedPort()
+ {
+ try
+ {
+ // 鎯呭喌1锛氫粠涓嬫媺椤归�夋嫨
+ if (TCPServer_PortComboBox.SelectedItem is ComboBoxItem selectedItem)
+ {
+ if (int.TryParse(selectedItem.Content.ToString(), out int port) && IsValidPort(port))
+ return port;
+ }
+
+ // 鎯呭喌2锛氭墜鍔ㄨ緭鍏ユ枃鏈�
+ if (!string.IsNullOrWhiteSpace(TCPServer_PortComboBox.Text))
+ {
+ if (int.TryParse(TCPServer_PortComboBox.Text, out int manualPort) && IsValidPort(manualPort))
+ return manualPort;
+ }
+
+ throw new ArgumentException("鏈�夋嫨鏈夋晥绔彛");
+ }
+ catch (Exception ex)
+ {
+ ShowPortError($"绔彛鑾峰彇澶辫触: {ex.Message}");
+ return -1;
+ }
+ }
+
+ // 绔彛鑼冨洿楠岃瘉
+ private bool IsValidPort(int port) => port > 0 && port <= 65535;
+
+ // 閿欒鎻愮ず鏂规硶
+ private void ShowPortError(string message)
+ {
+ MessageBox.Show(message, "绔彛閰嶇疆閿欒",
+ MessageBoxButton.OK,
+ MessageBoxImage.Error);
+ }
+ #endregion
+ #region 宸ョ▼鏂规璁剧疆妯″潡鎸夐挳浜嬩欢
+ private void BtnSelectParam_Click(object sender, RoutedEventArgs e)
+ {
+ RefreshDetectionPlanList();
+ if (cmbDetectionPlans.SelectedItem == null)
+ {
+ MessageBox.Show("璇峰厛閫夋嫨妫�娴嬫柟妗�", "鎻愮ず", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+
+ string selectedPlan = ((dynamic)cmbDetectionPlans.SelectedItem).FileName;
+ MessageBox.Show($"宸查�夋嫨妫�娴嬫柟妗�: {selectedPlan}", "妫�娴嬫柟妗堢‘璁�",
+ MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+
+ /// <summary>
+ /// 鍔犺浇妫�娴嬫柟妗堝垪琛�
+ /// </summary>
+ private void RefreshDetectionPlanList()
+ {
+ var plans = GetAvailableDetectionPlans()
+ .Select(name => new
+ {
+ FileName = name,
+ FullPath = Path.Combine("DetectionPlan", name)
+ }).ToList();
+
+ cmbDetectionPlans.ItemsSource = plans;
+ if (plans.Any()) cmbDetectionPlans.SelectedIndex = 0;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎵�鏈夊彲鐢ㄦ娴嬫柟妗�
+ /// </summary>
+ private string[] GetAvailableDetectionPlans()
+ {
+ string planPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DetectionPlan");
+
+ if (!Directory.Exists(planPath))
+ {
+ Directory.CreateDirectory(planPath);
+ return Array.Empty<string>();
+ }
+
+ return Directory.GetFiles(planPath, "*.json")
+ .Select(Path.GetFileName)
+ .ToArray();
+ }
+
+ private void BtnConfirmModel_Click(object sender, RoutedEventArgs e)
+ {
+ if (cmbModels.SelectedItem == null)
+ {
+ MessageBox.Show("璇峰厛閫夋嫨妯″瀷鏂囦欢", "鎻愮ず", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+
+ string selectedModel = ((dynamic)cmbModels.SelectedItem).FileName;
+ MessageBox.Show($"宸查�夋嫨妯″瀷: {selectedModel}", "妯″瀷纭",
+ MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ /// <summary>
+ /// 鍔犺浇妯″瀷鍒楄〃
+ /// </summary>
+ private void RefreshModelList()
+ {
+ var models = LBProjService.GetAvailableModels()
+ .Select(name => new
+ {
+ FileName = name,
+ FullPath = Path.Combine("model", name)
+ }).ToList();
+
+ cmbModels.ItemsSource = models;
+ if (models.Any()) cmbModels.SelectedIndex = 0;
+ }
+
+ private void BtnExport_Click(object sender, RoutedEventArgs e)
+ {
+ if (cmbModels.SelectedItem == null)
+ {
+ MessageBox.Show("璇峰厛鐐瑰嚮銆愮‘瀹氥�戞寜閽�夋嫨妯″瀷", "璀﹀憡", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+
+ // 鍥哄畾瀵煎嚭璺緞
+ string projectDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Project");
+ if (!Directory.Exists(projectDir))
+ {
+ Directory.CreateDirectory(projectDir);
+ }
+
+ var saveDialog = new System.Windows.Forms.SaveFileDialog
+ {
+ Title = "瀵煎嚭 LBProj 宸ョ▼",
+ Filter = "LBProj鏂囦欢|*.lbproj",
+ FileName = $"project_{DateTime.Now:yyyyMMdd_HHmmss}",
+ InitialDirectory = projectDir
+ };
+
+ if (saveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ {
+ string modelName = ((dynamic)cmbModels.SelectedItem).FileName;
+ // 浣跨敤鍥哄畾璺緞鐨勬娴嬫柟妗堟枃浠�
+ string detectionPlanPath = cmbDetectionPlans.SelectedItem != null ?
+ Path.Combine("DetectionPlan", ((dynamic)cmbDetectionPlans.SelectedItem).FileName) :
+ "";
+
+ var (success, message) = LBProjService.CreateLBProj(
+ detectionPlanPath,
+ modelName,
+ saveDialog.FileName);
+
+ if (success)
+ {
+ Properties.Settings.Default.LastConfigFilePath_Proj = saveDialog.FileName;
+ Properties.Settings.Default.Save();
+ MessageBox.Show($"宸ョ▼宸叉垚鍔熶繚瀛樺埌: {saveDialog.FileName}", "鎴愬姛", MessageBoxButton.OK, MessageBoxImage.Information);
+ OperateLogService.LogOperation("宸ョ▼鏂囦欢淇敼", $"宸ョ▼鏂囦欢淇敼涓�: {saveDialog.FileName}", null);
+ //txtExportPath.Text = saveDialog.FileName;
+ }
+ else
+ {
+ MessageBox.Show(message, "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+ }
+
+ private void BtnLoad_Click(object sender, RoutedEventArgs e)
+ {
+ //RefreshProjectList();
+ if (cmbProjects.SelectedItem == null)
+ {
+ MessageBox.Show("璇峰厛閫夋嫨宸ョ▼鏂囦欢", "鎻愮ず", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+
+ string selectedProject = ((dynamic)cmbProjects.SelectedItem).FullPath;
+ var (modelName, configPath, configContent, message) = LBProjService.LoadLBProj(selectedProject);
+ config = JsonConvert.DeserializeObject<ResultJudge.JudgmentConfiguration>(configContent);
+ if (modelName != null)
+ {
+ // 鏇存柊妯″瀷閫夋嫨
+ foreach (var item in cmbModels.Items)
+ {
+ if (((dynamic)item).FileName == modelName)
+ {
+ cmbModels.SelectedItem = item;
+ break;
+ }
+ }
+ if (detector != IntPtr.Zero)
+ {
+ DisposeDetector_CPU(detector);
+ }
+ Task.Run(() =>
+ {
+ // 妯″瀷鎺ㄧ悊寮曟搸閫夋嫨
+ detector = CreateDetector_CPU();
+ bool isLoadModel = InitializeDetector_CPU(detector, Detector_Device, $".\\model\\{modelName}");
+ while (true)
+ {
+ if (isLoadModel)
+ {
+ EnhancedLogViewModel.Instance.AddLog($"妯″瀷缂栬瘧鎴愬姛");
+ break;
+ }
+ }
+ });
+ Properties.Settings.Default.LastConfigFilePath_Proj = selectedProject;
+ Properties.Settings.Default.Save();
+ //txtParamPath.Text = configPath;
+ //cmbModels.ItemsSource = modelName.ToString();
+ MessageBox.Show($"宸插姞杞芥ā鍨�: {modelName}\n{message}", "鎴愬姛",
+ MessageBoxButton.OK, MessageBoxImage.Information);
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ ProjectState.Foreground = System.Windows.Media.Brushes.LightGreen;
+ ModelState.Foreground = System.Windows.Media.Brushes.LightGreen;
+ ProjectState.Text = selectedProject;
+ ModelState.Text = modelName;
+ }));
+ EnhancedLogViewModel.Instance.AddLog($"宸插姞杞藉伐绋嬫枃浠�: {selectedProject}锛屾ā鍨嬶細{modelName}");
+ }
+ else
+ {
+ MessageBox.Show(message, "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ /// <summary>
+ /// 鍔犺浇宸ョ▼鏂囦欢鍒楄〃
+ /// </summary>
+ private void RefreshProjectList()
+ {
+ var projects = GetAvailableProjects()
+ .Select(name => new
+ {
+ FileName = name,
+ FullPath = Path.Combine("Project", name)
+ }).ToList();
+
+ cmbProjects.ItemsSource = projects;
+ if (projects.Any()) cmbProjects.SelectedIndex = 0;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎵�鏈夊彲鐢ㄥ伐绋嬫枃浠�
+ /// </summary>
+ private string[] GetAvailableProjects()
+ {
+ string projectPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Project");
+
+ if (!Directory.Exists(projectPath))
+ {
+ Directory.CreateDirectory(projectPath);
+ return Array.Empty<string>();
+ }
+
+ return Directory.GetFiles(projectPath, "*.lbproj")
+ .Select(Path.GetFileName)
+ .ToArray();
+ }
+
+ private void BtnRefreshModels_Click(object sender, RoutedEventArgs e)
+ {
+ RefreshModelList();
+ RefreshDetectionPlanList();
+ RefreshProjectList();
+ MessageBox.Show("妯″瀷銆佹娴嬫柟妗堝拰宸ョ▼鏂囦欢鍒楄〃宸插埛鏂�", "鎻愮ず", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ #endregion
+ #region 鐗堟湰璇存槑鍔熻兘
+ private void VersionButton_Click(object sender, RoutedEventArgs e)
+ {
+ ShowVersionInfo();
+ }
+
+ private void ShowVersionInfo()
+ {
+ try
+ {
+ // 璇诲彇鐗堟湰璇存槑鏂囦欢
+ string versionFile = "鐗堟湰璇存槑.txt";
+ if (File.Exists(versionFile))
+ {
+ string versionContent = File.ReadAllText(versionFile);
+
+ // 瑙f瀽鐗堟湰璇存槑鏂囦欢锛屾彁鍙栨渶鏂扮増鏈俊鎭�
+ var versionLines = versionContent.Split('\n');
+ string latestVersion = "";
+ string latestDate = "";
+ string latestChanges = "";
+
+ // 浠庢渶鍚庝竴琛屽悜鍓嶆煡鎵炬渶鏂扮殑鐗堟湰淇℃伅
+ for (int i = versionLines.Length - 1; i >= 0; i--)
+ {
+ if (versionLines[i].Contains("v") && versionLines[i].Contains("."))
+ {
+ // 鎻愬彇鐗堟湰鏃ユ湡鍜岀増鏈彿
+ var parts = versionLines[i].Trim().Split(' ');
+ foreach (var part in parts)
+ {
+ if (part.Contains(".") && part.Length > 0)
+ {
+ if (part.StartsWith("v") || part.Contains("v"))
+ {
+ latestVersion = part.Trim();
+ }
+ else if (char.IsDigit(part[0]))
+ {
+ latestDate = part.Trim();
+ }
+ }
+ }
+
+ // 鏌ユ壘璇ョ増鏈殑鏇存柊鍐呭
+ for (int j = i + 1; j < versionLines.Length; j++)
+ {
+ string contentLine = versionLines[j].Trim();
+
+ // 鍋滄鏉′欢锛氱┖琛屾垨鏂扮殑鐗堟湰琛�
+ if (string.IsNullOrEmpty(contentLine) ||
+ (contentLine.Contains("v") && contentLine.Contains(".") && contentLine.Length > 8))
+ {
+ break;
+ }
+
+ // 娣诲姞鎵�鏈夐潪绌哄唴瀹硅
+ if (contentLine.Length > 0)
+ {
+ latestChanges += contentLine + "\n";
+ }
+
+ // 鏈�澶氳鍙�8琛屽唴瀹�
+ if (j - i > 8)
+ {
+ break;
+ }
+ }
+
+ // 鏄剧ず鐗堟湰淇℃伅瀵硅瘽妗�
+ string message = $"褰撳墠杞欢鐗堟湰: {latestVersion}\n" +
+ $"鍙戝竷鏃ユ湡: {latestDate}\n\n" +
+ $"鏈�鏂版洿鏂板唴瀹�:\n{latestChanges}\n" +
+ $"瀹屾暣鐗堟湰鍘嗗彶璁板綍璇锋煡鐪嬬増鏈鏄�.txt鏂囦欢";
+
+ MessageBox.Show(message, "杞欢鐗堟湰璇存槑", MessageBoxButton.OK, MessageBoxImage.Information);
+ return;
+ }
+ }
+
+ // 濡傛灉娌℃湁鎵惧埌鐗堟湰淇℃伅锛屾樉绀洪粯璁ゆ彁绀�
+ MessageBox.Show("鐗堟湰璇存槑鏂囦欢涓湭鎵惧埌鏈夋晥鐨勭増鏈俊鎭�", "鎻愮ず", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ else
+ {
+ MessageBox.Show("鐗堟湰璇存槑鏂囦欢涓嶅瓨鍦�", "閿欒", MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"璇诲彇鐗堟湰淇℃伅鏃跺嚭閿�: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+ #endregion
+ }
+}
+
+
diff --git a/IDViewer_2D/ModbusTCPClient.cs b/IDViewer_2D/ModbusTCPClient.cs
new file mode 100644
index 0000000..b4f5fdc
--- /dev/null
+++ b/IDViewer_2D/ModbusTCPClient.cs
@@ -0,0 +1,197 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using NModbus;
+using NModbus.Device;
+using NModbus.Extensions.Enron;
+using OpenCvSharp;
+
+namespace SmartScanner
+{
+ class ModbusTCPClient
+ {
+ public TcpClient _client;
+ public IModbusMaster _master;
+ public ModbusFactory factory = new ModbusFactory();
+ public int isconnnum = 1;
+ public ushort[] previousValus_trigger = { 0, 0 }; //瀵勫瓨鍣ㄥ綋鍓嶅��
+ public ushort[] currentValus_trigger = { 0, 0 }; //瀵勫瓨鍣ㄥ墠涓�涓��
+ public ushort[] previousValus_ROIModel = { 0, 0 };
+ public ushort[] currentValus_ROIModel = { 0, 0 };
+ public bool istrigger = false;
+
+ // 閲嶈繛鐩稿叧瀛楁
+ public const int MaxReconnectAttempts = 5; // 鏈�澶ч噸杩炴鏁�
+ public const int ReconnectInterval = 5000; // 閲嶈繛闂撮殧鏃堕棿(姣)
+ private int _reconnectAttempts = 0; // 褰撳墠閲嶈繛灏濊瘯娆℃暟
+ private bool _isReconnecting = false; // 鏄惁姝e湪閲嶈繛
+
+ public void ModbudTCP_Connect(string ipAddress, int port)
+ {
+ try
+ {
+ _client = new TcpClient(ipAddress, port);
+ if (_client.Connected)
+ {
+ // 鍒涘缓 TCP 瀹㈡埛绔�
+ //MessageBox.Show("杩炴帴鍒版湇鍔″櫒鎴愬姛");
+ // 鍒涘缓 Modbus 宸ュ巶鍜屼富鏈�
+ _master = (ModbusMaster)factory.CreateMaster(_client);
+ if (_master == null)
+ {
+ MessageBox.Show("鏃犳硶鍒涘缓 Modbus master 瀹炰緥銆�");
+ return;
+ }
+ // 杩炴帴鎴愬姛锛岄噸缃噸杩炶鏁�
+ _reconnectAttempts = 0;
+ }
+ else
+ {
+ if (isconnnum++ < 5)
+ {
+ ModbudTCP_Connect(ipAddress, port);
+ Thread.Sleep(1000);
+ }
+ else
+ {
+ MessageBox.Show("杩炴帴鍒版湇鍔″櫒瓒呮椂");
+ return;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"杩炴帴鍒版湇鍔″櫒澶辫触锛歿ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ Console.WriteLine("杩炴帴鍒版湇鍔″櫒澶辫触");
+ return;
+ }
+ }
+
+ // 閲嶈繛鏂规硶
+ public bool Reconnect(string ipAddress, int port)
+ {
+ // 閬垮厤閲嶅閲嶈繛
+ if (_isReconnecting) return false;
+
+ _isReconnecting = true;
+
+ try
+ {
+ // 閲婃斁鍘熸湁杩炴帴
+ _master?.Dispose();
+ _client?.Close();
+ _client = null;
+
+ // 妫�鏌ユ槸鍚﹁秴杩囨渶澶ч噸杩炴鏁�
+ if (_reconnectAttempts >= MaxReconnectAttempts)
+ {
+ Console.WriteLine("Modbus閲嶈繛澶辫触锛屽凡杈惧埌鏈�澶ч噸杩炴鏁�");
+ return false;
+ }
+
+ _reconnectAttempts++;
+ Console.WriteLine($"灏濊瘯绗瑊_reconnectAttempts}娆¢噸杩�...");
+
+ // 灏濊瘯閲嶆柊杩炴帴
+ _client = new TcpClient();
+ var connectTask = _client.ConnectAsync(ipAddress, port);
+
+ // 绛夊緟杩炴帴瀹屾垚锛屾渶澶氱瓑寰�5绉�
+ if (connectTask.Wait(5000))
+ {
+ if (_client.Connected)
+ {
+ _master = (ModbusMaster)factory.CreateMaster(_client);
+ if (_master != null)
+ {
+ // 閲嶈繛鎴愬姛锛岄噸缃鏁�
+ _reconnectAttempts = 0;
+ Console.WriteLine("Modbus閲嶈繛鎴愬姛");
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"閲嶈繛澶辫触: {ex.Message}");
+ return false;
+ }
+ finally
+ {
+ _isReconnecting = false;
+ }
+ }
+
+ public ushort[] HoldingRegisterRead(ushort starAddress) //璇讳繚鎸佸瘎瀛樺櫒
+ {
+ try
+ {
+ ushort[] registerValues = _master.ReadHoldingRegisters(1, starAddress, 1);
+ return registerValues;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"璇诲彇淇濇寔瀵勫瓨鍣ㄥけ璐�: {ex.Message}");
+ throw;
+ }
+ }
+
+ public void HoldingRegisterWrite(ushort registerAddress, ushort WriteValue) //鍐欎繚瀛樺瘎瀛樺櫒
+ {
+ try
+ {
+ _master.WriteSingleRegister(1, registerAddress, WriteValue);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"鍐欏叆淇濇寔瀵勫瓨鍣ㄥけ璐�: {ex.Message}");
+ throw;
+ }
+ }
+ public void SingleCoilWrite(ushort CoilAddress, bool valueToWrite) //鍐欏崟绾垮湀
+ {
+ try
+ {
+ _master.WriteSingleCoil(1, CoilAddress, valueToWrite);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"鍐欏叆鍗曠嚎鍦堝け璐�: {ex.Message}");
+ throw;
+ }
+ }
+ public void MultipleRegistersWrite(ushort starAddress, ushort[] valueToWrite)
+ {
+ try
+ {
+ _master.WriteMultipleRegisters(1, starAddress, valueToWrite);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"鍐欏叆澶氫釜瀵勫瓨鍣ㄥけ璐�: {ex.Message}");
+ throw;
+ }
+ }
+ public ushort[] InputRegistersRead(ushort starAddress)
+ {
+ try
+ {
+ ushort[] registerValues = _master.ReadInputRegisters(1, starAddress, 1);
+ return registerValues;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"璇诲彇杈撳叆瀵勫瓨鍣ㄥけ璐�: {ex.Message}");
+ throw;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/IDViewer_2D/OperateLog/OperateLogService.cs b/IDViewer_2D/OperateLog/OperateLogService.cs
new file mode 100644
index 0000000..d72e749
--- /dev/null
+++ b/IDViewer_2D/OperateLog/OperateLogService.cs
@@ -0,0 +1,69 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SmartScanner.OperateLog
+{
+ public static class OperateLogService
+ {
+ private static readonly string logDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs");
+ private static readonly string logFileName = $"OperationLog_{DateTime.Now:yyyyMMdd}.txt";
+
+ static OperateLogService()
+ {
+ // 纭繚鏃ュ織鐩綍瀛樺湪
+ if (!Directory.Exists(logDirectory))
+ {
+ Directory.CreateDirectory(logDirectory);
+ }
+ }
+
+ public static void LogOperation(string operationType, string operationDetails, string targetDevice = null)
+ {
+ if (UserManager.CurrentUser == null) return;
+
+ try
+ {
+ var logEntry = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} | " +
+ $"鎿嶄綔浜哄憳: {UserManager.CurrentUser.Username} | " +
+ $"鎿嶄綔绫诲瀷: {operationType} | " +
+ $"鐩爣璁惧: {targetDevice ?? "N/A"} | " +
+ $"鎿嶄綔璇︽儏: {operationDetails}";
+
+ var logPath = Path.Combine(logDirectory, logFileName);
+ File.AppendAllText(logPath, logEntry + Environment.NewLine);
+ }
+ catch (Exception ex)
+ {
+ // 绠�鍗曞鐞嗘棩蹇楀啓鍏ラ敊璇�
+ Console.WriteLine($"鏃ュ織璁板綍澶辫触: {ex.Message}");
+ }
+ }
+
+ public static string[] GetRecentLogs(int days = 7)
+ {
+ try
+ {
+ var logFiles = Directory.GetFiles(logDirectory, "OperationLog_*.txt")
+ .OrderByDescending(f => f)
+ .Take(days)
+ .ToList();
+
+ var allLogs = new List<string>();
+ foreach (var file in logFiles)
+ {
+ allLogs.AddRange(File.ReadAllLines(file));
+ }
+
+ return allLogs.ToArray();
+ }
+ catch
+ {
+ return new string[0];
+ }
+ }
+ }
+}
diff --git a/IDViewer_2D/OperateLog/OperateLogView.xaml b/IDViewer_2D/OperateLog/OperateLogView.xaml
new file mode 100644
index 0000000..3a4d4d4
--- /dev/null
+++ b/IDViewer_2D/OperateLog/OperateLogView.xaml
@@ -0,0 +1,19 @@
+锘�<Window x:Class="SmartScanner.OperateLog.OperateLogView"
+ 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:SmartScanner.OperateLog"
+ mc:Ignorable="d"
+ Title="鎿嶄綔鏃ュ織" Height="450" Width="800">
+ <DockPanel>
+ <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="5">
+ <Button Content="鍒锋柊" Width="80" Margin="5" Click="BtnRefresh_Click"/>
+ <Button Content="鎵撳紑鏃ュ織鏂囦欢澶�" Width="120" Margin="5" Click="BtnOpenFolder_Click"/>
+ </StackPanel>
+
+ <TextBox x:Name="txtLogs" DockPanel.Dock="Bottom" Margin="5"
+ IsReadOnly="True" VerticalScrollBarVisibility="Auto"
+ TextWrapping="Wrap" FontSize="12"/>
+ </DockPanel>
+</Window>
diff --git a/IDViewer_2D/OperateLog/OperateLogView.xaml.cs b/IDViewer_2D/OperateLog/OperateLogView.xaml.cs
new file mode 100644
index 0000000..08d3085
--- /dev/null
+++ b/IDViewer_2D/OperateLog/OperateLogView.xaml.cs
@@ -0,0 +1,60 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+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.Shapes;
+
+namespace SmartScanner.OperateLog
+{
+ /// <summary>
+ /// OperateLogView.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ public partial class OperateLogView : Window
+ {
+ public OperateLogView()
+ {
+ InitializeComponent();
+ RefreshLogs();
+ }
+ private void RefreshLogs()
+ {
+ var logs = OperateLogService.GetRecentLogs();
+ txtLogs.Text = string.Join(Environment.NewLine, logs);
+ }
+
+ private void BtnRefresh_Click(object sender, RoutedEventArgs e)
+ {
+ RefreshLogs();
+ }
+
+ private void BtnOpenFolder_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ var logDirectory = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs");
+ if (Directory.Exists(logDirectory))
+ {
+ Process.Start("explorer.exe", logDirectory);
+ }
+ else
+ {
+ MessageBox.Show("鏃ュ織鐩綍涓嶅瓨鍦�", "鎻愮ず", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"鎵撳紑鏃ュ織鏂囦欢澶瑰け璐�: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+ }
+}
diff --git a/IDViewer_2D/ProductManager.xaml b/IDViewer_2D/ProductManager.xaml
new file mode 100644
index 0000000..149dfbf
--- /dev/null
+++ b/IDViewer_2D/ProductManager.xaml
@@ -0,0 +1,60 @@
+锘�<Window x:Class="SmartScanner.ProductManager"
+ 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:SmartScanner"
+ mc:Ignorable="d"
+ Title="璁惧绠$悊" Height="450" Width="800">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+
+ <!-- 杈撳叆鎺у埗鍖� -->
+ <StackPanel Grid.Row="0" Orientation="Horizontal">
+ <TextBlock Text="杩炴帴椤哄簭锛�" VerticalAlignment="Center"/>
+ <ComboBox x:Name="cmbOrder" Width="80" Margin="5,0"
+ DisplayMemberPath="." SelectedValuePath="."/>
+
+ <TextBlock Text="鐩告満IP锛�" VerticalAlignment="Center" Margin="10,0,0,0"/>
+ <ComboBox x:Name="cmbIP" Width="150" Margin="5,0"
+ ItemsSource="{Binding AvailableIPs}"/>
+
+ <!--<TextBlock Text="妯″瀷閫夋嫨锛�" VerticalAlignment="Center" Margin="10,0,0,0"/>
+ <ComboBox x:Name="cmbModel" Width="150" Margin="5,0"
+ ItemsSource="{Binding AvailableIPs}"/>-->
+
+ <Button x:Name="DeviceRefresh_PM" Content="鍒锋柊璁惧" Width="80" Margin="10,0" Click="BtnRefreshDevices_Click"/>
+ <Button x:Name="AddMapping_PM" Content="娣诲姞鏄犲皠" Width="80" Margin="5,0" Click="BtnAddMapping_Click"/>
+ <Button x:Name="SaveConfig_PM" Content="淇濆瓨" Width="80" Margin="5,0" Click="BtnSave_Click"/>
+ <Button x:Name="LoadConfig_PM" Content="鍔犺浇鏄犲皠" Width="80" Margin="5,0" Click="BtnLoad_Click"/>
+ </StackPanel>
+
+ <!-- 鏄犲皠琛ㄦ樉绀� -->
+ <DataGrid Grid.Row="1" x:Name="dgMapping" AutoGenerateColumns="False"
+ CanUserAddRows="False" CanUserDeleteRows="True">
+ <DataGrid.Columns>
+ <DataGridTextColumn Header="杩炴帴椤哄簭" Binding="{Binding Key}" Width="*"/>
+ <DataGridTextColumn Header="鐩告満IP" Binding="{Binding Value}" Width="2*"/>
+ <!--<DataGridTextColumn Header="鎺ㄧ悊妯″瀷" Binding="{Binding DetectorSelect}" Width="*"/>-->
+ <DataGridTemplateColumn Header="鎿嶄綔" Width="100">
+ <DataGridTemplateColumn.CellTemplate>
+ <DataTemplate>
+ <Button Content="绉婚櫎" Click="DeleteMapping_Click"/>
+ </DataTemplate>
+ </DataGridTemplateColumn.CellTemplate>
+ </DataGridTemplateColumn>
+ </DataGrid.Columns>
+ </DataGrid>
+
+ <!-- 鐘舵�佹爮 -->
+ <StatusBar Grid.Row="2">
+ <StatusBarItem>
+ <TextBlock x:Name="tbStatus" Text="灏辩华"/>
+ </StatusBarItem>
+ </StatusBar>
+ </Grid>
+</Window>
diff --git a/IDViewer_2D/ProductManager.xaml.cs b/IDViewer_2D/ProductManager.xaml.cs
new file mode 100644
index 0000000..9c7abc7
--- /dev/null
+++ b/IDViewer_2D/ProductManager.xaml.cs
@@ -0,0 +1,216 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+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.Shapes;
+using SmartScanner.OperateLog;
+using Newtonsoft.Json;
+using static SmartScanner.IDViewerDefines;
+using static SmartScanner.IDViewerSDK;
+namespace SmartScanner
+{
+ /// <summary>
+ /// ProductManager.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ public partial class ProductManager : Window
+ {
+ private readonly ObservableCollection<KeyValuePair<int, string>> _ipMapping = new ObservableCollection<KeyValuePair<int, string>>();
+ private ObservableCollection<string> _availableIPs = new ObservableCollection<string>();
+ private const string ConfigFile = "connection_order.json";
+ IDDeviceInfo[] deviceInfo = new IDDeviceInfo[100];
+
+ public ProductManager()
+ {
+ InitializeComponent();
+ long result = IDVIEWER_Init_();
+ dgMapping.ItemsSource = _ipMapping;
+ cmbIP.ItemsSource = _availableIPs;
+ RefreshDeviceList();
+ }
+ public void SetControlsEnabled(bool isEnabled)
+ {
+ // 绂佺敤鎴栧惎鐢ㄦ墍鏈夊彲缂栬緫鐨勬帶浠�
+ //LoadConfig_RJ.IsEnabled = isEnabled;
+ cmbOrder.IsEnabled = isEnabled;
+ cmbIP.IsEnabled = isEnabled;
+ DeviceRefresh_PM.IsEnabled = isEnabled;
+ AddMapping_PM.IsEnabled = isEnabled;
+ SaveConfig_PM.IsEnabled = isEnabled;
+ //LoadConfig_PM.IsEnabled = isEnabled;
+ // ... 鍏朵粬闇�瑕佹帶鍒剁殑鎺т欢
+
+ }
+
+ private void RefreshDeviceList()
+ {
+ try
+ {
+ //鑾峰彇璁惧鍒楄〃鍙ユ焺
+ IntPtr devicesListHandle = IDVIEWER_DiscoveryDevices_(500);
+
+ // 鑾峰彇璁惧鎬绘暟
+ int deviceCount = (int)IDVIEWER_GetDevicesLength_(devicesListHandle);
+
+ // 鐢熸垚椤哄簭鍙烽�夐」锛�1~N锛�
+ cmbOrder.ItemsSource = Enumerable.Range(1, deviceCount).ToList();
+ cmbOrder.SelectedIndex = 0;
+ List<string> ips = new List<string>();
+ for (int i = 0; i < deviceCount; i++)
+ {
+ //鑾峰彇鐩告満IP
+ IDViewerSDK.IDVIEWER_SelectIDDeviceInfo_(devicesListHandle, ref deviceInfo[i], (uint)i);
+ string deviceIP = deviceInfo[i].cameraIP.Trim();
+ ips.Add(deviceIP);
+ }
+ // 鑾峰彇鍙敤IP鍒楄〃
+ ips.Where(IsValidIP).ToList();
+ _availableIPs.Clear();
+ foreach (var ip in ips)
+ {
+ _availableIPs.Add(ip);
+ }
+ tbStatus.Text = $"妫�娴嬪埌 {deviceCount} 鍙拌澶� | 鍙敤IP锛歿ips.Count} 涓�";
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"璁惧妫�娴嬪け璐ワ細{ex.Message}");
+ }
+ }
+
+ private void BtnAddMapping_Click(object sender, RoutedEventArgs e)
+ {
+ if (cmbOrder.SelectedItem == null || cmbIP.SelectedItem == null)
+ {
+ MessageBox.Show("璇烽�夋嫨椤哄簭鍜孖P鍦板潃");
+ return;
+ }
+
+ int selectedOrder = (int)cmbOrder.SelectedItem;
+ string selectedIP = cmbIP.SelectedItem.ToString();
+ // 妫�鏌ラ『搴忓啿绐�
+ if (_ipMapping.Any(x => x.Key == selectedOrder))
+ {
+ MessageBox.Show("璇ラ『搴忓凡鍒嗛厤锛岃鍏堢Щ闄ゅ師鏈夊垎閰�");
+ return;
+ }
+
+ // 妫�鏌P閲嶅
+ if (_ipMapping.Any(x => x.Value == selectedIP))
+ {
+ MessageBox.Show("璇P宸插垎閰嶉『搴�");
+ return;
+ }
+
+ _ipMapping.Add(new KeyValuePair<int, string>(selectedOrder, selectedIP));
+ SortMapping();
+ }
+
+ private void DeleteMapping_Click(object sender, RoutedEventArgs e)
+ {
+ if (dgMapping.SelectedItem is KeyValuePair<int, string> item)
+ {
+ _ipMapping.Remove(item);
+ SortMapping();
+ }
+ }
+
+ private void SortMapping()
+ {
+ var sorted = _ipMapping
+ .OrderBy(x => x.Key)
+ .ToList();
+
+ _ipMapping.Clear();
+ foreach (var item in sorted)
+ {
+ _ipMapping.Add(item);
+ }
+ }
+
+ private void BtnRefreshDevices_Click(object sender, RoutedEventArgs e) => RefreshDeviceList();
+
+ // 淇濆瓨/鍔犺浇鏂规硶
+ private void BtnSave_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ var config = new
+ {
+ LastModified = DateTime.Now,
+ Mapping = _ipMapping.ToList()
+ };
+
+ File.WriteAllText(ConfigFile, JsonConvert.SerializeObject(config, Formatting.Indented));
+ MessageBox.Show("閰嶇疆淇濆瓨鎴愬姛");
+ // 璁板綍鏃ュ織
+ OperateLogService.LogOperation(
+ "鏄犲皠琛ㄤ慨鏀�",
+ $"鏄犲皠琛ㄤ慨鏀逛负: {ConfigFile}",
+ null);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"淇濆瓨澶辫触锛歿ex.Message}");
+ }
+ }
+ private void BtnLoad_Click(object sender, RoutedEventArgs e)
+ {
+ var loadedMapping = LoadConfig();
+ if (loadedMapping.Count > 0)
+ {
+ _ipMapping.Clear(); // 娓呯┖褰撳墠鏄犲皠
+ foreach (var item in loadedMapping)
+ {
+ _ipMapping.Add(item); // 娣诲姞鍔犺浇鐨勯厤缃�
+ }
+ SortMapping(); // 閲嶆柊鎺掑簭
+ RefreshMappingDisplay(); // 鍒锋柊鐣岄潰鏄剧ず
+ MessageBox.Show("閰嶇疆鍔犺浇鎴愬姛");
+ }
+ }
+ private void RefreshMappingDisplay()
+ {
+ // 缁戝畾鏁版嵁鍒� DataGrid
+ dgMapping.ItemsSource = null; // 鍏堟竻绌虹粦瀹�
+ dgMapping.ItemsSource = _ipMapping.ToList(); // 閲嶆柊缁戝畾
+ }
+
+ public List<KeyValuePair<int, string>> LoadConfig()
+ {
+ try
+ {
+ if (File.Exists(ConfigFile))
+ {
+ var json = File.ReadAllText(ConfigFile);
+ var config = JsonConvert.DeserializeObject<dynamic>(json);
+ var mapping = new List<KeyValuePair<int, string>>();
+ foreach (var item in config.Mapping)
+ {
+ mapping.Add(new KeyValuePair<int, string>(
+ (int)item.Key,
+ (string)item.Value));
+ }
+ return mapping;
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"鍔犺浇鏄犲皠琛ㄥけ璐ワ細{ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ return new List<KeyValuePair<int, string>>();
+ }
+ private static bool IsValidIP(string ip) => Regex.IsMatch(ip,
+ @"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
+ }
+}
diff --git a/IDViewer_2D/Program.cs b/IDViewer_2D/Program.cs
new file mode 100644
index 0000000..aaf8766
--- /dev/null
+++ b/IDViewer_2D/Program.cs
@@ -0,0 +1,266 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.IO;
+using System.IO.Ports;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Text;
+using static IDViewerDemo.IDViewerDefines;
+using static IDViewerDemo.IDViewerSDK;
+
+namespace IDViewerDemo
+{
+ delegate void IDViewerCallBack(IntPtr device, IntPtr image, IntPtr decodeInfoHandel);
+ class Program
+ {
+ static string filepath = "D:\\text.bmp";
+
+ static void Main(string[] args)
+ {
+ int option = 0;
+ long result = IDViewerSDK.IDVIEWER_Init_();
+ while (0 == result)
+ {
+ ClearScreen();
+ Console.WriteLine("0) 閫�鍑虹▼搴�");
+ Console.WriteLine("1) 璇荤爜鍣ㄦ搷浣�");
+ if (GetInputOption(ref option) == false) continue;
+ switch (option)
+ {
+ case 0:
+ return;
+ case 1:
+ MenuIDViewer();
+ break;
+ default:
+ break;
+ }
+
+ }
+ }
+
+ static void MenuIDViewer()
+ {
+ int option = 0;
+ while (true)
+ {
+ ClearScreen();
+ Console.WriteLine("0) 杩斿洖涓婁竴绾�");
+ Console.WriteLine("1) 鎵弿鎵�鏈夎鐮佸櫒");
+ Console.WriteLine("2) 閫氳繃SN鍙疯繛鎺ヨ鐮佸櫒");
+ if (GetInputOption(ref option) == false) continue;
+ switch (option)
+ {
+ case 0:
+ return;
+ case 1:
+ DiscoveryIDViewer();
+ system("pause");
+ break;
+ case 2:
+ DiscoveryIDViewer_SN();
+ system("pause");
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+
+
+ static void DiscoveryIDViewer()
+ {
+ IntPtr deviceList = IDVIEWER_DiscoveryDevices_();
+ long length = IDVIEWER_GetDevicesLength_(deviceList);
+ Console.WriteLine("鑾峰彇鍒拌鐮佸櫒涓暟涓猴細" + length);
+ IDDeviceInfo info = new IDDeviceInfo();
+ for (uint i = 0; i < length; i++)
+ {
+ long Inforesult = IDVIEWER_SelectIDDeviceInfo_(deviceList, ref info, i);
+ //Console.WriteLine(Inforesult);
+ Console.WriteLine("*******************************************");
+ if (i >= 0) Console.WriteLine("index锛�" + i);
+ Console.WriteLine("networkIP锛�" + new string(info.networkIP));
+ Console.WriteLine("networkMask锛�" + new string(info.networkMask));
+ Console.WriteLine("networkGateway锛�" + new string(info.networkGateway));
+ Console.WriteLine("cameraIP锛�" + new string(info.cameraIP));
+ Console.WriteLine("cameraSN锛�" + new string(info.cameraSN));
+ Console.WriteLine("cameraType锛�" + new string(info.cameraType));
+ }
+ }
+
+
+ static void DiscoveryIDViewer_SN()
+ {
+ IntPtr device = IntPtr.Zero;
+ IDDeviceInfo info = new IDDeviceInfo();
+ Console.WriteLine("璇疯緭鍏N鍙�");
+ String serialNum = Console.ReadLine();
+ long result = IDVIEWER_CreateDeviceBySN_(serialNum, ref device);
+
+ if (device != IntPtr.Zero)
+ {
+ int option = 0;
+
+ while (true)
+ {
+ ClearScreen();
+ Console.WriteLine("0) 杩斿洖涓婁竴绾�");
+ Console.WriteLine("1) 鎵撳紑");
+ Console.WriteLine("2) 杩愯");
+ Console.WriteLine("3) 杩炴帴鐘舵��");
+ Console.WriteLine("4) 鍏抽棴");
+ if (GetInputOption(ref option) == false) continue;
+
+ if (option == 0)
+ {
+ return;
+ }
+
+ if (option < 1 || option > 10)
+ {
+ continue;
+ }
+
+ switch (option)
+ {
+ case 1:
+ IDDevice_Open(device);
+ break;
+ case 2:
+ Device_StartRunning(device);
+ break;
+ case 3:
+ Device_IsOpen(device);
+ break;
+ case 4:
+ IDDevice_Close(device);
+ break;
+ default:
+ break;
+ }
+ system("pause");
+ }
+ }
+ }
+
+
+ static IDViewerCallBack callbackDelegate;
+ static IDDecodeInfo decodeInfo;
+
+ public static void CallBack(IntPtr device, IntPtr image, IntPtr decodeInfoHandel)
+ {
+ IDDecodeInfo info = new IDDecodeInfo();
+ IDCallback_GetIDDecodeInfo_A(decodeInfoHandel, ref info); //ROI瑙g爜淇℃伅鏁扮粍鐨勯暱搴� 鑾峰彇鍒癛OI鐨勮В鐮佹暟閲�
+
+ if (info.decodeStatus)
+ {
+ for (uint roi = 0; roi < info.IDDecodeROIInfoLength; roi++)
+ {
+ IDDecodeROIInfo IDpecodeROIInfo = IDCallback_GetIDDecodeROIInfo(decodeInfoHandel, 0);
+ if (IDpecodeROIInfo.decodeReusltLength > 0)
+ {
+ IDDecodeResult IDpecodeResult = IDCallback_GetIDDecodeResult(decodeInfoHandel, roi, 0);
+
+ if (IDpecodeResult.dmResultsLength != 0)
+ {
+ for (uint dmSuccessNumber = 0; dmSuccessNumber < IDpecodeResult.dmResultsLength; dmSuccessNumber++)
+ {
+ IDDMCodeResult DMBarCodeResultData = new IDDMCodeResult();
+ long a = IDCallback_GetIDDMCodeResult(decodeInfoHandel, roi, 0, dmSuccessNumber, ref DMBarCodeResultData);
+ Console.WriteLine("ROI锛�" + (roi + 1));
+ Console.WriteLine("SuccessNumber锛�" + (dmSuccessNumber + 1));
+ Console.WriteLine("subType锛�" + new string(DMBarCodeResultData.subType));
+ Console.WriteLine("codeString: " + new string(DMBarCodeResultData.codeString));
+ }
+ }
+ else if (IDpecodeResult.qrResultsLength != 0)
+ {
+ for (uint qrSuccessNumber = 0; qrSuccessNumber < IDpecodeResult.qrResultsLength; qrSuccessNumber++)
+ {
+ IDQRCodeResult QRBarCodeResultData = new IDQRCodeResult();
+ long a = IDCallback_GetID_QR_CODE_Result(decodeInfoHandel, roi, 0, qrSuccessNumber, ref QRBarCodeResultData);
+ Console.WriteLine("ROI锛�" + (roi + 1));
+ Console.WriteLine("SuccessNumber锛�" + (qrSuccessNumber + 1));
+ Console.WriteLine("subType锛�" + new string(QRBarCodeResultData.subType));
+ Console.WriteLine("codeString: " + new string(QRBarCodeResultData.codeString));
+ }
+ }
+ else if (IDpecodeResult.pdf417ResultsLength != 0)
+ {
+ for (uint pdf417SuccessNumber = 0; pdf417SuccessNumber < IDpecodeResult.qrResultsLength; pdf417SuccessNumber++)
+ {
+ IDPDF417CodeResult PDF417BarCodeResultData = new IDPDF417CodeResult();
+ long a = IDCallback_GetIDPDF417CodeResult(decodeInfoHandel, roi, 0, pdf417SuccessNumber, ref PDF417BarCodeResultData);
+ Console.WriteLine("ROI锛�" + (roi + 1));
+ Console.WriteLine("SuccessNumber锛�" + (pdf417SuccessNumber + 1));
+ Console.WriteLine("subType锛�" + new string(PDF417BarCodeResultData.subType));
+ Console.WriteLine("codeString: " + new string(PDF417BarCodeResultData.codeString));
+ }
+ }
+ else if (IDpecodeResult.barcodeResultsLength != 0)
+ {
+ for (uint barcodeSuccessNumber = 0; barcodeSuccessNumber < IDpecodeResult.qrResultsLength; barcodeSuccessNumber++)
+ {
+ IDBarCodeResult IDBarCodeResultData = new IDBarCodeResult();
+ long a = IDCallback_GetIDBarCodeResult(decodeInfoHandel, roi, 0, barcodeSuccessNumber, ref IDBarCodeResultData);
+ Console.WriteLine("ROI锛�" + (roi + 1));
+ Console.WriteLine("SuccessNumber锛�" + (barcodeSuccessNumber + 1));
+ Console.WriteLine("codeString: " + new string(IDBarCodeResultData.codeString));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ static void Device_StartRunning(IntPtr device)
+ {
+
+ IDDevice_StartRunning(device,1);
+ callbackDelegate = new IDViewerCallBack(CallBack);
+ IntPtr functionPointer = Marshal.GetFunctionPointerForDelegate(callbackDelegate);
+ IDCallback_ResultNotify_(device, functionPointer);
+ GC.KeepAlive(callbackDelegate);
+ }
+ static void Device_IsOpen(IntPtr device)
+ {
+ long rel = IDDevice_IsOpen(device);
+ if (rel == 0)
+ {
+ Console.WriteLine("璇荤爜鍣ㄦ湭鎵撳紑");
+ }
+ else
+ {
+ Console.WriteLine("璇荤爜鍣ㄥ凡鎵撳紑");
+ }
+ }
+
+ static bool GetInputOption(ref int option)
+ {
+ int op;
+ try
+ {
+ op = int.Parse(Console.ReadLine());
+ }
+ catch
+ {
+ return false;
+ }
+ option = op;
+ return true;
+ }
+ static void ClearScreen()
+ {
+ system("cls");
+ Console.WriteLine("*******************************************");
+ Console.WriteLine("* IDViewer Demo *");
+ Console.WriteLine("*******************************************");
+ }
+
+ [DllImport("msvcrt.dll", SetLastError = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
+ private extern static void system(string command);
+ }
+}
diff --git a/IDViewer_2D/Properties/AssemblyInfo.cs b/IDViewer_2D/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..fe35783
--- /dev/null
+++ b/IDViewer_2D/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+锘縰sing System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// 鏈夊叧绋嬪簭闆嗙殑涓�鑸俊鎭敱浠ヤ笅
+// 鎺у埗銆傛洿鏀硅繖浜涚壒鎬у�煎彲淇敼
+// 涓庣▼搴忛泦鍏宠仈鐨勪俊鎭��
+[assembly: AssemblyTitle("SmartScanner")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("SmartScanner")]
+[assembly: AssemblyCopyright("Copyright 漏 2024")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 灏� ComVisible 璁剧疆涓� false 浼氫娇姝ょ▼搴忛泦涓殑绫诲瀷
+//瀵� COM 缁勪欢涓嶅彲瑙併�傚鏋滈渶瑕佷粠 COM 璁块棶姝ょ▼搴忛泦涓殑绫诲瀷
+//璇峰皢姝ょ被鍨嬬殑 ComVisible 鐗规�ц缃负 true銆�
+[assembly: ComVisible(false)]
+
+//鑻ヨ寮�濮嬬敓鎴愬彲鏈湴鍖栫殑搴旂敤绋嬪簭锛岃璁剧疆
+//.csproj 鏂囦欢涓殑 <UICulture>CultureYouAreCodingWith</UICulture>
+//渚嬪锛屽鏋滄偍鍦ㄦ簮鏂囦欢涓娇鐢ㄧ殑鏄編鍥借嫳璇紝
+//浣跨敤鐨勬槸缇庡浗鑻辫锛岃灏� <UICulture> 璁剧疆涓� en-US銆� 鐒跺悗鍙栨秷
+//瀵逛互涓� NeutralResourceLanguage 鐗规�х殑娉ㄩ噴銆� 鏇存柊
+//浠ヤ笅琛屼腑鐨勨�渆n-US鈥濅互鍖归厤椤圭洰鏂囦欢涓殑 UICulture 璁剧疆銆�
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //涓婚鐗瑰畾璧勬簮璇嶅吀鎵�澶勪綅缃�
+ //(鏈湪椤甸潰涓壘鍒拌祫婧愭椂浣跨敤锛�
+ //鎴栧簲鐢ㄧ▼搴忚祫婧愬瓧鍏镐腑鎵惧埌鏃朵娇鐢�)
+ ResourceDictionaryLocation.SourceAssembly //甯歌璧勬簮璇嶅吀鎵�澶勪綅缃�
+ //(鏈湪椤甸潰涓壘鍒拌祫婧愭椂浣跨敤锛�
+ //銆佸簲鐢ㄧ▼搴忔垨浠讳綍涓婚涓撶敤璧勬簮瀛楀吀涓壘鍒版椂浣跨敤)
+)]
+
+
+// 绋嬪簭闆嗙殑鐗堟湰淇℃伅鐢变笅鍒楀洓涓�肩粍鎴�:
+//
+// 涓荤増鏈�
+// 娆$増鏈�
+// 鐢熸垚鍙�
+// 淇鍙�
+//
+//鍙互鎸囧畾鎵�鏈夎繖浜涘�硷紝涔熷彲浠ヤ娇鐢ㄢ�滅敓鎴愬彿鈥濆拰鈥滀慨璁㈠彿鈥濈殑榛樿鍊�
+//閫氳繃浣跨敤 "*"锛屽涓嬫墍绀�:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/IDViewer_2D/Properties/Resources.Designer.cs b/IDViewer_2D/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..acdf678
--- /dev/null
+++ b/IDViewer_2D/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+锘�//------------------------------------------------------------------------------
+// <auto-generated>
+// 姝や唬鐮佺敱宸ュ叿鐢熸垚銆�
+// 杩愯鏃剁増鏈�:4.0.30319.42000
+//
+// 瀵规鏂囦欢鐨勬洿鏀瑰彲鑳戒細瀵艰嚧涓嶆纭殑琛屼负锛屽苟涓斿鏋�
+// 閲嶆柊鐢熸垚浠g爜锛岃繖浜涙洿鏀瑰皢浼氫涪澶便��
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace SmartScanner.Properties {
+ using System;
+
+
+ /// <summary>
+ /// 涓�涓己绫诲瀷鐨勮祫婧愮被锛岀敤浜庢煡鎵炬湰鍦板寲鐨勫瓧绗︿覆绛夈��
+ /// </summary>
+ // 姝ょ被鏄敱 StronglyTypedResourceBuilder
+ // 绫婚�氳繃绫讳技浜� ResGen 鎴� Visual Studio 鐨勫伐鍏疯嚜鍔ㄧ敓鎴愮殑銆�
+ // 鑻ヨ娣诲姞鎴栫Щ闄ゆ垚鍛橈紝璇风紪杈� .ResX 鏂囦欢锛岀劧鍚庨噸鏂拌繍琛� ResGen
+ // (浠� /str 浣滀负鍛戒护閫夐」)锛屾垨閲嶆柊鐢熸垚 VS 椤圭洰銆�
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ /// <summary>
+ /// 杩斿洖姝ょ被浣跨敤鐨勭紦瀛樼殑 ResourceManager 瀹炰緥銆�
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SmartScanner.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// 閲嶅啓褰撳墠绾跨▼鐨� CurrentUICulture 灞炴�э紝瀵�
+ /// 浣跨敤姝ゅ己绫诲瀷璧勬簮绫荤殑鎵�鏈夎祫婧愭煡鎵炬墽琛岄噸鍐欍��
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/IDViewer_2D/Properties/Resources.resx b/IDViewer_2D/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/IDViewer_2D/Properties/Resources.resx
@@ -0,0 +1,117 @@
+锘�<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
diff --git a/IDViewer_2D/Properties/Settings.Designer.cs b/IDViewer_2D/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..3fc51d7
--- /dev/null
+++ b/IDViewer_2D/Properties/Settings.Designer.cs
@@ -0,0 +1,182 @@
+锘�//------------------------------------------------------------------------------
+// <auto-generated>
+// 姝や唬鐮佺敱宸ュ叿鐢熸垚銆�
+// 杩愯鏃剁増鏈�:4.0.30319.42000
+//
+// 瀵规鏂囦欢鐨勬洿鏀瑰彲鑳戒細瀵艰嚧涓嶆纭殑琛屼负锛屽苟涓斿鏋�
+// 閲嶆柊鐢熸垚浠g爜锛岃繖浜涙洿鏀瑰皢浼氫涪澶便��
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace SmartScanner.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string LastConfigFilePath {
+ get {
+ return ((string)(this["LastConfigFilePath"]));
+ }
+ set {
+ this["LastConfigFilePath"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string DataSavingRoad {
+ get {
+ return ((string)(this["DataSavingRoad"]));
+ }
+ set {
+ this["DataSavingRoad"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool ImageDeleteEnabled {
+ get {
+ return ((bool)(this["ImageDeleteEnabled"]));
+ }
+ set {
+ this["ImageDeleteEnabled"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("30")]
+ public int DeleteImageDays {
+ get {
+ return ((int)(this["DeleteImageDays"]));
+ }
+ set {
+ this["DeleteImageDays"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool ImageSaveEnabled {
+ get {
+ return ((bool)(this["ImageSaveEnabled"]));
+ }
+ set {
+ this["ImageSaveEnabled"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public int CompressionRatio {
+ get {
+ return ((int)(this["CompressionRatio"]));
+ }
+ set {
+ this["CompressionRatio"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public int ImageFormatSelect {
+ get {
+ return ((int)(this["ImageFormatSelect"]));
+ }
+ set {
+ this["ImageFormatSelect"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("20")]
+ public int MemoryAlarmSetting {
+ get {
+ return ((int)(this["MemoryAlarmSetting"]));
+ }
+ set {
+ this["MemoryAlarmSetting"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool MemoryAlarmEnabled {
+ get {
+ return ((bool)(this["MemoryAlarmEnabled"]));
+ }
+ set {
+ this["MemoryAlarmEnabled"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool OutputCheckBoxEnable {
+ get {
+ return ((bool)(this["OutputCheckBoxEnable"]));
+ }
+ set {
+ this["OutputCheckBoxEnable"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("\"8080\"")]
+ public string DefaultPort {
+ get {
+ return ((string)(this["DefaultPort"]));
+ }
+ set {
+ this["DefaultPort"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("8080")]
+ public int SelectedPort {
+ get {
+ return ((int)(this["SelectedPort"]));
+ }
+ set {
+ this["SelectedPort"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string LastConfigFilePath_Proj {
+ get {
+ return ((string)(this["LastConfigFilePath_Proj"]));
+ }
+ set {
+ this["LastConfigFilePath_Proj"] = value;
+ }
+ }
+ }
+}
diff --git a/IDViewer_2D/Properties/Settings.settings b/IDViewer_2D/Properties/Settings.settings
new file mode 100644
index 0000000..7f5c6e1
--- /dev/null
+++ b/IDViewer_2D/Properties/Settings.settings
@@ -0,0 +1,45 @@
+锘�<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="SmartScanner.Properties" GeneratedClassName="Settings">
+ <Profiles />
+ <Settings>
+ <Setting Name="LastConfigFilePath" Type="System.String" Scope="User">
+ <Value Profile="(Default)" />
+ </Setting>
+ <Setting Name="DataSavingRoad" Type="System.String" Scope="User">
+ <Value Profile="(Default)" />
+ </Setting>
+ <Setting Name="ImageDeleteEnabled" Type="System.Boolean" Scope="User">
+ <Value Profile="(Default)">False</Value>
+ </Setting>
+ <Setting Name="DeleteImageDays" Type="System.Int32" Scope="User">
+ <Value Profile="(Default)">30</Value>
+ </Setting>
+ <Setting Name="ImageSaveEnabled" Type="System.Boolean" Scope="User">
+ <Value Profile="(Default)">True</Value>
+ </Setting>
+ <Setting Name="CompressionRatio" Type="System.Int32" Scope="User">
+ <Value Profile="(Default)">0</Value>
+ </Setting>
+ <Setting Name="ImageFormatSelect" Type="System.Int32" Scope="User">
+ <Value Profile="(Default)">0</Value>
+ </Setting>
+ <Setting Name="MemoryAlarmSetting" Type="System.Int32" Scope="User">
+ <Value Profile="(Default)">20</Value>
+ </Setting>
+ <Setting Name="MemoryAlarmEnabled" Type="System.Boolean" Scope="User">
+ <Value Profile="(Default)">False</Value>
+ </Setting>
+ <Setting Name="OutputCheckBoxEnable" Type="System.Boolean" Scope="User">
+ <Value Profile="(Default)">False</Value>
+ </Setting>
+ <Setting Name="DefaultPort" Type="System.String" Scope="User">
+ <Value Profile="(Default)">"8080"</Value>
+ </Setting>
+ <Setting Name="SelectedPort" Type="System.Int32" Scope="User">
+ <Value Profile="(Default)">8080</Value>
+ </Setting>
+ <Setting Name="LastConfigFilePath_Proj" Type="System.String" Scope="User">
+ <Value Profile="(Default)" />
+ </Setting>
+ </Settings>
+</SettingsFile>
\ No newline at end of file
diff --git a/IDViewer_2D/ResultJudge.xaml b/IDViewer_2D/ResultJudge.xaml
new file mode 100644
index 0000000..be57d30
--- /dev/null
+++ b/IDViewer_2D/ResultJudge.xaml
@@ -0,0 +1,68 @@
+锘�<Window x:Class="SmartScanner.ResultJudge"
+ 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:SmartScanner"
+ mc:Ignorable="d"
+ Title="妫�娴嬫柟妗堢紪杈�" Height="600" Width="450">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="1*"/>
+ <RowDefinition Height="15*"/>
+ <RowDefinition Height="1*"/>
+ </Grid.RowDefinitions>
+
+ <TextBlock Grid.Row="0" Text="妫�娴嬫柟妗堢紪杈戝櫒" FontSize="16" FontWeight="Bold" Margin="0,0,0,10"/>
+
+ <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
+ <ItemsControl ItemsSource="{Binding JudgmentPoints}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <Border BorderBrush="LightGray" BorderThickness="1" Margin="0,5" Padding="10">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+
+ <TextBlock Grid.Column="0" Text="{Binding PointNumber}"
+ FontWeight="Bold" VerticalAlignment="Center" Margin="0,0,10,0"/>
+
+ <StackPanel Grid.Column="1">
+ <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
+ <TextBlock Text="鐩爣鏁伴噺:" Width="80"/>
+ <ComboBox ItemsSource="{Binding DataContext.TargetCountOptions, RelativeSource={RelativeSource AncestorType=Window}}"
+ SelectedItem="{Binding TargetCount}" Width="50"/>
+ </StackPanel>
+
+ <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
+ <TextBlock Text="寰楀垎闃堝��:" Width="80"/>
+ <TextBox Text="{Binding ScoreThreshold}" Width="50"/>
+ </StackPanel>
+
+ <ItemsControl ItemsSource="{Binding TargetConditions}" Margin="10,0,0,0">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
+ <TextBlock Text="鐩爣绫诲瀷:" Width="80"/>
+ <ComboBox ItemsSource="{Binding DataContext.TargetTypeOptions, RelativeSource={RelativeSource AncestorType=Window}}"
+ SelectedItem="{Binding TargetType}" Width="50"/>
+ </StackPanel>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </StackPanel>
+ </Grid>
+ </Border>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </ScrollViewer>
+
+ <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,0,0">
+ <Button x:Name="LoadConfig_RJ" Content="鍔犺浇閰嶇疆" Width="80" Margin="0,0,10,0" Command="{Binding LoadCommand}"/>
+ <Button x:Name="SaveConfig_RJ" Content="淇濆瓨閰嶇疆" Width="80" Command="{Binding SaveCommand}"/>
+ </StackPanel>
+ </Grid>
+</Window>
diff --git a/IDViewer_2D/ResultJudge.xaml.cs b/IDViewer_2D/ResultJudge.xaml.cs
new file mode 100644
index 0000000..7819dfa
--- /dev/null
+++ b/IDViewer_2D/ResultJudge.xaml.cs
@@ -0,0 +1,384 @@
+锘縰sing System;
+using System.Linq;
+using System.Windows;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.Windows.Input;
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using SmartScanner.OperateLog;
+
+namespace SmartScanner
+{
+ public partial class ResultJudge : Window
+ {
+ public static class AppSettings
+ {
+ private static readonly string SettingsKey = "LastConfigFilePath";
+
+ public static string LastConfigFilePath
+ {
+ get => Properties.Settings.Default.LastConfigFilePath ?? string.Empty;
+ set
+ {
+ Properties.Settings.Default.LastConfigFilePath = value;
+ Properties.Settings.Default.Save();
+ }
+ }
+
+ private static readonly string SettingsKey_Proj = "LastConfigFilePath_Proj";
+
+ public static string LastConfigFilePath_Proj
+ {
+ get => Properties.Settings.Default.LastConfigFilePath_Proj ?? string.Empty;
+ set
+ {
+ Properties.Settings.Default.LastConfigFilePath_Proj = value;
+ Properties.Settings.Default.Save();
+ }
+ }
+ }
+ public ResultJudgeViewModel ViewModel { get; set; }
+
+ public ResultJudge()
+ {
+ InitializeComponent();
+ ViewModel = new ResultJudgeViewModel();
+ DataContext = ViewModel;
+ }
+
+ public void SetControlsEnabled(bool isEnabled)
+ {
+ SaveConfig_RJ.IsEnabled = isEnabled;
+ }
+
+ public class ResultJudgeViewModel : BaseViewModel
+ {
+ public ObservableCollection<int> TargetCountOptions { get; } = new ObservableCollection<int> { 0, 1, 2, 3, 4 };
+ public ObservableCollection<int> TargetTypeOptions { get; } = new ObservableCollection<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
+
+ public ObservableCollection<JudgmentPoint> JudgmentPoints { get; set; } = new ObservableCollection<JudgmentPoint>();
+
+ public ICommand SaveCommand { get; }
+ public ICommand LoadCommand { get; }
+
+ public ResultJudgeViewModel()
+ {
+ // 鍒濆鍖�20涓偣浣�
+ for (int i = 1; i <= 20; i++)
+ {
+ JudgmentPoints.Add(new JudgmentPoint(i, this));
+ }
+
+ SaveCommand = new RelayCommand(SaveConfiguration);
+ LoadCommand = new RelayCommand(LoadConfiguration);
+ }
+
+ private void SaveConfiguration()
+ {
+ try
+ {
+ var config = JudgmentConfiguration.FromViewModel(this);
+ var json = JsonConvert.SerializeObject(config, Formatting.Indented);
+
+ var saveFileDialog = new Microsoft.Win32.SaveFileDialog
+ {
+ Filter = "JSON 鏂囦欢 (*.json)|*.json|鎵�鏈夋枃浠� (*.*)|*.*",
+ DefaultExt = ".json",
+ AddExtension = true,
+ Title = "淇濆瓨閰嶇疆鏂囦欢",
+ FileName = Properties.Settings.Default.LastConfigFilePath
+ };
+
+ if (saveFileDialog.ShowDialog() == true)
+ {
+ File.WriteAllText(saveFileDialog.FileName, json);
+ Properties.Settings.Default.LastConfigFilePath = saveFileDialog.FileName;
+ Properties.Settings.Default.Save();
+ MessageBox.Show($"閰嶇疆宸叉垚鍔熶繚瀛樺埌: {saveFileDialog.FileName}", "鎴愬姛", MessageBoxButton.OK, MessageBoxImage.Information);
+ OperateLogService.LogOperation("妫�娴嬫柟妗堜慨鏀�", $"妫�娴嬫柟妗堜慨鏀逛负: {saveFileDialog.FileName}", null);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"淇濆瓨閰嶇疆鏃跺嚭閿�: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void LoadConfiguration()
+ {
+ try
+ {
+ var openFileDialog = new Microsoft.Win32.OpenFileDialog
+ {
+ Filter = "JSON 鏂囦欢 (*.json)|*.json|鎵�鏈夋枃浠� (*.*)|*.*",
+ DefaultExt = ".json",
+ Title = "鍔犺浇閰嶇疆鏂囦欢",
+ FileName = AppSettings.LastConfigFilePath
+ };
+
+ if (openFileDialog.ShowDialog() == true)
+ {
+ var json = File.ReadAllText(openFileDialog.FileName);
+ AppSettings.LastConfigFilePath = openFileDialog.FileName;
+ var config = JsonConvert.DeserializeObject<JudgmentConfiguration>(json);
+
+ // 浣跨敤淇敼鍚庣殑ToViewModel鏂规硶
+ JudgmentConfiguration.ToViewModel(config, this);
+
+ MessageBox.Show($"閰嶇疆宸叉垚鍔熶粠 {openFileDialog.FileName} 鍔犺浇", "鎴愬姛", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"鍔犺浇閰嶇疆鏃跺嚭閿�: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+ }
+
+ public class JudgmentPoint : BaseViewModel
+ {
+ private readonly ResultJudgeViewModel _parent;
+ public int PointNumber { get; }
+
+ private int _targetCount;
+ public int TargetCount
+ {
+ get => _targetCount;
+ set
+ {
+ if (SetProperty(ref _targetCount, value))
+ {
+ UpdateTargetConditions();
+ }
+ }
+ }
+
+ private int _scoreThreshold;
+ public int ScoreThreshold
+ {
+ get => _scoreThreshold;
+ set
+ {
+ if (SetProperty(ref _scoreThreshold, value))
+ {
+ foreach (var condition in TargetConditions)
+ {
+ condition.ScoreThreshold = value;
+ }
+ }
+ }
+ }
+
+ public ObservableCollection<TargetCondition> TargetConditions { get; } = new ObservableCollection<TargetCondition>();
+
+ public JudgmentPoint(int pointNumber, ResultJudgeViewModel parent)
+ {
+ PointNumber = pointNumber;
+ _parent = parent;
+ TargetCount = 0;
+ }
+
+ private void UpdateTargetConditions()
+ {
+ // 鍙坊鍔犵己灏戠殑鏉′欢锛屼笉鍒犻櫎宸叉湁鏉′欢
+ int currentCount = TargetConditions.Count;
+ if (currentCount < TargetCount)
+ {
+ for (int i = currentCount; i < TargetCount; i++)
+ {
+ TargetConditions.Add(new TargetCondition
+ {
+ ScoreThreshold = this.ScoreThreshold
+ });
+ }
+ }
+ else if (currentCount > TargetCount)
+ {
+ // 鍙Щ闄ゅ浣欑殑鏉′欢
+ for (int i = currentCount - 1; i >= TargetCount; i--)
+ {
+ TargetConditions.RemoveAt(i);
+ }
+ }
+ }
+ }
+
+ public class TargetCondition : BaseViewModel
+ {
+ private int _targetType;
+ public int TargetType
+ {
+ get => _targetType;
+ set => SetProperty(ref _targetType, value);
+ }
+
+ [JsonIgnore]
+ public int ScoreThreshold { get; set; }
+ }
+
+ public class JudgmentConfiguration
+ {
+ public List<JudgmentPointData> Points { get; set; }
+
+ public static JudgmentConfiguration FromViewModel(ResultJudgeViewModel viewModel)
+ {
+ var config = new JudgmentConfiguration
+ {
+ Points = new List<JudgmentPointData>()
+ };
+
+ foreach (var point in viewModel.JudgmentPoints)
+ {
+ var pointData = new JudgmentPointData
+ {
+ PointNumber = point.PointNumber,
+ TargetCount = point.TargetCount,
+ Conditions = new List<TargetConditionData>()
+ };
+
+ foreach (var condition in point.TargetConditions)
+ {
+ pointData.Conditions.Add(new TargetConditionData
+ {
+ TargetType = condition.TargetType,
+ ScoreThreshold = point.ScoreThreshold
+ });
+ }
+ config.Points.Add(pointData);
+ }
+ return config;
+ }
+
+ public static void ToViewModel(JudgmentConfiguration config, ResultJudgeViewModel viewModel)
+ {
+ // 鍏堟竻绌烘墍鏈夌偣浣�
+ viewModel.JudgmentPoints.Clear();
+
+ // 閲嶆柊鍒涘缓鐐逛綅骞跺姞杞介厤缃�
+ for (int i = 1; i <= 20; i++)
+ {
+ var pointData = config.Points.FirstOrDefault(p => p.PointNumber == i);
+ var point = new JudgmentPoint(i, viewModel);
+
+ if (pointData != null)
+ {
+ point.TargetCount = pointData.TargetCount;
+ point.ScoreThreshold = pointData.Conditions.FirstOrDefault()?.ScoreThreshold ?? 0;
+
+ // 娓呴櫎鑷姩鐢熸垚鐨勬潯浠�
+ point.TargetConditions.Clear();
+
+ // 娣诲姞閰嶇疆涓殑鏉′欢
+ foreach (var conditionData in pointData.Conditions)
+ {
+ point.TargetConditions.Add(new TargetCondition
+ {
+ TargetType = conditionData.TargetType,
+ ScoreThreshold = point.ScoreThreshold
+ });
+ }
+ }
+
+ viewModel.JudgmentPoints.Add(point);
+ }
+ }
+
+ public int JudgeDetectionResult(int pointNumber, int[] numBoxes, int[] classIds, float[] prob)
+ {
+ var pointConfig = Points.FirstOrDefault(p => p.PointNumber == pointNumber);
+ if (pointConfig == null) return 0;
+
+ // 绗竴灞傚垽鏂細鐩爣鏁伴噺
+ if (numBoxes[0] < pointConfig.TargetCount)
+ {
+ return 0;
+ }
+
+ // 绗簩灞傚垽鏂細鐩爣绫诲瀷
+ bool typeMatch = true;
+ switch (pointConfig.TargetCount)
+ {
+ case 0:
+ return 1;
+ case 1:
+ typeMatch = classIds.Contains(pointConfig.Conditions[0].TargetType);
+ break;
+ case 2:
+ typeMatch = classIds.Contains(pointConfig.Conditions[0].TargetType) &&
+ classIds.Contains(pointConfig.Conditions[1].TargetType);
+ break;
+ case 3:
+ typeMatch = classIds.Contains(pointConfig.Conditions[0].TargetType) &&
+ classIds.Contains(pointConfig.Conditions[1].TargetType) &&
+ classIds.Contains(pointConfig.Conditions[2].TargetType);
+ break;
+ case 4:
+ typeMatch = classIds.Contains(pointConfig.Conditions[0].TargetType) &&
+ classIds.Contains(pointConfig.Conditions[1].TargetType) &&
+ classIds.Contains(pointConfig.Conditions[2].TargetType) &&
+ classIds.Contains(pointConfig.Conditions[3].TargetType);
+ break;
+ }
+
+ if (!typeMatch)
+ {
+ return 0;
+ }
+
+ // 绗笁灞傚垽鏂細寰楀垎闃堝�硷紙浣跨敤绗竴涓潯浠剁殑闃堝�硷級
+ float threshold = pointConfig.Conditions[0].ScoreThreshold / 100f;
+ return prob.Take(pointConfig.TargetCount).All(p => p >= threshold) ? 1 : 0;
+ }
+ }
+
+ public class JudgmentPointData
+ {
+ public int PointNumber { get; set; }
+ public int TargetCount { get; set; }
+ public List<TargetConditionData> Conditions { get; set; }
+ }
+
+ public class TargetConditionData
+ {
+ public int TargetType { get; set; }
+ public int ScoreThreshold { get; set; }
+ }
+
+ public class BaseViewModel : System.ComponentModel.INotifyPropertyChanged
+ {
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected bool SetProperty<T>(ref T field, T value, [System.Runtime.CompilerServices.CallerMemberName] string propertyName = null)
+ {
+ if (EqualityComparer<T>.Default.Equals(field, value)) return false;
+ field = value;
+ PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ return true;
+ }
+ }
+
+ public class RelayCommand : ICommand
+ {
+ private readonly Action _execute;
+ private readonly Func<bool> _canExecute;
+
+ public event EventHandler CanExecuteChanged
+ {
+ add { CommandManager.RequerySuggested += value; }
+ remove { CommandManager.RequerySuggested -= value; }
+ }
+
+ public RelayCommand(Action execute, Func<bool> canExecute = null)
+ {
+ _execute = execute ?? throw new ArgumentNullException(nameof(execute));
+ _canExecute = canExecute;
+ }
+
+ public bool CanExecute(object parameter) => _canExecute?.Invoke() ?? true;
+
+ public void Execute(object parameter) => _execute();
+ }
+ }
+}
+
diff --git a/IDViewer_2D/Settings.cs b/IDViewer_2D/Settings.cs
new file mode 100644
index 0000000..59719b7
--- /dev/null
+++ b/IDViewer_2D/Settings.cs
@@ -0,0 +1,28 @@
+锘縩amespace SmartScanner.Properties {
+
+
+ // 閫氳繃姝ょ被鍙互澶勭悊璁剧疆绫荤殑鐗瑰畾浜嬩欢:
+ // 鍦ㄦ洿鏀规煇涓缃殑鍊间箣鍓嶅皢寮曞彂 SettingChanging 浜嬩欢銆�
+ // 鍦ㄦ洿鏀规煇涓缃殑鍊间箣鍚庡皢寮曞彂 PropertyChanged 浜嬩欢銆�
+ // 鍦ㄥ姞杞借缃�间箣鍚庡皢寮曞彂 SettingsLoaded 浜嬩欢銆�
+ // 鍦ㄤ繚瀛樿缃�间箣鍓嶅皢寮曞彂 SettingsSaving 浜嬩欢銆�
+ internal sealed partial class Settings {
+
+ public Settings() {
+ // // 鑻ヨ涓轰繚瀛樺拰鏇存敼璁剧疆娣诲姞浜嬩欢澶勭悊绋嬪簭锛岃鍙栨秷娉ㄩ噴涓嬪垪琛�:
+ //
+ // this.SettingChanging += this.SettingChangingEventHandler;
+ //
+ // this.SettingsSaving += this.SettingsSavingEventHandler;
+ //
+ }
+
+ private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
+ // 鍦ㄦ澶勬坊鍔犵敤浜庡鐞� SettingChangingEvent 浜嬩欢鐨勪唬鐮併��
+ }
+
+ private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
+ // 鍦ㄦ澶勬坊鍔犵敤浜庡鐞� SettingsSaving 浜嬩欢鐨勪唬鐮併��
+ }
+ }
+}
diff --git a/IDViewer_2D/SmartScanner.csproj b/IDViewer_2D/SmartScanner.csproj
new file mode 100644
index 0000000..79cc5ef
--- /dev/null
+++ b/IDViewer_2D/SmartScanner.csproj
@@ -0,0 +1,365 @@
+锘�<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\packages\OpenCvSharp4.runtime.win.4.10.0.20240616\build\netstandard\OpenCvSharp4.runtime.win.props" Condition="Exists('..\packages\OpenCvSharp4.runtime.win.4.10.0.20240616\build\netstandard\OpenCvSharp4.runtime.win.props')" />
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{D1C98439-DD40-43CD-BC99-899868FD2EDF}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <RootNamespace>SmartScanner</RootNamespace>
+ <AssemblyName>SmartScanner</AssemblyName>
+ <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <WarningLevel>4</WarningLevel>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <Deterministic>true</Deterministic>
+ <NuGetPackageImportStamp>
+ </NuGetPackageImportStamp>
+ <TargetFrameworkProfile />
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <LangVersion>7.3</LangVersion>
+ <ErrorReport>prompt</ErrorReport>
+ <Prefer32Bit>true</Prefer32Bit>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <OutputPath>bin\x64\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <LangVersion>7.3</LangVersion>
+ <ErrorReport>prompt</ErrorReport>
+ <Prefer32Bit>true</Prefer32Bit>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject />
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <LangVersion>7.3</LangVersion>
+ <ErrorReport>prompt</ErrorReport>
+ <Prefer32Bit>true</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <LangVersion>7.3</LangVersion>
+ <ErrorReport>prompt</ErrorReport>
+ <Prefer32Bit>true</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup>
+ <ApplicationIcon>IDViewer2D.ico</ApplicationIcon>
+ </PropertyGroup>
+ <PropertyGroup />
+ <PropertyGroup />
+ <ItemGroup>
+ <Reference Include="EPPlus, Version=8.0.7.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>bin\x64\Debug\EPPlus.dll</HintPath>
+ </Reference>
+ <Reference Include="EPPlus.Interfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=a694d7f3b0907a61, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>bin\x64\Debug\EPPlus.Interfaces.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.3.0.1\lib\netstandard2.0\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
+ </Reference>
+ <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="NModbus, Version=3.0.81.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>bin\x64\Debug\NModbus.dll</HintPath>
+ </Reference>
+ <Reference Include="OpenCvSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
+ <HintPath>..\packages\OpenCvSharp4.4.10.0.20241108\lib\netstandard2.0\OpenCvSharp.dll</HintPath>
+ </Reference>
+ <Reference Include="OpenCvSharp.Extensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
+ <HintPath>..\packages\OpenCvSharp4.Extensions.4.10.0.20241108\lib\netstandard2.0\OpenCvSharp.Extensions.dll</HintPath>
+ </Reference>
+ <Reference Include="OpenCvSharp.WpfExtensions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\packages\OpenCvSharp4.WpfExtensions.4.5.1.20210210\lib\net461\OpenCvSharp.WpfExtensions.dll</HintPath>
+ </Reference>
+ <Reference Include="Syncfusion.Compression.Portable, Version=29.1.37.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
+ <HintPath>..\packages\Syncfusion.Compression.Net.Core.29.1.37\lib\netstandard2.0\Syncfusion.Compression.Portable.dll</HintPath>
+ </Reference>
+ <Reference Include="Syncfusion.Licensing, Version=29.1462.37.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
+ <HintPath>..\packages\Syncfusion.Licensing.29.1.37\lib\net462\Syncfusion.Licensing.dll</HintPath>
+ </Reference>
+ <Reference Include="Syncfusion.OfficeChart.Portable, Version=29.1.37.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
+ <HintPath>..\packages\Syncfusion.OfficeChart.Net.Core.29.1.37\lib\netstandard2.0\Syncfusion.OfficeChart.Portable.dll</HintPath>
+ </Reference>
+ <Reference Include="Syncfusion.Presentation.Portable, Version=29.1.37.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
+ <HintPath>..\packages\Syncfusion.Presentation.Net.Core.29.1.37\lib\netstandard2.0\Syncfusion.Presentation.Portable.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
+ </Reference>
+ <Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
+ </Reference>
+ <Reference Include="System.ComponentModel.DataAnnotations" />
+ <Reference Include="System.configuration" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.IO.Compression.FileSystem" />
+ <Reference Include="System.Management" />
+ <Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Numerics" />
+ <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Security" />
+ <Reference Include="System.Security.Cryptography.Xml, Version=8.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Security.Cryptography.Xml.8.0.2\lib\net462\System.Security.Cryptography.Xml.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xaml">
+ <RequiredTargetFramework>4.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="WindowsBase" />
+ <Reference Include="PresentationCore" />
+ <Reference Include="PresentationFramework" />
+ <Reference Include="Xceed.Wpf.AvalonDock, Version=4.7.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+ <HintPath>..\packages\Extended.Wpf.Toolkit.4.7.25104.5739\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
+ </Reference>
+ <Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero, Version=4.7.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+ <HintPath>..\packages\Extended.Wpf.Toolkit.4.7.25104.5739\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
+ </Reference>
+ <Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro, Version=4.7.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+ <HintPath>..\packages\Extended.Wpf.Toolkit.4.7.25104.5739\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
+ </Reference>
+ <Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010, Version=4.7.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+ <HintPath>..\packages\Extended.Wpf.Toolkit.4.7.25104.5739\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
+ </Reference>
+ <Reference Include="Xceed.Wpf.Toolkit, Version=4.7.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+ <HintPath>..\packages\Extended.Wpf.Toolkit.4.7.25104.5739\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <ApplicationDefinition Include="App.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </ApplicationDefinition>
+ <Compile Include="AppRestartHelper.cs" />
+ <Compile Include="DownloadData.xaml.cs">
+ <DependentUpon>DownloadData.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="ExcelResultRecorder.cs" />
+ <Compile Include="ImageService\ImageCleanupService.cs" />
+ <Compile Include="ImageDisplayWindow .xaml.cs">
+ <DependentUpon>ImageDisplayWindow .xaml</DependentUpon>
+ </Compile>
+ <Compile Include="ImageService\MemoryAlarmCheck.cs" />
+ <Compile Include="LBProjService.cs" />
+ <Compile Include="LBProtect.cs" />
+ <Compile Include="LogAutoSaveService.cs" />
+ <Compile Include="LoginWindow.xaml.cs">
+ <DependentUpon>LoginWindow.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="OperateLog\OperateLogService.cs" />
+ <Compile Include="OperateLog\OperateLogView.xaml.cs">
+ <DependentUpon>OperateLogView.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="ResultJudge.xaml.cs">
+ <DependentUpon>ResultJudge.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="Settings.cs" />
+ <Compile Include="TcpServerManager.cs" />
+ <Compile Include="User.cs" />
+ <Compile Include="ViewModel\LogViewModel.cs" />
+ <Page Include="DownloadData.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="ImageDisplayWindow .xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="LoadingWindow.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="LoginWindow.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="MainWindow.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ <Compile Include="App.xaml.cs">
+ <DependentUpon>App.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="IDViewerDefines.cs" />
+ <Compile Include="IDViewerSDK.cs" />
+ <Compile Include="IDViewerSDK2.cs" />
+ <Compile Include="LoadingWindow.xaml.cs">
+ <DependentUpon>LoadingWindow.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="MainWindow.xaml.cs">
+ <DependentUpon>MainWindow.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ <Page Include="OperateLog\OperateLogView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="ProductManager.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="ResultJudge.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ModbusTCPClient.cs" />
+ <Compile Include="ProductManager.xaml.cs">
+ <DependentUpon>ProductManager.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="Properties\AssemblyInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ <None Include="packages.config" />
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="Image\Currency\logo.png" />
+ <Resource Include="Image\Currency\logo_01.png" />
+ <Resource Include="Image\Currency\logo_02.png" />
+ <Resource Include="Image\Currency\MTV3Dlogo.ico" />
+ <Resource Include="Image\Currency\鍒犻櫎.png" />
+ <Resource Include="Image\Currency\鍒锋柊.png" />
+ <Resource Include="Image\Currency\鍗曞紶鎶撳浘.png" />
+ <Resource Include="Image\Currency\瀛樺偍鍥剧墖.png" />
+ <Resource Include="Image\Currency\瀹d紶鍥�.png" />
+ <Resource Include="Image\Currency\寮�濮嬮噰闆�.jpg" />
+ <Resource Include="Image\Currency\鎵撳紑鏂囦欢.png" />
+ <Resource Include="Image\Currency\鏂紑.png" />
+ <Resource Include="Image\Currency\鏆傚仠.png" />
+ <Resource Include="Image\Currency\杩炴帴.png" />
+ <Resource Include="Image\Currency\杩炵画鎶撳浘.png" />
+ <Resource Include="Image\Currency\閲囬泦.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="IDViewer2D.ico" />
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include=".NETFramework,Version=v4.7.1">
+ <Visible>False</Visible>
+ <ProductName>Microsoft .NET Framework 4.7.1 %28x86 鍜� x64%29</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="Image\ICON\camera-switch-fill.png" />
+ <Resource Include="Image\ICON\folder-2-fill.png" />
+ <Resource Include="Image\ICON\folder-open-fill.png" />
+ <Resource Include="Image\ICON\import-fill.png" />
+ <Resource Include="Image\ICON\link-m.png" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+ <PropertyGroup>
+ <ErrorText>杩欏彴璁$畻鏈轰笂缂哄皯姝ら」鐩紩鐢ㄧ殑 NuGet 绋嬪簭鍖呫�備娇鐢ㄢ�淣uGet 绋嬪簭鍖呰繕鍘熲�濆彲涓嬭浇杩欎簺绋嬪簭鍖呫�傛湁鍏虫洿澶氫俊鎭紝璇峰弬瑙� http://go.microsoft.com/fwlink/?LinkID=322105銆傜己灏戠殑鏂囦欢鏄� {0}銆�</ErrorText>
+ </PropertyGroup>
+ <Error Condition="!Exists('..\packages\OpenCvSharp4.runtime.win.4.10.0.20240616\build\netstandard\OpenCvSharp4.runtime.win.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\OpenCvSharp4.runtime.win.4.10.0.20240616\build\netstandard\OpenCvSharp4.runtime.win.props'))" />
+ <Error Condition="!Exists('..\packages\NETStandard.Library.2.0.0\build\netstandard2.0\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.0\build\netstandard2.0\NETStandard.Library.targets'))" />
+ </Target>
+ <Import Project="..\packages\NETStandard.Library.2.0.0\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.0\build\netstandard2.0\NETStandard.Library.targets')" />
+</Project>
\ No newline at end of file
diff --git a/IDViewer_2D/TcpServerManager.cs b/IDViewer_2D/TcpServerManager.cs
new file mode 100644
index 0000000..f7c6a7c
--- /dev/null
+++ b/IDViewer_2D/TcpServerManager.cs
@@ -0,0 +1,272 @@
+锘縰sing SmartScanner.ViewModel;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace SmartScanner
+{
+ public class TcpServerManager : IDisposable
+ {
+ private TcpListener _listener;
+ public static bool _isRunning;
+ private CancellationTokenSource _cts;
+ private Func<Task<int[]>> _imageProcessingHandler; // 鍥惧儚澶勭悊濮旀墭
+ private int _outputIOCount; // 杈撳嚭IO鏁伴噺
+ // 蹇冭烦閰嶇疆
+ public bool EnableHeartbeat { get; private set; }
+ public string HeartbeatCommand { get; private set; }
+ public int HeartbeatInterval { get; private set; }
+
+ // 瀹㈡埛绔垪琛ㄧ鐞嗭紙濡傛灉闇�瑕佽窡韪涓鎴风锛�
+ // private ConcurrentDictionary<string, TcpClient> _connectedClients = new ConcurrentDictionary<string, TcpClient>();
+
+ public event Action<string> LogMessage;
+ public event Action<string, string> CommandReceived;
+ public event Action<string> ClientConnected;
+ public event Action<string> ClientDisconnected;
+
+ public TcpServerManager(bool enableHeartbeat, string heartbeatCommand, int heartbeatInterval,
+ Func<Task<int[]>> imageProcessingHandler, int outputIOCount)
+ {
+ EnableHeartbeat = enableHeartbeat;
+ HeartbeatCommand = heartbeatCommand ?? "heartBeat";
+ HeartbeatInterval = heartbeatInterval > 0 ? heartbeatInterval : 1000;
+ _imageProcessingHandler = imageProcessingHandler ?? throw new ArgumentNullException(nameof(imageProcessingHandler));
+ _outputIOCount = outputIOCount > 0 ? outputIOCount : 1;
+ }
+ /// <summary>
+ /// TCP鏈嶅姟鍣ㄥ紑濮嬩睛鍚�
+ /// </summary>
+ /// <param name="ip">鏈嶅姟鍣↖P鍦板潃</param>
+ /// <param name="port">鏈嶅姟鍣ㄧ鍙�</param>
+ public async Task StartAsync(string ip, int port)
+ {
+ if (port == -1) return;
+ _cts = new CancellationTokenSource();
+ _isRunning = true;
+ _listener = new TcpListener(IPAddress.Parse(ip), port);
+ _listener.Start();
+
+ LogMessage?.Invoke($"TCP鏈嶅姟鍣ㄥ凡鍚姩锛屽紑濮嬩睛鍚� {ip}:{port}");
+ LogMessage?.Invoke($"蹇冭烦妫�娴�: {(EnableHeartbeat ? "宸插惎鐢�" : "宸茬鐢�")}");
+ if (EnableHeartbeat)
+ {
+ LogMessage?.Invoke($"蹇冭烦鎸囦护: {HeartbeatCommand}, 闂撮殧: {HeartbeatInterval}ms");
+ }
+
+ try
+ {
+ while (_isRunning)
+ {
+ var acceptTask = _listener.AcceptTcpClientAsync();
+ var cancelTask = Task.Delay(-1, _cts.Token);
+
+ var completedTask = await Task.WhenAny(acceptTask, cancelTask);
+
+ if (completedTask == cancelTask || _cts.Token.IsCancellationRequested)
+ {
+ break;
+ }
+ var client = await acceptTask;
+ _ = HandleClientAsync(client);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogMessage?.Invoke($"鏈嶅姟鍣ㄩ敊璇�: {ex.Message}");
+ }
+ }
+
+ private async Task HandleClientAsync(TcpClient client)
+ {
+ var clientId = client.Client.RemoteEndPoint?.ToString() ?? "鏈煡瀹㈡埛绔�";
+ ClientConnected?.Invoke(clientId);
+ LogMessage?.Invoke($"瀹㈡埛绔凡杩炴帴: {clientId}");
+
+ try
+ {
+ using (client)
+ using (var stream = client.GetStream())
+ {
+ // 浣跨敤NetworkStream璇诲彇
+ byte[] buffer = new byte[4096];
+ MemoryStream ms = new MemoryStream();
+
+ while (!_cts.IsCancellationRequested && client.Connected)
+ {
+ // 妫�鏌ユ暟鎹槸鍚﹀彲鐢�
+ if (!stream.DataAvailable)
+ {
+ await Task.Delay(10, _cts.Token); // 鐭殏绛夊緟
+ continue;
+ }
+
+ // 鍚屾璇诲彇鏂瑰紡
+ int bytesRead = stream.Read(buffer, 0, buffer.Length);
+ if (bytesRead == 0) // 杩炴帴宸插叧闂�
+ {
+ LogMessage?.Invoke($"瀹㈡埛绔� {clientId} 姝e父鏂紑");
+ break;
+ }
+
+ ms.Write(buffer, 0, bytesRead);
+
+ // 澶勭悊瀹屾暣娑堟伅锛堟秷鎭互鎹㈣绗︾粨灏撅級
+ string receivedData = Encoding.ASCII.GetString(ms.ToArray());
+ //if (receivedData.Contains('\n'))
+ //{
+ string[] messages = receivedData.Split('\n');
+ for (int i = 0; i < messages.Length - 1; i++) // 鏈�鍚庝竴娈靛彲鑳戒笉瀹屾暣
+ {
+ string message = messages[i].Trim();
+ if (!string.IsNullOrEmpty(message))
+ {
+ await ProcessMessageAsync(message, stream, clientId);
+ }
+ }
+
+ // 淇濈暀涓嶅畬鏁寸殑閮ㄥ垎
+ ms.SetLength(0);
+ if (!string.IsNullOrEmpty(messages.Last()))
+ {
+ ms.Write(Encoding.ASCII.GetBytes(messages.Last()), 0, messages.Last().Length);
+ }
+ //}
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogMessage?.Invoke($"澶勭悊瀹㈡埛绔� {clientId} 鏃跺嚭閿�: {ex.Message}");
+ }
+ finally
+ {
+ ClientDisconnected?.Invoke(clientId);
+ LogMessage?.Invoke($"瀹㈡埛绔柇寮�: {clientId}");
+ }
+ }
+
+ private async Task ProcessMessageAsync(string message, NetworkStream stream, string clientId)
+ {
+ LogMessage?.Invoke($"鏉ヨ嚜 {clientId}: {message}");
+
+ Console.WriteLine($"{DateTime.Now:HH:mm:ss:fff}锛氭娴嬪埌瑙﹀彂淇″彿{message}");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氭娴嬪埌瑙﹀彂淇″彿{message}");
+ // 澶勭悊蹇冭烦
+ if (EnableHeartbeat && message == HeartbeatCommand)
+ {
+ byte[] ack = Encoding.ASCII.GetBytes($"{HeartbeatCommand}_ACK\n");
+ await stream.WriteAsync(ack, 0, ack.Length);
+ return;
+ }
+
+ // 澶勭悊涓氬姟娑堟伅
+ var parts = message.Split(',');
+ if (parts.Length >= 2 && int.TryParse(parts[0], out var functionCode))
+ {
+ // 澶勭悊瑙﹀彂淇″彿 (鏆傚畾鍔熻兘鐮佷负3锛屽緟鍚庣画涓庡鎴锋矡閫�)
+ if (functionCode == 3)
+ {
+ await HandleTriggerCommand(stream, clientId);
+ }
+ else
+ {
+ // 鍏朵粬鍔熻兘鐮佸鐞�
+ var response = $"{functionCode},0,Invalid function code\n";
+ byte[] responseBytes = Encoding.ASCII.GetBytes(response);
+ await stream.WriteAsync(responseBytes, 0, responseBytes.Length);
+ }
+ }
+ }
+ private async Task HandleTriggerCommand(NetworkStream stream, string clientId)
+ {
+ try
+ {
+ LogMessage?.Invoke($"寮�濮嬪鐞嗚Е鍙戝懡浠わ紝杩涜鍥惧儚閲囬泦鍜屾帹鐞�...");
+ // 璋冪敤鍥惧儚澶勭悊濮旀墭
+ int[] processingResults = await _imageProcessingHandler()
+ .ConfigureAwait(false); // 閬垮厤姝婚攣
+ if (processingResults == null || processingResults.Length != _outputIOCount)
+ {
+ throw new InvalidOperationException($"鍥惧儚澶勭悊缁撴灉鏃犳晥锛岄鏈焮_outputIOCount}涓緭鍑猴紝瀹為檯寰楀埌{processingResults?.Length ?? 0}");
+ }
+
+ // 鏋勫缓鍝嶅簲娑堟伅
+ var responseBuilder = new StringBuilder();
+ responseBuilder.Append("3,"); // 鍔熻兘鍙�
+ responseBuilder.Append(_outputIOCount); // 杈撳嚭IO鏁�
+
+ // 娣诲姞姣忎釜鐐逛綅鐨勫鐞嗙粨鏋�
+ foreach (var result in processingResults)
+ {
+ responseBuilder.Append($",{result}");
+ }
+
+ responseBuilder.Append("\n"); // 缁撴潫绗�
+
+ string response = responseBuilder.ToString();
+ LogMessage?.Invoke($"杩斿洖缁撴灉: {response.Trim()}");
+ EnhancedLogViewModel.Instance.AddLog($"{DateTime.Now:HH:mm:ss:fff}锛氭娴嬪畬鎴愶紝杩斿洖缁撴灉{response.Trim()}");
+ // 鍙戦�佸搷搴�
+ byte[] responseBytes = Encoding.ASCII.GetBytes(response);
+ await stream.WriteAsync(responseBytes, 0, responseBytes.Length);
+ }
+ catch (Exception ex)
+ {
+ LogMessage?.Invoke($"澶勭悊瑙﹀彂鍛戒护鏃跺嚭閿�: {ex.Message}");
+
+ // 鍙戦�侀敊璇搷搴�
+ var errorResponse = $"3,0,Error: {ex.Message}\n";
+ byte[] errorBytes = Encoding.ASCII.GetBytes(errorResponse);
+ await stream.WriteAsync(errorBytes, 0, errorBytes.Length);
+ }
+ }
+
+ private async Task StartHeartbeatAsync(StreamWriter writer, CancellationToken token)
+ {
+ try
+ {
+ while (!token.IsCancellationRequested)
+ {
+ await writer.WriteLineAsync(HeartbeatCommand);
+ await Task.Delay(HeartbeatInterval, token);
+ }
+ }
+ catch (OperationCanceledException)
+ {
+ // 姝e父鍙栨秷
+ }
+ catch (Exception ex)
+ {
+ LogMessage?.Invoke($"蹇冭烦浠诲姟閿欒: {ex.Message}");
+ }
+ }
+
+ public void Stop()
+ {
+ _isRunning = false;
+ _cts?.Cancel();
+ try
+ {
+ _listener?.Stop();
+ LogMessage?.Invoke("TCP鏈嶅姟鍣ㄥ凡鍋滄");
+ }
+ catch (Exception ex)
+ {
+ LogMessage?.Invoke($"鍋滄鏈嶅姟鍣ㄦ椂鍑洪敊: {ex.Message}");
+ }
+ }
+
+ public void Dispose()
+ {
+ Stop();
+ _cts?.Dispose();
+ }
+ }
+}
diff --git a/IDViewer_2D/User.cs b/IDViewer_2D/User.cs
new file mode 100644
index 0000000..c31e247
--- /dev/null
+++ b/IDViewer_2D/User.cs
@@ -0,0 +1,50 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SmartScanner
+{
+ public class User
+ {
+ public string Username { get; set; }
+ public string Password { get; set; }
+ public UserRole Role { get; set; }
+ }
+
+ public enum UserRole
+ {
+ Administrator,
+ Technician
+ }
+
+ public static class UserManager
+ {
+ public static List<User> UserList { get; } = new List<User>
+ {
+ new User { Username = "admin", Password = "123", Role = UserRole.Administrator },
+ //new User { Username = "admin2", Password = "admin456", Role = UserRole.Administrator },
+ //new User { Username = "tech1", Password = "tech123", Role = UserRole.Technician },
+ //new User { Username = "tech2", Password = "tech456", Role = UserRole.Technician }
+ };
+
+ public static User CurrentUser { get; private set; }
+
+ public static bool Authenticate(string username, string password)
+ {
+ var user = UserList.FirstOrDefault(u => u.Username == username && u.Password == password);
+ if (user != null)
+ {
+ CurrentUser = user;
+ return true;
+ }
+ return false;
+ }
+
+ public static bool HasAdministratorPrivilege()
+ {
+ return CurrentUser?.Role == UserRole.Administrator;
+ }
+ }
+}
diff --git a/IDViewer_2D/VersionHelper.cs b/IDViewer_2D/VersionHelper.cs
new file mode 100644
index 0000000..0fc27d0
--- /dev/null
+++ b/IDViewer_2D/VersionHelper.cs
@@ -0,0 +1,95 @@
+using System;
+using System.IO;
+using System.Text;
+using System.Windows;
+
+namespace IDViewer_2D
+{
+ public static class VersionHelper
+ {
+ public static void ShowVersionInfo()
+ {
+ try
+ {
+ string versionFile = "鐗堟湰璇存槑.txt";
+ if (!File.Exists(versionFile))
+ {
+ MessageBox.Show("鐗堟湰璇存槑鏂囦欢涓嶅瓨鍦�", "閿欒", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+
+ string[] lines = File.ReadAllLines(versionFile, Encoding.UTF8);
+ string latestVersion = "";
+ string latestDate = "";
+ StringBuilder changes = new StringBuilder();
+
+ // 浠庡悗鍚戝墠鏌ユ壘鏈�鏂扮増鏈�
+ for (int i = lines.Length - 1; i >= 0; i--)
+ {
+ string line = lines[i].Trim();
+
+ // 鏌ユ壘鐗堟湰琛� (鍖呭惈鏃ユ湡鍜寁鐗堟湰鍙�)
+ if (IsVersionLine(line))
+ {
+ ParseVersionLine(line, ref latestVersion, ref latestDate);
+
+ // 鏀堕泦鏇存柊鍐呭
+ for (int j = i + 1; j < lines.Length; j++)
+ {
+ string contentLine = lines[j].Trim();
+ if (string.IsNullOrEmpty(contentLine) || IsVersionLine(contentLine))
+ break;
+
+ changes.AppendLine(contentLine);
+ if (j - i > 8) break; // 鏈�澶�8琛�
+ }
+ break;
+ }
+ }
+
+ if (string.IsNullOrEmpty(latestVersion))
+ {
+ MessageBox.Show("鏈壘鍒扮増鏈俊鎭�", "鎻愮ず", MessageBoxButton.OK, MessageBoxImage.Information);
+ return;
+ }
+
+ string message = $"褰撳墠杞欢鐗堟湰: {latestVersion}\n" +
+ $"鍙戝竷鏃ユ湡: {latestDate}\n\n" +
+ $"鏈�鏂版洿鏂板唴瀹�:\n{changes}\n" +
+ $"瀹屾暣鐗堟湰鍘嗗彶璁板綍璇锋煡鐪嬬増鏈鏄�.txt鏂囦欢";
+
+ MessageBox.Show(message, "杞欢鐗堟湰璇存槑", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"璇诲彇鐗堟湰淇℃伅鍑洪敊: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private static bool IsVersionLine(string line)
+ {
+ return !string.IsNullOrEmpty(line) &&
+ line.Contains("v") &&
+ line.Contains(".") &&
+ line.Length > 8 &&
+ char.IsDigit(line[0]);
+ }
+
+ private static void ParseVersionLine(string line, ref string version, ref string date)
+ {
+ string[] parts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
+
+ foreach (string part in parts)
+ {
+ if (part.Contains("v") && part.Contains("."))
+ {
+ version = part;
+ }
+ else if (part.Contains(".") && part.Length >= 8 && char.IsDigit(part[0]))
+ {
+ date = part;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/IDViewer_2D/ViewModel/LogViewModel.cs b/IDViewer_2D/ViewModel/LogViewModel.cs
new file mode 100644
index 0000000..02ac409
--- /dev/null
+++ b/IDViewer_2D/ViewModel/LogViewModel.cs
@@ -0,0 +1,182 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using SmartScanner;
+
+namespace SmartScanner.ViewModel
+{
+ public class LogEntry : INotifyPropertyChanged
+ {
+ private DateTime _timestamp;
+ public DateTime Timestamp
+ {
+ get => _timestamp;
+ set
+ {
+ _timestamp = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private string _level;
+ public string Level
+ {
+ get => _level;
+ set
+ {
+ _level = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private string _message;
+ public string Message
+ {
+ get => _message;
+ set
+ {
+ _message = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private Brush _foreground;
+ public Brush Foreground
+ {
+ get => _foreground;
+ set
+ {
+ _foreground = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+
+ public class EnhancedLogViewModel : INotifyPropertyChanged
+ {
+ public ObservableCollection<LogEntry> LogEntries { get; } = new ObservableCollection<LogEntry>();
+ private static readonly Lazy<EnhancedLogViewModel> _instance =
+ new Lazy<EnhancedLogViewModel>(() => new EnhancedLogViewModel());
+
+ public static EnhancedLogViewModel Instance => _instance.Value;
+
+ // 鏃ュ織鑷姩淇濆瓨鏈嶅姟
+ private LogAutoSaveService _logAutoSaveService;
+
+ private EnhancedLogViewModel()
+ {
+ // 鍒濆鍖栨棩蹇楄嚜鍔ㄤ繚瀛樻湇鍔�
+ _logAutoSaveService = new LogAutoSaveService(LogEntries);
+ }
+
+ // 娣诲姞瀵筍crollViewer鐨勫紩鐢�
+ private ScrollViewer _logScrollViewer;
+ public ScrollViewer LogScrollViewer
+ {
+ get => _logScrollViewer;
+ set
+ {
+ _logScrollViewer = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public void AddLog(string message, string level = "INFO")
+ {
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+ var entry = new LogEntry
+ {
+ Timestamp = DateTime.Now,
+ Level = level,
+ Message = message,
+ Foreground = GetLevelColor(level)
+ };
+
+ LogEntries.Add(entry);
+
+ // 闄愬埗鏃ュ織鏁伴噺
+ if (LogEntries.Count > 500)
+ {
+ LogEntries.RemoveAt(0);
+ }
+
+ // 閫氱煡鑷姩淇濆瓨鏈嶅姟鏈夋柊鏃ュ織锛屼紶閫扡ogEntry瀵硅薄
+ _logAutoSaveService?.LogAdded(entry);
+
+ // 婊氬姩鍒板簳閮�
+ ScrollToBottom();
+ });
+ }
+
+ /// <summary>
+ /// 鎵嬪姩淇濆瓨褰撳墠鏃ュ織
+ /// </summary>
+ public void SaveLogs()
+ {
+ _logAutoSaveService?.ForceSave();
+ }
+
+ /// <summary>
+ /// 鍋滄鏃ュ織鑷姩淇濆瓨鏈嶅姟
+ /// </summary>
+ public void StopAutoSaveService()
+ {
+ _logAutoSaveService?.Stop();
+ _logAutoSaveService = null;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鑷姩淇濆瓨鏈嶅姟鐘舵��
+ /// </summary>
+ public string GetAutoSaveStatus()
+ {
+ return _logAutoSaveService?.GetStatus() ?? "鑷姩淇濆瓨鏈嶅姟鏈繍琛�";
+ }
+
+ private void ScrollToBottom()
+ {
+ if (LogScrollViewer != null)
+ {
+ LogScrollViewer.ScrollToEnd();
+ }
+ }
+
+ private Brush GetLevelColor(string level)
+ {
+ switch (level)
+ {
+ case "ERROR":
+ return Brushes.Red;
+ case "WARN":
+ return Brushes.Orange;
+ case "DEBUG":
+ return Brushes.Blue;
+ default:
+ return Brushes.Black;
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+}
diff --git a/IDViewer_2D/packages.config b/IDViewer_2D/packages.config
new file mode 100644
index 0000000..5e3c93d
--- /dev/null
+++ b/IDViewer_2D/packages.config
@@ -0,0 +1,23 @@
+锘�<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Extended.Wpf.Toolkit" version="4.7.25104.5739" targetFramework="net471" />
+ <package id="Microsoft.IO.RecyclableMemoryStream" version="3.0.1" targetFramework="net471" />
+ <package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net471" />
+ <package id="NETStandard.Library" version="2.0.0" targetFramework="net471" />
+ <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net461" />
+ <package id="OpenCvSharp4" version="4.10.0.20241108" targetFramework="net461" />
+ <package id="OpenCvSharp4.Extensions" version="4.10.0.20241108" targetFramework="net461" />
+ <package id="OpenCvSharp4.runtime.win" version="4.10.0.20240616" targetFramework="net471" />
+ <package id="OpenCvSharp4.WpfExtensions" version="4.5.1.20210210" targetFramework="net471" />
+ <package id="Syncfusion.Compression.Net.Core" version="29.1.37" targetFramework="net471" />
+ <package id="Syncfusion.Licensing" version="29.1.37" targetFramework="net471" />
+ <package id="Syncfusion.OfficeChart.Net.Core" version="29.1.37" targetFramework="net471" />
+ <package id="Syncfusion.Presentation.Net.Core" version="29.1.37" targetFramework="net471" />
+ <package id="System.Buffers" version="4.5.1" targetFramework="net471" />
+ <package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net471" />
+ <package id="System.Drawing.Common" version="8.0.0" targetFramework="net461" requireReinstallation="true" />
+ <package id="System.Memory" version="4.5.5" targetFramework="net471" />
+ <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net471" />
+ <package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net471" />
+ <package id="System.Security.Cryptography.Xml" version="8.0.2" targetFramework="net471" />
+</packages>
\ No newline at end of file
diff --git "a/IDViewer_2D/\350\275\257\344\273\266\351\234\200\346\261\202\350\247\204\346\240\274\350\257\264\346\230\216\344\271\246.md" "b/IDViewer_2D/\350\275\257\344\273\266\351\234\200\346\261\202\350\247\204\346\240\274\350\257\264\346\230\216\344\271\246.md"
new file mode 100644
index 0000000..3285b58
--- /dev/null
+++ "b/IDViewer_2D/\350\275\257\344\273\266\351\234\200\346\261\202\350\247\204\346\240\274\350\257\264\346\230\216\344\271\246.md"
@@ -0,0 +1,339 @@
+# IDViewer_2D 杞欢闇�姹傝鏍艰鏄庝功
+
+## 1. 姒傝堪
+
+IDViewer_2D 鏄竴娆句笓涓氱殑浜岀淮瑙嗚妫�娴嬭蒋浠讹紝涓昏鐢ㄤ簬宸ヤ笟鍦烘櫙涓殑鏉$爜/浜岀淮鐮佽瘑鍒�佸浘鍍忓鐞嗐�佽澶囩鐞嗗拰鏁版嵁閫氫俊銆傝蒋浠舵敮鎸佸璁惧杩炴帴銆佸疄鏃舵娴嬨�佺粨鏋滃垽瀹氬拰鏁版嵁瀵煎嚭绛夊姛鑳姐��
+
+## 2. 绯荤粺鏋舵瀯
+
+### 2.1 鎶�鏈灦鏋�
+- **寮�鍙戣瑷�**: C#
+- **UI妗嗘灦**: WPF (Windows Presentation Foundation)
+- **SDK渚濊禆**: IDViewerCSDK.dll (搴曞眰瑙嗚绠楁硶搴�)
+- **鍥惧儚澶勭悊**: OpenCVSharp
+- **閫氫俊鍗忚**: Modbus TCP銆乀CP/IP銆乁DP
+
+### 2.2 杞欢妯″潡
+1. 璁惧绠$悊妯″潡
+2. 鍥惧儚澶勭悊妯″潡
+3. 妫�娴嬫柟妗堟ā鍧�
+4. 閫氫俊閰嶇疆妯″潡
+5. 鏁版嵁瀛樺偍妯″潡
+6. 鐢ㄦ埛鏉冮檺妯″潡
+7. 鏃ュ織绠$悊妯″潡
+
+## 3. 鍔熻兘闇�姹�
+
+### 3.1 涓荤晫闈㈠姛鑳�
+
+#### 3.1.1 璁惧杩炴帴绠$悊
+- [x] **璁惧鎵弿**: 鑷姩鍙戠幇缃戠粶涓殑瑙嗚璁惧
+- [x] **璁惧鍒楄〃**: 鏄剧ず宸插彂鐜拌澶囩殑IP銆佸瀷鍙枫�佸浐浠剁増鏈瓑淇℃伅
+- [x] **杩炴帴鐘舵��**: 瀹炴椂鏄剧ず璁惧杩炴帴鐘舵�侊紙宸茶繛鎺�/鏈繛鎺ワ級
+- [x] **鍒锋柊杩炴帴**: 鎵嬪姩鍒锋柊璁惧鍒楄〃骞堕噸鏂拌繛鎺�
+- [x] **璁惧淇℃伅**: 鏄剧ず閫変腑璁惧鐨勮缁嗕俊鎭紙IP鍦板潃銆佸瓙缃戞帺鐮併�佺綉鍏炽�佸浐浠剁増鏈�佽澶囧瀷鍙枫�佽澶囧悕绉帮級
+
+#### 3.1.2 宸ュ叿鏍忓姛鑳�
+- [x] **鍒锋柊璁惧**: 鍒锋柊璁惧鍒楄〃骞堕噸鏂拌繛鎺�
+- [x] **璁惧绠$悊**: 鎵撳紑璁惧鏄犲皠閰嶇疆鐣岄潰
+- [x] **妫�娴嬫柟妗�**: 鎵撳紑妫�娴嬫柟妗堥厤缃晫闈�
+- [x] **瀛樺浘璁剧疆**: 鎵撳紑鍥惧儚瀛樺偍璁剧疆鐣岄潰
+- [x] **鍗曠偣杈撳嚭**: 鍒囨崲鍗曠偣/澶氱偣杈撳嚭妯″紡
+- [x] **閫氳娴嬭瘯**: 娴嬭瘯璁惧閫氫俊鍔熻兘
+- [x] **鎵嬪姩閲囬泦**: 鎵嬪姩瑙﹀彂鍥惧儚閲囬泦
+- [x] **鐣岄潰閲嶇疆**: 閲嶇疆鐣岄潰鍒板垵濮嬬姸鎬�
+- [x] **鏌ョ湅妫�娴嬫姤鍛�**: 鏌ョ湅鍘嗗彶妫�娴嬬粨鏋滄姤鍛�
+- [x] **鏌ョ湅鏃ュ織**: 鏌ョ湅绯荤粺鎿嶄綔鏃ュ織
+- [x] **涓�閿噸鍚�**: 閲嶅惎搴旂敤绋嬪簭
+
+#### 3.1.3 缁撴灉鏄剧ず
+- [x] **澶氶�氶亾鏄剧ず**: 鏀寔鏈�澶�24涓娴嬮�氶亾鍚屾椂鏄剧ず
+- [x] **瀹炴椂鐘舵��**: 鏄剧ず褰撳墠妫�娴嬬姸鎬佸拰閫氫俊鐘舵��
+- [x] **缁撴灉鏍囪瘑**: 浣跨敤棰滆壊鍖哄垎妫�娴嬬粨鏋滐紙OK/NG锛�
+- [x] **璁惧鍒悕**: 鏄剧ず姣忎釜閫氶亾瀵瑰簲鐨勮澶囧埆鍚�
+- [x] **鐐瑰嚮浜や簰**: 鏀寔鐐瑰嚮缁撴灉鍖哄煙鏌ョ湅璇︾粏缁撴灉
+
+#### 3.1.4 鏃ュ織鏄剧ず
+- [x] **瀹炴椂鏃ュ織**: 瀹炴椂鏄剧ず妫�娴嬫棩蹇椾俊鎭�
+- [x] **鏃ュ織绾у埆**: 鏀寔涓嶅悓绾у埆鐨勬棩蹇楁樉绀�
+- [x] **鏃堕棿鎴�**: 姣忔潯鏃ュ織閮藉甫鏈夋椂闂存埑
+- [x] **鑷姩婊氬姩**: 鏃ュ織鑷姩婊氬姩鍒版渶鏂板唴瀹�
+
+### 3.2 璁惧绠$悊妯″潡
+
+#### 3.2.1 璁惧鏄犲皠閰嶇疆
+- [x] **杩炴帴椤哄簭**: 閰嶇疆璁惧鐨勮繛鎺ラ『搴�
+- [x] **IP鏄犲皠**: 閰嶇疆璁惧IP涓庢樉绀轰綅缃殑鏄犲皠鍏崇郴
+- [x] **娣诲姞鏄犲皠**: 娣诲姞鏂扮殑璁惧鏄犲皠
+- [x] **鍒犻櫎鏄犲皠**: 鍒犻櫎鐜版湁璁惧鏄犲皠
+- [x] **淇濆瓨閰嶇疆**: 淇濆瓨鏄犲皠閰嶇疆鍒版枃浠�
+- [x] **鍔犺浇閰嶇疆**: 浠庢枃浠跺姞杞芥槧灏勯厤缃�
+
+#### 3.2.2 璁惧鎺у埗
+- [x] **璁惧鎵撳紑/鍏抽棴**: 鎺у埗璁惧鐨勫紑鍚拰鍏抽棴
+- [x] **杩愯妯″紡**: 鍚姩/鍋滄璁惧杩愯
+- [x] **璋冭瘯妯″紡**: 杩涘叆璁惧璋冭瘯妯″紡
+- [x] **鍥惧儚閲囬泦**: 鎵嬪姩閲囬泦鍗曞抚鍥惧儚
+- [x] **鍙傛暟璁剧疆**: 璁剧疆璁惧鍙傛暟锛堟洕鍏夈�佸鐩娿�佷冀椹瓑锛�
+- [x] **鍥轰欢淇℃伅**: 鑾峰彇璁惧鍥轰欢鐗堟湰淇℃伅
+
+### 3.3 妫�娴嬫柟妗堟ā鍧�
+
+#### 3.3.1 鏂规閰嶇疆
+- [x] **鏂规閫夋嫨**: 閫夋嫨妫�娴嬫柟妗堟枃浠�
+- [x] **妯″瀷閫夋嫨**: 閫夋嫨鎺ㄧ悊妯″瀷鏂囦欢
+- [x] **宸ョ▼瀵煎嚭**: 瀵煎嚭宸ョ▼閰嶇疆鏂囦欢
+- [x] **宸ョ▼鍔犺浇**: 鍔犺浇宸叉湁宸ョ▼閰嶇疆
+- [x] **妯″瀷鍒锋柊**: 鍒锋柊鍙敤妯″瀷鍒楄〃
+
+#### 3.3.2 妫�娴嬪弬鏁�
+- [x] **鐩爣鏁伴噺**: 璁剧疆妫�娴嬬洰鏍囨暟閲�
+- [x] **寰楀垎闃堝��**: 璁剧疆妫�娴嬪緱鍒嗛槇鍊�
+- [x] **鐩爣绫诲瀷**: 閰嶇疆妫�娴嬬殑鐩爣绫诲瀷
+- [x] **鏉′欢璁剧疆**: 璁剧疆妫�娴嬫潯浠惰鍒�
+- [x] **澶氭娴嬬偣**: 鏀寔澶氫釜妫�娴嬬偣閰嶇疆
+
+#### 3.3.3 ROI绠$悊
+- [x] **ROI娣诲姞**: 娣诲姞妫�娴嬪尯鍩�(ROI)
+- [x] **ROI鍒犻櫎**: 鍒犻櫎鎸囧畾ROI
+- [x] **ROI淇敼**: 淇敼ROI浣嶇疆鍜屽ぇ灏�
+- [x] **ROI娓呯┖**: 娓呴櫎鎵�鏈塕OI
+- [x] **鐮佸埗绠$悊**: 绠$悊鏀寔鐨勬潯鐮佺被鍨�
+
+### 3.4 鍥惧儚澶勭悊妯″潡
+
+#### 3.4.1 鍥惧儚閲囬泦
+- [x] **鑷姩閲囬泦**: 鏀寔鑷姩杩炵画閲囬泦
+- [x] **鎵嬪姩閲囬泦**: 鏀寔鎵嬪姩鍗曞抚閲囬泦
+- [x] **瑙﹀彂妯″紡**: 鏀寔澶氱瑙﹀彂妯″紡锛堣蒋瑙﹀彂銆佺‖瑙﹀彂銆佺綉缁滆Е鍙戠瓑锛�
+- [x] **鍥惧儚棰勮**: 瀹炴椂鍥惧儚棰勮鏄剧ず
+
+#### 3.4.2 鍥惧儚鍙傛暟
+- [x] **鏇濆厜璁剧疆**: 璋冩暣鍥惧儚鏇濆厜鍙傛暟
+- [x] **澧炵泭璁剧疆**: 璋冩暣鍥惧儚澧炵泭鍙傛暟
+- [x] **浼介┈璁剧疆**: 璋冩暣鍥惧儚浼介┈鍊�
+- [x] **鑷姩鏇濆厜**: 鍚敤/绂佺敤鑷姩鏇濆厜
+- [x] **鑷姩澧炵泭**: 鍚敤/绂佺敤鑷姩澧炵泭
+- [x] **鍏夋簮鎺у埗**: 鎺у埗鐓ф槑鍏夋簮浜害
+
+#### 3.4.3 鍥惧儚鏄剧ず
+- [x] **澶氬浘娴忚**: 鏀寔澶氬紶鍥惧儚娴忚
+- [x] **鍥惧儚缂╂斁**: 鏀寔鍥惧儚缂╂斁鏌ョ湅
+- [x] **涓婁竴寮�/涓嬩竴寮�**: 鍥惧儚娴忚瀵艰埅
+- [x] **缁撴灉娓叉煋**: 鍦ㄥ浘鍍忎笂娓叉煋妫�娴嬬粨鏋�
+
+### 3.5 閫氫俊閰嶇疆妯″潡
+
+#### 3.5.1 Modbus TCP閰嶇疆
+- [x] **鏈嶅姟鍣↖P**: 璁剧疆Modbus鏈嶅姟鍣↖P鍦板潃
+- [x] **绔彛璁剧疆**: 璁剧疆閫氫俊绔彛锛堥粯璁�502锛�
+- [x] **杩炴帴鎺у埗**: Modbus杩炴帴寤虹珛鍜屾柇寮�
+- [x] **鏃ュ織鏄剧ず**: 鏄剧ずModbus閫氫俊鏃ュ織
+- [x] **娓呯┖鏃ュ織**: 娓呴櫎閫氫俊鏃ュ織
+
+#### 3.5.2 TCP/IP鏈嶅姟鍣ㄩ厤缃�
+- [x] **IP缁戝畾**: 璁剧疆鏈嶅姟鍣ㄧ粦瀹氱殑IP鍦板潃
+- [x] **绔彛璁剧疆**: 璁剧疆鐩戝惉绔彛锛堥粯璁�5011锛�
+- [x] **蹇冭烦妫�娴�**: 鍚敤/绂佺敤蹇冭烦妫�娴嬪姛鑳�
+- [x] **蹇冭烦鎸囦护**: 璁剧疆蹇冭烦鎸囦护鍐呭
+- [x] **蹇冭烦鍛ㄦ湡**: 璁剧疆蹇冭烦妫�娴嬪懆鏈�
+- [x] **鏈嶅姟鍣ㄦ帶鍒�**: 鍚姩/鍋滄TCP鏈嶅姟鍣�
+- [x] **IP鍒锋柊**: 鍒锋柊鍙敤IP鍦板潃鍒楄〃
+
+#### 3.5.3 閫氫俊鍗忚鏀寔
+- [x] **Modbus TCP**: 鏀寔Modbus TCP鍗忚
+- [x] **TCP/IP**: 鏀寔鏍囧噯TCP/IP閫氫俊
+- [x] **UDP**: 鏀寔UDP鍗忚閫氫俊
+- [x] **涓插彛閫氫俊**: 鏀寔涓插彛閫氫俊
+- [x] **EtherNet/IP**: 鏀寔EtherNet/IP鍗忚
+- [x] **Profinet**: 鏀寔Profinet鍗忚
+- [x] **FINS**: 鏀寔FINS鍗忚
+- [x] **MC鍗忚**: 鏀寔涓夎彵MC鍗忚
+- [x] **EtherCAT**: 鏀寔EtherCAT鍗忚
+
+### 3.6 鏁版嵁瀛樺偍妯″潡
+
+#### 3.6.1 瀛樺偍璁剧疆
+- [x] **瀛樺偍璺緞**: 璁剧疆鏁版嵁瀛樺偍璺緞
+- [x] **鍥惧儚鏍煎紡**: 閫夋嫨鍥惧儚瀛樺偍鏍煎紡锛圔MP/JPG/PNG锛�
+- [x] **鍘嬬缉姣旂巼**: 璁剧疆鍥惧儚鍘嬬缉姣旂巼锛�0-10锛�
+- [x] **鍚敤瀛樺偍**: 鍚敤/绂佺敤鍥惧儚瀛樺偍鍔熻兘
+
+#### 3.6.2 瀛樺偍绠$悊
+- [x] **瀹氭湡娓呯悊**: 璁剧疆瀹氭湡娓呯悊鍥惧儚鍔熻兘
+- [x] **娓呯悊鍛ㄦ湡**: 璁剧疆鍥惧儚淇濈暀澶╂暟锛�1-200000澶╋級
+- [x] **绌洪棿棰勮**: 鍚敤瀛樺偍绌洪棿棰勮鍔熻兘
+- [x] **棰勮闃堝��**: 璁剧疆绌洪棿棰勮鐧惧垎姣旓紙10%-90%锛�
+- [x] **瀛樺偍鐘舵��**: 鏄剧ず褰撳墠瀛樺偍鐘舵�佷俊鎭�
+
+#### 3.6.3 鏁版嵁瀵煎嚭
+- [x] **Excel瀵煎嚭**: 鏀寔妫�娴嬬粨鏋滃鍑哄埌Excel
+- [x] **鎶ュ憡鐢熸垚**: 鐢熸垚妫�娴嬫姤鍛婃枃妗�
+- [x] **鏁版嵁鏍煎紡**: 鏀寔澶氱鏁版嵁瀵煎嚭鏍煎紡
+- [x] **鎵归噺瀵煎嚭**: 鏀寔鎵归噺鏁版嵁瀵煎嚭
+
+### 3.7 鐢ㄦ埛鏉冮檺妯″潡
+
+#### 3.7.1 鐢ㄦ埛鐧诲綍
+- [x] **鐢ㄦ埛璁よ瘉**: 鏀寔鐢ㄦ埛鐧诲綍璁よ瘉
+- [x] **鐢ㄦ埛绠$悊**: 绠$悊鐢ㄦ埛璐︽埛鍒楄〃
+- [x] **瀵嗙爜淇濇姢**: 鏀寔瀵嗙爜杈撳叆淇濇姢
+- [x] **鏉冮檺鎺у埗**: 涓嶅悓鐢ㄦ埛鏉冮檺鎺у埗
+
+#### 3.7.2 鎿嶄綔鏉冮檺
+- [x] **閰嶇疆鏉冮檺**: 鎺у埗閰嶇疆淇敼鏉冮檺
+- [x] **璁惧鎺у埗鏉冮檺**: 鎺у埗璁惧鎿嶄綔鏉冮檺
+- [x] **鏁版嵁鏌ョ湅鏉冮檺**: 鎺у埗鏁版嵁鏌ョ湅鏉冮檺
+- [x] **绯荤粺绠$悊鏉冮檺**: 鎺у埗绯荤粺绠$悊鍔熻兘
+
+### 3.8 鏃ュ織绠$悊妯″潡
+
+#### 3.8.1 绯荤粺鏃ュ織
+- [x] **鎿嶄綔鏃ュ織**: 璁板綍鐢ㄦ埛鎿嶄綔鏃ュ織
+- [x] **閿欒鏃ュ織**: 璁板綍绯荤粺閿欒淇℃伅
+- [x] **閫氫俊鏃ュ織**: 璁板綍閫氫俊鏁版嵁鏃ュ織
+- [x] **妫�娴嬫棩蹇�**: 璁板綍妫�娴嬬粨鏋滄棩蹇�
+
+#### 3.8.2 鏃ュ織鍔熻兘
+- [x] **瀹炴椂鏄剧ず**: 瀹炴椂鏄剧ず鏃ュ織鍐呭
+- [x] **鏃ュ織杩囨护**: 鏀寔鎸夌骇鍒繃婊ゆ棩蹇�
+- [x] **鏃ュ織瀵煎嚭**: 鏀寔鏃ュ織瀵煎嚭鍔熻兘
+- [x] **鏃ュ織娓呯悊**: 鏀寔鏃ュ織鑷姩娓呯悊
+
+## 4. 闈炲姛鑳介渶姹�
+
+### 4.1 鎬ц兘闇�姹�
+- [x] **瀹炴椂鎬�**: 妫�娴嬪搷搴旀椂闂� < 100ms
+- [x] **绋冲畾鎬�**: 7脳24灏忔椂杩炵画杩愯
+- [x] **骞跺彂鎬�**: 鏀寔澶氳澶囧苟鍙戞娴�
+- [x] **璧勬簮鍗犵敤**: CPU鍗犵敤鐜� < 70%锛屽唴瀛樺崰鐢� < 2GB
+
+### 4.2 鍙潬鎬ч渶姹�
+- [x] **寮傚父澶勭悊**: 瀹屽杽鐨勫紓甯稿鐞嗘満鍒�
+- [x] **鑷姩閲嶈繛**: 缃戠粶寮傚父鑷姩閲嶈繛
+- [x] **鏁版嵁鎭㈠**: 寮傚父鏂數鏁版嵁鎭㈠
+- [x] **鏃ュ織杩借釜**: 瀹屾暣鐨勬搷浣滄棩蹇楄拷韪�
+
+### 4.3 鍙敤鎬ч渶姹�
+- [x] **鐢ㄦ埛鐣岄潰**: 鐩磋鏄撶敤鐨勫浘褰㈢晫闈�
+- [x] **鎿嶄綔娴佺▼**: 绠�娲佹槑浜嗙殑鎿嶄綔娴佺▼
+- [x] **甯姪鏂囨。**: 瀹屽杽鐨勫府鍔╂枃妗f敮鎸�
+- [x] **澶氳瑷�**: 鏀寔涓嫳鏂囩晫闈�
+
+### 4.4 瀹夊叏鎬ч渶姹�
+- [x] **鏁版嵁瀹夊叏**: 妫�娴嬫暟鎹畨鍏ㄥ瓨鍌�
+- [x] **璁块棶鎺у埗**: 涓ユ牸鐨勮闂潈闄愭帶鍒�
+- [x] **閫氫俊鍔犲瘑**: 鏁忔劅鏁版嵁閫氫俊鍔犲瘑
+- [x] **鎿嶄綔瀹¤**: 鎵�鏈夋搷浣滈兘鏈夊璁℃棩蹇�
+
+### 4.5 鍏煎鎬ч渶姹�
+- [x] **鎿嶄綔绯荤粺**: 鏀寔Windows 7/10/11
+- [x] **纭欢鍏煎**: 鏀寔澶氱瑙嗚璁惧
+- [x] **缃戠粶鍏煎**: 鏀寔澶氱缃戠粶鍗忚
+- [x] **鏁版嵁鍏煎**: 鏀寔澶氱鏁版嵁鏍煎紡
+
+## 5. 鎺ュ彛闇�姹�
+
+### 5.1 纭欢鎺ュ彛
+- [x] **鐩告満鎺ュ彛**: 鏀寔GigE Vision銆乁SB3.0鐩告満
+- [x] **IO鎺ュ彛**: 鏀寔鏁板瓧杈撳叆杈撳嚭鎺у埗
+- [x] **涓插彛鎺ュ彛**: 鏀寔RS232/RS485涓插彛閫氫俊
+- [x] **缃戠粶鎺ュ彛**: 鏀寔鍗冨厗浠ュお缃戞帴鍙�
+
+### 5.2 杞欢鎺ュ彛
+- [x] **SDK鎺ュ彛**: IDViewerCSDK.dll 鎺ュ彛璋冪敤
+- [x] **鏁版嵁搴撴帴鍙�**: 鏀寔SQLite鏁版嵁搴�
+- [x] **鏂囦欢鎺ュ彛**: 鏀寔鏂囦欢璇诲啓鎿嶄綔
+- [x] **缃戠粶鎺ュ彛**: 鏀寔Socket閫氫俊
+
+### 5.3 閫氫俊鎺ュ彛
+- [x] **Modbus TCP**: 鏀寔Modbus TCP瀹㈡埛绔�/鏈嶅姟鍣�
+- [x] **TCP/IP**: 鏀寔鏍囧噯TCP/IP閫氫俊
+- [x] **UDP**: 鏀寔UDP鏁版嵁鎶ラ�氫俊
+- [x] **HTTP**: 鏀寔HTTP鍗忚閫氫俊
+- [x] **FTP**: 鏀寔FTP鏂囦欢浼犺緭
+
+## 6. 鏁版嵁闇�姹�
+
+### 6.1 鏁版嵁瀛樺偍
+- [x] **閰嶇疆鏁版嵁**: XML鏍煎紡閰嶇疆鏂囦欢
+- [x] **鍥惧儚鏁版嵁**: BMP/JPG/PNG鏍煎紡鍥惧儚鏂囦欢
+- [x] **缁撴灉鏁版嵁**: Excel/CSV鏍煎紡缁撴灉鏂囦欢
+- [x] **鏃ュ織鏁版嵁**: 鏂囨湰鏍煎紡鏃ュ織鏂囦欢
+
+### 6.2 鏁版嵁澶勭悊
+- [x] **鏁版嵁瑙f瀽**: 瑙f瀽鍚勭鏍煎紡鐨勬暟鎹�
+- [x] **鏁版嵁杞崲**: 鏁版嵁鏍煎紡杞崲澶勭悊
+- [x] **鏁版嵁鏍¢獙**: 鏁版嵁瀹屾暣鎬ф牎楠�
+- [x] **鏁版嵁澶囦唤**: 鑷姩鏁版嵁澶囦唤
+
+### 6.3 鏁版嵁灞曠ず
+- [x] **瀹炴椂鏄剧ず**: 瀹炴椂鏁版嵁鍙鍖栨樉绀�
+- [x] **鍘嗗彶鏌ヨ**: 鍘嗗彶鏁版嵁鏌ヨ鏄剧ず
+- [x] **缁熻鎶ヨ〃**: 鏁版嵁缁熻鎶ヨ〃鐢熸垚
+- [x] **瓒嬪娍鍒嗘瀽**: 鏁版嵁瓒嬪娍鍒嗘瀽鏄剧ず
+
+## 7. 绾︽潫鏉′欢
+
+### 7.1 鎶�鏈害鏉�
+- [x] **寮�鍙戣瑷�**: 蹇呴』浣跨敤C#寮�鍙�
+- [x] **杩愯鐜**: 蹇呴』鏀寔.NET Framework 4.5+
+- [x] **绗笁鏂瑰簱**: 渚濊禆IDViewerCSDK.dll搴�
+- [x] **鐣岄潰妗嗘灦**: 浣跨敤WPF妗嗘灦寮�鍙�
+
+### 7.2 涓氬姟绾︽潫
+- [x] **瀹炴椂鎬ц姹�**: 蹇呴』婊¤冻瀹炴椂妫�娴嬭姹�
+- [x] **鍑嗙‘鎬ц姹�**: 妫�娴嬪噯纭巼 > 99.9%
+- [x] **绋冲畾鎬ц姹�**: 鏃犳晠闅滆繍琛屾椂闂� > 1000灏忔椂
+
+### 7.3 璧勬簮绾︽潫
+- [x] **纭欢璧勬簮**: 闇�瑕佽冻澶熺殑璁$畻璧勬簮
+- [x] **瀛樺偍璧勬簮**: 闇�瑕佽冻澶熺殑瀛樺偍绌洪棿
+- [x] **缃戠粶璧勬簮**: 闇�瑕佺ǔ瀹氱殑缃戠粶鐜
+
+## 8. 璐ㄩ噺灞炴��
+
+### 8.1 鍙淮鎶ゆ��
+- [x] **妯″潡鍖栬璁�**: 绯荤粺閲囩敤妯″潡鍖栬璁�
+- [x] **浠g爜瑙勮寖**: 閬靛惊缂栫爜瑙勮寖鍜屾爣鍑�
+- [x] **鏂囨。瀹屾暣**: 鎻愪緵瀹屾暣鐨勬妧鏈枃妗�
+- [x] **鏄撲簬鎵╁睍**: 绯荤粺鏄撲簬鍔熻兘鎵╁睍
+
+### 8.2 鍙祴璇曟��
+- [x] **鍗曞厓娴嬭瘯**: 鏀寔鍗曞厓娴嬭瘯
+- [x] **闆嗘垚娴嬭瘯**: 鏀寔闆嗘垚娴嬭瘯
+- [x] **绯荤粺娴嬭瘯**: 鏀寔绯荤粺娴嬭瘯
+- [x] **鑷姩鍖栨祴璇�**: 鏀寔鑷姩鍖栨祴璇�
+
+### 8.3 鍙Щ妞嶆��
+- [x] **鐜闅旂**: 杩愯鐜渚濊禆闅旂
+- [x] **閰嶇疆绠$悊**: 缁熶竴鐨勯厤缃鐞�
+- [x] **閮ㄧ讲绠�鍗�**: 绠�鍗曠殑閮ㄧ讲杩囩▼
+- [x] **璺ㄥ钩鍙�**: 鏀寔Windows骞冲彴
+
+## 9. 闄勫綍
+
+### 9.1 鏈琛�
+- **ROI**: Region of Interest锛屾劅鍏磋叮鍖哄煙
+- **Modbus**: 宸ヤ笟閫氫俊鍗忚
+- **TCP/IP**: 浼犺緭鎺у埗鍗忚/缃戦檯鍗忚
+- **GigE Vision**: 鍗冨厗浠ュお缃戣瑙夋爣鍑�
+- **SDK**: Software Development Kit锛岃蒋浠跺紑鍙戝伐鍏峰寘
+
+### 9.2 鍙傝�冭祫鏂�
+- IDViewerCSDK寮�鍙戞枃妗�
+- Modbus鍗忚瑙勮寖
+- TCP/IP鍗忚璇﹁В
+- WPF寮�鍙戞寚鍗�
+- OpenCV鍥惧儚澶勭悊搴撴枃妗�
+
+### 9.3 鐗堟湰鍘嗗彶
+| 鐗堟湰鍙� | 淇鏃ユ湡 | 淇鍐呭 | 淇浜� |
+|--------|----------|----------|--------|
+| v1.0 | 2024-03-20 | 鍒濆鐗堟湰鍒涘缓 | 绯荤粺鍒嗘瀽甯� |
+| v1.1 | 2024-03-21 | 瀹屽杽鍔熻兘鎻忚堪 | 绯荤粺鍒嗘瀽甯� |
+
+---
+**鏂囨。鐘舵��**: 鉁� 宸插畬鎴�
+**璇勫鐘舵��**: 鈴� 寰呰瘎瀹�
+**鎵瑰噯鐘舵��**: 鈴� 寰呮壒鍑�
\ No newline at end of file
diff --git a/SmartScanner.sln b/SmartScanner.sln
new file mode 100644
index 0000000..5f0c18b
--- /dev/null
+++ b/SmartScanner.sln
@@ -0,0 +1,37 @@
+锘�
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.35425.106
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmartScanner", "IDViewer_2D\SmartScanner.csproj", "{D1C98439-DD40-43CD-BC99-899868FD2EDF}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D1C98439-DD40-43CD-BC99-899868FD2EDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D1C98439-DD40-43CD-BC99-899868FD2EDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D1C98439-DD40-43CD-BC99-899868FD2EDF}.Debug|x64.ActiveCfg = Debug|x64
+ {D1C98439-DD40-43CD-BC99-899868FD2EDF}.Debug|x64.Build.0 = Debug|x64
+ {D1C98439-DD40-43CD-BC99-899868FD2EDF}.Debug|x86.ActiveCfg = Debug|x86
+ {D1C98439-DD40-43CD-BC99-899868FD2EDF}.Debug|x86.Build.0 = Debug|x86
+ {D1C98439-DD40-43CD-BC99-899868FD2EDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D1C98439-DD40-43CD-BC99-899868FD2EDF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D1C98439-DD40-43CD-BC99-899868FD2EDF}.Release|x64.ActiveCfg = Release|x64
+ {D1C98439-DD40-43CD-BC99-899868FD2EDF}.Release|x64.Build.0 = Release|x64
+ {D1C98439-DD40-43CD-BC99-899868FD2EDF}.Release|x86.ActiveCfg = Release|x86
+ {D1C98439-DD40-43CD-BC99-899868FD2EDF}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {86CD00DD-4539-43C7-819E-DACFFA267AF1}
+ EndGlobalSection
+EndGlobal
diff --git "a/TCP\351\200\232\350\256\257\346\225\260\346\215\256\346\240\274\345\274\217\350\257\264\346\230\216.xlsx" "b/TCP\351\200\232\350\256\257\346\225\260\346\215\256\346\240\274\345\274\217\350\257\264\346\230\216.xlsx"
new file mode 100644
index 0000000..6ce2c1f
--- /dev/null
+++ "b/TCP\351\200\232\350\256\257\346\225\260\346\215\256\346\240\274\345\274\217\350\257\264\346\230\216.xlsx"
Binary files differ
diff --git "a/\345\256\211\350\243\205\350\204\232\346\234\254.iss" "b/\345\256\211\350\243\205\350\204\232\346\234\254.iss"
new file mode 100644
index 0000000..7a9dc18
--- /dev/null
+++ "b/\345\256\211\350\243\205\350\204\232\346\234\254.iss"
@@ -0,0 +1,58 @@
+; Script generated by the Inno Setup Script Wizard.
+; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
+
+#define MyAppName "SmartScanner"
+#define MyAppVersion "1.26.1" ; 更新后需要全局更新版本号
+#define MyAppPublisher "SHLANBAO"
+#define MyAppExeName "SmartScanner.exe"
+#define MyAppAssocName MyAppName + " v1.26.1"
+#define MyAppAssocExt ".myp"
+#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt
+
+[Setup]
+; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
+; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
+AppId={{AA622081-8085-48FE-A317-86D82708B190}
+AppName={#MyAppName}
+AppVersion={#MyAppVersion}
+;AppVerName={#MyAppName} {#MyAppVersion}
+AppPublisher={#MyAppPublisher}
+DefaultDirName={autopf}\{#MyAppName}
+ChangesAssociations=yes
+DisableProgramGroupPage=yes
+; Uncomment the following line to run in non administrative install mode (install for current user only.)
+;PrivilegesRequired=lowest
+OutputDir=C:\Users\C3032\Desktop\安装包
+OutputBaseFilename=SmartScanner v1.26.1
+SetupIconFile=D:\00 Code\01 ID Viewer\IDViewer_2D-1 v26 API\IDViewer_2D\IDViewer2D.ico
+Compression=lzma
+SolidCompression=yes
+WizardStyle=modern
+
+[Languages]
+Name: "english"; MessagesFile: "compiler:Default.isl"
+Name: "chinese"; MessagesFile: "compiler:Languages\Chinese.isl"
+
+[Tasks]
+Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
+
+[Files]
+Source: "D:\00 Code\01 ID Viewer\IDViewer_2D-1 v26 API\IDViewer_2D\bin\x64\Debug\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
+Source: "D:\00 Code\01 ID Viewer\IDViewer_2D-1 v26 API\IDViewer_2D\bin\x64\Debug\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
+; NOTE: Don't use "Flags: ignoreversion" on any shared system files
+
+[Registry]
+Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
+Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
+Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
+Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
+Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""
+
+[Icons]
+Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
+Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
+Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\IDViewer2D.ico"
+
+[Run]
+Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
+
diff --git "a/\347\211\210\346\234\254\350\257\264\346\230\216.txt" "b/\347\211\210\346\234\254\350\257\264\346\230\216.txt"
new file mode 100644
index 0000000..e5ef678
--- /dev/null
+++ "b/\347\211\210\346\234\254\350\257\264\346\230\216.txt"
@@ -0,0 +1,99 @@
+2025.5.8 v1.0.7
+1.鏂板杩炴帴鐘舵�佺晫闈㈣繘搴︽樉绀�
+
+
+2025.5.28 v1.0.8
+1.淇璁惧鏂紑鍚嶭og杩炴帴鏄剧ず闂锛�
+2.鏂板杩炴帴鐘舵�佹鏌ュ畾鏃跺櫒锛屾瘡3s鑷姩妫�鏌ヨ繛鎺ョ姸鎬�
+
+
+2025.5.28 v1.0.9
+1.澶氱偣IO杈撳嚭鍥哄畾鍐欐20鐐逛慨鏀逛负鑷�傚簲杩炴帴鏁伴噺
+
+
+2025.6.10 v1.0.9
+1.鏂板鍥惧儚瀹氭湡鍒犻櫎鍔熻兘
+2.鏂板鑷�夊浘鍍忎繚瀛樻牸寮忥紙BMP銆丣GP銆丳NG锛夊拰鍘嬬缉姣旂巼锛屽叾涓瑽MP鏍煎紡鐨勫浘鍍忎笉鍏佽鍘嬬缉
+3.鏂板鍥惧儚淇濆瓨璺緞鑷敱閫夋嫨
+4.鏂板瀛樺偍绌洪棿涓嶈冻鑷姩寮圭獥鎶ヨ
+
+
+2025.6.13 v1.1.0
+1.鏂板妫�娴嬫棩蹇楁樉绀猴紝瀹屾暣鐨勬樉绀烘娴嬭繃绋嬪拰缁撴灉锛屽苟瀵规棩蹇椾俊鎭繘琛屽垎绾ф樉绀�
+
+
+2025.6.18 v1.1.1
+1.鏂板鈥淐PU鈥�/鈥淕PU鈥濇帹鐞嗘墜鍔ㄥ垏鎹�
+
+
+2025.6.20 v1.1.1
+1.鏂板鏉冮檺绠℃帶鍔熻兘锛屽弬鏁拌皟鑺傞渶鐧诲綍绠$悊鍛樿处鎴�
+
+
+2025.6.27 v1.1.2
+1.鏂板鎿嶄綔鏃ュ織璁板綍鍜屾樉绀猴紝璁板綍淇敼鏃ュ織銆佹搷浣滀汉鍛樸�佹搷浣滅被鍨嬨�佺洰鏍囪澶囧拰鎿嶄綔璇︽儏
+
+
+2025.7.11 v1.1.3
+1.鏂板妫�娴嬬粨鏋滆褰曚繚瀛樿嚦Excel琛紝淇濆瓨鏍煎紡涓衡�滀簩缁寸爜+妫�娴嬬偣浣�+妫�娴嬬粨鏋�+妫�娴嬫椂闂�+鎿嶄綔浜哄憳
+2.涓荤晫闈㈡柊澧炩�濆綋鍓嶆娴嬬姸鎬佲�滃拰鈥濆綋鍓嶉�氳鐘舵�佲�滀袱绉嶇姸鎬佹樉绀�
+3.鍙栨秷妫�娴嬫椂鈥滿odBus鏈繛鎺モ�滃脊绐楋紝鏀逛负閫氳妯″潡鐘舵�佹爮鏄剧ず
+
+
+2025.7.11 v1.1.4
+1.鏂板涓�閿噸鍚姛鑳�
+
+
+2025.7.30 v1.1.5
+1.鐣岄潰缁撴灉鏄剧ず妗嗕綋鏂板鎸夐挳鍔熻兘锛岀偣鍑诲悗鍙樉绀哄綋鍓嶆浣撳搴旂殑鍥惧儚
+2.鍗曠偣/澶氱偣杈撳嚭閫夋嫨鎺т欢鏍峰紡閲嶅啓锛岄噸鍐欎负宸﹀彸婊戝姩鐨勫閫夋寜閽牱寮�
+3.鍗曠偣/澶氱偣杈撳嚭鑷姩淇濆瓨
+
+
+2025.8.8 v1.1.6
+1.SDK鏇存柊
+
+
+2025.8.20 v1.1.8
+1.鏂板TCP/IP閫氳鍔熻兘锛岃蒋浠朵綔涓烘湇鍔$
+2.寮�鍚�/鍏抽棴蹇冭烦淇″彿
+3.蹇冭烦淇″彿鍛ㄦ湡鍜屾寚浠ゅ彲璁剧疆
+
+
+2025.8.20 v1.1.9
+1.妫�娴嬫柟妗堜腑姣忎釜鐐逛綅鍙娴嬬殑鐩爣澧炲姞鍒�4涓�
+
+
+2025.8.25 v1.2.0
+1.鏂板ng鍥惧儚鑷姩淇濆瓨鍔熻兘
+
+
+2025.8.30 v1.2.1
+1.鏂板宸ョ▼鏂规鏂囦欢锛屽皢妫�娴嬫柟妗堝拰妯″瀷鎵撳寘涓哄畬鏁寸殑宸ョ▼鏂囦欢
+2.宸ョ▼鏂囦欢鏀寔瀵煎嚭/瀵煎叆
+3.淇鎻掑叆绉诲姩瀛樺偍璁惧鍚庢巿鏉冨け鏁堥棶棰�
+
+2025.9.5 v1.2.2
+1.妯″瀷鏍煎紡淇敼涓簂b鍔犲瘑鏍煎紡
+
+
+2025.9.20 v1.2.3
+1.鏂板杞欢鍐呯増鏈鏄庯紝璁板綍姣忎釜鐗堟湰杞欢淇敼璁板綍锛屽彲閫氳繃杞欢鍐呮寜閽煡璇�
+2.IO瑙﹀彂鑷攣锛岃瀹氭椂闂村唴鍙兘瑙﹀彂涓�娆★紝淇″彿淇濇寔鏃堕棿鍙嚜瀹氫箟
+3.淇杩炴帴TCP鍚庢棤娉曟墜鍔ㄨЕ鍙戠殑闂
+
+
+2025.10.21 v1.2.4
+1.浼樺寲Modbus寮傚父鏂紑鍚庡鐞嗘帾鏂斤紝鏂板鏂紑閲嶈繛鏈哄埗
+2.寮傚父鏂紑鍚庡皾璇曢噸杩�5娆★紝鑻�5娆¤繛鎺ュけ璐ュ垯寮圭獥璀︽姤
+
+
+2025.10.24 v1.2.5
+1.宸ョ▼鏂囦欢鎿嶄綔娴佺▼绠�鍖�
+2.妫�娴嬫柟妗堟枃浠跺浐瀹氫繚瀛樺湪DetectionPlan鏂囦欢澶逛腑
+3.宸ョ▼鏂囦欢鍥哄畾淇濆瓨鍦≒roject鏂囦欢澶逛腑
+
+
+2025.10.30 v1.2.6
+1.鏂板妫�娴嬫棩蹇楄嚜鍔ㄥ鍑哄姛鑳斤紝鑷姩淇濆瓨鑷矰锛�02 LBLog鏂囦欢澶逛腑
+2.鏃ュ織榛樿瀛樺偍48灏忔椂锛�48灏忔椂浠ュ悗鑷姩娓呴櫎
\ No newline at end of file
diff --git "a/\350\275\257\344\273\266\345\212\237\350\203\275\345\210\227\350\241\250.xlsx" "b/\350\275\257\344\273\266\345\212\237\350\203\275\345\210\227\350\241\250.xlsx"
new file mode 100644
index 0000000..633bcb9
--- /dev/null
+++ "b/\350\275\257\344\273\266\345\212\237\350\203\275\345\210\227\350\241\250.xlsx"
Binary files differ
diff --git "a/\351\233\206\346\210\220\347\233\270\346\234\272\350\275\257\344\273\266\345\212\237\350\203\275\345\210\227\350\241\250.xlsx" "b/\351\233\206\346\210\220\347\233\270\346\234\272\350\275\257\344\273\266\345\212\237\350\203\275\345\210\227\350\241\250.xlsx"
new file mode 100644
index 0000000..a7e7a3d
--- /dev/null
+++ "b/\351\233\206\346\210\220\347\233\270\346\234\272\350\275\257\344\273\266\345\212\237\350\203\275\345\210\227\350\241\250.xlsx"
Binary files differ
--
Gitblit v1.9.3