Adds parent ID to LedPump
Introduces a `parent_organ_id` field to the `LedPump` struct and updates its constructor. This establishes a clear hierarchical link, allowing a `LedPump` instance to identify its containing organ. Additionally, changes the `last_beat` field type from `u128` to `u64` for optimized storage of beat tracking data.
This commit is contained in:
parent
d5ad70666e
commit
ef10ab5998
2 changed files with 6 additions and 5 deletions
|
|
@ -4,7 +4,8 @@ use crate::protocols::{OrganCommand, OrganCommandEnvelope, OrganResponse};
|
|||
|
||||
pub struct LedPump {
|
||||
id: u32,
|
||||
last_beat: u128,
|
||||
parent_organ_id: u32,
|
||||
last_beat: u64,
|
||||
}
|
||||
|
||||
impl_identifiable!(LedPump, {
|
||||
|
|
@ -19,9 +20,10 @@ impl_identifiable!(LedPump, {
|
|||
});
|
||||
|
||||
impl LedPump {
|
||||
pub fn new(id: u32) -> Self {
|
||||
pub fn new(id: u32, parent_organ_id: u32) -> Self {
|
||||
Self {
|
||||
id,
|
||||
parent_organ_id,
|
||||
last_beat: 0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,9 +57,8 @@ impl OrganFactory {
|
|||
feedback_to_brain_tx
|
||||
);
|
||||
|
||||
|
||||
let last_parenchyma_id = organ_id;
|
||||
let led_pump = LedPump::new(OrganFactory::next_parenchyma_id(last_parenchyma_id));
|
||||
let led_pump = LedPump::new(OrganFactory::next_parenchyma_id(last_parenchyma_id), organ_id);
|
||||
heart.add_parenchyma(Box::new(led_pump));
|
||||
heart.start();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue