diff --git a/pom.xml b/pom.xml index 780aec6..6803f45 100644 --- a/pom.xml +++ b/pom.xml @@ -6,9 +6,9 @@ 1.0-SNAPSHOT war weather - 2007 + 2008 - 2.7.1 + 2.7.3 @@ -35,8 +35,13 @@ net.liftweb + lift-util + 1.0 + + + net.liftweb lift-webkit - 0.9 + 1.0 javax.servlet @@ -47,7 +52,7 @@ junit junit - 3.8.1 + 4.5 test diff --git a/src/main/scala/bootstrap/liftweb/Boot.scala b/src/main/scala/bootstrap/liftweb/Boot.scala index 45bb9a6..65edeb5 100644 --- a/src/main/scala/bootstrap/liftweb/Boot.scala +++ b/src/main/scala/bootstrap/liftweb/Boot.scala @@ -18,24 +18,14 @@ // where to search snippet LiftRules.addToPackages("uk.org.floop.msc") - val apiDispatcher: LiftRules.DispatchPf = { - case RequestMatcher(RequestState("graph" :: args, _) ,_) => graphApi(args) - case RequestMatcher(RequestState("dump":: args, _), _) => dumpApi(args) - } - LiftRules.statelessDispatchTable = - apiDispatcher orElse LiftRules.statelessDispatchTable + LiftRules.statelessDispatchTable.prepend { + case Req("graph" :: args, _, _) => + () => Graph(args) + case Req("dump":: args, _, _) => + () => Dump(args) + } DataCollector.start() } - private def graphApi - (args: List[String]) - (req: RequestState): Can[ResponseIt] = - Graph(args) - - private def dumpApi - (args: List[String]) - (req: RequestState): Can[ResponseIt] = - Dump(args) - } diff --git a/src/main/scala/uk/org/floop/msc/comet/WeatherActor.scala b/src/main/scala/uk/org/floop/msc/comet/WeatherActor.scala index d698b7f..4ac86dc 100644 --- a/src/main/scala/uk/org/floop/msc/comet/WeatherActor.scala +++ b/src/main/scala/uk/org/floop/msc/comet/WeatherActor.scala @@ -4,13 +4,14 @@ import net.liftweb.http._ import net.liftweb.http.js.JsCmds._ +import net.liftweb.util._ import uk.org.floop.msc.rrd._ import uk.org.floop.msc.wview.Forecast -class WeatherActor(info: CometActorInitInfo) extends CometActor(info) { +class WeatherActor extends CometActor { - def defaultPrefix = "weather" + override def defaultPrefix = Full("weather") def COMPASS_ROSE = List("N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW") diff --git a/src/main/scala/uk/org/floop/msc/rest/Dump.scala b/src/main/scala/uk/org/floop/msc/rest/Dump.scala index 469c07c..50e5fe3 100644 --- a/src/main/scala/uk/org/floop/msc/rest/Dump.scala +++ b/src/main/scala/uk/org/floop/msc/rest/Dump.scala @@ -7,7 +7,7 @@ object Dump { - def apply(args: List[String]): Can[ResponseIt] = { + def apply(args: List[String]): Box[LiftResponse] = { DataStore ! DumpXml() Empty } diff --git a/src/main/scala/uk/org/floop/msc/rest/Graph.scala b/src/main/scala/uk/org/floop/msc/rest/Graph.scala index b9c849b..e4261a3 100644 --- a/src/main/scala/uk/org/floop/msc/rest/Graph.scala +++ b/src/main/scala/uk/org/floop/msc/rest/Graph.scala @@ -8,7 +8,7 @@ object Graph { - def apply(args: List[String]): Can[ResponseIt] = { + def apply(args: List[String]): Box[LiftResponse] = { args match { case arg1 :: arg2 :: Nil => { val timePeriod = arg1 match { @@ -22,7 +22,7 @@ timePeriod match { case Some(p) => DataStore !? GenerateGraph("/" + arg2 + ".xml", p) match { - case Some(ImageGenerated(bytes)) => Full(Response(bytes, List(("Content-Type", "image/png")), Nil, 200)) + case Some(ImageGenerated(bytes)) => Full(InMemoryResponse(bytes, List(("Content-Type", "image/png")), Nil, 200)) case None => println("Unable to generate graph.") Empty diff --git a/src/main/scala/uk/org/floop/msc/rrd/DataStore.scala b/src/main/scala/uk/org/floop/msc/rrd/DataStore.scala index 800b10e..eaf485d 100644 --- a/src/main/scala/uk/org/floop/msc/rrd/DataStore.scala +++ b/src/main/scala/uk/org/floop/msc/rrd/DataStore.scala @@ -17,7 +17,7 @@ import _root_.org.rrd4j.graph.{RrdGraphDef, RrdGraph, RrdGraphDefTemplate} import net.liftweb.http.LiftRules -import net.liftweb.util.{Full, Empty, Can} +import net.liftweb.util.{Full, Empty, Box} object TimePeriod extends Enumeration { val HOUR, DAY, WEEK, MONTH, YEAR = Value diff --git a/src/main/scala/uk/org/floop/msc/wview/DataCollector.scala b/src/main/scala/uk/org/floop/msc/wview/DataCollector.scala index 293f170..0f8ec9a 100644 --- a/src/main/scala/uk/org/floop/msc/wview/DataCollector.scala +++ b/src/main/scala/uk/org/floop/msc/wview/DataCollector.scala @@ -18,7 +18,7 @@ def act() { var holdoff = 1000 - LiftRules.addUnloadHook(() => continue) + //LiftRules.unloadHooks.append{() => continue} while(true) { var sock: Socket = null try { diff --git a/src/main/scala/uk/org/floop/msc/wview/LoopPacket.scala b/src/main/scala/uk/org/floop/msc/wview/LoopPacket.scala index 71c56cc..0721302 100644 --- a/src/main/scala/uk/org/floop/msc/wview/LoopPacket.scala +++ b/src/main/scala/uk/org/floop/msc/wview/LoopPacket.scala @@ -28,7 +28,7 @@ (VALUE_TYPE.FLOAT, "sampleRain"), // inches (VALUE_TYPE.FLOAT, "sampleET"), // ET (VALUE_TYPE.USHORT, "radiation"), // watts/m^3 - (VALUE_TYPE.USHORT, "UV"), // UV index * 10 + (VALUE_TYPE.FLOAT, "UV"), // UV index * 10 (VALUE_TYPE.FLOAT, "dewpoint"), // degrees F (VALUE_TYPE.FLOAT, "windchill"), // degrees F (VALUE_TYPE.FLOAT, "heatindex"), // degrees F @@ -55,22 +55,21 @@ (VALUE_TYPE.USHORT, "forecastRule"), // VP only (VALUE_TYPE.USHORT, "txBatteryStatus"), // VP only (VALUE_TYPE.USHORT, "consBatteryVoltage"), // VP only - (VALUE_TYPE.UCHAR, "extraTemp1"), // degrees F + 90 - (VALUE_TYPE.UCHAR, "extraTemp2"), // degrees F + 90 - (VALUE_TYPE.UCHAR, "extraTemp3"), // degrees F + 90 - (VALUE_TYPE.UCHAR, "soilTemp1"), // degrees F + 90 - (VALUE_TYPE.UCHAR, "soilTemp2"), // degrees F + 90 - (VALUE_TYPE.UCHAR, "soilTemp3"), // degrees F + 90 - (VALUE_TYPE.UCHAR, "soilTemp4"), // degrees F + 90 - (VALUE_TYPE.UCHAR, "leafTemp1"), // degrees F + 90 - (VALUE_TYPE.UCHAR, "leafTemp2"), // degrees F + 90 + (VALUE_TYPE.SHORT, "extraTemp1"), // degrees F + 90 + (VALUE_TYPE.SHORT, "extraTemp2"), // degrees F + 90 + (VALUE_TYPE.SHORT, "extraTemp3"), // degrees F + 90 + (VALUE_TYPE.SHORT, "soilTemp1"), // degrees F + 90 + (VALUE_TYPE.SHORT, "soilTemp2"), // degrees F + 90 + (VALUE_TYPE.SHORT, "soilTemp3"), // degrees F + 90 + (VALUE_TYPE.SHORT, "soilTemp4"), // degrees F + 90 + (VALUE_TYPE.SHORT, "leafTemp1"), // degrees F + 90 + (VALUE_TYPE.SHORT, "leafTemp2"), // degrees F + 90 (VALUE_TYPE.UCHAR, "extraHumid1"), // percent (VALUE_TYPE.UCHAR, "extraHumid2"), // percent (VALUE_TYPE.UCHAR, "soilMoist1"), (VALUE_TYPE.UCHAR, "soilMoist2"), (VALUE_TYPE.UCHAR, "leafWet1"), (VALUE_TYPE.UCHAR, "leafWet2"), - (VALUE_TYPE.UCHAR, "pad1"), // Vaisala WXT-510 (VALUE_TYPE.FLOAT, "wxt510Hail"), // inches @@ -78,9 +77,28 @@ (VALUE_TYPE.FLOAT, "wxt510HeatingTemp"), // degrees F (VALUE_TYPE.FLOAT, "wxt510HeatingVoltage"), // volts (VALUE_TYPE.FLOAT, "wxt510SupplyVoltage"), // volts - (VALUE_TYPE.FLOAT, "wxt510ReferenceVoltage") // volts + (VALUE_TYPE.FLOAT, "wxt510ReferenceVoltage"), // volts + (VALUE_TYPE.FLOAT, "wxt510RainDuration"), // sec + (VALUE_TYPE.FLOAT, "wxt510RainPeakRate"), // volts + (VALUE_TYPE.FLOAT, "wxt510HailDuration"), // sec + (VALUE_TYPE.FLOAT, "wxt510HailPeakRate"), // volts + (VALUE_TYPE.FLOAT, "wxt510Rain"), // inches + + // WMR918/968 + (VALUE_TYPE.UCHAR, "wmr918Humid3"), // percent + (VALUE_TYPE.FLOAT, "wmr918Pool"), // degrees F + (VALUE_TYPE.UCHAR, "wmr918Tendency"), // WMR's Forecast + (VALUE_TYPE.UCHAR, "wmr918WindBatteryStatus"), + (VALUE_TYPE.UCHAR, "wmr918RainBatteryStatus"), + (VALUE_TYPE.UCHAR, "wmr918OutTempBatteryStatus"), + (VALUE_TYPE.UCHAR, "wmr918InTempBatteryStatus"), + (VALUE_TYPE.UCHAR, "wmr918poolTempBatteryStatus"), + (VALUE_TYPE.UCHAR, "wmr918extra1BatteryStatus"), + (VALUE_TYPE.UCHAR, "wmr918extra2BatteryStatus"), + (VALUE_TYPE.UCHAR, "wmr918extra3BatteryStatus") + ) - val START_FRAME = Array(0xf3, 0x88, 0xc6, 0xa2, 0xda, 0xda, 0xe7, 0xcf).map(_.toByte) + val START_FRAME = Array(0x88, 0xf3, 0xa2, 0xc6, 0xda, 0xda, 0xcf, 0xe7).map(_.toByte) }