添加项目文件。
This commit is contained in:
parent
fb81dcc23e
commit
4a40ba214a
38
App.config
Normal file
38
App.config
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
|
||||
</configSections>
|
||||
<startup>
|
||||
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></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.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.2" newVersion="7.0.0.2"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<entityFramework>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
|
||||
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
|
||||
</providers>
|
||||
</entityFramework>
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<remove invariant="System.Data.SQLite.EF6"/>
|
||||
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6"/>
|
||||
<remove invariant="System.Data.SQLite"/><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/></DbProviderFactories>
|
||||
</system.data>
|
||||
</configuration>
|
550
HikCamera.cs
Normal file
550
HikCamera.cs
Normal file
@ -0,0 +1,550 @@
|
||||
using Autofac.Core;
|
||||
using MvCamCtrl.NET;
|
||||
using OpenCvSharp;
|
||||
using OpenCvSharp.Dnn;
|
||||
using Sunny.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YSDetection
|
||||
{
|
||||
public class HikCamera
|
||||
{
|
||||
[DllImport("kernel32.dll", EntryPoint = "CopyMemory", SetLastError = false)]
|
||||
public static extern void CopyMemory(IntPtr dest, IntPtr src, uint count);
|
||||
|
||||
MyCamera.MV_CC_DEVICE_INFO_LIST m_stDeviceList = new MyCamera.MV_CC_DEVICE_INFO_LIST();
|
||||
int nRet = MyCamera.MV_OK;
|
||||
MyCamera.cbExceptiondelegate pCallBackFunc;
|
||||
public MyCamera device = new MyCamera();
|
||||
bool m_bGrabbing = false;
|
||||
Thread m_hReceiveThread = null;
|
||||
MyCamera.MV_FRAME_OUT_INFO_EX m_stFrameInfo = new MyCamera.MV_FRAME_OUT_INFO_EX();
|
||||
MyCamera.MV_CC_DEVICE_INFO stDevInfo = new MyCamera.MV_CC_DEVICE_INFO();
|
||||
// ch:用于从驱动获取图像的缓存 | en:Buffer for getting image from driver
|
||||
UInt32 m_nBufSizeForDriver = 0;
|
||||
IntPtr m_BufForDriver = IntPtr.Zero;
|
||||
private static Object BufForDriverLock = new Object();
|
||||
bool _snapFlag = false;
|
||||
public MyCamera.cbOutputExdelegate ImageCallback;
|
||||
MyCamera.MV_FRAME_OUT _frame = new MyCamera.MV_FRAME_OUT();
|
||||
readonly ManualResetEvent _snapHandle = new ManualResetEvent(false);
|
||||
|
||||
//ImageSet _bufferImgSet = null;
|
||||
ManualResetEvent _bufferHandle = new ManualResetEvent(false);
|
||||
public Action<DateTime, Mat, int> OnHImageOutput { get; set; }
|
||||
public Action<DateTime, Mat, int> OnHImageOutput2 { get; set; }
|
||||
/// <summary>
|
||||
/// 相机拍照计数
|
||||
/// </summary>
|
||||
public volatile int SnapshotCount = 0;
|
||||
public bool Ifsucess = false;
|
||||
public HikCamera() { }
|
||||
private void DeviceListAcq()
|
||||
{
|
||||
// ch:创建设备列表 | en:Create Device List
|
||||
System.GC.Collect();
|
||||
// cbDeviceList.Items.Clear();
|
||||
// m_stDeviceList.nDeviceNum = 0;
|
||||
int nRet = MyCamera.MV_CC_EnumDevices_NET(MyCamera.MV_GIGE_DEVICE | MyCamera.MV_USB_DEVICE, ref m_stDeviceList);
|
||||
if (0 != nRet)
|
||||
{
|
||||
// ShowErrorMsg("Enumerate devices fail!", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// ch:在窗体列表中显示设备名 | en:Display device name in the form list
|
||||
for (int i = 0; i < m_stDeviceList.nDeviceNum; i++)
|
||||
{
|
||||
MyCamera.MV_CC_DEVICE_INFO device = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_stDeviceList.pDeviceInfo[i], typeof(MyCamera.MV_CC_DEVICE_INFO));
|
||||
if (device.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||
{
|
||||
MyCamera.MV_GIGE_DEVICE_INFO gigeInfo = (MyCamera.MV_GIGE_DEVICE_INFO)MyCamera.ByteToStruct(device.SpecialInfo.stGigEInfo, typeof(MyCamera.MV_GIGE_DEVICE_INFO));
|
||||
|
||||
if (gigeInfo.chUserDefinedName != "")
|
||||
{
|
||||
//cbDeviceList.Items.Add("GEV: " + gigeInfo.chUserDefinedName + " (" + gigeInfo.chSerialNumber + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
// cbDeviceList.Items.Add("GEV: " + gigeInfo.chManufacturerName + " " + gigeInfo.chModelName + " (" + gigeInfo.chSerialNumber + ")");
|
||||
}
|
||||
}
|
||||
else if (device.nTLayerType == MyCamera.MV_USB_DEVICE)
|
||||
{
|
||||
MyCamera.MV_USB3_DEVICE_INFO usbInfo = (MyCamera.MV_USB3_DEVICE_INFO)MyCamera.ByteToStruct(device.SpecialInfo.stUsb3VInfo, typeof(MyCamera.MV_USB3_DEVICE_INFO));
|
||||
if (usbInfo.chUserDefinedName != "")
|
||||
{
|
||||
//cbDeviceList.Items.Add("U3V: " + usbInfo.chUserDefinedName + " (" + usbInfo.chSerialNumber + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
//cbDeviceList.Items.Add("U3V: " + usbInfo.chManufacturerName + " " + usbInfo.chModelName + " (" + usbInfo.chSerialNumber + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ch:选择第一项 | en:Select the first item
|
||||
if (m_stDeviceList.nDeviceNum != 0)
|
||||
{
|
||||
//cbDeviceList.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Start(string id)
|
||||
{
|
||||
#region 枚举相机后根据IP地址匹配连接相机
|
||||
//将IP地址转换为字节数组
|
||||
uint intAddress = 0;
|
||||
if (/*(IIConfig.HikCameraType == EnumHelper.HikCameraType.Gige) &&*/ (!string.IsNullOrWhiteSpace(id)))
|
||||
{
|
||||
byte[] IPArr = IPAddress.Parse(id).GetAddressBytes();
|
||||
for (int i = 0; i < IPArr.Length; i++)
|
||||
{
|
||||
intAddress += (uint)(IPArr[i] << (IPArr.Length - 1 - i) * 8);
|
||||
}
|
||||
}
|
||||
|
||||
MyCamera.MV_CC_DEVICE_INFO_LIST m_pDeviceList = new MyCamera.MV_CC_DEVICE_INFO_LIST();
|
||||
|
||||
int nRet = MyCamera.MV_CC_EnumDevices_NET(MyCamera.MV_GIGE_DEVICE | MyCamera.MV_USB_DEVICE, ref m_pDeviceList);
|
||||
if (0 != nRet)
|
||||
{
|
||||
throw new Exception($"Enumerate devices fail!");
|
||||
}
|
||||
else
|
||||
{
|
||||
//LogAsync(DateTime.Now, $"搜索获取{m_pDeviceList.nDeviceNum.ToInt()}台相机在线", "");
|
||||
}
|
||||
|
||||
bool isCameraFound = false;
|
||||
for (int i = 0; i < m_pDeviceList.nDeviceNum; i++)
|
||||
{
|
||||
MyCamera.MV_CC_DEVICE_INFO device = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_pDeviceList.pDeviceInfo[i], typeof(MyCamera.MV_CC_DEVICE_INFO));
|
||||
IntPtr buffer = IntPtr.Zero;
|
||||
|
||||
if (device.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||
{
|
||||
buffer = Marshal.UnsafeAddrOfPinnedArrayElement(device.SpecialInfo.stGigEInfo, 0);
|
||||
MyCamera.MV_GIGE_DEVICE_INFO stGigEDev = (MyCamera.MV_GIGE_DEVICE_INFO)Marshal.PtrToStructure(buffer, typeof(MyCamera.MV_GIGE_DEVICE_INFO));
|
||||
|
||||
if (stGigEDev.nCurrentIp == intAddress)
|
||||
{
|
||||
stDevInfo = device;
|
||||
isCameraFound = true;
|
||||
}
|
||||
}
|
||||
else if (device.nTLayerType == MyCamera.MV_USB_DEVICE)
|
||||
{
|
||||
//buffer = Marshal.UnsafeAddrOfPinnedArrayElement(device.SpecialInfo.stUsb3VInfo, 0);
|
||||
//MyCamera.MV_USB3_DEVICE_INFO usbInfo = (MyCamera.MV_USB3_DEVICE_INFO)Marshal.PtrToStructure(buffer, typeof(MyCamera.MV_USB3_DEVICE_INFO));
|
||||
//if (usbInfo.chSerialNumber == IConfig.SerialNum)
|
||||
//{
|
||||
// stDevInfo = device;
|
||||
// isCameraFound = true;
|
||||
//}
|
||||
}
|
||||
|
||||
//释放内存空间
|
||||
//Marshal.FreeHGlobal(buffer);
|
||||
|
||||
if (isCameraFound)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isCameraFound)
|
||||
{
|
||||
throw new Exception($"相机未能找到");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// ch:创建设备 | en: Create device
|
||||
nRet = device.MV_CC_CreateDevice_NET(ref stDevInfo);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Create device failed:{nRet:x8}");
|
||||
}
|
||||
|
||||
// ch:打开设备 | en:Open device
|
||||
nRet = device.MV_CC_OpenDevice_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Open device failed:{nRet:x8}");
|
||||
}
|
||||
|
||||
|
||||
// ch:探测网络最佳包大小(只对GigE相机有效) | en:Detection network optimal package size(It only works for the GigE camera)
|
||||
if (stDevInfo.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||
{
|
||||
int nPacketSize = device.MV_CC_GetOptimalPacketSize_NET();
|
||||
if (nPacketSize > 0)
|
||||
{
|
||||
nRet = device.MV_CC_SetIntValue_NET("GevSCPSPacketSize", (uint)nPacketSize);
|
||||
if (nRet != MyCamera.MV_OK)
|
||||
{
|
||||
Console.WriteLine("Warning: Set Packet Size failed {0:x8}", nRet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Warning: Get Packet Size failed {0:x8}", nPacketSize);
|
||||
}
|
||||
}
|
||||
|
||||
// ch:注册异常回调函数 | en:Register Exception Callback
|
||||
nRet = device.MV_CC_RegisterExceptionCallBack_NET(pCallBackFunc, IntPtr.Zero);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Register expection callback failed:{nRet}");
|
||||
}
|
||||
GC.KeepAlive(pCallBackFunc);
|
||||
|
||||
// ch:设置采集连续模式 | en:Set Continues Aquisition Mode
|
||||
device.MV_CC_SetEnumValue_NET("AcquisitionMode", 2);// ch:工作在连续模式 | en:Acquisition On Continuous Mode
|
||||
if (false)
|
||||
{
|
||||
device.MV_CC_SetEnumValue_NET("TriggerMode", 0); // ch:连续模式 | en:Continuous
|
||||
|
||||
// ch:注册回调函数 | en:Register image callback
|
||||
ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||
nRet = device.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Register image callback failed!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// ch:设置触发模式为off || en:set trigger mode as off
|
||||
nRet = device.MV_CC_SetEnumValue_NET("TriggerMode", 1);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Set TriggerMode failed!");
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
// ch:触发源选择:0 - Line0; | en:Trigger source select:0 - Line0;
|
||||
// 1 - Line1;
|
||||
// 2 - Line2;
|
||||
// 3 - Line3;
|
||||
// 4 - Counter;
|
||||
// 7 - Software;
|
||||
nRet = device.MV_CC_SetEnumValue_NET("TriggerSource", 0);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Set Line0 Trigger failed!");
|
||||
}
|
||||
|
||||
// ch:注册回调函数 | en:Register image callback
|
||||
ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||
nRet = device.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Register image callback failed!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nRet = device.MV_CC_SetEnumValue_NET("TriggerSource", 7);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Set Software Trigger failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
// ch:开启抓图 || en: start grab image
|
||||
nRet = device.MV_CC_StartGrabbing_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Start grabbing failed:{nRet:x8}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Ifsucess = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void Stop(MyCamera hik)
|
||||
{
|
||||
if(Ifsucess)
|
||||
{
|
||||
// IIConfig.PropertyChanged -= IIConfig_PropertyChanged;
|
||||
|
||||
|
||||
// ch:停止抓图 | en:Stop grab image
|
||||
nRet = hik.MV_CC_StopGrabbing_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Stop grabbing failed{nRet:x8}");
|
||||
}
|
||||
|
||||
// ch:关闭设备 | en:Close device
|
||||
nRet = hik.MV_CC_CloseDevice_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Close device failed{nRet:x8}");
|
||||
}
|
||||
|
||||
// ch:销毁设备 | en:Destroy device
|
||||
nRet = hik.MV_CC_DestroyDevice_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Destroy device failed:{nRet:x8}");
|
||||
}
|
||||
}
|
||||
Ifsucess = false;
|
||||
|
||||
|
||||
}
|
||||
void ImageCallbackFunc(IntPtr pData, ref MyCamera.MV_FRAME_OUT_INFO_EX pFrameInfo, IntPtr pUser)
|
||||
{
|
||||
try
|
||||
{
|
||||
// if (false)
|
||||
// {
|
||||
// // SnapshotCount++;
|
||||
// Interlocked.Increment(ref SnapshotCount);
|
||||
|
||||
|
||||
// // Console.WriteLine($">>>> {IIConfig.Name} 相机硬触发...");
|
||||
|
||||
// //LogAsync(DateTime.Now, LogLevel.Information, $"{Name}相机硬触发");
|
||||
// //Stopwatch sw = new Stopwatch();
|
||||
// //sw.Start();
|
||||
|
||||
// int nWidth = pFrameInfo.nWidth;
|
||||
// int nHeight = pFrameInfo.nHeight;
|
||||
|
||||
// //HImage hImage = new HImage();
|
||||
// //HObject Hobj = new HObject();
|
||||
// //IntPtr pTemp = IntPtr.Zero;
|
||||
// //hImage.GenImage1((HTuple)"byte", nWidth, nHeight, pData);
|
||||
|
||||
// //var imgSet = new ImageSet
|
||||
// //{
|
||||
// // HImage = hImage,
|
||||
// // ImageSaveOption = IConfig.ImageSaveOption.Copy()
|
||||
// //};
|
||||
|
||||
|
||||
// //测试图片颜色
|
||||
|
||||
// //if (IsColor(pFrameInfo.enPixelType))
|
||||
// //{
|
||||
// // //pFrameInfo.enPixelType = MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed;
|
||||
|
||||
// // // 彩色图
|
||||
// // switch (pFrameInfo.enPixelType)
|
||||
// // {
|
||||
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerGR8:
|
||||
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_gr", "bilinear");
|
||||
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||
// // break;
|
||||
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerRG8:
|
||||
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_rg", "bilinear");
|
||||
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||
// // break;
|
||||
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerGB8:
|
||||
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_gb", "bilinear");
|
||||
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||
// // break;
|
||||
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerBG8:
|
||||
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_bg", "bilinear");
|
||||
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||
// // break;
|
||||
// // }
|
||||
|
||||
// //}
|
||||
|
||||
|
||||
// if (pFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed)
|
||||
// {
|
||||
// // Console.WriteLine("image pixel format is rgb8...");
|
||||
// //pTemp = pData;
|
||||
// //HOperatorSet.GenImageInterleaved(out Hobj, (HTuple)pTemp, (HTuple)"rgb", (HTuple)pFrameInfo.nWidth, (HTuple)pFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||
// //HobjectToRGBHimage(Hobj, ref hImage);
|
||||
// }
|
||||
|
||||
// // Console.WriteLine($">>>> {IIConfig.Name} 相机数据转换完成 ...");
|
||||
|
||||
// //if (!IsMonoData(pFrameInfo.enPixelType))
|
||||
// //{
|
||||
// // pImageBuf = Marshal.AllocHGlobal((int)stFrameInfo.nWidth * stFrameInfo.nHeight * 3);
|
||||
// // HOperatorSet.GenImageInterleaved(out Hobj, (HTuple)pTemp, (HTuple)"rgb", (HTuple)pFrameInfo.nWidth, (HTuple)pFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||
// //}
|
||||
|
||||
|
||||
//#if false
|
||||
// if (pFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono8)
|
||||
// {
|
||||
// //加入内部队列
|
||||
// InitialImageSet(imgSet);
|
||||
|
||||
// //业务图片处理加入外部队列
|
||||
// var outImgSet = CopyImageSet(imgSet);
|
||||
|
||||
// if (IIConfig.IsDirectHardwareTrigger)
|
||||
// {
|
||||
// //传感器直接触发 收到图片后 传出
|
||||
// OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _bufferImgSet = outImgSet;
|
||||
// //_bufferImgSetQueue.Enqueue(outImgSet);
|
||||
// _bufferHandle.Set();
|
||||
// }
|
||||
// ClearImageSet(imgSet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine($">>>> 像素类型:{pFrameInfo.enPixelType}");
|
||||
// }
|
||||
|
||||
//#else
|
||||
// //加入内部队列
|
||||
// InitialImageSet(imgSet);
|
||||
|
||||
// //业务图片处理加入外部队列
|
||||
// var outImgSet = CopyImageSet(imgSet);
|
||||
|
||||
|
||||
// // LogAsync(DateTime.Now, LogLevel.Information, $"{Name}相机取像, 次数:{SnapshotCount}");
|
||||
|
||||
// // Console.WriteLine($">>>> {IIConfig.Name} 相机回调 OnHImageOutput ...");
|
||||
// if (IIConfig.IsDirectHardwareTrigger)
|
||||
// {
|
||||
// // 传感器直接触发 收到图片后 传出
|
||||
// OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _bufferImgSet = outImgSet;
|
||||
// // _bufferImgSetQueue.Enqueue(outImgSet);
|
||||
// _bufferHandle.Set();
|
||||
// }
|
||||
// //处理完图片 会清理内部队列的图像
|
||||
// DisplayAndSaveOriginImage(imgSet.Id);
|
||||
// //ClearImageSet(imgSet);
|
||||
//#endif
|
||||
// }
|
||||
//else
|
||||
//{
|
||||
if (_snapFlag)
|
||||
{
|
||||
_snapFlag = false;
|
||||
_frame = new MyCamera.MV_FRAME_OUT
|
||||
{
|
||||
stFrameInfo = pFrameInfo,
|
||||
pBufAddr = pData
|
||||
};
|
||||
_snapHandle.Set();
|
||||
}
|
||||
// }
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}相机取像异常,{ex.GetExceptionMessage()}");
|
||||
}
|
||||
}
|
||||
public void Snapshot()
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
// ImageSet set = new ImageSet();
|
||||
// set.SnapshotCount = SnapshotCount;
|
||||
// set.SnapshotFileName = SnapshotFileNames;
|
||||
|
||||
//InitialImageSet(set);
|
||||
MyCamera.MV_FRAME_OUT frameInfo = new MyCamera.MV_FRAME_OUT();
|
||||
nRet = MyCamera.MV_OK;
|
||||
if (true)
|
||||
{
|
||||
// ch: 触发命令 || en: Trigger command
|
||||
nRet = device.MV_CC_SetCommandValue_NET("TriggerSoftware");
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"相机拍照触发失败:{nRet}");
|
||||
}
|
||||
|
||||
nRet = device.MV_CC_GetImageBuffer_NET(ref frameInfo, 1000);
|
||||
nRet = device.MV_CC_FreeImageBuffer_NET(ref frameInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
_snapHandle.Reset();
|
||||
_snapFlag = true;
|
||||
_snapHandle.WaitOne();
|
||||
//lock (_imgCallBackLock)
|
||||
{
|
||||
frameInfo.stFrameInfo = _frame.stFrameInfo;
|
||||
frameInfo.pBufAddr = _frame.pBufAddr;
|
||||
}
|
||||
}
|
||||
|
||||
// ch:获取一帧图像 | en:Get one image
|
||||
if (MyCamera.MV_OK == nRet)
|
||||
{
|
||||
if (frameInfo.pBufAddr != IntPtr.Zero)
|
||||
{
|
||||
if (nRet == MyCamera.MV_OK)
|
||||
{
|
||||
var pFrameInfo = frameInfo.stFrameInfo;
|
||||
//图像格式存储格式
|
||||
Mat mat=new Mat(pFrameInfo.nHeight, pFrameInfo.nWidth, MatType.CV_8UC1, frameInfo.pBufAddr);
|
||||
OnHImageOutput?.Invoke(DateTime.Now, mat, SnapshotCount);
|
||||
mat.ImWrite("D://123.jpg");
|
||||
//OnHImageOutput2?.Invoke(DateTime.Now, mat2, SnapshotCount);
|
||||
//mat2.ImWrite("D://456.jpg");
|
||||
//HImage hImage = new HImage();
|
||||
//HObject Hobj = new HObject();
|
||||
//IntPtr pTemp = IntPtr.Zero;
|
||||
//hImage.GenImage1("byte", pFrameInfo.nWidth, pFrameInfo.nHeight, frameInfo.pBufAddr);
|
||||
|
||||
////hImage.ConvertHImageTo16GrayBitmap();
|
||||
//var imgSet = new ImageSet
|
||||
//{
|
||||
// HImage = hImage,
|
||||
// ImageSaveOption = IConfig.ImageSaveOption.Copy()
|
||||
//};
|
||||
//if (pFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed)
|
||||
//{
|
||||
// // Console.WriteLine("image pixel format is rgb8...");
|
||||
// pTemp = frameInfo.pBufAddr;
|
||||
// HOperatorSet.GenImageInterleaved(out Hobj, (HTuple)pTemp, (HTuple)"rgb", (HTuple)pFrameInfo.nWidth, (HTuple)pFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||
// HobjectToRGBHimage(Hobj, ref hImage);
|
||||
//}
|
||||
|
||||
|
||||
//加入内部队列
|
||||
//InitialImageSet(imgSet);
|
||||
|
||||
////业务图片处理加入外部队列
|
||||
//var outImgSet = CopyImageSet(imgSet);
|
||||
//OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"{Name}相机取像, 次数:{SnapshotCount}");
|
||||
//DisplayAndSaveOriginImage(imgSet.Id);
|
||||
//HikToBitmap(pFrameInfo, frameInfo.pBufAddr);
|
||||
//Generate8GrayImageByPointer((int)nWidth, (int)nHeight, frameInfo.pBufAddr, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Grap Image Failed:{nRet:x8}");
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"取像耗时:{sw.ElapsedMilliseconds} ms");
|
||||
}
|
||||
}
|
||||
}
|
835
HikCameraDriver.cs
Normal file
835
HikCameraDriver.cs
Normal file
@ -0,0 +1,835 @@
|
||||
|
||||
using MvCamCtrl.NET;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
|
||||
|
||||
|
||||
|
||||
//[Device("HikCamera", "海康相机", EnumHelper.DeviceAttributeType.Device)]
|
||||
public class HikCameraDriver
|
||||
{
|
||||
|
||||
#region CameraBase
|
||||
//public IOperationConfig GetOperationConfigFromDevice()
|
||||
// {
|
||||
// HikCameraOperationConfig opConfig = new HikCameraOperationConfig();
|
||||
|
||||
// MyCamera.MVCC_FLOATVALUE stParam = new MyCamera.MVCC_FLOATVALUE();
|
||||
// int nRet = device.MV_CC_GetFloatValue_NET("ExposureTime", ref stParam);
|
||||
// if (MyCamera.MV_OK == nRet)
|
||||
// {
|
||||
// opConfig.Exposure = stParam.fCurValue;
|
||||
// }
|
||||
|
||||
// nRet = device.MV_CC_GetFloatValue_NET("Gain", ref stParam);
|
||||
// if (MyCamera.MV_OK == nRet)
|
||||
// {
|
||||
// opConfig.Gain = stParam.fCurValue;
|
||||
// }
|
||||
|
||||
// return opConfig;
|
||||
// }
|
||||
|
||||
float _lastExposure = 0;
|
||||
float _lastGain = 0;
|
||||
|
||||
//public void UploadOperationConfig(IOperationConfig config)
|
||||
//{
|
||||
// if (CurrentState != EnumHelper.DeviceState.DSOpen)
|
||||
// return;
|
||||
|
||||
// CameraOprerationConfigBase opConfig = config as CameraOprerationConfigBase;
|
||||
|
||||
// int nRet;
|
||||
|
||||
// if (opConfig.Exposure != 0 && opConfig.Exposure != _lastExposure)
|
||||
// {
|
||||
// device.MV_CC_SetEnumValue_NET("ExposureAuto", 0);
|
||||
// nRet = device.MV_CC_SetFloatValue_NET("ExposureTime", opConfig.Exposure);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"Exposure set failed:{nRet}");
|
||||
// }
|
||||
|
||||
// _lastExposure = opConfig.Exposure;
|
||||
// }
|
||||
|
||||
// if (opConfig.Gain != 0 && opConfig.Gain != _lastGain)
|
||||
// {
|
||||
// device.MV_CC_SetEnumValue_NET("GainAuto", 0);
|
||||
// nRet = device.MV_CC_SetFloatValue_NET("Gain", opConfig.Gain);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"Gain set failed:{nRet}");
|
||||
// }
|
||||
|
||||
// _lastGain = opConfig.Gain;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
public void Init(string id)
|
||||
{
|
||||
|
||||
//_bufferImgSetQueue = new ConcurrentQueue<ImageSet>();
|
||||
//_bufferImgSet = new ImageSet();
|
||||
//pCallBackFunc = new MyCamera.cbExceptiondelegate(cbExceptiondelegate);
|
||||
#if false
|
||||
#region 根据IP连接相机
|
||||
|
||||
stDevInfo.nTLayerType = MyCamera.MV_GIGE_DEVICE;
|
||||
MyCamera.MV_GIGE_DEVICE_INFO stGigEDev = new MyCamera.MV_GIGE_DEVICE_INFO();
|
||||
//string strCurrentIp = IIConfig.CameraIP;// ch:需要连接的相机ip(根据实际填充)
|
||||
|
||||
//string strNetExport = IIConfig.ComputerIP; // ch:相机对应的网卡ip(根据实际填充)
|
||||
|
||||
string strCurrentIp = "192.168.1.21";// ch:需要连接的相机ip(根据实际填充)
|
||||
|
||||
string strNetExport = "192.168.1.20"; // ch:相机对应的网卡ip(根据实际填充)
|
||||
|
||||
var parts = strCurrentIp.Split('.');
|
||||
int nIp1 = Convert.ToInt32(parts[0]);
|
||||
int nIp2 = Convert.ToInt32(parts[1]);
|
||||
int nIp3 = Convert.ToInt32(parts[2]);
|
||||
int nIp4 = Convert.ToInt32(parts[3]);
|
||||
stGigEDev.nCurrentIp = (uint)((nIp1 << 24) | (nIp2 << 16) | (nIp3 << 8) | nIp4);
|
||||
|
||||
parts = strNetExport.Split('.');
|
||||
nIp1 = Convert.ToInt32(parts[0]);
|
||||
nIp2 = Convert.ToInt32(parts[1]);
|
||||
nIp3 = Convert.ToInt32(parts[2]);
|
||||
nIp4 = Convert.ToInt32(parts[3]);
|
||||
stGigEDev.nNetExport = (uint)((nIp1 << 24) | (nIp2 << 16) | (nIp3 << 8) | nIp4);
|
||||
|
||||
IntPtr stGigeInfoPtr = Marshal.AllocHGlobal(216);
|
||||
Marshal.StructureToPtr(stGigEDev, stGigeInfoPtr, false);
|
||||
stDevInfo.SpecialInfo.stGigEInfo = new Byte[540];
|
||||
Marshal.Copy(stGigeInfoPtr, stDevInfo.SpecialInfo.stGigEInfo, 0, 540);
|
||||
//释放内存空间
|
||||
Marshal.FreeHGlobal(stGigeInfoPtr);
|
||||
|
||||
#endregion
|
||||
#endif
|
||||
#region 枚举相机后根据IP地址匹配连接相机
|
||||
//将IP地址转换为字节数组
|
||||
uint intAddress = 0;
|
||||
if (/*(IIConfig.HikCameraType == EnumHelper.HikCameraType.Gige) &&*/ (!string.IsNullOrWhiteSpace(id)))
|
||||
{
|
||||
byte[] IPArr = IPAddress.Parse(id).GetAddressBytes();
|
||||
for (int i = 0; i < IPArr.Length; i++)
|
||||
{
|
||||
intAddress += (uint)(IPArr[i] << (IPArr.Length - 1 - i) * 8);
|
||||
}
|
||||
}
|
||||
|
||||
MyCamera.MV_CC_DEVICE_INFO_LIST m_pDeviceList = new MyCamera.MV_CC_DEVICE_INFO_LIST();
|
||||
|
||||
int nRet = MyCamera.MV_CC_EnumDevices_NET(MyCamera.MV_GIGE_DEVICE | MyCamera.MV_USB_DEVICE, ref m_pDeviceList);
|
||||
if (0 != nRet)
|
||||
{
|
||||
throw new Exception($"Enumerate devices fail!");
|
||||
}
|
||||
else
|
||||
{
|
||||
//LogAsync(DateTime.Now, $"搜索获取{m_pDeviceList.nDeviceNum.ToInt()}台相机在线", "");
|
||||
}
|
||||
|
||||
bool isCameraFound = false;
|
||||
for (int i = 0; i < m_pDeviceList.nDeviceNum; i++)
|
||||
{
|
||||
MyCamera.MV_CC_DEVICE_INFO device = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_pDeviceList.pDeviceInfo[i], typeof(MyCamera.MV_CC_DEVICE_INFO));
|
||||
IntPtr buffer = IntPtr.Zero;
|
||||
|
||||
if (device.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||
{
|
||||
buffer = Marshal.UnsafeAddrOfPinnedArrayElement(device.SpecialInfo.stGigEInfo, 0);
|
||||
MyCamera.MV_GIGE_DEVICE_INFO stGigEDev = (MyCamera.MV_GIGE_DEVICE_INFO)Marshal.PtrToStructure(buffer, typeof(MyCamera.MV_GIGE_DEVICE_INFO));
|
||||
|
||||
if (stGigEDev.nCurrentIp == intAddress)
|
||||
{
|
||||
stDevInfo = device;
|
||||
isCameraFound = true;
|
||||
}
|
||||
}
|
||||
else if (device.nTLayerType == MyCamera.MV_USB_DEVICE)
|
||||
{
|
||||
//buffer = Marshal.UnsafeAddrOfPinnedArrayElement(device.SpecialInfo.stUsb3VInfo, 0);
|
||||
//MyCamera.MV_USB3_DEVICE_INFO usbInfo = (MyCamera.MV_USB3_DEVICE_INFO)Marshal.PtrToStructure(buffer, typeof(MyCamera.MV_USB3_DEVICE_INFO));
|
||||
//if (usbInfo.chSerialNumber == IConfig.SerialNum)
|
||||
//{
|
||||
// stDevInfo = device;
|
||||
// isCameraFound = true;
|
||||
//}
|
||||
}
|
||||
|
||||
//释放内存空间
|
||||
//Marshal.FreeHGlobal(buffer);
|
||||
|
||||
if (isCameraFound)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isCameraFound)
|
||||
{
|
||||
throw new Exception($"相机未能找到");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
protected void Pause()
|
||||
{
|
||||
}
|
||||
|
||||
protected void Resume()
|
||||
{
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
|
||||
|
||||
// ch:创建设备 | en: Create device
|
||||
nRet = device.MV_CC_CreateDevice_NET(ref stDevInfo);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Create device failed:{nRet:x8}");
|
||||
}
|
||||
|
||||
// ch:打开设备 | en:Open device
|
||||
nRet = device.MV_CC_OpenDevice_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Open device failed:{nRet:x8}");
|
||||
}
|
||||
|
||||
|
||||
// ch:探测网络最佳包大小(只对GigE相机有效) | en:Detection network optimal package size(It only works for the GigE camera)
|
||||
if (stDevInfo.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||
{
|
||||
int nPacketSize = device.MV_CC_GetOptimalPacketSize_NET();
|
||||
if (nPacketSize > 0)
|
||||
{
|
||||
nRet = device.MV_CC_SetIntValue_NET("GevSCPSPacketSize", (uint)nPacketSize);
|
||||
if (nRet != MyCamera.MV_OK)
|
||||
{
|
||||
Console.WriteLine("Warning: Set Packet Size failed {0:x8}", nRet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Warning: Get Packet Size failed {0:x8}", nPacketSize);
|
||||
}
|
||||
}
|
||||
|
||||
// ch:注册异常回调函数 | en:Register Exception Callback
|
||||
nRet = device.MV_CC_RegisterExceptionCallBack_NET(pCallBackFunc, IntPtr.Zero);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Register expection callback failed:{nRet}");
|
||||
}
|
||||
GC.KeepAlive(pCallBackFunc);
|
||||
|
||||
// ch:设置采集连续模式 | en:Set Continues Aquisition Mode
|
||||
device.MV_CC_SetEnumValue_NET("AcquisitionMode", 2);// ch:工作在连续模式 | en:Acquisition On Continuous Mode
|
||||
if (false)
|
||||
{
|
||||
device.MV_CC_SetEnumValue_NET("TriggerMode", 0); // ch:连续模式 | en:Continuous
|
||||
|
||||
// ch:注册回调函数 | en:Register image callback
|
||||
ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||
nRet = device.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Register image callback failed!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// ch:设置触发模式为off || en:set trigger mode as off
|
||||
nRet = device.MV_CC_SetEnumValue_NET("TriggerMode", 1);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Set TriggerMode failed!");
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
// ch:触发源选择:0 - Line0; | en:Trigger source select:0 - Line0;
|
||||
// 1 - Line1;
|
||||
// 2 - Line2;
|
||||
// 3 - Line3;
|
||||
// 4 - Counter;
|
||||
// 7 - Software;
|
||||
nRet = device.MV_CC_SetEnumValue_NET("TriggerSource", 0);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Set Line0 Trigger failed!");
|
||||
}
|
||||
|
||||
// ch:注册回调函数 | en:Register image callback
|
||||
ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||
nRet = device.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Register image callback failed!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nRet = device.MV_CC_SetEnumValue_NET("TriggerSource", 7);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Set Software Trigger failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
// ch:开启抓图 || en: start grab image
|
||||
nRet = device.MV_CC_StartGrabbing_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Start grabbing failed:{nRet:x8}");
|
||||
}
|
||||
|
||||
//if (IIConfig.DefaultExposure != 0)
|
||||
//{
|
||||
// device.MV_CC_SetEnumValue_NET("ExposureAuto", 0);
|
||||
// nRet = device.MV_CC_SetFloatValue_NET("ExposureTime", IIConfig.DefaultExposure);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"Exposure set failed:{nRet}");
|
||||
// }
|
||||
//}
|
||||
//if (IIConfig.Gain >= 0)
|
||||
//{
|
||||
// nRet = device.MV_CC_SetFloatValue_NET("Gain", IIConfig.Gain);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"Gain set failed:{nRet}");
|
||||
// }
|
||||
//}
|
||||
//// 设置 触发延迟
|
||||
//if (IIConfig.TriggerDelay > 0)
|
||||
//{
|
||||
// nRet = device.MV_CC_SetFloatValue_NET("TriggerDelay", IIConfig.TriggerDelay);
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// throw new Exception("Set TriggerDelay failed!");
|
||||
// }
|
||||
//}
|
||||
//if (IIConfig.LineDebouncerTime > 0)
|
||||
//{
|
||||
// nRet = device.MV_CC_SetIntValue_NET("LineDebouncerTime", (uint)IIConfig.LineDebouncerTime);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"LineDebouncerTime set failed:{nRet}");
|
||||
// }
|
||||
//}
|
||||
//IIConfig.PropertyChanged -= IIConfig_PropertyChanged;
|
||||
//IIConfig.PropertyChanged += IIConfig_PropertyChanged;
|
||||
|
||||
}
|
||||
|
||||
private void IIConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "IsHardwareTrigger" && !false)
|
||||
{
|
||||
// ch:停止抓图 | en:Stop grab image
|
||||
nRet = device.MV_CC_StopGrabbing_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Stop grabbing failed{nRet:x8}");
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
// ch:触发源选择:0 - Line0; | en:Trigger source select:0 - Line0;
|
||||
// 1 - Line1;
|
||||
// 2 - Line2;
|
||||
// 3 - Line3;
|
||||
// 4 - Counter;
|
||||
// 7 - Software;
|
||||
nRet = device.MV_CC_SetEnumValue_NET("TriggerSource", 0);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Set Line0 Trigger failed!");
|
||||
}
|
||||
|
||||
// ch:注册回调函数 | en:Register image callback
|
||||
ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||
nRet = device.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Register image callback failed!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nRet = device.MV_CC_SetEnumValue_NET("TriggerSource", 7);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception("Set Software Trigger failed!");
|
||||
}
|
||||
}
|
||||
|
||||
// ch:开启抓图 || en: start grab image
|
||||
nRet = device.MV_CC_StartGrabbing_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Start grabbing failed:{nRet:x8}");
|
||||
}
|
||||
|
||||
//if (IIConfig.DefaultExposure != 0)
|
||||
//{
|
||||
// device.MV_CC_SetEnumValue_NET("ExposureAuto", 0);
|
||||
// nRet = device.MV_CC_SetFloatValue_NET("ExposureTime", IIConfig.DefaultExposure);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"Exposure set failed:{nRet}");
|
||||
// }
|
||||
//}
|
||||
//if (IIConfig.Gain >= 0)
|
||||
//{
|
||||
// nRet = device.MV_CC_SetFloatValue_NET("Gain", IIConfig.Gain);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"Gain set failed:{nRet}");
|
||||
// }
|
||||
//}
|
||||
|
||||
//// 设置 触发延迟
|
||||
//if (IIConfig.TriggerDelay > 0)
|
||||
//{
|
||||
// nRet = device.MV_CC_SetFloatValue_NET("TriggerDelay", IIConfig.TriggerDelay);
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// throw new Exception("Set TriggerDelay failed!");
|
||||
// }
|
||||
//}
|
||||
//if (IIConfig.LineDebouncerTime > 0)
|
||||
//{
|
||||
// nRet = device.MV_CC_SetIntValue_NET("LineDebouncerTime", (uint)IIConfig.LineDebouncerTime);
|
||||
// if (nRet != MyCamera.MV_OK)
|
||||
// {
|
||||
// throw new Exception($"LineDebouncerTime set failed:{nRet}");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
protected void Stop()
|
||||
{
|
||||
// IIConfig.PropertyChanged -= IIConfig_PropertyChanged;
|
||||
|
||||
|
||||
// ch:停止抓图 | en:Stop grab image
|
||||
nRet = device.MV_CC_StopGrabbing_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Stop grabbing failed{nRet:x8}");
|
||||
}
|
||||
|
||||
// ch:关闭设备 | en:Close device
|
||||
nRet = device.MV_CC_CloseDevice_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Close device failed{nRet:x8}");
|
||||
}
|
||||
|
||||
// ch:销毁设备 | en:Destroy device
|
||||
nRet = device.MV_CC_DestroyDevice_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"Destroy device failed:{nRet:x8}");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region HikCamera
|
||||
public MyCamera.cbOutputExdelegate ImageCallback;
|
||||
MyCamera.MV_FRAME_OUT _frame = new MyCamera.MV_FRAME_OUT();
|
||||
readonly ManualResetEvent _snapHandle = new ManualResetEvent(false);
|
||||
bool _snapFlag = false;
|
||||
|
||||
//ImageSet _bufferImgSet = null;
|
||||
ManualResetEvent _bufferHandle = new ManualResetEvent(false);
|
||||
//ConcurrentQueue<ImageSet> _bufferImgSetQueue = new ConcurrentQueue<ImageSet>();
|
||||
//volatile ImageSet _bufferImgSet = new ImageSet();
|
||||
|
||||
|
||||
void ImageCallbackFunc(IntPtr pData, ref MyCamera.MV_FRAME_OUT_INFO_EX pFrameInfo, IntPtr pUser)
|
||||
{
|
||||
try
|
||||
{
|
||||
// if (false)
|
||||
// {
|
||||
// // SnapshotCount++;
|
||||
// Interlocked.Increment(ref SnapshotCount);
|
||||
|
||||
|
||||
// // Console.WriteLine($">>>> {IIConfig.Name} 相机硬触发...");
|
||||
|
||||
// //LogAsync(DateTime.Now, LogLevel.Information, $"{Name}相机硬触发");
|
||||
// //Stopwatch sw = new Stopwatch();
|
||||
// //sw.Start();
|
||||
|
||||
// int nWidth = pFrameInfo.nWidth;
|
||||
// int nHeight = pFrameInfo.nHeight;
|
||||
|
||||
// //HImage hImage = new HImage();
|
||||
// //HObject Hobj = new HObject();
|
||||
// //IntPtr pTemp = IntPtr.Zero;
|
||||
// //hImage.GenImage1((HTuple)"byte", nWidth, nHeight, pData);
|
||||
|
||||
// //var imgSet = new ImageSet
|
||||
// //{
|
||||
// // HImage = hImage,
|
||||
// // ImageSaveOption = IConfig.ImageSaveOption.Copy()
|
||||
// //};
|
||||
|
||||
|
||||
// //测试图片颜色
|
||||
|
||||
// //if (IsColor(pFrameInfo.enPixelType))
|
||||
// //{
|
||||
// // //pFrameInfo.enPixelType = MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed;
|
||||
|
||||
// // // 彩色图
|
||||
// // switch (pFrameInfo.enPixelType)
|
||||
// // {
|
||||
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerGR8:
|
||||
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_gr", "bilinear");
|
||||
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||
// // break;
|
||||
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerRG8:
|
||||
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_rg", "bilinear");
|
||||
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||
// // break;
|
||||
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerGB8:
|
||||
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_gb", "bilinear");
|
||||
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||
// // break;
|
||||
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerBG8:
|
||||
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_bg", "bilinear");
|
||||
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||
// // break;
|
||||
// // }
|
||||
|
||||
// //}
|
||||
|
||||
|
||||
// if (pFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed)
|
||||
// {
|
||||
// // Console.WriteLine("image pixel format is rgb8...");
|
||||
// //pTemp = pData;
|
||||
// //HOperatorSet.GenImageInterleaved(out Hobj, (HTuple)pTemp, (HTuple)"rgb", (HTuple)pFrameInfo.nWidth, (HTuple)pFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||
// //HobjectToRGBHimage(Hobj, ref hImage);
|
||||
// }
|
||||
|
||||
// // Console.WriteLine($">>>> {IIConfig.Name} 相机数据转换完成 ...");
|
||||
|
||||
// //if (!IsMonoData(pFrameInfo.enPixelType))
|
||||
// //{
|
||||
// // pImageBuf = Marshal.AllocHGlobal((int)stFrameInfo.nWidth * stFrameInfo.nHeight * 3);
|
||||
// // HOperatorSet.GenImageInterleaved(out Hobj, (HTuple)pTemp, (HTuple)"rgb", (HTuple)pFrameInfo.nWidth, (HTuple)pFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||
// //}
|
||||
|
||||
|
||||
//#if false
|
||||
// if (pFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono8)
|
||||
// {
|
||||
// //加入内部队列
|
||||
// InitialImageSet(imgSet);
|
||||
|
||||
// //业务图片处理加入外部队列
|
||||
// var outImgSet = CopyImageSet(imgSet);
|
||||
|
||||
// if (IIConfig.IsDirectHardwareTrigger)
|
||||
// {
|
||||
// //传感器直接触发 收到图片后 传出
|
||||
// OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _bufferImgSet = outImgSet;
|
||||
// //_bufferImgSetQueue.Enqueue(outImgSet);
|
||||
// _bufferHandle.Set();
|
||||
// }
|
||||
// ClearImageSet(imgSet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine($">>>> 像素类型:{pFrameInfo.enPixelType}");
|
||||
// }
|
||||
|
||||
//#else
|
||||
// //加入内部队列
|
||||
// InitialImageSet(imgSet);
|
||||
|
||||
// //业务图片处理加入外部队列
|
||||
// var outImgSet = CopyImageSet(imgSet);
|
||||
|
||||
|
||||
// // LogAsync(DateTime.Now, LogLevel.Information, $"{Name}相机取像, 次数:{SnapshotCount}");
|
||||
|
||||
// // Console.WriteLine($">>>> {IIConfig.Name} 相机回调 OnHImageOutput ...");
|
||||
// if (IIConfig.IsDirectHardwareTrigger)
|
||||
// {
|
||||
// // 传感器直接触发 收到图片后 传出
|
||||
// OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _bufferImgSet = outImgSet;
|
||||
// // _bufferImgSetQueue.Enqueue(outImgSet);
|
||||
// _bufferHandle.Set();
|
||||
// }
|
||||
// //处理完图片 会清理内部队列的图像
|
||||
// DisplayAndSaveOriginImage(imgSet.Id);
|
||||
// //ClearImageSet(imgSet);
|
||||
//#endif
|
||||
// }
|
||||
//else
|
||||
//{
|
||||
if (_snapFlag)
|
||||
{
|
||||
_snapFlag = false;
|
||||
_frame = new MyCamera.MV_FRAME_OUT
|
||||
{
|
||||
stFrameInfo = pFrameInfo,
|
||||
pBufAddr = pData
|
||||
};
|
||||
_snapHandle.Set();
|
||||
}
|
||||
// }
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}相机取像异常,{ex.GetExceptionMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//bool IsColor(MvGvspPixelType enType)
|
||||
//{
|
||||
// switch (enType)
|
||||
// {
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BGR8_Packed:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_YUV422_Packed:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_YUV422_YUYV_Packed:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerGR8:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerRG8:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerGB8:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerBG8:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerGB10:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerGB10_Packed:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerBG10:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerBG10_Packed:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerRG10:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerRG10_Packed:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerGR10:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerGR10_Packed:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerGB12:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerGB12_Packed:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerBG12:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerBG12_Packed:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerRG12:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerRG12_Packed:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerGR12:
|
||||
// case MvGvspPixelType.PixelType_Gvsp_BayerGR12_Packed:
|
||||
// return true;
|
||||
// default:
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
private bool IsMonoData(MyCamera.MvGvspPixelType enGvspPixelType)
|
||||
{
|
||||
switch (enGvspPixelType)
|
||||
{
|
||||
case MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono8:
|
||||
case MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono10:
|
||||
case MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono10_Packed:
|
||||
case MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono12:
|
||||
case MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono12_Packed:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshImageBufferHandle()
|
||||
{
|
||||
//_bufferImgSet?.Dispose();
|
||||
//_bufferImgSet = null;
|
||||
|
||||
_bufferHandle.Reset();
|
||||
}
|
||||
|
||||
object _bufferLock = new object();
|
||||
|
||||
|
||||
//public void CameraOpModeChanged(EnumHelper.CameraOpMode opMode)
|
||||
//{
|
||||
// if (opMode == EnumHelper.CameraOpMode.ContinuousMode)
|
||||
// {
|
||||
// device.MV_CC_SetEnumValue_NET("TriggerMode", 0);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// device.MV_CC_SetEnumValue_NET("TriggerMode", 1);
|
||||
// }
|
||||
//}
|
||||
public void Snapshot(int pageBum, string napshotFileName)
|
||||
{
|
||||
//SnapshotCount = pageBum;
|
||||
//SnapshotFileNames = napshotFileName;
|
||||
|
||||
Snapshot();
|
||||
}
|
||||
public void Snapshot()
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
// ImageSet set = new ImageSet();
|
||||
// set.SnapshotCount = SnapshotCount;
|
||||
// set.SnapshotFileName = SnapshotFileNames;
|
||||
|
||||
//InitialImageSet(set);
|
||||
MyCamera.MV_FRAME_OUT frameInfo = new MyCamera.MV_FRAME_OUT();
|
||||
nRet = MyCamera.MV_OK;
|
||||
if (true)
|
||||
{
|
||||
// ch: 触发命令 || en: Trigger command
|
||||
nRet = device.MV_CC_SetCommandValue_NET("TriggerSoftware");
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
throw new Exception($"相机拍照触发失败:{nRet}");
|
||||
}
|
||||
|
||||
nRet = device.MV_CC_GetImageBuffer_NET(ref frameInfo, 1000);
|
||||
nRet = device.MV_CC_FreeImageBuffer_NET(ref frameInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
_snapHandle.Reset();
|
||||
_snapFlag = true;
|
||||
_snapHandle.WaitOne();
|
||||
//lock (_imgCallBackLock)
|
||||
{
|
||||
frameInfo.stFrameInfo = _frame.stFrameInfo;
|
||||
frameInfo.pBufAddr = _frame.pBufAddr;
|
||||
}
|
||||
}
|
||||
|
||||
// ch:获取一帧图像 | en:Get one image
|
||||
if (MyCamera.MV_OK == nRet)
|
||||
{
|
||||
if (frameInfo.pBufAddr != IntPtr.Zero)
|
||||
{
|
||||
if (nRet == MyCamera.MV_OK)
|
||||
{
|
||||
var pFrameInfo = frameInfo.stFrameInfo;
|
||||
//HImage hImage = new HImage();
|
||||
//HObject Hobj = new HObject();
|
||||
//IntPtr pTemp = IntPtr.Zero;
|
||||
//hImage.GenImage1("byte", pFrameInfo.nWidth, pFrameInfo.nHeight, frameInfo.pBufAddr);
|
||||
|
||||
////hImage.ConvertHImageTo16GrayBitmap();
|
||||
//var imgSet = new ImageSet
|
||||
//{
|
||||
// HImage = hImage,
|
||||
// ImageSaveOption = IConfig.ImageSaveOption.Copy()
|
||||
//};
|
||||
//if (pFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed)
|
||||
//{
|
||||
// // Console.WriteLine("image pixel format is rgb8...");
|
||||
// pTemp = frameInfo.pBufAddr;
|
||||
// HOperatorSet.GenImageInterleaved(out Hobj, (HTuple)pTemp, (HTuple)"rgb", (HTuple)pFrameInfo.nWidth, (HTuple)pFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||
// HobjectToRGBHimage(Hobj, ref hImage);
|
||||
//}
|
||||
|
||||
|
||||
//加入内部队列
|
||||
//InitialImageSet(imgSet);
|
||||
|
||||
////业务图片处理加入外部队列
|
||||
//var outImgSet = CopyImageSet(imgSet);
|
||||
//OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"{Name}相机取像, 次数:{SnapshotCount}");
|
||||
//DisplayAndSaveOriginImage(imgSet.Id);
|
||||
//HikToBitmap(pFrameInfo, frameInfo.pBufAddr);
|
||||
//Generate8GrayImageByPointer((int)nWidth, (int)nHeight, frameInfo.pBufAddr, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Grap Image Failed:{nRet:x8}");
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"取像耗时:{sw.ElapsedMilliseconds} ms");
|
||||
}
|
||||
|
||||
|
||||
|
||||
readonly MyCamera device = new MyCamera();
|
||||
MyCamera.MV_CC_DEVICE_INFO stDevInfo = new MyCamera.MV_CC_DEVICE_INFO();
|
||||
int nRet = MyCamera.MV_OK;
|
||||
MyCamera.cbExceptiondelegate pCallBackFunc;
|
||||
|
||||
|
||||
|
||||
// ch:回调函数 | en:Callback function
|
||||
//private void cbExceptiondelegate(uint nMsgType, IntPtr pUser)
|
||||
//{
|
||||
// if (nMsgType == MyCamera.MV_EXCEPTION_DEV_DISCONNECT)
|
||||
// {
|
||||
// if (CurrentState != EnumHelper.DeviceState.DSClose)
|
||||
// {
|
||||
// int reTryTimes = 3;
|
||||
// do
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Task.Delay(1000).Wait();
|
||||
// Stop();
|
||||
|
||||
// Start();
|
||||
// reTryTimes = -1;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// reTryTimes--;
|
||||
|
||||
// if (reTryTimes > 0)
|
||||
// {
|
||||
// LogAsync(DateTime.Now, LogLevel.Information, $"{this.Name}重新连接异常,{ex.GetExceptionMessage()}");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw ex;
|
||||
// }
|
||||
// }
|
||||
// } while (reTryTimes > 0);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
}
|
||||
|
690
MainForm.Designer.cs
generated
Normal file
690
MainForm.Designer.cs
generated
Normal file
@ -0,0 +1,690 @@
|
||||
namespace YSDetection
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows 窗体设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.textBox9 = new System.Windows.Forms.TextBox();
|
||||
this.textBox7 = new System.Windows.Forms.TextBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.pictureBox3 = new System.Windows.Forms.PictureBox();
|
||||
this.textBox6 = new System.Windows.Forms.TextBox();
|
||||
this.textBox5 = new System.Windows.Forms.TextBox();
|
||||
this.textBox3 = new System.Windows.Forms.TextBox();
|
||||
this.textBox2 = new System.Windows.Forms.TextBox();
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.textBox4 = new System.Windows.Forms.TextBox();
|
||||
this.label12 = new System.Windows.Forms.Label();
|
||||
this.label11 = new System.Windows.Forms.Label();
|
||||
this.label10 = new System.Windows.Forms.Label();
|
||||
this.label9 = new System.Windows.Forms.Label();
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.detectbutton = new System.Windows.Forms.Button();
|
||||
this.opendevicebutton = new System.Windows.Forms.Button();
|
||||
this.SnaptPage = new System.Windows.Forms.TextBox();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
||||
this.groupBox4 = new System.Windows.Forms.GroupBox();
|
||||
this.pictureBox2 = new System.Windows.Forms.PictureBox();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.tabcontrol1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.textBox15 = new System.Windows.Forms.TextBox();
|
||||
this.label17 = new System.Windows.Forms.Label();
|
||||
this.textBox14 = new System.Windows.Forms.TextBox();
|
||||
this.label16 = new System.Windows.Forms.Label();
|
||||
this.textBox13 = new System.Windows.Forms.TextBox();
|
||||
this.label15 = new System.Windows.Forms.Label();
|
||||
this.textBox12 = new System.Windows.Forms.TextBox();
|
||||
this.label14 = new System.Windows.Forms.Label();
|
||||
this.button3 = new System.Windows.Forms.Button();
|
||||
this.label13 = new System.Windows.Forms.Label();
|
||||
this.textBox11 = new System.Windows.Forms.TextBox();
|
||||
this.textBox10 = new System.Windows.Forms.TextBox();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.textBox8 = new System.Windows.Forms.TextBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
|
||||
this.groupBox3.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.groupBox4.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
|
||||
this.tabcontrol1.SuspendLayout();
|
||||
this.tabPage2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.BackColor = System.Drawing.Color.LightCyan;
|
||||
this.tabPage1.Controls.Add(this.groupBox2);
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(1597, 777);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "检测";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.BackColor = System.Drawing.Color.Transparent;
|
||||
this.groupBox2.Controls.Add(this.textBox9);
|
||||
this.groupBox2.Controls.Add(this.textBox7);
|
||||
this.groupBox2.Controls.Add(this.groupBox1);
|
||||
this.groupBox2.Controls.Add(this.textBox6);
|
||||
this.groupBox2.Controls.Add(this.textBox5);
|
||||
this.groupBox2.Controls.Add(this.textBox3);
|
||||
this.groupBox2.Controls.Add(this.textBox2);
|
||||
this.groupBox2.Controls.Add(this.textBox1);
|
||||
this.groupBox2.Controls.Add(this.textBox4);
|
||||
this.groupBox2.Controls.Add(this.label12);
|
||||
this.groupBox2.Controls.Add(this.label11);
|
||||
this.groupBox2.Controls.Add(this.label10);
|
||||
this.groupBox2.Controls.Add(this.label9);
|
||||
this.groupBox2.Controls.Add(this.label8);
|
||||
this.groupBox2.Controls.Add(this.label2);
|
||||
this.groupBox2.Controls.Add(this.label1);
|
||||
this.groupBox2.Controls.Add(this.detectbutton);
|
||||
this.groupBox2.Controls.Add(this.opendevicebutton);
|
||||
this.groupBox2.Controls.Add(this.SnaptPage);
|
||||
this.groupBox2.Controls.Add(this.groupBox3);
|
||||
this.groupBox2.Controls.Add(this.label7);
|
||||
this.groupBox2.Controls.Add(this.comboBox1);
|
||||
this.groupBox2.Controls.Add(this.groupBox4);
|
||||
this.groupBox2.Controls.Add(this.label6);
|
||||
this.groupBox2.Controls.Add(this.label5);
|
||||
this.groupBox2.Controls.Add(this.label4);
|
||||
this.groupBox2.Controls.Add(this.label3);
|
||||
this.groupBox2.Font = new System.Drawing.Font("楷体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.groupBox2.Location = new System.Drawing.Point(6, 24);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(1685, 747);
|
||||
this.groupBox2.TabIndex = 1;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "结果展示";
|
||||
this.groupBox2.Enter += new System.EventHandler(this.groupBox2_Enter);
|
||||
//
|
||||
// textBox9
|
||||
//
|
||||
this.textBox9.BackColor = System.Drawing.Color.LightCyan;
|
||||
this.textBox9.Location = new System.Drawing.Point(16, 501);
|
||||
this.textBox9.MaxLength = 32767000;
|
||||
this.textBox9.Multiline = true;
|
||||
this.textBox9.Name = "textBox9";
|
||||
this.textBox9.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.textBox9.Size = new System.Drawing.Size(990, 240);
|
||||
this.textBox9.TabIndex = 33;
|
||||
this.textBox9.WordWrap = false;
|
||||
//
|
||||
// textBox7
|
||||
//
|
||||
this.textBox7.Location = new System.Drawing.Point(1521, 216);
|
||||
this.textBox7.Name = "textBox7";
|
||||
this.textBox7.Size = new System.Drawing.Size(50, 30);
|
||||
this.textBox7.TabIndex = 32;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.pictureBox3);
|
||||
this.groupBox1.Location = new System.Drawing.Point(1215, 448);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(302, 222);
|
||||
this.groupBox1.TabIndex = 25;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "pic";
|
||||
//
|
||||
// pictureBox3
|
||||
//
|
||||
this.pictureBox3.Location = new System.Drawing.Point(6, 19);
|
||||
this.pictureBox3.Name = "pictureBox3";
|
||||
this.pictureBox3.Size = new System.Drawing.Size(287, 187);
|
||||
this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pictureBox3.TabIndex = 1;
|
||||
this.pictureBox3.TabStop = false;
|
||||
//
|
||||
// textBox6
|
||||
//
|
||||
this.textBox6.Location = new System.Drawing.Point(1520, 152);
|
||||
this.textBox6.Name = "textBox6";
|
||||
this.textBox6.Size = new System.Drawing.Size(50, 30);
|
||||
this.textBox6.TabIndex = 31;
|
||||
//
|
||||
// textBox5
|
||||
//
|
||||
this.textBox5.Location = new System.Drawing.Point(1416, 216);
|
||||
this.textBox5.Name = "textBox5";
|
||||
this.textBox5.Size = new System.Drawing.Size(50, 30);
|
||||
this.textBox5.TabIndex = 30;
|
||||
//
|
||||
// textBox3
|
||||
//
|
||||
this.textBox3.Location = new System.Drawing.Point(1417, 151);
|
||||
this.textBox3.Name = "textBox3";
|
||||
this.textBox3.Size = new System.Drawing.Size(50, 30);
|
||||
this.textBox3.TabIndex = 29;
|
||||
//
|
||||
// textBox2
|
||||
//
|
||||
this.textBox2.Location = new System.Drawing.Point(1275, 217);
|
||||
this.textBox2.Name = "textBox2";
|
||||
this.textBox2.Size = new System.Drawing.Size(50, 30);
|
||||
this.textBox2.TabIndex = 28;
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.Location = new System.Drawing.Point(1275, 153);
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(50, 30);
|
||||
this.textBox1.TabIndex = 27;
|
||||
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
|
||||
//
|
||||
// textBox4
|
||||
//
|
||||
this.textBox4.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.textBox4.Location = new System.Drawing.Point(1129, 217);
|
||||
this.textBox4.Name = "textBox4";
|
||||
this.textBox4.Size = new System.Drawing.Size(50, 30);
|
||||
this.textBox4.TabIndex = 26;
|
||||
//
|
||||
// label12
|
||||
//
|
||||
this.label12.AutoSize = true;
|
||||
this.label12.Font = new System.Drawing.Font("楷体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label12.Location = new System.Drawing.Point(1468, 221);
|
||||
this.label12.Name = "label12";
|
||||
this.label12.Size = new System.Drawing.Size(49, 20);
|
||||
this.label12.TabIndex = 23;
|
||||
this.label12.Text = "螺距";
|
||||
//
|
||||
// label11
|
||||
//
|
||||
this.label11.AutoSize = true;
|
||||
this.label11.Font = new System.Drawing.Font("楷体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label11.Location = new System.Drawing.Point(1327, 223);
|
||||
this.label11.Name = "label11";
|
||||
this.label11.Size = new System.Drawing.Size(89, 20);
|
||||
this.label11.TabIndex = 21;
|
||||
this.label11.Text = "螺丝长度";
|
||||
//
|
||||
// label10
|
||||
//
|
||||
this.label10.AutoSize = true;
|
||||
this.label10.Font = new System.Drawing.Font("楷体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label10.Location = new System.Drawing.Point(1189, 222);
|
||||
this.label10.Name = "label10";
|
||||
this.label10.Size = new System.Drawing.Size(89, 20);
|
||||
this.label10.TabIndex = 19;
|
||||
this.label10.Text = "螺丝个数";
|
||||
//
|
||||
// label9
|
||||
//
|
||||
this.label9.AutoSize = true;
|
||||
this.label9.Font = new System.Drawing.Font("楷体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label9.Location = new System.Drawing.Point(1070, 226);
|
||||
this.label9.Name = "label9";
|
||||
this.label9.Size = new System.Drawing.Size(49, 20);
|
||||
this.label9.TabIndex = 17;
|
||||
this.label9.Text = "齿数";
|
||||
//
|
||||
// label8
|
||||
//
|
||||
this.label8.AutoSize = true;
|
||||
this.label8.Font = new System.Drawing.Font("楷体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label8.Location = new System.Drawing.Point(1467, 156);
|
||||
this.label8.Name = "label8";
|
||||
this.label8.Size = new System.Drawing.Size(49, 20);
|
||||
this.label8.TabIndex = 15;
|
||||
this.label8.Text = "螺距";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Font = new System.Drawing.Font("楷体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label2.Location = new System.Drawing.Point(1326, 157);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(89, 20);
|
||||
this.label2.TabIndex = 13;
|
||||
this.label2.Text = "螺丝长度";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new System.Drawing.Font("楷体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label1.Location = new System.Drawing.Point(1187, 160);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(89, 20);
|
||||
this.label1.TabIndex = 11;
|
||||
this.label1.Text = "螺丝个数";
|
||||
this.label1.Click += new System.EventHandler(this.label1_Click);
|
||||
//
|
||||
// detectbutton
|
||||
//
|
||||
this.detectbutton.BackColor = System.Drawing.Color.Gold;
|
||||
this.detectbutton.Font = new System.Drawing.Font("楷体", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.detectbutton.Location = new System.Drawing.Point(1338, 296);
|
||||
this.detectbutton.Name = "detectbutton";
|
||||
this.detectbutton.Size = new System.Drawing.Size(185, 124);
|
||||
this.detectbutton.TabIndex = 10;
|
||||
this.detectbutton.Text = "检测(&M)";
|
||||
this.detectbutton.UseVisualStyleBackColor = false;
|
||||
this.detectbutton.Click += new System.EventHandler(this.detectbutton_Click);
|
||||
//
|
||||
// opendevicebutton
|
||||
//
|
||||
this.opendevicebutton.BackColor = System.Drawing.Color.Gold;
|
||||
this.opendevicebutton.Font = new System.Drawing.Font("楷体", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.opendevicebutton.Location = new System.Drawing.Point(1074, 296);
|
||||
this.opendevicebutton.Name = "opendevicebutton";
|
||||
this.opendevicebutton.Size = new System.Drawing.Size(212, 124);
|
||||
this.opendevicebutton.TabIndex = 6;
|
||||
this.opendevicebutton.Text = "开启设备";
|
||||
this.opendevicebutton.UseVisualStyleBackColor = false;
|
||||
this.opendevicebutton.Click += new System.EventHandler(this.opendevicebutton_Click);
|
||||
//
|
||||
// SnaptPage
|
||||
//
|
||||
this.SnaptPage.Location = new System.Drawing.Point(1128, 158);
|
||||
this.SnaptPage.Name = "SnaptPage";
|
||||
this.SnaptPage.Size = new System.Drawing.Size(50, 30);
|
||||
this.SnaptPage.TabIndex = 9;
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.pictureBox1);
|
||||
this.groupBox3.Location = new System.Drawing.Point(16, 46);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(461, 440);
|
||||
this.groupBox3.TabIndex = 1;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "pic";
|
||||
this.groupBox3.Enter += new System.EventHandler(this.groupBox3_Enter);
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Location = new System.Drawing.Point(6, 19);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(446, 416);
|
||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pictureBox1.TabIndex = 0;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Font = new System.Drawing.Font("楷体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label7.Location = new System.Drawing.Point(1070, 163);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(49, 20);
|
||||
this.label7.TabIndex = 7;
|
||||
this.label7.Text = "齿数";
|
||||
//
|
||||
// comboBox1
|
||||
//
|
||||
this.comboBox1.Font = new System.Drawing.Font("宋体", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.comboBox1.FormattingEnabled = true;
|
||||
this.comboBox1.Location = new System.Drawing.Point(1165, 44);
|
||||
this.comboBox1.Name = "comboBox1";
|
||||
this.comboBox1.Size = new System.Drawing.Size(352, 43);
|
||||
this.comboBox1.TabIndex = 8;
|
||||
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
|
||||
//
|
||||
// groupBox4
|
||||
//
|
||||
this.groupBox4.Controls.Add(this.pictureBox2);
|
||||
this.groupBox4.Location = new System.Drawing.Point(544, 44);
|
||||
this.groupBox4.Name = "groupBox4";
|
||||
this.groupBox4.Size = new System.Drawing.Size(462, 442);
|
||||
this.groupBox4.TabIndex = 6;
|
||||
this.groupBox4.TabStop = false;
|
||||
this.groupBox4.Text = "pic";
|
||||
this.groupBox4.Enter += new System.EventHandler(this.groupBox4_Enter);
|
||||
//
|
||||
// pictureBox2
|
||||
//
|
||||
this.pictureBox2.Location = new System.Drawing.Point(6, 21);
|
||||
this.pictureBox2.Name = "pictureBox2";
|
||||
this.pictureBox2.Size = new System.Drawing.Size(450, 416);
|
||||
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pictureBox2.TabIndex = 1;
|
||||
this.pictureBox2.TabStop = false;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.BackColor = System.Drawing.Color.Transparent;
|
||||
this.label6.Font = new System.Drawing.Font("楷体", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label6.Location = new System.Drawing.Point(1075, 48);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(87, 35);
|
||||
this.label6.TabIndex = 6;
|
||||
this.label6.Text = "型号";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(1334, 689);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(89, 20);
|
||||
this.label5.TabIndex = 5;
|
||||
this.label5.Text = "检测标识";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(745, 20);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(129, 20);
|
||||
this.label4.TabIndex = 4;
|
||||
this.label4.Text = "侧面检测结果";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(160, 18);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(129, 20);
|
||||
this.label3.TabIndex = 3;
|
||||
this.label3.Text = "上方检测结果";
|
||||
this.label3.Click += new System.EventHandler(this.label3_Click);
|
||||
//
|
||||
// tabcontrol1
|
||||
//
|
||||
this.tabcontrol1.Controls.Add(this.tabPage1);
|
||||
this.tabcontrol1.Controls.Add(this.tabPage2);
|
||||
this.tabcontrol1.Location = new System.Drawing.Point(2, 12);
|
||||
this.tabcontrol1.Name = "tabcontrol1";
|
||||
this.tabcontrol1.SelectedIndex = 0;
|
||||
this.tabcontrol1.Size = new System.Drawing.Size(1605, 803);
|
||||
this.tabcontrol1.TabIndex = 0;
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.textBox15);
|
||||
this.tabPage2.Controls.Add(this.label17);
|
||||
this.tabPage2.Controls.Add(this.textBox14);
|
||||
this.tabPage2.Controls.Add(this.label16);
|
||||
this.tabPage2.Controls.Add(this.textBox13);
|
||||
this.tabPage2.Controls.Add(this.label15);
|
||||
this.tabPage2.Controls.Add(this.textBox12);
|
||||
this.tabPage2.Controls.Add(this.label14);
|
||||
this.tabPage2.Controls.Add(this.button3);
|
||||
this.tabPage2.Controls.Add(this.label13);
|
||||
this.tabPage2.Controls.Add(this.textBox11);
|
||||
this.tabPage2.Controls.Add(this.textBox10);
|
||||
this.tabPage2.Controls.Add(this.button2);
|
||||
this.tabPage2.Controls.Add(this.textBox8);
|
||||
this.tabPage2.Controls.Add(this.button1);
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(1597, 777);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "PLC";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// textBox15
|
||||
//
|
||||
this.textBox15.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.textBox15.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.textBox15.Location = new System.Drawing.Point(350, 230);
|
||||
this.textBox15.Name = "textBox15";
|
||||
this.textBox15.Size = new System.Drawing.Size(168, 29);
|
||||
this.textBox15.TabIndex = 66;
|
||||
//
|
||||
// label17
|
||||
//
|
||||
this.label17.AutoSize = true;
|
||||
this.label17.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label17.Location = new System.Drawing.Point(255, 233);
|
||||
this.label17.Name = "label17";
|
||||
this.label17.Size = new System.Drawing.Size(89, 19);
|
||||
this.label17.TabIndex = 65;
|
||||
this.label17.Text = "不合格数";
|
||||
//
|
||||
// textBox14
|
||||
//
|
||||
this.textBox14.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.textBox14.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.textBox14.Location = new System.Drawing.Point(350, 144);
|
||||
this.textBox14.Name = "textBox14";
|
||||
this.textBox14.Size = new System.Drawing.Size(168, 29);
|
||||
this.textBox14.TabIndex = 64;
|
||||
//
|
||||
// label16
|
||||
//
|
||||
this.label16.AutoSize = true;
|
||||
this.label16.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label16.Location = new System.Drawing.Point(271, 93);
|
||||
this.label16.Name = "label16";
|
||||
this.label16.Size = new System.Drawing.Size(49, 19);
|
||||
this.label16.TabIndex = 63;
|
||||
this.label16.Text = "总数";
|
||||
//
|
||||
// textBox13
|
||||
//
|
||||
this.textBox13.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.textBox13.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.textBox13.Location = new System.Drawing.Point(350, 90);
|
||||
this.textBox13.Name = "textBox13";
|
||||
this.textBox13.Size = new System.Drawing.Size(168, 29);
|
||||
this.textBox13.TabIndex = 62;
|
||||
//
|
||||
// label15
|
||||
//
|
||||
this.label15.AutoSize = true;
|
||||
this.label15.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label15.Location = new System.Drawing.Point(261, 157);
|
||||
this.label15.Name = "label15";
|
||||
this.label15.Size = new System.Drawing.Size(69, 19);
|
||||
this.label15.TabIndex = 61;
|
||||
this.label15.Text = "合格数";
|
||||
//
|
||||
// textBox12
|
||||
//
|
||||
this.textBox12.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.textBox12.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.textBox12.Location = new System.Drawing.Point(350, 26);
|
||||
this.textBox12.Name = "textBox12";
|
||||
this.textBox12.Size = new System.Drawing.Size(168, 29);
|
||||
this.textBox12.TabIndex = 60;
|
||||
this.textBox12.Text = "无";
|
||||
//
|
||||
// label14
|
||||
//
|
||||
this.label14.AutoSize = true;
|
||||
this.label14.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label14.Location = new System.Drawing.Point(255, 33);
|
||||
this.label14.Name = "label14";
|
||||
this.label14.Size = new System.Drawing.Size(89, 19);
|
||||
this.label14.TabIndex = 59;
|
||||
this.label14.Text = "当前型号";
|
||||
//
|
||||
// button3
|
||||
//
|
||||
this.button3.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.button3.Location = new System.Drawing.Point(25, 205);
|
||||
this.button3.Name = "button3";
|
||||
this.button3.Size = new System.Drawing.Size(185, 54);
|
||||
this.button3.TabIndex = 58;
|
||||
this.button3.Text = "关闭报警";
|
||||
this.button3.UseVisualStyleBackColor = true;
|
||||
this.button3.Click += new System.EventHandler(this.button3_Click);
|
||||
//
|
||||
// label13
|
||||
//
|
||||
this.label13.AutoSize = true;
|
||||
this.label13.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label13.Location = new System.Drawing.Point(36, 26);
|
||||
this.label13.Name = "label13";
|
||||
this.label13.Size = new System.Drawing.Size(49, 19);
|
||||
this.label13.TabIndex = 57;
|
||||
this.label13.Text = "地址";
|
||||
//
|
||||
// textBox11
|
||||
//
|
||||
this.textBox11.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.textBox11.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.textBox11.Location = new System.Drawing.Point(132, 72);
|
||||
this.textBox11.Name = "textBox11";
|
||||
this.textBox11.Size = new System.Drawing.Size(64, 29);
|
||||
this.textBox11.TabIndex = 56;
|
||||
//
|
||||
// textBox10
|
||||
//
|
||||
this.textBox10.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.textBox10.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.textBox10.Location = new System.Drawing.Point(105, 23);
|
||||
this.textBox10.Name = "textBox10";
|
||||
this.textBox10.Size = new System.Drawing.Size(105, 29);
|
||||
this.textBox10.TabIndex = 55;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.button2.Location = new System.Drawing.Point(128, 129);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(82, 54);
|
||||
this.button2.TabIndex = 54;
|
||||
this.button2.Text = "写";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click_2);
|
||||
//
|
||||
// textBox8
|
||||
//
|
||||
this.textBox8.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.textBox8.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.textBox8.Location = new System.Drawing.Point(29, 72);
|
||||
this.textBox8.Name = "textBox8";
|
||||
this.textBox8.Size = new System.Drawing.Size(68, 29);
|
||||
this.textBox8.TabIndex = 53;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.button1.Location = new System.Drawing.Point(25, 129);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(82, 54);
|
||||
this.button1.TabIndex = 52;
|
||||
this.button1.Text = "读";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click_2);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.SystemColors.MenuHighlight;
|
||||
this.ClientSize = new System.Drawing.Size(1604, 827);
|
||||
this.Controls.Add(this.tabcontrol1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "MainForm";
|
||||
this.Text = "青岛星科瑞升信息科技有限公司";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
||||
this.Load += new System.EventHandler(this.MainForm_Load);
|
||||
this.tabPage1.ResumeLayout(false);
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.groupBox4.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
|
||||
this.tabcontrol1.ResumeLayout(false);
|
||||
this.tabPage2.ResumeLayout(false);
|
||||
this.tabPage2.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.TabPage tabPage1;
|
||||
private System.Windows.Forms.Button opendevicebutton;
|
||||
private System.Windows.Forms.Button detectbutton;
|
||||
private System.Windows.Forms.TextBox SnaptPage;
|
||||
private System.Windows.Forms.ComboBox comboBox1;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.GroupBox groupBox4;
|
||||
private System.Windows.Forms.PictureBox pictureBox2;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TabControl tabcontrol1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label8;
|
||||
private System.Windows.Forms.Label label9;
|
||||
private System.Windows.Forms.Label label10;
|
||||
private System.Windows.Forms.Label label12;
|
||||
private System.Windows.Forms.Label label11;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.PictureBox pictureBox3;
|
||||
private System.Windows.Forms.TextBox textBox7;
|
||||
private System.Windows.Forms.TextBox textBox6;
|
||||
private System.Windows.Forms.TextBox textBox5;
|
||||
private System.Windows.Forms.TextBox textBox3;
|
||||
private System.Windows.Forms.TextBox textBox2;
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.TextBox textBox4;
|
||||
private System.Windows.Forms.TextBox textBox9;
|
||||
private System.Windows.Forms.TabPage tabPage2;
|
||||
private System.Windows.Forms.Label label13;
|
||||
private System.Windows.Forms.TextBox textBox11;
|
||||
private System.Windows.Forms.TextBox textBox10;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.TextBox textBox8;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Button button3;
|
||||
private System.Windows.Forms.TextBox textBox15;
|
||||
private System.Windows.Forms.Label label17;
|
||||
private System.Windows.Forms.TextBox textBox14;
|
||||
private System.Windows.Forms.Label label16;
|
||||
private System.Windows.Forms.TextBox textBox13;
|
||||
private System.Windows.Forms.Label label15;
|
||||
private System.Windows.Forms.TextBox textBox12;
|
||||
private System.Windows.Forms.Label label14;
|
||||
}
|
||||
}
|
||||
|
1063
MainForm.cs
Normal file
1063
MainForm.cs
Normal file
File diff suppressed because it is too large
Load Diff
3717
MainForm.resx
Normal file
3717
MainForm.resx
Normal file
File diff suppressed because it is too large
Load Diff
42
Program.cs
Normal file
42
Program.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace YSDetection
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序的主入口点。
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
Application.Run(new MainForm());
|
||||
|
||||
//Application.EnableVisualStyles();
|
||||
//Application.SetCompatibleTextRenderingDefault(false);
|
||||
//Application.Run(new Login());
|
||||
//Login login = new Login();
|
||||
|
||||
////界面转换
|
||||
//login.ShowDialog();
|
||||
|
||||
//if (login.DialogResult == DialogResult.OK)
|
||||
//{
|
||||
// login.Dispose();
|
||||
// Application.Run(new MainForm());
|
||||
//}
|
||||
//else if (login.DialogResult == DialogResult.Cancel)
|
||||
//{
|
||||
// login.Dispose();
|
||||
// return;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
36
Properties/AssemblyInfo.cs
Normal file
36
Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("YSDetection")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("微软中国")]
|
||||
[assembly: AssemblyProduct("YSDetection")]
|
||||
[assembly: AssemblyCopyright("Copyright © 微软中国 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("4a2cf828-b838-46b9-a5a0-77b3e5089328")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
63
Properties/Resources.Designer.cs
generated
Normal file
63
Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace YSDetection.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.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("YSDetection.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
117
Properties/Resources.resx
Normal file
117
Properties/Resources.resx
Normal 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>
|
26
Properties/Settings.Designer.cs
generated
Normal file
26
Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace YSDetection.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
Properties/Settings.settings
Normal file
7
Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
612
SQLiteHelper.cs
Normal file
612
SQLiteHelper.cs
Normal file
@ -0,0 +1,612 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Data;
|
||||
using System.Data.SQLite;
|
||||
using System.Configuration;
|
||||
|
||||
|
||||
public class SQLiteHelper
|
||||
{
|
||||
//数据库连接字符串
|
||||
// public static string connectionString = ConfigurationManager.ConnectionStrings["ProcessDB"].ConnectionString;
|
||||
public static string connectionString = "Data Source =D:\\huarui\\database\\ProcessDB.db;BinaryGUID=False;";
|
||||
public SQLiteHelper() { }
|
||||
|
||||
#region 公用方法
|
||||
|
||||
public static int GetMaxID(string FieldName, string TableName)
|
||||
{
|
||||
string strsql = "select max(" + FieldName + ")+1 from " + TableName;
|
||||
object obj = GetSingle(strsql);
|
||||
if (obj == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return int.Parse(obj.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Exists(string strSql)
|
||||
{
|
||||
object obj = GetSingle(strSql);
|
||||
int cmdresult;
|
||||
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
|
||||
{
|
||||
cmdresult = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmdresult = int.Parse(obj.ToString());
|
||||
}
|
||||
if (cmdresult == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Exists(string strSql, params SQLiteParameter[] cmdParms)
|
||||
{
|
||||
object obj = GetSingle(strSql, cmdParms);
|
||||
int cmdresult;
|
||||
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
|
||||
{
|
||||
cmdresult = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmdresult = int.Parse(obj.ToString());
|
||||
}
|
||||
if (cmdresult == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 执行简单SQL语句
|
||||
|
||||
/// <summary>
|
||||
/// 执行SQL语句,返回影响的记录数
|
||||
/// </summary>
|
||||
/// <param name="SQLString">SQL语句</param>
|
||||
/// <returns>影响的记录数</returns>
|
||||
public static int ExecuteSql(string SQLString)
|
||||
{
|
||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
int rows = cmd.ExecuteNonQuery();
|
||||
return rows;
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException E)
|
||||
{
|
||||
connection.Close();
|
||||
throw new Exception(E.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行SQL语句,设置命令的执行等待时间
|
||||
/// </summary>
|
||||
/// <param name="SQLString"></param>
|
||||
/// <param name="Times"></param>
|
||||
/// <returns></returns>
|
||||
public static int ExecuteSqlByTime(string SQLString, int Times)
|
||||
{
|
||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
cmd.CommandTimeout = Times;
|
||||
int rows = cmd.ExecuteNonQuery();
|
||||
return rows;
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException E)
|
||||
{
|
||||
connection.Close();
|
||||
throw new Exception(E.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行多条SQL语句,实现数据库事务。
|
||||
/// </summary>
|
||||
/// <param name="SQLStringList">多条SQL语句</param>
|
||||
public static bool ExecuteSqlTran(ArrayList SQLStringList)
|
||||
{
|
||||
bool isSuccess = false;
|
||||
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
SQLiteCommand cmd = new SQLiteCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = "PRAGMA synchronous = OFF;";
|
||||
cmd.ExecuteNonQuery();
|
||||
SQLiteTransaction tx = conn.BeginTransaction();
|
||||
cmd.Transaction = tx;
|
||||
try
|
||||
{
|
||||
for (int n = 0; n < SQLStringList.Count; n++)
|
||||
{
|
||||
string strsql = SQLStringList[n].ToString();
|
||||
if (strsql.Trim().Length > 1)
|
||||
{
|
||||
cmd.CommandText = strsql;
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
tx.Commit();
|
||||
isSuccess = true;
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException E)
|
||||
{
|
||||
tx.Rollback();
|
||||
isSuccess = false;
|
||||
throw new Exception(E.Message);
|
||||
}
|
||||
}
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行带一个存储过程参数的的SQL语句。
|
||||
/// </summary>
|
||||
/// <param name="SQLString">SQL语句</param>
|
||||
/// <param name="content">参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加</param>
|
||||
/// <returns>影响的记录数</returns>
|
||||
public static int ExecuteSql(string SQLString, string content)
|
||||
{
|
||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
SQLiteCommand cmd = new SQLiteCommand(SQLString, connection);
|
||||
SQLiteParameter myParameter = new SQLiteParameter("@content", DbType.String);
|
||||
myParameter.Value = content;
|
||||
cmd.Parameters.Add(myParameter);
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
int rows = cmd.ExecuteNonQuery();
|
||||
return rows;
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException E)
|
||||
{
|
||||
throw new Exception(E.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Dispose();
|
||||
connection.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行带一个存储过程参数的的SQL语句。
|
||||
/// </summary>
|
||||
/// <param name="SQLString">SQL语句</param>
|
||||
/// <param name="content">参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加</param>
|
||||
/// <returns>影响的记录数</returns>
|
||||
public static object ExecuteSqlGet(string SQLString, string content)
|
||||
{
|
||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
SQLiteCommand cmd = new SQLiteCommand(SQLString, connection);
|
||||
SQLiteParameter myParameter = new SQLiteParameter("@content", DbType.String);
|
||||
myParameter.Value = content;
|
||||
cmd.Parameters.Add(myParameter);
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
object obj = cmd.ExecuteScalar();
|
||||
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException E)
|
||||
{
|
||||
throw new Exception(E.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Dispose();
|
||||
connection.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向数据库里插入图像格式的字段(和上面情况类似的另一种实例)
|
||||
/// </summary>
|
||||
/// <param name="strSQL">SQL语句</param>
|
||||
/// <param name="fs">图像字节,数据库的字段类型为image的情况</param>
|
||||
/// <returns>影响的记录数</returns>
|
||||
public static int ExecuteSqlInsertImg(string strSQL, byte[] fs)
|
||||
{
|
||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
SQLiteCommand cmd = new SQLiteCommand(strSQL, connection);
|
||||
SQLiteParameter myParameter = new SQLiteParameter("@fs", DbType.Binary);
|
||||
myParameter.Value = fs;
|
||||
cmd.Parameters.Add(myParameter);
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
int rows = cmd.ExecuteNonQuery();
|
||||
return rows;
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException E)
|
||||
{
|
||||
throw new Exception(E.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Dispose();
|
||||
connection.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行一条计算查询结果语句,返回查询结果(object)。
|
||||
/// </summary>
|
||||
/// <param name="SQLString">计算查询结果语句</param>
|
||||
/// <returns>查询结果(object)</returns>
|
||||
public static object GetSingle(string SQLString)
|
||||
{
|
||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
object obj = cmd.ExecuteScalar();
|
||||
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException e)
|
||||
{
|
||||
connection.Close();
|
||||
throw new Exception(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行查询语句,返回SQLiteDataReader(使用该方法切记要手工关闭SQLiteDataReader和连接)
|
||||
/// </summary>
|
||||
/// <param name="strSQL">查询语句</param>
|
||||
/// <returns>SQLiteDataReader</returns>
|
||||
public static SQLiteDataReader ExecuteReader(string strSQL)
|
||||
{
|
||||
SQLiteConnection connection = new SQLiteConnection(connectionString);
|
||||
SQLiteCommand cmd = new SQLiteCommand(strSQL, connection);
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
SQLiteDataReader myReader = cmd.ExecuteReader();
|
||||
return myReader;
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException e)
|
||||
{
|
||||
throw new Exception(e.Message);
|
||||
}
|
||||
//finally //不能在此关闭,否则,返回的对象将无法使用
|
||||
//{
|
||||
// cmd.Dispose();
|
||||
// connection.Close();
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行查询语句,返回DataSet
|
||||
/// </summary>
|
||||
/// <param name="SQLString">查询语句</param>
|
||||
/// <returns>DataSet</returns>
|
||||
public static DataSet Query(string SQLString)
|
||||
{
|
||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
DataSet ds = new DataSet();
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection);
|
||||
command.Fill(ds, "ds");
|
||||
connection.Close();
|
||||
command.Dispose();
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException ex)
|
||||
{
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
|
||||
public static DataSet Query(string SQLString, string TableName)
|
||||
{
|
||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
DataSet ds = new DataSet();
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection);
|
||||
command.Fill(ds, TableName);
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException ex)
|
||||
{
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行查询语句,返回DataSet,设置命令的执行等待时间
|
||||
/// </summary>
|
||||
/// <param name="SQLString"></param>
|
||||
/// <param name="Times"></param>
|
||||
/// <returns></returns>
|
||||
public static DataSet Query(string SQLString, int Times)
|
||||
{
|
||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
DataSet ds = new DataSet();
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection);
|
||||
command.SelectCommand.CommandTimeout = Times;
|
||||
command.Fill(ds, "ds");
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException ex)
|
||||
{
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 执行带参数的SQL语句
|
||||
|
||||
/// <summary>
|
||||
/// 执行SQL语句,返回影响的记录数
|
||||
/// </summary>
|
||||
/// <param name="SQLString">SQL语句</param>
|
||||
/// <returns>影响的记录数</returns>
|
||||
public static int ExecuteSql(string SQLString, params SQLiteParameter[] cmdParms)
|
||||
{
|
||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
using (SQLiteCommand cmd = new SQLiteCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, connection, null, SQLString, cmdParms);
|
||||
int rows = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
return rows;
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException E)
|
||||
{
|
||||
throw new Exception(E.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行多条SQL语句,实现数据库事务。
|
||||
/// </summary>
|
||||
/// <param name="SQLStringList">SQL语句的哈希表(key为sql语句,value是该语句的SQLiteParameter[])</param>
|
||||
public static void ExecuteSqlTran(Hashtable SQLStringList)
|
||||
{
|
||||
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (SQLiteTransaction trans = conn.BeginTransaction())
|
||||
{
|
||||
SQLiteCommand cmd = new SQLiteCommand();
|
||||
try
|
||||
{
|
||||
//循环
|
||||
foreach (DictionaryEntry myDE in SQLStringList)
|
||||
{
|
||||
string cmdText = myDE.Key.ToString();
|
||||
SQLiteParameter[] cmdParms = (SQLiteParameter[])myDE.Value;
|
||||
PrepareCommand(cmd, conn, trans, cmdText, cmdParms);
|
||||
int val = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
}
|
||||
trans.Commit();
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException e)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw new Exception(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行一条计算查询结果语句,返回查询结果(object)。
|
||||
/// </summary>
|
||||
/// <param name="SQLString">计算查询结果语句</param>
|
||||
/// <returns>查询结果(object)</returns>
|
||||
public static object GetSingle(string SQLString, params SQLiteParameter[] cmdParms)
|
||||
{
|
||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
using (SQLiteCommand cmd = new SQLiteCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, connection, null, SQLString, cmdParms);
|
||||
object obj = cmd.ExecuteScalar();
|
||||
cmd.Parameters.Clear();
|
||||
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException e)
|
||||
{
|
||||
throw new Exception(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行查询语句,返回SQLiteDataReader (使用该方法切记要手工关闭SQLiteDataReader和连接)
|
||||
/// </summary>
|
||||
/// <param name="strSQL">查询语句</param>
|
||||
/// <returns>SQLiteDataReader</returns>
|
||||
public static SQLiteDataReader ExecuteReader(string SQLString, params SQLiteParameter[] cmdParms)
|
||||
{
|
||||
SQLiteConnection connection = new SQLiteConnection(connectionString);
|
||||
SQLiteCommand cmd = new SQLiteCommand();
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, connection, null, SQLString, cmdParms);
|
||||
SQLiteDataReader myReader = cmd.ExecuteReader();
|
||||
cmd.Parameters.Clear();
|
||||
return myReader;
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException e)
|
||||
{
|
||||
throw new Exception(e.Message);
|
||||
}
|
||||
//finally //不能在此关闭,否则,返回的对象将无法使用
|
||||
//{
|
||||
// cmd.Dispose();
|
||||
// connection.Close();
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行查询语句,返回DataSet
|
||||
/// </summary>
|
||||
/// <param name="SQLString">查询语句</param>
|
||||
/// <returns>DataSet</returns>
|
||||
public static DataSet Query(string SQLString, params SQLiteParameter[] cmdParms)
|
||||
{
|
||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
SQLiteCommand cmd = new SQLiteCommand();
|
||||
PrepareCommand(cmd, connection, null, SQLString, cmdParms);
|
||||
using (SQLiteDataAdapter da = new SQLiteDataAdapter(cmd))
|
||||
{
|
||||
DataSet ds = new DataSet();
|
||||
try
|
||||
{
|
||||
da.Fill(ds, "ds");
|
||||
cmd.Parameters.Clear();
|
||||
}
|
||||
catch (System.Data.SQLite.SQLiteException ex)
|
||||
{
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void PrepareCommand(SQLiteCommand cmd, SQLiteConnection conn,
|
||||
SQLiteTransaction trans, string cmdText, SQLiteParameter[] cmdParms)
|
||||
{
|
||||
if (conn.State != ConnectionState.Open)
|
||||
conn.Open();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = cmdText;
|
||||
if (trans != null)
|
||||
cmd.Transaction = trans;
|
||||
cmd.CommandType = CommandType.Text;//cmdType;
|
||||
if (cmdParms != null)
|
||||
{
|
||||
foreach (SQLiteParameter parameter in cmdParms)
|
||||
{
|
||||
if ((parameter.Direction == ParameterDirection.InputOutput
|
||||
|| parameter.Direction == ParameterDirection.Input) &&
|
||||
(parameter.Value == null))
|
||||
{
|
||||
parameter.Value = DBNull.Value;
|
||||
}
|
||||
cmd.Parameters.Add(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 参数转换
|
||||
/// <summary>
|
||||
/// 放回一个SQLiteParameter
|
||||
/// </summary>
|
||||
/// <param name="name">参数名字</param>
|
||||
/// <param name="type">参数类型</param>
|
||||
/// <param name="size">参数大小</param>
|
||||
/// <param name="value">参数值</param>
|
||||
/// <returns>SQLiteParameter的值</returns>
|
||||
public static SQLiteParameter MakeSQLiteParameter(string name,
|
||||
DbType type, int size, object value)
|
||||
{
|
||||
SQLiteParameter parm = new SQLiteParameter(name, type, size);
|
||||
parm.Value = value;
|
||||
return parm;
|
||||
}
|
||||
|
||||
public static SQLiteParameter MakeSQLiteParameter(string name, DbType type, object value)
|
||||
{
|
||||
SQLiteParameter parm = new SQLiteParameter(name, type);
|
||||
parm.Value = value;
|
||||
return parm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
145
SerialPortBase.cs
Normal file
145
SerialPortBase.cs
Normal file
@ -0,0 +1,145 @@
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO.Ports;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace YSDetection
|
||||
{
|
||||
public class SerialPortBase
|
||||
{
|
||||
private object _lock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// 串口对象
|
||||
/// </summary>
|
||||
private SerialPort _serialPort = null;
|
||||
|
||||
|
||||
public event Action<byte[]> OnDataReceived;
|
||||
|
||||
|
||||
public void Init(string port)
|
||||
{
|
||||
if (_serialPort == null)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_serialPort == null)
|
||||
{
|
||||
_serialPort = new SerialPort(port);
|
||||
_serialPort.BaudRate = 115200;
|
||||
_serialPort.Parity = Parity.None;
|
||||
_serialPort.DataBits =8;
|
||||
_serialPort.StopBits = StopBits.One;
|
||||
_serialPort.DataReceived -= SerialPort_DataReceived;
|
||||
_serialPort.DataReceived += SerialPort_DataReceived;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void SerialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
|
||||
{
|
||||
int count = _serialPort.BytesToRead;
|
||||
byte[] buffer = new byte[count];
|
||||
|
||||
var rCount = Read(buffer, 0, count);
|
||||
|
||||
if (count != rCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Task.Run(async () =>
|
||||
//{
|
||||
// if (BytesCompare(buffer, _triggerdData))
|
||||
// {
|
||||
// if (IConfig.TriggerDelay > 0)
|
||||
// {
|
||||
// await Task.Delay(IConfig.TriggerDelay);
|
||||
// }
|
||||
// // OnTriggered?.Invoke();
|
||||
// }
|
||||
// else if (BytesCompare(buffer, _disconnectedData))
|
||||
// {
|
||||
// // OnDisconnected?.Invoke();
|
||||
// }
|
||||
//});
|
||||
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
//if(count==9)
|
||||
OnDataReceived?.Invoke(buffer);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
private bool BytesCompare(byte[] b1, byte[] b2)
|
||||
{
|
||||
if (b1 == null || b2 == null) return false;
|
||||
if (b1.Length != b2.Length) return false;
|
||||
for (int i = 0; i < b1.Length; ++i)
|
||||
{
|
||||
if (b1[i] != b2[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
try
|
||||
{
|
||||
_serialPort.Open();
|
||||
// LogAsync(DateTime.Now, LogLevel.Assist, $"{Name}[{_serialPort.PortName}]已打开");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
try
|
||||
{
|
||||
_serialPort.Close();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
return _serialPort.Read(buffer, offset, count);
|
||||
}
|
||||
|
||||
public void Writebty(byte[] buffer, int offset, int count)
|
||||
{
|
||||
_serialPort.Write(buffer, offset, count);
|
||||
}
|
||||
public void WriteStr(string buffer)
|
||||
{
|
||||
_serialPort.Write(buffer);
|
||||
}
|
||||
//protected void Read()
|
||||
//{
|
||||
// SerialPortHelper.ReadExisting(_serialPort);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
394
SiemensPLCTCPDriver.cs
Normal file
394
SiemensPLCTCPDriver.cs
Normal file
@ -0,0 +1,394 @@
|
||||
|
||||
using HslCommunication;
|
||||
using HslCommunication.Profinet.Melsec;
|
||||
using HslCommunication.Profinet.Siemens;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using static OpenCvSharp.FileStorage;
|
||||
|
||||
|
||||
|
||||
namespace YSDetection
|
||||
{
|
||||
|
||||
|
||||
public class SiemensPLCTCPDriver
|
||||
{
|
||||
|
||||
private SiemensS7Net siemensTcpNet = null;
|
||||
private SiemensPLCS siemensPLCSelected = SiemensPLCS.S200Smart;
|
||||
private MelsecMcNet melsecMc = new MelsecMcNet();
|
||||
// private HslCommunication.ModBus.ModbusTcpNet melsecMc = new HslCommunication.ModBus.ModbusTcpNet();
|
||||
//HslCommunication.Profinet.Melsec.MelsecMcServer melsecMc = new HslCommunication.Profinet.Melsec.MelsecMcServer();
|
||||
|
||||
#region PLCBase
|
||||
|
||||
|
||||
|
||||
public int ReadInt(string address)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 读取Int变量
|
||||
var result = siemensTcpNet.ReadInt32(address);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return result.Content;
|
||||
}
|
||||
else
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Error, $"{Name}未读取到数据:" + "地址:" + address + ";提示:" + result.Message);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}读取异常:" + ex.GetExceptionMessage());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
public int ReadBool(string address)
|
||||
{
|
||||
try
|
||||
{
|
||||
int value = -1;
|
||||
// 读取Int变量
|
||||
var result = siemensTcpNet.ReadBool(address);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
if(result.Content)
|
||||
value = 1;
|
||||
else
|
||||
value = 0;
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = -1;
|
||||
// LogAsync(DateTime.Now, LogLevel.Error, $"{Name}未读取到数据:" + "地址:" + address + ";提示:" + result.Message);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}读取异常:" + ex.GetExceptionMessage());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
//public void WriteItem(PLCItem item, bool waitForReply = true)
|
||||
//{
|
||||
// item.PLCOpType = PLCOpType.Write;
|
||||
|
||||
// if (item.ItemValues == null || item.ItemValues.Count < 1)
|
||||
// {
|
||||
// // LogAsync(DateTime.Now, LogLevel.Error, $"{Name} 数据写入值不能为空");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// int repeatTime = 3;
|
||||
// Stopwatch sw = new Stopwatch();
|
||||
|
||||
// do
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var result = siemensTcpNet.Write(item.Address, item.ItemValues.First());
|
||||
// if (result.IsSuccess)
|
||||
// {
|
||||
// repeatTime = 0;
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// if (repeatTime < 0)
|
||||
// {
|
||||
// //LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}数据写入异常:{ex.GetExceptionMessage()}");
|
||||
// }
|
||||
// }
|
||||
// } while (repeatTime > 0);
|
||||
// sw.Stop();
|
||||
// // LogAsync(DateTime.Now, LogLevel.Assist, $"{Name} WriteItem:{item.GetDisplayText()},写入 {item.ItemValues.First()}完成,耗时:{sw.ElapsedMilliseconds} ms");
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 写单独地址
|
||||
/// </summary>
|
||||
/// <param name="address">地址</param>
|
||||
/// <param name="writeValue"></param>
|
||||
/// <param name="waitForReply"></param>
|
||||
public void WriteBool(string address, bool writeValue, bool waitForReply = true)
|
||||
{
|
||||
if (string.IsNullOrEmpty(address))
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Error, $"{Name} 数据写入参数不能为空!");
|
||||
return;
|
||||
}
|
||||
|
||||
int repeatTime = 3;
|
||||
Stopwatch sw = new Stopwatch();
|
||||
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = siemensTcpNet.Write(address, writeValue);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
repeatTime = 0;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (repeatTime < 0)
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}数据写入异常:{ex.GetExceptionMessage()}");
|
||||
}
|
||||
}
|
||||
} while (repeatTime > 0);
|
||||
sw.Stop();
|
||||
// LogAsync(DateTime.Now, LogLevel.Assist, $"{Name} {address},写入 {writeValue} 完成,耗时:{sw.ElapsedMilliseconds} ms");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写单独地址
|
||||
/// </summary>
|
||||
/// <param name="address">地址</param>
|
||||
/// <param name="writeValue"></param>
|
||||
/// <param name="waitForReply"></param>
|
||||
public void WriteInt(string address, int writeValue, bool waitForReply = true)
|
||||
{
|
||||
if (string.IsNullOrEmpty(address))
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Error, $"{Name} 数据写入参数不能为空!");
|
||||
return;
|
||||
}
|
||||
|
||||
int repeatTime = 3;
|
||||
Stopwatch sw = new Stopwatch();
|
||||
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = siemensTcpNet.Write("M"+address, writeValue);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
repeatTime = 0;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (repeatTime < 0)
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}数据写入异常:{ex.GetExceptionMessage()}");
|
||||
}
|
||||
}
|
||||
} while (repeatTime > 0);
|
||||
sw.Stop();
|
||||
// LogAsync(DateTime.Now, LogLevel.Assist, $"{Name} {address},写入 {writeValue} 完成,耗时:{sw.ElapsedMilliseconds} ms");
|
||||
}
|
||||
/// <summary>
|
||||
/// 写单独地址 string值
|
||||
/// </summary>
|
||||
/// <param name="address">地址</param>
|
||||
/// <param name="writeValue"></param>
|
||||
/// <param name="waitForReply"></param>
|
||||
public void WriteString(string address, string writeValue, bool waitForReply = true)
|
||||
{
|
||||
if (string.IsNullOrEmpty(address) || string.IsNullOrEmpty(writeValue))
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Error, $"{Name} 数据写入参数不能为空!");
|
||||
return;
|
||||
}
|
||||
|
||||
int repeatTime = 3;
|
||||
Stopwatch sw = new Stopwatch();
|
||||
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = siemensTcpNet.Write(address, writeValue);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
repeatTime = 0;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (repeatTime < 0)
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}数据写入异常:{ex.GetExceptionMessage()}");
|
||||
}
|
||||
}
|
||||
} while (repeatTime > 0);
|
||||
sw.Stop();
|
||||
// LogAsync(DateTime.Now, LogLevel.Assist, $"{Name} {address},写入{writeValue}完成,耗时:{sw.ElapsedMilliseconds} ms");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写单独地址 float值
|
||||
/// </summary>
|
||||
/// <param name="address">地址</param>
|
||||
/// <param name="writeValue"></param>
|
||||
/// <param name="waitForReply"></param>
|
||||
public void WriteFloat(string address, float writeValue, bool waitForReply = true)
|
||||
{
|
||||
if (string.IsNullOrEmpty(address))
|
||||
{
|
||||
//LogAsync(DateTime.Now, LogLevel.Error, $"{Name} 数据写入参数不能为空!");
|
||||
return;
|
||||
}
|
||||
|
||||
int repeatTime = 3;
|
||||
Stopwatch sw = new Stopwatch();
|
||||
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = siemensTcpNet.Write(address, writeValue);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
repeatTime = 0;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (repeatTime < 0)
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}数据写入异常:{ex.GetExceptionMessage()}");
|
||||
}
|
||||
}
|
||||
} while (repeatTime > 0);
|
||||
sw.Stop();
|
||||
// LogAsync(DateTime.Now, LogLevel.Assist, $"{Name} {address},写入{writeValue}完成,耗时:{sw.ElapsedMilliseconds} ms");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DeviceBase
|
||||
|
||||
public void Start()
|
||||
{
|
||||
// IConfig.ip
|
||||
|
||||
siemensTcpNet = new SiemensS7Net(siemensPLCSelected, "192.168.2.1");
|
||||
|
||||
// 如果网络不太理想,配置了两个端口,一个有问题,立即切换另一个的话,可以配置如下的代码
|
||||
// melsecMc.GetPipeSocket().SetMultiPorts(new int[] { 6000, 6001 });
|
||||
//melsecMc = new HslCommunication.ModBus.ModbusTcpNet();
|
||||
//melsecMc.IpAddress = "192.168.3.39";
|
||||
//melsecMc.Port = 502;
|
||||
//melsecMc.ConnectTimeOut = 10000; // 连接超时,单位毫秒
|
||||
//melsecMc.ReceiveTimeOut = 5000; // 接收超时,单位毫秒
|
||||
//melsecMc.Station = 1;
|
||||
//melsecMc.AddressStartWithZero = true;
|
||||
//melsecMc.IsStringReverse = false;
|
||||
//melsecMc.DataFormat = HslCommunication.Core.DataFormat.CDAB;
|
||||
|
||||
|
||||
// melsecMc.ServerStart(6000);
|
||||
// 连接对象
|
||||
OperateResult connect = siemensTcpNet.ConnectServer();
|
||||
if (connect.IsSuccess)
|
||||
{
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
// HeartbeatMonitor();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}已开启异常:{connect.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
protected void Stop()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
// 断开连接
|
||||
// melsecMc.RemoteStop();
|
||||
siemensTcpNet.ConnectClose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}关闭异常:{ex.GetExceptionMessage()}");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
#region IMonitor
|
||||
readonly byte[] scanBuffer = new byte[2048];
|
||||
|
||||
public List<int> GetMonitorValues(int startAddress, int length)
|
||||
{
|
||||
List<int> res = new List<int>();
|
||||
// var result = melsecMc.ReadUInt16(startAddress.ToString(), (ushort)length);
|
||||
// var result = melsecMc.ReadInt32("D" + startAddress, (ushort)length);
|
||||
var result = siemensTcpNet.ReadInt32("" + startAddress, (ushort)length);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
res = new List<int>(result.Content);
|
||||
}
|
||||
else
|
||||
{
|
||||
//LogAsync(DateTime.Now, LogLevel.Error, $"{Name}未读取到数据:" + "地址:W" + startAddress + ";长度:" + length + ";提示:" + result.Message);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#endregion
|
||||
|
||||
int HeartbeatCycle = 2;
|
||||
string HeartbeatAddress = "M12.0";
|
||||
bool CurrentState = false;
|
||||
public event Action<int> Heartbeat;
|
||||
public async void HeartbeatMonitor()
|
||||
{
|
||||
if (HeartbeatCycle <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(HeartbeatAddress)
|
||||
&& HeartbeatCycle > 0)
|
||||
{
|
||||
while (CurrentState != false)
|
||||
{
|
||||
if (HeartbeatCycle <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Delay(HeartbeatCycle * 1000);
|
||||
var result = siemensTcpNet.Write(HeartbeatAddress, true);
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
Heartbeat?.Invoke(1);
|
||||
//LogAsync(DateTime.Now, LogLevel.Error, $"{this.Name} 心跳监听失败");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
270
SimboObjectDetection.cs
Normal file
270
SimboObjectDetection.cs
Normal file
@ -0,0 +1,270 @@
|
||||
|
||||
using OpenCvSharp;
|
||||
using OpenCvSharp.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class SegResult
|
||||
{
|
||||
public List<Result> SegmentResult;
|
||||
public class Result
|
||||
{
|
||||
|
||||
public double fScore;
|
||||
public int classId;
|
||||
public string classname;
|
||||
|
||||
public double area;
|
||||
public List<int> rect;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 实例分割 maskrcnn
|
||||
/// </summary>
|
||||
public class SimboObjectDetection
|
||||
{
|
||||
|
||||
|
||||
IntPtr Model;
|
||||
|
||||
public bool Load(string ModelFile, string InferenceDevice, string InputNodeName, int InferenceWidth, int InferenceHeight)
|
||||
{
|
||||
bool res = false;
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
Model = MLEngine.InitModel(ModelFile,
|
||||
InferenceDevice,
|
||||
InputNodeName,
|
||||
1, 3,
|
||||
InferenceWidth,
|
||||
InferenceHeight);
|
||||
res = true;
|
||||
|
||||
#if USE_MULTI_THREAD
|
||||
|
||||
IsCreated = true;
|
||||
if (IsCreated)
|
||||
{
|
||||
if (_runHandleBefore == null)
|
||||
{
|
||||
_runHandleBefore = new AutoResetEvent(false);
|
||||
}
|
||||
|
||||
if (_runHandleAfter == null)
|
||||
{
|
||||
_runHandleAfter = new ManualResetEvent(false);
|
||||
}
|
||||
|
||||
if (_runTask == null)
|
||||
{
|
||||
_runTask = Task.Factory.StartNew(() =>
|
||||
{
|
||||
while (IsCreated)
|
||||
{
|
||||
_runHandleBefore.WaitOne();
|
||||
|
||||
if (IsCreated)
|
||||
{
|
||||
_result = RunInferenceFixed(_req);
|
||||
_runHandleAfter.Set();
|
||||
}
|
||||
}
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if USE_MULTI_THREAD
|
||||
MLRequest _req = null;
|
||||
MLResult _result = null;
|
||||
|
||||
|
||||
public bool IsCreated { get; set; } = false;
|
||||
Task _runTask = null;
|
||||
AutoResetEvent _runHandleBefore = new AutoResetEvent(false);
|
||||
ManualResetEvent _runHandleAfter = new ManualResetEvent(false);
|
||||
object _runLock = new object();
|
||||
#endif
|
||||
|
||||
[HandleProcessCorruptedStateExceptions]
|
||||
public MLResult RunInference(MLRequest req)
|
||||
{
|
||||
#if USE_MULTI_THREAD
|
||||
MLResult mlResult = null;
|
||||
lock (_runLock)
|
||||
{
|
||||
_result = new MLResult();
|
||||
|
||||
_req = req;
|
||||
|
||||
_runHandleAfter.Reset();
|
||||
_runHandleBefore.Set();
|
||||
_runHandleAfter.WaitOne();
|
||||
|
||||
mlResult = _result;
|
||||
}
|
||||
|
||||
return mlResult;
|
||||
#else
|
||||
return RunInferenceFixed(req);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ConvertJsonResult(string json, ref MLResult result)
|
||||
{
|
||||
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
|
||||
//
|
||||
Console.WriteLine("检测结果JSON:" + json);
|
||||
SegResult detResult = JsonConvert.DeserializeObject<SegResult>(json);
|
||||
if (detResult == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int iNum = detResult.SegmentResult.Count;
|
||||
int IokNum = 0;
|
||||
for (int ix = 0; ix < iNum; ix++)
|
||||
{
|
||||
var det = detResult.SegmentResult[ix];
|
||||
|
||||
var rect = det.rect;
|
||||
DetectionResultDetail detectionResultDetail = new DetectionResultDetail();
|
||||
detectionResultDetail.LabelNo = det.classId;
|
||||
//todo: 标签名相对应
|
||||
detectionResultDetail.LabelDisplay = det.classname;
|
||||
detectionResultDetail.Rect = new Rectangle(rect[0], rect[1], rect[2], rect[3]);
|
||||
detectionResultDetail.Score = det.fScore;
|
||||
detectionResultDetail.LabelName = det.classname;
|
||||
detectionResultDetail.Area = det.area;
|
||||
result.ResultDetails.Add(detectionResultDetail);
|
||||
// detectionResultDetail.InferenceResult = ResultState.NG;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[HandleProcessCorruptedStateExceptions]
|
||||
public MLResult RunInferenceFixed(MLRequest req)
|
||||
{
|
||||
MLResult mlResult = new MLResult();
|
||||
Mat originMat = new Mat();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
// resize
|
||||
originMat = req.currentMat;//1ms
|
||||
|
||||
int iWidth = originMat.Cols;
|
||||
int iHeight = originMat.Rows;
|
||||
int channels = originMat.Channels();
|
||||
//输入数据转化为字节
|
||||
var inputByte = new byte[originMat.Total() * channels];//这里必须乘以通道数,不然数组越界,也可以用w*h*c,差不多
|
||||
Marshal.Copy(originMat.Data, inputByte, 0, inputByte.Length);
|
||||
|
||||
byte[] labellist = new byte[204800]; //新建字节数组:label1_str label2_str
|
||||
|
||||
byte[] outputByte = new byte[originMat.Total() * channels];
|
||||
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
unsafe
|
||||
{
|
||||
mlResult.IsSuccess = MLEngine.det_ModelPredict(Model,
|
||||
inputByte,
|
||||
iWidth, iHeight, channels,
|
||||
req.out_node_name,
|
||||
req.in_lable_path,
|
||||
req.confThreshold, req.iouThreshold,
|
||||
ref outputByte[0],
|
||||
ref labellist[0]);
|
||||
//mlResult.IsSuccess = true;
|
||||
}
|
||||
sw.Stop();
|
||||
|
||||
if (mlResult.IsSuccess)
|
||||
{
|
||||
mlResult.ResultMessage = $"深度学习推理成功,耗时:{sw.ElapsedMilliseconds} ms";
|
||||
|
||||
Mat maskWeighted = new Mat(iHeight, iWidth, MatType.CV_8UC3, outputByte);//CV_8UC3
|
||||
|
||||
mlResult.ResultMap = BitmapConverter.ToBitmap(maskWeighted);//4ms
|
||||
//将字节数组转换为字符串
|
||||
// mlResult.ResultMap = originMat.ToBitmap();//4ms
|
||||
|
||||
string strGet = System.Text.Encoding.Default.GetString(labellist, 0, labellist.Length);
|
||||
|
||||
Console.WriteLine("strGet:", strGet);
|
||||
|
||||
ConvertJsonResult(strGet, ref mlResult);
|
||||
|
||||
maskWeighted?.Dispose();
|
||||
maskWeighted = null;
|
||||
|
||||
// 解析json字符串
|
||||
return mlResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
mlResult.ResultMessage = $"异常:深度学习执行推理失败!";
|
||||
return mlResult;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//mlResult.ResultMessage = $"深度学习执行推理异常:{ex.GetExceptionMessage()}";
|
||||
return mlResult;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
originMat?.Dispose();
|
||||
originMat = null;
|
||||
|
||||
|
||||
// GC.Collect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
266
SimboVisionMLBase.cs
Normal file
266
SimboVisionMLBase.cs
Normal file
@ -0,0 +1,266 @@
|
||||
|
||||
using HZH_Controls.Controls;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
//public abstract class SimboVisionMLBase
|
||||
//{
|
||||
// public Mat ColorLut { get; set; }
|
||||
// public byte[] ColorMap { get; set; }
|
||||
|
||||
// public MLModelType ModelType { get; set; }
|
||||
|
||||
// public IntPtr Model { get; set; }
|
||||
|
||||
// public abstract bool Load(MLInit mLInit);
|
||||
|
||||
// public abstract MLResult RunInference(MLRequest req);
|
||||
|
||||
// public void Dispose()
|
||||
// {
|
||||
// MLEngine.FreePredictor(Model);
|
||||
// }
|
||||
|
||||
// public SimboVisionMLBase()
|
||||
// {
|
||||
// ColorMap = OpenCVHelper.GetColorMap(256);//使用3个通道
|
||||
// ColorLut = new Mat(1, 256, MatType.CV_8UC3, ColorMap);
|
||||
// }
|
||||
//}
|
||||
public class MLInit
|
||||
{
|
||||
public string ModelFile;
|
||||
public string InferenceDevice;
|
||||
|
||||
|
||||
public int InferenceWidth;
|
||||
public int InferenceHeight;
|
||||
|
||||
public string InputNodeName;
|
||||
|
||||
|
||||
|
||||
|
||||
public MLInit(string modelFile, string inputNodeName, string inferenceDevice, int inferenceWidth, int inferenceHeight)
|
||||
{
|
||||
ModelFile = modelFile;
|
||||
InferenceDevice = inferenceDevice;
|
||||
|
||||
InferenceWidth = inferenceWidth;
|
||||
InferenceHeight = inferenceHeight;
|
||||
InputNodeName = inputNodeName;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
public class MLResult
|
||||
{
|
||||
public bool IsSuccess = false;
|
||||
public string ResultMessage;
|
||||
public Bitmap ResultMap;
|
||||
public List<DetectionResultDetail> ResultDetails = new List<DetectionResultDetail>();
|
||||
}
|
||||
public class MLRequest
|
||||
{
|
||||
public int ImageChannels = 3;
|
||||
public Mat currentMat
|
||||
;
|
||||
public int ResizeWidth;
|
||||
public int ResizeHeight;
|
||||
|
||||
public float confThreshold;
|
||||
|
||||
public float iouThreshold;
|
||||
|
||||
//public int ImageResizeCount;
|
||||
|
||||
public string in_node_name;
|
||||
|
||||
public string out_node_name;
|
||||
|
||||
public string in_lable_path;
|
||||
|
||||
public int ResizeImageSize;
|
||||
public int segmentWidth;
|
||||
public int ImageWidth;
|
||||
|
||||
public int Snapshot;
|
||||
|
||||
public string SnapshotName;
|
||||
|
||||
//public List<labelStringBase> OkClassTxtList;
|
||||
|
||||
|
||||
// public List<ModelLabel> LabelNames;
|
||||
|
||||
public float Score;
|
||||
|
||||
}
|
||||
public class DetectionResultDetail
|
||||
{
|
||||
public string LabelBGR { get; set; }//识别到对象的标签BGR
|
||||
|
||||
|
||||
public int LabelNo { get; set; } // 识别到对象的标签索引
|
||||
|
||||
public string LabelName { get; set; }//识别到对象的标签名称
|
||||
|
||||
public double Score { get; set; }//识别目标结果的可能性、得分
|
||||
|
||||
public string LabelDisplay { get; set; }//识别到对象的 显示信息
|
||||
|
||||
public double Area { get; set; }//识别目标的区域面积
|
||||
|
||||
public Rectangle Rect { get; set; }//识别目标的外接矩形
|
||||
|
||||
public RotatedRect MinRect { get; set; }//识别目标的最小外接矩形(带角度)
|
||||
|
||||
//public ResultState InferenceResult { get; set; }//只是模型推理 label的结果
|
||||
|
||||
public double DistanceToImageCenter { get; set; } //计算矩形框到图像中心的距离
|
||||
|
||||
|
||||
|
||||
// public ResultState FinalResult { get; set; }//模型推理+其他视觉、逻辑判断后 label结果
|
||||
}
|
||||
public class XKOCROfficeWord
|
||||
{
|
||||
[StringLength(50)]
|
||||
public int ID { get; set; }
|
||||
[StringLength(50)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public int PageNum { get; set; } = 0;
|
||||
|
||||
[StringLength(100)]
|
||||
public string filePath { get; set; } = "";
|
||||
public string jsonpath { get; set; } = "";
|
||||
|
||||
|
||||
public int LeftTopX { get; set; } = 0;
|
||||
|
||||
public int LeftTopY { get; set; } = 0;
|
||||
|
||||
public int RightBottmX { get; set; } = 0;
|
||||
|
||||
public int RightBottmY { get; set; } = 0;
|
||||
|
||||
public string ResultStr { get; set; } = "";
|
||||
}
|
||||
|
||||
public static class MLEngine
|
||||
{
|
||||
|
||||
//private const string sPath = @"D:\\C#\磁环项目\\OpenVinoYolo\\openvino_Yolov5_v7_v2.0\\openvino_Yolov5_v7\\Program\ConsoleProject\\x64\\Release\\QuickSegmentDynamic.dll";
|
||||
|
||||
|
||||
[DllImport("QuickSegmentDynamic.dll", EntryPoint = "InitModel")]
|
||||
public static extern IntPtr InitModel(string model_filename, string inferenceDevice, string input_node_name, int bacth, int inferenceChannels, int InferenceWidth, int InferenceHeight);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 分割
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="img"></param>
|
||||
/// <param name="W"></param>
|
||||
/// <param name="H"></param>
|
||||
/// <param name="C"></param>
|
||||
/// <param name="labelText"></param>
|
||||
/// <param name="conf_threshold"></param>
|
||||
/// <param name="IOU_THRESHOLD"></param>
|
||||
/// <param name="fScoreThre"></param>
|
||||
/// <param name="segmentWidth"></param>
|
||||
/// <param name="Mask_output"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("QuickSegmentDynamic.dll", EntryPoint = "seg_ModelPredict")]
|
||||
|
||||
public static extern bool seg_ModelPredict(IntPtr model, byte[] img, int W, int H, int C,
|
||||
string labelText, float conf_threshold, float IOU_THRESHOLD, float fScoreThre, int segmentWidth,
|
||||
ref byte Mask_output, ref byte label);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 目标检测
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="img"></param>
|
||||
/// <param name="W"></param>
|
||||
/// <param name="H"></param>
|
||||
/// <param name="C"></param>
|
||||
/// <param name="nodes"></param>
|
||||
/// <param name="labelText"></param>
|
||||
/// <param name="conf_threshold"></param>
|
||||
/// <param name="IOU_THRESHOLD"></param>
|
||||
/// <param name="Mask_output"></param>
|
||||
/// <param name="label"></param>
|
||||
[DllImport("QuickSegmentDynamic.dll", EntryPoint = "det_ModelPredict")]
|
||||
public static extern bool det_ModelPredict(IntPtr model, byte[] img, int W, int H, int C,
|
||||
string nodes,// ++++++++++++++++++++++++++++++++++++
|
||||
string labelText, float conf_threshold, float IOU_THRESHOLD,
|
||||
ref byte Mask_output, ref byte label);
|
||||
|
||||
|
||||
[DllImport("QuickSegmentDynamic.dll", EntryPoint = "FreePredictor")]
|
||||
public static extern void FreePredictor(IntPtr model);
|
||||
|
||||
|
||||
}
|
||||
public static class OcrEngine
|
||||
{
|
||||
|
||||
// private const string sPath = @"F:\OOOCR\PaddleOCRsourcecodeGPU\PROJECTS\OcrDetForm\bin\Release\net7.0-windows\ocrInference.dll";
|
||||
|
||||
|
||||
|
||||
[DllImport("ocrInference.dll", EntryPoint = "InitModel")]
|
||||
public static extern IntPtr InitModel(string model_ParaPath, string device_id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[DllImport("ocrInference.dll", EntryPoint = "Inference")]
|
||||
public static extern bool Inference(IntPtr model, byte[] img, int W, int H, int C,
|
||||
|
||||
ref byte Mask_output, ref byte label);
|
||||
|
||||
|
||||
[DllImport("ocrInference.dll", EntryPoint = "FreePredictor")]
|
||||
public static extern void FreePredictor(IntPtr model);
|
||||
}
|
||||
public static class MLEngine1
|
||||
{
|
||||
/**********************************************************************/
|
||||
/***************** 1.推理DLL导入实现 ****************/
|
||||
/**********************************************************************/
|
||||
//private const string sPath = @"D:\M018_NET7.0\src\Debug\model_infer.dll";
|
||||
// 加载推理相关方法
|
||||
[DllImport("model_infer.dll", EntryPoint = "InitModel")] // 模型统一初始化方法: 需要yml、pdmodel、pdiparams
|
||||
//[DllImport(sPath, EntryPoint = "InitModel")] // 模型统一初始化方法: 需要yml、pdmodel、pdiparams
|
||||
public static extern IntPtr InitModel(string model_type, string model_filename, string params_filename, string cfg_file, bool use_gpu, int gpu_id, ref byte paddlex_model_type);
|
||||
|
||||
[DllImport("model_infer.dll", EntryPoint = "Det_ModelPredict")] // PaddleDetection模型推理方法
|
||||
public static extern bool Det_ModelPredict(IntPtr model, byte[] img, int W, int H, int C, IntPtr output, int[] BoxesNum, ref byte label);
|
||||
|
||||
[DllImport("model_infer.dll", EntryPoint = "Seg_ModelPredict")] // PaddleSeg模型推理方法
|
||||
public static extern bool Seg_ModelPredict(IntPtr model, byte[] img, int W, int H, int C, ref byte output);
|
||||
|
||||
[DllImport("model_infer.dll", EntryPoint = "Cls_ModelPredict")] // PaddleClas模型推理方法
|
||||
public static extern bool Cls_ModelPredict(IntPtr model, byte[] img, int W, int H, int C, ref float score, ref byte category, ref int category_id);
|
||||
|
||||
[DllImport("model_infer.dll", EntryPoint = "Mask_ModelPredict")] // Paddlex的MaskRCNN模型推理方法
|
||||
public static extern bool Mask_ModelPredict(IntPtr model, byte[] img, int W, int H, int C, IntPtr output, ref byte Mask_output, int[] BoxesNum, ref byte label);
|
||||
//public static extern bool Mask_ModelPredict(IntPtr model, IntPtr img, int W, int H, int C, IntPtr output, ref byte Mask_output, int[] BoxesNum, ref byte label);
|
||||
[DllImport("model_infer.dll", EntryPoint = "DestructModel")] // 分割、检测、识别模型销毁方法
|
||||
public static extern void DestructModel(IntPtr model);
|
||||
|
||||
}
|
||||
|
254
YSDetection.csproj
Normal file
254
YSDetection.csproj
Normal file
@ -0,0 +1,254 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
|
||||
<Import Project="packages\OpenCvSharp4.runtime.win.4.9.0.20240103\build\netstandard\OpenCvSharp4.runtime.win.props" Condition="Exists('packages\OpenCvSharp4.runtime.win.4.9.0.20240103\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>{4A2CF828-B838-46B9-A5A0-77B3E5089328}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>YSDetection</RootNamespace>
|
||||
<AssemblyName>YSDetection</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<TargetFrameworkProfile />
|
||||
</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>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</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>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Logo.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</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>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac, Version=8.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Autofac.8.0.0\lib\netstandard2.0\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BetterFolderBrowser, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\BetterFolderBrowser.1.2.0\lib\BetterFolderBrowser.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HslCommunication, Version=7.0.1.0, Culture=neutral, PublicKeyToken=cdb2261fa039ed67, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>bin\x64\Debug\HslCommunication.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HZH_Controls, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\HZH_Controls.1.5.240416\lib\net40\HZH_Controls.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Data.Sqlite, Version=8.0.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Data.Sqlite.Core.8.0.5\lib\netstandard2.0\Microsoft.Data.Sqlite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MvCameraControl.Net, Version=3.2.0.2, Culture=neutral, PublicKeyToken=52fddfb3f94be800, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>libs\MvCameraControl.Net.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="OpenCvSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
|
||||
<HintPath>packages\OpenCvSharp4.4.9.0.20240103\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.9.0.20240103\lib\netstandard2.0\OpenCvSharp.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PaddleOCRSharp, Version=3.1.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>bin\Debug\PaddleOCRSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="SQLitePCLRaw.core, Version=2.1.6.2060, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
|
||||
<HintPath>packages\SQLitePCLRaw.core.2.1.6\lib\netstandard2.0\SQLitePCLRaw.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SunnyUI, Version=3.6.6.0, Culture=neutral, PublicKeyToken=27d7d2e821d97aeb, processorArchitecture=MSIL">
|
||||
<HintPath>packages\SunnyUI.3.6.6\lib\net472\SunnyUI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SunnyUI.Common, Version=3.6.6.0, Culture=neutral, PublicKeyToken=5a271fb7ba597231, processorArchitecture=MSIL">
|
||||
<HintPath>packages\SunnyUI.Common.3.6.6\lib\net472\SunnyUI.Common.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.CodeDom, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.CodeDom.8.0.0\lib\net462\System.CodeDom.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\lib\net46\System.Data.SQLite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SQLite.EF6, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Data.SQLite.EF6.1.0.118.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SQLite.Linq, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Data.SQLite.Linq.1.0.118.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Diagnostics.DiagnosticSource.7.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing.Common, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Drawing.Common.7.0.0\lib\net462\System.Drawing.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.Ports, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.IO.Ports.8.0.0\lib\net462\System.IO.Ports.dll</HintPath>
|
||||
</Reference>
|
||||
<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.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<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.Extensions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WeifenLuo.WinFormsUI.Docking, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5cded1a1a0a7b481, processorArchitecture=MSIL">
|
||||
<HintPath>packages\DockPanelSuite.3.1.0\lib\net40\WeifenLuo.WinFormsUI.Docking.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WeifenLuo.WinFormsUI.Docking.ThemeVS2015, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5cded1a1a0a7b481, processorArchitecture=MSIL">
|
||||
<HintPath>packages\DockPanelSuite.ThemeVS2015.3.1.0\lib\net40\WeifenLuo.WinFormsUI.Docking.ThemeVS2015.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="HikCamera.cs" />
|
||||
<Compile Include="HikCameraDriver.cs" />
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SiemensPLCTCPDriver.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SerialPortBase.cs" />
|
||||
<Compile Include="SimboObjectDetection.cs" />
|
||||
<Compile Include="SimboVisionMLBase.cs" />
|
||||
<Compile Include="SQLiteHelper.cs" />
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Logo.ico" />
|
||||
</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.9.0.20240103\build\netstandard\OpenCvSharp4.runtime.win.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\OpenCvSharp4.runtime.win.4.9.0.20240103\build\netstandard\OpenCvSharp4.runtime.win.props'))" />
|
||||
<Error Condition="!Exists('packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
|
||||
<Error Condition="!Exists('packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
|
||||
<Error Condition="!Exists('packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
|
||||
</Target>
|
||||
<Import Project="packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
|
||||
<Import Project="packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
|
||||
</Project>
|
31
YSDetection.sln
Normal file
31
YSDetection.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34728.123
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YSDetection", "YSDetection.csproj", "{4A2CF828-B838-46B9-A5A0-77B3E5089328}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4A2CF828-B838-46B9-A5A0-77B3E5089328}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4A2CF828-B838-46B9-A5A0-77B3E5089328}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4A2CF828-B838-46B9-A5A0-77B3E5089328}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{4A2CF828-B838-46B9-A5A0-77B3E5089328}.Debug|x64.Build.0 = Debug|x64
|
||||
{4A2CF828-B838-46B9-A5A0-77B3E5089328}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4A2CF828-B838-46B9-A5A0-77B3E5089328}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4A2CF828-B838-46B9-A5A0-77B3E5089328}.Release|x64.ActiveCfg = Release|x64
|
||||
{4A2CF828-B838-46B9-A5A0-77B3E5089328}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E7165424-E71F-4C57-BAE5-2A079E4BA762}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
BIN
libs/HslCommunication.dll
Normal file
BIN
libs/HslCommunication.dll
Normal file
Binary file not shown.
BIN
libs/MvCameraControl.Net.dll
Normal file
BIN
libs/MvCameraControl.Net.dll
Normal file
Binary file not shown.
BIN
libs/MvCameraControl.dll
Normal file
BIN
libs/MvCameraControl.dll
Normal file
Binary file not shown.
37
packages.config
Normal file
37
packages.config
Normal file
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Autofac" version="8.0.0" targetFramework="net472" />
|
||||
<package id="BetterFolderBrowser" version="1.2.0" targetFramework="net472" />
|
||||
<package id="DockPanelSuite" version="3.1.0" targetFramework="net472" />
|
||||
<package id="DockPanelSuite.ThemeVS2015" version="3.1.0" targetFramework="net472" />
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net472" />
|
||||
<package id="HZH_Controls" version="1.5.240416" targetFramework="net472" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Data.Sqlite.Core" version="8.0.5" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||
<package id="OpenCvSharp4" version="4.9.0.20240103" targetFramework="net472" />
|
||||
<package id="OpenCvSharp4.Extensions" version="4.9.0.20240103" targetFramework="net472" />
|
||||
<package id="OpenCvSharp4.runtime.win" version="4.9.0.20240103" targetFramework="net472" />
|
||||
<package id="SQLitePCLRaw.core" version="2.1.6" targetFramework="net472" />
|
||||
<package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.118.0" targetFramework="net472" />
|
||||
<package id="SunnyUI" version="3.6.6" targetFramework="net472" />
|
||||
<package id="SunnyUI.Common" version="3.6.6" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
<package id="System.CodeDom" version="8.0.0" targetFramework="net472" />
|
||||
<package id="System.Data.SQLite" version="1.0.118.0" targetFramework="net472" />
|
||||
<package id="System.Data.SQLite.Core" version="1.0.118.0" targetFramework="net472" />
|
||||
<package id="System.Data.SQLite.EF6" version="1.0.118.0" targetFramework="net472" />
|
||||
<package id="System.Data.SQLite.Linq" version="1.0.118.0" targetFramework="net472" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="7.0.2" targetFramework="net472" />
|
||||
<package id="System.Drawing.Common" version="7.0.0" targetFramework="net472" />
|
||||
<package id="System.IO" version="4.3.0" targetFramework="net472" />
|
||||
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net472" />
|
||||
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net472" />
|
||||
<package id="System.IO.Ports" version="8.0.0" targetFramework="net472" />
|
||||
<package id="System.Management" version="8.0.0" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user