diff --git a/TAK Server Plugin/.gitignore b/TAK Server Plugin/.gitignore new file mode 100644 index 0000000..a1c2a23 --- /dev/null +++ b/TAK Server Plugin/.gitignore @@ -0,0 +1,23 @@ +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* diff --git a/TAK Server Plugin/Plugin/.gitignore b/TAK Server Plugin/Plugin/.gitignore new file mode 100644 index 0000000..9f0929b --- /dev/null +++ b/TAK Server Plugin/Plugin/.gitignore @@ -0,0 +1,24 @@ +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + diff --git a/TAK Server Plugin/Plugin/.vscode/launch.json b/TAK Server Plugin/Plugin/.vscode/launch.json new file mode 100644 index 0000000..5fe23b7 --- /dev/null +++ b/TAK Server Plugin/Plugin/.vscode/launch.json @@ -0,0 +1,35 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Launch Main", + "request": "launch", + "mainClass": "tak.server.plugins.Main", + "projectName": "takserver-sender-plugin-gas" + }, + { + "type": "java", + "name": "Launch GASMessageSenderPlugin", + "request": "launch", + "mainClass": "tak.server.plugins.GASMessageSenderPlugin", + "projectName": "takserver-sender-plugin-gas" + }, + { + "type": "java", + "name": "Launch Tester", + "request": "launch", + "mainClass": "tak.server.plugins.Tester", + "projectName": "takserver-sender-plugin-gas" + }, + { + "type": "java", + "name": "Launch Current File", + "request": "launch", + "mainClass": "${file}" + } + ] +} \ No newline at end of file diff --git a/TAK Server Plugin/Plugin/.vscode/settings.json b/TAK Server Plugin/Plugin/.vscode/settings.json new file mode 100644 index 0000000..e0f15db --- /dev/null +++ b/TAK Server Plugin/Plugin/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic" +} \ No newline at end of file diff --git a/TAK Server Plugin/Plugin/.vscode/tasks.json b/TAK Server Plugin/Plugin/.vscode/tasks.json new file mode 100644 index 0000000..ff138d8 --- /dev/null +++ b/TAK Server Plugin/Plugin/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "process", + "command": "${workspaceFolder}\\src\\gradlew", + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/TAK Server Plugin/Plugin/src/.gitignore b/TAK Server Plugin/Plugin/src/.gitignore new file mode 100644 index 0000000..2a49d93 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/.gitignore @@ -0,0 +1,8 @@ +.gradle/ +build/ +.settings/ +.classpath +.project/ +.project +/bin/ +!/lib/*.jar diff --git a/TAK Server Plugin/Plugin/src/build.gradle b/TAK Server Plugin/Plugin/src/build.gradle new file mode 100644 index 0000000..8fd11c4 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/build.gradle @@ -0,0 +1,71 @@ +buildscript { + + repositories { + jcenter() + mavenCentral() + } + + dependencies { + classpath 'org.ajoberstar:grgit:1.7.2' + } +} + +apply plugin: 'eclipse' +apply plugin: 'idea' + +// ext { +// // +// git = org.ajoberstar.grgit.Grgit.open(file('..')) +// gitrev = git.head().id +// gitdescribe = git.describe() +// gitbranch = git.branch.getCurrent().name +// } + +allprojects { + + apply plugin: 'java' + apply plugin: 'eclipse' + apply plugin: 'idea' + + version = '4-1'//UPDATE AS NEEDED + + defaultTasks 'build' + + test { + testLogging.showStandardStreams = true + + // display logging output + onOutput { descriptor, event -> logger.lifecycle(event.message) } + } + + repositories { + mavenCentral() + mavenLocal() + jcenter() + } +} + +subprojects { + buildscript { + repositories { + mavenCentral() + jcenter() + } + + dependencies { + classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' + } + } + + dependencies { + testCompile group: 'junit', name: 'junit', version: junit_version + testCompile group: 'ch.qos.logback', name: 'logback-classic', version: logback_version + } + + clean { + delete 'bin/' + } +} + + + diff --git a/TAK Server Plugin/Plugin/src/gradle.properties b/TAK Server Plugin/Plugin/src/gradle.properties new file mode 100644 index 0000000..8697606 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/gradle.properties @@ -0,0 +1,5 @@ +takserver_plugins_jar = takserver-plugins-4.1-BETA-94-all +junit_version = 4.12 +logback_version = 1.2.3 + + diff --git a/TAK Server Plugin/Plugin/src/gradle/wrapper/gradle-wrapper.properties b/TAK Server Plugin/Plugin/src/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..a4f0001 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/TAK Server Plugin/Plugin/src/gradlew b/TAK Server Plugin/Plugin/src/gradlew new file mode 100644 index 0000000..fbd7c51 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# 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 +# +# https://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. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/TAK Server Plugin/Plugin/src/gradlew.bat b/TAK Server Plugin/Plugin/src/gradlew.bat new file mode 100644 index 0000000..5093609 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/gradlew.bat @@ -0,0 +1,104 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/TAK Server Plugin/Plugin/src/lib/amqp-client-5.6.0.jar b/TAK Server Plugin/Plugin/src/lib/amqp-client-5.6.0.jar new file mode 100644 index 0000000..635af63 Binary files /dev/null and b/TAK Server Plugin/Plugin/src/lib/amqp-client-5.6.0.jar differ diff --git a/TAK Server Plugin/Plugin/src/lib/json-20201115.jar b/TAK Server Plugin/Plugin/src/lib/json-20201115.jar new file mode 100644 index 0000000..a9eab7a Binary files /dev/null and b/TAK Server Plugin/Plugin/src/lib/json-20201115.jar differ diff --git a/TAK Server Plugin/Plugin/src/lib/takserver-plugins-4.1-BETA-94-all.jar b/TAK Server Plugin/Plugin/src/lib/takserver-plugins-4.1-BETA-94-all.jar new file mode 100644 index 0000000..33dc866 Binary files /dev/null and b/TAK Server Plugin/Plugin/src/lib/takserver-plugins-4.1-BETA-94-all.jar differ diff --git a/TAK Server Plugin/Plugin/src/lib/takserver-plugins-4.2-BETA-39-all.jar b/TAK Server Plugin/Plugin/src/lib/takserver-plugins-4.2-BETA-39-all.jar new file mode 100644 index 0000000..0883117 Binary files /dev/null and b/TAK Server Plugin/Plugin/src/lib/takserver-plugins-4.2-BETA-39-all.jar differ diff --git a/TAK Server Plugin/Plugin/src/settings.gradle b/TAK Server Plugin/Plugin/src/settings.gradle new file mode 100644 index 0000000..35123e1 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/settings.gradle @@ -0,0 +1,4 @@ +rootProject.name = 'takserver-sdk' + +include 'takserver-sender-plugin-mcs' + diff --git a/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/.gitignore b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/.gitignore new file mode 100644 index 0000000..83ccc54 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/.gitignore @@ -0,0 +1,2 @@ +/build/ +/bin/ diff --git a/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/build.gradle b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/build.gradle new file mode 100644 index 0000000..8cab277 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/build.gradle @@ -0,0 +1,26 @@ + +repositories { + flatDir { + dirs '../lib' + } + mavenCentral() +} + +apply plugin: 'com.github.johnrengelman.shadow' + +// support building a single jar that contains plugin code and also dependencies +shadowJar { } + +dependencies { + + compileOnly name: takserver_plugins_jar + + // add additional depenencies as required for your TAK Server plugin + //compile group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.0' + + compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6' + implementation group: 'com.rabbitmq', name: 'amqp-client', version: '5.6.0' + compile group: 'org.json', name: 'json', version: '20201115' +} + + diff --git a/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/McsLoggerReceiverPlugin.java b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/McsLoggerReceiverPlugin.java new file mode 100644 index 0000000..0068789 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/McsLoggerReceiverPlugin.java @@ -0,0 +1,27 @@ +package tak.server.plugins; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import atakmap.commoncommo.protobuf.v1.MessageOuterClass.Message; + +@TakServerPlugin(name = "MCS COP Receiver Plugin", description = "TAK Server plugin that consumes TAK CoT messages, converts them to MCS COP messages, and sends them to the MCS COP Message Broker") +public class McsLoggerReceiverPlugin extends MessageReceiverBase { + + private static final Logger logger = LoggerFactory.getLogger(McsLoggerReceiverPlugin.class); + + public McsLoggerReceiverPlugin() throws ReservedConfigurationException { + logger.info("create " + getClass().getName()); + } + + @Override + public void start() { + logger.info(getClass().getName() + " started"); + } + + @Override + public void onMessage(Message message) { + + logger.info("plugin message received: " + message); + } +} \ No newline at end of file diff --git a/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/McsSenderPlugin.java b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/McsSenderPlugin.java new file mode 100644 index 0000000..d501953 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/McsSenderPlugin.java @@ -0,0 +1,115 @@ +package tak.server.plugins; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.UUID; +import java.time.Clock; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.stream.Collectors; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import atakmap.commoncommo.protobuf.v1.MessageOuterClass.Message; +import tak.server.plugins.dto.EventDto; +import tak.server.plugins.interfaces.MessageCallback; +import tak.server.plugins.messagebroker.RabbitMQConsumer; +import tak.server.plugins.processing.MessageConsumer; +import tak.server.plugins.processing.MessageProducer; +import tak.server.plugins.utilities.McsCoTConverter; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingDeque; + + +@TakServerPlugin(name = "MCS COP Sender Plugin", description = "TAK Server plugin that consumes MCS COP Events, converts them to CoT messages, and sends them to TAK Server") +public class McsSenderPlugin extends MessageSenderBase implements MessageCallback { + + private static int _queueSize = 10; + + private static final Logger _logger = LoggerFactory.getLogger(McsSenderPlugin.class); + private RabbitMQConsumer _rabbitMqConsumer; + private MessageProducer _messageProducer; + private MessageConsumer _messageConsumer; + private BlockingQueue _blockingQueue; + private ExecutorService _executor = Executors.newFixedThreadPool(2); + + @SuppressWarnings("unchecked") + public McsSenderPlugin() { + _logger.info("properties: " + config.getProperties()); + + if (config.containsProperty("processing_queue_size")) + _queueSize = (int)config.getProperty("processing_queue_size"); + + _blockingQueue = new LinkedBlockingDeque<>(_queueSize); + + _rabbitMqConsumer = new RabbitMQConsumer(); + _messageProducer = new MessageProducer(_executor, _blockingQueue); + _messageConsumer = new MessageConsumer(_executor, _blockingQueue, this); + } + + @Override + public void start() { + try { + _logger.info("Configuration Properties: " + config.getProperties()); + + setupConnection(); + } + catch (Exception e) { + _logger.error("error initializing periodic data sender", e); + } + } + + private void setupConnection(){ + _rabbitMqConsumer.SetupConsumption(_messageProducer, config); + _messageProducer.Start(); + _messageConsumer.Start(); + } + + @Override + public void stop() { + try { + if (_rabbitMqConsumer != null) _rabbitMqConsumer.Stop(); + if (_messageConsumer != null) _messageConsumer.Stop(); + if (_messageProducer != null) _messageProducer.Stop(); + _executor.shutdown(); + } + catch(Exception e){ + _logger.error("Error stopping", e); + } + } + + @Override + public void messageReceived(String message){ + try { + EventDto event = McsCoTConverter.convertToEvent(message, config); + if (event == null){ + _logger.error("error converting message to event"); + return; + } + + Message takMessage = McsCoTConverter.convertToMessage(event, config); + if (message == null){ + _logger.error("error converting event to protobuf message"); + return; + } + + _logger.info("TAK message converted: " + takMessage); + send(takMessage); + } catch (Exception exception) { + _logger.error("error converting message", exception); + } + } +} diff --git a/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/dto/EventDto.java b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/dto/EventDto.java new file mode 100644 index 0000000..7f15654 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/dto/EventDto.java @@ -0,0 +1,92 @@ +package tak.server.plugins.dto; + +import com.google.gson.annotations.SerializedName; + +public class EventDto { + @SerializedName("uid") + private String _uid = ""; + + @SerializedName("type") + private String _type = ""; + + @SerializedName("time") + private Long _time = -1L; + + @SerializedName("start") + private Long _start = -1L; + + @SerializedName("stale") + private Long _stale = -1L; + + @SerializedName("how") + private String _how = ""; + + @SerializedName("point") + private PointDto _point = null; + + private String _detail = null; + + public String getUid() { + return _uid; + } + + public void setUid(String uid) { + _uid = uid; + } + + public String getType() { + return _type; + } + + public void setType(String type) { + _type = type; + } + + public Long getTime() { + return _time; + } + + public void setTime(Long time) { + _time = time; + } + + public Long getStart() { + return _start; + } + + public void setStart(Long start) { + _start = start; + } + + public Long getStale() { + return _stale; + } + + public void setStale(Long stale) { + _stale = stale; + } + + public String getHow() { + return _how; + } + + public void setHow(String how) { + _how = how; + } + + public PointDto getPoint() { + return _point; + } + + public void setPoint(PointDto point) { + _point = point; + } + + public String getDetail() { + return _detail; + } + + public void setDetail(String detail) { + _detail = detail; + } +} diff --git a/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/dto/PointDto.java b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/dto/PointDto.java new file mode 100644 index 0000000..e260fb6 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/dto/PointDto.java @@ -0,0 +1,61 @@ +package tak.server.plugins.dto; + +import com.google.gson.annotations.SerializedName; + +public class PointDto { + + @SerializedName("lat") + private Double _lat = 0.0; + + @SerializedName("lon") + private Double _lon = 0.0; + + @SerializedName("hae") + private Double _hae = 0.0; + + @SerializedName("ce") + private Double _ce = 0.0; + + @SerializedName("le") + private Double _le = 0.0; + + public Double getLat() { + return _lat; + } + + public void setLat(Double lat) { + _lat = lat; + } + + public Double getLon() { + return _lon; + } + + public void setLon(Double lon) { + _lon = lon; + } + + public Double getHae() { + return _hae; + } + + public void setHae(Double hae) { + _hae = hae; + } + + public Double getCe() { + return _ce; + } + + public void setCe(Double ce) { + _ce = ce; + } + + public Double getLe() { + return _le; + } + + public void setLe(Double le) { + _le = le; + } +} diff --git a/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/interfaces/MessageCallback.java b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/interfaces/MessageCallback.java new file mode 100644 index 0000000..610bfe2 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/interfaces/MessageCallback.java @@ -0,0 +1,5 @@ +package tak.server.plugins.interfaces; + +public interface MessageCallback { + void messageReceived(String message); +} diff --git a/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/messagebroker/RabbitMQConsumer.java b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/messagebroker/RabbitMQConsumer.java new file mode 100644 index 0000000..09f1431 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/messagebroker/RabbitMQConsumer.java @@ -0,0 +1,98 @@ +package tak.server.plugins.messagebroker; + +import com.rabbitmq.client.Channel; +import com.rabbitmq.client.Connection; +import com.rabbitmq.client.ConnectionFactory; +import com.rabbitmq.client.DeliverCallback; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import tak.server.plugins.processing.*; +import tak.server.plugins.PluginConfiguration; + +public class RabbitMQConsumer { + private MessageProducer _producer; + private String _exchangeName = "dragonfly"; + private String _routingKey = "dragonfly.*"; + private String _rabbitHost = "some-rabbit"; + private String _password = "some-password"; + private String _username = "some-username"; + private boolean _useRapidX = false; + + private static final Logger logger = LoggerFactory.getLogger(RabbitMQConsumer.class); + private Channel _channel; + private String _consumerTag = ""; + + public void SetupConsumption(MessageProducer producer, PluginConfiguration config) { + logger.info("Connecting to rabbitMQ"); + + SetupConfiguration(config); + + try { + _producer = producer; + ConnectionFactory factory = new ConnectionFactory(); + logger.info("Use RapidX settings" + ":" + _useRapidX); + if (_useRapidX) { + factory.setUsername(_username); + factory.setPassword(_password); + factory.setHost(_rabbitHost); + } + else { + factory.setHost(_rabbitHost); + } + + Connection connection = factory.newConnection(); + _channel = connection.createChannel(); + + _channel.exchangeDeclare(_exchangeName, "topic", true); + String queueName = _channel.queueDeclare().getQueue(); + _channel.queueBind(queueName, _exchangeName, _routingKey); + + DeliverCallback deliverCallback = (consumerTag, delivery) -> { + String message = new String(delivery.getBody(), "UTF-8"); + logger.info("Msg Received '" + delivery.getEnvelope().getRoutingKey() + "':'" + message + "'"); + _producer.AddMessage(message); + }; + + _consumerTag = _channel.basicConsume(queueName, true, deliverCallback, consumerTag -> { }); + logger.info("RabbitMQ consumer setup : " + _consumerTag); + } + catch (Exception e) + { + logger.error("error initializing rabbitMQ", e); + } + } + + public void Stop() throws Exception { + if (_channel != null) _channel.basicCancel(_consumerTag); + } + + private void SetupConfiguration(PluginConfiguration configuration) { + logger.info("Reading configuration"); + + if (configuration.containsProperty("rabbitmq.exchange_name")) { + _exchangeName = (String)configuration.getProperty("rabbitmq.exchange_name"); + } + + if (configuration.containsProperty("rabbitmq.routing_key")) { + _routingKey = (String)configuration.getProperty("rabbitmq.routing_key"); + } + + if (configuration.containsProperty("rabbitmq.hostname")) { + _rabbitHost = (String)configuration.getProperty("rabbitmq.hostname"); + } + + if (configuration.containsProperty("rabbitmq.username")) { + _username = (String)configuration.getProperty("rabbitmq.username"); + } + + if (configuration.containsProperty("rabbitmq.password")) { + _password = (String)configuration.getProperty("rabbitmq.password"); + } + + if (configuration.containsProperty("useRapidX")) { + _useRapidX = (boolean)configuration.getProperty("useRapidX"); + } + } +} diff --git a/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/processing/MessageConsumer.java b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/processing/MessageConsumer.java new file mode 100644 index 0000000..36d82b7 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/processing/MessageConsumer.java @@ -0,0 +1,57 @@ +package tak.server.plugins.processing; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.BlockingQueue; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.atomic.AtomicBoolean; + +import tak.server.plugins.interfaces.*; + +public class MessageConsumer { + private ExecutorService _executor; + private BlockingQueue _queue; + private static final Logger _logger = LoggerFactory.getLogger(MessageConsumer.class); + private MessageCallback _callback; + private AtomicBoolean _running = new AtomicBoolean(false); + + public MessageConsumer(ExecutorService executorService, BlockingQueue queue, MessageCallback callback) { + _executor = executorService; + _queue = queue; + _callback = callback; + } + + public boolean isRunning() { + return _running.get(); + } + + public void Start(){ + _logger.info("Starting MessageConsumer"); + _running.set(true); + Runnable consumerTask = () -> { + try { + while(_running.get()) { + String message = _queue.take(); + _logger.info("message received in consumer sending to callback"); + _callback.messageReceived(message); + } + } + catch (InterruptedException e) { + _logger.info("thread interrupted", e); + } + catch (Exception e) { + _logger.error("error taking message from queue", e); + } + }; + + _executor.execute(consumerTask); + } + + public void Stop(){ + _logger.info("Stopping MessageConsumer"); + _running.set(false); + } + +} diff --git a/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/processing/MessageProducer.java b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/processing/MessageProducer.java new file mode 100644 index 0000000..59bd2c8 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/processing/MessageProducer.java @@ -0,0 +1,46 @@ +package tak.server.plugins.processing; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.concurrent.BlockingQueue; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MessageProducer { + + private ExecutorService _executor; + private BlockingQueue _queue; + private static final Logger _logger = LoggerFactory.getLogger(MessageProducer.class); + + public MessageProducer(ExecutorService executorService, BlockingQueue queue) { + _executor = executorService; + _queue = queue; + } + + public void Start(){ + //Notional + _logger.info("Starting MessageProducer"); + } + + public void Stop(){ + //Notional + _logger.info("Stopping MessageProducer"); + } + + public void AddMessage(String message) { + Runnable producerTask = () -> { + try { + _queue.put(message); + } + catch (InterruptedException e) { + _logger.info("thread interrupted", e); + } + catch (Exception e) { + _logger.error("error putting message on queue", e); + } + }; + + _executor.submit(producerTask); + } +} diff --git a/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/utilities/McsCoTConverter.java b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/utilities/McsCoTConverter.java new file mode 100644 index 0000000..7531061 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/utilities/McsCoTConverter.java @@ -0,0 +1,80 @@ +package tak.server.plugins.utilities; + +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import atakmap.commoncommo.protobuf.v1.MessageOuterClass; +import atakmap.commoncommo.protobuf.v1.MessageOuterClass.Message; +import atakmap.commoncommo.protobuf.v1.Takmessage.TakMessage; +import tak.server.plugins.PluginConfiguration; +import tak.server.plugins.dto.EventDto; +import atakmap.commoncommo.protobuf.v1.Cotevent.CotEvent; +import atakmap.commoncommo.protobuf.v1.DetailOuterClass; + +import org.json.JSONObject; +import org.json.XML; + +public class McsCoTConverter { + + public static Message convertToMessage(EventDto event, PluginConfiguration configuration) { + Message.Builder messageBuilder = MessageOuterClass.Message.newBuilder(); + TakMessage.Builder payloadBuilder = messageBuilder.getPayloadBuilder(); + CotEvent.Builder cotEventBuilder = payloadBuilder.getCotEventBuilder(); + DetailOuterClass.Detail.Builder detailBuilder = cotEventBuilder.getDetailBuilder(); + + @SuppressWarnings("unchecked") + List callsigns = (List) configuration.getProperty("callsigns"); + + @SuppressWarnings("unchecked") + List uids = (List) configuration.getProperty("uids"); + + cotEventBuilder.setUid(event.getUid()); + cotEventBuilder.setType(event.getType()); + cotEventBuilder.setHow(event.getHow()); + cotEventBuilder.setSendTime(event.getTime()); + cotEventBuilder.setStartTime(event.getStart()); + cotEventBuilder.setStaleTime(event.getStale()); + cotEventBuilder.setLat(event.getPoint().getLat()); + cotEventBuilder.setLon(event.getPoint().getLon()); + cotEventBuilder.setHae(event.getPoint().getHae()); + cotEventBuilder.setCe(event.getPoint().getCe()); + cotEventBuilder.setLe(event.getPoint().getLe()); + cotEventBuilder.setHow(event.getHow()); + detailBuilder.setXmlDetail(event.getDetail()); + + if (callsigns != null && !callsigns.isEmpty()) { + + messageBuilder.addAllDestCallsigns(callsigns); + } + + if (uids != null && !uids.isEmpty()) { + + messageBuilder.addAllDestClientUids(uids); + } + + return messageBuilder.build(); + } + + public static EventDto convertToEvent(String json, PluginConfiguration configuration) { + Gson gson = new Gson(); + EventDto event = gson.fromJson(json, EventDto.class); + + JsonElement element = JsonParser.parseString(json); + JsonObject jObject = element.getAsJsonObject(); + JsonObject detailJObject = jObject.getAsJsonObject("detail"); + if (detailJObject != null) { + String jsonDetailData = detailJObject.toString(); + + //Using org.json here for convenient json->xml serialization + JSONObject detailJsonObject = new JSONObject(jsonDetailData); + String xmlDetailData = XML.toString(detailJsonObject); + event.setDetail(xmlDetailData); + } + + return event; + } +} diff --git a/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/tak.server.plugins.McsSenderPlugin.yaml b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/tak.server.plugins.McsSenderPlugin.yaml new file mode 100644 index 0000000..256afe7 --- /dev/null +++ b/TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/tak.server.plugins.McsSenderPlugin.yaml @@ -0,0 +1,8 @@ +processing_queue_size: 10 +useRapidX : true +rabbitmq: + exchange_name: "dragonfly" + routing_key: "dragonfly.demo_entities" + hostname: "gsa.cognitics.net" + username: "rapidx" + password: "dragonfly" diff --git a/TAK Server Plugin/README.md b/TAK Server Plugin/README.md new file mode 100644 index 0000000..16a0105 --- /dev/null +++ b/TAK Server Plugin/README.md @@ -0,0 +1,45 @@ +# TAK Server Plugin for MCS COP +## Requirements +TAK Server 4.1 (See TAK_Server_Configuration_Guide.pdf for installation instructions) + +Installers available here: + +https://artifactory.takmaps.com/ui/repos/tree/General/TAKServer + +## Dev Environment +Visual Studio Code currently used as Code Editor for TAK Server Plugin (run gradlew clean ShadowJar on terminal) + +Visual Studio used for RabbitMQ Client (.Net Core Console App) + +## Overview +### Plugin Types +| Class | Type | Function | +| :--- | :--- | :--- | +| McsSenderPlugin | MessageSenderBase | Sends messages received from MCS COP (RabbitMQ and eventually Kafka) to TAK Server (and clients, federates and other plugins), using the TAK proto messaging format.| +| McsLoggerReceiverPlugin | MessageReceiverBase | Receives CoT messages from TAK Server and .| + +### Message Format +TAK Server plugins use the TAK proto message format to send and receive messages. This data format applies the fast and efficient data encoding of Protocol Buffers to Cursor on Target (CoT). Information about the format and definitions: + +https://git.takmaps.com/standards/takproto + +### Plugin Configuration +Plugin options can be set in a customized in a YAML configuration file that is specific to each plugin. Plugin configuration files are copied to /opt/tak/conf/plugins. If it doesn't already exist, an empty configuration file will be generated for each plugin the first time it is run. The name of the plugin configuration file is the fully-qualified name of the plugin, appended with the extension .yaml. + +### Misc Items + +Restart TAK Server to reload plugins. + +``` +sudo systemctl restart takserver +``` + +View plugin manager UI to see plugins loaded. This requires a client cert configured for admin access (see TAK Server configuration guide for information.) +``` +https://:8443/Marti/plugins/ +``` + +connect a local netcat client to see messages generated by sample sender plugin (unsecure input on port 8088 must be enabled - not for production use) +``` +nc localhost 8088 +``` diff --git a/TAK Server Plugin/RabbitMQ Client/.gitignore b/TAK Server Plugin/RabbitMQ Client/.gitignore new file mode 100644 index 0000000..cc2cc50 --- /dev/null +++ b/TAK Server Plugin/RabbitMQ Client/.gitignore @@ -0,0 +1,343 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +#*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ +/Deployment/GeoExPTPlugin.bundle/Contents/VideoProviders +/Deployment/AutodeskLauncher/AutodeskLauncher.exe +/Deployment/GeoExPTPlugin.bundle/Contents/Help/~GeoExPT ADSK.dat +/Deployment/GeoExPTPlugin.bundle/Contents/Help/GeoExPT ADSK.gui.bak +/Source Code/Notes/GeoExPT AutoLoad 2018 - WJC.reg +/Source Code/Notes/GeoExPT AutoLoad 2019 - WJC.reg +/Source Code/FMV.Demuxer/xsdfdsf +/Source Code/FMV.Demuxer/xGStreamer.zip +/Source Code/FMV.Demuxer/GStreamer_All1.14.4.zip +/Source Code/FMV.Demuxer/GStreamer - Copy.zip +/Pipeline/GeoExPT.Plugin.10.3.0.119.exe +/Source Code/FMV.FFME.VideoPathGenerator.Tester/FodyWeavers.xml +/Source Code/FMV.FFME.VideoPathGenerator.Tester/FodyWeavers.xsd diff --git a/TAK Server Plugin/RabbitMQ Client/Program.cs b/TAK Server Plugin/RabbitMQ Client/Program.cs new file mode 100644 index 0000000..160bc25 --- /dev/null +++ b/TAK Server Plugin/RabbitMQ Client/Program.cs @@ -0,0 +1,135 @@ +using System; +using RabbitMQ.Client; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System.Threading.Tasks; + +namespace RabbitMQClient +{ + class Program + { + private static string EXCHANGE = "dragonfly"; + private static string ROUTING_KEY = "dragonfly.entity_locations"; + private static string RABBITMQ_HOSTNAME = "gsa.cognitics.net"; + private static string PASSWORD = "dragonfly"; + private static string USERNAME = "rapidx"; + private static bool USE_RAPIDX = true; + + private static string MESSAGE = "{\"uid\":\"ExampleCompany.12345-abcde-6789-fghij\",\"type\":\"a-f-G-U-C\",\"time\":\"1614187736429\",\"start\":\"1614187736429\",\"stale\":\"1614191352000\",\"how\":\"m-g\",\"point\":{\"lat\":\"39.0495\",\"lon\":\"-85.7445\",\"hae\":\"9999999\",\"ce\":\"9999999\",\"le\":\"9999999\"},\"detail\":{\"milsym2525C\":\"SFGPUCI*****\"}}"; + + private static Random _random = new Random(); + private static double MIN_LAT = 39.04; + private static double MAX_LAT = 39.05; + + private static double MIN_LON = -85.74; + private static double MAX_LON = -85.75; + + static void Main(string[] args) + { + ConnectionFactory factory = new ConnectionFactory(); + + if (USE_RAPIDX) + { + factory.UserName = USERNAME; + factory.Password = PASSWORD; + factory.HostName = RABBITMQ_HOSTNAME; + } + else + factory.HostName = "localhost"; + + Task.Run(async () => + { + try + { + using var connection = factory.CreateConnection(); + using var channel = connection.CreateModel(); + channel.ExchangeDeclare(EXCHANGE, ExchangeType.Topic, true); + + while (true) + { + var message = MassageMessage(MESSAGE); + var body = Encoding.UTF8.GetBytes(message); + + channel.BasicPublish(exchange: EXCHANGE, + routingKey: ROUTING_KEY, + basicProperties: null, + body: body); + + Console.WriteLine(" [x] Sent {0}", message); + await Task.Delay(1000); + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + }); + + Console.ReadLine(); + } + + private static string MassageMessage(string message) + { + try + { + var jObject = JObject.Parse(message); + + var newLat = GetRandomNumber(MIN_LAT, MAX_LAT); + var newLon = GetRandomNumber(MIN_LON, MAX_LON); + + jObject["point"]["lat"] = newLat; + jObject["point"]["lon"] = newLon; + + var currentUnixTimeMs = DateTimeOffset.Now.ToUnixTimeMilliseconds(); + var staleUnixTimeMs = DateTimeOffset.Now.AddMinutes(10).ToUnixTimeMilliseconds(); + jObject["time"] = currentUnixTimeMs; + jObject["start"] = currentUnixTimeMs; + jObject["stale"] = staleUnixTimeMs; + + return jObject.ToString(Formatting.None); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + + return message; + + } + + private static double GetRandomNumber(double minimum, double maximum) + { + return _random.NextDouble() * (maximum - minimum) + minimum; + } + + /* + ConnectionFactory factory = new ConnectionFactory(); + factory.UserName = "rapidx"; + factory.Password = "dragonfly"; + factory.HostName = "gsa.cognitics.net"; + factory.Port = 5672; + using (var connection = factory.CreateConnection()) + using (var channel = connection.CreateModel()) + { + channel.ExchangeDeclare("dragonfly", ExchangeType.Topic, true); + + string message = "{\"originator\":\"1152786\"," + + "\"originalSender\":\"1152796\"," + + "\"lat\":\"36.9254843018683\"," + + "\"lon\":\"-76.02161526530303\"," + + "\"entityId\":\"1152796\"," + + "\"milSym\":\"SFAPMHUM------A\"," + + "\"metadata\":{ \"transformTimestamp\":\"1600707048358\",\"hlaTimestamp\":\"1600707048366\"}}"; + + var body = Encoding.UTF8.GetBytes(message); + + channel.BasicPublish(exchange: "dragonfly", + routingKey: "dragonfly.entity_locations", + basicProperties: null, + body: body); + Console.WriteLine(" [x] Sent {0}", message); + } + */ + } +} diff --git a/TAK Server Plugin/RabbitMQ Client/RabbitMQClient.csproj b/TAK Server Plugin/RabbitMQ Client/RabbitMQClient.csproj new file mode 100644 index 0000000..8e42fe8 --- /dev/null +++ b/TAK Server Plugin/RabbitMQ Client/RabbitMQClient.csproj @@ -0,0 +1,13 @@ + + + + Exe + netcoreapp3.1 + + + + + + + + diff --git a/TAK Server Plugin/RabbitMQ Client/RabbitMQClient.sln b/TAK Server Plugin/RabbitMQ Client/RabbitMQClient.sln new file mode 100644 index 0000000..b963434 --- /dev/null +++ b/TAK Server Plugin/RabbitMQ Client/RabbitMQClient.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30709.132 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RabbitMQClient", "RabbitMQClient.csproj", "{380FC0F1-DED7-4C28-BEC6-74233A74DFB1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {380FC0F1-DED7-4C28-BEC6-74233A74DFB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {380FC0F1-DED7-4C28-BEC6-74233A74DFB1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {380FC0F1-DED7-4C28-BEC6-74233A74DFB1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {380FC0F1-DED7-4C28-BEC6-74233A74DFB1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {14FD350B-E259-4A11-8874-B212E0BDF0B9} + EndGlobalSection +EndGlobal