added T9s

This commit is contained in:
UpstreamData
2022-01-21 14:42:01 -07:00
parent d5fc7650ef
commit a1839aae46
4 changed files with 52 additions and 9 deletions

View File

@@ -0,0 +1,11 @@
from miners.bmminer import BMMiner
class BMMinerT9(BMMiner):
def __init__(self, ip: str) -> None:
super().__init__(ip)
self.model = "T9"
self.api_type = "BMMiner"
def __repr__(self) -> str:
return f"BMMinerT9: {str(self.ip)}"

View File

@@ -0,0 +1,11 @@
from miners.cgminer import CGMiner
class CGMinerT9(CGMiner):
def __init__(self, ip: str) -> None:
super().__init__(ip)
self.model = "T9"
self.api_type = "CGMiner"
def __repr__(self) -> str:
return f"CGMinerT9: {str(self.ip)}"

View File

@@ -0,0 +1,11 @@
from miners.bmminer import BMMiner
class HiveonT9(BMMiner):
def __init__(self, ip: str) -> None:
super().__init__(ip)
self.model = "T9"
self.api_type = "Hiveon"
def __repr__(self) -> str:
return f"HiveonT9: {str(self.ip)}"

View File

@@ -2,6 +2,10 @@ from miners.antminer.S9.bosminer import BOSMinerS9
from miners.antminer.S9.bmminer import BMMinerS9 from miners.antminer.S9.bmminer import BMMinerS9
from miners.antminer.S9.cgminer import CGMinerS9 from miners.antminer.S9.cgminer import CGMinerS9
from miners.antminer.T9.hive import HiveonT9
from miners.antminer.T9.cgminer import CGMinerT9
from miners.antminer.T9.bmminer import BMMinerT9
from miners.antminer.X17.bosminer import BOSMinerX17 from miners.antminer.X17.bosminer import BOSMinerX17
from miners.antminer.X17.bmminer import BMMinerX17 from miners.antminer.X17.bmminer import BMMinerX17
from miners.antminer.X17.cgminer import CGMinerX17 from miners.antminer.X17.cgminer import CGMinerX17
@@ -83,7 +87,6 @@ class MinerFactory:
# if we find the model type, dont need to loop anymore # if we find the model type, dont need to loop anymore
if model: if model:
break break
# make sure we have model information # make sure we have model information
if model: if model:
@@ -104,6 +107,16 @@ class MinerFactory:
elif "BMMiner" in api: elif "BMMiner" in api:
miner = BMMinerS9(str(ip)) miner = BMMinerS9(str(ip))
elif "Antminer T9" in model:
if "BMMiner" in api:
if "Hiveon" in model:
# hiveOS, return T9 Hive
miner = HiveonT9(str(ip))
else:
miner = BMMinerT9(str(ip))
elif "CGMiner" in api:
miner = CGMinerT9(str(ip))
# X17 model logic # X17 model logic
elif "17" in model: elif "17" in model:
@@ -172,7 +185,6 @@ class MinerFactory:
# send the devdetails command to the miner (will fail with no boards/devices) # send the devdetails command to the miner (will fail with no boards/devices)
data = await self._send_api_command(str(ip), "devdetails") data = await self._send_api_command(str(ip), "devdetails")
# sometimes data is b'', check for that # sometimes data is b'', check for that
if data: if data:
# status check, make sure the command succeeded # status check, make sure the command succeeded
@@ -209,20 +221,18 @@ class MinerFactory:
data = await self._send_api_command(str(ip), "version") data = await self._send_api_command(str(ip), "version")
model = data["VERSION"][0]["Type"] model = data["VERSION"][0]["Type"]
# if we have a model, return it return model
if model:
return model
# if there are errors, we just return None # if there are errors, we just return None
except APIError as e: except APIError:
return None return model
except OSError as e: except OSError as e:
if e.winerror == 121: if e.winerror == 121:
print(e) print(e)
return None return model
else: else:
print(ip, e) print(ip, e)
return None return model
async def _send_api_command(self, ip: ipaddress.ip_address or str, command: str): async def _send_api_command(self, ip: ipaddress.ip_address or str, command: str):
try: try: