configurable poll_rate
This commit is contained in:
@@ -3,6 +3,7 @@ server = "127.0.0.1:5002"
|
|||||||
|
|
||||||
[grpc]
|
[grpc]
|
||||||
url = "http://127.0.0.1:50051/"
|
url = "http://127.0.0.1:50051/"
|
||||||
|
poll_rate = 10
|
||||||
|
|
||||||
[stt]
|
[stt]
|
||||||
url = "http://192.168.0.2:3000/"
|
url = "http://192.168.0.2:3000/"
|
||||||
@@ -11,8 +12,3 @@ url = "http://192.168.0.2:3000/"
|
|||||||
frequency = 251250000
|
frequency = 251250000
|
||||||
modulation = "Am"
|
modulation = "Am"
|
||||||
voice = "David"
|
voice = "David"
|
||||||
|
|
||||||
[channels.Magic1-1]
|
|
||||||
frequency = 266000000
|
|
||||||
modulation = "Am"
|
|
||||||
voice = "Zira"
|
|
||||||
|
|||||||
@@ -15,12 +15,16 @@ use serde::{Deserialize, Serialize};
|
|||||||
pub struct GrpcBaseUrl {
|
pub struct GrpcBaseUrl {
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
hash: u64,
|
hash: u64,
|
||||||
|
/// The URL of the DCS-gRPC Server
|
||||||
url: Cow<'static, str>,
|
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<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for GrpcBaseUrl {
|
impl Default for GrpcBaseUrl {
|
||||||
fn default() -> Self {
|
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.
|
/// Creates a new [`GrpcBaseUrl`] from any string-like type.
|
||||||
///
|
///
|
||||||
/// The internal hash will be computed immediately.
|
/// The internal hash will be computed immediately.
|
||||||
pub fn new(url: impl Into<Cow<'static, str>>) -> Self {
|
pub fn new(url: impl Into<Cow<'static, str>>, poll_rate: Option<u32>) -> Self {
|
||||||
let url = url.into();
|
let url = url.into();
|
||||||
let mut url = GrpcBaseUrl { url, hash: 0 };
|
let mut url = GrpcBaseUrl {
|
||||||
|
url,
|
||||||
|
hash: 0,
|
||||||
|
poll_rate,
|
||||||
|
};
|
||||||
url.update_hash();
|
url.update_hash();
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
@@ -40,7 +48,7 @@ impl GrpcBaseUrl {
|
|||||||
/// The internal hash will be re-computed.
|
/// The internal hash will be re-computed.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn set(&mut self, url: impl Into<Cow<'static, str>>) {
|
pub fn set(&mut self, url: impl Into<Cow<'static, str>>) {
|
||||||
*self = GrpcBaseUrl::new(url);
|
*self = GrpcBaseUrl::new(url, self.poll_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the url of the entity in place.
|
/// Updates the url of the entity in place.
|
||||||
@@ -59,6 +67,11 @@ impl GrpcBaseUrl {
|
|||||||
&self.url
|
&self.url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn poll_rate(&self) -> Option<u32> {
|
||||||
|
self.poll_rate
|
||||||
|
}
|
||||||
|
|
||||||
fn update_hash(&mut self) {
|
fn update_hash(&mut self) {
|
||||||
let mut hasher = AHasher::default();
|
let mut hasher = AHasher::default();
|
||||||
self.url.hash(&mut hasher);
|
self.url.hash(&mut hasher);
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ use bevy::ecs::system::Resource;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Resource, Clone, 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 {
|
impl Default for SrsSocketAddr {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
pub struct SttBaseUrl {
|
pub struct SttBaseUrl {
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
hash: u64,
|
hash: u64,
|
||||||
|
/// The url to the [whisper-web](https://git.avii.nl/Guardian/whisper-web) instance
|
||||||
url: Cow<'static, str>,
|
url: Cow<'static, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ fn connect_to_grpc(mut commands: Commands, tokio: Res<TokioResource>, url: Res<G
|
|||||||
|
|
||||||
let (tx, task) = unbounded();
|
let (tx, task) = unbounded();
|
||||||
|
|
||||||
|
let poll_rate = url.poll_rate();
|
||||||
let url = url.to_string();
|
let url = url.to_string();
|
||||||
|
|
||||||
handle.spawn(async move {
|
handle.spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
let Ok(mut client) = MissionServiceClient::connect(url.clone()).await else {
|
let Ok(mut client) = MissionServiceClient::connect(url.clone()).await else {
|
||||||
@@ -61,7 +63,7 @@ fn connect_to_grpc(mut commands: Commands, tokio: Res<TokioResource>, url: Res<G
|
|||||||
|
|
||||||
let Ok(mut stream) = client
|
let Ok(mut stream) = client
|
||||||
.stream_units(StreamUnitsRequest {
|
.stream_units(StreamUnitsRequest {
|
||||||
poll_rate: Some(10),
|
poll_rate,
|
||||||
max_backoff: Some(30),
|
max_backoff: Some(30),
|
||||||
category: Airplane as i32,
|
category: Airplane as i32,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user