91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 257KB
    文件類型: .zip
    金幣: 2
    下載: 2 次
    發(fā)布日期: 2021-06-17
  • 語言: C#
  • 標(biāo)簽: C#??OPC??automation??

資源簡介

c#編寫的 OPC 客戶端 讀取程序,將讀取值存入SQLserver。

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Net;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?OPC_Client.Methods;//添加引用
using?OPCAutomation;


namespace?OPC_Client
{
????public?partial?class?Frm_Main?:?Form
????{
????????public?Frm_Main()
????????{
????????????InitializeComponent();
????????}

????????#region?聲明變量與定義
????????DataTable?dt?=?new?DataTable();
????????IpRead?ipread?=?new?IpRead();//IP?操作類
????????SqlHelper?sqlhp?=?new?SqlHelper();//數(shù)據(jù)庫操作
????????string?LocalIP?=?““;//IP地址
????????OPCServer?KepServer;
????????OPCGroups?KepGroups;
????????OPCGroup?KepGroup;
????????OPCItems?KepItems;
????????OPCItem?KepItem;
????????int?itmHandleClient?=?0;//客戶端句柄
????????int?itmHandleServer?=?0;//服務(wù)端句柄
????????bool?opc_connected?=?false;//opc連接狀態(tài)
????????#endregion

????????private?void?Frm_Main_Load(object?sender?EventArgs?e)
????????{
????????????LocalIP?=?txt_LocalIP.Text?=?ipread.RetrunIP();//獲取本機(jī)IP地址
????????????GetLocalServer();//枚舉本地OPC服務(wù)器
????????????dt.Columns.Add(“標(biāo)簽“?System.Type.GetType(“System.String“));
????????????dt.Columns.Add(“測量值“?System.Type.GetType(“System.String“));
????????????dt.Columns.Add(“質(zhì)量“?System.Type.GetType(“System.String“));
????????????dt.Columns.Add(“時間戳“?System.Type.GetType(“System.String“));
????????????dgv_dataShow.DataSource?=?dt;
????????}

????????private?void?GetLocalServer()
????????{
????????????//檢查IP地址是否合法
????????????if?(System.Text.Regularexpressions.Regex.IsMatch(LocalIP?“[0-9]{13}\\.[0-9]{13}\\.[0-9]{13}\\.[0-9]{13}“))
????????????{
????????????????string?CoputerName?=?Dns.GetHostByAddress(LocalIP).HostName.ToString();
????????????????try
????????????????{
????????????????????KepServer?=?new?OPCServer();
????????????????????object?serverList?=?KepServer.GetOPCServers(CoputerName);
????????????????????foreach?(string?turn?in?(Array)serverList)
????????????????????{
????????????????????????cmb_OpcServer.Items.Add(turn);
????????????????????}
????????????????????cmb_OpcServer.SelectedIndex?=?0;
????????????????????Btn_ServerConnect.Enabled?=?true;
????????????????}
????????????????catch?(Exception?err)
????????????????{
????????????????????MessageBox.Show(“枚舉本地OPC服務(wù)器出錯:“?+?err.Message?“提示信息“?MessageBoxButtons.OK?MessageBoxIcon.Warning);
????????????????}
????????????}
????????????else?{?MessageBox.Show(“IP地址不合法,請檢查!!!“?“友情提示“);?}
????????}

????????///?
????????///?【按鈕】連接服務(wù)器
????????///?

????????///?
????????///?
????????private?void?Btn_ServerConnect_Click(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????KepServer.Connect(cmb_OpcServer.Text?txt_LocalIP.Text);
????????????????if?(KepServer.ServerState?==?(int)OPCServerState.OPCRunning)
????????????????{
???????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????3021??2016-07-25?10:58??51Aspx源碼必讀.txt
?????文件?????????187??2016-07-20?09:01??App.config
?????目錄???????????0??2016-07-25?10:51??DB_51aspx\
?????文件?????3145728??2016-07-25?10:58??DB_51aspx\OPC_Test.mdf
?????文件?????1048576??2016-07-25?10:58??DB_51aspx\OPC_Test_log.ldf
?????文件???????22960??2016-07-20?14:49??Frm_Main.Designer.cs
?????文件???????11138??2016-07-20?14:51??Frm_Main.cs
?????文件???????12549??2016-07-20?14:49??Frm_Main.resx
?????目錄???????????0??2016-07-25?10:51??Methods\
?????文件????????1031??2016-07-20?09:16??Methods\IpRead.cs
?????文件????????2051??2016-07-25?10:54??Methods\SqlHelper.cs
?????文件????????4288??2016-07-20?14:21??OPC?Client.csproj
?????文件?????????909??2016-07-25?10:53??OPC?Client.sln
?????文件???????26112??2016-07-25?10:53??OPC?Client.v11.suo
?????文件?????????525??2016-07-20?09:01??Program.cs
?????目錄???????????0??2016-07-25?10:51??Properties\
?????文件????????1352??2016-07-20?09:00??Properties\AssemblyInfo.cs
?????文件????????2872??2016-07-20?09:00??Properties\Resources.Designer.cs
?????文件????????5612??2016-07-20?09:00??Properties\Resources.resx
?????文件????????1097??2016-07-20?09:00??Properties\Settings.Designer.cs
?????文件?????????249??2016-07-20?09:00??Properties\Settings.settings
?????目錄???????????0??2016-07-25?10:51??bin\
?????目錄???????????0??2016-07-25?10:54??bin\Debug\
?????文件???????40960??2009-01-08?16:11??bin\Debug\Interop.OPCAutomation.dll
?????文件???????33792??2016-07-25?10:54??bin\Debug\OPC?Client.exe
?????文件?????????187??2016-07-20?09:01??bin\Debug\OPC?Client.exe.config
?????文件???????38400??2016-07-25?10:54??bin\Debug\OPC?Client.pdb
?????文件???????22984??2016-07-25?10:56??bin\Debug\OPC?Client.vshost.exe
?????文件?????????187??2016-07-20?09:01??bin\Debug\OPC?Client.vshost.exe.config
?????文件?????????490??2012-06-02?22:34??bin\Debug\OPC?Client.vshost.exe.manifest
?????目錄???????????0??2016-07-25?10:58??bin\Release\
............此處省略16個文件信息

評論

共有 條評論