feature: add cgminer support for new HashBoard structure
This commit is contained in:
@@ -22,7 +22,7 @@ from pyasic.miners.base import BaseMiner
|
|||||||
from pyasic.errors import APIError
|
from pyasic.errors import APIError
|
||||||
from pyasic.config import MinerConfig
|
from pyasic.config import MinerConfig
|
||||||
|
|
||||||
from pyasic.data import MinerData
|
from pyasic.data import MinerData, HashBoard
|
||||||
from pyasic.data.error_codes import MinerErrorData
|
from pyasic.data.error_codes import MinerErrorData
|
||||||
|
|
||||||
from pyasic.settings import PyasicSettings
|
from pyasic.settings import PyasicSettings
|
||||||
@@ -179,7 +179,9 @@ class CGMiner(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, ideal_hashboards=self.ideal_hashboards,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
board_offset = -1
|
board_offset = -1
|
||||||
fan_offset = -1
|
fan_offset = -1
|
||||||
@@ -235,19 +237,37 @@ class CGMiner(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
|
||||||
|
)
|
||||||
|
|
||||||
data.left_board_hashrate = round(
|
chip_temp = boards[1].get(f"temp{i}")
|
||||||
float(boards[1].get(f"chain_rate{board_offset}")) / 1000, 2
|
if chip_temp:
|
||||||
)
|
hashboard.chip_temp = round(chip_temp)
|
||||||
data.center_board_hashrate = round(
|
|
||||||
float(boards[1].get(f"chain_rate{board_offset+1}")) / 1000, 2
|
temp = boards[1].get(f"temp2_{i}")
|
||||||
)
|
if temp:
|
||||||
data.right_board_hashrate = round(
|
hashboard.temp = round(temp)
|
||||||
float(boards[1].get(f"chain_rate{board_offset+2}")) / 1000, 2
|
|
||||||
)
|
hashrate = boards[1].get(f"chain_rate{i}")
|
||||||
|
if hashrate:
|
||||||
|
hashboard.hashrate = round(float(hashrate) / 1000, 2)
|
||||||
|
|
||||||
|
chips = boards[1].get(f"chain_acn{i}")
|
||||||
|
if chips:
|
||||||
|
hashboard.chips = chips
|
||||||
|
hashboard.missing = False
|
||||||
|
if (not chips) or (not chips > 0):
|
||||||
|
hashboard.missing = True
|
||||||
|
data.hashboards.append(hashboard)
|
||||||
|
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")
|
||||||
@@ -265,19 +285,6 @@ class CGMiner(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))
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user