def __init__(self, args, kwargs): """ Initialize the socket connections """ # Call the constructor of the parent class DatastreamManager.__init__(self, args, kwargs) self.time_sync = kwargs.get('time_sync', False) self.sync_port = kwargs.get('sync_port', -1) if self.time_sync: if self.sync_port == -1: logger.error( "time_sync is required, but sync_port is not configured") raise MorseMiddlewareError("sync_port is not configured") else: self._init_trigger() # port -> MorseSocketServ self._server_dict = {} # component name (string) -> Port (int) self._component_nameservice = {} # Base port self._base_port = 60000 # Register two special services in the socket service manager: # TODO To use a new special component instead of 'simulation', # uncomment the line :-) # blenderapi.persistantstorage().morse_services.register_request_manager_mapping("streams", "SocketRequestManager") services.do_service_registration(self.list_streams, 'simulation') services.do_service_registration(self.get_stream_port, 'simulation') services.do_service_registration(self.get_all_stream_ports, 'simulation')
def register_component(self, component_name, component_instance, mw_data): """ Open the port used to communicate by the specified component. """ mw_data[3]["__hla_node"] = self.node DatastreamManager.register_component(self, component_name, component_instance, mw_data)
def __init__(self, args, kwargs): """ Initialize the socket connections """ # Call the constructor of the parent class DatastreamManager.__init__(self, args, kwargs) self._time_initialized = False try: fom = kwargs["fom"] node_name = kwargs["name"] federation = kwargs["federation"] sync_point = kwargs.get("sync_point", None) sync_register = kwargs.get("sync_register", False) self.time_sync = kwargs.get("time_sync", False) timestep = kwargs.get("timestep", 1.0 / blenderapi.getfrequency()) lookahead = kwargs.get("lookahead", timestep) self.stop_time = kwargs.get("stop_time", float("inf")) self.node = HLABaseNode( MorseBaseAmbassador, fom, node_name, federation, sync_point, sync_register, self.time_sync, timestep, lookahead, ) except KeyError as error: logger.error( "One of [fom, name, federation] attribute is not configured: " "Cannot create HLADatastreamManager" ) raise
def __init__(self, args, kwargs): """ Initialize the socket connections """ # Call the constructor of the parent class DatastreamManager.__init__(self, args, kwargs) self._time_initialized = False try: fom = kwargs["fom"] node_name = kwargs["name"] federation = kwargs["federation"] sync_point = kwargs.get("sync_point", None) sync_register = kwargs.get("sync_register", False) self.time_sync = kwargs.get("time_sync", False) timestep = kwargs.get("timestep", 1.0 / blenderapi.getfrequency()) lookahead = kwargs.get("lookahead", timestep) self.stop_time = kwargs.get("stop_time", float("inf")) self.node = HLABaseNode(MorseBaseAmbassador, fom, node_name, federation, sync_point, sync_register, self.time_sync, timestep, lookahead) except KeyError as error: logger.error( "One of [fom, name, federation] attribute is not configured: " "Cannot create HLADatastreamManager") raise
def __init__(self, args, kwargs): """ Initialize the socket connections """ # Call the constructor of the parent class DatastreamManager.__init__(self, args, kwargs) self.time_sync = kwargs.get('time_sync', False) self.sync_port = kwargs.get('sync_port', -1) if self.time_sync: if self.sync_port == -1: logger.error("time_sync is required, but sync_port is not configured") raise MorseMiddlewareError("sync_port is not configured") else: self._init_trigger() # port -> MorseSocketServ self._server_dict = {} # component name (string) -> Port (int) self._component_nameservice = {} # Base port self._base_port = 60000 # Register two special services in the socket service manager: # TODO To use a new special component instead of 'simulation', # uncomment the line :-) # blenderapi.persistantstorage().morse_services.register_request_manager_mapping("streams", "SocketRequestManager") services.do_service_registration(self.list_streams, 'simulation') services.do_service_registration(self.get_stream_port, 'simulation') services.do_service_registration(self.get_all_stream_ports, 'simulation')
def register_component(self, component_name, component_instance, mw_data): """ Open the port used to communicate by the specified component. """ mw_data[2]['__hla_node'] = self.node DatastreamManager.register_component(self, component_name, component_instance, mw_data)
def __init__(self, args, kwargs): """ Initialize the socket connections """ # Call the constructor of the parent class DatastreamManager.__init__(self, args, kwargs) self._mav = mavlink.MAVLink(None) self._conn_manager = MavlinkConnManager(self._mav) self._boot_time = blenderapi.persistantstorage().time.time
def register_component(self, component_name, component_instance, mw_data): """ Open the port used to communicate by the specified component. """ register_success = False must_inc_base_port = False if not 'port' in mw_data[2]: must_inc_base_port = True mw_data[2]['port'] = self._base_port while not register_success: try: # Create a socket server for this component serv = DatastreamManager.register_component(self, component_name, component_instance, mw_data) register_success = True except socket.error as error_info: if error_info.errno == errno.EADDRINUSE: mw_data[2]['port'] += 1 if must_inc_base_port: self._base_port += 1 else: raise self._server_dict[mw_data[2]['port']] = serv self._component_nameservice[component_name] = mw_data[2]['port'] if must_inc_base_port: self._base_port += 1
def register_component(self, component_name, component_instance, mw_data): """ Open the port used to communicate by the specified component. """ register_success = False must_inc_base_port = False if not 'port' in mw_data[2]: must_inc_base_port = True mw_data[2]['port'] = self._base_port while not register_success: try: # Create a socket server for this component serv = DatastreamManager.register_component( self, component_name, component_instance, mw_data) register_success = True except socket.error as error_info: if error_info.errno == errno.EADDRINUSE: mw_data[2]['port'] += 1 if must_inc_base_port: self._base_port += 1 else: raise self._server_dict[mw_data[2]['port']] = serv self._component_nameservice[component_name] = mw_data[2]['port'] if must_inc_base_port: self._base_port += 1
def register_component(self, component_name, component_instance, mw_data): """ Open the port used to communicate by the specified component. """ # Create a socket server for this component datastream = DatastreamManager.register_component(self, component_name, component_instance, mw_data) datastream.setup(self._conn_manager, self._mav, self._boot_time)
def register_component(self, component_name, component_instance, mw_data): """ Open the port used to communicate by the specified component. """ # Create a socket server for this component datastream = DatastreamManager.register_component( self, component_name, component_instance, mw_data) datastream.setup(self._conn_manager, self._mav, self._boot_time)
def __init__(self): """ Initialize the socket connections """ # Call the constructor of the parent class DatastreamManager.__init__(self) # port -> MorseSocketServ self._server_dict = {} # component name (string) -> Port (int) self._component_nameservice = {} # Register two special services in the socket service manager: # TODO To use a new special component instead of 'simulation', # uncomment the line :-) # blenderapi.persistantstorage().morse_services.register_request_manager_mapping("streams", "SocketRequestManager") services.do_service_registration(self.list_streams, 'simulation') services.do_service_registration(self.get_stream_port, 'simulation') services.do_service_registration(self.get_all_stream_ports, 'simulation')
def __init__(self, args, kwargs): """ Initialize the socket connections """ # Call the constructor of the parent class DatastreamManager.__init__(self, args, kwargs) try: fom = kwargs["fom"] node_name = kwargs["name"] federation = kwargs["federation"] sync_point = kwargs.get("sync_point", None) sync_register = kwargs.get("sync_register", False) time_sync = kwargs.get("time_sync", False) self.node = HLABaseNode(MorseBaseAmbassador, fom, node_name, federation, sync_point, sync_register, time_sync) except KeyError as error: logger.error( "One of [fom, name, federation] attribute is not configured: " "Cannot create HLADatastreamManager") raise
def register_component(self, component_name, component_instance, mw_data): """ Open the port used to communicate by the specified component. """ global BASE_PORT register_success = False while not register_success: try: # Create a socket server for this component serv = DatastreamManager.register_component(self, component_name, component_instance, mw_data) register_success = True except socket.error as error_info: if error_info.errno == errno.EADDRINUSE: BASE_PORT += 1 else: raise self._server_dict[BASE_PORT] = serv self._component_nameservice[component_name] = BASE_PORT BASE_PORT += 1
def finalize(self): DatastreamManager.finalize(self) self.node.finalize()