Introduction
gradysim.encapsulator
The encapsulator module is a middle-man between protocols and environments. One of GrADyS-SIM NextGen's features is the construction of protocols that can be used in different environments without changes to their code. These environments are called execution modes. Protocols are wrapped in encapsulators that handle the effects of the environment on the protocol and are injected with provider instances that provide them with the necessary tools to interact with the environment.
This module provides encapsulators that enable users to run their protocols inside a python simulation (prototype-mode), integrated with a realistic network simulator OMNeT++ (integrated-mode) and, in the future, connected to real-life nodes.
All encapsulators implement the IEncapsulator interface.
gradysim.encapsulator.interface.IEncapsulator
Bases: ABC
, Generic[T]
Defines a generic interface that all encapsulators should implement. Encapsulator's main task is to wrap nodes absorbing effects from the environment and propagating them to the node and injecting a provider instance so that the nodes can interact with the environment.
Source code in gradysim/encapsulator/interface.py
encapsulate(protocol)
abstractmethod
Wraps a protocol. Should instantiate it and inject a provider instance into it. Every IEncapsulator instance wraps a single protocol only.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
protocol |
Type[T]
|
The type of protocol being instantiated |
required |