示例#1
0
from serial.tools.list_ports import comports

# list the input decoder classes that could be used as specified in config.py
from get_csv import CSV_Buffer
from get_csv_w_timestamp import CSV_TS_Buffer
from get_binary import DecodeBinary

from plot_data import PlotData

from init import NoConfig, logset
try:
    from config import config
except ModuleNotFoundError:
    raise NoConfig

debug, info, warn, err = logset('scope')


class MainWindow(QtWidgets.QMainWindow):
    """ Create the main window from the Qt Designer generated file """
    def __init__(self):
        super().__init__()
        uic.loadUi('data_scope.ui', self)

        # Graph window

        self.scope = self.graph.addPlot()
        self.scope.setDownsampling(mode='peak')

        # Scroll window
示例#2
0
# -*- coding: utf-8 -*-
"""
Get csv formatted data from a file and buffer for plotting
"""
from data_thread import DataThread

from init import NoConfig, logset
try:
    from config import config
except ModuleNotFoundError:
    raise NoConfig

debug, info, warn, err = logset('data')


class LoadFile_Buffer(DataThread):
    """ reads csv formatted data from a file and converts it into data
        points to be further processed and graphed.
    """
    def __init__(self, file_name):
        super().__init__()
        self.max_signal_count = config["max_signal_count"]
        self.file_name = file_name

    def open(self):
        try:
            self.source = open(self.file_name, 'r')
        except Exception:
            return False
        return True
示例#3
0
''' serialport.py Wrapper of PySerial library '''

from serial.tools.list_ports import comports

from init import logset  # @UnresolvedImport
debug, info, warn, err = logset('serial')


def port_available(self, portname):
    ''' Check if port is currently available '''
    ports = comports()
    if ports == None:
        return False
    names, _descs, _hdwrIDs = zip(*ports)
    return portname in names


def list_ports():
    ''' List the connected comm ports'''
    portnames = [a[0] for a in comports()]
    for portinfo in comports():
        portname, description, hdwrID = portinfo
        info("{} {} {}".format(portname, description, hdwrID))
    return portnames
示例#4
0
import numpy as np
from bisect import bisect_left

from init import NoConfig, logset
try:
    from config import config
except ModuleNotFoundError:
    raise NoConfig

debug, info, warn, err = logset('plot')


class PlotData():
    def __init__(self, scope, scroll, signal):
        self.name = signal["name"]
        self.color = signal["color"]  # See pyqtgraph.mkColor()
        self.width = signal["width"]
        self.precision = signal["precision"]
        self.scale = signal["scale"]
        kwargs = signal.get("kwargs", {})
        self.scope = scope.plot(pen=self.color, name=self.name, **kwargs)
        self.scroll = scroll.plot(pen=self.color, name=self.name)
        self.size = 10000
        self.data = np.empty(self.size)
        self.tstamp = np.empty(self.size)
        self.ptr = 0

    def reset(self):
        self.data = np.empty(self.size)
        self.tstamp = np.empty(self.size)
        self.ptr = 0