- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » OMC corba interface
OMC corba interface
OMC corba interface
Hello,
I'm experimenting with multiple clients connecting to the OMC for querying and modifying the model. I am running the omc in Corba interactive mode with
"omc +d=interactiveCorba". I was able to establish a connection between the omc server and two local clients using some of the example python code found on this site.
What I want to do is establish a remote connection to the omc server and I'm struggling with the Corba InitRef syntax. Now, before I go on trying to figure this out, I wanted to make sure that the OMC server will support it.
My guess is that it should, but a confirmation would be appreciated.
Also, if somebody knows the right CORBA syntax + code snipped to establish a remote corba interface I would appreciate that. The Corba documentation is rather cryptic and I'm running out of time at this point to figure this out.
Here's what I have as my function to establish the local corba connection (this is a modification of OMC example code). It assumes that the omc server is running and has created an IOR file in a local temporary file at (tempdir + "\\" + "openmodelica.objid").
def initiateCorbaOMCConnection():
"""Establish a local connection to the OMC Corba interface.
Outputs:
omc = omc connection object
"""
host='localhost'
port ='0'
corbaString = "mico-local-orb=corbaloc::%s:%s/" % (host, port)
#print corbaString
orb = CORBA.ORB_init(["-ORBInitRef",corbaString], CORBA.ORB_ID)
# getting the TEMP variable
tempdir = os.environ['TEMP']
omc_objid_file = tempdir + "\\" + "openmodelica.objid"
omc_corba_uri= "file:///" + omc_objid_file
# See if the omc server is running
if os.path.isfile(omc_objid_file):
print "OMC Server is up and running at " + omc_corba_uri + "\n"
else:
raise Exception("OMC Server is down. Please start it! Exiting")
#print "OMC Server is down. Please start it! Exiting \n"
#sys.exit(2)
objid_file=open(omc_objid_file)
ior = objid_file.readline()
objid_file.close()
mico_obj = orb.resolve_initial_references("RootPOA")
# Calling string_to_object
print "URI of the OMC server: " + ior
obj = orb.string_to_object(ior)
omc = obj._narrow(_GlobalIDL.OmcCommunication)
if omc is None:
raise Exception("Failed to connect to OMC Server. Object reference is not an OmcCommunication")
#sys.exit(1)
return omc
Kind regards
Chahé
Re: OMC corba interface
Hello,
an update for those that may have the same problem/question:
My initial assumption that the IOR in openmodelica.objid should work was correct. The problem in my case was that the remote machine running the OMC server had two ethernet cards. After some reading, I found out that the IP of one of them ends up encoded in the IOR string. Unfortunately for me, from the client, this IP was not visible hence the failed connections.
So, bottom line. the IOR string in the openmodelica.objid, if it is somehow shared with the client, can be used to establish a corba link with the remote OMC.There are apparently mechanisms in Corba just for that, but for now I have implemented my own Socket based method to share the IOR with all clients.
Cheers
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » OMC corba interface