Skip to content

Commit

Permalink
Merge pull request #947 from NASA-AMMOS/855-860-catch-sim-exceptions-…
Browse files Browse the repository at this point in the history
…refactor-rootfinding

Refactor rootfinding to simulate less and catch simulation exceptions
  • Loading branch information
adrienmaillard authored Jun 9, 2023
2 parents 75308ad + b1cfdbb commit 6d22130
Show file tree
Hide file tree
Showing 11 changed files with 281 additions and 466 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package gov.nasa.jpl.aerie.foomissionmodel.activities;

import gov.nasa.jpl.aerie.foomissionmodel.Mission;
import gov.nasa.jpl.aerie.merlin.framework.annotations.ActivityType;
import gov.nasa.jpl.aerie.merlin.framework.annotations.ActivityType.EffectModel;

/**
* An activity that can't be scheduled in the first 60 seconds of the horizon
*/
@ActivityType("LateRiser")
public record LateRiserActivity() {
@EffectModel
public void run(final Mission mission) {
if (mission.timeTrackerDaemon.getMinutesElapsed() < 1) {
throw new RuntimeException("Can't be scheduled THAT early");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
package gov.nasa.jpl.aerie.foomissionmodel.models;

import gov.nasa.jpl.aerie.contrib.models.counters.Counter;
import gov.nasa.jpl.aerie.merlin.framework.ModelActions;
import gov.nasa.jpl.aerie.merlin.protocol.types.Duration;

/**
* A daemon task that tracks the number of minutes since plan start
*/
public class TimeTrackerDaemon {
private int minutesElapsed;
private Counter<Integer> minutesElapsed;

public int getMinutesElapsed() {
return minutesElapsed;
return minutesElapsed.get();
}

public TimeTrackerDaemon(){
minutesElapsed = 0;
}
public TimeTrackerDaemon(){ minutesElapsed = Counter.ofInteger(0);}

public void run(){
minutesElapsed = 0;
minutesElapsed.add(-minutesElapsed.get());
while(true) {
ModelActions.delay(Duration.MINUTE);
minutesElapsed++;
minutesElapsed.add(1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

@WithActivityType(DecompositionTestActivities.ParentActivity.class)
@WithActivityType(DecompositionTestActivities.ChildActivity.class)
@WithActivityType(LateRiserActivity.class)

package gov.nasa.jpl.aerie.foomissionmodel;

Expand All @@ -29,6 +30,7 @@
import gov.nasa.jpl.aerie.foomissionmodel.activities.DaemonCheckerActivity;
import gov.nasa.jpl.aerie.foomissionmodel.activities.DecompositionTestActivities;
import gov.nasa.jpl.aerie.foomissionmodel.activities.FooActivity;
import gov.nasa.jpl.aerie.foomissionmodel.activities.LateRiserActivity;
import gov.nasa.jpl.aerie.foomissionmodel.activities.OtherControllableDurationActivity;
import gov.nasa.jpl.aerie.foomissionmodel.activities.SolarPanelNonLinear;
import gov.nasa.jpl.aerie.foomissionmodel.activities.SolarPanelNonLinearTimeDependent;
Expand Down
Loading

0 comments on commit 6d22130

Please sign in to comment.