Add feature to export points of interest as a CSV file
parent
917a16782d
commit
1a5cf9b822
|
@ -8,5 +8,5 @@ settings:
|
|||
operationModeMinimumRunningTime: true # operation mode "minimum running time"
|
||||
operationModeMinimumEnergyConsumption: false # operation mode "minimum energy consumption"
|
||||
typeOfOutput: "julia dictionary" # output as "julia dictionary" or as "CSV"
|
||||
detailOfOutput: "driving course" # should the output be "minimal" or "driving course"?
|
||||
detailOfOutput: "driving course" # should the output be "minimal", "points of interest" or "driving course"?
|
||||
csvDirectory: "~/Desktop/TrainRun"
|
||||
|
|
|
@ -11,18 +11,28 @@ function exportToCsv(output::Dict)
|
|||
|
||||
if output[:settings][:operationModeMinimumRunningTime] == true
|
||||
operationMode = "minimum running time"
|
||||
createCsvFile(output[:movingSectionMinimumRunningTime], output[:drivingCourseMinimumRunningTime], operationMode, pathName, trainName, output[:settings])
|
||||
if output[:settings][:detailOfOutput] == "points of interest"
|
||||
dataPointsToExport = output[:pointsOfInterestMinimumRunningTime]
|
||||
else
|
||||
dataPointsToExport = output[:drivingCourseMinimumRunningTime]
|
||||
end
|
||||
createCsvFile(output[:movingSectionMinimumRunningTime], dataPointsToExport, operationMode, pathName, trainName, output[:settings])
|
||||
end
|
||||
if output[:settings][:operationModeMinimumEnergyConsumption] == true
|
||||
operationMode = "minimum energy consumption"
|
||||
createCsvFile(output[:movingSectionMinimumEnergyConsumption], output[:drivingCourseMinimumEnergyConsumption], operationMode, pathName, trainName, output[:settings])
|
||||
if output[:settings][:detailOfOutput] == "points of interest"
|
||||
dataPointsToExport = output[:pointsOfInterestMinimumEnergyConsumption]
|
||||
else
|
||||
dataPointsToExport = output[:drivingCourseMinimumEnergyConsumption]
|
||||
end
|
||||
createCsvFile(output[:movingSectionMinimumEnergyConsumption], dataPointsToExport, operationMode, pathName, trainName, output[:settings])
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end #function exportToCsv
|
||||
|
||||
function createCsvFile(movingSection::Dict, drivingCourse::Vector{Dict}, operationMode::String, pathName::String, trainName::String, settings::Dict)
|
||||
function createCsvFile(movingSection::Dict, dataPointsToExport::Vector{Dict}, operationMode::String, pathName::String, trainName::String, settings::Dict)
|
||||
detailOfOutput = settings[:detailOfOutput]
|
||||
|
||||
massModel = settings[:massModel]
|
||||
|
@ -35,9 +45,9 @@ function createCsvFile(movingSection::Dict, drivingCourse::Vector{Dict}, operati
|
|||
push!(summarizedData, ["s (in m)", "t (in s)","E (in Ws)"]) # push header to summarizedData
|
||||
row = [movingSection[:length], movingSection[:t], movingSection[:E]]
|
||||
push!(summarizedData, row) # push row to summarizedData
|
||||
elseif detailOfOutput=="driving course"
|
||||
elseif detailOfOutput == "driving course" || detailOfOutput == "points of interest"
|
||||
push!(summarizedData, ["i", "behavior", "Δs (in m)", "s (in m)", "Δt (in s)","t (in s)","Δv (in m/s)","v (in m/s)","F_T (in N)","F_R (in N)","R_path (in N)","R_train (in N)","R_traction (in N)","R_wagons (in N)", "ΔW (in Ws)","W (in Ws)","ΔE (in Ws)","E (in Ws)","a (in m/s^2)"]) # push header to summarizedData
|
||||
for point in drivingCourse
|
||||
for point in dataPointsToExport
|
||||
row = [point[:i], point[:behavior], point[:Δs], point[:s], point[:Δt], point[:t], point[:Δv], point[:v], point[:F_T], point[:F_R], point[:R_path], point[:R_train], point[:R_traction], point[:R_wagons], point[:ΔW], point[:W], point[:ΔE], point[:E], point[:a]]
|
||||
push!(summarizedData, row) # push row to summarizedData
|
||||
end
|
||||
|
@ -63,7 +73,7 @@ function createCsvFile(movingSection::Dict, drivingCourse::Vector{Dict}, operati
|
|||
# combine the columns in a data frame and saving it as a CSV-file at csvDirectory
|
||||
if detailOfOutput == "minimal"
|
||||
df = DataFrame(c1=allColumns[1], c2=allColumns[2],c3=allColumns[3])
|
||||
elseif detailOfOutput=="driving course"
|
||||
elseif detailOfOutput=="driving course" || detailOfOutput == "points of interest"
|
||||
df = DataFrame(c1=allColumns[1], c2=allColumns[2],c3=allColumns[3], c4=allColumns[4], c5=allColumns[5], c6=allColumns[6], c7=allColumns[7], c8=allColumns[8], c9=allColumns[9], c10=allColumns[10], c11=allColumns[11], c12=allColumns[12], c13=allColumns[13], c14=allColumns[14], c15=allColumns[15], c16=allColumns[16], c17=allColumns[17], c18=allColumns[18], c19=allColumns[19])
|
||||
end
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ function importSettingsFromYaml(settingsDirectory::String)
|
|||
# TODO: it could be checked if the path is existing on the pc
|
||||
end # if
|
||||
|
||||
settings[:detailOfOutput] = getString!(data, "settings", "detailOfOutput", ["minimal", "driving course"]) # should the output be "minimal" or "driving course"
|
||||
settings[:detailOfOutput] = getString!(data, "settings", "detailOfOutput", ["minimal", "points of interest", "driving course"]) # should the output be "minimal" or are "points of interest" or the complete "driving course" required?
|
||||
|
||||
informAboutUnusedKeys(data, "settings") # inform the user, which keywords of the imported data are not used in this tool
|
||||
|
||||
|
|
12
src/Input.jl
12
src/Input.jl
|
@ -17,6 +17,10 @@ function checkAndSetInput!(train::Dict, path::Dict, settings::Dict)
|
|||
checkAndSetPath!(path)
|
||||
checkAndSetSettings!(settings)
|
||||
|
||||
if settings[:detailOfOutput] == "points of interest" && !haskey(path, :pointsOfInterest)
|
||||
settings[:detailOfOutput] = "driving course"
|
||||
println("INFO at checking the input for settings and path: settings[:detailOfOutput] is 'points of interest' but the path does not have a list for pointsOfInterest. Therefore the detailOfOut is changed to 'driving course'.")
|
||||
end
|
||||
return (train, path, settings)
|
||||
end #function checkAndSetInput!
|
||||
|
||||
|
@ -92,7 +96,7 @@ function checkAndSetSettings!(settings::Dict)
|
|||
# TODO: it could be checked if the path is existing on the pc
|
||||
end # if
|
||||
|
||||
checkString(settings, "settings", :detailOfOutput, ["minimal", "driving course"]) # should the output be "minimal" or "driving course"
|
||||
checkString(settings, "settings", :detailOfOutput, ["minimal", "points of interest", "driving course"]) # should the output be "minimal" or are "points of interest" or the complete "driving course" required?
|
||||
|
||||
# TODO: informAboutUnusedKeys(settings, "settings") # inform the user, which Symbols of the input dictionary are not used in this tool
|
||||
|
||||
|
@ -424,7 +428,7 @@ function checkAndSetPOIs!(path::Dict)
|
|||
end # for
|
||||
|
||||
if errorDetected
|
||||
error("ERROR at checking the input dictionary for the path: The values of the point of interest have to be corrected.")
|
||||
error("ERROR at checking the input dictionary for the path: The values of pointsOfInterest have to be corrected.")
|
||||
end
|
||||
if sortingNeeded == true
|
||||
sort!(pointsOfInterest)
|
||||
|
@ -439,10 +443,12 @@ function checkAndSetPOIs!(path::Dict)
|
|||
end
|
||||
end # for
|
||||
path[:pointsOfInterest] = copiedPOIs
|
||||
end
|
||||
|
||||
else
|
||||
println("INFO at checking the input dictionary for the path: The key pointsOfInterest exists but without values.")
|
||||
delete!(path, :pointsOfInterest)
|
||||
end
|
||||
end
|
||||
|
||||
return path
|
||||
end #function checkAndSetPOIs!
|
||||
|
|
|
@ -32,7 +32,13 @@ julia> calculateDrivingDynamics(trainDict, pathDict, settingsDict)
|
|||
todo !!!
|
||||
```
|
||||
"""
|
||||
function calculateDrivingDynamics(train::Dict, path::Dict, settings::Dict)
|
||||
function calculateDrivingDynamics(trainInput::Dict, pathInput::Dict, settingsInput::Dict)
|
||||
# copy Input data for not changing them
|
||||
# TODO: or should they be changed? enormally it would only make it "better" except for settings[:detailOfOutput] == "points of interest" && !haskey(path, :pointsOfInterest)
|
||||
train = copy(trainInput)
|
||||
path = copy(pathInput)
|
||||
settings = copy(settingsInput)
|
||||
|
||||
# check the input data
|
||||
(train, path, settings) = checkAndSetInput!(train, path, settings)
|
||||
println("The input has been checked.")
|
||||
|
|
Loading…
Reference in New Issue