Beispiel #1
0
    def CommsConnect(self, event=None):
        """Connect comms"""
        if self.CommsIsConnected():
            return

        try:
            comms.getConnection().connect()

        except comms.CannotconnectException, msg:
            self._controller._error(msg)
    def CommsConnect(self, event = None):
        '''Connect comms'''
        if self.CommsIsConnected():
            return

        try:
            comms.getConnection().connect()

        except comms.CannotconnectException, msg:
            logger.error(msg)
    def insertRow(self, packet):
        '''
        Insert row into grid
        '''
        time = datetime.datetime.time(datetime.datetime.now())
        header = self.getHeaderFlags(packet)
        payload = packet.getPayload()
        
        #Format stuff before printing
        payload_id = packet.getPayloadIdInt()
        payload_id_hum = comms.getConnection().getProtocol().getPacketName(payload_id)
        payload_hex_hum = self.formatPayloadHex(payload)

        self.AppendRows()
        self.SetCellValue(self.row, 0, str(time))
        self.SetCellValue(self.row, 1, str(header))
        self.SetCellValue(self.row, 2, str(payload_id) + ":" + payload_id_hum)
        self.SetCellValue(self.row, 3, payload_hex_hum)

        # Make sure entire row is visible
        if self.GetCellOverflow(self.row, 3):
            lines = payload_hex_hum.count('\n') + 1
            self.SetRowSize(self.row, (lines * 15) + 3)

        self.MakeCellVisible(self.row + 1, 1)
        self.ForceRefresh()

        self.row += 1
Beispiel #4
0
    def _updateStatus(self):
        """
        Updates window title and statusbar text
        """
        # Generate title
        title = version.__title__

        # Set title
        self.SetTitle(title)

        # Set up statusbar
        if not self.statusbar:
            self.statusbar = wx.StatusBar(self, wx.ID_ANY)

        comm = comms.getConnection()

        fields = [
            "Interface: %s" % comm.getProtocol().getProtocolName(),
            "",
            "",
            "",
            "",
            "Connection: %s" % comm.getTitle(),
        ]
        self.statusbar.SetFields(fields)

        self.SetStatusBar(self.statusbar)
Beispiel #5
0
    def CreateDisplay(self, parent):
        """
        Create info display box"""
        display = wx.TextCtrl(parent, -1, style=wx.SUNKEN_BORDER | wx.VSCROLL | wx.HSCROLL | wx.TE_MULTILINE)
        display.SetEditable(False)

        comm = comms.getConnection()

        data = "System:\n"
        data += "--------------------\n"
        data += "Platform: %s\n" % sys.platform
        data += "Python version: %s\n" % str(sys.version).replace("\n", "")
        data += "Python path: %s\n" % sys.path
        data += "wxPython version: %s\n\n" % wx.__version__

        data += "FreeEMS:\n"
        data += "--------------------\n"
        data += "Tuner version: %s\n" % version.__revision__
        data += "Comms plugin: %s\n" % str(comm.__class__).split("'")[1]
        data += "Protocol plugin: %s\n" % comm.getProtocol().getProtocolName()
        data += "Data directory: %s\n\n" % libs.data.getPath()

        data += "Config:\n"
        data += "--------------------\n"

        # Update the config file (in case it hasn't been created yet)
        libs.config.save()

        configfile = open(libs.data.getPath() + "my_config.cached.ini", "r")
        data += "".join(configfile.readlines())
        configfile.close()

        display.SetValue(data)

        return display
    def __init__(self, parent):
        grid.Grid.__init__(self, parent)

        key = 'ui.commsdiagnostics.row.size.'
        width = []
        width.append( settings.get(key+'0', 110)    )
        width.append( settings.get(key+'1', 45)     )
        width.append( settings.get(key+'2', 75)     )
        width.append( settings.get(key+'3', 530)    )

        self.CreateGrid(        1, 4                )
        self.SetRowLabelSize(   50                  )
        self.SetColLabelValue(  0, 'Time'           )
        self.SetColSize(        0, int(width[0])    )
        self.SetColLabelValue(  1, 'Flags'          )             
        self.SetColSize(        1, int(width[1])    )
        self.SetColLabelValue(  2, 'Id'             )
        self.SetColSize(        2, int(width[2])    )
        self.SetColLabelValue(  3, 'Payload'        )
        self.SetColSize(        3, int(width[3])    )

        self.SetDefaultCellFont(wx.Font(8, wx.MODERN, wx.NORMAL, wx.NORMAL))

        # Get all column resizing
        self.Bind(grid.EVT_GRID_COL_SIZE, self.onResize)

        # Bind to connection
        self.conn = comms.getConnection()
        self.conn.bindSendWatcher(self.printSentPacket)
        self.conn.bindRecieveWatcher(self.printRecievedPacket)
Beispiel #7
0
    def CommsRecordingStart(self, event):
        '''
        Start recording comms
        '''
        timestamp = datetime.datetime.today().strftime('%Y%m%d%H%M%S')

        dialog = wx.FileDialog(
                parent = self,
                message = 'Comms Log File',
                defaultDir = 'data/',
                defaultFile = 'comms' + timestamp + '.bin',
                style = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)

        dialog.ShowModal()

        comms.getConnection().startRecording(dialog.GetPath())
Beispiel #8
0
    def CreateDisplay(self, parent):
        '''
        Create info display box'''
        display = wx.TextCtrl(parent, -1, style=wx.SUNKEN_BORDER | wx.VSCROLL | wx.HSCROLL | wx.TE_MULTILINE)
        display.SetEditable(False)

        comm = comms.getConnection()

        data  = 'System:\n'
        data += '--------------------\n'
        data += 'Platform: %s\n' % sys.platform
        data += 'Python version: %s\n' % str(sys.version).replace('\n', '')
        data += 'Python path: %s\n' % sys.path
        data += 'wxPython version: %s\n\n' % wx.__version__

        data += 'FreeEMS:\n'
        data += '--------------------\n'
        data += 'Tuner version: %s\n' % version.__revision__
        data += 'Comms plugin: %s\n' % type(comm)
        data += 'Protocol plugin: %s\n' % type(comm.getProtocol())
        data += 'Data directory: %s\n' % libs.data.getPath()

        display.SetValue(data)

        return display
Beispiel #9
0
    def CommsRecordingStart(self, event):
        """
        Start recording comms
        """
        timestamp = datetime.datetime.today().strftime("%Y%m%d%H%M%S")

        dialog = wx.FileDialog(
            parent=self,
            message="Comms Log File",
            defaultDir="data/logs/",
            defaultFile="comms" + timestamp + ".bin",
            style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
        )

        dialog.ShowModal()

        comms.getConnection().startRecording(dialog.GetPath())
Beispiel #10
0
    def _getComms(self):
        '''Return the protocols comm connection'''
        if not self._connection:
            self._connection = comms.getConnection()

        if not self._connection.isConnected():
            raise Exception, 'Serial comms not connected!'

        return self._connection 
Beispiel #11
0
    def _setupComms(self):
        '''
        Bind watcher method to comms
        '''
        # Bind to connection
        self._conn = comms.getConnection()
        self._conn.bindReceiveWatcher(self)

        # Bind to events
        self.Bind(comms.interface.EVT_RECEIVE, self.monitorPackets)
    def toggleLogging(self, event):
        '''
        Send packet to toggle logging
        '''
        # Check connected
        if not commsConnectWarning.confirmConnected(gui.frame):
            return

        protocol = comms.getConnection().getProtocol()
        packet = protocol.getRequestPacket('BasicDatalog')
        packet.startBasic()

        data = {'packet': packet}
        self._controller.action('comms.sendRequest', data)
    def __init__(self, parent):
        '''Setup UI elements'''
        wx.BoxSizer.__init__(self, wx.VERTICAL)
        
        self._controller = parent.controller

        self.text = wx.StaticText(parent, -1, 'Data to request', style=wx.ALIGN_CENTER)

        self.options = comms.getConnection().getProtocol().UTILITY_REQUEST_PACKETS
        self.choices = self.options.keys()

        self.input = wx.Choice(parent, -1, choices=self.choices)
        self.send = wx.Button(parent, self.ID_SEND_REQUEST, 'Send Request')

        self.Add((0,0), 1)
        self.Add(self.text, 3, wx.EXPAND)
        self.Add((0,0), 1)
        self.Add(self.input, 5, wx.EXPAND)
        self.Add((0,0), 1)
        self.Add(self.send, 5, wx.EXPAND)
        self.Add((0,0), 1)

        self.send.Bind(wx.EVT_BUTTON, self.sendRequest, id=self.ID_SEND_REQUEST)
    def __init__(self, parent):
        '''
        Setup UI elements
        '''
        wx.BoxSizer.__init__(self, wx.VERTICAL)

        self.controller = parent.GetParent().GetParent().getController()

        # Get payload id's
        self._options = options = comms.getConnection().getProtocol().getMemoryRequestPayloadIdList()
        for id in options.keys():
            self._p_options.append('%s (%d)' % (options[id], id))
            self._p_ids.append(id)

        self._p_text = wx.StaticText(parent, -1, 'Payload ID', style = wx.ALIGN_CENTER)
        self._p_input = wx.Choice(parent, -1, choices = self._p_options)

        # Get block id's
        try:
            locations = data.loadProtocolDataFile('location_ids')['FreeEMSLocationIDs']
            location_keys = []
            for key in locations.keys():
                location_keys.append(int(key))

            location_keys.sort()
            
            options = {}
            for location in location_keys:
                self._b_options.append('%s (%d)' % (locations[str(location)], location))
                self._b_ids.append(location)

        except KeyError, e:
            # Data file appears to be formed incorrectly
            logger.error('Data location ids data file appears to be formed incorrectly: %s' % e)
            self._b_options = []
            self._b_ids = []
Beispiel #15
0
 def CommsIsRecording(self):
     """
     Check if comms is recording
     """
     return comms.getConnection().isRecording()
 def CommsIsConnected(self):
     '''Check if comms is connected'''
     return comms.getConnection().isConnected()
    def CommsReceive(self, event = None):
        '''Check for any packets in the buffer'''
        if not self.CommsIsConnected():
            return

        comms.getConnection().recieve()
    def CommsDisconnect(self, event):
        '''Disconnect comms'''
        if not self.CommsIsConnected():
            return

        comms.getConnection().disconnect()
Beispiel #19
0
 def CommsRecordingStop(self, event):
     '''
     Stop recording comms
     '''
     comms.getConnection().stopRecording()
Beispiel #20
0
 def CommsIsRecording(self):
     '''
     Check if comms is recording
     '''
     return comms.getConnection().isRecording()
Beispiel #21
0
 def CommsIsConnected(self):
     """
     Check if comms is connected
     """
     return comms.getConnection().isConnected()
Beispiel #22
0
 def CommsRecordingStop(self, event):
     """
     Stop recording comms
     """
     comms.getConnection().stopRecording()