Skip to content
This repository has been archived by the owner on Mar 14, 2021. It is now read-only.

Commit

Permalink
ENH: added ResultsStore type to save propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexS12 committed May 9, 2020
1 parent 2e9457e commit 49488b8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/models/Models.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Models

import Base: +, -, *, isapprox, convert, copy, show
import Base: +, -, *, isapprox, convert, copy, show, push!, getindex, setindex!
using LinearAlgebra
using FlightMechanics

Expand Down Expand Up @@ -74,7 +74,9 @@ get_payload_mass_props, calculate_aircraft,
# DynamicSystem
SixDOFEulerFixedMass, SixDOFQuaternionFixedMass, SixDOFECEFQuaternionFixedMass,
SixDOFAeroEulerFixedMass,
get_state_equation, get_state_equation_ode_wrapper, get_x, get_x_count, get_state
get_state_equation, get_state_equation_ode_wrapper, get_x, get_x_count, get_state,
# Results Store
ResultsStore

include("attitude.jl")
include("position.jl")
Expand All @@ -93,4 +95,5 @@ include("propulsion.jl")
include("aerodynamics.jl")
include("aircraft.jl")
include("dynamic_systems.jl")
include("results_store.jl")
end
34 changes: 34 additions & 0 deletions src/models/results_store.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
struct ResultsStore
t :: Array{T, 1} where T <: Number
ac :: Array{T, 1} where T <: Aircraft
fcs :: Array{T, 1} where T <: FCS
env :: Array{T, 1} where T <: Environment
state :: Array{T, 1} where T <: State
aerostate :: Array{T, 1} where T <: AeroState
end

ResultsStore(t::Number, ac::Aircraft, fcs::FCS, env::Environment, state::State, aerostate::AeroState) = ResultsStore([t], [ac], [fcs], [env], [state], [aerostate])


function push!(results::ResultsStore, t, ac, fcs, env, state, aerostate)
push!(results.t, t)
push!(results.ac, ac)
push!(results.fcs, fcs)
push!(results.env, env)
push!(results.state, state)
push!(results.aerostate, aerostate)
end

# Indexable collection
function getindex(results::ResultsStore, ii)
return ResultsStore(results.t[ii], results.ac[ii], results.fcs[ii], results.env[ii], results.state[ii], results.aerostate[ii])
end

function set_index!(results::ResultsStore, value, ii)
results.t[ii] = value[0]
results.ac[ii] = value[1]
results.fcs[ii] = value[2]
results.env[ii] = value[3]
results.state[ii] = value[4]
results.aerostate[ii] = value[5]
end

0 comments on commit 49488b8

Please sign in to comment.