2023-07-21 14:54:09 +01:00
|
|
|
# © Crown-owned copyright 2023, Defence Science and Technology Laboratory UK
|
2023-05-25 11:42:19 +01:00
|
|
|
"""The protocol class."""
|
|
|
|
|
|
2023-03-28 17:33:34 +01:00
|
|
|
|
|
|
|
|
class Protocol(object):
|
2023-07-06 16:08:51 +01:00
|
|
|
"""Protocol class."""
|
2023-03-28 17:33:34 +01:00
|
|
|
|
2023-07-13 12:25:54 +01:00
|
|
|
def __init__(self, _name: str) -> None:
|
2023-07-06 16:08:51 +01:00
|
|
|
"""
|
|
|
|
|
Initialise a protocol.
|
|
|
|
|
|
|
|
|
|
:param _name: The name of the protocol
|
|
|
|
|
:type _name: str
|
|
|
|
|
"""
|
2023-07-13 12:25:54 +01:00
|
|
|
self.name: str = _name
|
|
|
|
|
self.load: int = 0 # bps
|
2023-03-28 17:33:34 +01:00
|
|
|
|
2023-07-13 12:25:54 +01:00
|
|
|
def get_name(self) -> str:
|
2023-07-06 16:08:51 +01:00
|
|
|
"""
|
|
|
|
|
Gets the protocol name.
|
2023-03-28 17:33:34 +01:00
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
The protocol name
|
|
|
|
|
"""
|
|
|
|
|
return self.name
|
|
|
|
|
|
2023-07-13 12:25:54 +01:00
|
|
|
def get_load(self) -> int:
|
2023-07-06 16:08:51 +01:00
|
|
|
"""
|
|
|
|
|
Gets the protocol load.
|
2023-03-28 17:33:34 +01:00
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
The protocol load (bps)
|
|
|
|
|
"""
|
|
|
|
|
return self.load
|
|
|
|
|
|
2023-07-13 12:25:54 +01:00
|
|
|
def add_load(self, _load: int) -> None:
|
2023-07-06 16:08:51 +01:00
|
|
|
"""
|
|
|
|
|
Adds load to the protocol.
|
2023-03-28 17:33:34 +01:00
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
_load: The load to add
|
|
|
|
|
"""
|
|
|
|
|
self.load += _load
|
|
|
|
|
|
2023-07-13 12:25:54 +01:00
|
|
|
def clear_load(self) -> None:
|
2023-05-25 11:42:19 +01:00
|
|
|
"""Clears the load on this protocol."""
|
2023-03-28 17:33:34 +01:00
|
|
|
self.load = 0
|