Mercurial > code > home > repos > homeauto
diff service/arduinoNode/arduinoNode.py @ 1023:3e6fac8569cd
multi-boards on one service, new devices, devices return their current
Ignore-this: e214852bca67519e79f9ddb3644576e1
values in the graph, jsonld support, multiple temp sensors on OW bus
darcs-hash:bc0f86023166e9b1d37c99506f6bc389309db327
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sun, 03 Jan 2016 02:29:14 -0800 |
parents | 93cc6238f5ce |
children | e606f1d89d89 |
line wrap: on
line diff
--- a/service/arduinoNode/arduinoNode.py Sun Jan 03 02:28:44 2016 -0800 +++ b/service/arduinoNode/arduinoNode.py Sun Jan 03 02:29:14 2016 -0800 @@ -133,7 +133,6 @@ if stmt[0] == s and stmt[1] in graphitePredicates: self._carbon.send(graphiteName, stmt[2].toPython(), now) - def currentGraph(self): g = Graph() @@ -142,6 +141,9 @@ for si in self._statementsFromInputs.values(): for s in si: g.add(s) + for dev in self._devs: + for stmt in dev.hostStatements(): + g.add(stmt) return g def outputStatements(self, stmts): @@ -165,9 +167,9 @@ "matching output bytes" % dev.__class__) log.info("success") if unused: - log.warn("No devices cared about these statements:") + log.info("Board %s doesn't care about these statements:", self.uri) for s in unused: - log.warn(repr(s)) + log.info("%r", s) def generateArduinoCode(self): generated = { @@ -343,7 +345,12 @@ if self.get_argument('config', 'no') == 'yes': for stmt in self.settings.config.graph: g.add(stmt) - + + if self.request.headers.get('accept') == 'application/ld+json': + self.set_header('Content-type', 'application/ld+json') + self.write(g.asJsonLd()) + return + self.set_header('Content-type', 'application/x-trig') self.write(g.asTrig()) @@ -357,7 +364,7 @@ def get(self): board = [b for b in self.settings.boards if b.uri == URIRef(self.get_argument('board'))][0] - self.set_header('Content-type', 'text/plain') + self.set_header('Content-Type', 'text/plain') code, cksum = board.generateArduinoCode() self.write(code) @@ -402,7 +409,7 @@ def main(): arg = docopt(""" - Usage: reasoning.py [options] + Usage: arduinoNode.py [options] -v Verbose """) @@ -428,7 +435,8 @@ b = Board(dev, config.graph, board, onChange) boards.append(b) - boards[0].deployToArduino() + for b in boards: + b.deployToArduino() log.info('open boards') for b in boards: