def start(): from core.plugins.abstraction.CCSRTestBed import TestBedNode from core.plugins.abstraction.GoogleWeather import WebNode from core.plugins.abstraction.SunSpot import SunSpotNodeWrapper from core.Node import Node print "Loading Sensors ..." #SunSpotNodeWrapper() global sensors sensors = [TestBedNode("21",10,"PIR"), TestBedNode("2",10,"PIR"), TestBedNode("116",10,"PIR"), TestBedNode("49",10,"PIR"), WebNode("1",10,"Guildford"), WebNode("5",10,"Santander"), Node("1000",10,"Saarbruecken")] for s in sensors: print "starting",s t = Utils.Timer(s.getSamplingRate(),s) t.start() threads.append(t)
def read(self): file = self.sock.makefile() while 1: line = file.readline() if not line: break if "who:" in line: ieee = line.split(":")[1] ieeeShort = ieee.split(".")[3].strip("\r\n") n = SunSpotNode(ieeeShort) if n not in self.spotNodes: self.spotNodes.append(n) Utils.Timer(1,n).start() SensorController.sensors.append(n) if line.startswith("V"): splitted =line.split(":") ieeeShort = splitted[1].split(".")[3].strip("\r\n") xValue = splitted[2] for n in self.spotNodes: if n.getId() == ieeeShort: n.value = xValue