fixes
This commit is contained in:
parent
1581c3607e
commit
ddda7357ad
|
|
@ -14,12 +14,6 @@ else:
|
|||
|
||||
from .component import Component
|
||||
|
||||
# from pymodbus.client.sync import ModbusSerialClient as ModbusClient
|
||||
# import serial
|
||||
# client = ModbusClient(method="rtu", port="COM3", stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, baudrate=115200, timeout=1, strict=False)
|
||||
# client.connect()
|
||||
# client.read_holding_registers(1, count=1)
|
||||
|
||||
|
||||
class ModbusComponent(Component):
|
||||
def __init__(self, config=None, name=None, period=1, lazy=True, paused=False, threaded=True, registers=None):
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ registers = {
|
|||
2: "BLOCKAGE TEST",
|
||||
3: "LEAK TEST WITH VOLUME CHECK",
|
||||
4: "BURST TEST",
|
||||
},}],
|
||||
}, }],
|
||||
"Testing in progress: progressive sequence index": [48, {"dt": "16bit_uint", }],
|
||||
"Testing in progress: graphical sampling rate": [49, {"dt": "16bit_uint", }],
|
||||
"Testing in progress: number of samples of the graph": [50, {"dt": "16bit_uint", }],
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from pathlib import Path
|
|||
|
||||
app = None
|
||||
|
||||
|
||||
def quit_app(signalnum=None, handler=None):
|
||||
logging.info(f"quitting app. signal: {signalnum!r}, handler: {handler!r}")
|
||||
global app
|
||||
|
|
@ -51,10 +52,9 @@ logging.basicConfig(
|
|||
|
||||
try:
|
||||
# IMPORT PROJECT ONLY AFTER SETTING UP SIGNAL, FAULTHANDLER AND LOGGHING
|
||||
from components import (ArchiveSynchronizer, NeoPixels,
|
||||
Os_Label_Printer, RemoteAPI,
|
||||
TecnaMarpossProvasetT3, TestComponent, Vision,
|
||||
VisionSaver)
|
||||
from components import (ArchiveSynchronizer, NeoPixels, Os_Label_Printer,
|
||||
RemoteAPI, TecnaMarpossProvasetT3, TestComponent,
|
||||
Vision, VisionSaver)
|
||||
from lib.db import Users
|
||||
from lib.helpers import ConfigReader
|
||||
from PyQt5.QtCore import QObject, QThread, pyqtSignal
|
||||
|
|
|
|||
56
src/test/chart_memory_usage.py
Executable file
56
src/test/chart_memory_usage.py
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import traceback
|
||||
from time import perf_counter
|
||||
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.Qt.QtCore import QTimer
|
||||
from pyqtgraph.Qt.QtWidgets import QApplication, QGridLayout, QWidget
|
||||
|
||||
interval_ms = 250
|
||||
statm_index = 0 # use 5 to limit showing size of data + stack
|
||||
|
||||
|
||||
class App(QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# GUI SETUP
|
||||
self.layout = QGridLayout()
|
||||
self.setLayout(self.layout)
|
||||
# CHART SETUP
|
||||
self.plot_widget = pg.PlotWidget()
|
||||
self.plot_widget.enableAutoRange()
|
||||
self.layout.addWidget(self.plot_widget)
|
||||
self.plot_data = {"time": [], "size": []}
|
||||
self.plot = self.plot_widget.plot(*self.plot_data.values())
|
||||
# print(self.plot)
|
||||
# self.plot_widget.addItem(self.plot)
|
||||
# DATA SETUP
|
||||
self.pid = sys.argv[1]
|
||||
self.statm_file = f"/proc/{self.pid}/statm"
|
||||
# PERIODIC SETUP
|
||||
self.timer = QTimer()
|
||||
# self.timer.setSingleShot(True)
|
||||
self.timer.setInterval(interval_ms)
|
||||
self.timer.timeout.connect(self.add_data)
|
||||
self.start = perf_counter()
|
||||
self.timer.start()
|
||||
|
||||
def add_data(self):
|
||||
try:
|
||||
with open(self.statm_file, "r") as f:
|
||||
statm = f.read()
|
||||
self.plot_data["time"].append(perf_counter() - self.start)
|
||||
statm = statm.split()
|
||||
self.plot_data["size"].append(int(statm[statm_index]))
|
||||
self.plot.setData(*self.plot_data.values())
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
self.timer.start()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
window = App()
|
||||
window.show()
|
||||
sys.exit(app.exec_())
|
||||
Loading…
Reference in New Issue
Block a user