Coverage for flexnetsim/event.py: 56%

18 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-22 20:03 +0000

1from enum import Enum 

2 

3 

4class Event: 

5 """ 

6 The Event class represents the event that happens inside the digital 

7 transmission system or computer network of the Simulator in terms of 

8 clients requesting to establish connections (thus needing resources) known as 

9 an "arrival" or closing the connection thereafter (thus freeing resources) 

10 known as a "departure". 

11 

12 Note that, as the Simulator uses Event Based Simulation, this class'  

13 implementation is a key-piece for the simulator's execution. 

14 

15 Attributes: 

16 type (Event.event type): an event variable which describes the kind of Event taking two possible values: ARRIVE or DEPARTURE. 

17 

18 id_connection (int): the Id (identifier) of the Connection regarding the current Event. 

19 

20 time (int): the time at which the current Event has occurred. 

21 

22 

23 The Event class contains two main methods for setting it's variables' values, 

24 both being in the constuctor method: the default constructor with default initialized  

25 values and another if arguments are given. Each attribute has it's own property gettter. 

26 """ 

27 

28 event = Enum("event", "ARRIVE DEPARTURE") 

29 

30 def __init__(self, type=None, time=-1, id_connection=-1): 

31 """ 

32 Init method of class Event 

33 

34 Args: 

35 type (Event.event type): an event variable which describes the kind of Event taking two possible values: ARRIVE or DEPARTURE. 

36 

37 id_connection (int): the Id (identifier) of the Connection regarding the current Event. 

38 

39 time (int): the time at which the current Event has occurred. 

40 """ 

41 self.__time = time 

42 self.__id_connection = id_connection 

43 if type == None: 

44 self.__type = Event.event.ARRIVE 

45 else: 

46 self.__type = type 

47 

48 @property 

49 def type(self): 

50 """ 

51 Getter for the type attribute 

52 """ 

53 return self.__type 

54 

55 @property 

56 def time(self): 

57 """ 

58 Getter for the time attribute 

59 """ 

60 return self.__time 

61 

62 @property 

63 def id_connection(self): 

64 """ 

65 Getter for the id_connection attribute 

66 """ 

67 return self.__id_connection