예제 #1
0
def main():
    zephyr.configure_root_logger()
    
    serial_port_dict = {"Darwin": "/dev/cu.BHBHT001931-iSerialPort1",
                        "Windows": 25}
    
    serial_port = serial_port_dict[platform.system()]
    ser = serial.Serial(serial_port)
    
    
    collector = MeasurementCollector()
    rr_signal_analysis = BioHarnessSignalAnalysis([], [collector.handle_event])
    signal_packet_handlers = [collector.handle_signal, rr_signal_analysis.handle_signal]
    
    signal_packet_handler = BioHarnessPacketHandler(signal_packet_handlers, [collector.handle_event])
    
    payload_parser = MessagePayloadParser(signal_packet_handler.handle_packet)
    
    delayed_stream_thread = DelayedRealTimeStream(collector, callback)
    
    protocol = zephyr.protocol.BioHarnessProtocol(ser, payload_parser.handle_message)
    protocol.enable_periodic_packets()
    
    delayed_stream_thread.start()
    
    threading.Thread(target=protocol.read_and_handle_forever).start()
    
    visualization = zephyr.visualization.VisualizationWindow(signal_collector)
    visualization.run()
    
    stream_thread.terminate()
    stream_thread.join()
def main():
    serial_port_dict = {"Darwin": "/dev/cu.BHBHT001931-iSerialPort1",
                        "Windows": 23}
    
    serial_port = serial_port_dict[platform.system()]
    ser = serial.Serial(serial_port)
    
    callback = lambda x: None
    protocol = zephyr.protocol.BioHarnessProtocol(ser, callback, "../test_data/120-second-bt-stream")
    protocol.enable_periodic_packets()
    
    start_time = time.time()
    while time.time() < start_time + 120:
        protocol.read_and_handle_bytes(1)
예제 #3
0
def main():
    serial_port_dict = {
        "Darwin": "/dev/cu.BHBHT001931-iSerialPort1",
        "Windows": 23
    }

    serial_port = serial_port_dict[platform.system()]
    ser = serial.Serial(serial_port)

    callback = lambda x: None
    protocol = zephyr.protocol.BioHarnessProtocol(
        ser, callback, "../test_data/120-second-bt-stream")
    protocol.enable_periodic_packets()

    start_time = time.time()
    while time.time() < start_time + 120:
        protocol.read_and_handle_bytes(1)
def create_data_files(input_definitions):
    threads = []
    
    try:
        for serial_i, (serial_port, enable_channels) in enumerate(input_definitions):
            payload_parser = zephyr.message.MessagePayloadParser([callback])
            
            ser = serial.Serial(serial_port)
            protocol = zephyr.protocol.BioHarnessProtocol(ser, payload_parser.handle_message, "../test_data/120-second-bt-stream-%d" % serial_i)
            
            if enable_channels:
                protocol.enable_periodic_packets()
            
            thread = threading.Thread(target=reading_thread, args=(protocol,))
            threads.append(thread)
            thread.start()
    
    finally:
        for thread in threads:
            thread.join()
def create_data_files(input_definitions):
    threads = []

    try:
        for serial_i, (serial_port,
                       enable_channels) in enumerate(input_definitions):
            payload_parser = zephyr.message.MessagePayloadParser([callback])
            ser = serial.Serial(serial_port)
            protocol = zephyr.protocol.BioHarnessProtocol(
                ser, payload_parser.handle_message,
                "../test_data/120-second-bt-stream-%d" % serial_i)

            if enable_channels:
                protocol.enable_periodic_packets()

            thread = threading.Thread(target=reading_thread, args=(protocol, ))
            threads.append(thread)
            thread.start()

    finally:
        for thread in threads:
            thread.join()
예제 #6
0
def main():
    zephyr.configure_root_logger()

    serial_port_dict = {
        "Darwin": "/dev/cu.BHBHT001931-iSerialPort1",
        "Windows": 25
    }

    serial_port = serial_port_dict[platform.system()]
    ser = serial.Serial(serial_port)

    collector = MeasurementCollector()
    rr_signal_analysis = BioHarnessSignalAnalysis([], [collector.handle_event])
    signal_packet_handlers = [
        collector.handle_signal, rr_signal_analysis.handle_signal
    ]

    signal_packet_handler = BioHarnessPacketHandler(signal_packet_handlers,
                                                    [collector.handle_event])

    payload_parser = MessagePayloadParser(signal_packet_handler.handle_packet)

    delayed_stream_thread = DelayedRealTimeStream(collector, callback)

    protocol = zephyr.protocol.BioHarnessProtocol(
        ser, payload_parser.handle_message)
    protocol.enable_periodic_packets()

    delayed_stream_thread.start()

    threading.Thread(target=protocol.read_and_handle_forever).start()

    visualization = zephyr.visualization.VisualizationWindow(signal_collector)
    visualization.run()

    stream_thread.terminate()
    stream_thread.join()