zoukankan      html  css  js  c++  java
  • 生成OSIDAAuto.OPCServer失败

    来源:https://pisquare.osisoft.com/message/13441

    A failuare of generating OSIDAAuto.OPCServer

    dorisliperHydrogen

    Dear Sir/Madam

     

    We'd like to use OSIDAAuto.OPCServer, but an exception occurs as follows when we generate OSIDAAuto.OPCServer. "error message:the following error occurred:80040154 when obtaining the COM class factory of component including CLSID{25E4451E-DA6A...}" We think that registering COM componet is done well, because the same key exists in the registry. Please let me know if you know another reason.

     

    Environment OS:Windows Server Enterprise SP2 (64Bit)
    developing tool:Visual Studio 2008(VB.NET / 3.5SP1) 
    Source Code

    Dim myOPCServer AS OSIDAAuto.OPCServer = new OSIDAAuto.OPCServer()
     

    Sincerely yours, Yamaguchi

    平均用户评级: 无评分 (0 评级)
    平均用户评级
    无评分
    (0 评级)

      • Re: A failuare of generating OSIDAAuto.OPCServer
        hanyongFluorine
         

        Hi Yamaguchi,

         

        I guess you are trying to write an OPC client that reads data from PI Server via PI OPC DA Server? Have you tried connecting to PI OPC Server using PI OPC Client or other 3rd party OPC client from the development machine? Is the PI Server on the same machine?

        • Re: A failuare of generating OSIDAAuto.OPCServer
          Hydrogen

          Is your application (the OPC Client) on the same machine than the PI OPC DA/HDA Server? I'm asking because it might very well be a DCOM security issue... I would kindly recommend you read the section on security and DCOM in the PI OPC DA/HDA Server manual (available on the vCampus Library, under vCampus PI Products Kit > Data Access Technologies).

          • Re: A failuare of generating OSIDAAuto.OPCServer
            dorisliperHydrogen

            Han san, Steve san,

             

            Thank you so much for your answer.

             

            The same error is displayed when the component generation is done though I set the DCOM while seeing the

             

            taught manual.

             

            PI Server, PI OPC Server and the program to be executed are in the same host.

             

            The thing I was anxious when I saw the manual is below.

             

            "It should be Windows 2000/XP.

             

            Although there are costomers who operate with Windows2003, that is not examined formally."

             

            Is it OK that we are testing in Windows2008(64bit)?

             

            In the manual, there is a descripition of using PISDK in PI OPC Server,too.

             

            Is there a condition that it's necessary to generate PI SDK before OPC server is generated?

             

            The source code is the following.

             

            Please teach if there is a code problem.

             
             
            1. Imports OSIDAAuto  
            2.   
            3. '''   
            4. ''' Test Program  
            5. '''               Watch Tag  
            6. '''   
            7. '''   
            8. ''' +-------------+    +----------------------+    +--------------+    +-----------+  
            9. ''' | ClsWatchOPC | -> |OSIsoft.OSIDAAuto.dll | -> | PI OPC Server| -> | PI Server |  
            10. ''' +-------------+    +----------------------+    +--------------+    +-----------+  
            11. '''   
            12.   
            13. Public Class ClsWatchOPC  
            14.    Protected _OPCServer As OPCServer  
            15.    Protected _OPCGroups As OPCGroups  
            16.    Protected WithEvents _OPCGroup As OPCGroup  
            17.    Protected _OPCItems As OPCItems  
            18.    Protected _OPCItem As OPCItem  
            19.    Public Const ITEM_MAX As Integer = 8  
            20.    Public ItemName(ITEM_MAX) As String  
            21.    Public HandleClient(ITEM_MAX) As Integer  
            22.    Public HandleServer(ITEM_MAX) As Integer  
            23.    Public oVal(ITEM_MAX) As Object  
            24.    Public dTime(ITEM_MAX) As Date  
            25.    Public wQuality(ITEM_MAX) As Short  
            26.   
            27.    Private Sub New()  
            28.        Dim ServerHandles As Array = Nothing  
            29.        Dim Errors As Array = Nothing  
            30.   
            31.        ' Create OPCServer and Connect  
            32.        Debug.WriteLine("Start : Create OPCServer")  
            33.        _OPCServer = New OPCServer()  
            34.        _OPCServer.Connect("OSI.DA.1")  
            35.        Debug.WriteLine("  End : Create OPCServer")  
            36.   
            37.        ' Setting Update Rate   1000[ms]  
            38.        Debug.WriteLine("Start : Setting Update Rate")  
            39.        _OPCGroups = _OPCServer.OPCGroups  
            40.        _OPCGroup = _OPCGroups.Add("Group1")  
            41.        _OPCGroup.UpdateRate = 1000  
            42.        Debug.WriteLine("  End : Setting Update Rate")  
            43.   
            44.        ' Enable Advise Function  
            45.        Debug.WriteLine("Start : Enable Advise Function")  
            46.        _OPCGroup.IsActive = True  
            47.        _OPCGroup.IsSubscribed = _OPCGroup.IsActive  
            48.        Debug.WriteLine("  End : Enable Advise Function")  
            49.   
            50.        ' Setting Watch Tag(TAG1 ~ TAG8)  
            51.        Debug.WriteLine("Start : Setting Watch Tag")  
            52.        _OPCItems = _OPCGroup.OPCItems  
            53.   
            54.        For i As Integer = 1 To ITEM_MAX  
            55.            ItemName(i) = "TAG" & i  
            56.            HandleClient(i) = i  
            57.        Next  
            58.   
            59.        _OPCItems.AddItems( _  
            60.              ITEM_MAX _  
            61.            , ItemName _  
            62.            , HandleClient _  
            63.            , ServerHandles _  
            64.            , Errors _  
            65.            )  
            66.   
            67.        For i As Integer = 1 To ITEM_MAX  
            68.            If Errors(i) = 0 Then  
            69.                HandleClient(i) = ServerHandles(i)  
            70.   
            71.                Debug.WriteLine( _  
            72.                      "ItemName[" _  
            73.                    & i _  
            74.                    & "] : Regist Success." _  
            75.                    )  
            76.            Else  
            77.                Debug.WriteLine( _  
            78.                      "ItemName[" _  
            79.                    & i _  
            80.                    & "] : Regist Failure." _  
            81.                    )  
            82.            End If  
            83.        Next  
            84.           
            85.        Debug.WriteLine("  End : Setting Watch Tag")  
            86.    End Sub  
            87.   
            88.    Private Sub OPCGroup_DataChange( _  
            89.          ByVal TransactionID As Integer _  
            90.        , ByVal NumItems As Integer _  
            91.        , ByRef ClientHandles As System.Array _  
            92.        , ByRef ItemValues As System.Array _  
            93.        , ByRef Qualities As System.Array _  
            94.        , ByRef TimeStamps As System.Array _  
            95.        ) Handles _OPCGroup.DataChange  
            96.   
            97.        Debug.WriteLine("DataChanged")  
            98.        Debug.WriteLine("TransactionID : [" & TransactionID & "]")  
            99.        Debug.WriteLine("NumItems : [" & NumItems & "]")  
            100.   
            101.        For i As Integer = 1 To NumItems  
            102.            Debug.WriteLine( _  
            103.                  "Rec[" & i & "] : " _  
            104.                & "ItemValues : [" & ItemValues(i) & "]" _  
            105.                & " / Qualities : [" & Qualities(i) & "]" _  
            106.                & " / TimeStamps : [" & TimeStamps(i) & "]" _  
            107.                )  
            108.        Next  
            109.    End Sub  
            110.   
            111.    Private Sub OPCGroup_AsyncReadComplete( _  
            112.          ByVal TransactionID As Integer _  
            113.        , ByVal NumItems As Integer _  
            114.        , ByRef ClientHandles As System.Array _  
            115.        , ByRef ItemValues As System.Array _  
            116.        , ByRef Qualities As System.Array _  
            117.        , ByRef TimeStamps As System.Array _  
            118.        , ByRef Errors As System.Array _  
            119.        ) Handles _OPCGroup.AsyncReadComplete  
            120.   
            121.        Debug.WriteLine("AsyncReadComplete")  
            122.        Debug.WriteLine("TransactionID : [" & TransactionID & "]")  
            123.        Debug.WriteLine("NumItems : [" & NumItems & "]")  
            124.   
            125.        For i As Integer = 1 To NumItems  
            126.            Debug.WriteLine( _  
            127.                  "Rec[" & i & "] : " _  
            128.                & "ItemValues : [" & ItemValues(i) & "]" _  
            129.                & " / Qualities : [" & Qualities(i) & "]" _  
            130.                & " / TimeStamps : [" & TimeStamps(i) & "]" _  
            131.                )  
            132.        Next  
            133.    End Sub  
            134.   
            135.    Private Sub OPCGroup_AsyncWriteComplete( _  
            136.          ByVal TransactionID As Integer _  
            137.        , ByVal NumItems As Integer _  
            138.        , ByRef ClientHandles As System.Array _  
            139.        , ByRef Errors As System.Array _  
            140.        ) Handles _OPCGroup.AsyncWriteComplete  
            141.           
            142.        Debug.WriteLine("AsyncWriteComplete")  
            143.        Debug.WriteLine("TransactionID : [" & TransactionID & "]")  
            144.        Debug.WriteLine("NumItems : [" & NumItems & "]")  
            145.    End Sub  
            146.   
            147.    Private Sub OPCGroup_AsyncCancelComplete( _  
            148.          ByVal CancelID As Integer _  
            149.        ) Handles _OPCGroup.AsyncCancelComplete  
            150.           
            151.        Debug.WriteLine("AsyncCancelComplete")  
            152.        Debug.WriteLine("CancelID : [" & CancelID & "]")  
            153.    End Sub  
            154. End Class  
            • Re: A failuare of generating OSIDAAuto.OPCServer
              Hydrogen

              What you seem to be using is a .NET Interop assembly that was automatically generated from the COM-based OPC Automation Interfaces we ship with our products. I personally do not have experience with using these "wrappers" and we actually never encouraged or taught how to use them.

               

              Typically, when you want to develop something OPC in .NET, you need to use the OPC .NET Automation Wrapper or the OPC .NET API. The former is intended to facilitate porting existing VB6 applications over to VB.NET, whereas the latter is the recommended approach for new OPC applications in .NET (whether in VB.NET or C#). For more information, please see the "OPC - Past, Present and Future" webinar under the vCampus Auditorium, or the PI Application Development Training course materials.

               

              Hope this helps!

              • Re: A failuare of generating OSIDAAuto.OPCServer
                Hydrogen

                Would you happen to be on a 64-bit machine? I dug this up a little more, and the Class ID you listed up there (at the least the 14 first characters) seem to point to the OSIDAAuto.dll COM library. This is a 32-bit library. You will have to force your .NET application to build for 32-bit because 64-bit stuff cannot call 32-bit DLLs.

                • Re: A failuare of generating OSIDAAuto.OPCServer
                  Hydrogen

                  Out of curiosity, I tried to make this code you posted earlier, but could not. I get past the creation of the OPCServer, but cannot seem to access/initialize the OPCGroups collection. After doing some research, it the seems like there is a problem in how .NET Interop was generated and how it deals with the underlying COM components. It seems like you can use it in the .NET Framework 1.1, but not in later version (like 3.5, which you are using). I found several other posts on forums on the Web, where people shared the same issue (for different OPC Servers, not OSIsoft's) and nobody found an answer.

                   

                  Per one of my previous posts, this library you are using is not something "official" or even supported. I strongly recommend you use one of the official alternatives:

                  • OPC DA Automation Wrapper (also known as the "OPC .NET RCWs MergeModule")
                  • OPC .NET API (they have version 1.3 for .NET 1.0/1.1, and version 2 for .NET 2.0)
                  • OPC .NET 3.0 (a WCF-based SDK, formerly known as OPC Xi)

                  Hope this helps!

    • 相关阅读:
      FlasCC发布说明
      FlasCC例子研究之Animation
      FlasCC例子研究之HelloWorld
      FlasCC例子研究之Drawing补充
      FlasCC Windows下开发环境搭建
      关于FlasCC(Adobe Flash C/C++ Compiler)
      FlasCC例子研究之c++interop
      魔兽世界客户端数据研究(四):M2文件头分析
      魔兽世界客户端数据研究(二)
      魔兽世界客户端数据研究(三)
    • 原文地址:https://www.cnblogs.com/zouhao/p/10051028.html
    Copyright © 2011-2022 走看看