📄 vb,vc开发opc客户程序必读! - 倪森的胡言乱语 - csdnblog.htm
字号:
<LI class=listitem><A href="http://www.progame.org/"
target=_self>progame</A><A
href="http://blog.csdn.net/freeboy20sui/archive/2004/09/14/这个家伙可是非常厉害的哦.用VB简直成精了"
target=_blank>(RSS)</A></LI></UL>
<H3 class=listtitle>我参与的圈子</H3>
<UL class=list></UL>
<H3 class=listtitle>存档</H3>
<UL class=list>
<LI><A
href="http://blog.csdn.net/freeboy20sui/archive/2006/09.aspx">2006年09月(1)</A>
<LI><A
href="http://blog.csdn.net/freeboy20sui/archive/2006/05.aspx">2006年05月(5)</A>
<LI><A
href="http://blog.csdn.net/freeboy20sui/archive/2006/04.aspx">2006年04月(1)</A>
<LI><A
href="http://blog.csdn.net/freeboy20sui/archive/2006/01.aspx">2006年01月(2)</A>
<LI><A
href="http://blog.csdn.net/freeboy20sui/archive/2005/12.aspx">2005年12月(1)</A>
<LI><A
href="http://blog.csdn.net/freeboy20sui/archive/2005/09.aspx">2005年09月(1)</A>
<LI><A
href="http://blog.csdn.net/freeboy20sui/archive/2005/04.aspx">2005年04月(1)</A>
<LI><A
href="http://blog.csdn.net/freeboy20sui/archive/2004/11.aspx">2004年11月(1)</A>
<LI><A
href="http://blog.csdn.net/freeboy20sui/archive/2004/09.aspx">2004年09月(5)</A></LI></UL><SPAN
id=Anthem_RecentComments_ltlComments__><SPAN id=RecentComments_ltlComments>
<H3 class=listtitle>最近评论</H3>
<UL class=list>
<LI class=listitem>yzhiguo:<A title="点击查看《回复:OPC Server开发的几大境界》"
href="http://blog.csdn.net/freeboy20sui/archive/2004/09/15/105671.aspx#542604">http://blog.csdn.net/freeboy20sui/archive/2004/09/15/105671.aspx#542604</A>
<LI class=listitem>opc123:<A title=点击查看《回复:OPC工具和书籍》
href="http://blog.csdn.net/freeboy20sui/archive/2004/09/11/101187.aspx#517058">楼主,那三个文档我都下载不了,你能发一份给我吗?非常感激!
<BR>260616936@163.COM</A>
<LI class=listitem>opc123:<A title=点击查看《回复:OPC工具和书籍》
href="http://blog.csdn.net/freeboy20sui/archive/2004/09/11/101187.aspx#517055">楼主,那三个文档我都下载不了,你能发一份给我吗?非常感激!</A>
<LI class=listitem>摆渡人:<A title="点击查看《回复:开始翻译Jakarta Commons Cookbook。》"
href="http://blog.csdn.net/freeboy20sui/archive/2006/05/15/728899.aspx#504569">有没有翻译中文呢。没有的话偶就打算去买E文算了。</A>
<LI class=listitem>袁:<A title="点击查看《回复:开始翻译Jakarta Commons Cookbook。》"
href="http://blog.csdn.net/freeboy20sui/archive/2006/05/15/728899.aspx#486998">什么时候才可以有中文版的书</A></LI></UL></SPAN></SPAN><BR><BR></DIV>
<DIV id=main>
<DIV class=Tag>
<SCRIPT language=javascript
src="VB,VC开发OPC客户程序必读! - 倪森的胡言乱语 - CSDNBlog.files/urltag.aspx"></SCRIPT>
<DIV style="CLEAR: both"></DIV></DIV>
<SCRIPT>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</SCRIPT>
<DIV class=post>
<DIV class=postTitle><A
href="http://blog.csdn.net/freeboy20sui/articles/104073.aspx"><IMG height=13
src="VB,VC开发OPC客户程序必读! - 倪森的胡言乱语 - CSDNBlog.files/zhuan.gif" width=15
border=0> VB,VC开发OPC客户程序必读!</A> </DIV>
<DIV class=postText>
<TABLE cellSpacing=1 cellPadding=0 width=750 bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD colSpan=2 height=5></TD></TR>
<TR>
<TD background="VB,VC开发OPC客户程序必读! - 倪森的胡言乱语 - CSDNBlog.files/pic-2.htm"
colSpan=2 height=47>
<DIV align=center><SPAN class=big><FONT
color=#000000><B>VB,VC开发OPC客户程序必读!</B></FONT></SPAN><FONT
color=#ffffff><BR><FONT color=#000000>作者: <A title=查看用户详细信息、留言、加为好友、用户专集
href="http://www.gongkong.com/tech/userdetail.asp?username=szTaoyanbin"
target=_blank><FONT color=#00007f>szTaoyanbin</FONT></A> ,2004-2-8
10:12:00 发表于:《<A href="http://www.gongkong.com/tech/forum/list38.asp"
target=_blank><FONT color=#00007f>OPC论坛</FONT></A>》 共有40人回复,7055次点击
</FONT></FONT></DIV></TD></TR>
<TR>
<TD bgColor=#f7f7f7 colSpan=2 height=32>
<TABLE width="98%" align=center border=0>
<TBODY>
<TR>
<TD><SPAN class=text
style="LINE-HEIGHT: 25px"> 开发OPC客户程序必读!!!!!!!!!<BR> <BR> Step.1<BR> 如果程序要调用COM
库的某一个函数必须先登录COM
函数CoInitialize()可<BR> 以完成此功能从函数CoGetMalloc()可以得到一个指向COM
内存管理接口的指<BR> 针<BR> HRESULT
rl;<BR> rl=CoInitialize(NULL);<BR> rl=CoGetMalloc(MEMCTX_TASK,&g_pIMalloc);<BR> <BR> Step.2<BR> 每个COM
服务器有一个ProgID 通过它可以得到一个全球唯一的CLSID
用<BR> CLSIDFromProgID()函数可以实现这个变换ProgID 用变量szName
进行参数传<BR> 递在示例程序中它的值是L”OPC.SimaticNET”<BR> m_Popc<BR> rl=CLSIDFromProgID(szName,&clsid);<BR> <BR> <BR> Step.3<BR> CoCreateInstance()函数创建一个类实例其CLSID
值设定如下:<BR> r2=CocreateInstance(clsid,NULL,CLSCTX_LOCAL_SERVER,IID_IUnkown,<BR> (void**)&Punk);<BR> 这段程序的结果是一个指向服务器对象IUnknown
接口的指针变量pUNK<BR> <BR> Step.4<BR> 从IUnkown
接口通过QueryInterface()方法可以得到其它接口的指针<BR> HRESULT
r3;<BR> r3=pUNK->QueryInterface(IID_IOPCServer , (void
**)&m_Popc);<BR> 这段程序的结果是得到一个指向服务器对象IOPCServer
接口的指针(变量m_Popc)<BR> <BR> Step.5<BR> IOPCServer
接口的AddGroup()方法可以创建OPC 组<BR> m_pItemMgt)<BR> HRESULT
r1;<BR> r1=m_Popc->AddGroup(szName,TRUE,500,1,&TimeBias,<BR> &PercDeadband,dwLCID,&m_GrpServerHandle,<BR> &RevUpRate,IID_IOPCItemMgt,<BR> (LPUNKNOWN*)&m_pItemMgt);<BR> 这段程序的执行结果是创建一个有指定名称和属性的组在返回的参数中有一<BR> 个指向所需要的进程组对象接口的指针在这里是IOPCItemMgt(变量<BR> <BR> Step.6<BR> IOPCItemMgt
接口有AddItem()方法可以创建OPC 项<BR> HRESULT
r1;<BR> r1=m_pItemMgt->AddItems(NumItems,pItems,
&m_pItResult,&pErrors);<BR> 这段程序的结果是创建有特殊属性的指定数量的项除此之外事件结构变量<BR> m_pItResult
服务器句柄目标系统上的项数据类型等也被赋值<BR> <BR> 用于执行所需操作的指针需要通过现有的指向IOPCItemMgt
接口的指针得到如<BR> 如果用户要进行异步通信就需要指向IOPCAsyncIO 接口的指针<BR> HRESULT
rl;<BR> r1=m_pItemMgt->Queryface(IID_IOPCAsyncIO, (void * *)
& pAsyncIO);<BR> <BR> 通过该接口的Read()
和Write()两个方法可以读写项的数值<BR> r2=pAsyncIO->Read(m_dwConnection,OPC_DS_CACHE,dwNumItems,phServer,
&m_TransactionID,&pErrors);<BR> 这段程序的执行结果是OPC
项的数据被送到客户程序的IAdviseSink
接口<BR> <BR> Step.7<BR> 在程序停止运行之前必须删除已创建的OPC
对象并释放内存到目前为止用到<BR> 的各种接口都有相应的函数<BR> 5.4
r1=m_pItemMgt->RemoveItems(dwNumItems,phServer,&pErrors);<BR> r1=m_Popc->RemoveGroup(m_GrpServerHandle,TRUE);<BR> m_pItemMgt->Release();<BR> m_pOPC->Release();</SPAN></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD bgColor=#d6e6f6 colSpan=2 height=19>
<DIV align=center><FONT color=#ff0000><B
class=text>以下是对《VB,VC开发OPC客户程序必读!》的回复: </B></FONT></DIV></TD></TR>
<TR>
<TD class=text width=378 bgColor=#e7e7e7 height=19><IMG height=13
src="VB,VC开发OPC客户程序必读! - 倪森的胡言乱语 - CSDNBlog.files/edit.gif" width=18
border=0> <A title=查看用户详细信息、留言、加为好友、用户专集
href="http://www.gongkong.com/tech/userdetail.asp?username=szTaoyanbin"
target=_blank><FONT color=#00007f>SZTAOYANBIN</FONT></A>: </TD>
<TD class=text width=372 bgColor=#e7e7e7 height=19>
<DIV align=right> 2003-12-30 13:47:00</DIV></TD></TR>
<TR>
<TD class=text bgColor=#f7f7f7 colSpan=2>
<TABLE width="98%" align=center border=0>
<TBODY>
<TR>
<TD class=text style="LINE-HEIGHT: 25px"> 可叹!!!!!!!<BR> VB
DEMO!!!!!<BR> <BR> STEP_1:Init Server!!<BR> Set
Svr=CreateObject(ProgID$)<BR> <BR> STEP_2:AddGroup!!<BR> Set
Group=Svr.AddGroup "szTaoYanBinGRP" false
RateRequested,GroupClientHdl, PercentDeadband,
dwLangId_ENGLISH,GroupServerHdl, RateRevised<BR> Set PtrItemMgt
=Group<BR> <BR> STEP_3:AddItems!!!<BR> ItemsActive(0)= True:
ItemsActive(1)= True <BR> PtrItemMgt.AddItems NbrItems,
ItemsIDs,ItemsActivity, ItemsClientHdls,ItemsSvrHdls, ItemsErrors,
ItemsObjects, accessPath<BR> <BR> STEP_4:Read&Write
Items!!!!<BR> Set ptrSyncIO = group <BR> WHILE (true) <BR>
PtrSyncIO.OPCRead OPC_DS_DEVICE, NbrItems, ItemsSvrHdls,pValues,
pQualities, pTimeStamps, ItemsErrors<BR> WEND<BR> <BR> STEP_5:
Free Group&Items!!!!!!<BR> Svr.RemoveGroup GroupServerHdl,
False <BR> Set Group = Nothing <BR> Set Svr = NothingS<BR>
OK!!!!!!<BR> 如果你认为本贴有价值,请推荐为精华!!!!!!<BR>
THANKS!!!!!!!!!!!!!!!!!!!! </TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD class=text width=378 bgColor=#e7e7e7 height=19><IMG height=13
src="VB,VC开发OPC客户程序必读! - 倪森的胡言乱语 - CSDNBlog.files/edit.gif" width=18
border=0> <A title=查看用户详细信息、留言、加为好友、用户专集
href="http://www.gongkong.com/tech/userdetail.asp?username=szTaoyanbin"
target=_blank><FONT color=#00007f>SZTAOYANBIN</FONT></A>: </TD>
<TD class=text width=372 bgColor=#e7e7e7 height=19>
<DIV align=right> 2003-12-30 15:02:00</DIV></TD></TR>
<TR>
<TD class=text bgColor=#f7f7f7 colSpan=2>
<TABLE width="98%" align=center border=0>
<TBODY>
<TR>
<TD class=text style="LINE-HEIGHT: 25px"> OPC HTML DEMO<BR>
szTaoyanbin注,把OPC
SEVER作为JAVA小程序的插件,加入HEML中,OBJECT的标记名称定义为GRP1则可!!!!!<BR> <BR> <Script
Language="VBScript"><!--<BR> <BR> Dim Item1<BR> Dim
Server<BR> Dim fValue<BR> <BR> Dim ItemValue<BR> <BR> Sub
Window_OnLoad()<BR> Server = "szTaoYanBin_Group"<BR> GRP1.Init
Server, ""<BR> GRP1.AddItem "", Item1<BR> GRP1.Read<BR> fValue
= GRP1.GetValue(Item1)<BR> GRP1.Start 500<BR> End
Sub<BR> <BR> Sub Window_OnUnload()<BR> GRP1.Stop<BR> End
Sub<BR> <BR> Sub GRP1_OnGroupChange()<BR> fValue =
GRP1.GetValue(Item1)<BR> End
Sub<BR> <BR> --></Script><BR> 如果有一天,你用网页作为组态软件,而是由本人启迪的话,别望了说声THANKS!!!<BR>
szTaoyanbin@163.com</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR>
<P id=TBPingURL>Trackback:
http://tb.blog.csdn.net/TrackBack.aspx?PostId=104073</P><BR></DIV>
<DIV class=postFoot>
<SCRIPT src=""></SCRIPT>
[<A title=功能强大的网络收藏夹,一秒钟操作就可以轻松实现保存带来的价值、分享带来的快乐
href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(saveit=window.open('http://wz.csdn.net/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=590,height=300,left=75,top=20,status=no,resizable=yes'));saveit.focus();">收藏到我的网摘</A>]
freeboy发表于 2004年09月14日 14:04:00 </DIV></DIV><LINK
href="http://blog.csdn.net/freeboy20sui/Services/Pingback.aspx" rel=pingback><!--<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:dc="http://purl.org/dc/elements/1.1/"xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"><rdf:Descriptionrdf:about="http://blog.csdn.net/freeboy20sui/articles/104073.aspx"dc:identifier="http://blog.csdn.net/freeboy20sui/articles/104073.aspx"dc:title="VB,VC开发OPC客户程序必读!"trackback:ping="http://tb.blog.csdn.net/TrackBack.aspx?PostId=104073" /></rdf:RDF>-->
<SCRIPT>function hide(){showComment();}</SCRIPT>
<BR>
<DIV class=post>
<DIV class=postTitle>相关文章:</DIV>
<UL class=postText>
<LI><A href="http://blog.csdn.net/sijigang/archive/2005/01/06/242183.aspx"
target=_blank>关于OPC(Ole for process control)服务器开发需要的知识</A> 2005-01-06 <A
href="http://blog.csdn.net/sijigang/" target=_blank>sijigang</A>
<LI><A href="http://blog.csdn.net/cl007/archive/2001/07/06/10456.aspx"
target=_blank>IUnknown接口</A> 2001-07-06 <A href="http://blog.csdn.net/cl007/"
target=_blank>cl007</A>
<LI><A href="http://blog.csdn.net/hotyoung/archive/2004/03/11/7021.aspx"
target=_blank>如何开发OPC Server</A> 2004-03-11 <A
href="http://blog.csdn.net/hotyoung/" target=_blank>hotyoung</A>
<LI><A href="http://blog.csdn.net/linuszhu/archive/2004/07/09/38199.aspx"
target=_blank>《COM 原理与应用》学习笔记</A> 2004-07-09 <A
href="http://blog.csdn.net/linuszhu/" target=_blank>linuszhu</A>
<LI><A
href="http://blog.csdn.net/qianjintianguo/archive/2006/04/20/670718.aspx"
target=_blank>语音编程之Speech SDK概述(2)</A> 2006-04-20 <A
href="http://blog.csdn.net/qianjintianguo/"
target=_blank>qianjintianguo</A></LI></UL></DIV><BR><BR>
<DIV class=post id=csdn_zhaig_ad_yahoo></DIV><SPAN
id=Anthem_Comments.ascx_ltlComments__><SPAN id=Comments.ascx_ltlComments><BR>
<DIV id=comments>
<H3></H3>
<DIV class=post>
<DIV class=postTitle><A title="permalink: 回复:VB,VC开发OPC客户程序必读!"
href="http://blog.csdn.net/freeboy20sui/articles/104073.aspx#283010">#</A> <A
name=283010> </A>逃 发表于2004-09-16 12:35:00 IP:
218.61.49.*</DIV>
<DIV class=postText>归纳得不错,但有点过于简单了!对OPC入门较好!</DIV></DIV><BR>
<DIV class=post>
<DIV class=postTitle><A title="permalink: 回复:VB,VC开发OPC客户程序必读!"
href="http://blog.csdn.net/freeboy20sui/articles/104073.aspx#283042">#</A> <A
name=283042> </A><A href="http://blog.csdn.net/freeboy20sui" target=_blank
rel=nofollow>freeboy</A> 发表于2004-09-16 12:41:00 IP:
218.11.8.*</DIV>
<DIV class=postText>从工控OPC论坛转过来的,不是原创特此声明^_^</DIV></DIV><BR>
<DIV class=post>
<DIV class=postTitle><A title="permalink: 回复:VB,VC开发OPC客户程序必读!"
href="http://blog.csdn.net/freeboy20sui/articles/104073.aspx#284253">#</A> <A
name=284253> </A>深山野人 发表于2004-09-18 09:47:00 IP:
202.119.24.*</DIV>
<DIV class=postText>IOPCAsyncIO接口还是OPCDA
1.0规范的接口,2.0规范用的是IOPCAsyncIO2接口,3.0规范中IOPCAsyncIO接口已经不用了,增加了IOPCAsyncIO3接口。</DIV></DIV><BR>
<DIV class=post>
<DIV class=postTitle><A title="permalink: 回复:VB,VC开发OPC客户程序必读!"
href="http://blog.csdn.net/freeboy20sui/articles/104073.aspx#322652">#</A> <A
name=322652> </A>扬风飞雪 发表于2004-12-11 15:17:00 IP:
219.232.57.*</DIV>
<DIV class=postText>看了感觉很有收获。谢谢楼主了
<BR>我现在也是在学习OPC,一头雾水,不知从何做起</DIV></DIV><BR></DIV></SPAN></SPAN>
<SCRIPT language=javascript>
ad_width=468;
ad_height=60;
adcss=2;
unionuser=19;
ad_type='j';
count=5;
</SCRIPT>
<SCRIPT language=javascript
src="VB,VC开发OPC客户程序必读! - 倪森的胡言乱语 - CSDNBlog.files/showads.js"
type=text/javascript></SCRIPT>
<SCRIPT language=javascript
src="VB,VC开发OPC客户程序必读! - 倪森的胡言乱语 - CSDNBlog.files/showgm.js"
type=text/javascript></SCRIPT>
<SCRIPT type=text/javascript>document.write("<img src=http://counter.csdn.net/pv.aspx?id=24 border=0 width=0 height=0>");</SCRIPT>
<DIV class=CommentForm id=commentform>
<H3>发表评论</H3>
<DIV id=Anthem_PostComment.ascx_UpdatePanel1__>
<DIV id=PostComment.ascx_UpdatePanel1>
<TABLE class=CommentForm>
<TBODY>
<TR>
<TD width=69 height=0></TD>
<TD></TD></TR>
<TR>
<TD width=70>大名:</TD>
<TD align=left><INPUT id=PostComment.ascx_tbName style="WIDTH: 300px"
disabled maxLength=32 size=40 name=PostComment.ascx:tbName> <SPAN
id=PostComment.ascx_RequiredFieldValidator2
style="DISPLAY: none; COLOR: red" initialvalue=""
evaluationfunction="RequiredFieldValidatorEvaluateIsValid"
display="Dynamic" errormessage="<br>请输入尊姓大名"
controltovalidate="PostComment.ascx_tbName"><BR>请输入尊姓大名</SPAN> </TD></TR>
<TR>
<TD width=70>网址:</TD>
<TD align=left><INPUT id=PostComment.ascx_tbUrl style="WIDTH: 300px"
disabled maxLength=256 size=40 name=PostComment.ascx:tbUrl> </TD></TR>
<TR>
<TD colSpan=3>评论 <SPAN id=PostComment.ascx_RequiredFieldValidator3
style="DISPLAY: none; COLOR: red" initialvalue=""
evaluationfunction="RequiredFieldValidatorEvaluateIsValid"
display="Dynamic" errormessage="<br>请输入评论"
controltovalidate="PostComment.ascx_tbComment"><BR>请输入评论</SPAN> <BR><TEXTAREA id=PostComment.ascx_tbComment style="WIDTH: 381px; HEIGHT: 193px" disabled name=PostComment.ascx:tbComment rows=10 cols=50></TEXTAREA>
</TD></TR>
<TR>
<TD colSpan=3><SPAN
id=Anthem_PostComment.ascx_btnSubmit__></SPAN> </TD></TR>
<TR>
<TD colSpan=3><SPAN id=PostComment.ascx_Message
style="COLOR: red">注册用户才能发表评论。如果你没有登录,请点击<A
href="http://passport.csdn.net/member/UserLogin.aspx?from=http://blog.csdn.net/freeboy20sui/archive/2004/09/14/104073.aspx">登录</A></SPAN>
</TD></TR></TBODY></TABLE></DIV></DIV></DIV></DIV>
<P id=footer>Powered by: <BR><A id=Footer1_Hyperlink2
href="http://scottwater.com/blog" name=Hyperlink1><IMG
src="VB,VC开发OPC客户程序必读! - 倪森的胡言乱语 - CSDNBlog.files/100x30_Logo.gif" border=0></A>
<A id=Footer1_Hyperlink3 href="http://asp.net/" name=Hyperlink1><IMG
src="VB,VC开发OPC客户程序必读! - 倪森的胡言乱语 - CSDNBlog.files/PoweredByAsp.Net.gif"
border=0></A> <BR>Copyright © 倪森 </P>
<SCRIPT src="VB,VC开发OPC客户程序必读! - 倪森的胡言乱语 - CSDNBlog.files/counter.js"></SCRIPT>
<SCRIPT type=text/javascript>
<!--
var Page_Validators = new Array(document.getElementById("PostComment.ascx_RequiredFieldValidator2"), document.getElementById("PostComment.ascx_RequiredFieldValidator3"));
// -->
</SCRIPT>
<INPUT id=__EVENTVALIDATION type=hidden
value=/wEWBAL+raDpAgKqtOi0AwLAsuLbDAKi687YCaEdUuRgIvhS8PYPDsd5LslVNRL0
name=__EVENTVALIDATION>
<SCRIPT type=text/javascript>
<!--
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
ValidatorOnLoad();
}
function ValidatorOnSubmit() {
if (Page_ValidationActive) {
return ValidatorCommonOnSubmit();
}
else {
return true;
}
}
// -->
</SCRIPT>
</FORM>
<SCRIPT language=javascript type=text/javascript>
<!--
try{
hide();
}
catch(e){
}
//-->
</SCRIPT>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -