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 changeTarget(self, newTarget = None): if newTarget == None: os.unsetenv("BSLPORT") try: os.environ["BSLPORT"] = Motelist.getMotelist(False)[0].getPort() except: pass else: os.environ["BSLPORT"] = newTarget
def changeTarget(self, newTarget=None): if newTarget == None: os.unsetenv("BSLPORT") try: os.environ["BSLPORT"] = Motelist.getMotelist( False)[0].getPort() except: pass else: os.environ["BSLPORT"] = newTarget
def saveUserMotes(self, name, port): os.chdir(self.path) f = open(".motelist", 'w') for mote in Motelist.getMotelist(False): if mote.isUserMote(): f.write(str(mote.getName()) + "->" + str(mote.getPort()) + '\n') f.close()
def saveUserMotes(self, name, port): os.chdir(self.path) f = open(".motelist", 'w') for mote in Motelist.getMotelist(False): if mote.isUserMote(): f.write( str(mote.getName()) + "->" + str(mote.getPort()) + '\n') f.close()
def updateMotelist(self, event = None): old = self.list.GetCheckedStrings() pos = 0 self.list.Clear() for mote in Motelist.getMotelist(False): self.list.Enable(True) self.list.Insert(mote.getNiceName(), pos) if mote.getNiceName() in old: self.list.Check(pos) pos += 1 if self.list.GetCount() == 0: self.list.Enable(False) self.list.Insert(localize("No devices found!"), 0)
def updateMotelist(self, event = None): oldVal = self.ports.GetValue() self.haveMote = False self.ports.Clear() for mote in Motelist.getMotelist(False): if not self.haveMote: self.args['serialPort'] = mote.getPort() self.haveMote = True self.ports.Append(mote.getNiceName()) self.ports.SetStringSelection(oldVal) if self.ports.GetValue() == "": if self.haveMote: self.ports.SetValue(localize("Use default device")) else: self.ports.SetValue(localize("No devices found"))
def updateMotelist(self, event=None): oldVal = self.ports.GetValue() self.haveMote = False self.ports.Clear() for mote in Motelist.getMotelist(False): if not self.haveMote: self.args['serialPort'] = mote.getPort() self.haveMote = True self.ports.Append(mote.getNiceName()) self.ports.SetStringSelection(oldVal) if self.ports.GetValue() == "": if self.haveMote: self.ports.SetValue(localize("Use default device")) else: self.ports.SetValue(localize("No devices found"))
def motesUpdated(): motes.refreshMotes(Motelist.getMotelist(False))
def periodicUpdateCallback(): motelist = Motelist.getMotelist(False) print "Periodic update result:", "Empty" if len(motelist) == 0 else "" for mote in motelist: print "\t{}".format(mote.getCSVData())
# 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. Motelist.getMotelist(False) Motelist.getMotelist(True) Motelist.printMotelist() # Clean up. Motelist.removeUpdateCallback(periodicUpdateCallback) Motelist.stopPeriodicUpdate() # Cya. print "\nThe end, to understand more, please look into the source of this test." readKey()
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. Motelist.getMotelist(False) Motelist.getMotelist(True) Motelist.printMotelist() # Clean up. Motelist.removeUpdateCallback(periodicUpdateCallback) Motelist.stopPeriodicUpdate() # Cya. print "\nThe end, to understand more, please look into the source of this test." readKey()