qns.simulator package
Submodules
qns.simulator.event module
- class qns.simulator.event.Event(t: Optional[qns.simulator.ts.Time] = None, name: Optional[str] = None, by: Optional[Any] = None)[source]
Bases:
object
Basic event class in simulator
- property is_canceled: bool
Returns: whether this event has been canceled
- qns.simulator.event.func_to_event(t: qns.simulator.ts.Time, fn, name: Optional[str] = None, by: Optional[Any] = None, *args, **kwargs)[source]
Convert a function to an event, the function fn will be called at t. It is a simple method to wrap a function to an event.
- Parameters
t (Time) – the function will be called at t
fn (Callable) – the function
by – the entity or application that will causes this event
*args – the function’s parameters
**kwargs – the function’s parameters
qns.simulator.pool module
- class qns.simulator.pool.DefaultEventPool(ts: qns.simulator.ts.Time, te: qns.simulator.ts.Time)[source]
Bases:
object
The default implement of the event pool
- add_event(event: qns.simulator.event.Event) bool [source]
Insert an event into the pool
- Parameters
event (Event) – The inserting event
- Returns
if the event is inserted successfully
- property current_time: qns.simulator.ts.Time
Get the current time
- next_event() qns.simulator.event.Event [source]
Get the next event to be executed
- Returns
The next event to be executed
qns.simulator.pool module
- class qns.simulator.pool.DefaultEventPool(ts: qns.simulator.ts.Time, te: qns.simulator.ts.Time)[source]
Bases:
object
The default implement of the event pool
- add_event(event: qns.simulator.event.Event) bool [source]
Insert an event into the pool
- Parameters
event (Event) – The inserting event
- Returns
if the event is inserted successfully
- property current_time: qns.simulator.ts.Time
Get the current time
- next_event() qns.simulator.event.Event [source]
Get the next event to be executed
- Returns
The next event to be executed
qns.simulator.simulator module
- class qns.simulator.simulator.Simulator(start_second: float = 0.0, end_second: float = 60.0, accuracy: int = 1000000)[source]
Bases:
object
The discrete-event driven simulator core
- add_event(event: qns.simulator.event.Event) None [source]
Add an
event
into simulator event pool. :param event: the inserting event
- property current_time: qns.simulator.ts.Time
Get the current time of the simulation
- Returns
(Time) the current time
- property tc: qns.simulator.ts.Time
The alias of current_time
- time(time_slot: Optional[int] = None, sec: Optional[float] = None) qns.simulator.ts.Time [source]
Produce a
Time
usingtime_slot
orsec
- Parameters
time_slot (Optional[int]) – the time slot
sec (Optional[float]) – the second
- Returns
the produced
Time
object
qns.simulator.ts module
qns.simulator.ts module
Module contents
- class qns.simulator.Event(t: Optional[qns.simulator.ts.Time] = None, name: Optional[str] = None, by: Optional[Any] = None)[source]
Bases:
object
Basic event class in simulator
- property is_canceled: bool
Returns: whether this event has been canceled
- class qns.simulator.Simulator(start_second: float = 0.0, end_second: float = 60.0, accuracy: int = 1000000)[source]
Bases:
object
The discrete-event driven simulator core
- add_event(event: qns.simulator.event.Event) None [source]
Add an
event
into simulator event pool. :param event: the inserting event
- property current_time: qns.simulator.ts.Time
Get the current time of the simulation
- Returns
(Time) the current time
- property tc: qns.simulator.ts.Time
The alias of current_time
- time(time_slot: Optional[int] = None, sec: Optional[float] = None) qns.simulator.ts.Time [source]
Produce a
Time
usingtime_slot
orsec
- Parameters
time_slot (Optional[int]) – the time slot
sec (Optional[float]) – the second
- Returns
the produced
Time
object
- class qns.simulator.Time(time_slot: int = 0, sec: float = 0.0, accuracy: int = 1000000)[source]
Bases:
object
- property sec: float
Returns: the timestamp in second
- qns.simulator.func_to_event(t: qns.simulator.ts.Time, fn, name: Optional[str] = None, by: Optional[Any] = None, *args, **kwargs)[source]
Convert a function to an event, the function fn will be called at t. It is a simple method to wrap a function to an event.
- Parameters
t (Time) – the function will be called at t
fn (Callable) – the function
by – the entity or application that will causes this event
*args – the function’s parameters
**kwargs – the function’s parameters