feature: add new HashBoard data structure to bmminer, and add ideal_hashboards to BaseMiner.
This commit is contained in:
@@ -20,7 +20,7 @@ from typing import Union, List
|
|||||||
from pyasic.API.bmminer import BMMinerAPI
|
from pyasic.API.bmminer import BMMinerAPI
|
||||||
from pyasic.miners.base import BaseMiner
|
from pyasic.miners.base import BaseMiner
|
||||||
|
|
||||||
from pyasic.data import MinerData
|
from pyasic.data import MinerData, HashBoard
|
||||||
from pyasic.config import MinerConfig
|
from pyasic.config import MinerConfig
|
||||||
from pyasic.data.error_codes import MinerErrorData
|
from pyasic.data.error_codes import MinerErrorData
|
||||||
|
|
||||||
@@ -252,30 +252,37 @@ class BMMiner(BaseMiner):
|
|||||||
if board_offset == -1:
|
if board_offset == -1:
|
||||||
board_offset = 1
|
board_offset = 1
|
||||||
|
|
||||||
data.left_chips = boards[1].get(f"chain_acn{board_offset}")
|
env_temp_list = []
|
||||||
data.center_chips = boards[1].get(f"chain_acn{board_offset+1}")
|
for i in range(board_offset, board_offset + self.ideal_hashboards):
|
||||||
data.right_chips = boards[1].get(f"chain_acn{board_offset+2}")
|
hashboard = HashBoard(
|
||||||
|
slot=i - board_offset, expected_chips=self.nominal_chips
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
chip_temp = boards[1].get(f"temp{i}")
|
||||||
data.left_board_hashrate = round(
|
if chip_temp:
|
||||||
float(boards[1].get(f"chain_rate{board_offset}")) / 1000, 2
|
hashboard.chip_temp = round(chip_temp)
|
||||||
)
|
|
||||||
except ValueError as e:
|
temp = boards[1].get(f"temp2_{i}")
|
||||||
data.left_board_hashrate = round(0.00, 2)
|
if temp:
|
||||||
try:
|
hashboard.temp = round(temp)
|
||||||
data.center_board_hashrate = round(
|
|
||||||
float(boards[1].get(f"chain_rate{board_offset+1}")) / 1000,
|
hashrate = boards[1].get(f"chain_rate{i}")
|
||||||
2,
|
if hashrate:
|
||||||
)
|
hashboard.hashrate = round(float(hashrate) / 1000, 2)
|
||||||
except ValueError as e:
|
|
||||||
data.center_board_hashrate = round(0.00, 2)
|
chips = boards[1].get(f"chain_acn{i}")
|
||||||
try:
|
if chips:
|
||||||
data.right_board_hashrate = round(
|
hashboard.chips = chips
|
||||||
float(boards[1].get(f"chain_rate{board_offset+2}")) / 1000,
|
hashboard.missing = False
|
||||||
2,
|
if (not chips) or (not chips > 0):
|
||||||
)
|
hashboard.missing = True
|
||||||
except ValueError as e:
|
data.hashboards.append(hashboard)
|
||||||
data.right_board_hashrate = round(0.00, 2)
|
if f"temp_pcb{i}" in temp[1].keys():
|
||||||
|
env_temp = temp[1][f"temp_pcb{i}"].split("-")[0]
|
||||||
|
if not env_temp == 0:
|
||||||
|
env_temp_list.append(int(env_temp))
|
||||||
|
if not env_temp_list == []:
|
||||||
|
data.env_temp = sum(env_temp_list) / len(env_temp_list)
|
||||||
|
|
||||||
if stats:
|
if stats:
|
||||||
temp = stats.get("STATS")
|
temp = stats.get("STATS")
|
||||||
@@ -293,20 +300,6 @@ class BMMiner(BaseMiner):
|
|||||||
data, f"fan_{fan + 1}", temp[1].get(f"fan{fan_offset+fan}")
|
data, f"fan_{fan + 1}", temp[1].get(f"fan{fan_offset+fan}")
|
||||||
)
|
)
|
||||||
|
|
||||||
board_map = {0: "left_board", 1: "center_board", 2: "right_board"}
|
|
||||||
env_temp_list = []
|
|
||||||
for item in range(3):
|
|
||||||
board_temp = temp[1].get(f"temp{item + board_offset}")
|
|
||||||
chip_temp = temp[1].get(f"temp2_{item + board_offset}")
|
|
||||||
setattr(data, f"{board_map[item]}_chip_temp", chip_temp)
|
|
||||||
setattr(data, f"{board_map[item]}_temp", board_temp)
|
|
||||||
if f"temp_pcb{item}" in temp[1].keys():
|
|
||||||
env_temp = temp[1][f"temp_pcb{item}"].split("-")[0]
|
|
||||||
if not env_temp == 0:
|
|
||||||
env_temp_list.append(int(env_temp))
|
|
||||||
if not env_temp_list == []:
|
|
||||||
data.env_temp = sum(env_temp_list) / len(env_temp_list)
|
|
||||||
|
|
||||||
if pools:
|
if pools:
|
||||||
pool_1 = None
|
pool_1 = None
|
||||||
pool_2 = None
|
pool_2 = None
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class BaseMiner(ABC):
|
|||||||
self.version = None
|
self.version = None
|
||||||
self.fan_count = 2
|
self.fan_count = 2
|
||||||
self.config = None
|
self.config = None
|
||||||
|
self.ideal_hashboards = 3
|
||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
if cls is BaseMiner:
|
if cls is BaseMiner:
|
||||||
|
|||||||
Reference in New Issue
Block a user