1313
1414Flat struct, defining the settings of the Simulator and the Viewer.
1515
16+ Use [`load_settings`](@ref) to reload the global module singleton, or
17+ [`Settings(project)`](@ref) to create a fresh, independent instance.
18+
1619$(TYPEDFIELDS)
1720"""
1821@with_kw mutable struct Settings @deftype Float64
@@ -355,13 +358,20 @@ StructTypes.StructType(::Type{Settings}) = StructTypes.Mutable()
355358PROJECT:: String = " system.yaml"
356359
357360"""
358- Settings(project)
361+ Settings(project; relax=false)
362+
363+ Create a fresh [`Settings`](@ref) instance, loading from the given
364+ project file. Unlike [`load_settings`](@ref), this does **not** modify
365+ the global module settings; it returns an independent struct.
359366
360- Constructor for the [`Settings`](@ref) struct, loading settings from the given project file.
367+ ## Parameters
368+ - `project`: The name of the project file to load.
369+ - `relax`: If true, missing sections in the settings file are
370+ skipped instead of raising an error.
361371"""
362- function Settings (project)
372+ function Settings (project; relax = false )
363373 set = Settings ()
364- return se (set, project)
374+ return se (set, project; relax )
365375end
366376const SETTINGS = Settings ()
367377const _SE_DICTS = IdDict {Settings, Dict{String, Any}} ()
@@ -396,13 +406,18 @@ end
396406"""
397407 load_settings(project=PROJECT; relax=false)
398408
399- Load the project with the given file name.
409+ Reload the global module [`Settings`](@ref) from the given project
410+ file. Returns the updated global settings singleton. To obtain an
411+ independent settings instance instead, use the
412+ [`Settings(project)`](@ref) constructor.
400413
401414The project must include the path and the suffix .yaml .
402415
403416## Parameters
404- - `project`: The name of the project file to load, defaults to the project that was loaded before.
405- - `relax`: If true, no section needs to be present in the settings.yaml file.
417+ - `project`: The name of the project file to load, defaults to
418+ the project that was loaded before.
419+ - `relax`: If true, missing sections in the settings file are
420+ skipped instead of raising an error.
406421"""
407422function load_settings (project= PROJECT; relax= false )
408423 SETTINGS. segments= 0
@@ -536,7 +551,7 @@ function se(settings::Settings, project=PROJECT; relax=false)
536551 dict = YAML. load_file (joinpath (DATA_PATH[1 ], sim_settings_path))
537552 _SE_DICTS[settings] = dict
538553 # update the settings struct from the dictionary
539- required_sections = [" system" , " initial " , " solver" , " kite" , " tether" , " environment" ]
554+ required_sections = [" system" , " solver" , " kite" , " tether" , " environment" ]
540555 if relax
541556 for section in required_sections
542557 if section in keys (dict)
@@ -546,7 +561,7 @@ function se(settings::Settings, project=PROJECT; relax=false)
546561 else
547562 update_settings (dict, required_sections, settings)
548563 end
549- for section in [" steering" , " depower" , " kps4" , " kps5" , " bridle" , " winch" , " kcu" ]
564+ for section in [" initial " , " steering" , " depower" , " kps4" , " kps5" , " bridle" , " winch" , " kcu" ]
550565 if section in keys (dict)
551566 update_settings (dict, [section], settings)
552567 end
0 commit comments