| ¶Ô±ÈÐÂÎļþ |
| | |
| | | ############################################################################### |
| | | # Set default behavior to automatically normalize line endings. |
| | | ############################################################################### |
| | | * text=auto |
| | | |
| | | ############################################################################### |
| | | # Set default behavior for command prompt diff. |
| | | # |
| | | # This is need for earlier builds of msysgit that does not have it on by |
| | | # default for csharp files. |
| | | # Note: This is only used by command line |
| | | ############################################################################### |
| | | #*.cs diff=csharp |
| | | |
| | | ############################################################################### |
| | | # Set the merge driver for project and solution files |
| | | # |
| | | # Merging from the command prompt will add diff markers to the files if there |
| | | # are conflicts (Merging from VS is not affected by the settings below, in VS |
| | | # the diff markers are never inserted). Diff markers may cause the following |
| | | # file extensions to fail to load in VS. An alternative would be to treat |
| | | # these files as binary and thus will always conflict and require user |
| | | # intervention with every merge. To do so, just uncomment the entries below |
| | | ############################################################################### |
| | | #*.sln merge=binary |
| | | #*.csproj merge=binary |
| | | #*.vbproj merge=binary |
| | | #*.vcxproj merge=binary |
| | | #*.vcproj merge=binary |
| | | #*.dbproj merge=binary |
| | | #*.fsproj merge=binary |
| | | #*.lsproj merge=binary |
| | | #*.wixproj merge=binary |
| | | #*.modelproj merge=binary |
| | | #*.sqlproj merge=binary |
| | | #*.wwaproj merge=binary |
| | | |
| | | ############################################################################### |
| | | # behavior for image files |
| | | # |
| | | # image files are treated as binary by default. |
| | | ############################################################################### |
| | | #*.jpg binary |
| | | #*.png binary |
| | | #*.gif binary |
| | | |
| | | ############################################################################### |
| | | # diff behavior for common document formats |
| | | # |
| | | # Convert binary document formats to text before diffing them. This feature |
| | | # is only available from the command line. Turn it on by uncommenting the |
| | | # entries below. |
| | | ############################################################################### |
| | | #*.doc diff=astextplain |
| | | #*.DOC diff=astextplain |
| | | #*.docx diff=astextplain |
| | | #*.DOCX diff=astextplain |
| | | #*.dot diff=astextplain |
| | | #*.DOT diff=astextplain |
| | | #*.pdf diff=astextplain |
| | | #*.PDF diff=astextplain |
| | | #*.rtf diff=astextplain |
| | | #*.RTF diff=astextplain |
| | |
| | | ## Ignore Visual Studio temporary files, build results, and |
| | | ## files generated by popular Visual Studio add-ons. |
| | | ## |
| | | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore |
| | | |
| | | # User-specific files |
| | | *.rsuser |
| | | *.suo |
| | | *.user |
| | | *.userosscache |
| | | *.sln.docstates |
| | | |
| | | # User-specific files (MonoDevelop/Xamarin Studio) |
| | | *.userprefs |
| | | |
| | | # Mono auto generated files |
| | | mono_crash.* |
| | | |
| | | # Build results |
| | | [Dd]ebug/ |
| | |
| | | [Rr]elease/ |
| | | [Rr]eleases/ |
| | | x64/ |
| | | build/ |
| | | bld/ |
| | | [Bb]in/ |
| | | [Oo]bj/ |
| | | [Oo]ut/ |
| | | [Ll]og/ |
| | | [Ll]ogs/ |
| | | |
| | | # Roslyn cache directories |
| | | *.ide/ |
| | | |
| | | # Visual Studio 2017 auto generated files |
| | | Generated\ Files/ |
| | | |
| | | # MSTest test Results |
| | | [Tt]est[Rr]esult*/ |
| | | [Bb]uild[Ll]og.* |
| | | |
| | | #NUNIT |
| | | *.VisualState.xml |
| | | TestResult.xml |
| | | nunit-*.xml |
| | | |
| | | # Build Results of an ATL Project |
| | | [Dd]ebugPS/ |
| | | [Rr]eleasePS/ |
| | | dlldata.c |
| | | |
| | | # Benchmark Results |
| | | BenchmarkDotNet.Artifacts/ |
| | | |
| | | # .NET Core |
| | | project.lock.json |
| | | project.fragment.lock.json |
| | | artifacts/ |
| | | |
| | | # ASP.NET Scaffolding |
| | | ScaffoldingReadMe.txt |
| | | |
| | | # StyleCop |
| | | StyleCopReport.xml |
| | | |
| | | # Files built by Visual Studio |
| | | *_i.c |
| | | *_p.c |
| | | *_i.h |
| | | *.ilk |
| | | *.meta |
| | | *.obj |
| | | *.iobj |
| | | *.pch |
| | | *.pdb |
| | | *.ipdb |
| | | *.pgc |
| | | *.pgd |
| | | *.rsp |
| | |
| | | *.tlh |
| | | *.tmp |
| | | *.tmp_proj |
| | | *_wpftmp.csproj |
| | | *.log |
| | | *.vspscc |
| | | *.vssscc |
| | |
| | | ipch/ |
| | | *.aps |
| | | *.ncb |
| | | *.opendb |
| | | *.opensdf |
| | | *.sdf |
| | | *.cachefile |
| | | *.VC.db |
| | | *.VC.VC.opendb |
| | | |
| | | # Visual Studio profiler |
| | | *.psess |
| | | *.vsp |
| | | *.vspx |
| | | *.sap |
| | | |
| | | # Visual Studio Trace Files |
| | | *.e2e |
| | | |
| | | # TFS 2012 Local Workspace |
| | | $tf/ |
| | |
| | | # DotCover is a Code Coverage Tool |
| | | *.dotCover |
| | | |
| | | # AxoCover is a Code Coverage Tool |
| | | .axoCover/* |
| | | !.axoCover/settings.json |
| | | |
| | | # Coverlet is a free, cross platform Code Coverage Tool |
| | | coverage*.json |
| | | coverage*.xml |
| | | coverage*.info |
| | | |
| | | # Visual Studio code coverage results |
| | | *.coverage |
| | | *.coveragexml |
| | | |
| | | # NCrunch |
| | | _NCrunch_* |
| | | .*crunch*.local.xml |
| | | nCrunchTemp_* |
| | | |
| | | # MightyMoose |
| | | *.mm.* |
| | |
| | | # Publish Web Output |
| | | *.[Pp]ublish.xml |
| | | *.azurePubxml |
| | | ## TODO: Comment the next line if you want to checkin your |
| | | ## web deploy settings but do note that will include unencrypted |
| | | ## passwords |
| | | *.pubxml |
| | | *.publishproj |
| | | |
| | | # Microsoft Azure Web App publish settings. Comment the next line if you want to |
| | | # checkin your Azure Web App publish settings, but sensitive information contained |
| | | # in these scripts will be unencrypted |
| | | PublishScripts/ |
| | | |
| | | # NuGet Packages |
| | | packages/* |
| | | *.nupkg |
| | | ## TODO: If the tool you use requires repositories.config |
| | | ## uncomment the next line |
| | | #!packages/repositories.config |
| | | |
| | | # Enable "build/" folder in the NuGet Packages folder since |
| | | # NuGet packages use it for MSBuild targets. |
| | | # This line needs to be after the ignore of the build folder |
| | | # (and the packages folder if the line above has been uncommented) |
| | | !packages/build/ |
| | | |
| | | # Windows Azure Build Output |
| | | csx/ |
| | | *.build.csdef |
| | | |
| | | # Windows Store app package directory |
| | | AppPackages/ |
| | | BundleArtifacts/ |
| | | Package.StoreAssociation.xml |
| | | _pkginfo.txt |
| | | *.appx |
| | | *.appxbundle |
| | | *.appxupload |
| | | |
| | | # Visual Studio cache files |
| | | # files ending in .cache can be ignored |
| | | *.[Cc]ache |
| | | # but keep track of directories ending in .cache |
| | | !?*.[Cc]ache/ |
| | | |
| | | # Others |
| | | sql/ |
| | |
| | | *~ |
| | | *.dbmdl |
| | | *.dbproj.schemaview |
| | | *.jfm |
| | | *.pfx |
| | | *.publishsettings |
| | | node_modules/ |
| | | |
| | | # RIA/Silverlight projects |
| | | Generated_Code/ |
| | |
| | | Backup*/ |
| | | UpgradeLog*.XML |
| | | UpgradeLog*.htm |
| | | ServiceFabricBackup/ |
| | | *.rptproj.bak |
| | | |
| | | # SQL Server files |
| | | *.mdf |
| | | *.ldf |
| | | *.ndf |
| | | |
| | | # Business Intelligence projects |
| | | *.rdl.data |
| | | *.bim.layout |
| | | *.bim_*.settings |
| | | *.rptproj.rsuser |
| | | *- [Bb]ackup.rdl |
| | | *- [Bb]ackup ([0-9]).rdl |
| | | *- [Bb]ackup ([0-9][0-9]).rdl |
| | | |
| | | # Microsoft Fakes |
| | | FakesAssemblies/ |
| | | |
| | | # GhostDoc plugin setting file |
| | | *.GhostDoc.xml |
| | | |
| | | # Node.js Tools for Visual Studio |
| | | .ntvs_analysis.dat |
| | | node_modules/ |
| | | |
| | | # Visual Studio 6 build log |
| | | *.plg |
| | | |
| | | # Visual Studio 6 workspace options file |
| | | *.opt |
| | | |
| | | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) |
| | | *.vbw |
| | | |
| | | # Visual Studio LightSwitch build output |
| | | **/*.HTMLClient/GeneratedArtifacts |
| | | **/*.DesktopClient/GeneratedArtifacts |
| | | **/*.DesktopClient/ModelManifest.xml |
| | | **/*.Server/GeneratedArtifacts |
| | | **/*.Server/ModelManifest.xml |
| | | _Pvt_Extensions |
| | | |
| | | # Paket dependency manager |
| | | .paket/paket.exe |
| | | paket-files/ |
| | | |
| | | # FAKE - F# Make |
| | | .fake/ |
| | | |
| | | # CodeRush personal settings |
| | | .cr/personal |
| | | |
| | | # Python Tools for Visual Studio (PTVS) |
| | | __pycache__/ |
| | | *.pyc |
| | | |
| | | # Cake - Uncomment if you are using it |
| | | # tools/** |
| | | # !tools/packages.config |
| | | |
| | | # Tabs Studio |
| | | *.tss |
| | | |
| | | # Telerik's JustMock configuration file |
| | | *.jmconfig |
| | | |
| | | # BizTalk build output |
| | | *.btp.cs |
| | | *.btm.cs |
| | | *.odx.cs |
| | | *.xsd.cs |
| | | |
| | | # OpenCover UI analysis results |
| | | OpenCover/ |
| | | |
| | | # Azure Stream Analytics local run output |
| | | ASALocalRun/ |
| | | |
| | | # MSBuild Binary and Structured Log |
| | | *.binlog |
| | | |
| | | # NVidia Nsight GPU debugger configuration file |
| | | *.nvuser |
| | | |
| | | # MFractors (Xamarin productivity tool) working folder |
| | | .mfractor/ |
| | | |
| | | # Local History for Visual Studio |
| | | .localhistory/ |
| | | |
| | | # BeatPulse healthcheck temp database |
| | | healthchecksdb |
| | | |
| | | # Backup folder for Package Reference Convert tool in Visual Studio 2017 |
| | | MigrationBackup/ |
| | | |
| | | # Ionide (cross platform F# VS Code tools) working folder |
| | | .ionide/ |
| | | |
| | | # Fody - auto-generated XML schema |
| | | FodyWeavers.xsd |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "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" |
| | | ] |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | Active code page: 65001 |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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 |
| | | { |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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; } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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, //设置çIPå°ååç½å
³ä¸å¨åä¸ç½æ®µ |
| | | ID_ERROR_SET_IP_ADDRESS_ALREADY_EXISTED = 146000032, //设置çIPå·²ç»åå¨ |
| | | 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, //å é¤çROIä¸åå¨ |
| | | 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, //æ¹æ¡å
容解æå¤±è´¥ |
| | | 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, //å é¤çOCRä¸åå¨ |
| | | ID_ERROR_CONFIG_LOAD_CONTENT_ERROR = 146000050, //é
ç½®å
容解æå¤±è´¥ |
| | | 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; //软触åé´éms |
| | | [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; //æå¡å¨IPå°å |
| | | [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 //æ£åè¡¨è¾¾å¼ |
| | | } |
| | | |
| | | //æ¯ä¸ªROIçcodexçè§å |
| | | [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, //渲æå¾JPG |
| | | ID_IMAGE_FORMAT_RANDERING_PNG, //渲æå¾PNG |
| | | ID_IMAGE_FORMAT_RANDERING_BMP //渲æå¾GMP |
| | | } |
| | | |
| | | |
| | | 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; //æå¡å¨IP |
| | | 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; //æå¡å¨IP |
| | | 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; //è§£ç 容é度 |
| | | 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; //è§£ç ç»æç¶æOK/NG |
| | | public float runtime; //è§£ç èæ¶ |
| | | public uint hardParamIndex; |
| | | public uint successCount; //è§£ç æåæ° |
| | | public uint failedCount; //è§£ç å¤±è´¥æ° |
| | | public uint decodeCount; //æ»è§£ç æ° |
| | | public double decodeRate; //è§£ç ç |
| | | public uint IDDecodeROIInfoLength; //ROIçä¸ªæ° |
| | | } |
| | | |
| | | |
| | | //å½åROIè§£ç ç»æ |
| | | public struct IDDecodeROIInfo |
| | | { |
| | | |
| | | public int roiIndex; //第å 个ROI |
| | | public int decodeReusltLength; //ç®ååªä¼æä¸ä¸ªç å¶ï¼ç»æä¸º1ï¼åç»ä¿ç坿©å±æ§ |
| | | } |
| | | |
| | | |
| | | //å½åè§£ç ç±»å,åªæä¸ä¸ªç å¶ææ°æ® |
| | | public struct IDDecodeResult |
| | | { |
| | | public int conbination; |
| | | public int dmResultsLength; |
| | | public int qrResultsLength; |
| | | public int pdf417ResultsLength; |
| | | public int barcodeResultsLength; |
| | | } |
| | | |
| | | //DMè§£ç ç»æ |
| | | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] |
| | | public struct IDDMCodeResult |
| | | { |
| | | [MarshalAs(UnmanagedType.I1)] |
| | | public bool state; // å½åç»æè§£ç ç¶æ |
| | | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] |
| | | public char[] subType; // åç±»å |
| | | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] |
| | | public char[] codeString; // è§£ç ç»æ |
| | | [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è§£ç ç»æ |
| | | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] |
| | | public struct IDQRCodeResult |
| | | { |
| | | |
| | | [MarshalAs(UnmanagedType.I1)] |
| | | public bool state; //å½åç»æè§£ç ç¶æ |
| | | //IDCodeType codeType; //æ¡ç ç±»å |
| | | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] |
| | | public char[] codeString; //è§£ç ç»æ |
| | | [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è§£ç ç»æ |
| | | |
| | | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] |
| | | public struct IDPDF417CodeResult |
| | | { |
| | | |
| | | [MarshalAs(UnmanagedType.I1)] |
| | | public bool state; //å½åç»æè§£ç ç¶æ |
| | | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] |
| | | public char[] codeString; //è§£ç ç»æ |
| | | [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è§£ç ç»æ |
| | | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] |
| | | public struct IDBarCodeResult |
| | | { |
| | | |
| | | [MarshalAs(UnmanagedType.I1)] |
| | | public bool state; //å½åç»æè§£ç ç¶æ |
| | | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] |
| | | public char[] codeString; //è§£ç ç»æ |
| | | 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;//è§£ç æ¹å 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;//æ¯å¦åéèµ·å§ç»æ¢ç¬¦ï¼CodaBarä¸ç¨ |
| | | 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, // è§£ç NG æ¶ |
| | | EVENT_SOURCE_READ_SUCCESS_C, // è§£ç 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; // æç»æ¶é´ï¼msï¼ |
| | | 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ï¼OPTæ¨¡å¼ |
| | | ID_PARAM_TRIGGER_STATUS, //触åç¶æ |
| | | ID_PARAM_TRIGGER_DELAY, //触åå»¶æ¶ |
| | | ID_PARAM_TRIGGER_MODLE, //è§¦åæ¨¡å¼ |
| | | ID_PARAM_TRIGGER_DURATION, //触åæç»æ¶é´ |
| | | ID_PARAM_TRIGGER_CODE_NUM, //触åè§£ç æ° |
| | | 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, //è§£ç æ° |
| | | 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客æ·ç«¯IP |
| | | 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æå¡å¨IP |
| | | 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çæè¯»ç å¨IDæä»¶å¤¹ |
| | | 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, //æ¯å¦æ¯master |
| | | 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ä¸ä½æºIP |
| | | 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å°å |
| | | } |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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, //设置çIPå°ååç½å
³ä¸å¨åä¸ç½æ®µ |
| | | ID_ERROR_SET_IP_ADDRESS_ALREADY_EXISTED = 146000032, //设置çIPå·²ç»åå¨ |
| | | 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; //è§£ç ç»æç¶æOK/NG |
| | | public float runtime; //è§£ç èæ¶ |
| | | public uint hardParamIndex; |
| | | public uint successCount; //è§£ç æåæ° |
| | | public uint failedCount; //è§£ç å¤±è´¥æ° |
| | | public uint decodeCount; //æ»è§£ç æ° |
| | | public double decodeRate; //è§£ç ç |
| | | public uint IDDecodeROIInfoLength; //ROIè§£ç ä¿¡æ¯æ°ç»çé¿åº¦ |
| | | } |
| | | |
| | | |
| | | //å½åROIè§£ç ç»æ |
| | | public struct IDDecodeROIInfo |
| | | { |
| | | |
| | | public int roiIndex; //ROIç¼å· |
| | | public int decodeReusltLength; |
| | | } |
| | | |
| | | |
| | | //å½åè§£ç ç»æ,å½åçæ¬æ¯ä¸ªè§£ç ç»æä¸çéå,åªæä¸ä¸ªç å¶æç»æï¼éé¢çé¿åº¦ä»£è¡¨çæ¯å½åç ç±»åçè§£ç ä¸ªæ° |
| | | 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; // å½åç»æè§£ç ç¶æ |
| | | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256 )] |
| | | public char[] subType; // åç±»å |
| | | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] |
| | | public char[] codeString; // è§£ç ç»æ |
| | | [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è§£ç ç»æ |
| | | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] |
| | | public struct IDQRCodeResult { |
| | | |
| | | [MarshalAs(UnmanagedType.I1)] |
| | | public bool state; //å½åç»æè§£ç ç¶æ |
| | | //IDCodeType codeType; //æ¡ç ç±»å |
| | | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] |
| | | public char[] codeString; //è§£ç ç»æ |
| | | [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è§£ç ç»æ |
| | | |
| | | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] |
| | | public struct IDPDF417CodeResult { |
| | | |
| | | [MarshalAs(UnmanagedType.I1)] |
| | | public bool state; //å½åç»æè§£ç ç¶æ |
| | | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] |
| | | public char[] codeString; //è§£ç ç»æ |
| | | [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è§£ç ç»æ |
| | | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] |
| | | public struct IDBarCodeResult { |
| | | |
| | | [MarshalAs(UnmanagedType.I1)] |
| | | public bool state; //å½åç»æè§£ç ç¶æ |
| | | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] |
| | | public char[] codeString; //è§£ç ç»æ |
| | | public float orientation; //è§åº¦ |
| | | public float pixelPerModule; |
| | | |
| | | } |
| | | |
| | | public unsafe struct StringList |
| | | { |
| | | public char** items; |
| | | public int size; |
| | | public int capacity; |
| | | } |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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 |
| | | */ |
| | | |
| | | // æé 彿°å£°æ |
| | | |
| | | [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); |
| | | |
| | | // å°vector<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); |
| | | |
| | | // å°vector<bool>转æ¢ä¸ºC飿 ¼çæ¥å£ |
| | | [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)] //使ç¨åéè¦è°ç¨IDDevice_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åéç±»åæ¯Num |
| | | |
| | | 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); //åä¸é¢IDGeneralParam_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); |
| | | |
| | | //æ¤æ¥å£éè¦VS2019以ä¸ççæ¬ï¼C#7.0æ°å¢å¼å
¥äºæ°çè¯æ³ref returnåref localsï¼å
è®¸å½æ°çè¿åå¼ä¹å¯ä»¥è¢«å£°æä¸ºå¼ç¨ |
| | | [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æ ¼å¼ï¼BIN/ASCIIï¼ |
| | | * @param ip MCçIPå°å |
| | | * @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)] //æ¸
餿æROI |
| | | 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);//æ¸
餿æå¾åROI |
| | | |
| | | [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 第å 个IDCodeType_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 è·åææIOè¾å
¥åæ°ä¿¡æ¯é¿åº¦ |
| | | * @ |
| | | * @ |
| | | * @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 è·åææIOè¾åºåæ°ä¿¡æ¯é¿åº¦ |
| | | * @ |
| | | * @ |
| | | * @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è§£ç æ°æ® |
| | | 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表示没æè§£ç ç»æï¼-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è§£ç æ°æ® |
| | | // 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 è§£ç ç±»å æ¯å¦ 1dm ï¼2 qrï¼3 pdf417,4 barcode |
| | | * decodeROIInfoIndex roi 第å 个roi |
| | | * 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 æ¯å¦è®¾ç½®éæIP(false为临æ¶IP) |
| | | * @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 使ç¨å®SDKåè°ç¨éæ¾èµæº |
| | | * @return é误ç |
| | | */ |
| | | [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_UnInit_", CharSet = CharSet.Ansi)] |
| | | public static extern long IDVIEWER_UnInit_(IntPtr deviceList); |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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); |
| | | |
| | | //æ¤æ¥å£éè¦VS2019以ä¸çæ¬ï¼C#7.0æ´æ°æ¯æå¼å
¥äºæ°çè¯æ³ref returnåref localsï¼å
è®¸å½æ°çè¿åå¼ä¹å¯ä»¥è¢«å£°æä¸ºå¼ç¨ |
| | | [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 第å 个ROI |
| | | *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 æ¯å¦è®¾ç½®éæIP(false为临æ¶IP) |
| | | * @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 使ç¨å®SDKåè°ç¨éæ¾èµæº |
| | | * @return é误ç |
| | | */ |
| | | [DllImport("IDViewerCSDK.dll", EntryPoint = "IDVIEWER_UnInit_", CharSet = CharSet.Ansi)] |
| | | public static extern long IDVIEWER_UnInit_(IntPtr deviceList); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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æä¾çC++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); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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; |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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}"); |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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(); |
| | | |
| | | // è§£å¯ |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | // æ¥æ¾éUSBæ¥å£çè®¾å¤ |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Windows; |
| | | using System.Windows.Controls; |
| | | using System.Windows.Data; |
| | | using System.Windows.Documents; |
| | | using System.Windows.Input; |
| | | using System.Windows.Media; |
| | | using System.Windows.Media.Imaging; |
| | | using System.Windows.Shapes; |
| | | |
| | | namespace SmartScanner |
| | | { |
| | | /// <summary> |
| | | /// LoadingWindow.xaml ç交äºé»è¾ |
| | | /// </summary> |
| | | public partial class LoadingWindow : Window |
| | | { |
| | | public LoadingWindow() |
| | | { |
| | | InitializeComponent(); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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} æ¡"; |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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} æ¡"; |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Windows; |
| | | using System.Windows.Controls; |
| | | using System.Windows.Data; |
| | | using System.Windows.Documents; |
| | | using System.Windows.Input; |
| | | using System.Windows.Media; |
| | | using System.Windows.Media.Imaging; |
| | | using System.Windows.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(); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <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> |
| | | <!-- ä»
ä¿çPressedåDisabledç¶æ --> |
| | | <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="æå¡å¨IP:" 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="æå¡å¨IP:" 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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | 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(); |
| | | |
| | | //å®ä¾ålogç±» |
| | | //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;//æ¯å¦æ£å¨éè¿ |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | // 妿ä¿åç端å£ä¸å¨é¢è®¾å表ä¸ï¼æ¾ç¤ºå¨ç¼è¾æ¡ |
| | | 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("æ å°è¡¨ä¸ºç©ºï¼è¯·å
é
置顺åºåIP", "æç¤º", 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 æ¯å¦ä¸ºç©ºæå¤§å°ä¸æ£ç¡® |
| | | 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("å°åå端å£å·²è¢«å ç¨"); |
| | | 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 = "æ£å¨æ£æµä¸ããã"; |
| | | DetectState.Foreground = System.Windows.Media.Brushes.LightGreen; |
| | | })); |
| | | //计æ¶å¨å¯å¨ |
| | | stopwatch.Reset(); |
| | | stopwatch.Start(); |
| | | Console.WriteLine($"计æ¶å¨å¯å¨!"); |
| | | //å è½½ä¸æ¬¡è§£å³æ¹æ¡ |
| | | 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} å¼ NGå¾ç"); |
| | | Image_NG_Save.Clear(); |
| | | }); |
| | | |
| | | } |
| | | |
| | | //æ£æµç»æéè¿ModBusåå
¥å¯åå¨ |
| | | try |
| | | { |
| | | if (modbusTCPClient._client != null) |
| | | { |
| | | if (!IsSignleOutput) |
| | | { |
| | | // å°äºè¿å¶æ°ç»è½¬æ¢ä¸ºushort |
| | | ushort value = BinaryToUshort_MSBFirst(usOutput);//1å·-16å·ç¸æº |
| | | ushort value2 = BinaryToUshort_MSBFirst(usOutput2);//17-20å·ç¸æº |
| | | // å°ushortåå¨å¨ushortæ°ç»ä¸ |
| | | 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; // 设置为false表示åªè§¦å䏿¬¡ |
| | | 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; // 设置为false表示åªè§¦å䏿¬¡ |
| | | 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(() => |
| | | { |
| | | // æ£æ¥çªå£æ¯å¦å·²åå¨ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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(() => |
| | | { |
| | | // è®°å½å°Excelï¼æ¹éåå
¥ï¼ |
| | | 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å¾ç尿宿¥æç®å½ |
| | | /// ä¿åè·¯å¾æ ¼å¼ï¼D:\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 |
| | | { |
| | | // è·åå½åç³»ç»æ¥æï¼æ ¼å¼å为yyyyMMdd |
| | | string dateFolderName = DateTime.Now.ToString("yyyyMMdd"); |
| | | |
| | | // æå»ºå®æ´çç®æ ç®å½è·¯å¾ |
| | | string targetDirectory = Path.Combine(baseDirectory, dateFolderName); |
| | | |
| | | // å¦æç®æ ç®å½ä¸åå¨ï¼åå建 |
| | | if (!Directory.Exists(targetDirectory)) |
| | | { |
| | | Directory.CreateDirectory(targetDirectory); |
| | | } |
| | | |
| | | // éåææNGå¾çè·¯å¾ |
| | | 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; // 妿æ£å¨éè¿ï¼ç´æ¥è¿å |
| | | |
| | | modbusTCPClient.ModbudTCP_Connect(_lastIpAddress, _lastPort); |
| | | if (num++ > 3) |
| | | { |
| | | this.Dispatcher.BeginInvoke(new Action(() => |
| | | { |
| | | MessageBox.Show("Modbus master æªåå§åãæ æ³è¿æ¥PLC"); |
| | | })); |
| | | 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) |
| | | { |
| | | // 妿æ£å¨éè¿ï¼ä¸æ¾ç¤ºéè¯¯æ¶æ¯ |
| | | if (!_isReconnecting) |
| | | { |
| | | this.Dispatcher.BeginInvoke(new Action(() => |
| | | { |
| | | // ä¸åå¼¹çªï¼åªå¨æ¥å¿ä¸è®°å½ |
| | | GetMessage_Modbus("Modbusè¿æ¥æå¼ï¼å¼å§å°è¯éè¿...\n"); |
| | | })); |
| | | } |
| | | } |
| | | } |
| | | //ModBuså¿è·³ä¿¡å· |
| | | private void HeartbeatCallback(object state) |
| | | { |
| | | try |
| | | { |
| | | // 读åä¿æå¯åå¨1çå¼ |
| | | modbusTCPClient.HoldingRegisterRead(1); |
| | | Console.WriteLine("å¿è·³ä¿¡å·æ¶åæ£å¸¸"); |
| | | |
| | | // å¿è·³æ£å¸¸ï¼éç½®éè¿å°è¯æ¬¡æ° |
| | | _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 |
| | | |
| | | // é讯æµè¯ï¼debugç¨ |
| | | private void Write_Click(object sender, RoutedEventArgs e) |
| | | { |
| | | EnhancedLogViewModel.Instance.AddLog("å¼å§ModBusé讯æµè¯ï¼ææå¯åå¨åå
¥é«çµå¹³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 }; |
| | | |
| | | // å°äºè¿å¶æ°ç»è½¬æ¢ä¸ºushort |
| | | ushort value = BinaryToUshort_MSBFirst(binaryDigits); |
| | | ushort value2 = BinaryToUshort_MSBFirst(binaryDigits2); |
| | | |
| | | // å°ushortåå¨å¨ushortæ°ç»ä¸ |
| | | 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; // éæ°æåºä»¥è§¦åTCPå±çé误å¤ç |
| | | } |
| | | } |
| | | 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> |
| | | /// è·åå½åéæ©çIPå°åå符串 |
| | | /// </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> |
| | | /// å®å
¨è·åéæ©ç端å£å· |
| | | /// </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); |
| | | |
| | | // è§£æçæ¬è¯´ææä»¶ï¼æåææ°çæ¬ä¿¡æ¯ |
| | | 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 |
| | | } |
| | | } |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; // æ¯å¦æ£å¨éè¿ |
| | | |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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]; |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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("è¯·éæ©é¡ºåºåIPå°å"); |
| | | return; |
| | | } |
| | | |
| | | int selectedOrder = (int)cmbOrder.SelectedItem; |
| | | string selectedIP = cmbIP.SelectedItem.ToString(); |
| | | // æ£æ¥é¡ºåºå²çª |
| | | if (_ipMapping.Any(x => x.Key == selectedOrder)) |
| | | { |
| | | MessageBox.Show("该顺åºå·²åé
ï¼è¯·å
ç§»é¤åæåé
"); |
| | | return; |
| | | } |
| | | |
| | | // æ£æ¥IPéå¤ |
| | | if (_ipMapping.Any(x => x.Value == selectedIP)) |
| | | { |
| | | MessageBox.Show("该IPå·²åé
顺åº"); |
| | | 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]?)$"); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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("请è¾å
¥SNå·"); |
| | | 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è§£ç ä¿¡æ¯æ°ç»çé¿åº¦ è·åå°ROIçè§£ç æ°é |
| | | |
| | | 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); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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 ç¹æ§ç注éã æ´æ° |
| | | //以ä¸è¡ä¸çâen-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")] |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | //------------------------------------------------------------------------------ |
| | | // <auto-generated> |
| | | // æ¤ä»£ç ç±å·¥å
·çæã |
| | | // è¿è¡æ¶çæ¬:4.0.30319.42000 |
| | | // |
| | | // å¯¹æ¤æä»¶çæ´æ¹å¯è½ä¼å¯¼è´ä¸æ£ç¡®çè¡ä¸ºï¼å¹¶ä¸å¦æ |
| | | // éæ°çæä»£ç ï¼è¿äºæ´æ¹å°ä¼ä¸¢å¤±ã |
| | | // </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; |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | //------------------------------------------------------------------------------ |
| | | // <auto-generated> |
| | | // æ¤ä»£ç ç±å·¥å
·çæã |
| | | // è¿è¡æ¶çæ¬:4.0.30319.42000 |
| | | // |
| | | // å¯¹æ¤æä»¶çæ´æ¹å¯è½ä¼å¯¼è´ä¸æ£ç¡®çè¡ä¸ºï¼å¹¶ä¸å¦æ |
| | | // éæ°çæä»£ç ï¼è¿äºæ´æ¹å°ä¼ä¸¢å¤±ã |
| | | // </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; |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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(); |
| | | } |
| | | } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace 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 äºä»¶ç代ç ã |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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\å®£ä¼ å¾.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 ç¨åºå
ã使ç¨âNuGet ç¨åºå
è¿åâå¯ä¸è½½è¿äºç¨åºå
ãæå
³æ´å¤ä¿¡æ¯ï¼è¯·åè§ 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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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">æå¡å¨IPå°å</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} æ£å¸¸æå¼"); |
| | | 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) |
| | | { |
| | | // æ£å¸¸åæ¶ |
| | | } |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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; |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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(); |
| | | |
| | | // æ¥æ¾çæ¬è¡ (å
嫿¥æåvçæ¬å·) |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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); |
| | | } |
| | | |
| | | // æ·»å 对ScrollViewerçå¼ç¨ |
| | | 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); |
| | | } |
| | | |
| | | // éç¥èªå¨ä¿åæå¡ææ°æ¥å¿ï¼ä¼ éLogEntry对象 |
| | | _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)); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # IDViewer_2D è½¯ä»¶éæ±è§æ ¼è¯´æä¹¦ |
| | | |
| | | ## 1. æ¦è¿° |
| | | |
| | | IDViewer_2D æ¯ä¸æ¬¾ä¸ä¸çäºç»´è§è§æ£æµè½¯ä»¶ï¼ä¸»è¦ç¨äºå·¥ä¸åºæ¯ä¸çæ¡ç /äºç»´ç è¯å«ãå¾åå¤çã设å¤ç®¡çåæ°æ®éä¿¡ãè½¯ä»¶æ¯æå¤è®¾å¤è¿æ¥ã宿¶æ£æµãç»æå¤å®åæ°æ®å¯¼åºçåè½ã |
| | | |
| | | ## 2. ç³»ç»æ¶æ |
| | | |
| | | ### 2.1 ææ¯æ¶æ |
| | | - **å¼åè¯è¨**: C# |
| | | - **UIæ¡æ¶**: WPF (Windows Presentation Foundation) |
| | | - **SDKä¾èµ**: IDViewerCSDK.dll (åºå±è§è§ç®æ³åº) |
| | | - **å¾åå¤ç**: OpenCVSharp |
| | | - **éä¿¡åè®®**: Modbus TCPãTCP/IPãUDP |
| | | |
| | | ### 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æ¸
空**: æ¸
餿æROI |
| | | - [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] **æå¡å¨IP**: 设置Modbusæå¡å¨IPå°å |
| | | - [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] **å¾åæ ¼å¼**: éæ©å¾åå卿 ¼å¼ï¼BMP/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] **å¸®å©ææ¡£**: å®åçå¸®å©ææ¡£æ¯æ |
| | | - [x] **å¤è¯è¨**: æ¯æä¸è±æçé¢ |
| | | |
| | | ### 4.4 å®å
¨æ§éæ± |
| | | - [x] **æ°æ®å®å
¨**: æ£æµæ°æ®å®å
¨åå¨ |
| | | - [x] **è®¿é®æ§å¶**: ä¸¥æ ¼çè®¿é®æéæ§å¶ |
| | | - [x] **éä¿¡å å¯**: æææ°æ®éä¿¡å å¯ |
| | | - [x] **æä½å®¡è®¡**: æææä½é½æå®¡è®¡æ¥å¿ |
| | | |
| | | ### 4.5 å
¼å®¹æ§éæ± |
| | | - [x] **æä½ç³»ç»**: æ¯æWindows 7/10/11 |
| | | - [x] **硬件å
¼å®¹**: æ¯æå¤ç§è§è§è®¾å¤ |
| | | - [x] **ç½ç»å
¼å®¹**: æ¯æå¤ç§ç½ç»åè®® |
| | | - [x] **æ°æ®å
¼å®¹**: æ¯æå¤ç§æ°æ®æ ¼å¼ |
| | | |
| | | ## 5. æ¥å£éæ± |
| | | |
| | | ### 5.1 硬件æ¥å£ |
| | | - [x] **ç¸æºæ¥å£**: æ¯æGigE VisionãUSB3.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] **æ°æ®è§£æ**: è§£æåç§æ ¼å¼çæ°æ® |
| | | - [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] **代ç è§è**: éµå¾ªç¼ç è§èåæ å |
| | | - [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 | å®ååè½æè¿° | ç³»ç»åæå¸ | |
| | | |
| | | --- |
| | | **ææ¡£ç¶æ**: â
已宿 |
| | | **è¯å®¡ç¶æ**: â³ å¾
è¯å®¡ |
| | | **æ¹åç¶æ**: â³ å¾
æ¹å |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | 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 |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | ; 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 |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 2025.5.8 v1.0.7 |
| | | 1.æ°å¢è¿æ¥ç¶æçé¢è¿åº¦æ¾ç¤º |
| | | |
| | | |
| | | 2025.5.28 v1.0.8 |
| | | 1.ä¿®å¤è®¾å¤æå¼åLogè¿æ¥æ¾ç¤ºé®é¢ï¼ |
| | | 2.æ°å¢è¿æ¥ç¶ææ£æ¥å®æ¶å¨ï¼æ¯3sèªå¨æ£æ¥è¿æ¥ç¶æ |
| | | |
| | | |
| | | 2025.5.28 v1.0.9 |
| | | 1.å¤ç¹IOè¾åºåºå®åæ»20ç¹ä¿®æ¹ä¸ºèªéåºè¿æ¥æ°é |
| | | |
| | | |
| | | 2025.6.10 v1.0.9 |
| | | 1.æ°å¢å¾å宿å é¤åè½ |
| | | 2.æ°å¢èªéå¾åä¿åæ ¼å¼ï¼BMPãJGPãPNGï¼åå缩æ¯çï¼å
¶ä¸BMPæ ¼å¼çå¾åä¸å
许å缩 |
| | | 3.æ°å¢å¾åä¿åè·¯å¾èªç±éæ© |
| | | 4.æ°å¢åå¨ç©ºé´ä¸è¶³èªå¨å¼¹çªæ¥è¦ |
| | | |
| | | |
| | | 2025.6.13 v1.1.0 |
| | | 1.æ°å¢æ£æµæ¥å¿æ¾ç¤ºï¼å®æ´çæ¾ç¤ºæ£æµè¿ç¨åç»æï¼å¹¶å¯¹æ¥å¿ä¿¡æ¯è¿è¡å级æ¾ç¤º |
| | | |
| | | |
| | | 2025.6.18 v1.1.1 |
| | | 1.æ°å¢âCPUâ/âGPUâæ¨çæå¨åæ¢ |
| | | |
| | | |
| | | 2025.6.20 v1.1.1 |
| | | 1.æ°å¢æé管æ§åè½ï¼åæ°è°èéç»å½ç®¡çåè´¦æ· |
| | | |
| | | |
| | | 2025.6.27 v1.1.2 |
| | | 1.æ°å¢æä½æ¥å¿è®°å½åæ¾ç¤ºï¼è®°å½ä¿®æ¹æ¥å¿ãæä½äººåãæä½ç±»åãç®æ 设å¤åæä½è¯¦æ
|
| | | |
| | | |
| | | 2025.7.11 v1.1.3 |
| | | 1.æ°å¢æ£æµç»æè®°å½ä¿åè³Excel表ï¼ä¿åæ ¼å¼ä¸ºâäºç»´ç +æ£æµç¹ä½+æ£æµç»æ+æ£æµæ¶é´+æä½äººå |
| | | 2.主ç颿°å¢âå½åæ£æµç¶æâåâå½åéè®¯ç¶æâ两ç§ç¶ææ¾ç¤º |
| | | 3.åæ¶æ£æµæ¶âModBusæªè¿æ¥âå¼¹çªï¼æ¹ä¸ºé讯模åç¶ææ æ¾ç¤º |
| | | |
| | | |
| | | 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.æ¨¡åæ ¼å¼ä¿®æ¹ä¸ºlbå 坿 ¼å¼ |
| | | |
| | | |
| | | 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.å·¥ç¨æä»¶åºå®ä¿åå¨Projectæä»¶å¤¹ä¸ |
| | | |
| | | |
| | | 2025.10.30 v1.2.6 |
| | | 1.æ°å¢æ£æµæ¥å¿èªå¨å¯¼åºåè½ï¼èªå¨ä¿åè³Dï¼02 LBLogæä»¶å¤¹ä¸ |
| | | 2.æ¥å¿é»è®¤åå¨48å°æ¶ï¼48å°æ¶ä»¥åèªå¨æ¸
é¤ |