예제 #1
0
 def OnDeviceRemoved(self, event):
     if event.payload[0].split("#")[1] == 'Vid_0403&Pid_f850':
         if self.dll:
             if not self.dll.UUIRTClose(self.hDrvHandle):
                 raise self.Exception("Error calling UUIRTClose")
             self.dll = None
         eg.Bind("System.DeviceAttached", self.OnDeviceAttached)
예제 #2
0
    def __init__(self, parent):
        wx.StatusBar.__init__(self, parent, -1)
        self.sizeChanged = False
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_IDLE, self.OnIdle)
        self.SetFieldsCount(2)
        self.SetStatusWidths([-1, 40])
        self.icons = [
            GetInternalBitmap("Tray1"),
            GetInternalBitmap("Tray3"),
            GetInternalBitmap("Tray2"),
        ]
        self.icon = wx.StaticBitmap(self, -1, self.icons[0], (0, 0), (16, 16))
        rect = self.GetFieldRect(0)

        checkBox = wx.CheckBox(self, -1, eg.text.MainFrame.onlyLogAssigned)
        self.checkBox = checkBox
        colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
        checkBox.SetBackgroundColour(colour)
        self.checkBoxColour = checkBox.GetForegroundColour()
        checkBox.SetValue(eg.config.onlyLogAssigned)
        self.SetCheckBoxColour(eg.config.onlyLogAssigned)
        checkBox.Bind(wx.EVT_CHECKBOX, self.OnCheckBox)
        checkBox.SetPosition((rect.x + 2, rect.y + 2))
        checkBox.SetToolTipString(eg.text.MainFrame.onlyLogAssignedToolTip)

        eg.Bind("ProcessingChange", self.OnProcessingChange)
        self.Reposition()
예제 #3
0
 def __init__(self, show):
     self.stateIcons = (
         wx.Icon(join(eg.imagesDir, "Tray1.png"), wx.BITMAP_TYPE_PNG),
         wx.Icon(join(eg.imagesDir, "Tray3.png"), wx.BITMAP_TYPE_PNG),
         wx.Icon(join(eg.imagesDir, "Tray2.png"), wx.BITMAP_TYPE_PNG),
     )
     self.tooltip = eg.APP_NAME + " " + eg.Version.string
     wx.TaskBarIcon.__init__(self)
     # SetIcon *must* be called immediately after creation, as otherwise
     # it won't appear on Vista restricted user accounts. (who knows why?)
     if show:
         self.Show()
     self.currentEvent = None
     self.processingEvent = None
     self.currentState = 0
     self.reentrantLock = threading.Lock()
     eg.Bind("ProcessingChange", self.OnProcessingChange)
     menu = self.menu = wx.Menu()
     text = eg.text.MainFrame.TaskBarMenu
     menu.Append(ID_SHOW, text.Show)
     menu.Append(ID_HIDE, text.Hide)
     menu.AppendSeparator()
     menu.Append(ID_EXIT, text.Exit)
     self.Bind(wx.EVT_MENU, self.OnCmdShow, id=ID_SHOW)
     self.Bind(wx.EVT_MENU, self.OnCmdHide, id=ID_HIDE)
     self.Bind(wx.EVT_MENU, self.OnCmdExit, id=ID_EXIT)
     self.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.OnTaskBarMenu)
     self.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.OnCmdShow)
예제 #4
0
    def __start__(
        self,
        ledRX=True,
        ledTX=True,
        legacyRX=False,
        repeatStopCodes=False,
    ):
        self.args = (ledRX, ledTX, legacyRX, repeatStopCodes)
        self.codeFormat = UUIRTDRV_IRFMT_PRONTO
        try:
            dll = WinDLL('uuirtdrv')
        except:
            raise self.Exceptions.DriverNotFound
        puDrvVersion = c_uint(0)
        if not dll.UUIRTGetDrvInfo(byref(puDrvVersion)):
            raise self.Exception("Unable to retrieve uuirtdrv version!")
        if puDrvVersion.value != 0x0100:
            raise self.Exception("Invalid uuirtdrv version!")

        if self.info.evalName[-1].isdigit():
            self.deviceStr = "USB-UIRT-%s" % self.info.evalName[-1]
        else:
            self.deviceStr = "USB-UIRT"
        hDrvHandle = dll.UUIRTOpenEx(self.deviceStr, 0, 0, 0)
        if hDrvHandle == INVALID_HANDLE_VALUE:
            err = GetLastError()
            if err == UUIRTDRV_ERR_NO_DLL:
                raise self.Exceptions.DriverNotFound
            elif err == UUIRTDRV_ERR_NO_DEVICE:
                raise self.Exceptions.DeviceNotFound
            elif err == UUIRTDRV_ERR_NO_RESP:
                raise self.Exceptions.DeviceInitFailed
            else:
                raise self.Exceptions.DeviceInitFailed
        self.hDrvHandle = hDrvHandle

        puuInfo = UUINFO()
        if not dll.UUIRTGetUUIRTInfo(hDrvHandle, byref(puuInfo)):
            raise self.Exceptions.DeviceInitFailed
        self.firmwareVersion = "%d.%d" % (puuInfo.fwVersion >> 8,
                                          puuInfo.fwVersion & 0xFF)
        self.protocolVersion = "%d.%d" % (puuInfo.protVersion >> 8,
                                          puuInfo.protVersion & 0xFF)
        self.firmwareDate = datetime.date(puuInfo.fwDateYear + 2000,
                                          puuInfo.fwDateMonth,
                                          puuInfo.fwDateDay)
        self.dll = dll
        self.receiveProc = UUCALLBACKPROC(self.ReceiveCallback)
        res = dll.UUIRTSetRawReceiveCallback(self.hDrvHandle, self.receiveProc,
                                             0)
        if not res:
            self.dll = None
            raise self.Exception("Error calling UUIRTSetRawReceiveCallback")

        self.SetConfig(ledRX, ledTX, legacyRX, repeatStopCodes)
        self.enabled = True
        eg.Bind("System.DeviceRemoved", self.OnDeviceRemoved)
예제 #5
0
 def __init__(self, parent, document, size=wx.DefaultSize):
     self.document = document
     self.root = None
     self.editLabelId = None
     self.insertionMark = None
     self.editControl = EditControlProxy(self)
     style = (
         wx.TR_HAS_BUTTONS |
         wx.TR_EDIT_LABELS |
         wx.TR_ROW_LINES |
         wx.CLIP_CHILDREN
     )
     wx.TreeCtrl.__init__(self, parent, size=size, style=style)
     self.SetImageList(eg.Icons.gImageList)
     self.hwnd = self.GetHandle()
     self.normalfont = self.GetFont()
     self.italicfont = self.GetFont()
     self.italicfont.SetStyle(wx.FONTSTYLE_ITALIC)
     self.Bind(wx.EVT_SET_FOCUS, self.OnGetFocusEvent)
     self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocusEvent)
     self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnItemExpandingEvent)
     self.Bind(wx.EVT_TREE_ITEM_COLLAPSING, self.OnItemCollapsingEvent)
     self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnBeginLabelEditEvent)
     self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEndLabelEditEvent)
     self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemActivateEvent)
     self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDoubleClickEvent)
     self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnRightClickEvent)
     self.Bind(wx.EVT_TREE_ITEM_MENU, self.OnItemMenuEvent)
     self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnBeginDragEvent)
     self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelectionChangedEvent)
     self.visibleNodes = {}
     self.expandedNodes = document.expandedNodes
     self.dropTarget = DropTarget(self)
     self.SetDropTarget(self.dropTarget)
     eg.Bind("NodeAdded", self.OnNodeAdded)
     eg.Bind("NodeDeleted", self.OnNodeDeleted)
     eg.Bind("NodeChanged", self.OnNodeChanged)
     eg.Bind("NodeSelected", self.OnNodeSelected)
     eg.Bind("DocumentNewRoot", self.OnNewRoot)
     if document.root:
         self.OnNewRoot(document.root)
예제 #6
0
 def __start__(
     self,
     port = 0,
     bType = '',
     initState = [0,0,0,0,0,0,0,0],
     prefix = "ICS_Relay"
 ):
     coms = self.enumerate_ports()
     self.coms = coms
     self.port = port
     self.bType = bType
     self.info.eventPrefix = prefix
     self.curState = initState[:]
     self.initState = initState[:]
     eg.Bind("System.DeviceAttached", self.InitBoard)
     eg.Bind("System.DeviceRemoved", self.DeleteBoard)
     if self.port in self.coms:
         self.ConnectPort()
         #bType = self.SelectBoard() # init or not ?
     else:
         eg.PrintNotice(self.text.info1 % (prefix, self.port + 1))
