Package gov.nasa.jpl.aerie.merlin.protocol.driver
Since a model provides methods to be invoked by a driver, typically the only way for the model to communicate back to the driver is via the values returned from its methods. However, it is often necessary for the model to communicate with the driver without returning immediately. The interfaces in this package are provided as arguments to a model at one time or another, allowing the model to call back to the driver.
The exception (which proves the rule) is the CellId type, which
has no methods of its own. Instead, it acts as a typed identifier that the model can use to ask the driver for
the current state of an allocated cell. (It "proves the rule" because it is used precisely when calling the driver
back.)
The model can only interact with the driver during three contexts: initialization, execution, and inquisition.
-
During initialization, a model can allocate cells to hold its internal state, spawn top-level "daemon" tasks, and export resources (time-varying values) and topics (streams of discrete events). It can also query the current state of its cells, even though they cannot be changed from their initial values during this phase. The
Initializerinterface grants access to these actions, and is typically provided to theModelType.instantiate(java.time.Instant, java.lang.Object, gov.nasa.jpl.aerie.merlin.protocol.driver.Initializer)method.In the future, resource and topic exportation may be moved to the
ModelTypeclass instead, so that the input and output interface of a model can be known independent of a particular choice of configuration. -
During execution, a model can get the current value of a cell, emit events (to influence cells or to be logged on an exported topic), and spawn additional tasks. The
Schedulerinterface grants access to these actions, and is typically provided to theTask.step(gov.nasa.jpl.aerie.merlin.protocol.driver.Scheduler)method.In the future, models may also be able to allocate state during execution, to facilitate sharing temporary state between subtasks.
- During inquisition, a model can only get the current value of a cell. The
Querierinterface provides this read-only access to the model's state, and is typically provided to theResource.getDynamics(gov.nasa.jpl.aerie.merlin.protocol.driver.Querier)andCondition.nextSatisfied(gov.nasa.jpl.aerie.merlin.protocol.driver.Querier, gov.nasa.jpl.aerie.merlin.protocol.types.Duration)methods.