def __init__(self, service_name, local_port, remote_port): """ Constructor """ self.service_name = service_name self.local_port = local_port try: CRSServer.__init__(self, "localhost", local_port) except: print "[CRSService.__init__] %s fail creating the XML-RPC server port=%d" % (service_name, local_port) raise else: print "[CRSService.__init__]%s server listening port %d!!" % (service_name, local_port) self.register_function(self.WC_input, "PyRoboticStudio.input") self.register_function(self.WC_output, "PyRoboticStudio.output") self.register_function(self.WC_step, "PyRoboticStudio.step") try: self.remote_port = remote_port host = "http://localhost:%d" % self.remote_port self.crsClient = CRSClient(host, service_name, "1_0_0_0") except: print "[CRSService.__init__] %s fail connecting to the server" % service_name raise else: print "[CRSService.__init__] %s connected!!" % service_name try: if not self.crsClient.Hello(self.local_port): print "[CRSService.__init__] %s - Hello not accepted." % service_name except: print "[CRSService.__init__] XML-RPC hello fail!" raise else: print "[CRSService.__init__] %s - Initialization DONE." % service_name
def __init__(self,local_port=49580): ''' Constructor ''' try: CRSServer.__init__(self,'localhost',local_port) except: print '[CRSEngine.__init__] fail creating the XML-RPC server' else: print '[CRSEngine.__init__] server listening!!' self.register_function(self.WC_input, "PyRoboticStudio.input") self.register_function(self.WC_output, "PyRoboticStudio.output") ''' Properties ''' self.delta_time = 0.1 #delta time in sec. self.total_simulation_time = 120.0 #total time of the simulation in sec. self.local_port = local_port ''' Service list ''' self.services = {}