Skip to content

Instantly share code, notes, and snippets.

@ampledata
Created August 28, 2022 07:04
Show Gist options
  • Save ampledata/c9b9585df21026b13b4cc373fc4ed398 to your computer and use it in GitHub Desktop.
Save ampledata/c9b9585df21026b13b4cc373fc4ed398 to your computer and use it in GitHub Desktop.
Node-RED: JSON to cursor on target CoT example flow.
[
{
"id": "0b934157aa7465fa",
"type": "tab",
"label": "To CoT",
"disabled": false,
"info": "",
"env": []
},
{
"id": "ad9ed18733dcd7a0",
"type": "tak",
"z": "0b934157aa7465fa",
"name": "TAK",
"x": 470,
"y": 300,
"wires": [
[
"fe9f8a5a4e3bac25",
"e8f1bbdd6adee435",
"5ffea8c959a4f044"
]
]
},
{
"id": "2c755df06a1d782a",
"type": "inject",
"z": "0b934157aa7465fa",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 160,
"y": 300,
"wires": [
[
"bb6af233fc1e871a"
]
]
},
{
"id": "bb6af233fc1e871a",
"type": "function",
"z": "0b934157aa7465fa",
"name": "Example JSON",
"func": "/* \nExample JSON containing the keys & values for popular cursor on target CoT \nfields, including time, point latitude & longitude, type, and more.\n*/\n\n/* Stale is Date.now() + miliseconds. \n Ruberic: 1000 Miliseconds in 1 Second\n Example: 5 Minutes, in Miliseconds, is 300000\n (5 x 60 * 1000 )\n*/\nconst cinco = 5 * 60 * 1000;\nconst diez = 2 * cinco;\nconst stale = new Date(Date.now() + diez).toISOString();\n\n/*\nNot all fields are required for display on most TAK Products, other systems may \nhave different requirements. YMMV.\n*/\n\nmsg.payload = {\n \"event\": {\n \"_attributes\": {\n \"version\": \"2.0\",\n \"uid\": \"TACO MONSTER\",\n \"type\": \"a-f-G-U-S-T-A-C\",\n \"how\": \"m-p\",\n \"time\": new Date(Date.now()).toISOString(),\n \"start\": new Date(Date.now()).toISOString(),\n \"stale\": stale\n },\n \"point\": {\n \"_attributes\": {\n \"lat\": \"37.76\",\n \"lon\": \"-122.4975\",\n \"hae\": \"0.0\",\n \"ce\": \"9999999.0\",\n \"le\": \"9999999.0\"\n }\n },\n \"detail\": {}\n }\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 300,
"wires": [
[
"ad9ed18733dcd7a0"
]
]
},
{
"id": "fe9f8a5a4e3bac25",
"type": "debug",
"z": "0b934157aa7465fa",
"name": "CoT as XML",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 630,
"y": 380,
"wires": []
},
{
"id": "e8f1bbdd6adee435",
"type": "tcp out",
"z": "0b934157aa7465fa",
"name": "",
"host": "takserver.example.com",
"port": "8089",
"beserver": "client",
"base64": false,
"end": false,
"tls": "",
"x": 700,
"y": 320,
"wires": []
},
{
"id": "5ffea8c959a4f044",
"type": "udp out",
"z": "0b934157aa7465fa",
"name": "",
"addr": "239.2.3.1",
"iface": "",
"port": "6969",
"ipv": "udp4",
"outport": "",
"base64": false,
"multicast": "multi",
"x": 650,
"y": 260,
"wires": []
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment