Tee block, bpsk eye

This commit is contained in:
2026-03-25 16:33:10 +01:00
parent 7766d9b91d
commit b57b85f959
3 changed files with 229 additions and 59 deletions

View File

@ -1,5 +1,3 @@
use core::sync;
use oxydsp_flowgraph::BlockIO;
use oxydsp_flowgraph::block::Block;
use oxydsp_flowgraph::block::BlockResult;
@ -348,3 +346,52 @@ impl<'view, I: 'static> SyncBlock<'view> for NullSink<I>
Some(())
}
}
#[derive(BlockIO)]
pub struct Tee<T: 'static + Clone>
{
#[input]
input: In<T>,
#[output]
output_a: Out<T>,
#[output]
output_b: Out<T>,
}
impl<T: 'static + Clone> Tee<T>
{
pub fn new(input: In<T>) -> (Self, In<T>, In<T>)
{
let (output_a, port_a) = stream();
let (output_b, port_b) = stream();
(
Self {
input,
output_a,
output_b,
},
port_a,
port_b,
)
}
}
impl<T: 'static + Clone> Block for Tee<T>
{
fn work(&mut self) -> BlockResult
{
let writer_a = self.output_a.write();
let writer_b = self.output_b.write();
for x in self
.input
.pop_iter()
.take(writer_a.len().min(writer_b.len()))
{
let _ = writer_a.push(x.clone());
let _ = writer_b.push(x);
}
BlockResult::Ok
}
}