daemon: updated config.py to use dataclasses for config classes, updated naming and referencing. updated configurable options to self validate default values align with the config type. updated the example emane model to better align with the current state of things
This commit is contained in:
parent
bb3590fbde
commit
6086d1229b
14 changed files with 171 additions and 133 deletions
|
@ -120,7 +120,8 @@ Here is an example model with documentation describing functionality:
|
|||
"""
|
||||
Example custom emane model.
|
||||
"""
|
||||
from typing import Dict, List, Optional, Set
|
||||
from pathlib import Path
|
||||
from typing import Dict, Optional, Set, List
|
||||
|
||||
from core.config import Configuration
|
||||
from core.emane import emanemanifest, emanemodel
|
||||
|
@ -162,14 +163,31 @@ class ExampleModel(emanemodel.EmaneModel):
|
|||
mac_defaults: Dict[str, str] = {
|
||||
"pcrcurveuri": "/usr/share/emane/xml/models/mac/rfpipe/rfpipepcr.xml"
|
||||
}
|
||||
mac_config: List[Configuration] = emanemanifest.parse(mac_xml, mac_defaults)
|
||||
mac_config: List[Configuration] = []
|
||||
phy_library: Optional[str] = None
|
||||
phy_xml: str = "/usr/share/emane/manifest/emanephy.xml"
|
||||
phy_defaults: Dict[str, str] = {
|
||||
"subid": "1", "propagationmodel": "2ray", "noisemode": "none"
|
||||
}
|
||||
phy_config: List[Configuration] = emanemanifest.parse(phy_xml, phy_defaults)
|
||||
phy_config: List[Configuration] = []
|
||||
config_ignore: Set[str] = set()
|
||||
|
||||
@classmethod
|
||||
def load(cls, emane_prefix: Path) -> None:
|
||||
"""
|
||||
Called after being loaded within the EmaneManager. Provides configured
|
||||
emane_prefix for parsing xml files.
|
||||
|
||||
:param emane_prefix: configured emane prefix path
|
||||
:return: nothing
|
||||
"""
|
||||
manifest_path = "share/emane/manifest"
|
||||
# load mac configuration
|
||||
mac_xml_path = emane_prefix / manifest_path / cls.mac_xml
|
||||
cls.mac_config = emanemanifest.parse(mac_xml_path, cls.mac_defaults)
|
||||
# load phy configuration
|
||||
phy_xml_path = emane_prefix / manifest_path / cls.phy_xml
|
||||
cls.phy_config = emanemanifest.parse(phy_xml_path, cls.phy_defaults)
|
||||
```
|
||||
|
||||
## Single PC with EMANE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue