示例#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 __init__(self, parent, API):
        super(ListenModule, self).__init__(parent)

        self.API = API

        self.haveMote = False
        self.listening = False
        self.args = {'serialPort': '/dev/ttyUSB0', 'baudrate': 38400}

        Motelist.addUpdateCallback(self.updateMotelist)

        self.SetBackgroundColour("white")
        self.main = wx.BoxSizer(wx.VERTICAL)
        self.listenControls = wx.BoxSizer(wx.HORIZONTAL)

        self.ports = wx.ComboBox(self, choices=[], size=(300, -1))
        self.clear = wx.Button(self, label=localize("Start listening"))
        self.refresh = wx.Button(self, label=localize("Refresh"))
        self.clearOutput = wx.Button(self, label=localize("Clear"))
        self.saveOutput = wx.Button(self, label=localize("Save to file"))
        self.baudrate = wx.ComboBox(self,
                                    choices=[
                                        '2400', '4800', '9600', '19200',
                                        '38400', '57600', '115200'
                                    ])
        self.baudrate.SetSelection(4)

        self.ports.SetEditable(False)

        # Init outputArea for output
        self.outputArea = OutputArea(self, self.API, 1)
        self.updateStatus = self.outputArea.printLine
        self.clearOutputArea = self.outputArea.clear

        self.listenControls.Add(self.ports)
        self.listenControls.Add(self.baudrate)
        self.listenControls.Add(self.refresh)
        self.listenControls.Add(self.clear)
        self.listenControls.Add(self.clearOutput)
        self.listenControls.Add(self.saveOutput)

        self.main.Add(self.listenControls, 0,
                      wx.EXPAND | wx.wx.TOP | wx.LEFT | wx.RIGHT, 10)
        self.main.Add(self.outputArea, 1, wx.EXPAND | wx.ALL, 5)

        self.Bind(wx.EVT_BUTTON, self.doClear, self.clear)
        self.Bind(wx.EVT_BUTTON, self.updateMotelist, self.refresh)
        self.Bind(wx.EVT_BUTTON, self.clearOutputArea, self.clearOutput)
        self.Bind(wx.EVT_BUTTON, self.saveOutputArea, self.saveOutput)
        self.Bind(wx.EVT_COMBOBOX, self.changeTarget, self.ports)
        self.Bind(wx.EVT_COMBOBOX, self.changeBaudrate, self.baudrate)
        self.Bind(wx.EVT_TEXT, self.changeTarget, self.ports)

        #self.updateMotelist()

        self.SetSizer(self.main)
        self.main.Fit(self)
        self.Show()
示例#3
0
    def __init__(self, parent, API):
        super(UploadModule, self).__init__(parent=parent)

        self.API = API
        self.editorManager = self.API.tabManager.GetCurrentPage()
        self.filename = self.editorManager.fileName
        Motelist.addUpdateCallback(self.updateMotelist)

        self.tmpDir = self.API.path + '/temp/'
        self.haveMote = False
        self.platform = "telosb"
        self.moteOrder = list()
        # this is path from /osw/tools/IDE
        self.pathToMansos = self.API.path + "/../.."
        self.motes = []

        self.main = wx.BoxSizer(wx.VERTICAL)
        self.controls = wx.GridBagSizer(10, 10)

        #self.source = wx.ComboBox(self, choices = ["USB", "Shell"])
        #self.source.SetValue("USB")
        self.upload = wx.Button(self, label=localize("Upload"))
        self.platforms = wx.ComboBox(self, choices=self.API.getPlatforms())
        self.refresh = wx.Button(self, label=localize("Refresh"))
        self.compile = wx.Button(self, label=localize("Compile"))
        self.newMote = wx.Button(self, label=localize("Add mote"))
        self.platforms.SetValue(self.API.getActivePlatform())
        if self.API.platformOnly != None:
            self.platforms.Enable(False)

        self.controls.Add(self.compile, (0, 0), flag=wx.EXPAND | wx.ALL)
        self.controls.Add(self.platforms, (0, 1), flag=wx.EXPAND | wx.ALL)
        self.controls.Add(self.upload, (0, 2),
                          span=(2, 2),
                          flag=wx.EXPAND | wx.ALL)

        #self.controls.Add(self.source, (1, 1), flag = wx.EXPAND | wx.ALL)
        self.controls.Add(self.newMote, (1, 1), flag=wx.EXPAND | wx.ALL)
        self.controls.Add(self.refresh, (1, 0), flag=wx.EXPAND | wx.ALL)

        self.list = wx.CheckListBox(self, wx.ID_ANY, style=wx.MULTIPLE)

        self.main.Add(self.controls, 0, wx.EXPAND | wx.ALL, 3)
        self.main.Add(self.list, 0, wx.EXPAND | wx.ALL, 3)

        self.Bind(wx.EVT_BUTTON, self.API.doCompile, self.compile)
        self.Bind(wx.EVT_BUTTON, self.API.doUpload, self.upload)
        self.Bind(wx.EVT_BUTTON, self.updateMotelist, self.refresh)
        #self.Bind(wx.EVT_COMBOBOX, self.populateMotelist, self.source)
        self.Bind(wx.EVT_BUTTON, self.openNewMoteDialog, self.newMote)
        self.Bind(wx.EVT_COMBOBOX, self.API.changePlatform, self.platforms)
        self.Bind(wx.EVT_CHECKLISTBOX, self.modifyTargets, self.list)

        self.SetSizerAndFit(self.main)
        self.SetAutoLayout(1)
        self.Show()

        self.updateMotelist()
