Starting fsk demod
This commit is contained in:
@ -9,8 +9,10 @@ pub enum BlockResult
|
||||
|
||||
// Signifies that the block finished its work
|
||||
// Running it again would be useless
|
||||
// This triggers the graph shutdown
|
||||
Terminated,
|
||||
|
||||
// Kill graph
|
||||
Exit,
|
||||
}
|
||||
|
||||
pub trait BlockIO
|
||||
|
||||
5
oxydsp-flowgraph/src/event.rs
Normal file
5
oxydsp-flowgraph/src/event.rs
Normal file
@ -0,0 +1,5 @@
|
||||
// Represents a FlowGrahWide, simultaneous event
|
||||
pub enum FlowGraphEvent
|
||||
{
|
||||
Kill(String),
|
||||
}
|
||||
@ -49,20 +49,15 @@ impl FlowGraph
|
||||
crate::block::BlockResult::Ok =>
|
||||
{}
|
||||
crate::block::BlockResult::Terminated =>
|
||||
{ //break 'outer;
|
||||
}
|
||||
crate::block::BlockResult::Exit =>
|
||||
{
|
||||
break 'outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _ in 0..10_000
|
||||
{
|
||||
for x in self.blocks.iter_mut()
|
||||
{
|
||||
x.work();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -131,7 +131,7 @@ impl<T: 'static> Out<T>
|
||||
}
|
||||
}
|
||||
|
||||
pub fn push_iter<I: Iterator<Item = (T, Option<Tag>)>>(&mut self, mut iter: I) -> bool
|
||||
pub fn push_iter<I: Iterator<Item = Tagged<T>>>(&mut self, mut iter: I) -> bool
|
||||
{
|
||||
let writer = self.write();
|
||||
let len = writer.len();
|
||||
@ -140,17 +140,7 @@ impl<T: 'static> Out<T>
|
||||
{
|
||||
if let Some(elt) = iter.next()
|
||||
{
|
||||
match elt.1
|
||||
{
|
||||
Some(tag) =>
|
||||
{
|
||||
let _ = writer.push(Tagged(elt.0, Some(tag)));
|
||||
}
|
||||
None =>
|
||||
{
|
||||
let _ = writer.push_no_tag(elt.0);
|
||||
}
|
||||
}
|
||||
let _ = writer.push(elt);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -220,7 +210,13 @@ impl<T> OutWriter<'_, T>
|
||||
|
||||
pub fn push(&self, data: Tagged<T>) -> Result<(), Tagged<T>>
|
||||
{
|
||||
let (data, tag) = data.into();
|
||||
let (data, mut tag) = data.into();
|
||||
let position = self.data_writer.next_index();
|
||||
if let Some(tag) = &mut tag
|
||||
{
|
||||
tag.position = position
|
||||
}
|
||||
|
||||
match self.data_writer.push(data)
|
||||
{
|
||||
Ok(_) if tag.is_some() =>
|
||||
|
||||
@ -3,8 +3,10 @@
|
||||
|
||||
pub mod block;
|
||||
pub mod edge;
|
||||
pub mod event;
|
||||
pub mod graph;
|
||||
pub mod io;
|
||||
pub mod stream;
|
||||
pub mod tag;
|
||||
pub use oxydsp_flowgraph_macros::{BlockIO, sync_block};
|
||||
pub use oxydsp_flowgraph_macros::BlockIO;
|
||||
pub use oxydsp_flowgraph_macros::sync_block;
|
||||
|
||||
@ -22,6 +22,14 @@ pub struct Tag
|
||||
|
||||
impl Tag
|
||||
{
|
||||
pub fn new() -> Self
|
||||
{
|
||||
Self {
|
||||
position: 0,
|
||||
data: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn merge_tag_opts<const N: usize>(tag_opts: [Option<Tag>; N]) -> Option<Tag>
|
||||
{
|
||||
let mut out_tag = None;
|
||||
@ -31,6 +39,27 @@ impl Tag
|
||||
}
|
||||
out_tag
|
||||
}
|
||||
|
||||
pub fn tag<T: 'static + Send + Sync>(&self, key: impl AsRef<str>, value: T)
|
||||
{
|
||||
self.data
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(key.as_ref().to_owned(), Arc::new(value));
|
||||
}
|
||||
|
||||
pub fn retrieve(&self, key: impl AsRef<str>) -> Option<Arc<dyn Any + Send + Sync>>
|
||||
{
|
||||
self.data.lock().unwrap().get(key.as_ref()).cloned()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Tag
|
||||
{
|
||||
fn default() -> Self
|
||||
{
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TagValue: Clone {}
|
||||
@ -93,6 +122,10 @@ impl<T> Tagged<T>
|
||||
{
|
||||
pub fn new(inner: T, tag: Option<Tag>) -> Self
|
||||
{
|
||||
if tag.is_none()
|
||||
{
|
||||
//println!("data has no tag");
|
||||
}
|
||||
Self(inner, tag)
|
||||
}
|
||||
|
||||
@ -156,11 +189,11 @@ impl<T> From<(T, Option<Tag>)> for Tagged<T>
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Into<(T, Option<Tag>)> for Tagged<T>
|
||||
impl<T> From<Tagged<T>> for (T, Option<Tag>)
|
||||
{
|
||||
fn into(self) -> (T, Option<Tag>)
|
||||
fn from(val: Tagged<T>) -> Self
|
||||
{
|
||||
(self.0, self.1)
|
||||
(val.0, val.1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user