diff --git a/config.toml b/config.toml index 8b04baf..b9fac2a 100644 --- a/config.toml +++ b/config.toml @@ -3,6 +3,7 @@ server = "127.0.0.1:5002" [grpc] url = "http://127.0.0.1:50051/" +poll_rate = 10 [stt] url = "http://192.168.0.2:3000/" @@ -11,8 +12,3 @@ url = "http://192.168.0.2:3000/" frequency = 251250000 modulation = "Am" voice = "David" - -[channels.Magic1-1] -frequency = 266000000 -modulation = "Am" -voice = "Zira" diff --git a/crates/guardian_core/src/components/grpc_base_url.rs b/crates/guardian_core/src/components/grpc_base_url.rs index b306c21..30f9fc2 100644 --- a/crates/guardian_core/src/components/grpc_base_url.rs +++ b/crates/guardian_core/src/components/grpc_base_url.rs @@ -15,12 +15,16 @@ use serde::{Deserialize, Serialize}; pub struct GrpcBaseUrl { #[serde(skip)] hash: u64, + /// The URL of the DCS-gRPC Server url: Cow<'static, str>, + /// The poll rate for updating the mission situation in secononds. + /// Lower values might cause noticeable ingame lag spikes + poll_rate: Option, } impl Default for GrpcBaseUrl { fn default() -> Self { - GrpcBaseUrl::new("http://127.0.0.1:50051/") + GrpcBaseUrl::new("http://127.0.0.1:50051/", Some(10)) } } @@ -28,9 +32,13 @@ impl GrpcBaseUrl { /// Creates a new [`GrpcBaseUrl`] from any string-like type. /// /// The internal hash will be computed immediately. - pub fn new(url: impl Into>) -> Self { + pub fn new(url: impl Into>, poll_rate: Option) -> Self { let url = url.into(); - let mut url = GrpcBaseUrl { url, hash: 0 }; + let mut url = GrpcBaseUrl { + url, + hash: 0, + poll_rate, + }; url.update_hash(); url } @@ -40,7 +48,7 @@ impl GrpcBaseUrl { /// The internal hash will be re-computed. #[inline(always)] pub fn set(&mut self, url: impl Into>) { - *self = GrpcBaseUrl::new(url); + *self = GrpcBaseUrl::new(url, self.poll_rate); } /// Updates the url of the entity in place. @@ -59,6 +67,11 @@ impl GrpcBaseUrl { &self.url } + #[inline(always)] + pub fn poll_rate(&self) -> Option { + self.poll_rate + } + fn update_hash(&mut self) { let mut hasher = AHasher::default(); self.url.hash(&mut hasher); diff --git a/crates/guardian_core/src/components/srs_socket_addr.rs b/crates/guardian_core/src/components/srs_socket_addr.rs index 096649a..68636f4 100644 --- a/crates/guardian_core/src/components/srs_socket_addr.rs +++ b/crates/guardian_core/src/components/srs_socket_addr.rs @@ -4,7 +4,10 @@ use bevy::ecs::system::Resource; use serde::{Deserialize, Serialize}; #[derive(Debug, Resource, Clone, Deserialize, Serialize)] -pub struct SrsSocketAddr(SocketAddr); +pub struct SrsSocketAddr( + /// The server details for DCS-SRS + SocketAddr, +); impl Default for SrsSocketAddr { fn default() -> Self { diff --git a/crates/guardian_core/src/components/stt_base_url.rs b/crates/guardian_core/src/components/stt_base_url.rs index 0bb3cf0..f5316a9 100644 --- a/crates/guardian_core/src/components/stt_base_url.rs +++ b/crates/guardian_core/src/components/stt_base_url.rs @@ -15,6 +15,7 @@ use serde::{Deserialize, Serialize}; pub struct SttBaseUrl { #[serde(skip)] hash: u64, + /// The url to the [whisper-web](https://git.avii.nl/Guardian/whisper-web) instance url: Cow<'static, str>, } diff --git a/crates/guardian_core/src/dcs/mission.rs b/crates/guardian_core/src/dcs/mission.rs index 21d5f83..7c5420e 100644 --- a/crates/guardian_core/src/dcs/mission.rs +++ b/crates/guardian_core/src/dcs/mission.rs @@ -49,7 +49,9 @@ fn connect_to_grpc(mut commands: Commands, tokio: Res, url: Res, url: Res