资源简介
C#HALCON开发的完整视觉检测案例MachineVisionPro.
public partial class FrmMain : Form
{
private CamNetMana cam1Server = new CamNetMana("Server1");
private CamNetMana cam2Server = new CamNetMana("Server2");
//相机1
private Cam1Prog cam1 = new Cam1Prog();
//相机2
private Cam2Prog cam2 = new Cam2Prog();
public FrmMain()
{
InitializeComponent();
BackgroundWorker worker = new BackgroundWorker();
worker.WorkerSupportsCancellation = true;
//worker.DoWork = new DoWorkEventHandler(FrmLoad);
worker.DoWork = new DoWorkEventHandler(FrmLoad);
worker.RunWorkerAsync();
FrmStart fs = new FrmStart(worker);
fs.ShowDialog();
}
private void FrmLoad(object sender, DoWorkEventArgs e)
{
cam1.SetModelFile("");
cam2.SetModelFile("");
CamConfig save = new CamConfig();
cam1.NeedSaveCsv = save.CamReadConfig(1, "SaveCsv") == "1" ? true : false;
cam1.NeedSavePicOk = save.CamReadConfig(1, "SavePicOk") == "1" ? true : false;
cam1.NeedSavePicNg = save.CamReadConfig(1, "SavePicNg") == "1" ? true : false;
cam1.NeedSaveDB = save.CamReadConfig(1, "SaveDB") == "1" ? true : false;
cam2.NeedSaveCsv = save.CamReadConfig(2, "SaveCsv") == "1" ? true : false;
cam2.NeedSavePicOk = save.CamReadConfig(2, "SavePicOk") == "1" ? true : false;
cam2.NeedSavePicNg = save.CamReadConfig(2, "SavePicNg") == "1" ? true : false;
cam2.NeedSaveDB = save.CamReadConfig(2, "SaveDB") == "1" ? true : false;
cam1Server.ReadConfig();
cam1Server.Start();
cam2Server.ReadConfig();
cam2Server.Start();
cam1Server.OnReceive = cam1Server_OnReceive;
cam2Server.OnReceive = cam2Server_OnReceive;
cam1Server.OnLogRecord = cam1Server_OnLogRecord;
cam2Server.OnLogRecord = cam2Server_OnLogRecord;
}
void cam1Server_OnLogRecord(string arg1, string arg2)
{
string[] sArray = arg2.Split(':');
// Convert.ToInt32(sArray[0])
Plc1State(Convert.ToInt32(sArray[0]) > 0);
}
void cam2Server_OnLogRecord(string arg1, string arg2)
{
string[] sArray = arg2.Split(':');
// Convert.ToInt32(sArray[0])
Plc2State(Convert.ToInt32(sArray[0]) > 0);
}
void Plc1State(bool isOnLine)
{
if (this.lblPlc1Con.InvokeRequired)
{
this.lblPlc1Con.Invoke(new Action<bool>(a =>
{
this.lblPlc1Con.BackColor = a ? Color.LimeGreen : Color.Gray;
}), isOnLine);
}
else
{
this.lblPlc1Con.BackColor = isOnLine ? Color.LimeGreen : Color.Gray;
}
}
void Plc2State(bool isOnLine)
{
if (this.lblPlc2Con.InvokeRequired)
{
this.lblPlc2Con.Invoke(new Action<bool>(a =>
{
this.lblPlc2Con.BackColor = a ? Color.LimeGreen : Color.Gray;
}), isOnLine);
}
else
{
this.lblPlc2Con.BackColor = isOnLine ? Color.LimeGreen : Color.Gray;
}
}
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//引入三个命名空间
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
namespace BLL
{
public class SerializeobjectToString
{
//将object类型对象(注:必须是可序列化的对象)转换为二进制序列字符串
public string Serializeobject(object obj)
{
IFormatter formatter = new BinaryFormatter();
string result = string.Empty;
using (MemoryStream stream = new MemoryStream())
{
formatter.Serialize(stream obj);
byte[] byt = new byte[stream.Length];
byt = stream.ToArray();
//result = Encoding.UTF8.GetString(byt 0 byt.Length);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 185344 2019-04-12 17:49 MachineVisionPro\.vs\MachineVisionPro\v14\.suo
..A..H. 91648 2019-09-04 09:13 MachineVisionPro\.vs\MachineVisionPro\v16\.suo
....... 24064 2019-04-12 17:36 MachineVisionPro\BLL\bin\Debug\BLL.dll
文件 50688 2019-04-12 17:36 MachineVisionPro\BLL\bin\Debug\BLL.pdb
....... 17408 2019-04-12 17:36 MachineVisionPro\BLL\bin\Debug\DAL.dll
文件 46592 2019-04-12 17:36 MachineVisionPro\BLL\bin\Debug\DAL.pdb
....... 1440400 2017-12-02 17:26 MachineVisionPro\BLL\bin\Debug\halcondotnet.dll
文件 4433597 2017-12-02 02:17 MachineVisionPro\BLL\bin\Debug\halcondotnet.xm
....... 5632 2019-04-12 17:34 MachineVisionPro\BLL\bin\Debug\Models.dll
文件 13824 2019-04-12 17:34 MachineVisionPro\BLL\bin\Debug\Models.pdb
....... 23552 2019-04-12 17:36 MachineVisionPro\BLL\bin\Debug\MyHalcon.dll
文件 34304 2019-04-12 17:36 MachineVisionPro\BLL\bin\Debug\MyHalcon.pdb
....... 12800 2019-04-12 17:34 MachineVisionPro\BLL\bin\Debug\SokectHelper.dll
文件 30208 2019-04-12 17:34 MachineVisionPro\BLL\bin\Debug\SokectHelper.pdb
....... 1770496 2017-11-01 13:32 MachineVisionPro\BLL\bin\Debug\System.Data.SQLite.dll
文件 3872 2019-09-04 09:05 MachineVisionPro\BLL\BLL.csproj
文件 1548 2017-12-15 16:28 MachineVisionPro\BLL\Common\Serializeob
文件 19449 2017-12-16 20:49 MachineVisionPro\BLL\Halcon\Cam1Prog.cs
文件 21388 2017-12-16 20:50 MachineVisionPro\BLL\Halcon\Cam2Prog.cs
文件 653 2017-12-15 08:50 MachineVisionPro\BLL\Halcon\CamConfig.cs
文件 4157 2017-12-15 16:08 MachineVisionPro\BLL\Halcon\CamNetMana.cs
文件 904 2017-12-16 20:39 MachineVisionPro\BLL\Halcon\CamSaveData.cs
文件 4270 2019-04-12 17:36 MachineVisionPro\BLL\obj\Debug\BLL.csproj.FileListAbsolute.txt
文件 28269 2019-04-12 17:36 MachineVisionPro\BLL\obj\Debug\BLL.csprojResolveAssemblyReference.cache
....... 24064 2019-04-12 17:36 MachineVisionPro\BLL\obj\Debug\BLL.dll
文件 50688 2019-04-12 17:36 MachineVisionPro\BLL\obj\Debug\BLL.pdb
文件 7231 2019-04-12 17:34 MachineVisionPro\BLL\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 0 2017-12-14 08:56 MachineVisionPro\BLL\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2017-12-14 08:56 MachineVisionPro\BLL\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2017-12-14 08:56 MachineVisionPro\BLL\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
............此处省略275个文件信息
相关资源
- Basler相机通过IO触发源码
- 亮剑asp.net案例导航项目开发
- 亮剑ASP.NET项目开发案例导航-part03共三
- C#自定义控件案例--美化GroupBox.rar
- Rony.DotNetCore.Solution.zip
- C#项目开发案例全程实录源代码
- 华视CVR100开发SDK说明+C#案例.rar
- visual C#2005 管理系统开发经典案例 罗
- Visual Studio C#播放器制作
- 俄罗斯方框UNITY项目案例包含代码
- C#.NET程序设计案例教程
- c#数据库开发经典案例
- 《C#数据库系统开发案例精选》源代码
-
Visual.Studio.NET.fr
amework技术内幕(高 - 分享 10 套 c# 项目开发案例全程实录全
- Web实训网站C#新闻发布系统
- LMI3D相机连接LMIHalconAcqTest.zip
- C#调用SAP RFC 案例demo
- C#潮流计算和Visio二次开发画电气接线
- PC桌面程序鼠标轨迹在Robotstudio中重现
- ASP.NET课程设计案例精编279451
- halcon联合C#实现图像实时采集使用Ba
- Unity in Action: Multiplatform Game Developmen
- 指针仪表识别halcon代码
- Pro WPF and Silverlight MVVM Effective Applica
- ASP.NET案例教程
- Halcon联合C#编写的检测二维码窗体程序
- C#网络应用高级编程PDF+案例源码+习题
- Visual C# 2010程序设计教程(教程PPT+源
- 图书管理系统 C# Visul studio.NET( 含源
评论
共有 条评论