How to implement a callback COM object in Python

Discussion in 'Python' started by Michael Bode, Nov 16, 2010.

  1. Michael Bode

    Michael Bode Guest

    Hi,

    I'm trying to write a COM client to a COM server which controls a power
    meter. The COM server fires events that should be handled by the
    client. The docs state that I have to supply a class which implements
    the IFM2DeviceEvents interface. I need some instructions on how to
    translate the VB sample code to Python:

    Option Explicit

    Implements IFM2DeviceEvents

    Private m_CallbackEvent As String
    Private m_CallbackMessage As String
    Private m_DeviceIndex As Integer
    Private m_SerialNumber As String
    Private m_ZeroDeviceTimeoutCounter As Integer

    ' Methods

    Private Sub IFM2DeviceEvents_DisplayErrorToClient()
    frmTest.DisplayErrorMessage m_CallbackMessage
    End Sub

    Private Sub IFM2DeviceEvents_NotifyData(ByVal CallbackData As IFM2DeviceEvents)
    frmTest.NotifyData CallbackData
    End Sub

    Private Sub IFM2DeviceEvents_NotifyDeviceStatus(ByVal CallbackData As IFM2DeviceEvents, ByVal DevicesList As cFM2Devices)
    frmTest.NotifyDeviceStatus CallbackData, DevicesList
    End Sub

    Private Sub IFM2DeviceEvents_DisplayZeroDeviceProgressToClient()
    frmTest.DisplayZeroDeviceProgress m_CallbackMessage, m_ZeroDeviceTimeoutCounter
    End Sub

    ' Read/write properties

    Private Property Let IFM2DeviceEvents_CallbackEvent(ByVal RHS As String)
    m_CallbackEvent = RHS
    End Property

    Private Property Get IFM2DeviceEvents_CallbackEvent() As String
    IFM2DeviceEvents_CallbackEvent = m_CallbackEvent
    End Property

    ....
    Michael Bode, Nov 16, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff
    Replies:
    0
    Views:
    713
  2. Stephen Kellett
    Replies:
    5
    Views:
    149
    Stephen Kellett
    Nov 30, 2004
  3. Marc Aymerich
    Replies:
    0
    Views:
    65
    Marc Aymerich
    Nov 24, 2013
  4. Devin Jeanpierre
    Replies:
    12
    Views:
    101
    Steven D'Aprano
    Nov 24, 2013
  5. Chris Angelico
    Replies:
    0
    Views:
    56
    Chris Angelico
    Nov 24, 2013
Loading...

Share This Page