初始化提交

仓库转移到Gitea,初始化提交,可能丢失以前的git版本日志
This commit is contained in:
2025-11-27 16:41:05 +08:00
commit 027d0f8024
663 changed files with 171319 additions and 0 deletions

217
AUTS_AOI/AUTS_AOI.vbproj Normal file
View File

@@ -0,0 +1,217 @@
<?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.6.0.20220608\build\net48\OpenCvSharp4.runtime.win.props" Condition="Exists('..\packages\OpenCvSharp4.runtime.win.4.6.0.20220608\build\net48\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>{63C0C05D-77F2-4F37-9D0E-2EF197337FCF}</ProjectGuid>
<OutputType>WinExe</OutputType>
<StartupObject>AUTS_AOI.My.MyApplication</StartupObject>
<RootNamespace>AUTS_AOI</RootNamespace>
<AssemblyName>AUTS_AOI</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>WindowsForms</MyType>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<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>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>AUTS_AOI.xml</DocumentationFile>
<NoWarn>
</NoWarn>
<WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>AUTS_AOI.xml</DocumentationFile>
<NoWarn>
</NoWarn>
<WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<OptionExplicit>On</OptionExplicit>
</PropertyGroup>
<PropertyGroup>
<OptionCompare>Binary</OptionCompare>
</PropertyGroup>
<PropertyGroup>
<OptionStrict>On</OptionStrict>
</PropertyGroup>
<PropertyGroup>
<OptionInfer>Off</OptionInfer>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>iconfinder_Instagram_571111.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>0A24DBE81683427A18C6FFDAD761CAAF5FF0B642</ManifestCertificateThumbprint>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentFTP">
<HintPath>..\AUTS_UpdateService\FluentFTP.dll</HintPath>
</Reference>
<Reference Include="OpenCvSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
<HintPath>..\packages\OpenCvSharp4.4.6.0.20220608\lib\net48\OpenCvSharp.dll</HintPath>
</Reference>
<Reference Include="OpenCvSharp.Extensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
<HintPath>..\packages\OpenCvSharp4.Extensions.4.6.0.20220608\lib\net48\OpenCvSharp.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Drawing.Common.6.0.0\lib\net461\System.Drawing.Common.dll</HintPath>
</Reference>
<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.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<Import Include="Microsoft.VisualBasic" />
<Import Include="System" />
<Import Include="System.Collections" />
<Import Include="System.Collections.Generic" />
<Import Include="System.Data" />
<Import Include="System.Drawing" />
<Import Include="System.Diagnostics" />
<Import Include="System.Windows.Forms" />
<Import Include="System.Linq" />
<Import Include="System.Xml.Linq" />
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="FrmMain.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMain.Designer.vb">
<DependentUpon>FrmMain.vb</DependentUpon>
<SubType>Form</SubType>
</Compile>
<Compile Include="IStatisticsObserver.vb" />
<Compile Include="IFailTip.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Application.myapp</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="My Project\Resources.Designer.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="My Project\Settings.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Statistics.vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
<None Include="My Project\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="iconfinder_Instagram_571111.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %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>
<ProjectReference Include="..\UTS_Core\UTS_Core.vbproj">
<Project>{33c6456c-f00d-41ac-a6fb-db0601495c6a}</Project>
<Name>UTS_Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.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.6.0.20220608\build\net48\OpenCvSharp4.runtime.win.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\OpenCvSharp4.runtime.win.4.6.0.20220608\build\net48\OpenCvSharp4.runtime.win.props'))" />
</Target>
</Project>

57
AUTS_AOI/App.config Normal file
View File

@@ -0,0 +1,57 @@
<?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="AUTS_AOI.My.MySettings" 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.8" />
</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="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.30.1.0" newVersion="3.30.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<userSettings>
<AUTS_AOI.My.MySettings>
<setting name="Project" serializeAs="String">
<value />
</setting>
<setting name="ProcessStation" serializeAs="String">
<value />
</setting>
<setting name="ProductionLine" serializeAs="String">
<value />
</setting>
<setting name="UseCamera" serializeAs="String">
<value>True</value>
</setting>
<setting name="CameraFrameIndex" serializeAs="String">
<value>4</value>
</setting>
<setting name="DoubleCamera" serializeAs="String">
<value>True</value>
</setting>
</AUTS_AOI.My.MySettings>
</userSettings>
</configuration>

61
AUTS_AOI/CheckRecorder.vb Normal file
View File

@@ -0,0 +1,61 @@
Imports UTS_Core.Database
Imports UTS_Core.UTSModule
Imports UTS_Core.UTSModule.DbTableModel.Customer
Public Class CheckRecorder
Private ReadOnly _failTipDictionary As Dictionary(Of String, Integer)
Sub New()
_failTipDictionary = New Dictionary(Of String, Integer)()
End Sub
Public Property TestLogTableName As String
Public Sub Commit(failTip As String)
If _failTipDictionary.ContainsKey(failTip) Then
_failTipDictionary(failTip) += 1
Else
_failTipDictionary.Add(failTip, 1)
End If
End Sub
''' <summary>
''' 获取当前倒叙排序的结果信息
''' </summary>
''' <returns></returns>
Public Function UpdateFailStrings() As String()
Dim result As New List(Of String)
'排序
For Each valuePair As KeyValuePair(Of String, Integer) In _failTipDictionary.OrderByDescending(Function(x) x.Value)
result.Add(valuePair.Key)
Next
Return result.ToArray()
End Function
Public Sub ReloadFailString()
If String.IsNullOrWhiteSpace(TestLogTableName) Then Return
'以本地库为准
Using db As New DbExecutor(UtsDb.LocalDbType, UtsDb.LocalConnString)
db.Open()
Dim cmdText As String
'统计日志表分组信息
cmdText = $"select `{TestLogTable.ColNamesEnum.QA_CheckResult}`,count(*) as count from `{TestLogTableName}` where `TestResult` = '0' group by `{TestLogTable.ColNamesEnum.QA_CheckResult}` order by count"
Dim dtTable As DataTable = db.ExecuteDataTable(cmdText)
For Each row As DataRow In dtTable.Rows
_failTipDictionary.Add(row($"{TestLogTable.ColNamesEnum.QA_CheckResult}").ToString(), CInt(row("count")))
Next
db.Close()
End Using
End Sub
End Class

452
AUTS_AOI/FrmMain.Designer.vb generated Normal file
View File

@@ -0,0 +1,452 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FrmMain
Inherits System.Windows.Forms.Form
'Form 重写 Dispose以清理组件列表。
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改它。
'不要使用代码编辑器修改它。
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(FrmMain))
Me.StatusStrip1 = New System.Windows.Forms.StatusStrip()
Me.TssLblProductionLine = New System.Windows.Forms.ToolStripStatusLabel()
Me.TssLblStaion = New System.Windows.Forms.ToolStripStatusLabel()
Me.TsLblCheckSum = New System.Windows.Forms.ToolStripStatusLabel()
Me.TssLblInvalidCount = New System.Windows.Forms.ToolStripStatusLabel()
Me.TssLblValidCount = New System.Windows.Forms.ToolStripStatusLabel()
Me.TssLblPassCount = New System.Windows.Forms.ToolStripStatusLabel()
Me.TssLblFailCount = New System.Windows.Forms.ToolStripStatusLabel()
Me.TssLblYield = New System.Windows.Forms.ToolStripStatusLabel()
Me.ToolStrip1 = New System.Windows.Forms.ToolStrip()
Me.TsChangeStation = New System.Windows.Forms.ToolStripButton()
Me.ToolStripLabel1 = New System.Windows.Forms.ToolStripLabel()
Me.TsCboCameraFrame = New System.Windows.Forms.ToolStripComboBox()
Me.ToolStripLabel2 = New System.Windows.Forms.ToolStripLabel()
Me.SplitContainer1 = New System.Windows.Forms.SplitContainer()
Me.RdBtnDouble = New System.Windows.Forms.RadioButton()
Me.RdBtnSingle = New System.Windows.Forms.RadioButton()
Me.GroupBox3 = New System.Windows.Forms.GroupBox()
Me.RtxRecord = New System.Windows.Forms.RichTextBox()
Me.LblResult = New System.Windows.Forms.Label()
Me.GroupBox4 = New System.Windows.Forms.GroupBox()
Me.CboProductionLines = New System.Windows.Forms.ComboBox()
Me.BtnCommit = New System.Windows.Forms.Button()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.RtxBarcodeSn = New System.Windows.Forms.RichTextBox()
Me.SplitContainer2 = New System.Windows.Forms.SplitContainer()
Me.GroupBox2 = New System.Windows.Forms.GroupBox()
Me.PicCamera1 = New System.Windows.Forms.PictureBox()
Me.GroupBox5 = New System.Windows.Forms.GroupBox()
Me.PicCamera2 = New System.Windows.Forms.PictureBox()
Me.StatusStrip1.SuspendLayout()
Me.ToolStrip1.SuspendLayout()
CType(Me.SplitContainer1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SplitContainer1.Panel1.SuspendLayout()
Me.SplitContainer1.Panel2.SuspendLayout()
Me.SplitContainer1.SuspendLayout()
Me.GroupBox3.SuspendLayout()
Me.GroupBox4.SuspendLayout()
Me.GroupBox1.SuspendLayout()
CType(Me.SplitContainer2, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SplitContainer2.Panel1.SuspendLayout()
Me.SplitContainer2.Panel2.SuspendLayout()
Me.SplitContainer2.SuspendLayout()
Me.GroupBox2.SuspendLayout()
CType(Me.PicCamera1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.GroupBox5.SuspendLayout()
CType(Me.PicCamera2, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'StatusStrip1
'
Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.TssLblProductionLine, Me.TssLblStaion, Me.TsLblCheckSum, Me.TssLblInvalidCount, Me.TssLblValidCount, Me.TssLblPassCount, Me.TssLblFailCount, Me.TssLblYield})
Me.StatusStrip1.Location = New System.Drawing.Point(0, 579)
Me.StatusStrip1.Name = "StatusStrip1"
Me.StatusStrip1.Size = New System.Drawing.Size(790, 22)
Me.StatusStrip1.TabIndex = 0
Me.StatusStrip1.Text = "StatusStrip1"
'
'TssLblProductionLine
'
Me.TssLblProductionLine.ForeColor = System.Drawing.Color.Black
Me.TssLblProductionLine.Name = "TssLblProductionLine"
Me.TssLblProductionLine.Size = New System.Drawing.Size(44, 17)
Me.TssLblProductionLine.Text = "A-Line"
'
'TssLblStaion
'
Me.TssLblStaion.ForeColor = System.Drawing.Color.Black
Me.TssLblStaion.Name = "TssLblStaion"
Me.TssLblStaion.Size = New System.Drawing.Size(68, 17)
Me.TssLblStaion.Text = "BLV-12 A1"
'
'TsLblCheckSum
'
Me.TsLblCheckSum.Name = "TsLblCheckSum"
Me.TsLblCheckSum.Size = New System.Drawing.Size(64, 17)
Me.TsLblCheckSum.Text = "Sum:0000"
'
'TssLblInvalidCount
'
Me.TssLblInvalidCount.Name = "TssLblInvalidCount"
Me.TssLblInvalidCount.Size = New System.Drawing.Size(77, 17)
Me.TssLblInvalidCount.Text = "Invalid:0000"
'
'TssLblValidCount
'
Me.TssLblValidCount.Name = "TssLblValidCount"
Me.TssLblValidCount.Size = New System.Drawing.Size(68, 17)
Me.TssLblValidCount.Text = "Valid:0000"
'
'TssLblPassCount
'
Me.TssLblPassCount.Name = "TssLblPassCount"
Me.TssLblPassCount.Size = New System.Drawing.Size(65, 17)
Me.TssLblPassCount.Text = "Pass:0000"
'
'TssLblFailCount
'
Me.TssLblFailCount.Name = "TssLblFailCount"
Me.TssLblFailCount.Size = New System.Drawing.Size(58, 17)
Me.TssLblFailCount.Text = "Fail:0000"
'
'TssLblYield
'
Me.TssLblYield.Name = "TssLblYield"
Me.TssLblYield.Size = New System.Drawing.Size(81, 17)
Me.TssLblYield.Text = "Yield:00.00%"
'
'ToolStrip1
'
Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.TsChangeStation, Me.ToolStripLabel1, Me.TsCboCameraFrame, Me.ToolStripLabel2})
Me.ToolStrip1.Location = New System.Drawing.Point(0, 0)
Me.ToolStrip1.Name = "ToolStrip1"
Me.ToolStrip1.Size = New System.Drawing.Size(790, 40)
Me.ToolStrip1.TabIndex = 1
Me.ToolStrip1.Text = "ToolStrip1"
'
'TsChangeStation
'
Me.TsChangeStation.Image = CType(resources.GetObject("TsChangeStation.Image"), System.Drawing.Image)
Me.TsChangeStation.ImageTransparentColor = System.Drawing.Color.Magenta
Me.TsChangeStation.Name = "TsChangeStation"
Me.TsChangeStation.Size = New System.Drawing.Size(60, 37)
Me.TsChangeStation.Text = "切换站位"
Me.TsChangeStation.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText
Me.TsChangeStation.ToolTipText = "切换站位"
'
'ToolStripLabel1
'
Me.ToolStripLabel1.Name = "ToolStripLabel1"
Me.ToolStripLabel1.Size = New System.Drawing.Size(44, 37)
Me.ToolStripLabel1.Text = "分辨率"
'
'TsCboCameraFrame
'
Me.TsCboCameraFrame.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.TsCboCameraFrame.Name = "TsCboCameraFrame"
Me.TsCboCameraFrame.Size = New System.Drawing.Size(121, 40)
'
'ToolStripLabel2
'
Me.ToolStripLabel2.Name = "ToolStripLabel2"
Me.ToolStripLabel2.Size = New System.Drawing.Size(0, 37)
'
'SplitContainer1
'
Me.SplitContainer1.Dock = System.Windows.Forms.DockStyle.Fill
Me.SplitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1
Me.SplitContainer1.Location = New System.Drawing.Point(0, 40)
Me.SplitContainer1.Name = "SplitContainer1"
'
'SplitContainer1.Panel1
'
Me.SplitContainer1.Panel1.Controls.Add(Me.RdBtnDouble)
Me.SplitContainer1.Panel1.Controls.Add(Me.RdBtnSingle)
Me.SplitContainer1.Panel1.Controls.Add(Me.GroupBox3)
Me.SplitContainer1.Panel1.Controls.Add(Me.LblResult)
Me.SplitContainer1.Panel1.Controls.Add(Me.GroupBox4)
Me.SplitContainer1.Panel1.Controls.Add(Me.BtnCommit)
Me.SplitContainer1.Panel1.Controls.Add(Me.GroupBox1)
'
'SplitContainer1.Panel2
'
Me.SplitContainer1.Panel2.Controls.Add(Me.SplitContainer2)
Me.SplitContainer1.Size = New System.Drawing.Size(790, 539)
Me.SplitContainer1.SplitterDistance = 429
Me.SplitContainer1.TabIndex = 0
Me.SplitContainer1.TabStop = False
'
'RdBtnDouble
'
Me.RdBtnDouble.AutoSize = True
Me.RdBtnDouble.Checked = True
Me.RdBtnDouble.Location = New System.Drawing.Point(347, 154)
Me.RdBtnDouble.Name = "RdBtnDouble"
Me.RdBtnDouble.Size = New System.Drawing.Size(71, 16)
Me.RdBtnDouble.TabIndex = 1
Me.RdBtnDouble.TabStop = True
Me.RdBtnDouble.Text = "双摄像头"
Me.RdBtnDouble.UseVisualStyleBackColor = True
'
'RdBtnSingle
'
Me.RdBtnSingle.AutoSize = True
Me.RdBtnSingle.Location = New System.Drawing.Point(259, 154)
Me.RdBtnSingle.Name = "RdBtnSingle"
Me.RdBtnSingle.Size = New System.Drawing.Size(71, 16)
Me.RdBtnSingle.TabIndex = 6
Me.RdBtnSingle.TabStop = True
Me.RdBtnSingle.Text = "单摄像头"
Me.RdBtnSingle.UseVisualStyleBackColor = True
'
'GroupBox3
'
Me.GroupBox3.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.GroupBox3.Controls.Add(Me.RtxRecord)
Me.GroupBox3.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.GroupBox3.Location = New System.Drawing.Point(12, 172)
Me.GroupBox3.Name = "GroupBox3"
Me.GroupBox3.Size = New System.Drawing.Size(406, 317)
Me.GroupBox3.TabIndex = 2
Me.GroupBox3.TabStop = False
Me.GroupBox3.Text = "校验日志"
'
'RtxRecord
'
Me.RtxRecord.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.RtxRecord.Dock = System.Windows.Forms.DockStyle.Fill
Me.RtxRecord.Font = New System.Drawing.Font("微软雅黑", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.RtxRecord.Location = New System.Drawing.Point(3, 22)
Me.RtxRecord.Name = "RtxRecord"
Me.RtxRecord.ReadOnly = True
Me.RtxRecord.Size = New System.Drawing.Size(400, 292)
Me.RtxRecord.TabIndex = 0
Me.RtxRecord.TabStop = False
Me.RtxRecord.Text = ""
'
'LblResult
'
Me.LblResult.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.LblResult.Font = New System.Drawing.Font("宋体", 18.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.LblResult.Location = New System.Drawing.Point(12, 496)
Me.LblResult.Name = "LblResult"
Me.LblResult.Size = New System.Drawing.Size(249, 40)
Me.LblResult.TabIndex = 4
Me.LblResult.Text = "待开始测试"
Me.LblResult.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'GroupBox4
'
Me.GroupBox4.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.GroupBox4.Controls.Add(Me.CboProductionLines)
Me.GroupBox4.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.GroupBox4.Location = New System.Drawing.Point(12, 9)
Me.GroupBox4.Name = "GroupBox4"
Me.GroupBox4.Size = New System.Drawing.Size(409, 50)
Me.GroupBox4.TabIndex = 3
Me.GroupBox4.TabStop = False
Me.GroupBox4.Text = "产线"
'
'CboProductionLines
'
Me.CboProductionLines.Dock = System.Windows.Forms.DockStyle.Fill
Me.CboProductionLines.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.CboProductionLines.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.CboProductionLines.ForeColor = System.Drawing.Color.Gray
Me.CboProductionLines.FormattingEnabled = True
Me.CboProductionLines.Items.AddRange(New Object() {"Q1", "Q2", "Q3", "Q4"})
Me.CboProductionLines.Location = New System.Drawing.Point(3, 22)
Me.CboProductionLines.Name = "CboProductionLines"
Me.CboProductionLines.Size = New System.Drawing.Size(403, 24)
Me.CboProductionLines.TabIndex = 0
Me.CboProductionLines.TabStop = False
'
'BtnCommit
'
Me.BtnCommit.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.BtnCommit.Font = New System.Drawing.Font("宋体", 20.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.BtnCommit.Location = New System.Drawing.Point(313, 495)
Me.BtnCommit.Name = "BtnCommit"
Me.BtnCommit.Size = New System.Drawing.Size(105, 40)
Me.BtnCommit.TabIndex = 2
Me.BtnCommit.Text = "提交"
Me.BtnCommit.UseVisualStyleBackColor = True
'
'GroupBox1
'
Me.GroupBox1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.GroupBox1.Controls.Add(Me.RtxBarcodeSn)
Me.GroupBox1.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.GroupBox1.Location = New System.Drawing.Point(12, 65)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(409, 86)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "产品序号"
'
'RtxBarcodeSn
'
Me.RtxBarcodeSn.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.RtxBarcodeSn.Dock = System.Windows.Forms.DockStyle.Fill
Me.RtxBarcodeSn.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.RtxBarcodeSn.ForeColor = System.Drawing.Color.Gray
Me.RtxBarcodeSn.Location = New System.Drawing.Point(3, 22)
Me.RtxBarcodeSn.Name = "RtxBarcodeSn"
Me.RtxBarcodeSn.Size = New System.Drawing.Size(403, 61)
Me.RtxBarcodeSn.TabIndex = 0
Me.RtxBarcodeSn.Text = "123456ABCDEFabcdef"
'
'SplitContainer2
'
Me.SplitContainer2.Dock = System.Windows.Forms.DockStyle.Fill
Me.SplitContainer2.IsSplitterFixed = True
Me.SplitContainer2.Location = New System.Drawing.Point(0, 0)
Me.SplitContainer2.Name = "SplitContainer2"
Me.SplitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal
'
'SplitContainer2.Panel1
'
Me.SplitContainer2.Panel1.Controls.Add(Me.GroupBox2)
'
'SplitContainer2.Panel2
'
Me.SplitContainer2.Panel2.Controls.Add(Me.GroupBox5)
Me.SplitContainer2.Size = New System.Drawing.Size(357, 539)
Me.SplitContainer2.SplitterDistance = 258
Me.SplitContainer2.TabIndex = 0
'
'GroupBox2
'
Me.GroupBox2.Controls.Add(Me.PicCamera1)
Me.GroupBox2.Dock = System.Windows.Forms.DockStyle.Fill
Me.GroupBox2.Font = New System.Drawing.Font("微软雅黑", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.GroupBox2.Location = New System.Drawing.Point(0, 0)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(357, 258)
Me.GroupBox2.TabIndex = 1
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "主摄像头"
'
'PicCamera1
'
Me.PicCamera1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom
Me.PicCamera1.Dock = System.Windows.Forms.DockStyle.Fill
Me.PicCamera1.Location = New System.Drawing.Point(3, 25)
Me.PicCamera1.Name = "PicCamera1"
Me.PicCamera1.Size = New System.Drawing.Size(351, 230)
Me.PicCamera1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Me.PicCamera1.TabIndex = 3
Me.PicCamera1.TabStop = False
'
'GroupBox5
'
Me.GroupBox5.Controls.Add(Me.PicCamera2)
Me.GroupBox5.Dock = System.Windows.Forms.DockStyle.Fill
Me.GroupBox5.Font = New System.Drawing.Font("微软雅黑", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.GroupBox5.Location = New System.Drawing.Point(0, 0)
Me.GroupBox5.Name = "GroupBox5"
Me.GroupBox5.Size = New System.Drawing.Size(357, 277)
Me.GroupBox5.TabIndex = 2
Me.GroupBox5.TabStop = False
Me.GroupBox5.Text = "次摄像头"
'
'PicCamera2
'
Me.PicCamera2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom
Me.PicCamera2.Dock = System.Windows.Forms.DockStyle.Fill
Me.PicCamera2.Location = New System.Drawing.Point(3, 25)
Me.PicCamera2.Name = "PicCamera2"
Me.PicCamera2.Size = New System.Drawing.Size(351, 249)
Me.PicCamera2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Me.PicCamera2.TabIndex = 3
Me.PicCamera2.TabStop = False
'
'FrmMain
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(790, 601)
Me.Controls.Add(Me.SplitContainer1)
Me.Controls.Add(Me.ToolStrip1)
Me.Controls.Add(Me.StatusStrip1)
Me.ForeColor = System.Drawing.Color.Gray
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "FrmMain"
Me.Text = "Form1"
Me.StatusStrip1.ResumeLayout(False)
Me.StatusStrip1.PerformLayout()
Me.ToolStrip1.ResumeLayout(False)
Me.ToolStrip1.PerformLayout()
Me.SplitContainer1.Panel1.ResumeLayout(False)
Me.SplitContainer1.Panel1.PerformLayout()
Me.SplitContainer1.Panel2.ResumeLayout(False)
CType(Me.SplitContainer1,System.ComponentModel.ISupportInitialize).EndInit
Me.SplitContainer1.ResumeLayout(false)
Me.GroupBox3.ResumeLayout(false)
Me.GroupBox4.ResumeLayout(false)
Me.GroupBox1.ResumeLayout(false)
Me.SplitContainer2.Panel1.ResumeLayout(false)
Me.SplitContainer2.Panel2.ResumeLayout(false)
CType(Me.SplitContainer2,System.ComponentModel.ISupportInitialize).EndInit
Me.SplitContainer2.ResumeLayout(false)
Me.GroupBox2.ResumeLayout(false)
CType(Me.PicCamera1,System.ComponentModel.ISupportInitialize).EndInit
Me.GroupBox5.ResumeLayout(false)
CType(Me.PicCamera2,System.ComponentModel.ISupportInitialize).EndInit
Me.ResumeLayout(false)
Me.PerformLayout
End Sub
Friend WithEvents StatusStrip1 As StatusStrip
Friend WithEvents ToolStrip1 As ToolStrip
Friend WithEvents TsChangeStation As ToolStripButton
Friend WithEvents SplitContainer1 As SplitContainer
Friend WithEvents GroupBox2 As GroupBox
Friend WithEvents GroupBox1 As GroupBox
Friend WithEvents RtxBarcodeSn As RichTextBox
Friend WithEvents RtxRecord As RichTextBox
Friend WithEvents GroupBox3 As GroupBox
Friend WithEvents TsLblCheckSum As ToolStripStatusLabel
Friend WithEvents TssLblPassCount As ToolStripStatusLabel
Friend WithEvents TssLblFailCount As ToolStripStatusLabel
Friend WithEvents BtnCommit As Button
Friend WithEvents TssLblStaion As ToolStripStatusLabel
Friend WithEvents TssLblYield As ToolStripStatusLabel
Friend WithEvents GroupBox4 As GroupBox
Friend WithEvents CboProductionLines As ComboBox
Friend WithEvents TssLblProductionLine As ToolStripStatusLabel
Friend WithEvents TssLblInvalidCount As ToolStripStatusLabel
Friend WithEvents TssLblValidCount As ToolStripStatusLabel
Friend WithEvents PicCamera1 As PictureBox
Friend WithEvents LblResult As Label
Friend WithEvents ToolStripLabel1 As ToolStripLabel
Friend WithEvents TsCboCameraFrame As ToolStripComboBox
Friend WithEvents ToolStripLabel2 As ToolStripLabel
Friend WithEvents SplitContainer2 As SplitContainer
Friend WithEvents GroupBox5 As GroupBox
Friend WithEvents PicCamera2 As PictureBox
Friend WithEvents RdBtnDouble As RadioButton
Friend WithEvents RdBtnSingle As RadioButton
End Class

1978
AUTS_AOI/FrmMain.resx Normal file

File diff suppressed because it is too large Load Diff

541
AUTS_AOI/FrmMain.vb Normal file
View File

@@ -0,0 +1,541 @@
Imports System.Text
Imports System.Threading
Imports OpenCvSharp
Imports OpenCvSharp.Extensions
Imports UTS_Core.UTSModule.Test
Imports UTS_Core.UTSModule
Imports UTS_Core.UTSModule.Station
Public Class FrmMain
Implements IStatisticsObserver
Implements IProcessStation
Implements IProductionLine
Private _ftp As FtpService
Private _utsApp As UtsAppForm
Private _checkStatistics As Statistics
Private _snSqliteChar As Char = "|"c
Private _useCamera As Boolean
Private _doubleCarera As Boolean
Public Sub ProductionLineChanged() Implements IProductionLine.ProductionLineChanged
TssLblProductionLine.Text = CboProductionLines.Text
My.Settings.ProductionLine = CboProductionLines.Text
End Sub
Public Sub StationChanged() Implements IProcessStation.StationChanged
My.Settings.Project = _utsApp.ProcessStation.ParentProject.Name
My.Settings.ProcessStation = _utsApp.ProcessStation.Name
UpdateStation(_utsApp.ProcessStation.ParentProject.Name, _utsApp.ProcessStation.Name)
End Sub
Public Sub UpdateStation(projectName As String, stationName As String)
If String.IsNullOrWhiteSpace(projectName) OrElse
String.IsNullOrWhiteSpace(stationName) Then
TssLblStaion.Text = $"Invalid Station"
Else
TssLblStaion.Text = $"{projectName} - {stationName}"
End If
End Sub
Public Sub UpdateFailCount(failCount As Integer) Implements IStatisticsObserver.UpdateFailCount
TssLblFailCount.Text = $"Fail:{failCount:D4}"
End Sub
Public Sub UpdatePassCount(passCount As Integer) Implements IStatisticsObserver.UpdatePassCount
TssLblPassCount.Text = $"Pass:{passCount:D4}"
End Sub
Public Sub UpdateValidCount(validCount As Integer) Implements IStatisticsObserver.UpdateValidCount
TssLblValidCount.Text = $"Valid:{validCount:D4}"
End Sub
Public Sub UpdateInvalidCount(invalidCount As Integer) Implements IStatisticsObserver.UpdateInvalidCount
TssLblInvalidCount.Text = $"Invalid:{invalidCount:D4}"
End Sub
Public Sub UpdateSumCount(sumCount As Integer) Implements IStatisticsObserver.UpdateSumCount
TsLblCheckSum.Text = $"Sum:{sumCount:D4}"
End Sub
Public Sub UpdateYield(yield As Double) Implements IStatisticsObserver.UpdateYield
Select Case yield
Case > 90
TssLblYield.ForeColor = Color.DarkGreen
Case > 75
TssLblYield.ForeColor = Color.Green
Case > 60
TssLblYield.ForeColor = Color.Orange
Case > 40
TssLblYield.ForeColor = Color.OrangeRed
Case Else
TssLblYield.ForeColor = Color.Red
End Select
TssLblYield.Text = $"Yield:{yield:F2}%"
End Sub
Private Sub FrmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
My.Application.SaveMySettingsOnExit = True
_checkStatistics = New Statistics()
_checkStatistics.AddStatisticsObserver(Me)
_utsApp = UtsAppForm.CreateSingleton()
Try
If _utsApp.IsInitialized = False Then
_utsApp.AddStatisticsObserver(Me)
_utsApp.Initialize(ProcessStation.StationTypeEnum.AOI)
_utsApp.LoadStation(My.Settings.Project, My.Settings.ProcessStation)
End If
Catch ex As Exception
MsgBox($"Initialize UTSForm Error:{ex.Message}")
Close()
Return
End Try
Try
_ftp = New FtpService(UtsRegistry.FtpHost, CInt(_utsApp.License.FtpPort), _utsApp.License.FtpUser, _utsApp.License.FtpPwd)
Catch ex As Exception
MsgBox($"Initialize FtpService Error:{ex.Message}")
Close()
Return
End Try
'初始化产线信息
CboProductionLines.Items.Clear()
CboProductionLines.Items.AddRange(_utsApp.ProductionLines.GetLineNames())
CboProductionLines.SelectedIndex = CboProductionLines.Items.IndexOf(My.Settings.ProductionLine)
_doubleCarera = My.Settings.DoubleCamera
If _doubleCarera Then
RdBtnDouble.Checked = True
Else
RdBtnSingle.Checked = True
End If
TsCboCameraFrame.Items.Clear()
For Each siz As Size In _cameraFrame
TsCboCameraFrame.Items.Add($"{siz.Width}*{siz.Height}")
Next
TsCboCameraFrame.SelectedIndex = My.Settings.CameraFrameIndex
RtxBarcodeSn.Clear()
InitImageControl()
Text = $"{Application.ProductName} {Application.ProductVersion}"
End Sub
Private Sub InitImageControl()
_imgControl(0) = PicCamera1
_imgControl(1) = PicCamera2
End Sub
Private Sub FrmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
SaveLogFile()
My.Settings.CameraFrameIndex = _selectFrameSizeIndex
My.Settings.DoubleCamera = _doubleCarera
_utsApp.Dispose()
CloseForm()
End Sub
Private Sub CloseForm()
Text = $"Goodbye World."
For i As Double = 1 To 0 Step -0.05
Thread.Sleep(50)
Opacity = i
Next
End Sub
Private Sub RtxDUT_SN_KeyDown(sender As Object, e As KeyEventArgs) Handles RtxBarcodeSn.KeyDown
If e.KeyCode = Keys.Enter Then
If String.IsNullOrWhiteSpace(RtxBarcodeSn.Text) = False Then
My.Computer.Keyboard.SendKeys("|")
e.SuppressKeyPress = True
e.Handled = True
End If
ElseIf e.KeyCode = Keys.Space Then
CommitTestResult()
e.SuppressKeyPress = True
e.Handled = True
Console.WriteLine($"{ e.SuppressKeyPress} { e.Handled}")
End If
End Sub
Private Function UploadFileToFtp(localPath As String, remotePath As String) As Boolean
Try
_ftp.FtpUpload(remotePath, localPath)
Catch ex As Exception
MsgBox($"上传图像[{localPath}]失败:{ex.Message}")
'todo:添加本地缓存上传失败图像,定期上传
'记录本地位置上传文件位置写入FTP的缓存数据库
'服务新增ftp同步任务区分上传下载
'
'
'记录ftp命令
'只记录上传下载命令?
Return False
End Try
Return True
End Function
Private Function GetImageName(barCode As String, index As Integer) As String
Dim fileName As New StringBuilder
fileName.Append(_utsApp.ProcessStation.ParentProject.Name)
fileName.Append("_")
fileName.Append(_utsApp.ProcessStation.Name)
fileName.Append("_")
fileName.Append(barCode)
fileName.Append("_")
fileName.Append($"{Now:yyyyMMdd_HHmmss}")
fileName.Append("_")
fileName.Append($"{index}")
fileName.Append(".jpg")
Return fileName.ToString()
End Function
Private Function SaveImageToLocal(localPath As String, index As Integer) As Boolean
If _imgControl(index).Image Is Nothing Then
MsgBox($"未检测到Camera[{index}] Image,录入失败")
Return False
End If
Dim img As Image = CType(_imgControl(index).Image.Clone(), Image)
Try
img.Save(localPath, Imaging.ImageFormat.Jpeg)
Catch ex As Exception
MsgBox($"Save Camera[{index}] Image Error:{ex.Message}")
Return False
End Try
Return True
End Function
Private Sub BtnCommit_Click(sender As Object, e As EventArgs) Handles BtnCommit.Click
CommitTestResult()
End Sub
Private Sub CommitTestResult()
If _utsApp.ProcessStation Is Nothing Then
MsgBox($"请选择项目与测试站后再尝试录入!")
Return
End If
If String.IsNullOrWhiteSpace(CboProductionLines.Text) Then
MsgBox($"请选择生产线后再尝试录入!")
Return
End If
Dim barcodeString As String = RtxBarcodeSn.Text.ToUpper
If String.IsNullOrWhiteSpace(barcodeString) Then
MsgBox($"请输入合法的序列号!")
Return
End If
Dim barcodeList As String() = barcodeString.Split(New Char() {_snSqliteChar}, StringSplitOptions.RemoveEmptyEntries)
If barcodeList.Count() = 0 Then Return
For Each barcode As String In barcodeList
If barcode.Length <> 8 Then
MsgBox($"录入失败,条码[{barcode}]长度非法,请检查后重新录入!")
Return
End If
Static imgDirPath As String = $"{Application.StartupPath}\Img"
If IO.Directory.Exists(imgDirPath) = False Then IO.Directory.CreateDirectory(imgDirPath)
Dim imgFileName As String = GetImageName(barcode, 0)
Dim imgLocalPath As String = $"{imgDirPath}\{imgFileName}"
Dim imgRemotePath As String = $"/uts_Manager/AUTS/{_utsApp.License.VendorName}/AOI/{_utsApp.ProcessStation.ParentProject.Index}/{imgFileName}"
If SaveImageToLocal(imgLocalPath, 0) = False Then Return
If UploadFileToFtp(imgLocalPath, imgRemotePath) = False Then Return
Dim imgFileName2 As String = GetImageName(barcode, 1)
Dim imgRemotePath2 As String = ""
If _doubleCarera Then
Dim imgLocalPath2 As String = $"{imgDirPath}\{imgFileName2}"
If SaveImageToLocal(imgLocalPath2, 1) = False Then Return
imgRemotePath2 = $"/uts_Manager/AUTS/{_utsApp.License.VendorName}/AOI/{_utsApp.ProcessStation.ParentProject.Index}/{imgFileName2}"
If UploadFileToFtp(imgLocalPath2, imgRemotePath2) = False Then Return
End If
Try
FillTestResult(barcode, imgRemotePath, imgRemotePath2)
_utsApp.CommitTestResult()
_checkStatistics.AddPassCount()
AppendRecord(True, _utsApp.ProcessStation.ParentProject.Index, _utsApp.ProcessStation.StationID, _utsApp.TestResult.OrderID, _utsApp.TestResult.DUT_SN, "Pass")
LblResult.Text = $"{_utsApp.ProcessStation.ParentProject.Index:D2}-{_utsApp.ProcessStation.StationID:D2}-{_utsApp.TestResult.OrderID:D6}-{_utsApp.TestResult.DUT_SN} 录入成功"
LblResult.ForeColor = Color.Green
Catch ex As Exception
_checkStatistics.AddInvalidCount()
MsgBox($"测试结果录入失败:{ex.Message}")
LblResult.Text = $"{_utsApp.TestResult.DUT_SN} 录入失败"
LblResult.ForeColor = Color.Red
End Try
Next
TestResultCommitted()
End Sub
''' <summary>
''' 填充测试记录内容,每个应用程序这个部分有所差异
''' </summary>
Public Sub FillTestResult(barcodeSn As String, imgPath As String, imgPath2 As String)
_utsApp.TestResult.ResetTestResult()
'产线索引
Dim lineID As Integer = _utsApp.ProductionLines(CboProductionLines.Text).ID
_utsApp.TestResult.ProductionLineID = lineID
'测试开始时间
_utsApp.TestResult.StartTime = Now
_utsApp.TestResult.DUT_SN = barcodeSn
_utsApp.TestResult.TestResult = TestResult.TestResultEnum.Pass
_utsApp.TestResult.AddCustomRecord("ImagePath", imgPath)
_utsApp.TestResult.AddCustomRecord("ImagePath2", imgPath2)
End Sub
Public Sub TestResultCommitted()
RtxBarcodeSn.Focus()
RtxBarcodeSn.SelectAll()
End Sub
Private Sub TsChangeStation_Click(sender As Object, e As EventArgs) Handles TsChangeStation.Click
Try
Dim filed As New Dictionary(Of String, String) From {{"ImagePath", "varchar(128)"}, {"ImagePath2", "varchar(128)"}}
_utsApp.ChangeStation(filed)
Catch ex As Exception
MsgBox($"ChangeStation Error:{ex.Message}")
End Try
End Sub
''' <summary>
''' 添加提示信息
''' </summary>
''' <param name="checkResult">校验结果</param>
''' <param name="log">提示信息</param>
Private Sub AppendRecord(checkResult As Boolean, pid As Integer, sid As Integer, order As Integer, barcode As String, log As String)
Static recordMaxCount As Integer = 256
Static recordCount As Integer = 1
With RtxRecord
.Enabled = False
If recordCount >= recordMaxCount Then
SaveLogFile()
.Clear()
recordCount = 1
End If
.SelectionStart = .TextLength
.SelectionColor = Color.Black
.AppendText($"{recordCount:D4} ")
.SelectionStart = .TextLength
.SelectionColor = Color.DarkBlue
.AppendText($"{Now:MMdd_HH:mm:ss} ")
.SelectionStart = .TextLength
.SelectionColor = Color.Black
.AppendText($"{pid:D2}-")
.SelectionStart = .TextLength
.SelectionColor = Color.Black
.AppendText($"{sid:D2} ")
.SelectionStart = .TextLength
.SelectionColor = Color.DarkSeaGreen
.AppendText($"{order:D6} ")
.SelectionStart = .TextLength
.SelectionColor = Color.DarkOrange
.AppendText($"{barcode,8} ")
.SelectionStart = .TextLength
.SelectionColor = CType(IIf(checkResult, Color.Green, Color.Red), Color)
.AppendText($"{log}{vbNewLine}")
recordCount += 1
.ScrollToCaret()
.Enabled = True
End With
End Sub
Private Sub SaveLogFile()
Dim dirPath As String = $"{Application.StartupPath}\Log"
Dim filePath As String = $"{dirPath}\Log_{Now:yyyyMMdd_HHmmss}.txt"
If IO.Directory.Exists(dirPath) = False Then IO.Directory.CreateDirectory(dirPath)
RtxRecord.SaveFile(filePath, RichTextBoxStreamType.TextTextOleObjs)
End Sub
Private Sub CboProductionLines_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CboProductionLines.SelectedIndexChanged
ProductionLineChanged()
End Sub
#Region "相机"
Private ReadOnly _imgControl(1) As PictureBox
Private ReadOnly _camera(1) As VideoCapture
Private ReadOnly _frameChanged(1) As Boolean
Private _selectFrameSizeIndex As Integer
Private ReadOnly _cameraFrame() As Size = {New Size(640, 480), New Size(1280, 960), New Size(2048, 1536), New Size(2560, 1920), New Size(3200, 2400), New Size(3840, 2880)}
Private Sub UpdateText(w As Integer, h As Integer, fps As Double)
If InvokeRequired Then
Invoke(New Action(Sub()
Text = $"{Application.ProductName} {Application.ProductVersion} Camera : {w} * {h} : {CInt(fps)} Fps"
End Sub))
Else
Text = $"{Application.ProductName} {Application.ProductVersion} Camera : {w} * {h} : {CInt(fps)} Fps"
End If
End Sub
''' <summary>
''' 打开摄像头显示图像
''' </summary>
Private Sub OpenVideoThread(state As Object)
Dim index As Integer = CInt(state)
While _useCamera
Thread.Sleep(10)
If _doubleCarera = False AndAlso index = 1 Then
If _camera(index) IsNot Nothing Then
_camera(index).Release()
_camera(index).Dispose()
_camera(index) = Nothing
_imgControl(index).Image = Nothing
End If
Continue While
End If
If _camera(index) Is Nothing Then
_camera(index) = New VideoCapture(index) '打开默认的相机使用默认为0
'摄像头为4:3
If _selectFrameSizeIndex <> -1 Then
_camera(index).FrameWidth = _cameraFrame(_selectFrameSizeIndex).Width
_camera(index).FrameHeight = _cameraFrame(_selectFrameSizeIndex).Height
Else
_camera(index).FrameWidth = 2560
_camera(index).FrameHeight = 1920
End If
_camera(index).Fps = 30 '采集率FTP
_camera(index).Saturation = 60 '图像饱和度
_camera(index).Gain = 0 '图像增益
_camera(index).Contrast = 0 '对比度
_camera(index).Hue = 20 '色调
_camera(index).Brightness = 0
_camera(index).Exposure = 0 '曝光度
If _camera(index).IsOpened() = False Then
Thread.Sleep(1000)
Continue While
End If
UpdateText(_camera(index).FrameWidth, _camera(index).FrameHeight, _camera(index).Fps)
End If
If _frameChanged(index) Then
Console.WriteLine($"分辨率切换!")
_camera(index).Release()
_camera(index).Dispose()
_camera(index) = Nothing
_frameChanged(index) = False
Continue While
End If
Using src As New Mat
If _camera(index).Read(src) = False Then
Console.WriteLine($"图像为空!")
_camera(index).Release()
_camera(index).Dispose()
_camera(index) = Nothing
Continue While
End If
Cv2.Flip(src, src, FlipMode.XY) '反转图像
_imgControl(index).Image = src.ToBitmap
End Using
GC.Collect()
End While
End Sub
Private Sub FrmMain_Shown(sender As Object, e As EventArgs) Handles Me.Shown
_useCamera = True
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf OpenVideoThread), 0)
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf OpenVideoThread), 1)
End Sub
Private Sub TsCboCameraFrame_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TsCboCameraFrame.SelectedIndexChanged
_frameChanged(0) = True
_frameChanged(1) = True
_selectFrameSizeIndex = TsCboCameraFrame.SelectedIndex
End Sub
Private Sub RdBtnDouble_CheckedChanged(sender As Object, e As EventArgs) Handles RdBtnDouble.CheckedChanged
_doubleCarera = RdBtnDouble.Checked
End Sub
Private Sub RtxRecord_TextChanged(sender As Object, e As EventArgs) Handles RtxRecord.TextChanged
End Sub
#End Region
End Class

51
AUTS_AOI/FtpService.vb Normal file
View File

@@ -0,0 +1,51 @@
Imports FluentFTP
Public Class FtpService
Private _ftpUser As String
Private _ftpPwd As String
Private _ftpPort As Integer
Private _ftpHost As String
Sub New(host As String, port As Integer, user As String, pwd As String)
_ftpHost = host
_ftpPort = port
_ftpUser = user
_ftpPwd = pwd
End Sub
Private Sub OnValidateCertificate(control As FtpClient, e As FtpSslValidationEventArgs)
e.Accept = True
End Sub
''' <summary>
''' 文件上传,覆盖式上传,文件夹不存在则回创建文件夹
''' </summary>
Public Sub UploadFile(remotePath As String, loadPath As String)
Using ftpClient As New FtpClient(_ftpHost, _ftpPort, _ftpUser, _ftpPwd)
AddHandler ftpClient.ValidateCertificate, AddressOf OnValidateCertificate
ftpClient.EncryptionMode = FtpEncryptionMode.Auto
ftpClient.Connect()
ftpClient.UploadFile(loadPath, remotePath, FtpRemoteExists.Overwrite, True)
ftpClient.Disconnect()
End Using
End Sub
''' <summary>
''' 文件下载
''' 从FTP下载压缩包到本地指定路径
''' </summary>
Public Sub DownloadFile(remotePath As String, loadPath As String)
Using ftpClient As New FtpClient(_ftpHost, _ftpPort, _ftpUser, _ftpPwd)
AddHandler ftpClient.ValidateCertificate, AddressOf OnValidateCertificate
ftpClient.EncryptionMode = FtpEncryptionMode.Auto
ftpClient.Connect()
ftpClient.DownloadFile(loadPath, remotePath)
ftpClient.Disconnect()
End Using
End Sub
End Class

3
AUTS_AOI/IFailTip.vb Normal file
View File

@@ -0,0 +1,3 @@
Public Interface IFailTip
Sub UpdateFailTips(failTips() As String)
End Interface

View File

@@ -0,0 +1,15 @@
Public Interface IStatisticsObserver
Sub UpdateFailCount(failCount As Integer)
Sub UpdatePassCount(passCount As Integer)
Sub UpdateValidCount(validCount As Integer)
Sub UpdateInvalidCount(invalidCount As Integer)
Sub UpdateSumCount(sumCount As Integer)
Sub UpdateYield(yield As Double)
End Interface

View File

@@ -0,0 +1,38 @@
'------------------------------------------------------------------------------
' <auto-generated>
' 此代码由工具生成。
' 运行时版本:4.0.30319.42000
'
' 对此文件的更改可能会导致不正确的行为,并且如果
' 重新生成代码,这些更改将会丢失。
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
'注意:此文件是自动生成的;请勿直接进行修改。若要更改,
' 或者如果您在此文件中遇到生成错误,请转至项目设计器
' (转至“项目属性”或在解决方案资源管理器中双击“我的项目”节点)
' 然后在“应用程序”选项卡中进行更改。
'
Partial Friend Class MyApplication
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = false
Me.EnableVisualStyles = true
Me.SaveMySettingsOnExit = true
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
End Sub
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.AUTS_AOI.FrmMain
End Sub
End Class
End Namespace

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>true</MySubMain>
<MainForm>FrmMain</MainForm>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>

View File

@@ -0,0 +1,35 @@
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' 有关程序集的一般信息由以下
' 控制。更改这些特性值可修改
' 与程序集关联的信息。
'查看程序集特性的值
<Assembly: AssemblyTitle("AUTS_AOI")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("AUTS_AOI")>
<Assembly: AssemblyCopyright("Copyright © 2021")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
'如果此项目向 COM 公开,则下列 GUID 用于 typelib 的 ID
<Assembly: Guid("17469f21-f87e-49db-a07a-eab96b4e1476")>
' 程序集的版本信息由下列四个值组成:
'
' 主版本
' 次版本
' 生成号
' 修订号
'
'可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
'通过使用 "*",如下所示:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.3.1.0")>

View File

@@ -0,0 +1,63 @@
'------------------------------------------------------------------------------
' <auto-generated>
' 此代码由工具生成。
' 运行时版本:4.0.30319.42000
'
' 对此文件的更改可能会导致不正确的行为,并且如果
' 重新生成代码,这些更改将会丢失。
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Imports System
Namespace My.Resources
'此类是由 StronglyTypedResourceBuilder
'类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
'若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
'(以 /str 作为命令选项),或重新生成 VS 项目。
'''<summary>
''' 一个强类型的资源类,用于查找本地化的字符串等。
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' 返回此类使用的缓存的 ResourceManager 实例。
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("AUTS_AOI.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' 重写当前线程的 CurrentUICulture 属性,对
''' 使用此强类型资源类的所有资源查找执行重写。
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set
resourceCulture = value
End Set
End Property
End Module
End Namespace

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

145
AUTS_AOI/My Project/Settings.Designer.vb generated Normal file
View File

@@ -0,0 +1,145 @@
'------------------------------------------------------------------------------
' <auto-generated>
' 此代码由工具生成。
' 运行时版本:4.0.30319.42000
'
' 对此文件的更改可能会导致不正确的行为,并且如果
' 重新生成代码,这些更改将会丢失。
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
#Region "My.Settings 自动保存功能"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public Property Project() As String
Get
Return CType(Me("Project"),String)
End Get
Set
Me("Project") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public Property ProcessStation() As String
Get
Return CType(Me("ProcessStation"),String)
End Get
Set
Me("ProcessStation") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public Property ProductionLine() As String
Get
Return CType(Me("ProductionLine"),String)
End Get
Set
Me("ProductionLine") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("True")> _
Public Property UseCamera() As Boolean
Get
Return CType(Me("UseCamera"),Boolean)
End Get
Set
Me("UseCamera") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("4")> _
Public Property CameraFrameIndex() As Integer
Get
Return CType(Me("CameraFrameIndex"),Integer)
End Get
Set
Me("CameraFrameIndex") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("True")> _
Public Property DoubleCamera() As Boolean
Get
Return CType(Me("DoubleCamera"),Boolean)
End Get
Set
Me("DoubleCamera") = value
End Set
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.AUTS_AOI.My.MySettings
Get
Return Global.AUTS_AOI.My.MySettings.Default
End Get
End Property
End Module
End Namespace

View File

@@ -0,0 +1,24 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="My" GeneratedClassName="MySettings" UseMySettingsClassName="true">
<Profiles />
<Settings>
<Setting Name="Project" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ProcessStation" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ProductionLine" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="UseCamera" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="CameraFrameIndex" Type="System.Int32" Scope="User">
<Value Profile="(Default)">4</Value>
</Setting>
<Setting Name="DoubleCamera" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>

161
AUTS_AOI/Statistics.vb Normal file
View File

@@ -0,0 +1,161 @@
''' <summary>
''' 生产统计类(当前类线程仅限同步中使用)
''' </summary>
Public Class Statistics
''' <summary>
''' 校验总数,包含有效校验与无效检验
''' </summary>
Private _checkCount As Integer
''' <summary>
''' 检验有效总数中无效总数
''' </summary>
Private _invalidCount As Integer
''' <summary>
''' 检验总数中有效总数
''' </summary>
Private _validCount As Integer
''' <summary>
''' 检验有效总数中失败总数
''' </summary>
Private _failCount As Integer
''' <summary>
''' 检验有效总数中通过总数
''' </summary>
Private _passCount As Integer
''' <summary>
''' 产品运行时良品率,通过总数除以有效总数
''' </summary>
Private _yield As Double
Private ReadOnly _observerList As List(Of IStatisticsObserver)
Sub New()
_checkCount = 0
_failCount = 0
_passCount = 0
_observerList = New List(Of IStatisticsObserver)()
End Sub
Public ReadOnly Property CheckCount() As Integer
Get
Return _checkCount
End Get
End Property
Public ReadOnly Property InvalidCount() As Integer
Get
Return _invalidCount
End Get
End Property
Public ReadOnly Property FailCount() As Integer
Get
Return _failCount
End Get
End Property
Public ReadOnly Property PassCount() As Integer
Get
Return _passCount
End Get
End Property
Public Sub AddFailCount()
_failCount += 1
UpdateFailCount(_failCount)
_validCount +=1
UpdateValidCount(_validCount)
_checkCount += 1
UpdateSumCount(_checkCount)
_yield = (_passCount / _validCount) * 100
UpdateYield(_yield)
End Sub
Public Sub AddPassCount()
_passCount += 1
UpdatePassCount(_passCount)
_validCount +=1
UpdateValidCount(_validCount)
_checkCount += 1
UpdateSumCount(_checkCount)
_yield = (_passCount / _validCount) * 100
UpdateYield(_yield)
End Sub
Public Sub AddInvalidCount()
_invalidCount += 1
UpdateInvalidCount(_invalidCount)
_checkCount += 1
UpdateSumCount(_checkCount)
End Sub
Public Sub AddStatisticsObserver(observer As IStatisticsObserver)
_observerList.Add(observer)
End Sub
Public Sub RemoveStatisticsObserver(observer As IStatisticsObserver)
_observerList.Remove(observer)
End Sub
Public Sub ClearStatisticsObserver()
_observerList.Clear()
End Sub
Private Sub UpdateFailCount(count As Integer)
For Each observer As IStatisticsObserver In _observerList
observer.UpdateFailCount(count)
Next
End Sub
Private Sub UpdatePassCount(count As Integer)
For Each observer As IStatisticsObserver In _observerList
observer.UpdatePassCount(count)
Next
End Sub
Private Sub UpdateValidCount(count As Integer)
For Each observer As IStatisticsObserver In _observerList
observer.UpdateValidCount(count)
Next
End Sub
Private Sub UpdateInvalidCount(count As Integer)
For Each observer As IStatisticsObserver In _observerList
observer.UpdateInvalidCount(count)
Next
End Sub
Private Sub UpdateSumCount(count As Integer)
For Each observer As IStatisticsObserver In _observerList
observer.UpdateSumCount(count)
Next
End Sub
Private Sub UpdateYield(yield As Double)
For Each observer As IStatisticsObserver In _observerList
observer.UpdateYield(yield)
Next
End Sub
End Class

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

12
AUTS_AOI/packages.config Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="OpenCvSharp4" version="4.6.0.20220608" targetFramework="net48" />
<package id="OpenCvSharp4.Extensions" version="4.6.0.20220608" targetFramework="net48" />
<package id="OpenCvSharp4.runtime.win" version="4.6.0.20220608" targetFramework="net48" />
<package id="System.Buffers" version="4.6.0" targetFramework="net48" />
<package id="System.Drawing.Common" version="6.0.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages>