예제 #1
0
파일: motes.py 프로젝트: KuanYuChen/mansos
 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
파일: motes.py 프로젝트: zxpower/MansOS
 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
파일: do_upload.py 프로젝트: zxpower/MansOS
 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
파일: api_core.py 프로젝트: atiselsts/osw
    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
파일: motes.py 프로젝트: KuanYuChen/mansos
 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
파일: motes.py 프로젝트: zxpower/MansOS
 def motesUpdated():
     motes.refreshMotes(Motelist.getMotelist(False))