add get_config to ePIC backend
This commit is contained in:
@@ -161,6 +161,13 @@ class MinerConfig:
|
|||||||
power_scaling=PowerScalingConfig.from_bosminer(toml_conf),
|
power_scaling=PowerScalingConfig.from_bosminer(toml_conf),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_epic(cls, web_conf: dict) -> "MinerConfig":
|
||||||
|
return cls(pools=PoolConfig.from_epic(web_conf),
|
||||||
|
fan_mode=FanModeConfig.from_epic(web_conf),
|
||||||
|
temperature=TemperatureConfig.from_epic(web_conf),
|
||||||
|
mining_mode=MiningModeConfig.from_epic(web_conf))
|
||||||
|
|
||||||
|
|
||||||
def merge(a: dict, b: dict) -> dict:
|
def merge(a: dict, b: dict) -> dict:
|
||||||
result = deepcopy(a)
|
result = deepcopy(a)
|
||||||
|
|||||||
@@ -116,6 +116,17 @@ class FanModeConfig(MinerConfigOption):
|
|||||||
else:
|
else:
|
||||||
return cls.default()
|
return cls.default()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_epic(cls, web_conf: dict):
|
||||||
|
if web_conf.get("Fans") is not None:
|
||||||
|
fan_mode = web_conf["Fans"]["Fan Mode"]
|
||||||
|
if fan_mode.get("Manual") is not None:
|
||||||
|
return cls.manual(speed=fan_mode.get("Manual"))
|
||||||
|
else:
|
||||||
|
return cls.normal()
|
||||||
|
else:
|
||||||
|
return cls.default()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_bosminer(cls, toml_conf: dict):
|
def from_bosminer(cls, toml_conf: dict):
|
||||||
if toml_conf.get("temp_control") is None:
|
if toml_conf.get("temp_control") is None:
|
||||||
|
|||||||
@@ -186,6 +186,19 @@ class MiningModeConfig(MinerConfigOption):
|
|||||||
return cls.low()
|
return cls.low()
|
||||||
return cls.default()
|
return cls.default()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_epic(cls, web_conf: dict):
|
||||||
|
if web_conf.get("PerpetualTune") is not None:
|
||||||
|
work_mode = web_conf["PerpetualTune"]
|
||||||
|
if work_mode["Running"] == True:
|
||||||
|
if web_conf["PerpetualTune"]["Algorithm"].get("VoltageOptimizer") is not None:
|
||||||
|
return cls.hashrate_tuning(web_conf["PerpetualTune"]["Algorithm"]["VoltageOptimizer"].get("Target"))
|
||||||
|
else:
|
||||||
|
return cls.hashrate_tuning()
|
||||||
|
else:
|
||||||
|
return cls.normal()
|
||||||
|
return cls.default()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_bosminer(cls, toml_conf: dict):
|
def from_bosminer(cls, toml_conf: dict):
|
||||||
if toml_conf.get("autotuning") is None:
|
if toml_conf.get("autotuning") is None:
|
||||||
|
|||||||
@@ -108,6 +108,10 @@ class Pool(MinerConfigValue):
|
|||||||
def from_api(cls, api_pool: dict) -> "Pool":
|
def from_api(cls, api_pool: dict) -> "Pool":
|
||||||
return cls(url=api_pool["URL"], user=api_pool["User"], password="x")
|
return cls(url=api_pool["URL"], user=api_pool["User"], password="x")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_epic(cls, api_pool: dict) -> "Pool":
|
||||||
|
return cls(url=api_pool["pool"].replace("stratum+tcp://", ""), user=api_pool["login"], password=api_pool["password"])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_am_modern(cls, web_pool: dict) -> "Pool":
|
def from_am_modern(cls, web_pool: dict) -> "Pool":
|
||||||
return cls(
|
return cls(
|
||||||
@@ -237,6 +241,13 @@ class PoolGroup(MinerConfigValue):
|
|||||||
pools.append(Pool.from_api(pool))
|
pools.append(Pool.from_api(pool))
|
||||||
return cls(pools=pools)
|
return cls(pools=pools)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_epic(cls, api_pool_list: list) -> "PoolGroup":
|
||||||
|
pools = []
|
||||||
|
for pool in api_pool_list:
|
||||||
|
pools.append(Pool.from_epic(pool))
|
||||||
|
return cls(pools=pools)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_am_modern(cls, web_pool_list: list) -> "PoolGroup":
|
def from_am_modern(cls, web_pool_list: list) -> "PoolGroup":
|
||||||
pools = []
|
pools = []
|
||||||
@@ -334,6 +345,11 @@ class PoolConfig(MinerConfigValue):
|
|||||||
|
|
||||||
return cls([PoolGroup.from_api(pool_data)])
|
return cls([PoolGroup.from_api(pool_data)])
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_epic(cls, web_conf: dict) -> "PoolConfig":
|
||||||
|
pool_data = web_conf["StratumConfigs"]
|
||||||
|
return cls([PoolGroup.from_epic(pool_data)])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_am_modern(cls, web_conf: dict) -> "PoolConfig":
|
def from_am_modern(cls, web_conf: dict) -> "PoolConfig":
|
||||||
pool_data = web_conf["pools"]
|
pool_data = web_conf["pools"]
|
||||||
|
|||||||
@@ -56,3 +56,21 @@ class TemperatureConfig(MinerConfigValue):
|
|||||||
hot=temp_control.get("hot_temp"),
|
hot=temp_control.get("hot_temp"),
|
||||||
danger=temp_control.get("dangerous_temp"),
|
danger=temp_control.get("dangerous_temp"),
|
||||||
)
|
)
|
||||||
|
@classmethod
|
||||||
|
def from_epic(cls, web_conf: dict) -> "TemperatureConfig":
|
||||||
|
## we only have a target temp if we are in auto-fan mode, so
|
||||||
|
## we need to check for that
|
||||||
|
if web_conf.get("Misc") is not None:
|
||||||
|
target_temp = web_conf["Misc"]["Shutdown Temp"]
|
||||||
|
hot_temp = web_conf["Misc"]["Shutdown Temp"]
|
||||||
|
dangerous_temp = web_conf["Misc"]["Shutdown Temp"]
|
||||||
|
|
||||||
|
if web_conf["Fans"]["Fan Mode"].get("Auto") is not None:
|
||||||
|
target_temp = web_conf["Fans"]["Fan Mode"]["Auto"]["Target Temperature"]
|
||||||
|
|
||||||
|
if web_conf.get("Misc") is not None:
|
||||||
|
return cls(
|
||||||
|
target=target_temp,
|
||||||
|
hot=hot_temp,
|
||||||
|
danger=dangerous_temp
|
||||||
|
)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from typing import List, Optional, Tuple, Union
|
|||||||
|
|
||||||
from pyasic.data import Fan, HashBoard
|
from pyasic.data import Fan, HashBoard
|
||||||
from pyasic.data.error_codes import MinerErrorData, X19Error
|
from pyasic.data.error_codes import MinerErrorData, X19Error
|
||||||
|
from pyasic.config import MinerConfig, MiningModeConfig
|
||||||
from pyasic.errors import APIError
|
from pyasic.errors import APIError
|
||||||
from pyasic.logger import logger
|
from pyasic.logger import logger
|
||||||
from pyasic.miners.backends.bmminer import BMMiner
|
from pyasic.miners.backends.bmminer import BMMiner
|
||||||
@@ -74,6 +75,23 @@ class ePIC(BMMiner):
|
|||||||
return self.model + " (ePIC)"
|
return self.model + " (ePIC)"
|
||||||
return "? (ePIC)"
|
return "? (ePIC)"
|
||||||
|
|
||||||
|
async def get_config(self) -> MinerConfig:
|
||||||
|
summary = None
|
||||||
|
try:
|
||||||
|
summary = await self.web.summary()
|
||||||
|
except APIError as e:
|
||||||
|
logger.warning(e)
|
||||||
|
except LookupError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if summary is not None:
|
||||||
|
cfg = MinerConfig.from_epic(summary)
|
||||||
|
else:
|
||||||
|
cfg = MinerConfig()
|
||||||
|
|
||||||
|
self.config = cfg
|
||||||
|
return self.config
|
||||||
|
|
||||||
async def restart_backend(self) -> bool:
|
async def restart_backend(self) -> bool:
|
||||||
data = await self.web.restart_epic()
|
data = await self.web.restart_epic()
|
||||||
if data:
|
if data:
|
||||||
|
|||||||
Reference in New Issue
Block a user