Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 import time, string
00009
00010
00011
00012
00013
00014 def doNarrow4Jython(corbaClass, corbaObject):
00015 return corbaClass.narrow(corbaObject)
00016
00017
00018 def getORBJython(argv):
00019 props = System.getProperties()
00020 s = System.getenv("NS_OPT")
00021 if(not s):
00022 s = System.getenv("NS_OPT")
00023
00024 if(s == ''):
00025 args = argv
00026 else:
00027 args = string.split(s)
00028
00029 return CORBA.ORB.init(args, props)
00030
00031
00032 def getPluginObject2NarrowJython(name):
00033
00034 try:
00035 exec('import Simulator.'+name+'Helper as localImport')
00036 return localImport
00037 except ImportError:
00038 return None
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 def doNarrow4Python(corbaClass, corbaObject):
00055
00056
00057 try:
00058 tmp = corbaObject._narrow(corbaClass)
00059
00060 return tmp
00061 except:
00062 print 'narrow exception:', corbaObject, 'to', corbaClass
00063
00064 return None
00065
00066
00067 def getORBPython(argv):
00068 return CORBA.ORB_init(argv, CORBA.ORB_ID)
00069
00070
00071 def getPluginObject2NarrowPython(name):
00072 print name
00073 print 'getPluginObject2NarrowPython('+name+')'
00074 try:
00075 exec('from _GlobalIDL import '+name+' as localImport')
00076 return localImport
00077 except ImportError:
00078 return None
00079
00080
00081
00082 global doNarrow
00083 doNarrow = None
00084
00085 try:
00086 import java.lang.System as System
00087 print 'platform is probably Jython'
00088 import org.omg.CORBA as CORBA
00089
00090 from org.omg.CosNaming import NameComponent
00091 from org.omg.CosNaming.NamingContextPackage import NotFound
00092 from jp.go.aist.hrp import simulator as IDLBase
00093
00094 Platform = 'J'
00095
00096
00097 from org.omg.CosNaming import NamingContextHelper as NamingContext
00098
00099
00100
00101 PluginManager = IDLBase.PluginManagerHelper
00102
00103
00104 CommandReceiver = IDLBase.CommandReceiverHelper
00105
00106
00107 Plugin = IDLBase.PluginHelper
00108
00109
00110 LoggerPlugin = IDLBase.LoggerPluginHelper
00111
00112
00113 SequencePlayer = IDLBase.SequencePlayerHelper
00114
00115 stateProvider = IDLBase.stateProviderHelper
00116 IoControPlugin = IDLBase.IoControlPluginHelper
00117
00118 doNarrow = doNarrow4Jython
00119 getORB = getORBJython
00120 getPluginObject2Narrow = getPluginObject2NarrowJython
00121
00122 except ImportError:
00123 print 'platform is probably CPython'
00124 import omniORB.CORBA as CORBA
00125 import CosNaming
00126 import _GlobalIDL as IDLBase
00127
00128 NameComponent = CosNaming.NameComponent
00129 NotFound = CosNaming.NamingContext.NotFound
00130
00131 Platform = 'C'
00132
00133
00134 NamingContext = CosNaming.NamingContext
00135
00136
00137 PluginManager = IDLBase.PluginManager
00138
00139
00140 CommandReceiver = IDLBase.CommandReceiver
00141
00142
00143 Plugin = IDLBase.Plugin
00144
00145
00146 LoggerPlugin = IDLBase.LoggerPlugin
00147
00148
00149 SequencePlayer = IDLBase.SequencePlayer
00150
00151 stateProvider = IDLBase.stateProvider
00152 IoControPlugin = IDLBase.IoControlPlugin
00153
00154 doNarrow = doNarrow4Python
00155 getORB = getORBPython
00156 getPluginObject2Narrow = getPluginObject2NarrowPython
00157
00158
00159
00160 def getCORBAObjects():
00161 return NotFound, NamingContext, NameComponent, \
00162 IDLBase, \
00163 PluginManager, \
00164 Plugin, \
00165 CommandReceiver, \
00166 stateProvider, \
00167 IoControPlugin, \
00168 LoggerPlugin, \
00169 SequencePlayer