D
Divya
Hello,
I'm new to IronPython and COM so please bear with me.
I have a COM interface provided to me. I need to implement this
interface and pass it to a method as a way of implementing
'callbacks'.
However it appears that the methods of my interface object are never
called.
As a alternative, I implemented the interface in C# and then extended
the C# class in IronPython. However, on running the code, methods of
my C# class rather than the IronPython class are being called.
Can anyone advise? Is this possible in IronPython?
The code is listed below.
Regards,
Divya
---------------------------
import time
import clr
clr.AddReference('Interop.MBTCOMLib.dll')
clr.AddReference('Interop.MBTORDERSLib.dll')
clr.AddReference('Interop.MBTQUOTELib.dll')
import MBTCOMLib
import MBTORDERSLib
import MBTQUOTELib
demo_user='user'
demo_pass='pass'
demo_host=9
class MBEvents(MBTQUOTELib.IMbtQuotesNotify):
def __init__(self):
MBTQUOTELib.IMbtQuotesNotify.__init__(self)
def OnLevel2Data(data):
print 'OnLevel2Data'
def OnOptionsData(self, data):
print 'OnOptionsData'
def OnQuoteData(self, data):
print 'OnQuoteData'
def OnTSData(self, data):
print 'OnTSData'
class MB:
def __init__(self):
self.conn = MBTCOMLib.MbtComMgrClass()
#self.conn.EnableSplash(False)
self.orders = self.conn.OrderClient
self.quotes = self.conn.Quotes
self.events = MBEvents()
def login(self, host=demo_host, user=demo_user, passwd=demo_pass):
self.conn.DoLogin(host, user, passwd, '')
print self.quotes.RemoteAddress, self.quotes.RemotePort
self.quotes.AdviseSymbol(self.events, 'EUR/USD', 1|2|3|4)
I'm new to IronPython and COM so please bear with me.
I have a COM interface provided to me. I need to implement this
interface and pass it to a method as a way of implementing
'callbacks'.
However it appears that the methods of my interface object are never
called.
As a alternative, I implemented the interface in C# and then extended
the C# class in IronPython. However, on running the code, methods of
my C# class rather than the IronPython class are being called.
Can anyone advise? Is this possible in IronPython?
The code is listed below.
Regards,
Divya
---------------------------
import time
import clr
clr.AddReference('Interop.MBTCOMLib.dll')
clr.AddReference('Interop.MBTORDERSLib.dll')
clr.AddReference('Interop.MBTQUOTELib.dll')
import MBTCOMLib
import MBTORDERSLib
import MBTQUOTELib
demo_user='user'
demo_pass='pass'
demo_host=9
class MBEvents(MBTQUOTELib.IMbtQuotesNotify):
def __init__(self):
MBTQUOTELib.IMbtQuotesNotify.__init__(self)
def OnLevel2Data(data):
print 'OnLevel2Data'
def OnOptionsData(self, data):
print 'OnOptionsData'
def OnQuoteData(self, data):
print 'OnQuoteData'
def OnTSData(self, data):
print 'OnTSData'
class MB:
def __init__(self):
self.conn = MBTCOMLib.MbtComMgrClass()
#self.conn.EnableSplash(False)
self.orders = self.conn.OrderClient
self.quotes = self.conn.Quotes
self.events = MBEvents()
def login(self, host=demo_host, user=demo_user, passwd=demo_pass):
self.conn.DoLogin(host, user, passwd, '')
print self.quotes.RemoteAddress, self.quotes.RemotePort
self.quotes.AdviseSymbol(self.events, 'EUR/USD', 1|2|3|4)