How to implement a callback COM object in Python

M

Michael Bode

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

....
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top