mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 16:23:30 +00:00
Added report marker functions and stale time param to CoT type
This commit is contained in:
@@ -18,6 +18,7 @@ pub struct CursorOverTime {
|
||||
pub link_uid: Option<String>,
|
||||
pub remarker: Option<String>,
|
||||
pub video_url: Option<String>,
|
||||
pub stale_seconds: Option<i64>,
|
||||
}
|
||||
|
||||
impl CursorOverTime {
|
||||
@@ -34,8 +35,9 @@ impl CursorOverTime {
|
||||
|
||||
let created_time = Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true);
|
||||
|
||||
let stale_time =
|
||||
(Utc::now() + Duration::seconds(360)).to_rfc3339_opts(SecondsFormat::Millis, true);
|
||||
let stale_seconds = self.stale_seconds.unwrap_or(360).max(1);
|
||||
let stale_time = (Utc::now() + Duration::seconds(stale_seconds))
|
||||
.to_rfc3339_opts(SecondsFormat::Millis, true);
|
||||
|
||||
let mut xml = String::new();
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ impl DigitalPointerPayload {
|
||||
link_uid: Some(self.link_uid.clone()),
|
||||
remarker: None,
|
||||
video_url: None,
|
||||
stale_seconds: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ impl EudCoTPayload {
|
||||
link_uid: None,
|
||||
remarker: None,
|
||||
video_url: None,
|
||||
stale_seconds: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ impl ExternalPositionPayload {
|
||||
link_uid: None,
|
||||
remarker: Some(self.remarker.clone()),
|
||||
video_url: None,
|
||||
stale_seconds: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,5 +5,6 @@ pub mod eud;
|
||||
pub mod gps;
|
||||
pub mod message;
|
||||
pub mod nato;
|
||||
pub mod report_marker;
|
||||
pub mod uas;
|
||||
pub mod video;
|
||||
|
||||
@@ -87,6 +87,7 @@ impl MarkerCoTPayload {
|
||||
link_uid: None,
|
||||
remarker: None,
|
||||
video_url: self.video_url.clone(),
|
||||
stale_seconds: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
63
src/cot/report_marker.rs
Normal file
63
src/cot/report_marker.rs
Normal file
@@ -0,0 +1,63 @@
|
||||
use arma_rs::{FromArma, FromArmaError};
|
||||
|
||||
use super::cot::CursorOverTime;
|
||||
|
||||
pub struct ReportMarkerCoTPayload {
|
||||
pub uuid: String,
|
||||
pub r#type: String,
|
||||
pub point_lat: f64,
|
||||
pub point_lon: f64,
|
||||
pub point_hae: f32,
|
||||
pub contact_callsign: String,
|
||||
pub stale_seconds: i64,
|
||||
pub remarks: String,
|
||||
}
|
||||
|
||||
impl FromArma for ReportMarkerCoTPayload {
|
||||
fn from_arma(data: String) -> Result<ReportMarkerCoTPayload, FromArmaError> {
|
||||
let (
|
||||
uuid,
|
||||
r#type,
|
||||
point_lat,
|
||||
point_lon,
|
||||
point_hae,
|
||||
contact_callsign,
|
||||
stale_seconds,
|
||||
remarks,
|
||||
) = <(String, String, f64, f64, f32, String, i64, String)>::from_arma(data)?;
|
||||
|
||||
Ok(Self {
|
||||
uuid,
|
||||
r#type,
|
||||
point_lat,
|
||||
point_lon,
|
||||
point_hae,
|
||||
contact_callsign,
|
||||
stale_seconds,
|
||||
remarks,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ReportMarkerCoTPayload {
|
||||
pub fn to_cot(&self) -> CursorOverTime {
|
||||
CursorOverTime {
|
||||
uuid: Some(self.uuid.clone()),
|
||||
r#type: Some(self.r#type.clone()),
|
||||
point_lat: self.point_lat,
|
||||
point_lon: self.point_lon,
|
||||
point_hae: self.point_hae,
|
||||
point_ce: None,
|
||||
point_le: None,
|
||||
contact_callsign: self.contact_callsign.clone(),
|
||||
group_name: None,
|
||||
group_role: None,
|
||||
track_course: None,
|
||||
track_speed: None,
|
||||
link_uid: None,
|
||||
remarker: Some(self.remarks.clone()),
|
||||
video_url: None,
|
||||
stale_seconds: Some(self.stale_seconds),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
use arma_rs::{arma, Extension, Group};
|
||||
use rustls::crypto::aws_lc_rs;
|
||||
mod uas;
|
||||
mod mdns;
|
||||
mod structs;
|
||||
mod tcp;
|
||||
@@ -77,6 +76,7 @@ pub fn init() -> Extension {
|
||||
Group::new()
|
||||
.command("eud", tcp::cot::send_eud_cot)
|
||||
.command("marker", tcp::cot::send_marker_cot)
|
||||
.command("report_marker", tcp::cot::send_report_marker_cot)
|
||||
.command("digital_pointer", tcp::cot::send_digital_pointer_cot)
|
||||
.command("chat", tcp::cot::send_message_cot)
|
||||
.command("uas_platform", tcp::cot::send_uas_platform_cot)
|
||||
|
||||
Reference in New Issue
Block a user