docs: update docs.

This commit is contained in:
UpstreamData
2023-04-04 09:22:36 -06:00
parent a577f64d59
commit d4d48f5582
6 changed files with 73 additions and 59 deletions

View File

@@ -10,6 +10,7 @@ All API implementations inherit from [`BaseMinerAPI`][pyasic.API.BaseMinerAPI],
[`BaseMinerAPI`][pyasic.API.BaseMinerAPI] cannot be instantiated directly, it will raise a `TypeError`. [`BaseMinerAPI`][pyasic.API.BaseMinerAPI] cannot be instantiated directly, it will raise a `TypeError`.
Use these instead - Use these instead -
#### [BFGMiner API][pyasic.API.bfgminer.BFGMinerAPI]
#### [BMMiner API][pyasic.API.bmminer.BMMinerAPI] #### [BMMiner API][pyasic.API.bmminer.BMMinerAPI]
#### [BOSMiner API][pyasic.API.bosminer.BOSMinerAPI] #### [BOSMiner API][pyasic.API.bosminer.BOSMinerAPI]
#### [BTMiner API][pyasic.API.btminer.BTMinerAPI] #### [BTMiner API][pyasic.API.btminer.BTMinerAPI]

7
docs/API/bfgminer.md Normal file
View File

@@ -0,0 +1,7 @@
# pyasic
## BFGMinerAPI
::: pyasic.API.bfgminer.BFGMinerAPI
handler: python
options:
show_root_heading: false
heading_level: 4

View File

@@ -42,21 +42,27 @@ if __name__ == "__main__":
<br> <br>
## Creating miners based on IP ## Creating miners based on IP
If you already know the IP address of your miner or miners, you can use the [`MinerFactory`][pyasic.miners.miner_factory.MinerFactory] to communicate and identify the miners. If you already know the IP address of your miner or miners, you can use the [`MinerFactory`][pyasic.miners.miner_factory.MinerFactory] to communicate and identify the miners, or an abstraction of its functionality, [`get_miner()`][pyasic.miners.miner_factory.MinerFactory.get_miner].
The function [`MinerFactory().get_miner()`][pyasic.miners.miner_factory.MinerFactory.get_miner] will return any miner it found at the IP address specified, or an `UnknownMiner` if it cannot identify the miner. The function [`get_miner()`][pyasic.miners.miner_factory.MinerFactory.get_miner] will return any miner it found at the IP address specified, or an `UnknownMiner` if it cannot identify the miner.
```python ```python
import asyncio # asyncio for handling the async part import asyncio # asyncio for handling the async part
from pyasic.miners.miner_factory import MinerFactory # miner factory handles miners creation from pyasic import get_miner # handles miner creation
async def get_miners(): # define async scan function to allow awaiting async def get_miners(): # define async scan function to allow awaiting
# get the miner with miner factory # get the miner with the miner factory
# miner factory is a singleton, and will always use the same object and cache # the miner factory is a singleton, and will always use the same object and cache
# this means you can always call it as MinerFactory().get_miner() # this means you can always call it as MinerFactory().get_miner(), or just get_miner()
miner_1 = await MinerFactory().get_miner("192.168.1.75") miner_1 = await get_miner("192.168.1.75")
miner_2 = await MinerFactory().get_miner("192.168.1.76") miner_2 = await get_miner("192.168.1.76")
print(miner_1, miner_2) print(miner_1, miner_2)
# can also gather these, since they are async
tasks = [get_miner("192.168.1.75"), get_miner("192.168.1.76")]
miners = await asyncio.gather(*tasks)
print(miners)
if __name__ == "__main__": if __name__ == "__main__":
asyncio.run(get_miners()) # get the miners asynchronously with asyncio.run() asyncio.run(get_miners()) # get the miners asynchronously with asyncio.run()
``` ```
@@ -66,7 +72,7 @@ if __name__ == "__main__":
## Getting data from miners ## Getting data from miners
Once you have your miner(s) identified, you will likely want to get data from the miner(s). You can do this using a built in function in each miner called `get_data()`. Once you have your miner(s) identified, you will likely want to get data from the miner(s). You can do this using a built in function in each miner called `get_data()`.
This function will return a instance of the dataclass [`MinerData`][pyasic.data.MinerData] with all data it can gather from the miner. This function will return an instance of the dataclass [`MinerData`][pyasic.data.MinerData] with all data it can gather from the miner.
Each piece of data in a [`MinerData`][pyasic.data.MinerData] instance can be referenced by getting it as an attribute, such as [`MinerData().hashrate`][pyasic.data.MinerData]. Each piece of data in a [`MinerData`][pyasic.data.MinerData] instance can be referenced by getting it as an attribute, such as [`MinerData().hashrate`][pyasic.data.MinerData].
```python ```python
import asyncio import asyncio

View File

@@ -1,7 +1,7 @@
# pyasic # pyasic
## BFGMiner Backend ## BFGMiner Backend
::: pyasic.miners.kda._backends.bfgminer.BFGMiner ::: pyasic.miners.backends.bfgminer.BFGMiner
handler: python handler: python
options: options:
show_root_heading: false show_root_heading: false

View File

