TrainRun.jl/src/TrainRuns.jl

70 lines
2.1 KiB
Julia
Raw Normal View History

#!/usr/bin/env julia
# -*- coding: UTF-8 -*-
# __julia-version__ = 1.7.2
2022-04-28 17:02:40 +02:00
# __author__ = "Max Kannenberg, Martin Scheidt"
# __copyright__ = "2020-2022"
# __license__ = "ISC"
2022-04-28 17:02:40 +02:00
__precompile__(true)
2022-05-04 16:53:58 +02:00
module TrainRuns
2021-10-13 16:49:42 +02:00
## loading standard library packages
using UUIDs, Dates
2022-04-28 17:02:40 +02:00
## loading external packages
using YAML, JSONSchema, CSV, DataFrames
export
## Interface
trainrun, Path, Settings, exportToCsv
2022-04-28 17:02:40 +02:00
## include package files
include("types.jl")
2022-05-08 21:43:21 +02:00
include("constructors.jl")
2022-04-28 17:02:40 +02:00
include("formulary.jl")
include("characteristics.jl")
include("behavior.jl")
include("output.jl")
include("import.jl")
include("export.jl")
include("calc.jl")
## main function
"""
trainrun(train::Dict, path::Path, settings::Settings)
Calculate the running time of a `train` on a `path`.
The `settings` provides the choice of models for the calculation.
`settings` can be omitted. If so, a default is used.
The running time will be return in seconds.
# Examples
```julia-repl
julia> trainrun(train, path)
xxx.xx # in seconds
```
"""
function trainrun(trainInput::Dict, path::Path, settings=Settings()::Settings)
# copy Input data for not changing them
# TODO: or should they be changed? normally it would only make it "better" except for settings.outputDetail == :points_of_interest && isempty(path.poi)
train = copy(trainInput)
# check the input data
train = checkAndSetTrain!(train)
settings.outputDetail == :everything && println("The input has been checked.")
# prepare the input data
movingSection = determineCharacteristics(path, train, settings)
settings.outputDetail == :everything && println("The moving section has been prepared.")
# calculate the train run for oparation mode "minimum running time"
(movingSection, drivingCourse) = calculateMinimumRunningTime!(movingSection, settings, train)
settings.outputDetail == :everything && println("The driving course for the shortest running time has been calculated.")
# accumulate data and create an output dictionary
output = createOutput(train, settings, path, movingSection, drivingCourse)
return output
end # function trainrun
2021-10-13 16:49:42 +02:00
2022-05-04 16:53:58 +02:00
end # module TrainRuns