mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-26 00:24:55 +01:00
Add sensors registry to global registries
This commit is contained in:
parent
fc1480314f
commit
637490bd75
@ -2,6 +2,7 @@ mod actuators;
|
|||||||
mod sensors;
|
mod sensors;
|
||||||
|
|
||||||
pub use actuators::{Actuator, ActBox};
|
pub use actuators::{Actuator, ActBox};
|
||||||
|
pub use sensors::{Sensor, SensBox};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
/// BFFH registries
|
/// BFFH registries
|
||||||
@ -10,12 +11,14 @@ pub use actuators::{Actuator, ActBox};
|
|||||||
/// reference, not clone the registries
|
/// reference, not clone the registries
|
||||||
pub struct Registries {
|
pub struct Registries {
|
||||||
pub actuators: actuators::Actuators,
|
pub actuators: actuators::Actuators,
|
||||||
|
pub sensors: sensors::Sensors,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Registries {
|
impl Registries {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Registries {
|
Registries {
|
||||||
actuators: actuators::Actuators::new()
|
actuators: actuators::Actuators::new(),
|
||||||
|
sensors: sensors::Sensors::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,19 @@ use std::sync::Arc;
|
|||||||
use smol::lock::RwLock;
|
use smol::lock::RwLock;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct Sensors {
|
pub struct Sensors {
|
||||||
inner: Arc<RwLock<Inner>>,
|
inner: Arc<RwLock<Inner>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sensors {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Sensors {
|
||||||
|
inner: Arc::new(RwLock::new(Inner::new())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub type SensBox<'a> = Box<dyn Sensor<'a>>;
|
pub type SensBox<'a> = Box<dyn Sensor<'a>>;
|
||||||
type Inner = HashMap<String, SensBox<'static>>;
|
type Inner = HashMap<String, SensBox<'static>>;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user