cleanup
This commit is contained in:
@@ -144,15 +144,24 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
let mut tlm = Telemetry::new("http://[::1]:50051").await?;
|
||||
|
||||
let index_handle = tlm
|
||||
.register("simple_producer/time_offset".into(), TelemetryDataType::Float64)
|
||||
.register(
|
||||
"simple_producer/time_offset".into(),
|
||||
TelemetryDataType::Float64,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let publish_offset = tlm
|
||||
.register("simple_producer/publish_offset".into(), TelemetryDataType::Float64)
|
||||
.register(
|
||||
"simple_producer/publish_offset".into(),
|
||||
TelemetryDataType::Float64,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let await_offset = tlm
|
||||
.register("simple_producer/await_offset".into(), TelemetryDataType::Float64)
|
||||
.register(
|
||||
"simple_producer/await_offset".into(),
|
||||
TelemetryDataType::Float64,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let sin_tlm_handle = tlm
|
||||
@@ -215,89 +224,75 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
next_time += Duration::from_millis(10);
|
||||
index += 1;
|
||||
tokio::time::sleep_until(next_time).await;
|
||||
let publish_time = start_time + chrono::TimeDelta::from_std(next_time - start_instant).unwrap();
|
||||
let publish_time =
|
||||
start_time + chrono::TimeDelta::from_std(next_time - start_instant).unwrap();
|
||||
let actual_time = Instant::now();
|
||||
tasks.push(index_handle
|
||||
.publish(
|
||||
Value::Float64((actual_time - next_time).as_secs_f64()),
|
||||
chrono::Utc::now(),
|
||||
));
|
||||
tasks.push(sin_tlm_handle
|
||||
.publish(
|
||||
Value::Float32((f32::TAU() * (index as f32) / (1000.0_f32)).sin()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(cos_tlm_handle
|
||||
.publish(
|
||||
Value::Float64((f64::TAU() * (index as f64) / (1000.0_f64)).cos()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(sin2_tlm_handle
|
||||
.publish(
|
||||
Value::Float32((f32::TAU() * (index as f32) / (500.0_f32)).sin()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(cos2_tlm_handle
|
||||
.publish(
|
||||
Value::Float64((f64::TAU() * (index as f64) / (500.0_f64)).cos()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(sin3_tlm_handle
|
||||
.publish(
|
||||
Value::Float32((f32::TAU() * (index as f32) / (333.0_f32)).sin()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(cos3_tlm_handle
|
||||
.publish(
|
||||
Value::Float64((f64::TAU() * (index as f64) / (333.0_f64)).cos()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(sin4_tlm_handle
|
||||
.publish(
|
||||
Value::Float32((f32::TAU() * (index as f32) / (250.0_f32)).sin()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(cos4_tlm_handle
|
||||
.publish(
|
||||
Value::Float64((f64::TAU() * (index as f64) / (250.0_f64)).cos()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(sin5_tlm_handle
|
||||
.publish(
|
||||
Value::Float32((f32::TAU() * (index as f32) / (200.0_f32)).sin()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(cos5_tlm_handle
|
||||
.publish(
|
||||
Value::Float64((f64::TAU() * (index as f64) / (200.0_f64)).cos()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(sin6_tlm_handle
|
||||
.publish(
|
||||
Value::Float32((f32::TAU() * (index as f32) / (166.0_f32)).sin()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(cos6_tlm_handle
|
||||
.publish(
|
||||
Value::Float64((f64::TAU() * (index as f64) / (166.0_f64)).cos()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(index_handle.publish(
|
||||
Value::Float64((actual_time - next_time).as_secs_f64()),
|
||||
chrono::Utc::now(),
|
||||
));
|
||||
tasks.push(sin_tlm_handle.publish(
|
||||
Value::Float32((f32::TAU() * (index as f32) / (1000.0_f32)).sin()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(cos_tlm_handle.publish(
|
||||
Value::Float64((f64::TAU() * (index as f64) / (1000.0_f64)).cos()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(sin2_tlm_handle.publish(
|
||||
Value::Float32((f32::TAU() * (index as f32) / (500.0_f32)).sin()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(cos2_tlm_handle.publish(
|
||||
Value::Float64((f64::TAU() * (index as f64) / (500.0_f64)).cos()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(sin3_tlm_handle.publish(
|
||||
Value::Float32((f32::TAU() * (index as f32) / (333.0_f32)).sin()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(cos3_tlm_handle.publish(
|
||||
Value::Float64((f64::TAU() * (index as f64) / (333.0_f64)).cos()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(sin4_tlm_handle.publish(
|
||||
Value::Float32((f32::TAU() * (index as f32) / (250.0_f32)).sin()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(cos4_tlm_handle.publish(
|
||||
Value::Float64((f64::TAU() * (index as f64) / (250.0_f64)).cos()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(sin5_tlm_handle.publish(
|
||||
Value::Float32((f32::TAU() * (index as f32) / (200.0_f32)).sin()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(cos5_tlm_handle.publish(
|
||||
Value::Float64((f64::TAU() * (index as f64) / (200.0_f64)).cos()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(sin6_tlm_handle.publish(
|
||||
Value::Float32((f32::TAU() * (index as f32) / (166.0_f32)).sin()),
|
||||
publish_time,
|
||||
));
|
||||
tasks.push(cos6_tlm_handle.publish(
|
||||
Value::Float64((f64::TAU() * (index as f64) / (166.0_f64)).cos()),
|
||||
publish_time,
|
||||
));
|
||||
|
||||
tasks.push(publish_offset
|
||||
.publish(
|
||||
Value::Float64((Instant::now() - actual_time).as_secs_f64()),
|
||||
chrono::Utc::now(),
|
||||
));
|
||||
tasks.push(publish_offset.publish(
|
||||
Value::Float64((Instant::now() - actual_time).as_secs_f64()),
|
||||
chrono::Utc::now(),
|
||||
));
|
||||
|
||||
for task in tasks.drain(..) {
|
||||
task.await?;
|
||||
}
|
||||
|
||||
tasks.push(await_offset
|
||||
.publish(
|
||||
Value::Float64((Instant::now() - actual_time).as_secs_f64()),
|
||||
chrono::Utc::now(),
|
||||
));
|
||||
tasks.push(await_offset.publish(
|
||||
Value::Float64((Instant::now() - actual_time).as_secs_f64()),
|
||||
chrono::Utc::now(),
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user