Commit 5d6992d5 authored by Jonas Kaufmann's avatar Jonas Kaufmann Committed by Antoine Kaufmann
Browse files

improve docstrings for simulators

parent 77a9296c
......@@ -19,7 +19,7 @@
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""Provides utility functions for assembling host simulators."""
"""Provides helper functions for assembling multiple host simulators."""
import typing as tp
......@@ -47,7 +47,7 @@ def create_basic_hosts(
parameters.
Args:
`num`: number of hosts to create
num: number of hosts to create
"""
hosts: tp.List[HostSim] = []
......
......@@ -113,8 +113,10 @@ class NICSim(PCIDevSim):
self.network: tp.Optional[NetSim] = None
self.mac: tp.Optional[str] = None
self.eth_latency = 500
"""Ethernet latency in nanoseconds from this NIC to the network component."""
def set_network(self, net: NetSim):
"""Connect this NIC to a network simulator."""
self.network = net
net.nics.append(self)
......@@ -158,7 +160,9 @@ class NetSim(Simulator):
self.opt = ''
self.sync_mode = 0
self.sync_period = 500
"""Synchronization period in nanoseconds from this network to connected components."""
self.eth_latency = 500
"""Ethernet latency in nanoseconds from this network to connected components."""
self.nics: list[NICSim] = []
self.hosts_direct: list[HostSim] = []
self.net_listen: list[NetSim] = []
......@@ -204,12 +208,12 @@ class HostSim(Simulator):
def __init__(self, node_config: NodeConfig):
super().__init__()
self.node_config = node_config
"""Config for the simulated host. """
"""System configuration for this simulated host. """
self.name = ''
self.wait = False
"""
`True` - Wait for process of simulator to exit.
`False` - Don't wait and instead stop the process.
`True` - Wait for this simulator to finish execution.
`False` - Don't wait and instead shutdown the simulator as soon as all other awaited simulators have completed execution.
"""
self.sleep = 0
self.cpu_freq = '8GHz'
......@@ -229,13 +233,16 @@ class HostSim(Simulator):
return 'host.' + self.name
def add_nic(self, dev: NICSim):
"""Add a NIC to this host."""
self.add_pcidev(dev)
def add_pcidev(self, dev: PCIDevSim):
"""Add a PCIe device to this host."""
dev.name = self.name + '.' + dev.name
self.pcidevs.append(dev)
def add_netdirect(self, net: NetSim):
"""Add a direct connection to a network to this host."""
net.hosts_direct.append(self)
self.net_directs.append(net)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment