Discussion:
[omniORB] How do you implement callbacks?
Morris, Steve (SW/FW - Rehovot)
2008-01-07 17:54:31 UTC
Permalink
How do you implement callbacks?

The IDL has the following code:

module iPC_API {
interface iPC_API_WatchDogObserver { boolean connectionAlive();};

interface iPC_Connect : PropertyManager {
exception UnableToConnect {wstring why;};
iPC_Device connectToiPCDevice(in iPC_API_WatchDogObserver watchDogObserver) raises (UnableToConnect);
}
}

I derive a class from iPC_API_WatchDogObserver and define its method
class iPCWatchdogObserver(iPC_API__POA.iPC_API_WatchDogObserver):
def connectionAlive(self):
return True

I create an instance of iPCWatchdogObserver
self.watchdogObserver = iPCWatchdogObserver()

I call connectToiPCDevice() with the
iPCDevice = self.iPCConnect.connectToiPCDevice(self.watchdogObserver)

I get the following exception
'Traceback (most recent call last):
File "C:\\projects\\JobPreview\\JobPreviewFrame.py", line 477, in LoadJobListFromiPC
iPCDevice = self.iPCConnect.connectToiPCDevice(self.watchdogObserver)
File "C:\\projects\\JobPreview\\iPC_Connect_idl.py", line 3124, in connectToiPCDevice
return _omnipy.invoke(self, "connectToiPCDevice", _0_iPC_API.iPC_Connect._d_connectToiPCDevice, args)
BAD_PARAM: CORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType, CORBA.COMPLETED_NO)\n'

What am I doing wrong?

Thanks,
Steve
Andrew Edem
2008-01-08 15:09:29 UTC
Permalink
Hi Steve,
Post by Morris, Steve (SW/FW - Rehovot)
I create an instance of iPCWatchdogObserver
self.watchdogObserver = iPCWatchdogObserver()
I call connectToiPCDevice() with the
iPCDevice = self.iPCConnect.connectToiPCDevice(self.watchdogObserver)
CORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType, CORBA.COMPLETED_NO)\n'
What am I doing wrong?
You need to call self.watchdogObserver._this() to register it on the POA and
get the object reference from the implementation:

iPCDevice = self.iPCConnect.connectToiPCDevice(self.watchdogObserver._this())

Cheers,
-Andrew
Duncan Grisby
2008-01-10 22:44:36 UTC
Permalink
Post by Morris, Steve (SW/FW - Rehovot)
How do you implement callbacks?
Your question actually has nothing to do with callbacks, but is just
about servers in general...

[...]
Post by Morris, Steve (SW/FW - Rehovot)
I create an instance of iPCWatchdogObserver
self.watchdogObserver = iPCWatchdogObserver()
I call connectToiPCDevice() with the
iPCDevice = self.iPCConnect.connectToiPCDevice(self.watchdogObserver)
[...]
Post by Morris, Steve (SW/FW - Rehovot)
BAD_PARAM: CORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType, CORBA.COMPLETED_NO)\n'
What am I doing wrong?
You have tried to use a servant -- i.e. a programming language object --
where you need a CORBA object reference. They are different things. To
get an object reference, you must activate your servant in a POA, and
acquire an object reference for it. Look at the various server examples
to see how to do that.

You can find a good explanation of the different between servants and
object references in Ciaran McHale's free book:

http://www.ciaranmchale.com/corba-explained-simply/

in particular the chapter about server-side programming:

http://www.ciaranmchale.com/corba-explained-simply/concepts-for-server-side-programming.html

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Continue reading on narkive:
Loading...