Upsdated bosminer API docstrings, and fixed some errors in CGMiner API docstings

This commit is contained in:
UpstreamData
2022-03-14 14:07:17 -06:00
parent 05e14baa68
commit d8e59afee0
2 changed files with 69 additions and 81 deletions

View File

@@ -2,64 +2,63 @@ from API import BaseMinerAPI
class BOSMinerAPI(BaseMinerAPI): class BOSMinerAPI(BaseMinerAPI):
""" """An abstraction of the BOSMiner API.
A class that abstracts the BOSMiner API in the miners.
Each method corresponds to an API command in BOSMiner. Each method corresponds to an API command in BOSMiner.
BOSMiner API documentation: BOSMiner API documentation:
https://docs.braiins.com/os/plus-en/Development/1_api.html https://docs.braiins.com/os/plus-en/Development/1_api.html
Parameters: This class abstracts use of the BOSMiner API, as well as the
ip: the IP address of the miner. methods for sending commands to it. The self.send_command()
port (optional): the port of the API on the miner (standard is 4028) function handles sending a command to the miner asynchronously, and
as such is the base for many of the functions in this class, which
rely on it to send the command for them.
:param ip: The IP of the miner to reference the API on.
:param port: The port to reference the API on. Default is 4028.
""" """
def __init__(self, ip, port=4028): def __init__(self, ip, port=4028):
super().__init__(ip, port) super().__init__(ip, port)
async def asccount(self) -> dict: async def asccount(self) -> dict:
""" """Get data on the number of ASC devices and their info.
API 'asccount' command.
Returns a dict containing the number of ASC devices. :return: Data on all ASC devices.
""" """
return await self.send_command("asccount") return await self.send_command("asccount")
async def asc(self, n: int) -> dict: async def asc(self, n: int) -> dict:
""" """Get data for ASC device n.
API 'asc' command.
Returns a dict containing the details of a single ASC of number N. :param n: The device to get data for.
n: the ASC device to get details of. :return: The data for ASC device n.
""" """
return await self.send_command("asc", parameters=n) return await self.send_command("asc", parameters=n)
async def devdetails(self) -> dict: async def devdetails(self) -> dict:
""" """Get data on all devices with their static details.
API 'devdetails' command.
Returns a dict containing all devices with their static details. :return: Data on all devices with their static details.
""" """
return await self.send_command("devdetails") return await self.send_command("devdetails")
async def devs(self) -> dict: async def devs(self) -> dict:
""" """Get data on each PGA/ASC with their details.
API 'devs' command.
Returns a dict containing each PGA/ASC with their details. :return: Data on each PGA/ASC with their details.
""" """
return await self.send_command("devs") return await self.send_command("devs")
async def edevs(self, old: bool = False) -> dict: async def edevs(self, old: bool = False) -> dict:
""" """Get data on each PGA/ASC with their details, ignoring
API 'edevs' command. blacklisted and zombie devices.
Returns a dict containing each PGA/ASC with their details, :param old: Include zombie devices that became zombies less
ignoring blacklisted devices and zombie devices. than 'old' seconds ago
Parameters: :return: Data on each PGA/ASC with their details.
old (optional): include zombie devices that became zombies less than 'old' seconds ago
""" """
if old: if old:
return await self.send_command("edevs", parameters="old") return await self.send_command("edevs", parameters="old")
@@ -67,77 +66,76 @@ class BOSMinerAPI(BaseMinerAPI):
return await self.send_command("edevs") return await self.send_command("edevs")
async def pools(self) -> dict: async def pools(self) -> dict:
""" """Get pool information.
API 'pools' command.
Returns a dict containing the status of each pool. :return: Miner pool information.
""" """
return await self.send_command("pools") return await self.send_command("pools")
async def summary(self) -> dict: async def summary(self) -> dict:
""" """Get the status summary of the miner.
API 'summary' command.
Returns a dict containing the status summary of the miner. :return: The status summary of the miner.
""" """
return await self.send_command("summary") return await self.send_command("summary")
async def stats(self) -> dict: async def stats(self) -> dict:
""" """Get stats of each device/pool with more than 1 getwork.
API 'stats' command.
Returns a dict containing stats for all device/pool with more than 1 getwork. :return: Stats of each device/pool with more than 1 getwork.
""" """
return await self.send_command("stats") return await self.send_command("stats")
async def version(self) -> dict: async def version(self) -> dict:
""" """Get miner version info.
API 'version' command.
Returns a dict containing version information. :return: Miner version information.
""" """
return await self.send_command("version") return await self.send_command("version")
async def estats(self) -> dict: async def estats(self, old: bool = False) -> dict:
""" """Get stats of each device/pool with more than 1 getwork,
API 'estats' command. ignoring zombie devices.
Returns a dict containing stats for all device/pool with more than 1 getwork, :param old: Include zombie devices that became zombies less
than 'old' seconds ago.
:return: Stats of each device/pool with more than 1 getwork,
ignoring zombie devices. ignoring zombie devices.
""" """
return await self.send_command("estats") if old:
return await self.send_command("estats", parameters=old)
else:
return await self.send_command("estats")
async def check(self, command: str) -> dict: async def check(self, command: str) -> dict:
""" """Check if the command command exists in BOSMiner.
API 'check' command.
Returns information about a command: :param command: The command to check.
:return: Information about a command:
Exists (Y/N) <- the command exists in this version Exists (Y/N) <- the command exists in this version
Access (Y/N) <- you have access to use the command Access (Y/N) <- you have access to use the command
Parameters:
command: the command to get information about.
""" """
return await self.send_command("check", parameters=command) return await self.send_command("check", parameters=command)
async def coin(self) -> dict: async def coin(self) -> dict:
""" """Get information on the current coin.
API 'coin' command.
Returns information about the current coin being mined: :return: Information about the current coin being mined:
Hash Method <- the hashing algorithm Hash Method <- the hashing algorithm
Current Block Time <- blocktime as a float, 0 means none Current Block Time <- blocktime as a float, 0 means none
Current Block Hash <- the hash of the current block, blank means none Current Block Hash <- the hash of the current block, blank
means none
LP <- whether LP is in use on at least 1 pool LP <- whether LP is in use on at least 1 pool
Network Difficulty: the current network difficulty Network Difficulty: the current network difficulty
""" """
return await self.send_command("coin") return await self.send_command("coin")
async def lcd(self) -> dict: async def lcd(self) -> dict:
""" """Get a general all-in-one status summary of the miner.
API 'lcd' command.
Returns a dict containing an all in one status summary of the miner. :return: An all-in-one status summary of the miner.
""" """
return await self.send_command("lcd") return await self.send_command("lcd")
@@ -167,53 +165,43 @@ class BOSMinerAPI(BaseMinerAPI):
# return await self.send_command("removepool", parameters=n) # return await self.send_command("removepool", parameters=n)
async def fans(self) -> dict: async def fans(self) -> dict:
""" """Get fan data.
API 'fans' command.
Returns a dict containing information on fans and fan speeds. :return: Data on the fans of the miner.
""" """
return await self.send_command("fans") return await self.send_command("fans")
async def tempctrl(self) -> dict: async def tempctrl(self) -> dict:
""" """Get temperature control data.
API 'tempctrl' command.
Returns a dict containing temp control configuration. :return: Data about the temp control settings of the miner.
""" """
return await self.send_command("tempctrl") return await self.send_command("tempctrl")
async def temps(self) -> dict: async def temps(self) -> dict:
""" """Get temperature data.
API 'temps' command.
Returns a dict containing temperature information. :return: Data on the temps of the miner.
""" """
return await self.send_command("temps") return await self.send_command("temps")
async def tunerstatus(self) -> dict: async def tunerstatus(self) -> dict:
""" """Get tuner status data
API 'tunerstatus' command.
Returns a dict containing tuning stats. :return: Data on the status of autotuning.
""" """
return await self.send_command("tunerstatus") return await self.send_command("tunerstatus")
async def pause(self) -> dict: async def pause(self) -> dict:
""" """Pause mining.
API 'pause' command.
Pauses mining and stops power consumption and waits for resume command. :return: Confirmation of pausing mining.
Returns a dict stating that the miner paused mining.
""" """
return await self.send_command("pause") return await self.send_command("pause")
async def resume(self) -> dict: async def resume(self) -> dict:
""" """Resume mining.
API 'pause' command.
Resumes mining on the miner. :return: Confirmation of resuming mining.
Returns a dict stating that the miner resumed mining.
""" """
return await self.send_command("resume") return await self.send_command("resume")

