OPC driver thoughts

  • Anonymous - 2012-08-07

    Currently if the OPCServer is invalid or offline, your program will throw an exception.  It would be better to catch this, then shut down OPC attempts and notify your program that something is wrong.

    I suggest to add at the start of the program:

    Imports System.ComponentModel

    after the "Public Class OPCComm" declaration add:

        Inherits System.ComponentModel.Component

    then change the CreateDLLInstance() subroutine to throw an event to your program and report the success or failure

    Public Event OPCcreationFailed As PropertyChangedEventHandler Implements _ 
        Private Function CreateDLLInstance() As Boolean
            Dim created as Boolean = True
            If DLL Is Nothing Then
                DLL = New Opc.Da.Server(fact, Nothing)
                DLL.Url = New Opc.URL("opcda://localhost/" & _OPCServer)
                Catch ex As Exception
                    created = False
                    RaiseEvent OPCcreationFailed(Me, New PropertyChangedEventArgs(_OPCServer))
                End Try
            End If
        Return created
        End Sub

    Then add a quick test at the start of the read/write/subscribe routines, etc
    Some routines check for the DLL and create it, but then continue on failing if it is not created.
    The write routines do not even have a check, so they need one.

    If DLL Is Nothing Then
        If Not CreateDLLInstance() Then Return

    If you don't like that idea, feel free to add something to stop the exception crashes.
    Keep up the good work and thanks for the work you put into advancedHMI

  • Anonymous - 2012-08-07

    Man the forums need edit/preview.  :)

    In the second block of code I did not mean to say add:

    Inherits System.ComponentModel.Component

    It's already there.  :)  I meant to say add the following after the inherts:

    Implements INotifyPropertyChanged

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks