Class SimulationEngine
java.lang.Object
gov.nasa.jpl.aerie.merlin.driver.engine.SimulationEngine
- All Implemented Interfaces:
AutoCloseable
A representation of the work remaining to do during a simulation, and its accumulated results.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA representation of a job processable by theSimulationEngine.static final recordstatic final recordstatic final recordThe span of time over which a subtree of tasks has acted.static interfacestatic final record -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Resets all tasks (freeing any held resources).Create a timeline that in the output of the engine's reference timeline combined with its expanded timeline.computeActivitySimulationResults(Instant startTime, gov.nasa.jpl.aerie.merlin.driver.engine.SimulationEngine.SpanInfo spanInfo) Computes only activity-related results when resources are not neededcomputeActivitySimulationResults(Instant startTime, gov.nasa.jpl.aerie.merlin.protocol.driver.Topic<gov.nasa.jpl.aerie.types.ActivityDirectiveId> activityTopic, Iterable<MissionModel.SerializableTopic<?>> serializableTopics) computeResults(Instant startTime, gov.nasa.jpl.aerie.merlin.protocol.driver.Topic<gov.nasa.jpl.aerie.types.ActivityDirectiveId> activityTopic, Iterable<MissionModel.SerializableTopic<?>> serializableTopics, SimulationResourceManager resourceManager) Compute a set of results from the current state of simulation.computeResults(Instant startTime, gov.nasa.jpl.aerie.merlin.protocol.driver.Topic<gov.nasa.jpl.aerie.types.ActivityDirectiveId> activityTopic, Iterable<MissionModel.SerializableTopic<?>> serializableTopics, SimulationResourceManager resourceManager, Set<String> resourceNames) extractNextJobs(gov.nasa.jpl.aerie.merlin.protocol.types.Duration maximumTime) Removes and returns the next set of jobs to be performed concurrently.getDirectiveDetailsFromSpan(gov.nasa.jpl.aerie.merlin.protocol.driver.Topic<gov.nasa.jpl.aerie.types.ActivityDirectiveId> activityTopic, Iterable<MissionModel.SerializableTopic<?>> serializableTopics, SpanId spanId) Get an Activity Directive Id from a SpanId, if the span is a descendent of a directive.gov.nasa.jpl.aerie.merlin.protocol.types.Durationvoidinit(Map<String, gov.nasa.jpl.aerie.merlin.protocol.model.Resource<?>> resources, gov.nasa.jpl.aerie.merlin.protocol.model.TaskFactory<gov.nasa.jpl.aerie.merlin.protocol.types.Unit> daemons) Initialize the engine by tracking resources and kicking off daemon tasks.voidinvalidateTopic(gov.nasa.jpl.aerie.merlin.protocol.driver.Topic<?> topic, gov.nasa.jpl.aerie.merlin.protocol.types.Duration invalidationTime) Schedules any conditions or resources dependent on the given topic to be re-checked at the given time.Optional<gov.nasa.jpl.aerie.merlin.protocol.types.Duration> voidperformJob(SimulationEngine.JobId job, TaskFrame<SimulationEngine.JobId> frame, gov.nasa.jpl.aerie.merlin.protocol.types.Duration currentTime, gov.nasa.jpl.aerie.merlin.protocol.types.Duration maximumTime, SimulationEngine.ResourceUpdates resourceUpdates) Performs a single job.performJobs(Collection<SimulationEngine.JobId> jobs, LiveCells context, gov.nasa.jpl.aerie.merlin.protocol.types.Duration currentTime, gov.nasa.jpl.aerie.merlin.protocol.types.Duration maximumTime) Performs a collection of tasks concurrently, extending the given timeline by their stateful effects.<Output> SpanIdscheduleTask(gov.nasa.jpl.aerie.merlin.protocol.types.Duration startTime, gov.nasa.jpl.aerie.merlin.protocol.model.TaskFactory<Output> state) Schedule a new task to be performed at the given time.booleanspanIsComplete(SpanId spanId) step(gov.nasa.jpl.aerie.merlin.protocol.types.Duration simulationDuration) Step the engine forward one batch.voidstepTask(TaskId task, TaskFrame<SimulationEngine.JobId> frame, gov.nasa.jpl.aerie.merlin.protocol.types.Duration currentTime) Perform the next step of a modeled task.<Dynamics> voidtrackResource(String name, gov.nasa.jpl.aerie.merlin.protocol.model.Resource<Dynamics> resource, gov.nasa.jpl.aerie.merlin.protocol.types.Duration nextQueryTime) Register a resource whose profile should be accumulated over time.voidunscheduleAfter(gov.nasa.jpl.aerie.merlin.protocol.types.Duration duration) voidupdateCondition(ConditionId condition, TaskFrame<SimulationEngine.JobId> frame, gov.nasa.jpl.aerie.merlin.protocol.types.Duration currentTime, gov.nasa.jpl.aerie.merlin.protocol.types.Duration horizonTime) Determine when a condition is next true, and schedule a signal to be raised at that time.voidupdateResource(ResourceId resourceId, TaskFrame<SimulationEngine.JobId> frame, gov.nasa.jpl.aerie.merlin.protocol.types.Duration currentTime, SimulationEngine.ResourceUpdates resourceUpdates) Get the current behavior of a given resource and accumulate it into the resource's profile.
-
Constructor Details
-
SimulationEngine
-
-
Method Details
-
init
public void init(Map<String, gov.nasa.jpl.aerie.merlin.protocol.model.Resource<?>> resources, gov.nasa.jpl.aerie.merlin.protocol.model.TaskFactory<gov.nasa.jpl.aerie.merlin.protocol.types.Unit> daemons) throws ThrowableInitialize the engine by tracking resources and kicking off daemon tasks.- Throws:
Throwable
-
getElapsedTime
public gov.nasa.jpl.aerie.merlin.protocol.types.Duration getElapsedTime() -
step
public SimulationEngine.Status step(gov.nasa.jpl.aerie.merlin.protocol.types.Duration simulationDuration) throws Throwable Step the engine forward one batch.- Throws:
Throwable
-
scheduleTask
public <Output> SpanId scheduleTask(gov.nasa.jpl.aerie.merlin.protocol.types.Duration startTime, gov.nasa.jpl.aerie.merlin.protocol.model.TaskFactory<Output> state) Schedule a new task to be performed at the given time. -
trackResource
public <Dynamics> void trackResource(String name, gov.nasa.jpl.aerie.merlin.protocol.model.Resource<Dynamics> resource, gov.nasa.jpl.aerie.merlin.protocol.types.Duration nextQueryTime) Register a resource whose profile should be accumulated over time. -
invalidateTopic
public void invalidateTopic(gov.nasa.jpl.aerie.merlin.protocol.driver.Topic<?> topic, gov.nasa.jpl.aerie.merlin.protocol.types.Duration invalidationTime) Schedules any conditions or resources dependent on the given topic to be re-checked at the given time. -
extractNextJobs
public JobSchedule.Batch<SimulationEngine.JobId> extractNextJobs(gov.nasa.jpl.aerie.merlin.protocol.types.Duration maximumTime) Removes and returns the next set of jobs to be performed concurrently. -
performJobs
public SimulationEngine.StepResult performJobs(Collection<SimulationEngine.JobId> jobs, LiveCells context, gov.nasa.jpl.aerie.merlin.protocol.types.Duration currentTime, gov.nasa.jpl.aerie.merlin.protocol.types.Duration maximumTime) throws SpanException Performs a collection of tasks concurrently, extending the given timeline by their stateful effects.- Throws:
SpanException
-
performJob
public void performJob(SimulationEngine.JobId job, TaskFrame<SimulationEngine.JobId> frame, gov.nasa.jpl.aerie.merlin.protocol.types.Duration currentTime, gov.nasa.jpl.aerie.merlin.protocol.types.Duration maximumTime, SimulationEngine.ResourceUpdates resourceUpdates) throws SpanException Performs a single job.- Throws:
SpanException
-
stepTask
public void stepTask(TaskId task, TaskFrame<SimulationEngine.JobId> frame, gov.nasa.jpl.aerie.merlin.protocol.types.Duration currentTime) throws SpanException Perform the next step of a modeled task.- Throws:
SpanException
-
updateCondition
public void updateCondition(ConditionId condition, TaskFrame<SimulationEngine.JobId> frame, gov.nasa.jpl.aerie.merlin.protocol.types.Duration currentTime, gov.nasa.jpl.aerie.merlin.protocol.types.Duration horizonTime) Determine when a condition is next true, and schedule a signal to be raised at that time. -
updateResource
public void updateResource(ResourceId resourceId, TaskFrame<SimulationEngine.JobId> frame, gov.nasa.jpl.aerie.merlin.protocol.types.Duration currentTime, SimulationEngine.ResourceUpdates resourceUpdates) Get the current behavior of a given resource and accumulate it into the resource's profile. -
close
public void close()Resets all tasks (freeing any held resources). The engine should not be used after being closed.- Specified by:
closein interfaceAutoCloseable
-
unscheduleAfter
public void unscheduleAfter(gov.nasa.jpl.aerie.merlin.protocol.types.Duration duration) -
getDirectiveDetailsFromSpan
public DirectiveDetail getDirectiveDetailsFromSpan(gov.nasa.jpl.aerie.merlin.protocol.driver.Topic<gov.nasa.jpl.aerie.types.ActivityDirectiveId> activityTopic, Iterable<MissionModel.SerializableTopic<?>> serializableTopics, SpanId spanId) Get an Activity Directive Id from a SpanId, if the span is a descendent of a directive. -
computeActivitySimulationResults
public SimulationEngine.SimulationActivityExtract computeActivitySimulationResults(Instant startTime, gov.nasa.jpl.aerie.merlin.protocol.driver.Topic<gov.nasa.jpl.aerie.types.ActivityDirectiveId> activityTopic, Iterable<MissionModel.SerializableTopic<?>> serializableTopics) -
computeActivitySimulationResults
public SimulationEngine.SimulationActivityExtract computeActivitySimulationResults(Instant startTime, gov.nasa.jpl.aerie.merlin.driver.engine.SimulationEngine.SpanInfo spanInfo) Computes only activity-related results when resources are not needed -
computeResults
public SimulationResults computeResults(Instant startTime, gov.nasa.jpl.aerie.merlin.protocol.driver.Topic<gov.nasa.jpl.aerie.types.ActivityDirectiveId> activityTopic, Iterable<MissionModel.SerializableTopic<?>> serializableTopics, SimulationResourceManager resourceManager) Compute a set of results from the current state of simulation. -
computeResults
public SimulationResults computeResults(Instant startTime, gov.nasa.jpl.aerie.merlin.protocol.driver.Topic<gov.nasa.jpl.aerie.types.ActivityDirectiveId> activityTopic, Iterable<MissionModel.SerializableTopic<?>> serializableTopics, SimulationResourceManager resourceManager, Set<String> resourceNames) -
getSpan
-
spanIsComplete
-
duplicate
-
peekNextTime
-
combineTimeline
Create a timeline that in the output of the engine's reference timeline combined with its expanded timeline.
-