Jump to content
Sign in to follow this  

AutoIt and Events generated by DLLs (OPC Server)

Recommended Posts

I am using AutoIt to connect to an OPC server and acquire data using

$OPC_ID=$OPC_DA.Connect($WrapperOPCServer, $WrapperOPCNodeName)
$OPC_Groups = $OPC_DA.OPCGroups
$OPCGroup = $OPC_Groups.Add("SPWrapper")




At this point, I am just polling the OPC server for the data and determining if there is a change programatically. That works but I would prefer to avoid polling. The OPC.Automation event has a data change event.

I was wondering if I would be able to create an event handler in AutoIt that would allow me to react to the data change event when the data changed?

Here is what the event looks like for VB

Sub ConnectedGroup_DataChange(ByVal TransactionID As Long, ByVal NumItems As Long, ClientHandles() As Long, ItemValues() As Variant, Qualities() As Long, TimeStamps() As Date)
    ' We don't have error handling here since this is an event called from the OPC interface
    Dim i As Integer
    For i = 1 To NumItems
        ' Use the 'Clienthandles' array returned by the server to pull out the
        ' index number of the control to update and load the value.
        OPCItemValue(ClientHandles(i)).Text = ItemValues(i)
        ' Check the Qualties for each item retured here.  The actual contents of the
        ' quality field can contain bit field data which can provide specific
        ' error conditions.  Normally if everything is OK then the quality will
        ' contain the 0xC0
        If Qualities(i) And &HC0 Then
            OPCItemQuality(ClientHandles(i)).Text = "Good"
            OPCItemQuality(ClientHandles(i)).Text = Qualities(i)
        End If
    Next i
End Sub
Edited by ijourneaux

Share this post

Link to post
Share on other sites

Your example shows COM object usage, not DLL calls. See ObjEvent() in the help file. For the more general information, see OBJ/COM Reference in the help file. Successfully using those COM events will depend on good documentation of the interface. Do you have a link to the documentation for that interface?

If it had been DLL usage, you would have registered a callback function with DllCallbackRegister(), again in the help file.


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...