View File

@@ -2,14 +2,14 @@ from API import BaseMinerAPI
class CGMinerAPI(BaseMinerAPI): class CGMinerAPI(BaseMinerAPI):
"""An abstraction of the BMMiner API. """An abstraction of the CGMiner API.
Each method corresponds to an API command in BMMiner. Each method corresponds to an API command in GGMiner.
CGMiner API documentation: CGMiner API documentation:
https://github.com/ckolivas/cgminer/blob/master/API-README https://github.com/ckolivas/cgminer/blob/master/API-README
This class abstracts use of the BMMiner API, as well as the This class abstracts use of the CGMiner API, as well as the
methods for sending commands to it. The self.send_command() methods for sending commands to it. The self.send_command()
function handles sending a command to the miner asynchronously, and function handles sending a command to the miner asynchronously, and
as such is the base for many of the functions in this class, which as such is the base for many of the functions in this class, which
@@ -185,7 +185,7 @@ class CGMinerAPI(BaseMinerAPI):
return await self.send_command("save") return await self.send_command("save")
async def quit(self) -> dict: async def quit(self) -> dict:
"""Quit BMMiner. """Quit CGMiner.
:return: A single "BYE" before CGMiner quits. :return: A single "BYE" before CGMiner quits.
""" """
@@ -270,7 +270,7 @@ class CGMinerAPI(BaseMinerAPI):
return await self.send_command("estats") return await self.send_command("estats")
async def check(self, command: str) -> dict: async def check(self, command: str) -> dict:
"""Check if the command command exists in BMMiner. """Check if the command command exists in CGMiner.
:param command: The command to check. :param command: The command to check.