simplay.components — Components¶
- class simplay.components.VisualProcess(env: VisualEnvironment, id: str, visual: str, tint: int = 16777215)¶
Bases:
VisualComponentShorthand for creating an entity of type
PROCESS.- Parameters:
env – The environment instance.
id – The id of the component.
visual – The visualization of the component, must be registered in the
VisualizationManager.tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.
- class simplay.components.VisualResource(env: VisualEnvironment, id: str, capacity: int, visual: str, tint: int = 16777215)¶
Bases:
VisualComponent,Resource- Extends the
Resourceclass with visualization.
- Parameters:
env – The environment instance.
id – The id of the component.
capacity – The capacity of the resource.
visual – The visualization of the component, must be registered in the
VisualizationManager.tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.
- Raises:
ValueError – If the capacity is not a positive integer.
TypeError – If the capacity is not a integer.
- release(request: Request) Release¶
Releases the usage of resource granted by request. This event is triggered immediately. Subclass of
simpy.resources.base.Get.
- request() Request¶
Request usage of the resource. The event is triggered once access is granted. Subclass of
simpy.resources.base.Put.If the maximum capacity of users has not yet been reached, the request is triggered immediately. If the maximum capacity has been reached, the request is triggered once an earlier usage request on the resource is released.
The request is automatically released when the request was created within a
withstatement.
- Extends the
- class simplay.components.VisualPreemptiveResource(env: VisualEnvironment, id: str, capacity: int, visual: str, tint: int = 16777215)¶
Bases:
VisualComponent,PreemptiveResource- Extends the
PreemptiveResourceclass with visualization.
- Parameters:
env – The environment instance.
id – The id of the component.
capacity – The capacity of the resource.
visual – The visualization of the component, must be registered in the
VisualizationManager.tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.
- Raises:
TypeError – If the capacity is not a integer.
ValueError – If the capacity is not a positive integer.
- release(request: PriorityRequest) Release¶
Releases the usage of resource granted by request. This event is triggered immediately. Subclass of
simpy.resources.base.Get.
- request(priority: int = 0, preempt: bool = True) PriorityRequest¶
Request the usage of resource with a given priority. If the resource supports preemption and preempt is
Trueother usage requests of the resource may be preempted (seePreemptiveResourcefor details).This event type inherits
Requestand adds some additional attributes needed byPriorityResourceandPreemptiveResource
- Extends the
- class simplay.components.VisualPriorityResource(env: VisualEnvironment, id: str, capacity: int, visual: str, tint: int = 16777215)¶
Bases:
VisualComponent,PriorityResource- Extends the
PriorityResourceclass with visualization.
- Parameters:
env – The environment instance.
id – The id of the component.
capacity – The capacity of the resource.
visual – The visualization of the component, must be registered in the
VisualizationManager.tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.
- Raises:
TypeError – If the capacity is not a integer.
ValueError – If the capacity is not a positive integer.
- release(request: PriorityRequest) Release¶
Releases the usage of resource granted by request. This event is triggered immediately. Subclass of
simpy.resources.base.Get.
- request(priority: int = 0, preempt: bool = True) PriorityRequest¶
Request the usage of resource with a given priority. If the resource supports preemption and preempt is
Trueother usage requests of the resource may be preempted (seePreemptiveResourcefor details).This event type inherits
Requestand adds some additional attributes needed byPriorityResourceandPreemptiveResource
- Extends the
- class simplay.components.VisualStore(env: VisualEnvironment, id: str, visual: str, tint: int = 16777215, capacity: float | int = inf)¶
Bases:
VisualComponent,StoreExtends the
Storeclass with visualization.- Parameters:
env – The environment instance.
id – The id of the component.
capacity – The capacity of the store.
visual – The visualization of the component, must be registered in the
VisualizationManager.tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.
- Raises:
TypeError – If the capacity is not a integer or float.
ValueError – If the capacity is not a positive integer or float.
- get() StoreGet¶
Request to get an item from the store. The request is triggered once there is an item available in the store.
- put(item) StorePut¶
Request to put item into the store. The request is triggered once there is space for the item in the store.
- class simplay.components.VisualFilterStore(env: VisualEnvironment, id: str, capacity: int, visual: str, tint: int = 16777215)¶
Bases:
VisualComponent,FilterStore- Extends the
FilterStoreclass with visualization.
- Parameters:
env – The environment instance.
id – The id of the component.
capacity – The capacity of the store.
visual – The visualization of the component, must be registered in the
VisualizationManager.tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.
- Raises:
TypeError – If the capacity is not a integer or float.
ValueError – If the capacity is not a positive integer or float.
- get(filter: ~typing.Callable[[~typing.Any], bool] = <function VisualFilterStore.<lambda>>) FilterStoreGet¶
Request to get an item from the store matching the filter. The request is triggered once there is such an item available in the store.
filter is a function receiving one item. It should return
Truefor items matching the filter criterion. The default function returnsTruefor all items, which makes the request to behave exactly likeStoreGet.
- put(item) StorePut¶
Request to put item into the store. The request is triggered once there is space for the item in the store.
- Extends the
- class simplay.components.VisualContainer(env: VisualEnvironment, id: str, visual: str, tint: int = 16777215, capacity: int | float = inf, init: int | float = 0)¶
Bases:
VisualComponent,Container- Extends the
Containerclass with visualization.
- Parameters:
env – The environment instance.
id – The id of the component.
capacity – The capacity of the container.
init – The initial amount of the container.
visual – The visualization of the component, must be registered in the
VisualizationManager.tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.
- Raises:
TypeError – If the capacity is not a integer or float.
ValueError – If the capacity is not a positive integer or float.
- get(amount: int | float) ContainerGet¶
Request to get amount of matter from the container. The request will be triggered once there is enough matter available in the container.
Raise a
ValueErrorifamount <= 0.
- put(amount: int | float) ContainerPut¶
Request to put amount of matter into the container. The request will be triggered once there is enough space in the container available.
Raise a
ValueErrorifamount <= 0.
- Extends the