예제 #7
0
    def __init__(self, document):
        """
        Create the MainFrame
        """
        self.document = document
        self.findDialog = None
        self.openDialogs = []
        self.lastClickedTool = None
        self.egEvent = None
        self.lastFocus = None

        wx.Frame.__init__(self,
                          None,
                          -1,
                          document.GetTitle(),
                          pos=Config.position,
                          size=(1, 1),
                          style=self.style)
        self.SetMinSize((400, 200))
        document.frame = self
        auiManager = wx.aui.AuiManager(self, wx.aui.AUI_MGR_DEFAULT)
        self.auiManager = auiManager

        self.logCtrl = self.CreateLogCtrl()
        self.corConst = self.logCtrl.GetWindowBorderSize()[0] + \
            wx.SystemSettings.GetMetric(wx.SYS_VSCROLL_X)
        self.treeCtrl = self.CreateTreeCtrl()
        self.toolBar = self.CreateToolBar()
        self.menuBar = self.CreateMenuBar()
        self.statusBar = StatusBar(self)
        self.SetStatusBar(self.statusBar)

        # tree popup menu
        self.popupMenu = self.CreateTreePopupMenu()

        iconBundle = wx.IconBundle()
        iconBundle.AddIcon(eg.taskBarIcon.stateIcons[0])
        icon = wx.EmptyIcon()
        icon.LoadFile(join(eg.imagesDir, "icon32x32.png"), wx.BITMAP_TYPE_PNG)
        iconBundle.AddIcon(icon)
        self.SetIcons(iconBundle)

        self.Bind(wx.EVT_ICONIZE, self.OnIconize)
        self.Bind(wx.EVT_MENU_OPEN, self.OnMenuOpen)
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.mainSizeFlag = True
        self.ratioLock = False
        self.ratio = Config.ratio
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_MOVE, self.OnMove)
        self.Bind(wx.aui.EVT_AUI_PANE_CLOSE, self.OnPaneClose)
        self.Bind(wx.aui.EVT_AUI_PANE_MAXIMIZE, self.OnPaneMaximize)
        self.Bind(wx.aui.EVT_AUI_PANE_RESTORE, self.OnPaneRestore)
        self.UpdateViewOptions()
        self.SetSize(Config.size)
        eg.Bind("DocumentFileChange", self.OnDocumentFileChange)
        eg.Bind("DocumentChange", self.OnDocumentChange)
        eg.Bind("DialogCreate", self.OnAddDialog)
        eg.Bind("DialogDestroy", self.OnRemoveDialog)
        eg.Bind("UndoChange", self.OnUndoChange)
        self.OnUndoChange(document.undoState)
        eg.Bind("SelectionChange", self.OnSelectionChange)
        if document.selection is not None:
            self.OnSelectionChange(document.selection)
        eg.Bind("FocusChange", self.OnFocusChange)
        self.OnFocusChange(self.treeCtrl)
        eg.Bind("ClipboardChange", self.OnClipboardChange)
        # tell FrameManager to manage this frame
        if (Config.perspective is not None):
            try:
                auiManager.LoadPerspective(Config.perspective, False)
            except:
                pass
        artProvider = auiManager.GetArtProvider()
        artProvider.SetMetric(wx.aui.AUI_DOCKART_PANE_BORDER_SIZE, 0)
        artProvider.SetMetric(wx.aui.AUI_DOCKART_GRADIENT_TYPE,
                              wx.aui.AUI_GRADIENT_HORIZONTAL)
        artProvider.SetColour(wx.aui.AUI_DOCKART_INACTIVE_CAPTION_COLOUR,
                              eg.colour.inactiveCaption)
        artProvider.SetColour(
            wx.aui.AUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR,
            eg.colour.inactiveCaptionGradient)
        artProvider.SetColour(wx.aui.AUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR,
                              eg.colour.inactiveCaptionTextColour)
        auiManager.GetPane("tree").Caption(" " + Text.Tree.caption)
        self.toolBar.Show(Config.showToolbar)
        auiManager.Update()
        auiManager.GetPane("logger").MinSize((100, 100))\
            .Caption(" " + Text.Logger.caption)

        # create an accelerator for the "Log only assigned and activated
        # events" checkbox. An awful hack.
        @eg.LogIt
        def ToggleOnlyLogAssigned(dummyEvent):
            checkBox = self.statusBar.checkBox
            flag = not checkBox.GetValue()
            checkBox.SetValue(flag)
            eg.config.onlyLogAssigned = flag
            self.statusBar.SetCheckBoxColour(flag)

        toggleOnlyLogAssignedId = wx.NewId()
        wx.EVT_MENU(self, toggleOnlyLogAssignedId, ToggleOnlyLogAssigned)

        # find the accelerator key in the label of the checkbox
        labelText = eg.text.MainFrame.onlyLogAssigned
        result = re.search(r'&([a-z])', labelText, re.IGNORECASE)
        if result:
            hotKey = result.groups()[0].upper()
        else:
            hotKey = "L"

        # create an accelerator for the "Del" key. This way we can temporarily
        # disable it while editing a tree label.
        # (see TreeCtrl.py OnBeginLabelEdit and OnEndLabelEdit)

        def OnDelKey(dummyEvent):
            self.DispatchCommand('OnCmdDelete')

        delId = wx.NewId()
        wx.EVT_MENU(self, delId, OnDelKey)

        def OnEnterKey(dummyEvent):
            if self.lastFocus == self.treeCtrl.editControl:
                self.treeCtrl.EndEditLabel(self.treeCtrl.editLabelId, False)

        enterId = wx.NewId()
        wx.EVT_MENU(self, enterId, OnEnterKey)

        self.acceleratorTable = wx.AcceleratorTable([
            (wx.ACCEL_NORMAL, wx.WXK_DELETE, delId),
            (wx.ACCEL_NORMAL, wx.WXK_RETURN, enterId),
            (wx.ACCEL_ALT, ord(hotKey), toggleOnlyLogAssignedId),
        ])
        self.SetAcceleratorTable(self.acceleratorTable)
        self.logCtrl.Bind(wx.EVT_SIZE, self.OnLogCtrlSize)
        eg.EnsureVisible(self)