added chip percent to config tool
This commit is contained in:
@@ -9,11 +9,12 @@ class MinerData:
|
||||
hashrate: float = 0
|
||||
temperature: float = 0
|
||||
wattage: int = 0
|
||||
ideal_chips: int = 0
|
||||
left_chips: int = 0
|
||||
center_chips: int = 0
|
||||
right_chips: int = 0
|
||||
total_chips: int = field(init=False)
|
||||
ideal_chips: int = 0
|
||||
percent_ideal: float = field(init=False)
|
||||
nominal: int = field(init=False)
|
||||
pool_split: str = 0
|
||||
pool_1_url: str = "Unknown"
|
||||
@@ -37,13 +38,17 @@ class MinerData:
|
||||
def nominal(self, val):
|
||||
pass
|
||||
|
||||
@property
|
||||
def percent_ideal(self): # noqa - Skip PyCharm inspection
|
||||
return round((self.total_chips / self.ideal_chips) * 100)
|
||||
|
||||
@percent_ideal.setter
|
||||
def percent_ideal(self, val):
|
||||
pass
|
||||
|
||||
def __post_init__(self):
|
||||
self.total_chips = self.right_chips + self.center_chips + self.left_chips
|
||||
self.nominal = self.ideal_chips == self.total_chips
|
||||
|
||||
def asdict(self):
|
||||
return asdict(self)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(MinerData(ip="192.168.1.1").asdict())
|
||||
|
||||
@@ -97,6 +97,7 @@ TABLE_HEADERS = {
|
||||
"Model",
|
||||
"Ideal",
|
||||
"Total",
|
||||
"Chip %",
|
||||
"Left Board",
|
||||
"Center Board",
|
||||
"Right Board",
|
||||
@@ -176,6 +177,7 @@ WATTAGE_COL_WIDTH = 10
|
||||
SPLIT_COL_WIDTH = 8
|
||||
TOTAL_CHIP_WIDTH = 9
|
||||
IDEAL_CHIP_WIDTH = 9
|
||||
CHIP_PERCENT_WIDTH = 10
|
||||
SCAN_COL_WIDTHS = [
|
||||
IP_COL_WIDTH,
|
||||
MODEL_COL_WIDTH,
|
||||
@@ -279,6 +281,7 @@ def get_boards_layout():
|
||||
MODEL_COL_WIDTH,
|
||||
TOTAL_CHIP_WIDTH,
|
||||
IDEAL_CHIP_WIDTH,
|
||||
CHIP_PERCENT_WIDTH,
|
||||
]
|
||||
add_length = TABLE_TOTAL_WIDTH - sum(BOARDS_COL_WIDTHS)
|
||||
for i in range(3):
|
||||
|
||||
@@ -26,6 +26,7 @@ DATA_HEADER_MAP = {
|
||||
"pool_1_user": "Pool 1 User",
|
||||
"pool_2_url": "Pool 2",
|
||||
"pool_2_user": "Pool 2 User",
|
||||
"percent_ideal": "Chip %",
|
||||
}
|
||||
|
||||
DEFAULT_DATA = set()
|
||||
@@ -117,5 +118,6 @@ async def _get_data(miner):
|
||||
_data = (await miner.get_data()).asdict()
|
||||
data = {}
|
||||
for item in _data.keys():
|
||||
data[DATA_HEADER_MAP[item]] = _data[item]
|
||||
if item in DATA_HEADER_MAP.keys():
|
||||
data[DATA_HEADER_MAP[item]] = _data[item]
|
||||
return data
|
||||
|
||||
@@ -139,6 +139,11 @@ class TableManager(metaclass=Singleton):
|
||||
item[
|
||||
"Hashrate"
|
||||
] = f"{format(float(item['Hashrate']), '.2f').rjust(6, ' ')} TH/s"
|
||||
|
||||
if "Chip %" in keys:
|
||||
if not isinstance(item["Chip %"], str):
|
||||
item["Chip %"] = f"{item['Chip %']}%"
|
||||
|
||||
for _key in keys:
|
||||
for table in TABLE_HEADERS.keys():
|
||||
for idx, header in enumerate(TABLE_HEADERS[table]):
|
||||
@@ -182,6 +187,9 @@ class TableManager(metaclass=Singleton):
|
||||
if self.sort_key == "IP":
|
||||
return ipaddress.ip_address(self.data[data_key]["IP"])
|
||||
|
||||
if self.sort_key == "Chip %":
|
||||
return int((self.data[data_key]["Chip %"]).replace("%", ""))
|
||||
|
||||
if self.sort_key == "Hashrate":
|
||||
if self.data[data_key]["Hashrate"] == "":
|
||||
return -1
|
||||
|
||||
Reference in New Issue
Block a user