def addAll(self): cfgMotes = configuration.c.getCfgValueAsList("motes") for portName in cfgMotes: Motelist.addMote(portName, "A statically added mote", "") Motelist.initialize(self.motesUpdated, startPeriodicUpdate = True) self.refreshMotes(Motelist.getMotelist(False)) self.retrieveSelected()
def addAll(self): cfgMotes = configuration.c.getCfgValueAsList("motes") for portName in cfgMotes: Motelist.addMote(portName, "A statically added mote", "") Motelist.initialize(self.motesUpdated, False, False) Motelist.startPeriodicUpdate() self.refreshMotes(Motelist.getMotelist(False))
def loadUserMotes(self): # Read motelist from config file if os.path.exists(".motelist") and os.path.isfile(".motelist"): f = open(".motelist", 'r') lines = f.readlines() for x in lines: if x != '': if x.find("->") != -1: name, port = x.strip().split("->") Motelist.addMote(port, name, localize("User defined"))
def manualyScanForMotes(prefix): prefix = str(prefix) retVal = list() print "Manualy scaning for motes with prefix: {}".format(prefix) for portNumber in range(20): if Motelist.addMote(prefix + str(portNumber), "TestMote", "Test description"): print "\tFound mote on port:", prefix + str(portNumber) retVal.append(prefix + str(portNumber)) print "Founded mote count: {}".format(len(retVal)) return retVal
def addNewMote(self, event): if not Motelist.portExists(self.port.GetValue()): self.portError.SetLabel(localize("No device found on this port") + "!") self.SetSizerAndFit(self.main) self.SetAutoLayout(1) self.Show() else: if Motelist.addMote(self.port.GetValue(), self.name.GetValue(), "User defined"): self.API.updateUserMotes() self.Close() else: self.portError.SetLabel(localize("There already is device on that port in list") + "!") self.SetSizerAndFit(self.main) self.SetAutoLayout(1) self.Show()
def addNewMote(self, event): if not Motelist.portExists(self.port.GetValue()): self.portError.SetLabel( localize("No device found on this port") + "!") self.SetSizerAndFit(self.main) self.SetAutoLayout(1) self.Show() else: if Motelist.addMote(self.port.GetValue(), self.name.GetValue(), "User defined"): self.API.updateUserMotes() self.Close() else: self.portError.SetLabel( localize("There already is device on that port in list") + "!") self.SetSizerAndFit(self.main) self.SetAutoLayout(1) self.Show()
# Clear stored motelist, to automatically detect conected motes. print "\nClearing motelist from manually found motes." Motelist.motes = list() readKey() # Automatically detect and print all connected motes. print "\nRunning automatic mote detection and printing motelist\n" Motelist.printMotelist() readKey() # Try to manually add previously found motes, should fail! print "\nTrying to add back previously manualy found motes(this should FAIL)" for port in ports: print "\tAdding mote on port {}, result: {}".format( port, "Success" if Motelist.addMote(port, "TestMote", "Test description") else "Failure") readKey() print "\nStarting periodic updates, press enter to stop!" print "\nTry to attach and reattach motes, to see any changes!" # Add our function to callbacks. # Start periodic update, which checks for motelist changes # each second and calls all callbacks only if motelist have changed. # Note that this is not blocking, it runs on different thread. Motelist.initialize(periodicUpdateCallback, True) readKey() print "\nMotelist once again:" # Simple check, to see if no problems are caused by this.