pypdevsbbl.tracers package

Create and use tracers for your models.

This file provides a basic tracer (BaseTracer) that can be used as a superclass for all custom tracers. Furthermore, a setTracer() function is provided to allow for more complex tracing possibilities.

The subpackage also provides a few commonly used tracers in production-based models.

pypdevsbbl.tracers._hashes = {}

Helper variable that will allow the setTracer() method to work.

It is a dict of the id()-value of a tracer and its arguments.

pypdevsbbl.tracers._hashedTracer(uid, server, tracer, *hargs)[source]

Helper function to set the tracer.

pypdevsbbl.tracers.setTracer(simulator, tracerclass, *args)[source]

Assigns a custom tracer with variable arguments.

In PythonPDEVS’ custom tracer registration process, all additional arguments are casted to a string before passed to an eval() function call. Not all objects can be cast to a string and still retain their information.

This function allows you to set a tracer with custom arguments that cannot be cast to a string.

See also

src/dependencies/pythonpdevs/src/pypdevs/tracer.py:40-42

Parameters:
  • simulator – The simulator to set the tracer on.
  • tracerclass – The tracer class to set as an instatiatable.
  • *args – All arguments to pass to the tracer’s __init__()-call, except the uid and the server.
pypdevsbbl.tracers.superTrace(server, uid, model, args)[source]
class pypdevsbbl.tracers.BaseTracer(uid, server, filename)[source]

Bases: object

Base for all custom tracers.

Implements all required methods for a custom tracer.

Parameters:
  • uid – A unique identifier for distributed simulation. Can be ignored, but must be the first argument!
  • server – The server that runs the distributed simulation. Can be ignored, but must be the second argument!
  • filename – The name of the file to write the results to. When None, all results will be written to the standard output.
startTracer(recover)[source]

Starts the Tracer

Parameters:recover (bool) – Represents whether or not this is a recovered call. E.g., should the file be overwritten (False) or appended to (True)?
stopTracer()[source]

Stops the tracer (e.g., flush the file)

trace(*text, sep=' ', end='')[source]

Actual tracing function.

This function sort of works like the “print” function, but only takes strings or bytes as arguments.

Parameters:
  • text – The text to trace.
  • sep (str) – The text separator. Defaults to a space.
  • end (str) – The ending token of the stream to write. Defaults to the empty string.
traceInternal(aDEVS)[source]

Called for each atomic DEVS model that does an internal transition.

traceExternal(aDEVS)[source]

Called for each atomic DEVS model that does an external transition.

traceConfluent(aDEVS)[source]

Called for each atomic DEVS model that does a confluent transition.

traceInit(aDEVS, t)[source]

Called upon initialization of a model.

Parameters:t (numeric) – The time at which the model commences (likely 0).
traceUser(time, aDEVS, variable, value)[source]

Called upon so-called god events during debugging.

A god event is an event where a user manually alters the state of an atomic DEVS instance.