资源简介
C#写的与PLC通过TCP/IP协议通信的实例,代码供参考
代码片段和文件信息
using OPC;
using OPCDA;
using OPCDA.NET;
using System;
using System.Collections.Generic;
using System.Text;
using Interface;
using System.IO.Ports;
using System.Threading;
using System.Windows.Forms;
using CommonLibrary;
using System.IO;
using General;
using System.Net.Sockets;
using System.Net;
delegate void AddMessage(string sNewMessage);
namespace HostMainApp
{
public class PLCControl : ILog IWafterControl
{
private Socket plc_sender = null;
// private event AddMessage m_AddMessage;
private PLCCommu plcCommu = PLCCommu.Instance;
//private System.IO.Ports.SerialPort plcSerialPort;
private readonly object SendLockObj = new object();
private readonly object waferIDObj = new object();
private DefectType plsNotReadyType = DefectType.Hole2;
private bool unloadTimeout = false;
private bool isCheckWaferEnd = true;
private bool isCheckUIRunEnd = true;
private bool isClickStop = false; //N0.39
private int typeA1Count = 0;
private int typeB1Count = 0;
private int typeC1Count = 0;
private int typeA2Count = 0;
private int typeB2Count = 0;
private int typeC2Count = 0;
private int curIdleTime = 20;//N0.36
//N0.00 private int typeDCount = 0;
private int waferID = 1;
private int curWaferCount = -300;
private string reginfo = ““;
private System.Timers.Timer timerWafer = new System.Timers.Timer();
private System.Timers.Timer timerUIRun = new System.Timers.Timer();
private float curExposureTime = 0.7F;
private static PLCControl instance = null;
private static readonly object plcLock = new object();
public static PLCControl Instance
{
get
{
lock (plcLock)
{
if (instance == null)
{
instance = new PLCControl();
}
return instance;
}
}
}
private PLCControl()
{
if (plcConnect())
{
SystemLogger.Write(LogType.Debug “PLC连接成功!“ “Stage.InitThread“);
}
else
{
SystemLogger.Write(LogType.Debug “PLC连接失败!“ “Stage.InitThread“);
}
}
private bool plcConnect()
{
bool connectResult = true;
try
{
if (plc_sender != null && plc_sender.Connected)
{
plc_sender.Shutdown(SocketShutdown.Both);
System.Threading.Thread.Sleep(100);
plc_sender.Close();
}
plc_sender = new Socket(AddressFamily.InterNetwork SocketType.Stream Protoco
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2010-12-02 17:18 PlcConn_Tcp\
目录 0 2010-12-17 16:44 PlcConn_Tcp\PlcConn_Tcp\
文件 923 2010-11-29 08:10 PlcConn_Tcp\PlcConn_Tcp.sln
文件 20992 2010-12-17 16:45 PlcConn_Tcp\PlcConn_Tcp.suo
目录 0 2010-12-02 17:18 PlcConn_Tcp\PlcConn_Tcp\bin\
目录 0 2010-12-02 17:18 PlcConn_Tcp\PlcConn_Tcp\bin\Debug\
文件 32256 2010-12-03 10:05 PlcConn_Tcp\PlcConn_Tcp\bin\Debug\PlcConn_Tcp.exe
文件 36352 2010-12-03 10:05 PlcConn_Tcp\PlcConn_Tcp\bin\Debug\PlcConn_Tcp.pdb
文件 14328 2010-12-17 16:41 PlcConn_Tcp\PlcConn_Tcp\bin\Debug\PlcConn_Tcp.vshost.exe
文件 490 2007-07-21 01:33 PlcConn_Tcp\PlcConn_Tcp\bin\Debug\PlcConn_Tcp.vshost.exe.manifest
目录 0 2010-12-02 17:18 PlcConn_Tcp\PlcConn_Tcp\obj\
目录 0 2010-12-03 09:56 PlcConn_Tcp\PlcConn_Tcp\obj\Debug\
文件 688 2010-12-17 16:41 PlcConn_Tcp\PlcConn_Tcp\obj\Debug\PlcConn_Tcp.csproj.FileListAbsolute.txt
文件 913 2010-12-01 13:53 PlcConn_Tcp\PlcConn_Tcp\obj\Debug\PlcConn_Tcp.csproj.GenerateResource.Cache
文件 32256 2010-12-03 10:05 PlcConn_Tcp\PlcConn_Tcp\obj\Debug\PlcConn_Tcp.exe
文件 36352 2010-12-03 10:05 PlcConn_Tcp\PlcConn_Tcp\obj\Debug\PlcConn_Tcp.pdb
文件 180 2010-11-30 13:18 PlcConn_Tcp\PlcConn_Tcp\obj\Debug\PlcConn_Tcp.Properties.Resources.resources
文件 180 2010-12-01 13:53 PlcConn_Tcp\PlcConn_Tcp\obj\Debug\PlcConn_Tcp.Test_PLC_Conn.resources
目录 0 2010-12-02 17:18 PlcConn_Tcp\PlcConn_Tcp\obj\Debug\Refactor\
目录 0 2010-12-02 17:18 PlcConn_Tcp\PlcConn_Tcp\obj\Debug\TempPE\
文件 36729 2010-12-01 16:59 PlcConn_Tcp\PlcConn_Tcp\PLCCommu.cs
文件 3847 2010-11-30 13:18 PlcConn_Tcp\PlcConn_Tcp\PlcConn_Tcp.csproj
文件 511 2010-11-29 13:09 PlcConn_Tcp\PlcConn_Tcp\Program.cs
目录 0 2010-12-02 17:18 PlcConn_Tcp\PlcConn_Tcp\Properties\
文件 1442 2010-11-29 08:10 PlcConn_Tcp\PlcConn_Tcp\Properties\AssemblyInfo.cs
文件 2851 2010-11-29 08:10 PlcConn_Tcp\PlcConn_Tcp\Properties\Resources.Designer.cs
文件 5612 2010-11-29 08:10 PlcConn_Tcp\PlcConn_Tcp\Properties\Resources.resx
文件 1096 2010-11-29 08:10 PlcConn_Tcp\PlcConn_Tcp\Properties\Settings.Designer.cs
文件 249 2010-11-29 08:10 PlcConn_Tcp\PlcConn_Tcp\Properties\Settings.settings
文件 9643 2010-12-17 16:44 PlcConn_Tcp\PlcConn_Tcp\Test_PLC_Conn.cs
文件 7449 2010-12-01 13:53 PlcConn_Tcp\PlcConn_Tcp\Test_PLC_Conn.Designer.cs
............此处省略2个文件信息
相关资源
- C#ip地址查看器
- C#写的地理信息系统初级代码
- 基于C#的多线程的网页抓取
- 生产者消费者为模型的多线程编程c
- 模拟进程调度C#版基于时间片的轮转调
- C# 提取文章关键词
- C#科学高级计算机源码
- c# vs2010 小游戏之五子棋
- C#数字图像处理3种典型方法:提取像
- c# winForm Ip地址输入控件反馈修改
- C#操作Mysql创建数据库,数据表,增、
- C#超市管理系统代码及窗体
- C# 基于三层架构开发的物流信息管理
- 9种预测、处理算法实现源代码c#
- 基于C#的网络五子棋对战
- C#网络版斗地主
- c# 同步网上聊天程序代码服务器+客户
- C#图像处理源代码包括包括均值滤波,
- 标准正态分布---由概率计算分位数C
- C# 用VScrollBar控制webbrowser的滚动条 简
- WPF查看Word文档应用程序源码C#源码
- C#根据字符串生成二维码并显示
- C# ,WinForm 多人聊天
- 人脸识别C#源码
- C# 实现画图软件
- C# 局域网聊天 无需服务器 自动搜索
- 用C#写成的网上订票系统
- C#加密(DES)
- DataGridView列标头带数据筛选功能(含
- c#自动录音
评论
共有 条评论