-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23395e2
commit 7b42510
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use crate::{ | ||
core::{MachineType, Object, Repository}, | ||
global, | ||
runtime::{CommandSender, NullConfig, Service, ServiceContext, SignalReceiver}, | ||
}; | ||
|
||
pub struct Distributor { | ||
repository: Repository, | ||
} | ||
|
||
impl Service<NullConfig> for Distributor { | ||
fn new(_: NullConfig) -> Self | ||
where | ||
Self: Sized, | ||
{ | ||
Self { | ||
repository: Repository::new(global::instance().clone(), MachineType::Excavator), | ||
} | ||
} | ||
|
||
fn ctx(&self) -> ServiceContext { | ||
ServiceContext::new("distributor") | ||
} | ||
|
||
async fn wait_io_sub(&mut self, _command_tx: CommandSender, mut signal_rx: SignalReceiver) { | ||
while let Ok(signal) = signal_rx.recv().await { | ||
match signal { | ||
Object::Engine(engine) => { | ||
self.repository.engine = engine; | ||
} | ||
Object::Rotator(rotator) => { | ||
self.repository.rotator.insert(rotator.source, rotator); | ||
// debug!("Rotator size {}", self.repository.rotator.len()); | ||
} | ||
Object::ModuleStatus(status) => { | ||
self.repository | ||
.module_status | ||
.insert(status.name.clone(), status); | ||
// debug!("Module status size {}", self.repository.module_status.len()); | ||
} | ||
Object::Control(control) => { | ||
self.repository.control.insert(control); | ||
// debug!("Control size {}", self.repository.control.len()); | ||
} | ||
_ => {} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
pub use authority::{NetworkAuthority, NetworkConfig}; | ||
pub use director::Director; | ||
pub use distributor::Distributor; | ||
pub use server::{UnixServer, UnixServerConfig}; | ||
|
||
mod authority; | ||
mod director; | ||
mod distributor; | ||
mod server; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters