Initial modifications to account for differential hashboard counts
Now storing the hasboard data as an array of datastructs. Not fully fleshed out yet, but this is where I'm going.
This commit is contained in:
@@ -15,12 +15,23 @@
|
|||||||
from typing import Union, List
|
from typing import Union, List
|
||||||
from dataclasses import dataclass, field, asdict
|
from dataclasses import dataclass, field, asdict
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
from functools import reduce
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from .error_codes import X19Error, WhatsminerError, BraiinsOSError, InnosiliconError
|
from .error_codes import X19Error, WhatsminerError, BraiinsOSError, InnosiliconError
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class HashBoard:
|
||||||
|
slot: int = 0
|
||||||
|
hashrate: float = 0.0
|
||||||
|
temp: int = -1
|
||||||
|
chip_temp: int = -1
|
||||||
|
chips: int = 0
|
||||||
|
expected_chips: int = 0
|
||||||
|
missing: bool = True
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class MinerData:
|
class MinerData:
|
||||||
@@ -108,6 +119,10 @@ class MinerData:
|
|||||||
] = field(default_factory=list)
|
] = field(default_factory=list)
|
||||||
fault_light: Union[bool, None] = None
|
fault_light: Union[bool, None] = None
|
||||||
efficiency: int = field(init=False)
|
efficiency: int = field(init=False)
|
||||||
|
hashboards: List[HashBoard] = field(default_factory=list)
|
||||||
|
ideal_hashboards: int = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
self.datetime = datetime.now(timezone.utc).astimezone()
|
self.datetime = datetime.now(timezone.utc).astimezone()
|
||||||
@@ -162,9 +177,13 @@ class MinerData:
|
|||||||
return cp
|
return cp
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def total_chips(self): # noqa - Skip PyCharm inspection
|
def old_total_chips(self): # noqa - Skip PyCharm inspection
|
||||||
return self.right_chips + self.center_chips + self.left_chips
|
return self.right_chips + self.center_chips + self.left_chips
|
||||||
|
|
||||||
|
@property
|
||||||
|
def total_chips(self): # noqa - Skip PyCharm inspection
|
||||||
|
return reduce(lambda x, y: x + y, [board.chips for board in self.hashboards])
|
||||||
|
|
||||||
@total_chips.setter
|
@total_chips.setter
|
||||||
def total_chips(self, val):
|
def total_chips(self, val):
|
||||||
pass
|
pass
|
||||||
@@ -186,7 +205,7 @@ class MinerData:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def temperature_avg(self): # noqa - Skip PyCharm inspection
|
def old_temperature_avg(self): # noqa - Skip PyCharm inspection
|
||||||
total_temp = 0
|
total_temp = 0
|
||||||
temp_count = 0
|
temp_count = 0
|
||||||
for temp in [
|
for temp in [
|
||||||
@@ -201,6 +220,18 @@ class MinerData:
|
|||||||
return 0
|
return 0
|
||||||
return round(total_temp / temp_count)
|
return round(total_temp / temp_count)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def temperature_avg(self): # noqa - Skip PyCharm inspection
|
||||||
|
total_temp = 0
|
||||||
|
temp_count = 0
|
||||||
|
for temp in self.hashboards:
|
||||||
|
if temp.temp and not temp.temp == -1:
|
||||||
|
total_temp += temp.temp
|
||||||
|
temp_count += 1
|
||||||
|
if not temp_count > 0:
|
||||||
|
return 0
|
||||||
|
return round(total_temp / temp_count)
|
||||||
|
|
||||||
@temperature_avg.setter
|
@temperature_avg.setter
|
||||||
def temperature_avg(self, val):
|
def temperature_avg(self, val):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from pyasic.API.btminer import BTMinerAPI
|
|||||||
from pyasic.miners.base import BaseMiner
|
from pyasic.miners.base import BaseMiner
|
||||||
from pyasic.errors import APIError
|
from pyasic.errors import APIError
|
||||||
|
|
||||||
from pyasic.data import MinerData
|
from pyasic.data import MinerData, HashBoard
|
||||||
from pyasic.data.error_codes import WhatsminerError, MinerErrorData
|
from pyasic.data.error_codes import WhatsminerError, MinerErrorData
|
||||||
from pyasic.config import MinerConfig
|
from pyasic.config import MinerConfig
|
||||||
|
|
||||||
@@ -254,7 +254,7 @@ class BTMiner(BaseMiner):
|
|||||||
Returns:
|
Returns:
|
||||||
A [`MinerData`][pyasic.data.MinerData] instance containing the miners data.
|
A [`MinerData`][pyasic.data.MinerData] instance containing the miners data.
|
||||||
"""
|
"""
|
||||||
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3)
|
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * self.ideal_hashboards)
|
||||||
|
|
||||||
mac = None
|
mac = None
|
||||||
|
|
||||||
@@ -372,6 +372,23 @@ class BTMiner(BaseMiner):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if devs:
|
||||||
|
dev_data = devs.get("DEVS")
|
||||||
|
if dev_data:
|
||||||
|
for board in dev_data:
|
||||||
|
temp_board = HashBoard(
|
||||||
|
slot = board["ASC"],
|
||||||
|
chip_temp = round(board["Chip Temp Avg"]),
|
||||||
|
temp = round(board["Temperature"]),
|
||||||
|
hashrate = round(board["MHS 1m"] / 1000000, 2),
|
||||||
|
chips = board["Effective Chips"],
|
||||||
|
missing = False if board["Effective Chips"] > 0 else True,
|
||||||
|
expected_chips = self.nominal_chips,
|
||||||
|
)
|
||||||
|
data.hashboards.append(temp_board)
|
||||||
|
|
||||||
|
"""
|
||||||
if devs:
|
if devs:
|
||||||
temp_data = devs.get("DEVS")
|
temp_data = devs.get("DEVS")
|
||||||
if temp_data:
|
if temp_data:
|
||||||
@@ -398,7 +415,7 @@ class BTMiner(BaseMiner):
|
|||||||
for board in boards:
|
for board in boards:
|
||||||
_id = board[id_key] - offset
|
_id = board[id_key] - offset
|
||||||
chips = board["Effective Chips"]
|
chips = board["Effective Chips"]
|
||||||
setattr(data, board_map[_id], chips)
|
setattr(data, board_map[_id], chips)"""
|
||||||
|
|
||||||
if pools:
|
if pools:
|
||||||
pool_1 = None
|
pool_1 = None
|
||||||
|
|||||||
Reference in New Issue
Block a user