node-red-contrib-tak
Version:
Node-RED Nodes for encoding & decoding TAK Protocol and Cursor on Target messages from TAK Products.
257 lines (231 loc) • 7.32 kB
HTML
<!--
/* TAK Node-RED Nodes.
Copyright Sensors & Signals LLC https://www.snstac.com/
Licensed under the Apache License, Version 2.0 (the 'License');
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an 'AS IS' BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/* jslint node: true */
/* jslint white: true */
-->
<script type="text/javascript">
RED.nodes.registerType("tak", {
category: "parser",
color: "#a6bbcf",
inputs: 1,
outputs: 3,
icon: "tak.png",
inputLabels: "CoT as a Buffer, String or Object.",
outputLabels: ["CoT XML or JSON", "Multicast Protobuf", "Stream Protobuf"],
defaults: {
name: { value: "TAK" },
},
label: function () {
return this.name || "TAK";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
});
</script>
<script type="text/html" data-template-name="tak">
<div class="form-row">
<label for="node-input-name"
><i class="fa fa-tag"></i>
<span data-i18n="node-red:common.label.name"></span
></label>
<input
type="text"
id="node-input-name"
data-i18n="node-red:[placeholder]common.label.name"
/>
</div>
<div class="form-row">
<label for="node-input-property"
><i class="fa fa-ellipsis-h"></i>
<span data-i18n="node-red:common.label.property"></span
></label>
<input
type="text"
id="node-input-property"
style="width:70%;"
placeholder="payload"
/>
</div>
<hr align="middle" />
<div class="form-row">
<label style="width:100%;"
><span data-i18n="node-red:xml.label.x2o"></span
></label>
</div>
<div class="form-row" style="padding-left: 20px;">
<label
style="width:250px;"
for="node-input-attr"
data-i18n="node-red:xml.label.represent"
></label>
<input
type="text"
id="node-input-attr"
style="text-align:center; width:100px"
placeholder="_attributes"
/>
</div>
<div class="form-row" style="padding-left: 20px;">
<label
style="width:250px;"
for="node-input-chr"
data-i18n="node-red:xml.label.prefix"
></label>
<input
type="text"
id="node-input-chr"
style="text-align:center; width:40px"
placeholder="_"
/>
</div>
</script>
<script type="text/html" data-help-name="tak">
<p>
A encoder & decoder for
<a href="https://www.tak.gov">Team Awareness Kit (TAK)</a> Cursor on Target
(CoT) messages. Supports plain XML ("'Traditional' TAK Protocol Version 0"),
Multicast ("mesh SA") & Stream Protobuf messages ("TAK Protocol Version 1").
</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object | buffer | string</span></dt>
<dd>One of:</dd>
<ol>
<li>object: A JavaScript-native Object containing CoT details.</li>
<li>
buffer: Raw output from a network socket, for example, tcp-in or udp-in.
</li>
<li>string: Plain XML CoT as a String.</li>
</ol>
</dl>
<h3>Outputs</h3>
This node hast 3 different outputs:
<ol>
<li>
<dl class="message-properties">
<dt>payload <span class="property-type">object | string</span></dt>
<dd>
<ul>
<li>
If the input is a string it tries to parse it as XML and creates a
JavaScript object.
</li>
<li>
If the input is a JavaScript object it tries to build an XML
string.
</li>
</ul>
</dd>
</dl>
</li>
<li>
<dl class="message-properties">
<dt>payload <span class="property-type">buffer</span></dt>
<dd>CoT as Multicast Protobuf format.</dd>
</dl>
</li>
<li>
<dl class="message-properties">
<dt>payload <span class="property-type">buffer</span></dt>
<dd>CoT as Stream Protobuf format.</dd>
</dl>
</li>
</ol>
<h3>Details</h3>
<h4>Example Input CoT JavaScript-native Object:</h4>
<pre>
{
'event': {
'_attributes': {
'version': '2.0',
'time': new Date(Date.now()).toISOString(),
'start': new Date(Date.now()).toISOString(),
'stale': new Date(Date.now() + 500000).toISOString(),
'type': 'a-u-G',
'uid': 'UID-12345',
'how': 'm-r'
},
'point': {
'_attributes': {
'lat': '1.2',
'lon': '-2.3',
'hae': "999999.0",
'le': "999999.0",
'ce': "999999.0",
}
}
}
}</pre
>
<h4>Example Output CoT XML:</h4>
<pre>
<?xml version="1.0" encoding="UTF-8"?><event version="2.0" time="2022-10-05T05:11:47.992Z" start="2022-10-05T05:11:47.992Z" stale="2022-10-05T05:20:07.992Z" type="a-u-G" uid="UID-12345" how="m-r"><point lat="1.2" lon="-2.3" hae="999999.0" le="999999.0" ce="999999.0"/></event></pre
>
</script>
<script type="text/javascript">
RED.nodes.registerType("tak2wm", {
category: "location",
color: "#a6bbcf",
inputs: 1,
outputs: 1,
icon: "tak.png",
defaults: {
name: { value: "TAK2Worldmap" },
},
label: function () {
return this.name || "TAK2Worldmap";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
});
</script>
<script type="text/html" data-template-name="tak2wm">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name" />
</div>
</script>
<script type="text/html" data-help-name="tak2wm">
<p>
Serializes
<a href="https://www.tak.gov">Team Awareness Kit (TAK)</a> Cursor-on-Target
(CoT) as
<a href="https://github.com/dceejay/RedMap">Node-RED Worldmap</a> objects.
</p>
<h3>Input</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>CoT XML</dd>
</dl>
<h4>Example Input CoT XML:</h4>
<pre>
<?xml version="1.0" encoding="UTF-8"?><event version="2.0" time="2022-10-05T05:11:47.992Z" start="2022-10-05T05:11:47.992Z" stale="2022-10-05T05:20:07.992Z" type="a-u-G" uid="UID-12345" how="m-r"><point lat="1.2" lon="-2.3" hae="999999.0" le="999999.0" ce="999999.0"/></event></pre
>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>Worldmap object from parsed CoT XML.</dd>
</dl>
<h4>Example Output:</h4>
<pre>
{
"name": "UID-12345",
"lat": 1.2,
"lon": -2.3,
"SIDC": "suGp-----------"
}</pre
>
</script>