simpype.message
¶
SimPype’s message.
-
class
simpype.message.
Message
(sim, resource, id)¶ This class implements the simpype.Message object.
simpype.Message object is the atomic unit processed by simpype.Resource objects.
Parameters: - sim (
Simulation
) – The SimPype simulation object - resource (
Resource
) – The simpype.Resource object generating this message - id (str) – The SimPype message id
-
sim
¶ The SimPype simulation object.
Type: Simulation
-
env
¶ The SimPy environment object.
Type: simpy.Environment
-
id
¶ The simpype.Message id
Type: str
-
generated
¶ The simulation time when this object was generated.
Type: float
-
is_alive
¶ The boolean value marking if the message is alive or not. A message is not alive when no further steps are available or if it is used as a template by a generator.
Type: bool
-
location
¶ The location of the simpype.Message inside the simulation pipeline.
Type: Resource
Pipe
Queue
-
property
¶ The PropertyDict dictionary storing the
Property
objectsType: PropertyDict
-
seq_num
¶ The sequence number of the message
Type: int
-
subscription
¶ The dictionary storing the Subscription objects
Type: dict
-
visited
¶ The list of the visited simpype.Resource objects
Type: list
-
done
()¶ Deactivate the message, empty the next adjency list, and defuse all the active subscriptions
-
drop
(id='dropped', event=None)¶ Drop the simpype.Message object from the simulation.
If event is not None, subscribe the message to the event and the default drop callback
Parameters: - id (str, optional) – The id identifying in the log this drop action
- event (simpy.Event, optional) – The event that will trigger the message dropping
-
next
¶ The next resources available to the message in the form of adjency list
Next property admits only simpype.Resource, simpype.Pipeline, and next-compatible values
-
pipeline
¶ The pipeline associated to the message in the form of adjency.
A pipeline represents all the possible paths to the message. Pipeline property admits only simpype.Pipeline objects as a value
-
resource
¶ The resource currently managing the message.
Resource property admits only simpype.Resource objects as a value
-
subscribe
(event, callback, id)¶ Subscribe the message to a given event which will execute a callback function.
Parameters: - event (simpy.Event) – The simpy.Event to subscribe to
- callback (user-defined python function) – The function to call upon event triggering
- id (str) – The id identifying this subscription
Returns:
-
timestamp
(description)¶ Create and write a timestamp to the log file
Parameters: description (str) – The timestamp description
-
unsubscribe
(id)¶ Unsubscribe the message from the subscription
id
Parameters: id (any) – The subscription id to unsubscribe
- sim (
-
class
simpype.message.
Property
(sim, name, value)¶ This class implements the properties used by simpype.Message objects.
A property value can be either static or dynamic. In the latter case the
value
must follow the simpype.Random value dictionary format.Parameters: - sim (
Simulation
) – The SimPype simulation object - name (str) – The property name
- value (any) – The property value
-
sim
¶ The SimPype simulation object
Type: Simulation
-
env
¶ The SimPy environment object
Type: simpy.Environment
-
name
¶ The property name
Type: str
-
value
¶ The property value
Type: any
-
refresh
()¶ Generate a new random value for the simpype.Property object.
This function does not produce any effects if the simpype.Property value is static.
-
value
The value of the simpype.Property.
- sim (
-
class
simpype.message.
PropertyDict
(sim)¶ A custom dictionary storing simpype.Property objects.
Parameters: sim ( Simulation
) – The SimPype simulation object-
sim
¶ The SimPype simulation object
Type: Simulation
-
env
¶ The SimPy environment object
Type: simpy.Environment
-
-
class
simpype.message.
Subscription
(sim, message, event, callback, id)¶ This class implements the subscriptions used by simpype.Message objects.
Subscription used to execute a given function upong some events triggering.
Parameters: - sim (
Simulation
) – The SimPype simulation object - message (
Message
) – The SimPype message object this timestamp is associated to - event (simpy.Event) – The Simpy event the simpype.Message object is subscribed to
- callback (user-defined python function) – The python function to call upon event triggering
- id (str) – The simpype.Subscription id
-
sim
¶ The SimPype simulation object
Type: Simulation
-
env
¶ The SimPy environment object
Type: simpy.Environment
-
event
¶ The Simpy event the simpype.Message object is subscribed to
Type: simpy.Event
-
callback
¶ The python function to call upon event triggering
Type: user-defined python function
-
id
¶ The simpype.Subscription id
Type: str
-
disable
¶ The Simpy event used to remove the subscription
Type: simpy.Event
- sim (
-
class
simpype.message.
Timestamp
(message, timestamp, resource, description)¶ This class implements the timestamps used by simpype.Message objects.
Timestamp objects are used for logging purposes.
Parameters: -
timestamp
¶ The simulation time of the timestmap
Type: int,float
-
description
¶ The description of the event generating the timestamp
Type: str
-