Skip to content

Commit 9763cb6

Browse files
committed
reoganized command groups on extension call
1 parent 5ac49e1 commit 9763cb6

File tree

14 files changed

+382
-39
lines changed

14 files changed

+382
-39
lines changed

addons/main/functions/api/fn_send_digital_pointer_cot.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ if (!isNull _digitalPointer) then {
1010

1111
_dpCot = [_link_uid, _contact_callsign, _digitalPointerPosition select 1, _digitalPointerPosition select 2, _digitalPointerPosition select 3];
1212

13-
"armatak" callExtension ["tcp_socket:send_digital_pointer_cot", [_dpCot]];
13+
"armatak" callExtension ["tcp_socket:cot:digital_pointer", [_dpCot]];
1414
};

addons/main/functions/api/fn_send_enemy_cot.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ _callsign = _unit call armatak_fnc_extract_marker_callsign;
1212

1313
_marker_cot = [_uuid, _type, _unit_position select 1, _unit_position select 2, _unit_position select 3, _callsign, _unit_position select 5, _unit_position select 6];
1414

15-
"armatak" callExtension ["tcp_socket:send_marker_cot", [_marker_cot]];
15+
"armatak" callExtension ["tcp_socket:cot:marker", [_marker_cot]];

addons/main/functions/api/fn_send_eud_cot.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ _position = _unit call armatak_client_fnc_extractClientPosition;
99
_uuid = _unit call armatak_fnc_extract_uuid;
1010

1111
_eud_cot = [_uuid, _position select 1, _position select 2, _position select 3, _callsign, _group_name, _group_role, _position select 5, _position select 6];
12-
"armatak" callExtension ["tcp_socket:send_eud_cot", [_eud_cot]];
12+
"armatak" callExtension ["tcp_socket:cot:eud", [_eud_cot]];

addons/main/functions/api/fn_send_marker_cot.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ _uuid = _unit call armatak_fnc_extract_uuid;
1010

1111
_marker_cot = [_uuid, _type, _unit_position select 1, _unit_position select 2, _unit_position select 3, _callsign, _unit_position select 5, _unit_position select 6];
1212

13-
"armatak" callExtension ["tcp_socket:send_marker_cot", [_marker_cot]];
13+
"armatak" callExtension ["tcp_socket:cot:marker", [_marker_cot]];

addons/main/functions/extract_data/fn_extract_role.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,4 @@ if (!isNil "armatak_attribute_marker_type" or armatak_attribute_marker_type != '
123123
_role = armatak_attribute_marker_type;
124124
};
125125

126-
_role
126+
_role

addons/main/functions/extract_data/fn_extract_sensor_data.sqf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ _target = getSensorTargets (_unit);
2222

2323
_marker_cot = [_uuid, _type, _unit_position select 1, _unit_position select 2, _unit_position select 3, _callsign, _unit_position select 5, _unit_position select 6];
2424

25-
"armatak" callExtension ["tcp_socket:send_marker_cot", [_marker_cot]];
25+
"armatak" callExtension ["tcp_socket:cot:marker", [_marker_cot]];
2626
};
27-
} forEach _target;
27+
} forEach _target;

src/cot/draws/circle.rs

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
use arma_rs::{FromArma, FromArmaError};
2+
3+
pub struct CircleCoTPayload {
4+
pub uuid: String,
5+
pub center_lat: f64,
6+
pub center_lon: f64,
7+
pub center_hae: f32,
8+
pub major: f64,
9+
pub minor: f64,
10+
pub angle: f32,
11+
pub callsign: String,
12+
pub creator_uid: String,
13+
pub creator_callsign: String,
14+
}
15+
16+
impl FromArma for CircleCoTPayload {
17+
fn from_arma(data: String) -> Result<Self, FromArmaError> {
18+
let (
19+
uuid,
20+
center_lat,
21+
center_lon,
22+
center_hae,
23+
major,
24+
minor,
25+
angle,
26+
callsign,
27+
creator_uid,
28+
creator_callsign,
29+
) = <(String, f64, f64, f32, f64, f64, f32, String, String, String)>::from_arma(data)?;
30+
31+
Ok(Self {
32+
uuid,
33+
center_lat,
34+
center_lon,
35+
center_hae,
36+
major,
37+
minor,
38+
angle,
39+
callsign,
40+
creator_uid,
41+
creator_callsign,
42+
})
43+
}
44+
}
45+
46+
pub struct ShapeCircleCoT {
47+
pub uid: String,
48+
pub lat: f64,
49+
pub lon: f64,
50+
pub hae: f32,
51+
pub major: f64,
52+
pub minor: f64,
53+
pub angle: f32,
54+
pub callsign: String,
55+
pub creator_uid: String,
56+
pub creator_callsign: String,
57+
}
58+
59+
impl CircleCoTPayload {
60+
pub fn to_cot(&self) -> ShapeCircleCoT {
61+
ShapeCircleCoT {
62+
uid: self.uuid.clone(),
63+
lat: self.center_lat,
64+
lon: self.center_lon,
65+
hae: self.center_hae,
66+
major: self.major,
67+
minor: self.minor,
68+
angle: self.angle,
69+
callsign: self.callsign.clone(),
70+
creator_uid: self.creator_uid.clone(),
71+
creator_callsign: self.creator_callsign.clone(),
72+
}
73+
}
74+
}
75+
76+
impl ShapeCircleCoT {
77+
pub fn to_xml(&self, now: &str, stale: &str) -> String {
78+
format!(
79+
r#"<event version="2.0" uid="{uid}" type="u-d-c-c"
80+
time="{t}" start="{t}" stale="{stale}"
81+
how="h-e" access="Undefined">
82+
<point lat="{lat}" lon="{lon}" hae="{hae}" ce="10.9" le="9999999.0" />
83+
<detail>
84+
<shape>
85+
<ellipse major="{major}" minor="{minor}" angle="{angle}" />
86+
<link uid="{uid}.Style" type="b-x-KmlStyle" relation="p-c">
87+
<Style>
88+
<LineStyle>
89+
<color>ffffffff</color>
90+
<width>3.0</width>
91+
</LineStyle>
92+
<PolyStyle>
93+
<color>96ffffff</color>
94+
</PolyStyle>
95+
</Style>
96+
</link>
97+
<link uid="{creator_uid}" type="self" relation="p-p-CenterAnchor" />
98+
</shape>
99+
<__shapeExtras cpvis="true" editable="true" />
100+
<remarks />
101+
<contact callsign="{callsign}" />
102+
<creator uid="{creator_uid}" callsign="{creator_callsign}" time="{t}" type="a-f-G-U-C" />
103+
<archive />
104+
<labels_on value="true" />
105+
<strokeColor value="-1" />
106+
<strokeWeight value="3.0" />
107+
<strokeStyle value="solid" />
108+
<fillColor value="-1761607681" />
109+
<precisionlocation altsrc="GPS" geopointsrc="GPS" />
110+
</detail>
111+
</event>"#,
112+
uid = self.uid,
113+
t = now,
114+
stale = stale,
115+
lat = self.lat,
116+
lon = self.lon,
117+
hae = self.hae,
118+
major = self.major,
119+
minor = self.minor,
120+
angle = self.angle,
121+
callsign = self.callsign,
122+
creator_uid = self.creator_uid,
123+
creator_callsign = self.creator_callsign
124+
)
125+
}
126+
}

src/cot/draws/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod circle;

src/cot/message.rs

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
use arma_rs::{FromArma, FromArmaError};
2+
use chrono::{Utc, Duration, SecondsFormat};
3+
use uuid::Uuid;
4+
5+
pub struct MessagePayload {
6+
pub sender_callsign: String,
7+
pub chatroom: String,
8+
pub message_text: String,
9+
pub point_lat: f64,
10+
pub point_lon: f64,
11+
pub point_hae: f32,
12+
pub sender_uid: String,
13+
}
14+
15+
impl FromArma for MessagePayload {
16+
fn from_arma(data: String) -> Result<Self, FromArmaError> {
17+
let (sender_callsign, chatroom, message_text,
18+
point_lat, point_lon, point_hae, sender_uid) =
19+
<(String, String, String, f64, f64, f32, String)>::from_arma(data)?;
20+
21+
Ok(Self {
22+
sender_callsign,
23+
chatroom,
24+
message_text,
25+
point_lat,
26+
point_lon,
27+
point_hae,
28+
sender_uid,
29+
})
30+
}
31+
}
32+
33+
pub struct MessageCot {
34+
pub sender_callsign: String,
35+
pub chatroom: String,
36+
pub message_text: String,
37+
pub point_lat: f64,
38+
pub point_lon: f64,
39+
pub point_hae: f32,
40+
pub sender_uid: String,
41+
}
42+
43+
impl MessageCot {
44+
pub fn from_payload(p: MessagePayload) -> Self {
45+
Self {
46+
sender_callsign: p.sender_callsign,
47+
chatroom: p.chatroom,
48+
message_text: p.message_text,
49+
point_lat: p.point_lat,
50+
point_lon: p.point_lon,
51+
point_hae: p.point_hae,
52+
sender_uid: p.sender_uid,
53+
}
54+
}
55+
56+
pub fn to_xml(&self) -> String {
57+
let created_time = Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true);
58+
let stale_time = (Utc::now() + Duration::days(1))
59+
.to_rfc3339_opts(SecondsFormat::Millis, true);
60+
61+
// MESSAGE ID (random UUID)
62+
let message_uuid = Uuid::new_v4().to_string();
63+
64+
// FULL EVENT UID
65+
// format: GeoChat.{sender}.{chatroom}.{uuid}
66+
let event_uid = format!(
67+
"GeoChat.{}.{}.{}",
68+
self.sender_uid,
69+
self.chatroom.replace(" ", "_"),
70+
message_uuid,
71+
);
72+
73+
let mut xml = String::new();
74+
75+
xml.push_str("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
76+
77+
xml.push_str(
78+
format!(
79+
"<event version=\"2.0\" uid=\"{}\" type=\"b-t-f\" time=\"{}\" start=\"{}\" stale=\"{}\" how=\"h-g-i-g-o\" access=\"Undefined\">",
80+
event_uid, created_time, created_time, stale_time
81+
)
82+
.as_str(),
83+
);
84+
85+
xml.push_str(
86+
format!(
87+
"<point lat=\"{}\" lon=\"{}\" hae=\"{}\" ce=\"10.3\" le=\"9999999.0\"/>",
88+
self.point_lat, self.point_lon, self.point_hae
89+
)
90+
.as_str(),
91+
);
92+
93+
xml.push_str("<detail>");
94+
95+
// ========== CHAT OBJECT ==========
96+
97+
xml.push_str(
98+
format!(
99+
"<__chat parent=\"RootContactGroup\" groupOwner=\"false\" \
100+
messageId=\"{}\" chatroom=\"{}\" id=\"{}\" senderCallsign=\"{}\">",
101+
message_uuid,
102+
self.chatroom,
103+
self.chatroom,
104+
self.sender_callsign,
105+
)
106+
.as_str(),
107+
);
108+
109+
xml.push_str(
110+
format!(
111+
"<chatgrp uid0=\"{}\" uid1=\"{}\" id=\"{}\" />",
112+
self.sender_uid,
113+
self.chatroom,
114+
self.chatroom
115+
)
116+
.as_str(),
117+
);
118+
119+
xml.push_str("</__chat>");
120+
121+
// ========== LINK ELEMENT ==========
122+
xml.push_str(
123+
format!(
124+
"<link uid=\"{}\" type=\"a-f-G-U-C\" relation=\"p-p\" />",
125+
self.sender_uid
126+
)
127+
.as_str(),
128+
);
129+
130+
// ========== SERVER DEST ==========
131+
// This is optional — you may remove or customize it
132+
xml.push_str(
133+
format!(
134+
"<__serverdestination destinations=\"0.0.0.0:0:tcp:{}\" />",
135+
self.sender_uid
136+
)
137+
.as_str(),
138+
);
139+
140+
// ========== MESSAGE REMARKS ==========
141+
xml.push_str(
142+
format!(
143+
"<remarks source=\"ARMATAK.{}\" to=\"{}\" time=\"{}\">{}</remarks>",
144+
self.sender_uid, self.chatroom, created_time, self.message_text
145+
)
146+
.as_str(),
147+
);
148+
149+
xml.push_str("</detail></event>");
150+
151+
xml
152+
}
153+
}

src/cot/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
pub mod draws;
12
pub mod cot;
23
pub mod digital_pointer;
34
pub mod eud;
45
pub mod gps;
6+
pub mod message;
57
pub mod nato;

0 commit comments

Comments
 (0)