×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How do you refer to the RSLinx Gateway Server

How do you refer to the RSLinx Gateway Server

How do you refer to the RSLinx Gateway Server

(OP)
I can get the code below to work if I have RSLinx OEM or higher installed on the local pc, but I want to go through RSLinx Gateway which is installed on our server. How do I get this code to point to the RSLinx Gateway server? I tried replacing:
 oServer.Connect("RSLinx OPC Server")
with:
 oServer.Connect("\\ServerName\RSLinx OPC Server")
but it fails to connect.

Any help would be much appreciated as I am at wits end.

Thanks in advance.

Example Code:
Imports RsiOPCAuto

Public Class Form1
    Public oServer As RsiOPCAuto.OPCServer
    Public WithEvents oGroup As RsiOPCAuto.OPCGroup
    Public oItem1 As RsiOPCAuto.OPCItem
    Public oItem2 As RsiOPCAuto.OPCItem

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load

        oServer = New RsiOPCAuto.OPCServer
        
        oServer.Connect("RSLinx OPC Server")

        oGroup = oServer.OPCGroups.Add("TestGroup") 'Group name can be anything you want it to be

        oGroup.IsActive = True 'Enables updates of the data and creates events
        oGroup.UpdateRate = 500 'In milliseconds (1000 = 1 second)
        oGroup.IsSubscribed = True

        'Now that we've created our group, we can add some items


        oItem1 = oGroup.OPCItems.AddItem("[TopicName]PLCAdress", 1)
        oItem2 = oGroup.OPCItems.AddItem("[TopicName]PLCAdress", 2)
        'In the code above, the text in the quotes is the OPC item. The number following it is a UNIQUE identifier
        'that is given and referred back to if needed later.

        'The data event handler below gets fired whenever an opc item inside of it gets its value updated

        AddHandler (oGroup.DataChange), AddressOf DataChanged


    End Sub

    Private Sub DataChanged(ByVal TransactionID As Integer, ByVal NumItems As Integer, _
    ByRef ClientHandles As System.Array, ByRef ItemValues As System.Array, _
    ByRef ItemQualities As System.Array, ByRef Qualities As System.Array)
        '{i
        'This event gets fired whenever the data changes for one of the tags added to the OPCGroup.
        'It is my recommendation that if you are going to have a lot of items in the OPCGroup, that you
        'create a collection class for the OPCItems, instead of using a separate variable for each one.
        Static iStatus As Integer
        If iStatus <> CType(oItem2.Value, Integer) Then
            If CType(oItem2.Value, Integer) = 0 Then
                lblStatus.Text = "Press Down - Waiting For Response"
            Else
                lblStatus.Text = "Press Running - Production"
            End If
            iStatus = CType(oItem2.Value, Integer)
            TextBox1.Text = TextBox1.Text & lblStatus.Text & " " & Now() & vbCrLf
        End If

        Static iLabel As Integer
        If iLabel <> CType(oItem1.Value, Integer) Then
            If CType(oItem1.Value, Integer) = 0 Then
                Label1.Text = "Down"
            Else
                Label1.Text = "Up"
            End If
            iLabel = CType(oItem1.Value, Integer)
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        '{
        'This sub demonstrates getting the value of an item. The item values are always passed back
        'from the OPCItem group as a type Object. The Object can then be cast to whatever you need
        'to use it as.

        'Basically this just flips the value of the item in the PLC. I was using it to start a timer that triggered
        'the TEST_ALARM value when the timer expired.

        If CType(oItem1.Value, Integer) = 1 Then
            oItem1.Write(0)
        Else
            oItem1.Write(1)
        End If

        'Data is also written back to the item as Object, but the interop will automatically convert most types
        'to Object before passing it into the OPC item. If it won't, then you'll need to do a typecast back to
        'the Object type. The .Write method blocks during operation, so it is not advised if you are using it
        'to write a lot of data. There are methods for synchronous and asynchronous writes back to the
        'OPC server, which are not described here (mostly because I haven't gotten them to work yet, I'm
        'doing all of this by trial-and-error).

        '}
    End Sub



End Class

RE: How do you refer to the RSLinx Gateway Server

Hi,

I think you do this

oServer.Connect("RSLinx OPC Server", "Servername")

There is an optional variable of nodename ("Servername")

Hope this helps!
Jenn

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources