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()
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()