diff options
author | Jakob Odersky <jodersky@gmail.com> | 2015-03-31 13:58:03 +0200 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2015-04-01 14:23:00 +0200 |
commit | 6f76598ae4306c22f84571655c885fc570b897a6 (patch) | |
tree | d0c0b7006df08f8c56307b6b064ccd793a2b89d4 | |
parent | e47400b340fc9533058cfaf1ce0b695d9f9bd0eb (diff) | |
download | mavigator-6f76598ae4306c22f84571655c885fc570b897a6.tar.gz mavigator-6f76598ae4306c22f84571655c885fc570b897a6.tar.bz2 mavigator-6f76598ae4306c22f84571655c885fc570b897a6.zip |
Move bindings to central project and generate scaladoc
-rw-r--r-- | README.md | 57 | ||||
-rw-r--r-- | project/Build.scala | 79 | ||||
-rw-r--r-- | project/plugins.sbt | 31 | ||||
-rw-r--r-- | vfd-bindings/mavlink/common.xml (renamed from mavlink/common.xml) | 0 |
4 files changed, 117 insertions, 50 deletions
@@ -2,45 +2,60 @@ Web interface simulating a cockpit of an unmanned aerial vehicle, built with Akka, Play and ScalaJS. -This project is made of several subprojects: - - `vfd-main` contains the play application that serves the actual interface - - `vfd-dashboard` dynamic cockpit interface built with scalajs that displays real-time data from the drone - - `vfd-index` dynamic landing page advertising available drones - - `vfd-uav` communication backend for message exchange with drones +See [demo](http://vfd.herokuapp.com). -# Run +# Getting started SBT is used as the build tool. To get started: 1. start sbt in the base directory 2. enter 'run' *Note: if this is the first time your run a play project through sbt, be aware that you may need to wait a while as your computer downloads half the internet* - 3. open localhost:9000 in a modern browser to see the application in action - 4. make some changes + 3. open [localhost:9000](http://localhost:9000) in a modern browser (tested in Firefox and Chromium) to see the application in action + 4. make some changes to the application 5. go to step 3 (the application is automatically recompiled) The application can be deployed as a standalone package by running the 'dist' task. # Developer Overview -The general idea of this project is to create a web interface for displaying live data from a drone. +## General Idea +The general idea of this project is to create a web interface for displaying live data from a drone. It is made of several subprojects, each providing a certain functionality. -The flow of such data can be summarized in a few points: + Project | Description | Technology + ------- | ----------- | ---------- + `vfd-main` | Contains a play application that serves the actual interface. | Scala + `vfd-dashboard` | Dynamic cockpit web interface that displays real-time data from a drone. Served up by `vfd-main`. | ScalaJS + `vfd-index` | Dynamic landing page advertising available drones. | ScalaJS + `vfd-uav` | Communication backend for message exchange with drones. | Scala + `vfd-bindings` | MAVLink utility library, used by all other projects. | Scala + +To get acquainted with the application's internal structure, it is recommended start looking at code in `vfd-main` and `vfd-dashboard`. + +As stated in the general idea, this application mainly reads data from a drone and displays it. The flow of such data can be summarized in a few points: - Data is received and processed in the form of [MAVLink](http://qgroundcontrol.org/mavlink/start) messages. - Messages arrive at a communication backend (implemented in vfd-uav). Currently, this is either a mock backend that generates random messages, or a serial connection using [flow](https://github.com/jodersky/flow) for low-level communication. - These messages are then transferred through vfd-main to the interface via websockets. -- Messages are parsed by the front-end (the interface) and used to display virtual instrumentation. -- Currently, a custom set of MAVLink messages are used. Their definition is in mavlink/concise.xml -- The dialect definition is translated from xml into useable scala code by a [plugin](https://github.com/jodersky/sbt-mavlink) during the build. +- Messages are parsed by the interface and used to display virtual instrumentation. +- The official 'common' mavlink dialect is used. Its definition is in [vfd-bindings/mavlink/common.xml](vfd-bindings/mavlink/common.xml) +- The dialect definition is translated from xml into useable scala code by a plugin during the build. + +## Sub-project details + +### vfd-dashboard +The dynamic cockpit UI frontend. + - The frontend is a pure scalajs application using [scalatags](https://github.com/lihaoyi/scalatags) templating. + - Basically, `vfd-main` serves an empty page containing the frontend and provides a websocket for communication. + - Once loaded, the scalajs frontend replaces the empty page with its UI. + - Messages are received by the websocket and stored in an observable [scala.rx](https://github.com/lihaoyi/scala.rx) "var". + - Messages are reactively propagated to the final user interface components. -Details on the dashboard interface: - - the frontend is a pure scalajs application using [scalatags](https://github.com/lihaoyi/scalatags) templating - - basically, vfd-main provides a websocket for communication and serves a page (see views.uav.scala.html) that contains a div with a loading message - - once loaded, the scalajs frontend replaces the content of said div with its insrumentation (see code in package vfd.dashboard.ui.*) - - messages are received by a websocket and stored in an observable "var"; this process uses [scala.rx](https://github.com/lihaoyi/scala.rx) - - panels observe the recieved messages and update their respective instruments and components +### vfd-bindings +Initially an empty project, it uses the [sbt-mavlink plugin](https://github.com/jodersky/sbt-mavlink) to generate Scala bindings for the MAVLink protocol Other projects depend on it for interacting with the protocol. See the scaladoc, package `org.mavlink`, for details on the MAVLink API. +## Scaladoc +Scaladoc of the current application is available [here](https://jodersky.github.io/vfd/latest/api/#org.mavlink.package). -# License -Copyright (C) Jakob Odersky +# Copying +Copyright (C) 2015 The VFD Developers This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as diff --git a/project/Build.scala b/project/Build.scala index c99b088..10dd228 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -15,39 +15,61 @@ import playscalajs.ScalaJSPlay import playscalajs.PlayScalaJS.autoImport._ import com.typesafe.sbt.web.Import._ +import sbtunidoc.Plugin._ + +import com.typesafe.sbt.SbtSite._ +import com.typesafe.sbt.SbtGhPages._ +import com.typesafe.sbt.SbtGit._ object ApplicationBuild extends Build { - //settings common to all projects - val common = Seq( + // settings common to all projects + val commonSettings = Seq( scalaVersion := "2.11.6", - scalacOptions ++= Seq("-feature", "-deprecation"), - mavlinkDialect := (baseDirectory in ThisBuild).value / "mavlink" / "common.xml" + scalacOptions ++= Seq("-feature", "-deprecation") ) - //root super-project + // root super-project lazy val root = ( - Project("root", file(".")).aggregate( + Project("root", file(".")) + settings(commonSettings: _*) + settings(unidocSettings: _*) + settings(site.settings: _*) + settings(ghpages.settings: _*) + settings( + //goto main project on load + onLoad in Global := (Command.process("project vfd-main", _: State)) compose (onLoad in Global).value, + site.addMappingsToSiteDir(mappings in (ScalaUnidoc, packageDoc), "latest/api"), + git.remoteRepo := "git@github.com:jodersky/vfd.git" + ) + aggregate( + bindings, main, uav, dashboard, index ) - settings(common: _*) + ) + + // empty project that uses SbtMavlink to generate protocol bindings + lazy val bindings = ( + Project("vfd-bindings", file("vfd-bindings")) + enablePlugins(SbtMavlink) + enablePlugins(ScalaJSPlugin) + settings(commonSettings: _*) settings( - //goto main project on load - onLoad in Global := (Command.process("project vfd-main", _: State)) compose (onLoad in Global).value + mavlinkDialect := baseDirectory.value / "mavlink" / "common.xml" ) ) - //main play project + // main play project lazy val main = ( Project("vfd-main", file("vfd-main")) enablePlugins(PlayScala) - enablePlugins(SbtMavlink) - settings(common: _*) + dependsOn(bindings) + dependsOn(uav) + settings(commonSettings: _*) settings( - resolvers += Resolver.url("scala-js-releases", url("http://dl.bintray.com/content/scala-js/scala-js-releases"))(Resolver.ivyStylePatterns), scalaJSProjects := Seq(dashboard, index), pipelineStages := Seq(scalaJSProd), libraryDependencies ++= Seq( @@ -56,18 +78,17 @@ object ApplicationBuild extends Build { "org.webjars" % "jquery" % "2.1.3" ) ) - dependsOn(uav) aggregate( projectToRef(dashboard), projectToRef(index) ) ) - //communication backend + // communication backend lazy val uav = ( Project("vfd-uav", file("vfd-uav")) - enablePlugins(SbtMavlink) - settings(common: _*) + dependsOn(bindings) + settings(commonSettings: _*) settings( libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-actor" % "2.3.9", @@ -77,31 +98,33 @@ object ApplicationBuild extends Build { ) ) - //web frontends - val scalajs = Seq( + // web frontends + val scalajsSettings = Seq( libraryDependencies ++= Seq( - "org.scala-js" %%% "scalajs-dom" % "0.8.0", - "com.lihaoyi" %%% "scalatags" % "0.5.0", - "com.lihaoyi" %%% "scalarx" % "0.2.8" + "org.scala-js" %%% "scalajs-dom" % "0.8.0", + "com.lihaoyi" %%% "scalatags" % "0.5.0", + "com.lihaoyi" %%% "scalarx" % "0.2.8" ) ) + // main cockpit front-end lazy val dashboard = ( Project("vfd-dashboard", file("vfd-dashboard")) enablePlugins(ScalaJSPlugin) enablePlugins(ScalaJSPlay) - enablePlugins(SbtMavlink) - settings(common: _*) - settings(scalajs: _*) + dependsOn(bindings) + settings(commonSettings: _*) + settings(scalajsSettings: _*) ) + // landing page providing selection of drone lazy val index = ( Project("vfd-index", file("vfd-index")) enablePlugins(ScalaJSPlugin) enablePlugins(ScalaJSPlay) - enablePlugins(SbtMavlink) - settings(common: _*) - settings(scalajs: _*) + dependsOn(bindings) + settings(commonSettings: _*) + settings(scalajsSettings: _*) ) }
\ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index d47ecca..4a09da5 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,38 @@ +/* + * Additional resolvers + */ + resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/" +resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven" + + +/* + * Main plugins + */ + +// play web framework addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8") +// add support for scalajs addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.2") +// enable "smooth" dependencies between play and scalajs projects addSbtPlugin("com.vmunier" % "sbt-play-scalajs" % "0.2.3") -addSbtPlugin("com.github.jodersky" % "sbt-mavlink" % "0.5.0") +// generate MAVLink protocol bindings +addSbtPlugin("com.github.jodersky" % "sbt-mavlink" % "0.5.1") + + +/* + * Utility or meta plugins + */ + +// automate publishing documentation +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.8.1") + +// publish to github pages +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.3") + +// generate documentation for all projects +addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.3.2")
\ No newline at end of file diff --git a/mavlink/common.xml b/vfd-bindings/mavlink/common.xml index 7f35f07..7f35f07 100644 --- a/mavlink/common.xml +++ b/vfd-bindings/mavlink/common.xml |