diff options
Diffstat (limited to 'vfd-main/app')
-rw-r--r-- | vfd-main/app/controllers/Application.scala | 28 | ||||
-rw-r--r-- | vfd-main/app/plugins/UavClientConnection.scala | 33 | ||||
-rw-r--r-- | vfd-main/app/plugins/UavPlugin.scala | 48 | ||||
-rw-r--r-- | vfd-main/app/views/app.scala.html | 50 | ||||
-rw-r--r-- | vfd-main/app/views/dashboard.scala.html | 13 | ||||
-rw-r--r-- | vfd-main/app/views/index.scala.html | 35 | ||||
-rw-r--r-- | vfd-main/app/views/main.scala.html | 26 |
7 files changed, 0 insertions, 233 deletions
diff --git a/vfd-main/app/controllers/Application.scala b/vfd-main/app/controllers/Application.scala deleted file mode 100644 index 149ac1c..0000000 --- a/vfd-main/app/controllers/Application.scala +++ /dev/null @@ -1,28 +0,0 @@ -package controllers - -import util._ -import play.api._ -import play.api.mvc._ -import play.api.Play.current -import play.api.mvc.WebSocket.FrameFormatter - -import play.api.libs.json._ -import plugins.UavPlugin - -object Application extends Controller { - - private def plugin = current.plugin[UavPlugin].getOrElse(throw new RuntimeException("UAV plugin is not available")) - - def index = Action { implicit request => - Ok(views.html.index(routes.Application.mavlink.webSocketURL())) - } - - def dashboard(remoteSystemId: Int) = Action { implicit request => - Ok(views.html.dashboard(routes.Application.mavlink.webSocketURL(), remoteSystemId.toByte, plugin.systemId, 0.toByte)) - } - - def mavlink = WebSocket.acceptWithActor[Array[Byte], Array[Byte]] { implicit request => - out => plugin.register(out) - } - -}
\ No newline at end of file diff --git a/vfd-main/app/plugins/UavClientConnection.scala b/vfd-main/app/plugins/UavClientConnection.scala deleted file mode 100644 index 76975e1..0000000 --- a/vfd-main/app/plugins/UavClientConnection.scala +++ /dev/null @@ -1,33 +0,0 @@ -package plugins - -import akka.actor.Actor -import akka.actor.ActorLogging -import akka.actor.ActorRef -import akka.actor.actorRef2Scala -import vfd.uav.Connection -import akka.util.ByteString - -/** - * Interfaces traffic from a websocket with a connection to a UAV. - */ -class UavClientConnection(websocket: ActorRef, uav: ActorRef) extends Actor with ActorLogging { - - override def preStart = { - uav ! Connection.Register - } - - def receive = { - - case Connection.Received(bstr) => - websocket ! bstr.toArray - - case Connection.Closed(msg) => - log.warning(msg) - context stop self - - case fromClient: Array[Byte] => - uav ! Connection.Send(ByteString(fromClient)) - - } - -}
\ No newline at end of file diff --git a/vfd-main/app/plugins/UavPlugin.scala b/vfd-main/app/plugins/UavPlugin.scala deleted file mode 100644 index 00efb8d..0000000 --- a/vfd-main/app/plugins/UavPlugin.scala +++ /dev/null @@ -1,48 +0,0 @@ -package plugins - -import akka.actor.ActorRef -import akka.actor.Props -import play.api.Application -import play.api.Plugin -import play.api.libs.concurrent.Akka -import vfd.uav.MockConnection -import vfd.uav.SerialConnection - -class UavPlugin(app: Application) extends Plugin { - - private lazy val config = app.configuration.getConfig("uav") - - lazy val systemId = config.flatMap(_.getInt("system_id")).getOrElse(1).toByte - - private lazy val connection = { - val conn = config.flatMap(_.getConfig("connection")) - val tpe = conn.flatMap(_.getString("type")).getOrElse("mock") - val heartbeat = conn.flatMap(_.getInt("heartbeat")).getOrElse(2000) - val compId = conn.flatMap(_.getInt("component_id")).getOrElse(1).toByte - - val props = tpe match { - case "mock" => - val remote = config.flatMap(_.getInt("mock.remote_system_id")).getOrElse(0).toByte - val prescaler = config.flatMap(_.getInt("mock.prescaler")).getOrElse(1) - MockConnection(systemId, compId, remote, prescaler) - - case "serial" => - val serial = config.flatMap(_.getConfig("serial")) - SerialConnection( - systemId, - compId, - heartbeat, - serial.flatMap(_.getString("port")).getOrElse("/dev/ttyUSB0"), - serial.flatMap(_.getInt("baud")).getOrElse(115200), - serial.flatMap(_.getBoolean("two_stop_bits")).getOrElse(false), - serial.flatMap(_.getInt("parity")).getOrElse(0)) - - case unknown => throw new IllegalArgumentException("Unsupported connection type '" + unknown + "'") - } - - Akka.system(app).actorOf(props, name = "uav-connection") - } - - def register(websocket: ActorRef): Props = Props(classOf[UavClientConnection], websocket, connection) - -} diff --git a/vfd-main/app/views/app.scala.html b/vfd-main/app/views/app.scala.html deleted file mode 100644 index ea738f0..0000000 --- a/vfd-main/app/views/app.scala.html +++ /dev/null @@ -1,50 +0,0 @@ -@(app: String)(args: (String, String)*) - -@import play.api.Play - -<div id="scalajsError" class="alert alert-danger" style="display: none;"> - <p><strong><i class="fa fa-bug"></i> Error! </strong> An uncaught exception occurred in the browser application, - any information displayed on this website may be corrupt. This is NOT an error that should occur under normal - operation, it is an indication of a bug in the software.</p> - <p>The error was: "<span id="scalajsErrorMessage"></span>" - </p> -</div> - -<div id="@app"> - <div class="loader"> - <i class="fa fa-spinner fa-spin"></i> - </div> -</div> - -<script type="text/javascript"> - document.addEventListener('DOMContentLoaded', function() { - try { - var root = document.getElementById('@app') - var args = { - @args.map{ case (key, value) => - @key: '@value', - } - } - - while (root.firstChild) { - root.removeChild(root.firstChild); - } - - Main().main( - root, - '@routes.Assets.at("")', - args - ) - } catch(err) { - document.getElementById("scalajsError").style.display = "block"; - document.getElementById("scalajsErrorMessage").innerHTML = err; - console.error(err) - } - }, false); -</script> - -@if(Play.isProd(Play.current)) { - <script type="text/javascript" src="@routes.Assets.at(app + "-opt.js")"></script> -} else { - <script type="text/javascript" src="@routes.Assets.at(app + "-fastopt.js")"></script> -}
\ No newline at end of file diff --git a/vfd-main/app/views/dashboard.scala.html b/vfd-main/app/views/dashboard.scala.html deleted file mode 100644 index b2cfdfd..0000000 --- a/vfd-main/app/views/dashboard.scala.html +++ /dev/null @@ -1,13 +0,0 @@ -@(socket: String, remoteSystemId: Byte, systemId: Byte, componentId: Byte) - -@main("Main"){ - - @app("vfd-dashboard")( - "socketUrl" -> socket, - "remoteSystemId" -> remoteSystemId.toString, - "systemId" -> systemId.toString, - "componentId" -> componentId.toString - ) - -} - diff --git a/vfd-main/app/views/index.scala.html b/vfd-main/app/views/index.scala.html deleted file mode 100644 index 12ac9bd..0000000 --- a/vfd-main/app/views/index.scala.html +++ /dev/null @@ -1,35 +0,0 @@ -@(socket: String) - -@import play.api.Play - -@main("Home") { - - <div class="container" style="margin-top: 200px"> - <div class="col-md-6 col-md-offset-3 col-sm-6 col-sm-offset-3"> - - <div class="panel panel-default"> - <div class="panel-heading"> - <h3 class="panel-title"> - <strong>Available vehicles </strong> - </h3> - </div> - <div class="panel-body"> - @app("vfd-index")( - "socketUrl" -> socket - ) - </div> - </div> - @if(!Play.isProd(Play.current)) { - <div class="alert alert-warning"> - <strong><i class="fa fa-exclamation-triangle"></i> Warning</strong> running in development mode - </div> - } - <div class="text-center"> - <a href="#"><small></small></a> - <a href="#"><small>Help</small></a> - </div> - </div> - </div> - - -}
\ No newline at end of file diff --git a/vfd-main/app/views/main.scala.html b/vfd-main/app/views/main.scala.html deleted file mode 100644 index 79a9f2b..0000000 --- a/vfd-main/app/views/main.scala.html +++ /dev/null @@ -1,26 +0,0 @@ -@(title: String)(content: Html) - -<!DOCTYPE html> - -<html lang="en"> -<head> - <meta charset="utf-8"> - <meta http-equiv="X-UA-Compatible" content="IE=edge"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <meta name="mobile-web-app-capable" content="yes"> - <title>VFD - @title</title> - - <link rel="shortcut icon" href="@routes.Assets.at("images/logo.svg")"> - <link rel="stylesheet" media="screen" href="@routes.Assets.at("lib/bootstrap/css/bootstrap.min.css")"> - <link rel="stylesheet" media="screen" href="@routes.Assets.at("lib/font-awesome/css/font-awesome.min.css")"> - <link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")"> -</head> -<body> - - @content - - <script type="text/javascript" src="@routes.Assets.at("lib/jquery/jquery.js")"></script> - <script type="text/javascript" src="@routes.Assets.at("lib/bootstrap/js/bootstrap.min.js")"></script> - -</body> -</html>
\ No newline at end of file |