Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions statime/src/ctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use std::{
};

use crate::{
daemon::{Config, ObservableState, config::CliArg, tracing::LogLevel},
daemon::{
Config, ObservableState, config::CliArg, observer::ObservableDrivenLink, tracing::LogLevel,
},
force_sync,
};
use tokio::runtime::Builder;
Expand Down Expand Up @@ -400,25 +402,41 @@ async fn print_spawners(observe_socket: PathBuf) -> Result<ExitCode, std::io::Er
};

for spawner in output.spawners {
println!("{:?}", spawner.id);
println!("\tSpawn state: {:?}", spawner.spawn_state);

println!("\tCurrent timeout: {:?}", spawner.current_timeout);

println!("\tLast spawn: {:?}", spawner.last_spawn);

if !spawner.driven_links.is_empty() {
println!("\tLinks:");
for link in spawner.driven_links {
println!("\t\t{}: {:?}", link.source_type, link.link_id);
}
let link_info = if spawner.desired_links > 1 {
&format!(" {}/{}", spawner.driven_links.len(), spawner.desired_links)
} else {
""
};
println!(
"{}. {}{}: {}",
spawner.id, spawner.kind, link_info, spawner.name
);
for link in spawner.driven_links {
print_link(&link);
}
println!();
}

Ok(ExitCode::SUCCESS)
}

fn print_link(link: &ObservableDrivenLink) {
println!(
"{} ({})",
link.network_address.as_ref().unwrap_or(&link.name),
if link.active { "Active" } else { "Inactive" }
);
println!("\tOffset:\t\t{:+.6}", link.offset);
println!(
"\tDelay:\t\t±{:.6}",
link.delay.unwrap_or(statime_base::Duration::ZERO)
);
println!(
"\tPoll interval:\t{:.6?}",
link.request_interval.unwrap_or(core::time::Duration::ZERO)
);
}

#[cfg(test)]
mod tests {
use std::path::Path;
Expand Down
8 changes: 7 additions & 1 deletion statime/src/daemon/spawn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::sync::Mutex;
use std::{
borrow::Cow,
fmt,
fmt::{self, Display},
future::Future,
net::SocketAddr,
ops::Deref,
Expand Down Expand Up @@ -59,6 +59,12 @@ impl Default for SpawnerId {
}
}

impl Display for SpawnerId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LinkTerminationReason {
MustDemobilize,
Expand Down
Loading