Store Example
pydes.Store(sim, capacity=1)
Stores are useful to save and retrieve objects. Stores can be use to insert any type of object but it requires all the objects to be of the same type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sim
|
Simulator
|
The simulator instance. |
required |
capacity
|
int
|
The capacity of the store, default is infinity. |
1
|
get()
Get an item from the store.
put(item)
Put an item into the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
Any
|
The item to put into the store. |
required |
level()
Get the current level of the store.
capacity()
Get the capacity of the store.
Imports
Define Model
Run Simulation
sim = Simulator()
store = Store(sim, 3)
p1 = Process1(sim, store)
p2 = Process2(sim, store)
sim.schedule(p1.main)
sim.schedule(p2.main)
sim.run(until=20)
| ------------------------------ | --------------- | ---------------------------------------- | ------------------------------ |
| time | component | value | description |
| ------------------------------ | --------------- | ---------------------------------------- | ------------------------------ |
| | | | |
| 0 | Process1.0 | start put | None |
| 0 | Process2.0 | start get | None |
| 0 | Process1.0 | end put | None |
| 0 | Process1.0 | store level: 1 | None |
| 0 | Process2.0 | end get: Element(id=0) | None |
| 0 | Process2.0 | store level: 0 | None |
| 5 | Process1.0 | start put | None |
| 5 | Process1.0 | end put | None |
| 5 | Process1.0 | store level: 1 | None |
| 10 | Process1.0 | start put | None |
| 10 | Process1.0 | end put | None |
| 10 | Process1.0 | store level: 2 | None |
| 15 | Process1.0 | start put | None |
| 15 | Process1.0 | end put | None |
| 15 | Process1.0 | store level: 3 | None |
| 20 | Process2.0 | start get | None |
| 20 | Process1.0 | start put | None |
| 20 | Process2.0 | end get: Element(id=1) | None |
| 20 | Process2.0 | store level: 2 | None |
| 20 | Process1.0 | end put | None |
| 20 | Process1.0 | store level: 3 | None |