wsnsim/node.py
def convert_to_simulation_nodes(
        regular_nodes: Iterable[Node],
        routing_protocol: str,
        deadline: float,
        send_data_function: Callable[[str], Generator[Event, Any, Any]],
        env: Environment) -> Iterable[SimulationNode]:
    """Returns simulation nodes from regular nodes."""
    simulation_nodes = []
    if routing_protocol == 'min-hop':
        routing_sensing_node = MinHopRouting
        routing_sink_node = MinHopRoutingSink
    elif routing_protocol == "etx":
        routing_sensing_node = ETX
        routing_sink_node = ETXSink
    elif routing_protocol == 'dap':
        routing_sensing_node = DAPRouting
        routing_sink_node = DAPRoutingSink
        routing_sensing_node.deadline = deadline
        routing_sink_node.deadline = deadline
    else:  # Default routing protocol
        raise ValueError(f"{routing_protocol} is not a valid protocol")
    for node in regular_nodes:
        if isinstance(node, SensingNode):
            simulation_node = SimulationSensingNode(node.address,
                                                    node.name,
                                                    routing_sensing_node,
                                                    send_data_function,
                                                    env,
                                                    node.sensing_period,
                                                    node.sensing_offset)
        elif isinstance(node, SinkNode):
            simulation_node = SimulationSinkNode(node.address,
                                                 node.name,
                                                 routing_sink_node,
                                                 send_data_function,
                                                 env)
        else:
            raise AttributeError('Class of node is not correct')
        simulation_nodes.append(simulation_node)
    return simulation_nodes
Returns simulation nodes from regular nodes.
Returns simulation nodes from regular nodes.
Returns simulation nodes from regular nodes .
def convert_to_simulation_nodes(
        regular_nodes: Iterable[Node],
        routing_protocol: str,
        deadline: float,
        send_data_function: Callable[[str], Generator[Event, Any, Any]],
        env: Environment) -> Iterable[SimulationNode]:
    simulation_nodes = []
    if routing_protocol == 'min-hop':
        routing_sensing_node = MinHopRouting
        routing_sink_node = MinHopRoutingSink
    elif routing_protocol == "etx":
        routing_sensing_node = ETX
        routing_sink_node = ETXSink
    elif routing_protocol == 'dap':
        routing_sensing_node = DAPRouting
        routing_sink_node = DAPRoutingSink
        routing_sensing_node.deadline = deadline
        routing_sink_node.deadline = deadline
    else:  
        raise ValueError(f"{routing_protocol} is not a valid protocol")
    for node in regular_nodes:
        if isinstance(node, SensingNode):
            simulation_node = SimulationSensingNode(node.address,
                                                    node.name,
                                                    routing_sensing_node,
                                                    send_data_function,
                                                    env,
                                                    node.sensing_period,
                                                    node.sensing_offset)
        elif isinstance(node, SinkNode):
            simulation_node = SimulationSinkNode(node.address,
                                                 node.name,
                                                 routing_sink_node,
                                                 send_data_function,
                                                 env)
        else:
            raise AttributeError('Class of node is not correct')
        simulation_nodes.append(simulation_node)
    return simulation_nodes
def convert_to_simulation_nodes ( regular_nodes : Iterable [ Node ] , routing_protocol : str , deadline : float , send_data_function : Callable [ [ str ] , Generator [ Event , Any , Any ] ] , env : Environment ) -> Iterable [ SimulationNode ] : simulation_nodes = [ ] if routing_protocol == 'min-hop' : routing_sensing_node = MinHopRouting routing_sink_node = MinHopRoutingSink elif routing_protocol == "etx" : routing_sensing_node = ETX routing_sink_node = ETXSink elif routing_protocol == 'dap' : routing_sensing_node = DAPRouting routing_sink_node = DAPRoutingSink routing_sensing_node . deadline = deadline routing_sink_node . deadline = deadline else : raise ValueError ( f"{routing_protocol} is not a valid protocol" ) for node in regular_nodes : if isinstance ( node , SensingNode ) : simulation_node = SimulationSensingNode ( node . address , node . name , routing_sensing_node , send_data_function , env , node . sensing_period , node . sensing_offset ) elif isinstance ( node , SinkNode ) : simulation_node = SimulationSinkNode ( node . address , node . name , routing_sink_node , send_data_function , env ) else : raise AttributeError ( 'Class of node is not correct' ) simulation_nodes . append ( simulation_node ) return simulation_nodes
Returns simulation nodes from regular nodes.
Returns simulation nodes from regular nodes .
"""Returns simulation nodes from regular nodes.""" # Default routing protocol
regular_nodes
Iterable[Node]
routing_protocol
str
deadline
float
send_data_function
Callable[[str], Generator[Event, Any, Any]]
env
Environment