Bases: ComponentManager
, Agent
Class that represents an application.
Source code in edge_sim_py/components/application.py
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91 | class Application(ComponentManager, Agent):
"""Class that represents an application."""
# Class attributes that allow this class to use helper methods from the ComponentManager
_instances = []
_object_count = 0
def __init__(self, obj_id: int = None, label: str = "") -> object:
"""Creates an Application object.
Args:
obj_id (int, optional): Object identifier.
label (str, optional): Application label.
Returns:
object: Created Application object.
"""
# Adding the new object to the list of instances of its class
self.__class__._instances.append(self)
# Object's class instance ID
self.__class__._object_count += 1
if obj_id is None:
obj_id = self.__class__._object_count
self.id = obj_id
# Application label
self.label = label
# List of services that compose the application
self.services = []
# List of users that access the application
self.users = []
# Model-specific attributes (defined inside the model's "initialize()" method)
self.model = None
self.unique_id = None
def _to_dict(self) -> dict:
"""Method that overrides the way the object is formatted to JSON."
Returns:
dict: JSON-friendly representation of the object as a dictionary.
"""
dictionary = {
"attributes": {
"id": self.id,
"label": self.label,
},
"relationships": {
"services": [{"class": type(service).__name__, "id": service.id} for service in self.services],
"users": [{"class": type(user).__name__, "id": user.id} for user in self.users],
},
}
return dictionary
def collect(self) -> dict:
"""Method that collects a set of metrics for the object.
Returns:
metrics (dict): Object metrics.
"""
metrics = {}
return metrics
def step(self):
"""Method that executes the events involving the object at each time step."""
...
def connect_to_service(self, service: object) -> object:
"""Creates a relationship between the application and a given Service object.
Args:
service (Service): Service object.
Returns:
object: Updated Application object.
"""
self.services.append(service)
service.application = self
return self
|
__init__(obj_id=None, label='')
Creates an Application object.
Parameters:
Name |
Type |
Description |
Default |
obj_id |
int
|
Object identifier. |
None
|
label |
str
|
Application label. |
''
|
Returns:
Name | Type |
Description |
object |
object
|
Created Application object. |
Source code in edge_sim_py/components/application.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 | def __init__(self, obj_id: int = None, label: str = "") -> object:
"""Creates an Application object.
Args:
obj_id (int, optional): Object identifier.
label (str, optional): Application label.
Returns:
object: Created Application object.
"""
# Adding the new object to the list of instances of its class
self.__class__._instances.append(self)
# Object's class instance ID
self.__class__._object_count += 1
if obj_id is None:
obj_id = self.__class__._object_count
self.id = obj_id
# Application label
self.label = label
# List of services that compose the application
self.services = []
# List of users that access the application
self.users = []
# Model-specific attributes (defined inside the model's "initialize()" method)
self.model = None
self.unique_id = None
|
collect()
Method that collects a set of metrics for the object.
Returns:
Name | Type |
Description |
metrics |
dict
|
Object metrics. |
Source code in edge_sim_py/components/application.py
| def collect(self) -> dict:
"""Method that collects a set of metrics for the object.
Returns:
metrics (dict): Object metrics.
"""
metrics = {}
return metrics
|
connect_to_service(service)
Creates a relationship between the application and a given Service object.
Parameters:
Name |
Type |
Description |
Default |
service |
Service
|
Service object. |
required
|
Returns:
Name | Type |
Description |
object |
object
|
Updated Application object. |
Source code in edge_sim_py/components/application.py
79
80
81
82
83
84
85
86
87
88
89
90
91 | def connect_to_service(self, service: object) -> object:
"""Creates a relationship between the application and a given Service object.
Args:
service (Service): Service object.
Returns:
object: Updated Application object.
"""
self.services.append(service)
service.application = self
return self
|
step()
Method that executes the events involving the object at each time step.
Source code in edge_sim_py/components/application.py
| def step(self):
"""Method that executes the events involving the object at each time step."""
...
|