示例#4
0
    def __init__(self, parent, API):
        super(UploadModule, self).__init__(parent = parent)

        self.API = API
        self.editorManager = self.API.tabManager.GetCurrentPage()
        self.filename = self.editorManager.fileName
        Motelist.addUpdateCallback(self.updateMotelist)

        self.tmpDir = self.API.path + '/temp/'
        self.haveMote = False
        self.platform = "telosb"
        self.moteOrder = list()
        # this is path from /mansos/tools/IDE
        self.pathToMansos = self.API.path + "/../.."
        self.motes = []

        self.main = wx.BoxSizer(wx.VERTICAL)
        self.controls = wx.GridBagSizer(10, 10)

        #self.source = wx.ComboBox(self, choices = ["USB", "Shell"])
        #self.source.SetValue("USB")
        self.upload = wx.Button(self, label = localize("Upload"))
        self.platforms = wx.ComboBox(self, choices = self.API.getPlatforms())
        self.refresh = wx.Button(self, label = localize("Refresh"))
        self.compile = wx.Button(self, label = localize("Compile"))
        self.newMote = wx.Button(self, label = localize("Add mote"))
        self.platforms.SetValue(self.API.getActivePlatform())
        if self.API.platformOnly != None:
            self.platforms.Enable(False)

        self.controls.Add(self.compile, (0, 0), flag = wx.EXPAND | wx.ALL)
        self.controls.Add(self.platforms, (0, 1), flag = wx.EXPAND | wx.ALL)
        self.controls.Add(self.upload, (0, 2), span = (2, 2),
                          flag = wx.EXPAND | wx.ALL)

        #self.controls.Add(self.source, (1, 1), flag = wx.EXPAND | wx.ALL)
        self.controls.Add(self.newMote, (1, 1), flag = wx.EXPAND | wx.ALL)
        self.controls.Add(self.refresh, (1, 0), flag = wx.EXPAND | wx.ALL)

        self.list = wx.CheckListBox(self, wx.ID_ANY, style = wx.MULTIPLE)

        self.main.Add(self.controls, 0, wx.EXPAND | wx.ALL, 3);
        self.main.Add(self.list, 0, wx.EXPAND | wx.ALL, 3);

        self.Bind(wx.EVT_BUTTON, self.API.doCompile, self.compile)
        self.Bind(wx.EVT_BUTTON, self.API.doUpload, self.upload)
        self.Bind(wx.EVT_BUTTON, self.updateMotelist, self.refresh)
        #self.Bind(wx.EVT_COMBOBOX, self.populateMotelist, self.source)
        self.Bind(wx.EVT_BUTTON, self.openNewMoteDialog, self.newMote)
        self.Bind(wx.EVT_COMBOBOX, self.API.changePlatform, self.platforms)
        self.Bind(wx.EVT_CHECKLISTBOX, self.modifyTargets, self.list)

        self.SetSizerAndFit(self.main)
        self.SetAutoLayout(1)
        self.Show()

        self.updateMotelist()
示例#5
0
    def __init__(self, parent, API):
        super(ListenModule, self).__init__(parent)

        self.API = API

        self.haveMote = False
        self.listening = False
        self.args = {
             'serialPort': '/dev/ttyUSB0',
             'baudrate': 38400
         }

        Motelist.addUpdateCallback(self.updateMotelist)

        self.SetBackgroundColour("white")
        self.main = wx.BoxSizer(wx.VERTICAL)
        self.listenControls = wx.BoxSizer(wx.HORIZONTAL)

        self.ports = wx.ComboBox(self, choices = [], size = (300, -1))
        self.clear = wx.Button(self, label = localize("Start listening"))
        self.refresh = wx.Button(self, label = localize("Refresh"))
        self.clearOutput = wx.Button(self, label = localize("Clear"))
        self.saveOutput = wx.Button(self, label = localize("Save to file"))
        self.baudrate = wx.ComboBox(self, choices = ['2400', '4800', '9600', '19200', '38400', '57600', '115200'])
        self.baudrate.SetSelection(4);

        self.ports.SetEditable(False)

        # Init outputArea for output
        self.outputArea = OutputArea(self, self.API, 1)
        self.updateStatus = self.outputArea.printLine
        self.clearOutputArea = self.outputArea.clear

        self.listenControls.Add(self.ports)
        self.listenControls.Add(self.baudrate)
        self.listenControls.Add(self.refresh)     
        self.listenControls.Add(self.clear)
        self.listenControls.Add(self.clearOutput)
        self.listenControls.Add(self.saveOutput)

        self.main.Add(self.listenControls, 0,
                      wx.EXPAND | wx.wx.TOP | wx.LEFT | wx.RIGHT, 10);
        self.main.Add(self.outputArea, 1, wx.EXPAND | wx.ALL, 5);

        self.Bind(wx.EVT_BUTTON, self.doClear, self.clear)         
        self.Bind(wx.EVT_BUTTON, self.updateMotelist, self.refresh)
        self.Bind(wx.EVT_BUTTON, self.clearOutputArea, self.clearOutput)
        self.Bind(wx.EVT_BUTTON, self.saveOutputArea, self.saveOutput)
        self.Bind(wx.EVT_COMBOBOX, self.changeTarget, self.ports)
        self.Bind(wx.EVT_COMBOBOX, self.changeBaudrate, self.baudrate)
        self.Bind(wx.EVT_TEXT, self.changeTarget, self.ports)

        #self.updateMotelist()

        self.SetSizer(self.main)
        self.main.Fit(self)
        self.Show()
示例#6
0
    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"))
示例#7
0
文件: api_core.py 项目: atiselsts/osw
    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"))
示例#8
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))
示例#9
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
示例#10
0
    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()
示例#11
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
示例#12
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()
示例#13
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()
示例#14
0
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
示例#15
0
    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()
示例#16
0
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
示例#17
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)
示例#18
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"))
示例#19
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"))
示例#20
0
    prefix = "/dev/tty."  # Not tested
else:
    print("Your OS ('{}') is not supported, sorry!".format(os.name))
    exit(1)

# This is done before any other action on Motelist,
# to ensure that motelist is empty on manual scan, because
# if there are already registred mote on that port,
# motelist will ignore it.
ports = manualyScanForMotes(prefix)
readKey()

# This actually updates motelist with all connected motes,
# but found motes are not overwriten, because they already exist in the list.
print "Printing motelist with manualy found motes\n"
Motelist.printMotelist()
readKey()

# 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:
示例#21
0
 def __del__(self):
     Motelist.removeUpdateCallback(self.updateMotelist)
示例#22
0
 def motesUpdated():
     motes.refreshMotes(Motelist.getMotelist(False))
示例#23
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())
示例#24
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())
示例#25
0
    prefix = "/dev/tty." # Not tested
else:
    print ("Your OS ('{}') is not supported, sorry!".format(os.name))
    exit(1)

# This is done before any other action on Motelist, 
# to ensure that motelist is empty on manual scan, because
# if there are already registred mote on that port, 
# motelist will ignore it.
ports = manualyScanForMotes(prefix)
readKey()

# This actually updates motelist with all connected motes, 
# but found motes are not overwriten, because they already exist in the list.
print "Printing motelist with manualy found motes\n"
Motelist.printMotelist()
readKey()

# 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:
示例#26
0
文件: api_core.py 项目: atiselsts/osw
    def __init__(self, argv):
        self.loaded = False
        self.config = wx.Config("OSW-IDE", style = wx.CONFIG_USE_LOCAL_FILE)

        self.path = os.getcwd()

        # All functions here will be called upon exit
        self.onExit = [Settings.saveConfig]

        Settings()

        # All defined platforms
        self.platforms = self.getPlatformsFromMakefile()

        self.platformOnly = None
        self.excludedPlatforms = list()

        self.activePlatform = self.platforms.index("telosb")

        # Flag indicates that next thread's output shouldn't trigger 
        # force switching to info area tab.
        self.supressTabSwitching = False

        self.targets = [None]
        self.targetType = "USB"

        self.activeThreads = {}

        self.onExit.append(self.killAllThreads)

        if LOG_TO_FILE:
            path = os.getcwd()
            os.chdir(self.path)
            self.logFile = open(LOG_FILE_NAME, "a")
            os.chdir(path)
            self.onExit.append(self.logFile.close)

        # this is path from /osw/tools/IDE
        self.pathToMansos = os.path.join(self.path, "../..")

        # Try to get system default font
        #font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        #self.fontName = font.GetFaceName()
        #if self.fontName != "":
        #    print "Using system default font: {}".format(self.fontName)
        #else:
        self.fontName = "Courier New"
        #    print "Can't find system default font, defaulting to {}".\
        #                format(self.fontName)

        self.listenModules = list()

        self.editors = list()

        icon = os.path.normpath('../../doc/osw-32x32.ico')

### Module initializations

# Visual objects here can be used in forms only after they have been re-parented 
# using their Reparent() function, else they won't be visible!

        self.emptyFrame = wx.Frame(None)

        # Defines seal syntax
        self.sealSyntax = SealSyntax(self)

        # Init translation module
        Translater(self)

        # Init output_tools
        #self.outputTools = OutputTools(self.emptyFrame, self)

        # Init outputArea for info, 1st tab
        self.infoArea = OutputArea(self.emptyFrame, self, 0)
        self.printInfo = self.infoArea.printLine
        self.clearInfoArea = self.infoArea.clear

        # Init blockly handler
        if os.path.exists(os.path.join(self.path, Settings.get("blockly_location"))):
            self.blockly = Blockly(self.emptyFrame, self)
            self.foundBlockly = True
        else:
            print "Warning: No SEAL-Blockly found!"
            self.foundBlockly = False

        # Init seal parser
        self.sealParser = seal_parser.SealParser("msp430", self.printInfo, False, True)

        # Init tab manager 
        self.tabManager = TabManager(self.emptyFrame, self)

        # Init listenModule
        self.listenModules.append(ListenModule(self.emptyFrame, self))

        self.editPanel = ScrolledPanel(self.emptyFrame)

        self.editWindow = EditStatement(self.editPanel, self)

        self.frame = Frame(None, "OSW IDE", (0, 0), (0, 0), self)

        #self.outputTools.addTools()

        self.compiler = DoCompile(self)
        self.uploader = DoUpload(self)

### Shortcuts

# This allows modules to be disabled and dummy functions attached, so other 
# modules can keep saving the day... Each module updates his functions at 
# startup and restores them at termination. All function calls between modules 
# should go through here, but this ain't perfect world :(

        self.getKeywords = self.sealSyntax.getKeywords

        #self.printInfo = self.dummyPrint
        self.printOutput = self.dummyPrint

# Check if icon can be found
        if os.path.exists(icon):
            self.frame.SetIcon(wx.Icon(icon, wx.BITMAP_TYPE_ICO, 32, 32))
        else:
            self.logMsg(LOG_WARNING, "Icon not found in '{}'!".format(icon))

# Check that everything is OK
        assert len(self.emptyFrame.GetChildren()) == 0, \
        "There are parentless objects after API initialization.\n{}".format(\
                            self.emptyFrame.GetChildren())

        self.syncModuleCheckboxes()

# Initialize upload targets
        self.uploadTargets = ([], localize('the default device'))

# Load last used tabs
        self.tabManager.loadRememberedTabs()
        for x in argv:
            self.tabManager.addPage(x)
        self.frame.auiManager.Update()

        self.loaded = True
        self.frame.checkToggleState()

        Motelist.startPeriodicUpdate()
        self.onExit.append(Motelist.stopPeriodicUpdate)

        self.loadUserMotes()
