基于opc协议的数据通讯

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

OPCOPCOPCOLEforProecssControlOPCOPCCOMComponentObjectModoleCOMCOMOPCTear-offOPCOPCOPCOPCOPCCOMTear-offBASEONTHESPECEFICATIONOFOPCDATAACCESSABSTRACTOPCissuchastandardthatweneed.OPCmeansOLE(ObjectLinkingandEmbedding)forProgressControl.OPCwasputforwardinsolvingcommunicationbetweenapplicationsoftwareandvarydriversofdevices.Itmakestheworkmoreefficient.Consequently,therepeatedexploitationsarereducedintheintegratedsystem.OPCspecificationwillbeadevelopmentalaspectaboutprocessautomation’scommunicationnormalforfuture.InthemasterstudentprojecttheComponentObjectModelasOPCnuttechnologyanditsapplicationsdetailabouttherealizeissuanceandestablishmethodofCOMcomponent.TheusesofconnectionpointertechnologyandTear-offtechnology,theprogramforOPCinterfacewasaccomplished.AccordingtotheOPCDataAccessSpecification,theOPCofDataAccesswiththebasicfunctionhasbeendeveloped,whichcancommunicatewithOPCClientofthethirdparty.Thisservercancompletesyncread,asyncreadorasyncsubscription,andsyncwriteorasyncwrite.KEYWORDS:opc,com,interface,connectionpointtechnology,Tear-offtechnologyi11.1OPC11.1.111.1.2OPC21.1.3OPC31.1.4OPC31.241.2.141.2.251.2.351.2.46COM72.1COMOPC72.2COM72.3COM92.3.1102.3.2112.3.3QueryInterface()152.3.4162.4COM172.4.1BSTR172.4.2182.519OPC223.1OPC223.2OPC23ii3.2.1233.2.2233.2.3243.2.4243.2.5OPCHANDLE243.3OPC253.426OPC274.1OPC294.1.1OPC294.1.2OPC304.2334.2.1334.2.2334.2.3344.3354.4374.4.1IOPCSyncIO374.4.2IOPCAsyncIO384.4.3IOPCAsyncIO2384.4.4IDataObject394.4.5IOPCDataCallback39OPC425.1425.2425.3425.4435.5OPC455.5.1OPCServer45iii5.5.2ISimuOPCServer465.5.3OPCGroup465.5.4OPCItem475.5.5ISimuOPCItemMgt485.5.6ISimuOPCSyncIO485.5.7ISimuOPCAsyncIO2485.5.8ISimuOPCGroupStateMgt485.6485.6.1485.6.2525.6.3535.6.4555.6.5585.7605.7.1Proxy/StubDLL605.7.2605.7.3615.8OPC626466698787111OPC111DCSSCADA2OPCOLEforProcessControlOLEOPCServerOPCOPC112OPCOPCOPCOPCOPC[1]OPCCOMMicrosoftDCOMOPC[2][3]OPC[4][5][6]11OPC3OPC[7]OPCISA88[8]113OPCOPC(OPCFoundation)OPC,OPCOLE/COM/DCOM[9]19968OPCTaskForce(OPCFoundation)OPC1.019972MicrosoftWindows95DCOM19979OPCFoundationOPCOPC1.0A1.0A(DataAccessStandard)OPC1998OPC2.01.01998121.01999121.0119981.0200011.0101.0(extensiblemarkuplanguageXML)OPCXMLOPCInternetOPC114OPCOPC4CEOPC.NETOPCXMLOPCOPCOPCOPCOPC[10]DCS[11][12]OPCOPC12121OPCOPC5OPCOPCOPC122OPCOPCOPCCOMCOMOPCServerOPCGroupOPCItemOPC2.0COMOPCOPCOPC123DCSOPCOPC6124OPCCOMOPCOPCOPCOPCCOMCOMCOMOPCOPCOPCOPCOPCOPCOPCOPC7COMCOMComponentObjectModel()OPC/OPCCOMCOMCOM21COMOPCOPCOLEOLEOLEDDEDDEDDEDDEOLE1.0OLE2.0LRPCDDEUDTmonikerCOMOLE2.0COM’OPCOLE2.0OPC[13]22COMCOM(component)COMCOMCOMCOMVCVBjavaDelph8[14](Interface)(virtualfunctiontable)vtableVTBLvtablevtablevtablevtablevtableIIDID[14]21GUID(GloballyUniqueIndentifier,)COM(DEC)128WindowsGUIDGENGUIDIIDCLSIDLIBIDGUID[14]HRESULTHRESULT(AddRefRelease)HRESULT32&m_pServer-AddGroupPwpSimuOPC.dllIOPCServerIOPCServerOPCServer(vtable)IUnknown9COMRPCCOMHRESULTCOM31SSERVERITY_SUCCESS(0)SERVERITY_ERROR(1)SUCCEEDED()FAILED()HRESULTFacility3027Facility()16CodeFACILITY_ITFHRESULTFacility_Serverity_ReasonIUnknownCOMIUnknownCOMIUnknown[15]InterfaceIUnknown{HRESULTQueryInterface(REFIIDiid,void**ppvobject);ULONGAddRef();ULONGRelease();};23COMSRC31302916150FaclityCode22HRESULT10COMDllGetClassObject()CLSIDDLLIClassFactoryCOMCOMIClassFactory[16]CreateInstance•LockServer231OPCCOMOPCCOM23NewCOPCServerNewCOPCFactoryDllGetClassObjectCoGetClassObjectOPCCOMDLLOPCCoCreateInstanceIClassFactory::CreateInstanceIIDI_OPCServerIClassFactory::Realease()PI_OPCServerFx()11COMCOMCOMCLSIDIIDCOMCOMCOMCoInitializaEx(NULL,COINIT_MULITITHREADED)CoInitializa(NULL)COMCOMCoCreateInstanceCoCreateInstanceCoGetClassObjectCoGetClassObjectOPCDLL(DLLLockServer())DLLDllGetClassObjectNewDllGetClassObjectIClassFactoryCoCreateInstanceCoCreateInstanceIClassFactoryCreateInstanceCOMI_OPCServerCoCreateInstanceI_OPCServerCOMOPCServer232COMCOMCOMDLLEXEDLLDLLCOMDLLOPCDLLEXE12/COMOLEOLEApartmentModelThreading”()OPCCOMSTAsinglethreadedapartmentCOMCOMCOMCOMDllGetClassObjectDllCanUnloadNowCOM()COMCOMAPICoMarshalInterThreadInterfaceInStream13CoGetInterfaceAndReleaseStreamCoMarshalInterThreadInterfaceInStreamCoMarshalInterfaceCoMarshalInterfaceCoMarshalInterThreadInterfaceInStreamAPIHRESULTCoMarshalInterThreadInterfaceInStream(REFIIDriid,IUnknown*pUnk,IStream**ppStm);IIDIStream24ObjectSTA1STA2CoMarshalInterThreadInterfaceInStreamIStreamCoGetInterfaceAndReleaseStreamProxyAB14STA1STASTA1CoMarshalInterThreadInterfaceInStreamIIDIStreamSTA2STA2IStreamCoGetInterfaceAndReleaseStreamSTA2STA2STA1STA2[17]COMCOMWindows(COM)DLLDLLDllGetClassObjectDllCanUnloadNowDllGetClassObjectCOM[18]15BothOPCNT7APIWaitForSingleObject()WaitFor-MultipleObjects()WaitForSingleObject()WaitForMultipleObjects()[17]()233QueryInterface()COMQueryInterface()QueryInterface()[19]COMQueryInterface()16IUnknown*pServerIUnk=0;HRESULThr=pOPCServer-QueryInterface(IID_IUnknown,(void**)&pServerIUnk);234COMCOMAddRef()Release()InterlockedIncrement()InterlockedDecrement()APICOMAddRef()Release()COMAddRef()Release()AddRef()Release()AddRef()Release()17C

1 / 93
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功