finished updating the miner type handlers to create subclasses of the backend and type to create a miner, each of which handles its own data to simplify creation of new miner types
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
from miners.cgminer import CGMiner
|
||||
import logging
|
||||
|
||||
|
||||
class CGMinerAvalon10(CGMiner):
|
||||
def __init__(self, ip: str) -> None:
|
||||
super().__init__(ip)
|
||||
self.model = "Avalon 10"
|
||||
self.api_type = "CGMiner"
|
||||
self.nominal_chips = 114
|
||||
|
||||
async def get_hostname(self):
|
||||
try:
|
||||
devdetails = await self.api.devdetails()
|
||||
if devdetails:
|
||||
if len(devdetails.get("DEVDETAILS")) > 0:
|
||||
if "Name" in devdetails["DEVDETAILS"][0]:
|
||||
host = devdetails["DEVDETAILS"][0]["Name"]
|
||||
logging.debug(f"Found hostname for {self.ip}: {host}")
|
||||
return host
|
||||
except Exception as e:
|
||||
logging.warning(f"Failed to get hostname for miner: {self}")
|
||||
return "?"
|
||||
logging.warning(f"Failed to get hostname for miner: {self}")
|
||||
return "?"
|
||||
|
||||
async def get_board_info(self):
|
||||
boards_chips = 0
|
||||
logging.debug(f"{self}: Getting board info.")
|
||||
stats = await self.api.stats()
|
||||
if not stats.get("STATS") and not stats.get("STATS") == []:
|
||||
print("stats error", stats)
|
||||
return {0: [], 1: [], 2: []}
|
||||
stats = stats["STATS"][0]
|
||||
for key in stats.keys():
|
||||
if key.startswith("MM") and not stats[key] == 1:
|
||||
data = stats[key]
|
||||
for line in data.split("]"):
|
||||
if "TA[" in line:
|
||||
total_chips = line.replace("TA[", "")
|
||||
boards_chips = round(int(total_chips)/3)
|
||||
boards = {}
|
||||
for board in [0, 1, 2]:
|
||||
if not boards_chips == self.nominal_chips:
|
||||
nominal = False
|
||||
else:
|
||||
nominal = True
|
||||
boards[board] = []
|
||||
boards[board].append({
|
||||
"chain": board,
|
||||
"chip_count": boards_chips,
|
||||
"chip_status": "o" * boards_chips,
|
||||
"nominal": nominal,
|
||||
})
|
||||
return boards
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
from miners.cgminer import CGMiner
|
||||
import re
|
||||
|
||||
|
||||
class CGMinerAvalon8(CGMiner):
|
||||
def __init__(self, ip: str) -> None:
|
||||
super().__init__(ip)
|
||||
self.model = "Avalon 8"
|
||||
self.api_type = "CGMiner"
|
||||
self.pattern = re.compile(
|
||||
r"Ver\[(?P<Ver>[-0-9A-Fa-f+]+)\]\s"
|
||||
"DNA\[(?P<DNA>[0-9A-Fa-f]+)\]\s"
|
||||
"Elapsed\[(?P<Elapsed>[-0-9]+)\]\s"
|
||||
"MW\[(?P<MW>[-\s0-9]+)\]\s"
|
||||
"LW\[(?P<LW>[-0-9]+)\]\s"
|
||||
"MH\[(?P<MH>[-\s0-9]+)\]\s"
|
||||
"HW\[(?P<HW>[-0-9]+)\]\s"
|
||||
"Temp\[(?P<Temp>[0-9]+)\]\s"
|
||||
"TMax\[(?P<TMax>[0-9]+)\]\s"
|
||||
"Fan\[(?P<Fan>[0-9]+)\]\s"
|
||||
"FanR\[(?P<FanR>[0-9]+)%\]\s"
|
||||
"Vi\[(?P<Vi>[-\s0-9]+)\]\s"
|
||||
"Vo\[(?P<Vo>[-\s0-9]+)\]\s"
|
||||
"("
|
||||
"PLL0\[(?P<PLL0>[-\s0-9]+)\]\s"
|
||||
"PLL1\[(?P<PLL1>[-\s0-9]+)\]\s"
|
||||
"PLL2\[(?P<PLL2>[-\s0-9]+)\]\s"
|
||||
"PLL3\[(?P<PLL3>[-\s0-9]+)\]\s"
|
||||
")?"
|
||||
"GHSmm\[(?P<GHSmm>[-.0-9]+)\]\s"
|
||||
"WU\[(?P<WU>[-.0-9]+)\]\s"
|
||||
"Freq\[(?P<Freq>[.0-9]+)\]\s"
|
||||
"PG\[(?P<PG>[0-9]+)\]\s"
|
||||
"Led\[(?P<LED>0|1)\]\s"
|
||||
"MW0\[(?P<MW0>[0-9\s]+)\]\s"
|
||||
"MW1\[(?P<MW1>[0-9\s]+)\]\s"
|
||||
"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"PVT_V3_23\[(?P<PVT_V3_23>[-0-9\s]+)\]\s"
|
||||
"PVT_V3_24\[(?P<PVT_V3_24>[-0-9\s]+)\]\s"
|
||||
"PVT_V3_25\[(?P<PVT_V3_25>[-0-9\s]+)\]\s"
|
||||
"FM\[(?P<FM>[0-9]+)\]\s"
|
||||
"CRC\[(?P<CRC>[0-9\s]+)\]",
|
||||
re.X,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"CGMinerAvalon8: {str(self.ip)}"
|
||||
|
||||
def parse_estats(self, estats):
|
||||
for estat in estats:
|
||||
for key in estat:
|
||||
if key[:5] == "MM ID":
|
||||
self._parse_estat(estat, key)
|
||||
|
||||
def _parse_estat(self, estat, key):
|
||||
module = estat[key]
|
||||
module_info = re.match(self.pattern, module)
|
||||
if not module_info:
|
||||
return None
|
||||
module_info = module_info.groupdict()
|
||||
print(module_info)
|
||||
@@ -1,11 +1 @@
|
||||
from miners.cgminer import CGMiner
|
||||
|
||||
|
||||
class CGMinerAvalon(CGMiner):
|
||||
def __init__(self, ip: str) -> None:
|
||||
super().__init__(ip)
|
||||
self.model = "Avalon"
|
||||
self.api_type = "CGMiner"
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"CGMinerAvalon: {str(self.ip)}"
|
||||
from .cgminer import *
|
||||
|
||||
8
miners/avalonminer/cgminer/A10X/A1047.py
Normal file
8
miners/avalonminer/cgminer/A10X/A1047.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from miners._backends import CGMiner
|
||||
from miners._types import Avalon1047
|
||||
|
||||
|
||||
class CGMinerAvalon1047(CGMiner, Avalon1047):
|
||||
def __init__(self, ip: str) -> None:
|
||||
super().__init__(ip)
|
||||
self.ip = ip
|
||||
8
miners/avalonminer/cgminer/A10X/A1066.py
Normal file
8
miners/avalonminer/cgminer/A10X/A1066.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from miners._backends import CGMiner
|
||||
from miners._types import Avalon1066
|
||||
|
||||
|
||||
class CGMinerAvalon1066(CGMiner, Avalon1066):
|
||||
def __init__(self, ip: str) -> None:
|
||||
super().__init__(ip)
|
||||
self.ip = ip
|
||||
2
miners/avalonminer/cgminer/A10X/__init__.py
Normal file
2
miners/avalonminer/cgminer/A10X/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from .A1047 import CGMinerAvalon1047
|
||||
from .A1066 import CGMinerAvalon1066
|
||||
8
miners/avalonminer/cgminer/A8X/A821.py
Normal file
8
miners/avalonminer/cgminer/A8X/A821.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from miners._backends import CGMiner
|
||||
from miners._types import Avalon821
|
||||
|
||||
|
||||
class CGMinerAvalon821(CGMiner, Avalon821):
|
||||
def __init__(self, ip: str) -> None:
|
||||
super().__init__(ip)
|
||||
self.ip = ip
|
||||
8
miners/avalonminer/cgminer/A8X/A841.py
Normal file
8
miners/avalonminer/cgminer/A8X/A841.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from miners._backends import CGMiner
|
||||
from miners._types import Avalon841
|
||||
|
||||
|
||||
class CGMinerAvalon841(CGMiner, Avalon841):
|
||||
def __init__(self, ip: str) -> None:
|
||||
super().__init__(ip)
|
||||
self.ip = ip
|
||||
2
miners/avalonminer/cgminer/A8X/__init__.py
Normal file
2
miners/avalonminer/cgminer/A8X/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from .A821 import CGMinerAvalon821
|
||||
from .A841 import CGMinerAvalon841
|
||||
2
miners/avalonminer/cgminer/__init__.py
Normal file
2
miners/avalonminer/cgminer/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from .A8X import *
|
||||
from .A10X import *
|
||||
Reference in New Issue
Block a user