【正文】
t work.Post the code in this forum.Does anyone help me?Answer 10When i try add an Opc group, i get te following error message:Opc Server add group failed with exception: Unable to cast object of type 39。 If you are an end user, you need to get the binaries from your OPC Vendor Version of the automation wrapper has been tested with on Win2000 and WinXP. wrapper so continue to ship the vendor branded version.interface dll. you will have to handle the offset yourself. A little bit of background on the Automation wrappers.ponents for mydevelop s COM dll.You just add the reference to to your project and use its classes.To pass an array to a OPC method, just dim the array to n+1 and fill it starting at index 1.The method will return object arrays that you will read starting at index 1. You have to cast to the specific types to get the values.Excuse me for my bad grammar.I hope this helps. Why do I even need ? :)... and while the C++ If I was using C++ I39。 It only accepts Arrays with lower bounds of 1 which is not possible in . (seere talking about ... Can I also butter you up and find out if you know anything about using an stability, you39。Foundation39。 If you39。.NET wrapper supplied by the OPC Foundation. 39。s just say I39。m curious as to what devices you are trying to access?give Have your checked out the59 Answers Foundt access the physical device and return the last data on memory. The OPC Server read and caches the value every each will be able to access on high speed if not need newest value.Sync Read OPCDevice, 16, ItemServerHandles, ItemValues, ItemServerErrors, ItemQualities, ItemTimeStampsFor i = 1 To 16 ItemValues(i) + : + ItemTimeStamps(i) + : + ItemQuality(i)Next i39。0xC039。 etc.) are constructed at the low hierarchy, and you can access the device datas as the unit of item or collection.ClassHierarchyThe OPC server and the client application municate each other through the interface of COM. The root class is OPC server object, and it accesses the group object and the item object by using this device datas of PLC (ex. 39。EndTry(OPC server disconnect failed: ExceptionNothing)IfByValButton2_Click(ByValEndIf(OPC server connect failed : NothingCatchGlobalOPCItems(2) = (, 2)GlobalOPCItems(1) = (, 1)GlobalOPCItems(0) = (, 0)Add items =Set property for Group connectionAsAsPrivate Connect to OPC server+ ,CatchNothingIfNext(ServerList(index))UBound(ServerList)AsAsGlobalOPCServer =TryByValForm1_Load(ByValAsAsAsClassEndTry+Closeexamp。MsgBox(Close0ServerValues,ServerValues(1)GlobalOPCItems(1).ServerHandleServerErrorsDimIntegerNothingAsAsPrivate關(guān)閉卡片EndCStr(.DefaultGroupUpdateRate)CStr(.DefaultGroupLocaleID)=.DefaultGroupIsActive=()IsNotPrivate刷新服務(wù)器狀態(tài)屬性信息EndTrueTrueElseFalseFalseThenIfTrueElse0FalseFalseTrueIsPrivate重設(shè)控件狀態(tài)OPCSample,failed:(OPCExceptionEndSucceed)amp。0ServerValues,=AsServerErrorsDim準備參數(shù)數(shù)組200(Is=Dim獲取塊號(ConnectedGroupesender39。SubOPCSample,failed:(OPCExceptionEndServerResults(1)amp。0ServerResults,39。GlobalOPCBlockItems(BlockNo).ServerHandleServerHandles(1)Dim39。IfCStr(BlockNo),=GlobalOPCBlockItems(BlockNo)Short39。TryThenNotByValbtnReadCard_Click(ByValEndIf,CardAs=ServerErrors(1)1,ServerResultEndServerErrors(1))MsgBox(OpenCardError:ThenIfServerErrors)39。1ServerHandles(1)AsServerHandles(1)IsNotesender39。Sub=,disconnectAsTry(ConnectedOPCServerHandlesByValbtnDisconnectServer_Click(ByVal39。EndElse=CStr(ItemValues(i))Case204=CStr(ItemValues(i))Case測試7張卡片CStr(ItemValues(i))CaseThenIf=ForAsAsAsAsAsAsPrivateEventArgs())HandlesOnServerShutDown(ByVal39。IfEnd+connect=exRefreshServerStatus()GlobalOPCItems(2)GlobalOPCItems(1)GlobalOPCItems(0)39。刷新慮,用于下面的DataChange事件3=0=()=HandlesByValbtnConnectServer_Click(ByVal39。Try,serversAs=ResetControlStatus()=(ServerList(index))ToAs=DimGlobalOPCServer),SubGlobalOPCBlockItems(64)AsConnectedGroupDimGlobalOPCServerClass:相關(guān)鏈接非常好的一個OPC技術(shù)網(wǎng)站OPC基金會網(wǎng)址國內(nèi)的一個比較好的OPC網(wǎng)站(八):全部源碼ImportsEndTry(OPC server disconnect failed: ExceptionNothing)Ifesender39。:斷開服務(wù)器斷開服務(wù)器只要使用OPCServer的Disconnect方法幾個,以下是代碼段:EndTryAsamp。39。ServerValues(1) = ServerHandles(1) = GlobalOPCBlockItems(BlockNo).ServerHandleIntegerAsServerValues(1)Is=Dim獲取塊號(ConnectedGroupesender39。EndOPCSample, )exMsgBox(Read Card Failed:ThenAsServerErrorsDim準備參數(shù)數(shù)組amp。GlobalOPCBlockItems(BlockNo)Short39。TryThenNotByValbtnReadCard_Click(ByValString)Server(服務(wù)器)關(guān)閉通知事件Public EventAsyncCancelComplete(ByValTimeStampsByRefQualitiesB