@@ -1,54 +1,54 @@
site_name: pyasic site_name: pyasic
repo_url: https://github.com/UpstreamData/pyasic repo_url: https://github.com/UpstreamData/pyasic
nav: nav:
- Introduction: "index.md" - Introduction: "index.md"
- Miners: - Miners:
- Supported Miners: "miners/supported_types.md" - Supported Miners: "miners/supported_types.md"
- Miner Factory: "miners/miner_factory.md" - Miner Factory: "miners/miner_factory.md"
- Backends: - Network:
- BMMiner: "miners/backends/bmminer.md" - Miner Network: "network/miner_network.md"
- BOSMiner: "miners/backends/bosminer.md" - Miner Network Range: "network/miner_network_range.md"
- BFGMiner: "miners/backends/bfgminer.md" - Dataclasses:
- BTMiner: "miners/backends/btminer.md" - Miner Data: "data/miner_data.md"
- CGMiner: "miners/backends/cgminer.md" - Error Codes: "data/error_codes.md"
- Hiveon: "miners/backends/hiveon.md" - Miner Config: "config/miner_config.md"
- Classes: - Advanced:
- Antminer X3: "miners/antminer/X3.md" - Miner APIs:
- Antminer X5: "miners/antminer/X5.md" - Intro: "API/api.md"
- Antminer X7: "miners/antminer/X7.md" - BFGMiner: "API/bfgminer.md"
- Antminer X9: "miners/antminer/X9.md" - BMMiner: "API/bmminer.md"
- Antminer X15: "miners/antminer/X15.md" - BOSMiner: "API/bosminer.md"
- Antminer X17: "miners/antminer/X17.md" - BTMiner: "API/btminer.md"
- Antminer X19: "miners/antminer/X19.md" - CGMiner: "API/cgminer.md"
- Avalon 7X: "miners/avalonminer/A7X.md" - Unknown: "API/unknown.md"
- Avalon 8X: "miners/avalonminer/A8X.md" - Backends:
- Avalon 9X: "miners/avalonminer/A9X.md" - BMMiner: "miners/backends/bmminer.md"
- Avalon 10X: "miners/avalonminer/A10X.md" - BOSMiner: "miners/backends/bosminer.md"
- Whatsminer M2X: "miners/whatsminer/M2X.md" - BFGMiner: "miners/backends/bfgminer.md"
- Whatsminer M3X: "miners/whatsminer/M3X.md" - BTMiner: "miners/backends/btminer.md"
- Whatsminer M5X: "miners/whatsminer/M5X.md" - CGMiner: "miners/backends/cgminer.md"
- Innosilicon T3X: "miners/innosilicon/T3X.md" - Hiveon: "miners/backends/hiveon.md"
- Innosilicon A10X: "miners/innosilicon/A10X.md" - Classes:
- Goldshell CKX: "miners/goldshell/CKX.md" - Antminer X3: "miners/antminer/X3.md"
- Goldshell HSX: "miners/goldshell/HSX.md" - Antminer X5: "miners/antminer/X5.md"
- Goldshell KDX: "miners/goldshell/KDX.md" - Antminer X7: "miners/antminer/X7.md"
- Network: - Antminer X9: "miners/antminer/X9.md"
- Miner Network: "network/miner_network.md" - Antminer X15: "miners/antminer/X15.md"
- Miner Network Range: "network/miner_network_range.md" - Antminer X17: "miners/antminer/X17.md"
- Dataclasses: - Antminer X19: "miners/antminer/X19.md"
- Miner Data: "data/miner_data.md" - Avalon 7X: "miners/avalonminer/A7X.md"
- Error Codes: "data/error_codes.md" - Avalon 8X: "miners/avalonminer/A8X.md"
- Miner Config: "config/miner_config.md" - Avalon 9X: "miners/avalonminer/A9X.md"
- Advanced: - Avalon 10X: "miners/avalonminer/A10X.md"
- Miner APIs: - Whatsminer M2X: "miners/whatsminer/M2X.md"
- Intro: "API/api.md" - Whatsminer M3X: "miners/whatsminer/M3X.md"
- BMMiner: "API/bmminer.md" - Whatsminer M5X: "miners/whatsminer/M5X.md"
- BOSMiner: "API/bosminer.md" - Innosilicon T3X: "miners/innosilicon/T3X.md"
- BTMiner: "API/btminer.md" - Innosilicon A10X: "miners/innosilicon/A10X.md"
- CGMiner: "API/cgminer.md" - Goldshell CKX: "miners/goldshell/CKX.md"
- Unknown: "API/unknown.md" - Goldshell HSX: "miners/goldshell/HSX.md"
- Goldshell KDX: "miners/goldshell/KDX.md"
- Base Miner: "miners/base_miner.md" - Base Miner: "miners/base_miner.md"
plugins: plugins:

View File

@@ -560,7 +560,7 @@ MINER_CLASSES = {
class MinerFactory(metaclass=Singleton): class MinerFactory(metaclass=Singleton):
"""A factory to handle identification and selection of the proper class of miner""" """A factory to handle identification and selection of the proper class of miner."""
def __init__(self) -> None: def __init__(self) -> None:
self.miners = {} self.miners = {}