aboutsummaryrefslogtreecommitdiff
path: root/mavigator-cockpit/src/main/scala/mavigator/index/ActiveVehicle.scala
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2016-02-24 20:33:51 -0800
committerJakob Odersky <jakob@odersky.com>2016-02-24 20:33:51 -0800
commit8186b3622ce1c9d2b50df3d264ab526dc1e61d77 (patch)
treeb4446408291c9f179e1c270a561523023ac6a105 /mavigator-cockpit/src/main/scala/mavigator/index/ActiveVehicle.scala
parent6c4e8849d753734b3e50523dcdb372fbdbccc2c1 (diff)
parenta41de68066007852d7d3dbf019d75b4caf7463ad (diff)
downloadmavigator-8186b3622ce1c9d2b50df3d264ab526dc1e61d77.tar.gz
mavigator-8186b3622ce1c9d2b50df3d264ab526dc1e61d77.tar.bz2
mavigator-8186b3622ce1c9d2b50df3d264ab526dc1e61d77.zip
Merge branch 'akka-streams'
Diffstat (limited to 'mavigator-cockpit/src/main/scala/mavigator/index/ActiveVehicle.scala')
-rw-r--r--mavigator-cockpit/src/main/scala/mavigator/index/ActiveVehicle.scala44
1 files changed, 44 insertions, 0 deletions
diff --git a/mavigator-cockpit/src/main/scala/mavigator/index/ActiveVehicle.scala b/mavigator-cockpit/src/main/scala/mavigator/index/ActiveVehicle.scala
new file mode 100644
index 0000000..870d3be
--- /dev/null
+++ b/mavigator-cockpit/src/main/scala/mavigator/index/ActiveVehicle.scala
@@ -0,0 +1,44 @@
+package mavigator.index
+
+import org.mavlink.enums.MavAutopilot
+import org.mavlink.enums.MavState
+import org.mavlink.enums.MavType
+import org.mavlink.messages.Heartbeat
+
+case class ActiveVehicle(systemId: Int, vehicleType: String, autopilot: String, state: String)
+
+object ActiveVehicle {
+
+ def fromHeartbeat(id: Int, hb: Heartbeat) = ActiveVehicle(
+ id,
+ vehicleType(hb.`type`),
+ autopilot(hb.autopilot),
+ state(hb.systemStatus))
+
+ def vehicleType(tpe: Int) = tpe match {
+ case MavType.MavTypeGeneric => "Generic"
+ case MavType.MavTypeQuadrotor => "Quadcopter"
+ case MavType.MavTypeFixedWing => "Fixed Wing"
+ case _ => "Other"
+ }
+
+ def autopilot(tpe: Int) = tpe match {
+ case MavAutopilot.MavAutopilotGeneric => "Generic"
+ case MavAutopilot.MavAutopilotInvalid => "Invalid"
+ case MavAutopilot.MavAutopilotPixhawk => "Pixhawk"
+ case _ => "Other"
+ }
+
+ def state(s: Int) = s match {
+ case MavState.MavStateActive => "Active"
+ case MavState.MavStateBoot => "Booting"
+ case MavState.MavStateCalibrating => "Calibrating"
+ case MavState.MavStateCritical => "Critical"
+ case MavState.MavStateEmergency => "Emergency"
+ case MavState.MavStatePoweroff => "Poweroff"
+ case MavState.MavStateStandby => "Standby"
+ case MavState.MavStateUninit => "Uninitialized"
+ case _ => "Unknown"
+ }
+
+}