Mercurial > code > home > repos > homeauto
changeset 113:66f8897b74ea
wallscreen show map of people and their distances from home
Ignore-this: f7ff288f146881a55529d9a11585aeb4
author | drewp@bigasterisk.com |
---|---|
date | Tue, 10 Sep 2013 00:36:52 -0700 |
parents | bab30d0fb240 |
children | 4cd065b97fa1 |
files | service/wallscreen/gui.js service/wallscreen/index.html service/wallscreen/pydeps service/wallscreen/wallscreen.py |
diffstat | 4 files changed, 67 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/service/wallscreen/gui.js Mon Sep 02 20:58:07 2013 -0700 +++ b/service/wallscreen/gui.js Tue Sep 10 00:36:52 2013 -0700 @@ -12,7 +12,8 @@ isToday: function (ev) { var today = moment().format("YYYY-MM-DD"); return ev.date == today; - } + }, + mapPersonData: ko.observable(), }; reloadData = function() { $.getJSON("content", function (data) { @@ -23,6 +24,22 @@ setInterval(reloadData, 30*60*1000); reloadData(); + reloadMap = function () { + $.getJSON("content/map", function (data) { + var personData = []; + data.pts.forEach(function (pt) { + // this is in another config but not yet in the graph + var initial = pt.who.split("#")[1].substr(0, 1).toUpperCase(); + pt.initial = initial; + pt.topFrac = initial == 'K' ? 0 : .5; + personData.push(pt); + }); + model.mapPersonData(personData); + }); + }; + setInterval(reloadMap, 2*60*1000); + reloadMap(); + function onMessage(d) { if (d.tempF) { model.requestedF(d.tempF);
--- a/service/wallscreen/index.html Mon Sep 02 20:58:07 2013 -0700 +++ b/service/wallscreen/index.html Tue Sep 10 00:36:52 2013 -0700 @@ -69,7 +69,7 @@ #events { width: 70%; - height: 33%; + height: 25%; overflow: hidden; } #events > ul > li { @@ -113,6 +113,13 @@ background: #432; color: white; } +#map { +height: 8%; +width: 70%; +overflow: hidden; +background: #111; +position: relative; +} #thermostat { position: absolute; @@ -126,6 +133,16 @@ top: 100px; } +#map span.person { + position: absolute; + display: inline-block; + border-radius: 10px; + border: 1px solid gray; + background: rgba(21, 26, 21, 0.55); + width: 1em; + height: 1em; + text-align: center; +} /* ]]> */ </style> @@ -162,6 +179,12 @@ </li> </ul> </div> + <div id="map"> + <span class="place">⌂</span> + <!-- ko foreach: mapPersonData --> + <span class="person" data-bind="text: initial, style: {left: (frac*100+'%'), top: (topFrac*100+'%')}"></span> + <!-- /ko --> + </div> <div id="thermostat"> Thermostat at <span style="color: #FAB1FA;" data-bind="text: requestedF"></span>. Use knob to adjust. </div>
--- a/service/wallscreen/pydeps Mon Sep 02 20:58:07 2013 -0700 +++ b/service/wallscreen/pydeps Tue Sep 10 00:36:52 2013 -0700 @@ -6,6 +6,9 @@ isodate==0.4.9 pyOpenSSL==0.13 python-dateutil==2.1 -rdflib==3.2.3 +rdflib==4.0.1 six==1.2.0 zope.interface==4.0.3 + +# from reasoning addTrig +restkit==4.2.2
--- a/service/wallscreen/wallscreen.py Mon Sep 02 20:58:07 2013 -0700 +++ b/service/wallscreen/wallscreen.py Tue Sep 10 00:36:52 2013 -0700 @@ -9,14 +9,18 @@ from twisted.internet import reactor, task from twisted.internet.defer import inlineCallbacks import cyclone.web, cyclone.httpclient, cyclone.websocket -from rdflib import Graph, URIRef, Namespace, Literal, RDF +from rdflib import Graph, ConjunctiveGraph, URIRef, Namespace, Literal, RDF sys.path.append("../../lib") from logsetup import log from cycloneerr import PrettyErrorHandler +sys.path.append("../reasoning") +from rdflibtrig import addTrig + CV = Namespace("http://bigasterisk.com/checkvist/v1#") EV = Namespace("http://bigasterisk.com/event#") +MAP = Namespace("http://bigasterisk.com/map#") class Content(PrettyErrorHandler, cyclone.web.RequestHandler): def get(self): @@ -72,6 +76,21 @@ self.write(json.dumps({'tasks':out, 'events' : events})) +class ContentMap(PrettyErrorHandler, cyclone.web.RequestHandler): + def get(self): + g = ConjunctiveGraph() + addTrig(g, "http://bang:9099/graph") + maxMeters = 65000 + pts = [] + print "loaded", len(g) + for s,p,o in g.triples((None, MAP['distanceToHomeM'], None)): + pts.append(dict(who=s, + frac=float(o) / maxMeters, + distanceToHomeM=o, + displayMilesDistance="%.1f miles" % + (float(o) * 0.000621371))) + self.write(json.dumps({'pts': pts})) + @inlineCallbacks def pushThermostat(): f = json.loads((yield cyclone.httpclient.fetch("http://bang:10001/requestedTemperature")).body) @@ -105,6 +124,7 @@ port = 9102 reactor.listenTCP(port, cyclone.web.Application(handlers=[ (r'/content', Content), + (r'/content/map', ContentMap), (r'/live', Live), (r'/refreshTemperature', RefreshTemperature), (r'/(.*)', cyclone.web.StaticFileHandler,