OpenModelica and Python via CORBA (Part 2: IDL compilation)

Part 1 (getting started) | Part 2 (IDL compilation) | Part 3 (Python wrapper)

In part 1 I showed you how to get set up with the omniORB library/tools to communicate with OMC from Python. This post will show how to compile an IDL file to provide the appropriate interface to your script. This post assumes that the environment variables from last time are still set up and that you have OMC running with the +d=interactiveCorba parameter.

The test code we downloaded last time came with rather a lot of files, most of which we don’t need when creating a new script, so let’s set up a minimal example. First, create a directory for this new script.

cd $PREFIX/omniORB
mkdir -p apps/idl_example
cd apps/idl_example

Next, copy and omc_communication.idl into this directory.

cp $PREFIX/omniORB/src/python_2.5-omniORBPy_3.3-win32/omc_communication.{py,idl} .

These are the only two files we need to get started. The next step is to compile the IDL file to provide your script with the appropriate interfaces. The default method of doing this creates two folders and an additional file in your directory, which is a little too messy for me. To prevent this, you can tell omniidl (the omniORB IDL compiler) to place all the files into a package. The documentation has a warning about this.

Note that if you use these options to change the module package, the interface to the generated code is not strictly-speaking CORBA compliant. You may have to change your code if you ever use a Python ORB other than omniORBpy.

However, we’re only using omniORBpy here, and the files are easy enough to regenerate if you ever reconsider. With that in mind, let’s compile the IDL.

omniidl -bpython -Wbpackage=idl omc_communication.idl

You should now see an idl directory containing:

  • _GlobalIDL
  • _GlobalIDL__POA

Because we compiled the IDL a little differently to the default, we need to edit the test script. Simply change line 6 to read:

import idl._GlobalIDL as _GlobalIDL

Now run the script:


If all is well, you should see the same graph as in part 1.

Loading Facebook Comments ...
  1. […] a reply Part 1 (getting started) | Part 2 (IDL compilation) | Part 3 (Python […]

  2. […] a reply Part 1 (getting started) | Part 2 (IDL compilation) | Part 3 (Python […]