Exemple #1
0
    def send_out(self, output: Output, current_time: float):
        # 1st: Destination (check if multicast)
        if output.multicast:
            udp_ip = output._packet.calculate_multicast_addr()
            self.socket.send_multicast(output._packet, udp_ip, output.ttl)
        else:
            udp_ip = output.destination
            self.socket.send_unicast(output._packet, udp_ip)

        output._last_time_send = current_time
        # increase the sequence counter
        output._packet.sequence_increase()
        # the changed flag is not necessary any more
        output._changed = False
Exemple #2
0
    def send_out(self, output: Output):
        # 1st: Destination (check if multicast)
        if output.multicast:
            udp_ip = output._packet.calculate_multicast_addr()
            # make socket multicast-aware: (set TTL)
            self._socket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, output.ttl)
        else:
            udp_ip = output.destination

        self.send_packet(output._packet, udp_ip)
        output._last_time_send = time.time()
        # increase the sequence counter
        output._packet.sequence_increase()
        # the changed flag is not necessary any more
        output._changed = False
Exemple #3
0
 def activate_output(self, universe: int) -> None:
     """
     Activates a universe that's then starting to sending every second.
     See http://tsp.esta.org/tsp/documents/docs/E1-31-2016.pdf for more information
     :param universe: the universe to activate
     """
     check_universe(universe)
     # check, if the universe already exists in the list:
     if universe in self._outputs:
         return
     # add new sending:
     new_output = Output(DataPacket(cid=self._sender_handler._CID, sourceName=self._sender_handler._source_name, universe=universe))
     self._outputs[universe] = new_output
def get_handler():
    cid = tuple(range(0, 16))
    source_name = 'test'
    outputs: Dict[int, Output] = {
        1: Output(packet=DataPacket(
            cid=cid,
            sourceName=source_name,
            universe=1,
        ))
    }
    socket = SenderSocketTest()
    handler = SenderHandler(
        cid=cid,
        source_name=source_name,
        outputs=outputs,
        bind_address='0.0.0.0',
        bind_port=5568,
        fps=30,
        socket=socket,
    )
    handler.manual_flush = True
    # wire up listener for tests
    socket._listener = handler
    return handler, socket, cid, source_name, outputs