diff options
author | Jakob Odersky <jodersky@gmail.com> | 2014-11-09 13:19:34 +0100 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2014-11-09 13:25:25 +0100 |
commit | f37bdb01ecc88618c267deaa80ecacb520001d1a (patch) | |
tree | 02e283fe71461587be8e98f57a8069decd3d1142 /vfd-backend | |
parent | 7ebffc568407e950955b9975f06a0164295cbc5a (diff) | |
download | mavigator-f37bdb01ecc88618c267deaa80ecacb520001d1a.tar.gz mavigator-f37bdb01ecc88618c267deaa80ecacb520001d1a.tar.bz2 mavigator-f37bdb01ecc88618c267deaa80ecacb520001d1a.zip |
implement serial backend functionality
Diffstat (limited to 'vfd-backend')
-rw-r--r-- | vfd-backend/app/plugins/UavPlugin.scala | 21 | ||||
-rw-r--r-- | vfd-backend/app/views/uav.scala.html | 7 | ||||
-rw-r--r-- | vfd-backend/conf/application.conf | 2 |
3 files changed, 21 insertions, 9 deletions
diff --git a/vfd-backend/app/plugins/UavPlugin.scala b/vfd-backend/app/plugins/UavPlugin.scala index 998f445..2e5af65 100644 --- a/vfd-backend/app/plugins/UavPlugin.scala +++ b/vfd-backend/app/plugins/UavPlugin.scala @@ -1,6 +1,7 @@ package plugins import akka.actor.Actor +import akka.actor.ActorLogging import akka.actor.ActorRef import akka.actor.Props import akka.actor.actorRef2Scala @@ -8,8 +9,8 @@ import play.api.Application import play.api.Plugin import play.api.libs.concurrent.Akka import vfd.uav.Connection -import vfd.uav.SerialConnection import vfd.uav.MockConnection +import vfd.uav.SerialConnection class UavPlugin(app: Application) extends Plugin { @@ -41,21 +42,29 @@ class UavPlugin(app: Application) extends Plugin { } Akka.system(app).actorOf(props, name = "uav-connection") - } - def register(out: ActorRef): Props = Props(classOf[Repeater], out, connection) + def register(websocket: ActorRef): Props = Props(classOf[ClientConnection], websocket, connection) } -class Repeater(out: ActorRef, connection: ActorRef) extends Actor { +class ClientConnection(websocket: ActorRef, uav: ActorRef) extends Actor with ActorLogging { override def preStart = { - connection ! Connection.Register + uav ! Connection.Register } def receive = { - case Connection.Received(bytes) => out ! bytes + + case Connection.Received(bstr) => + log.info(bstr.toArray.mkString(",")) + websocket ! bstr.toArray + + + case Connection.Closed(msg) => + log.warning(msg) + context stop self + } }
\ No newline at end of file diff --git a/vfd-backend/app/views/uav.scala.html b/vfd-backend/app/views/uav.scala.html index 6ce3007..410e3c0 100644 --- a/vfd-backend/app/views/uav.scala.html +++ b/vfd-backend/app/views/uav.scala.html @@ -3,8 +3,11 @@ @main("Main", "Remote System " + remoteSystemId){ <div id="scalajsError" class="alert alert-danger" style="display: none;"> - <strong><i class="fa fa-bug"></i> Warning: an uncaught error occurred in the display software!</strong> Any visible information may be - corrupt. The error was: "<span id="scalajsErrorMessage"></span>" + <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" data-socketUrl="@socket" data-remoteSystemId="@remoteSystemId.toString"> diff --git a/vfd-backend/conf/application.conf b/vfd-backend/conf/application.conf index 27586a2..1559b89 100644 --- a/vfd-backend/conf/application.conf +++ b/vfd-backend/conf/application.conf @@ -69,7 +69,7 @@ uav.system_id=1 # Type of connection to use # 'mock' for a sample connection -uav.connection.type=mock +uav.connection.type=serial # Mavlink component id used by this connection # (not the web frontend), in case it needs to inject messages |