Skip to content

Commit 5f3b5b6

Browse files
authored
Merge pull request #3 from ModiaSim/development
Improvements
2 parents 141c844 + 686c755 commit 5f3b5b6

File tree

5 files changed

+52
-18
lines changed

5 files changed

+52
-18
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SignalTables"
22
uuid = "3201582d-3078-4276-ba5d-0a1254d79d7c"
33
authors = ["Martin.Otter@dlr.de <Martin.Otter@dlr.de>"]
4-
version = "0.3.0"
4+
version = "0.3.1"
55

66
[deps]
77
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

docs/src/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ are different to the Python 2.x version.
183183

184184
## Release Notes
185185

186+
### Version 0.3.1
187+
188+
- writeSignalTable(..): Do not store elements, that cannot be mapped to JSON + add _classVersion to signal table on file.
189+
- For backwards compatibilty to ModiaResult, also accept ENV["MODIA_PLOT_PACKAGE"] instead of ENV["SignalTablesPlotPackage"]
190+
to define plot package.
191+
192+
186193
### Version 0.3.0
187194

188195
- Slightly non-backwards compatiable to 0.2.0.

src/PlotPackageDefinition.jl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ macro usingPlotPackage()
1414
if haskey(ENV, "SignalTablesPlotPackage")
1515
PlotPackage = ENV["SignalTablesPlotPackage"]
1616
if !(PlotPackage in AvailablePlotPackages)
17-
@warn "ENV[\"SignalTablesPlotPackage\"] = \"$PlotPackage\" is not supported!. Using \"SilentNoPlot\"."
17+
@info "ENV[\"SignalTablesPlotPackage\"] = \"$PlotPackage\" is not supported!. Using \"SilentNoPlot\"."
1818
@goto USE_NO_PLOT
1919
elseif PlotPackage == "NoPlot"
2020
@goto USE_NO_PLOT
@@ -28,8 +28,25 @@ macro usingPlotPackage()
2828
return esc( :(using $PlotPackage) )
2929
end
3030

31+
elseif haskey(ENV, "MODIA_PLOT_PACKAGE")
32+
PlotPackage = ENV["MODIA_PLOT_PACKAGE"]
33+
if !(PlotPackage in AvailablePlotPackages)
34+
@info "ENV[\"MODIA_PLOT_PACKAGE\"] = \"$PlotPackage\" is not supported!. Using \"SilentNoPlot\"."
35+
@goto USE_NO_PLOT
36+
elseif PlotPackage == "NoPlot"
37+
@goto USE_NO_PLOT
38+
elseif PlotPackage == "SilentNoPlot"
39+
expr = :( import SignalTables.SilentNoPlot: plot, showFigure, saveFigure, closeFigure, closeAllFigures )
40+
return esc( expr )
41+
else
42+
PlotPackage = Symbol("SignalTablesInterface_" * PlotPackage)
43+
expr = :(using $PlotPackage)
44+
println("$expr")
45+
return esc( :(using $PlotPackage) )
46+
end
47+
3148
else
32-
@warn "No plot package activated. Using \"SilentNoPlot\"."
49+
@info "No plot package activated. Using \"SilentNoPlot\"."
3350
@goto USE_NO_PLOT
3451
end
3552

src/SignalTableFunctions.jl

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -675,13 +675,17 @@ the corresponding signals are encoded.
675675
"""
676676
function encodeSignalTable(signalTable; signalNames=nothing)
677677
if isSignalTable(signalTable)
678-
jdict = OrderedDict{String,Any}("_class" => "SignalTable")
678+
jdict = OrderedDict{String,Any}("_class" => "SignalTable",
679+
"_classVersion" => version)
679680
if isnothing(signalNames)
680681
signalNames = getSignalNames(signalTable)
681682
end
682683
for name in signalNames
683684
signal = getSignal(signalTable, name)
684-
jdict[name] = encodeSignalTableElement(name, signal)
685+
encodedSignal = encodeSignalTableElement(name, signal)
686+
if !isnothing(encodedSignal)
687+
jdict[name] = encodedSignal
688+
end
685689
end
686690
return jdict
687691
else
@@ -696,23 +700,28 @@ end
696700
Encodes a signal table element suitable to convert to JSON format.
697701
"""
698702
function encodeSignalTableElement(path, element)
699-
if isVar(element)
700-
jdict = OrderedDict{String,Any}("_class" => "Var")
701-
for (key,val) in element
702-
if key != :Var
703-
jdict[string(key)] = encodeSignalTableElement(appendNames(path,key),val)
704-
end
703+
if isSignal(element)
704+
if isVar(element)
705+
jdict = OrderedDict{String,Any}("_class" => "Var")
706+
else
707+
jdict = OrderedDict{String,Any}("_class" => "Par")
705708
end
706-
return jdict
707-
708-
elseif isPar(element)
709-
jdict = OrderedDict{String,Any}("_class" => "Par")
709+
available = true
710710
for (key,val) in element
711-
if key != :Par
712-
jdict[string(key)] = encodeSignalTableElement(appendNames(path,key),val)
711+
if key != ":_class"
712+
encodedSignal = encodeSignalTableElement(appendNames(path,key),val)
713+
if isnothing(encodedSignal)
714+
available = false
715+
else
716+
jdict[string(key)] = encodedSignal
717+
end
713718
end
714719
end
715-
return jdict
720+
if available
721+
return jdict
722+
else
723+
return nothing
724+
end
716725

717726
elseif typeof(element) <: AbstractArray && (elementBaseType(eltype(element)) <: Number || elementBaseType(eltype(element)) <: String)
718727
if ndims(element) == 1 && string(elementBaseType(eltype(element))) in TypesWithoutEncoding

src/SignalTables.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module SignalTables
22

33
const path = dirname(dirname(@__FILE__))
4+
const version = "0.3.1" # version tag of SignalTables release without "v"
45

56
using OrderedCollections
67
using Unitful

0 commit comments

Comments
 (0)