-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from HHS/dev
v4.3.0
- Loading branch information
Showing
34 changed files
with
1,521 additions
and
967 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 37 additions & 20 deletions
57
simulation/src/main/java/gov/hhs/aspr/ms/gcm/simulation/nucleus/ActorPlan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,45 @@ | ||
package gov.hhs.aspr.ms.gcm.simulation.nucleus; | ||
|
||
import java.util.function.Consumer; | ||
public abstract class ActorPlan extends Plan { | ||
|
||
public class ActorPlan extends Plan { | ||
ActorId actorId; | ||
protected final Consumer<ActorContext> consumer; | ||
// The actor id is used by the simulation via package access | ||
ActorId actorId; | ||
|
||
public ActorPlan(double time, boolean active, long arrivalId, Consumer<ActorContext> consumer) { | ||
super(time, active, arrivalId, Planner.ACTOR); | ||
this.consumer = consumer; | ||
} | ||
|
||
|
||
public ActorPlan(double time, Consumer<ActorContext> consumer) { | ||
super(time, true, -1L, Planner.ACTOR); | ||
this.consumer = consumer; | ||
} | ||
/** | ||
* Constructs the plan scheduled for the given time, active status and arrivalId. | ||
* | ||
* | ||
*/ | ||
public ActorPlan(double time, boolean active, long arrivalId) { | ||
super(time, active, arrivalId, Planner.ACTOR); | ||
} | ||
|
||
public ActorPlan(double time, boolean active, Consumer<ActorContext> consumer) { | ||
super(time, active, -1L, Planner.ACTOR); | ||
this.consumer = consumer; | ||
} | ||
/** | ||
* Constructs the plan scheduled for the given time. The plan will | ||
* be active.The arrival id is set to -1L indicating that this is a new, | ||
* non-deserialized plan. | ||
* | ||
* | ||
*/ | ||
public ActorPlan(double time) { | ||
super(time, true, -1L, Planner.ACTOR); | ||
} | ||
|
||
protected void execute(ActorContext context) { | ||
this.consumer.accept(context); | ||
} | ||
|
||
/** | ||
* Constructs the plan scheduled for the given time and active status. | ||
* The arrival id is set to -1L indicating that this is a new, non-deserialized | ||
* plan. | ||
* | ||
* | ||
*/ | ||
public ActorPlan(double time, boolean active) { | ||
super(time, active, -1L, Planner.ACTOR); | ||
} | ||
|
||
/** | ||
* Executes the actor logic associated with the plan. | ||
*/ | ||
protected abstract void execute(ActorContext context); | ||
} |
71 changes: 71 additions & 0 deletions
71
simulation/src/main/java/gov/hhs/aspr/ms/gcm/simulation/nucleus/ConsumerActorPlan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package gov.hhs.aspr.ms.gcm.simulation.nucleus; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import gov.hhs.aspr.ms.util.errors.ContractException; | ||
|
||
public final class ConsumerActorPlan extends ActorPlan { | ||
|
||
private final Consumer<ActorContext> consumer; | ||
|
||
/** | ||
* Constructs the plan scheduled for the given time active status arrivalId and | ||
* consumer | ||
* | ||
* @throws ContractException | ||
* <ul> | ||
* <li>{@linkplain NucleusError#NULL_PLAN_CONSUMER} if | ||
* the consumer is null</li> | ||
* </ul> | ||
*/ | ||
public ConsumerActorPlan(double time, boolean active, long arrivalId, Consumer<ActorContext> consumer) { | ||
super(time, active, arrivalId); | ||
if (consumer == null) { | ||
throw new ContractException(NucleusError.NULL_PLAN_CONSUMER); | ||
} | ||
this.consumer = consumer; | ||
} | ||
|
||
/** | ||
* Constructs the plan scheduled for the given time and consumer. The plan will | ||
* be active.The arrival id is set to -1L indicating that this is a new, | ||
* non-deserialized plan. | ||
* | ||
* @throws ContractException | ||
* <ul> | ||
* <li>{@linkplain NucleusError#NULL_PLAN_CONSUMER} if | ||
* the consumer is null</li> | ||
* </ul> | ||
*/ | ||
public ConsumerActorPlan(double time, Consumer<ActorContext> consumer) { | ||
super(time); | ||
if (consumer == null) { | ||
throw new ContractException(NucleusError.NULL_PLAN_CONSUMER); | ||
} | ||
this.consumer = consumer; | ||
} | ||
|
||
/** | ||
* Constructs the plan scheduled for the given time, active status and consumer. | ||
* The arrival id is set to -1L indicating that this is a new, non-deserialized | ||
* plan. | ||
* | ||
* @throws ContractException | ||
* <ul> | ||
* <li>{@linkplain NucleusError#NULL_PLAN_CONSUMER} if | ||
* the consumer is null</li> | ||
* </ul> | ||
*/ | ||
public ConsumerActorPlan(double time, boolean active, Consumer<ActorContext> consumer) { | ||
super(time, active); | ||
if (consumer == null) { | ||
throw new ContractException(NucleusError.NULL_PLAN_CONSUMER); | ||
} | ||
this.consumer = consumer; | ||
} | ||
|
||
@Override | ||
protected final void execute(ActorContext context) { | ||
this.consumer.accept(context); | ||
} | ||
} |
Oops, something went wrong.