-
Notifications
You must be signed in to change notification settings - Fork 0
/
slave_mapping.py
30 lines (25 loc) · 1.37 KB
/
slave_mapping.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from PyQt5.QtWidgets import QTableWidgetItem
from config_reader import ConfigReader
class SlaveMapping(ConfigReader):
def __init__(self, config: dict):
super().__init__(config, 'slave_mapping')
def get_info(self):
self.store = self.get_yaml_file('/docker/build/easybms-master/slave_mapping.yaml')
def show_info(self):
headers = ['Number', 'Mac', 'Assignments']
self.table_widget.clear()
self.table_widget.setColumnCount(len(headers))
self.table_widget.setHorizontalHeaderLabels(headers)
self.table_widget.setRowCount(len(self.store['slaves']))
for i, slave_mac in enumerate(self.store['slaves']):
slave: dict = self.store['slaves'][slave_mac]
self.table_widget.setItem(i, headers.index('Number'), QTableWidgetItem(str(slave['number'])))
self.table_widget.setItem(i, headers.index('Mac'), QTableWidgetItem(slave_mac))
assignments = []
if slave.get('total_current_measurer', False):
assignments.append('total_current_measurer')
if slave.get('total_voltage_measurer', False):
assignments.append('total_voltage_measurer')
self.table_widget.setItem(i, headers.index('Assignments'), QTableWidgetItem(', '.join(assignments)))
self.table_widget.resizeColumnsToContents()
self.autosize_window()