Skip to content

Commit

Permalink
I think that should be it for the fuel handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherRabotin committed Apr 16, 2017
1 parent f3acbfb commit b46fc89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion mission.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package smd

import (
"fmt"
"log"
"math"
"sync"
"time"
Expand Down Expand Up @@ -113,8 +114,9 @@ func (a *Mission) Propagate() {
}
a.Vehicle.logger.Log("level", "notice", "subsys", "astro", "status", "finished", "duration", durStr, "Δv(km/s)", math.Abs(vFinal-vInit), "fuel(kg)", initFuel-a.Vehicle.FuelMass)
a.LogStatus()
if a.Vehicle.FuelMass < 0 {
if a.Vehicle.handleFuel && a.Vehicle.FuelMass < 0 {
a.Vehicle.logger.Log("level", "critical", "subsys", "prop", "fuel(kg)", a.Vehicle.FuelMass)
log.Fatal("cannot continue without fuel")
}
wg.Wait() // Don't return until we're done writing all the files.
}
Expand Down
5 changes: 3 additions & 2 deletions spacecraft.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Spacecraft struct {
logger kitlog.Logger
prevCL *ControlLaw // Stores the previous control law to follow what is going on.
Drag float64
handleFuel bool
}

// SCLogInit initializes the logger.
Expand Down Expand Up @@ -181,12 +182,12 @@ func (sc *Spacecraft) ToXCentric(body CelestialObject, dt time.Time, o *Orbit) f

// NewEmptySC returns a spacecraft with no cargo and no EPThrusters.
func NewEmptySC(name string, mass uint) *Spacecraft {
return &Spacecraft{name, float64(mass), 0, NewUnlimitedEPS(), []EPThruster{}, false, []*Cargo{}, []Waypoint{}, []func(){}, SCLogInit(name), nil, 0}
return &Spacecraft{name, float64(mass), 0, NewUnlimitedEPS(), []EPThruster{}, false, []*Cargo{}, []Waypoint{}, []func(){}, SCLogInit(name), nil, 0, false}
}

// NewSpacecraft returns a spacecraft with initialized function queue and logger.
func NewSpacecraft(name string, dryMass, fuelMass float64, eps EPS, prop []EPThruster, impulse bool, payload []*Cargo, wp []Waypoint) *Spacecraft {
return &Spacecraft{name, dryMass, fuelMass, eps, prop, impulse, payload, wp, make([]func(), 5), SCLogInit(name), nil, 0}
return &Spacecraft{name, dryMass, fuelMass, eps, prop, impulse, payload, wp, make([]func(), 5), SCLogInit(name), nil, 0, fuelMass > 0}
}

// Cargo defines a piece of cargo with arrival date and destination orbit
Expand Down

0 comments on commit b46fc89

Please sign in to comment.