Skip to content

Discrete Event Worker

feral3gp.feral.get_discrete_event_director()

Returns:

Type Description

The predefined discrete event director of the simulation

Source code in feral3gp/feral/core/simulation.py
65
66
67
68
69
def get_discrete_event_director():
    """
    :returns: The predefined discrete event director of the simulation
    """
    return Simulation.director_de

feral3gp.feral.EventTriggeredWorker

Bases: JavaDelegate

Event Triggered Workers integrate discrete event behavior/simulation models into a FERAL simulation.

Source code in feral3gp/feral/core/de_worker.py
  7
  8
  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
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
class EventTriggeredWorker(JavaDelegate):
    """
    Event Triggered Workers integrate discrete event behavior/simulation models into a FERAL simulation.
    """

    def __init__(self, name: str, parent=Simulation.director_de):
        java_delegate = delegate.EventTriggeredWorkerDelegate(self, name, parent)
        self.set_java_delegate(java_delegate)

        self.in_port = self.create_input_port("input")
        self.out_port = self.create_output_port("output")

    def message_received(self, event, rx_port):
        """
        Process a received event over an input port
        :param event: The received event
        :param rx_port: The port via which the event was received
        """
        pass

    def timer_expired(self, timed_event):
        """
        A timer has expired. Process the given timed event.
        """
        pass

    def initialize(self):
        """
        This method will be called by the controlling MOCC during the initialization phase of the simulation
        """
        pass

    def terminate(self):
        """
        This method will be called by the controlling MOCC during the termination phase of the simulation
        """
        pass

    def get_simulation_time(self):
        """
        :return: The current simulation time in nanoseconds
        """
        return self.get_java_delegate().getSimulationTime()

    def get_simulation_duration(self):
        """
        :return: The simulation duration time in nanoseconds
        """
        return self.get_java_delegate().getSimulationDuration()

    def get_director(self):
        """
        :return: The director of this worker
        """
        return self.get_java_delegate().getDirector()

    def create_input_port(self, port_name) -> JRxPort:
        """
        Create a RxPort with a given name
        :param port_name: The name of the port
        :return: The created RxPort
        """
        return self.get_java_delegate().createInputPort(port_name)

    def create_output_port(self, port_name):
        """
        Create a TxPort with a given name
        :param port_name: The name of the port
        :return: The created TxPort
        """
        return self.get_java_delegate().createOutputPort(port_name)

    def get_input_port(self, port_name):
        """
        Get a RxPort with a given name
        :param port_name: The name of the port
        :return: The RxPort
        """
        return self.get_java_delegate().getInputPort(port_name)

    def get_input_ports(self):
        """
        Get all RxPorts of this worker
        :return: The RxPorts
        """
        return self.get_java_delegate().getInputPorts()

    def get_output_port(self, port_name):
        """
        Get a TxPort with a given name
        :param port_name: The name of the port
        :return: The TxPort
        """
        return self.get_java_delegate().getOutputPort(port_name)

    def get_output_ports(self):
        """
        Get all TxPorts of this worker
        :return: The TxPorts
        """
        return self.get_java_delegate().getOutputPorts()

    def schedule_timer(self, time, value):
        """
        Schedule a timer at a given absolute simulation time
        :param time: The simulation time in nanoseconds at which the timer shall expire
        :param value: The event data which is set for the created timer
        :return: The TimedEvent
        """
        return self.get_java_delegate().scheduleTimer(time, value)

    def delete_timer(self, timed_event):
        """
        Delete a given timer
        :param timed_event: The timer to be deleted
        """
        self.get_java_delegate().deleteTimer(timed_event)

    def schedule_delta_timer(self, delay, value):
        """
        Schedule a timer at a specific simulation time based on the current time

        :param delay: The delay in nanoseconds after which the timer should run. This is to be understood
        relative to the current time.
        :param value: The event data which is set for the created timer
        :returns: The TimedEvent
        """
        return self.get_java_delegate().scheduleDeltaTimer(delay, value)

    def get_console(self):
        """
        :return: The console of this worker
        """
        return self.get_java_delegate().getConsole()

    def set_console(self, console):
        """
        Set the console for this worker
        :param console: The console to be set
        """
        self.get_java_delegate().setConsole(console)

create_input_port(port_name)

Create a RxPort with a given name

Parameters:

Name Type Description Default
port_name

The name of the port

required

Returns:

Type Description
RxPort

The created RxPort

Source code in feral3gp/feral/core/de_worker.py
63
64
65
66
67
68
69
def create_input_port(self, port_name) -> JRxPort:
    """
    Create a RxPort with a given name
    :param port_name: The name of the port
    :return: The created RxPort
    """
    return self.get_java_delegate().createInputPort(port_name)

create_output_port(port_name)

Create a TxPort with a given name

Parameters:

Name Type Description Default
port_name

The name of the port

required

Returns:

Type Description

The created TxPort

Source code in feral3gp/feral/core/de_worker.py
71
72
73
74
75
76
77
def create_output_port(self, port_name):
    """
    Create a TxPort with a given name
    :param port_name: The name of the port
    :return: The created TxPort
    """
    return self.get_java_delegate().createOutputPort(port_name)

delete_timer(timed_event)

Delete a given timer

Parameters:

Name Type Description Default
timed_event

The timer to be deleted

required
Source code in feral3gp/feral/core/de_worker.py
118
119
120
121
122
123
def delete_timer(self, timed_event):
    """
    Delete a given timer
    :param timed_event: The timer to be deleted
    """
    self.get_java_delegate().deleteTimer(timed_event)

get_console()

Returns:

Type Description

The console of this worker

Source code in feral3gp/feral/core/de_worker.py
136
137
138
139
140
def get_console(self):
    """
    :return: The console of this worker
    """
    return self.get_java_delegate().getConsole()

get_director()

Returns:

Type Description

The director of this worker

Source code in feral3gp/feral/core/de_worker.py
57
58
59
60
61
def get_director(self):
    """
    :return: The director of this worker
    """
    return self.get_java_delegate().getDirector()

get_input_port(port_name)

Get a RxPort with a given name

Parameters:

Name Type Description Default
port_name

The name of the port

required

Returns:

Type Description

The RxPort

Source code in feral3gp/feral/core/de_worker.py
79
80
81
82
83
84
85
def get_input_port(self, port_name):
    """
    Get a RxPort with a given name
    :param port_name: The name of the port
    :return: The RxPort
    """
    return self.get_java_delegate().getInputPort(port_name)

get_input_ports()

Get all RxPorts of this worker

Returns:

Type Description

The RxPorts

Source code in feral3gp/feral/core/de_worker.py
87
88
89
90
91
92
def get_input_ports(self):
    """
    Get all RxPorts of this worker
    :return: The RxPorts
    """
    return self.get_java_delegate().getInputPorts()

get_output_port(port_name)

Get a TxPort with a given name

Parameters:

Name Type Description Default
port_name

The name of the port

required

Returns:

Type Description

The TxPort

Source code in feral3gp/feral/core/de_worker.py
 94
 95
 96
 97
 98
 99
100
def get_output_port(self, port_name):
    """
    Get a TxPort with a given name
    :param port_name: The name of the port
    :return: The TxPort
    """
    return self.get_java_delegate().getOutputPort(port_name)

get_output_ports()

Get all TxPorts of this worker

Returns:

Type Description

The TxPorts

Source code in feral3gp/feral/core/de_worker.py
102
103
104
105
106
107
def get_output_ports(self):
    """
    Get all TxPorts of this worker
    :return: The TxPorts
    """
    return self.get_java_delegate().getOutputPorts()

get_simulation_duration()

Returns:

Type Description

The simulation duration time in nanoseconds

Source code in feral3gp/feral/core/de_worker.py
51
52
53
54
55
def get_simulation_duration(self):
    """
    :return: The simulation duration time in nanoseconds
    """
    return self.get_java_delegate().getSimulationDuration()

get_simulation_time()

Returns:

Type Description

The current simulation time in nanoseconds

Source code in feral3gp/feral/core/de_worker.py
45
46
47
48
49
def get_simulation_time(self):
    """
    :return: The current simulation time in nanoseconds
    """
    return self.get_java_delegate().getSimulationTime()

initialize()

This method will be called by the controlling MOCC during the initialization phase of the simulation

Source code in feral3gp/feral/core/de_worker.py
33
34
35
36
37
def initialize(self):
    """
    This method will be called by the controlling MOCC during the initialization phase of the simulation
    """
    pass

message_received(event, rx_port)

Process a received event over an input port

Parameters:

Name Type Description Default
event

The received event

required
rx_port

The port via which the event was received

required
Source code in feral3gp/feral/core/de_worker.py
19
20
21
22
23
24
25
def message_received(self, event, rx_port):
    """
    Process a received event over an input port
    :param event: The received event
    :param rx_port: The port via which the event was received
    """
    pass

schedule_delta_timer(delay, value)

Schedule a timer at a specific simulation time based on the current time

Parameters:

Name Type Description Default
delay

The delay in nanoseconds after which the timer should run. This is to be understood relative to the current time.

required
value

The event data which is set for the created timer

required

Returns:

Type Description

The TimedEvent

Source code in feral3gp/feral/core/de_worker.py
125
126
127
128
129
130
131
132
133
134
def schedule_delta_timer(self, delay, value):
    """
    Schedule a timer at a specific simulation time based on the current time

    :param delay: The delay in nanoseconds after which the timer should run. This is to be understood
    relative to the current time.
    :param value: The event data which is set for the created timer
    :returns: The TimedEvent
    """
    return self.get_java_delegate().scheduleDeltaTimer(delay, value)

schedule_timer(time, value)

Schedule a timer at a given absolute simulation time

Parameters:

Name Type Description Default
time

The simulation time in nanoseconds at which the timer shall expire

required
value

The event data which is set for the created timer

required

Returns:

Type Description

The TimedEvent

Source code in feral3gp/feral/core/de_worker.py
109
110
111
112
113
114
115
116
def schedule_timer(self, time, value):
    """
    Schedule a timer at a given absolute simulation time
    :param time: The simulation time in nanoseconds at which the timer shall expire
    :param value: The event data which is set for the created timer
    :return: The TimedEvent
    """
    return self.get_java_delegate().scheduleTimer(time, value)

set_console(console)

Set the console for this worker

Parameters:

Name Type Description Default
console

The console to be set

required
Source code in feral3gp/feral/core/de_worker.py
142
143
144
145
146
147
def set_console(self, console):
    """
    Set the console for this worker
    :param console: The console to be set
    """
    self.get_java_delegate().setConsole(console)

terminate()

This method will be called by the controlling MOCC during the termination phase of the simulation

Source code in feral3gp/feral/core/de_worker.py
39
40
41
42
43
def terminate(self):
    """
    This method will be called by the controlling MOCC during the termination phase of the simulation
    """
    pass

timer_expired(timed_event)

A timer has expired. Process the given timed event.

Source code in feral3gp/feral/core/de_worker.py
27
28
29
30
31
def timer_expired(self, timed_event):
    """
    A timer has expired. Process the given timed event.
    """
    pass