# 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)

  Helper function to set the tracer.

`pypdevsbbl.tracers.``setTracer`(simulator, tracerclass, *args)

  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)

class `pypdevsbbl.tracers.``BaseTracer`(uid, server, filename)

  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)

    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`()

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

  `trace`(*text, sep=' ', end='')

    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)

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

  `traceExternal`(aDEVS)

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

  `traceConfluent`(aDEVS)

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

  `traceInit`(aDEVS, t)

    Called upon initialization of a model.

    Parameters: | t (numeric) – The time at which the model commences (likely 0).

  `traceUser`(time, aDEVS, variable, value)

    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.

## Submodules

- pypdevsbbl.tracers.FootprintTracer module
- pypdevsbbl.tracers.PlotTracer module
- pypdevsbbl.tracers.ProfileTracer module
- pypdevsbbl.tracers.StatisticsTracer module