aboutsummaryrefslogtreecommitdiff
path: root/vfd-main/app/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'vfd-main/app/plugins')
-rw-r--r--vfd-main/app/plugins/UavClientConnection.scala33
-rw-r--r--vfd-main/app/plugins/UavPlugin.scala48
2 files changed, 0 insertions, 81 deletions
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)
-
-}