Пример #1
0
 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()
Пример #2
0
 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))
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
    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()
Пример #6
0
    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()
Пример #7
0
    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)
Пример #8
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"))
Пример #9
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"))
Пример #10
0
 def motesUpdated():
     motes.refreshMotes(Motelist.getMotelist(False))
Пример #11
0
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())
Пример #12
0
# 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()
Пример #13
0
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())
Пример #14
0
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()
Пример #15
0
 def motesUpdated():
     motes.refreshMotes(Motelist.getMotelist(False))