示例#27
0
    def __init__(self, argv):
        self.loaded = False
        self.config = wx.Config("MansOS-IDE", style=wx.CONFIG_USE_LOCAL_FILE)

        self.path = os.getcwd()

        # All functions here will be called upon exit
        self.onExit = [Settings.saveConfig]

        Settings()

        # All defined platforms
        self.platforms = self.getPlatformsFromMakefile()

        self.platformOnly = None
        self.excludedPlatforms = list()

        self.activePlatform = self.platforms.index("telosb")

        # Flag indicates that next thread's output shouldn't trigger
        # force switching to info area tab.
        self.supressTabSwitching = False

        self.targets = [None]
        self.targetType = "USB"

        self.activeThreads = {}

        self.onExit.append(self.killAllThreads)

        if LOG_TO_FILE:
            path = os.getcwd()
            os.chdir(self.path)
            self.logFile = open(LOG_FILE_NAME, "a")
            os.chdir(path)
            self.onExit.append(self.logFile.close)

        # this is path from /mansos/tools/IDE
        self.pathToMansos = os.path.join(self.path, "../..")

        # Try to get system default font
        #font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        #self.fontName = font.GetFaceName()
        #if self.fontName != "":
        #    print "Using system default font: {}".format(self.fontName)
        #else:
        self.fontName = "Courier New"
        #    print "Can't find system default font, defaulting to {}".\
        #                format(self.fontName)

        self.listenModules = list()

        self.editors = list()

        icon = os.path.normpath('../../doc/mansos-32x32.ico')

        ### Module initializations

        # Visual objects here can be used in forms only after they have been re-parented
        # using their Reparent() function, else they won't be visible!

        self.emptyFrame = wx.Frame(None)

        # Defines seal syntax
        self.sealSyntax = SealSyntax(self)

        # Init translation module
        Translater(self)

        # Init output_tools
        #self.outputTools = OutputTools(self.emptyFrame, self)

        # Init outputArea for info, 1st tab
        self.infoArea = OutputArea(self.emptyFrame, self, 0)
        self.printInfo = self.infoArea.printLine
        self.clearInfoArea = self.infoArea.clear

        # Init blockly handler
        if os.path.exists(
                os.path.join(self.path, Settings.get("blockly_location"))):
            self.blockly = Blockly(self.emptyFrame, self)
            self.foundBlockly = True
        else:
            print "Warning: No SEAL-Blockly found!"
            self.foundBlockly = False

        # Init seal parser
        self.sealParser = seal_parser.SealParser("msp430", self.printInfo,
                                                 False, True)

        # Init tab manager
        self.tabManager = TabManager(self.emptyFrame, self)

        # Init listenModule
        self.listenModules.append(ListenModule(self.emptyFrame, self))

        self.editPanel = ScrolledPanel(self.emptyFrame)

        self.editWindow = EditStatement(self.editPanel, self)

        self.frame = Frame(None, "MansOS IDE", (0, 0), (0, 0), self)

        #self.outputTools.addTools()

        self.compiler = DoCompile(self)
        self.uploader = DoUpload(self)

        ### Shortcuts

        # This allows modules to be disabled and dummy functions attached, so other
        # modules can keep saving the day... Each module updates his functions at
        # startup and restores them at termination. All function calls between modules
        # should go through here, but this ain't perfect world :(

        self.getKeywords = self.sealSyntax.getKeywords

        #self.printInfo = self.dummyPrint
        self.printOutput = self.dummyPrint

        # Check if icon can be found
        if os.path.exists(icon):
            self.frame.SetIcon(wx.Icon(icon, wx.BITMAP_TYPE_ICO, 32, 32))
        else:
            self.logMsg(LOG_WARNING, "Icon not found in '{}'!".format(icon))

# Check that everything is OK
        assert len(self.emptyFrame.GetChildren()) == 0, \
        "There are parentless objects after API initialization.\n{}".format(\
                            self.emptyFrame.GetChildren())

        self.syncModuleCheckboxes()

        # Initialize upload targets
        self.uploadTargets = ([], localize('the default device'))

        # Load last used tabs
        self.tabManager.loadRememberedTabs()
        for x in argv:
            self.tabManager.addPage(x)
        self.frame.auiManager.Update()

        self.loaded = True
        self.frame.checkToggleState()

        Motelist.startPeriodicUpdate()
        self.onExit.append(Motelist.stopPeriodicUpdate)

        self.loadUserMotes()
示例#28
0
文件: motes.py 项目: zxpower/MansOS
 def motesUpdated():
     motes.refreshMotes(Motelist.getMotelist(False))