-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodbus.py
23 lines (18 loc) · 933 Bytes
/
modbus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from PyQt5.QtWidgets import QTableWidgetItem
from config_reader import ConfigReader
class Modbus(ConfigReader):
def __init__(self, config: dict):
super().__init__(config, 'modbus')
def get_info(self):
self.store = self.get_yaml_file('/docker/modbus4mqtt/sungrow_sh10rt.yaml')
def show_info(self):
headers = ['address', 'table', 'pub_topic', 'type', 'unit', 'retain', 'sensor_type']
self.table_widget.clear()
self.table_widget.setColumnCount(len(headers))
self.table_widget.setHorizontalHeaderLabels(headers)
self.table_widget.setRowCount(len(self.store['registers']))
for i, register in enumerate(self.store['registers']):
for j, header in enumerate(headers):
self.table_widget.setItem(i, j, QTableWidgetItem(str(register.get(header, ''))))
self.table_widget.resizeColumnsToContents()
self.autosize_window()