@@ -72,12 +72,12 @@ mutable struct ResultInfo
7272 aliasName:: String # Name of non-eliminated variable
7373 aliasNegate:: Bool # = true, if info[aliasName] signal must be negated
7474 id:: Vector{ValuesID} # Location of the variable values with respect to ResultKind and Result
75- _basetype # If known, basetype (signal.values/.values); if not known: Nothing
75+ _eltypeOrType # If known, eltypeOrType (signal.values/.values); if not known: Nothing
7676 value:: Any # Value of constant variable (without unit)
7777
78- ResultInfo (kind:: ResultKind , signal, _basetype ) = new (kind , signal, " " , false , ValuesID[] , _basetype , nothing )
79- ResultInfo (kind:: ResultKind , signal, id:: ValuesID , _basetype ) = new (kind , signal, " " , false , ValuesID[id], _basetype , nothing )
80- ResultInfo (signal:: SignalTables.SymbolDictType , value) = new (RESULT_CONSTANT , signal, " " , false , ValuesID[] , basetype (value), value)
78+ ResultInfo (kind:: ResultKind , signal, _eltypeOrType ) = new (kind , signal, " " , false , ValuesID[] , _eltypeOrType , nothing )
79+ ResultInfo (kind:: ResultKind , signal, id:: ValuesID , _eltypeOrType ) = new (kind , signal, " " , false , ValuesID[id], _eltypeOrType , nothing )
80+ ResultInfo (signal:: SignalTables.SymbolDictType , value) = new (RESULT_CONSTANT , signal, " " , false , ValuesID[] , eltypeOrType (value), value)
8181 ResultInfo (signal:: SignalTables.SymbolDictType , aliasName:: String , aliasNegate:: Bool ) = new (RESULT_ELIMINATED, signal, aliasName, aliasNegate, ValuesID[], Nothing, nothing )
8282end
8383
@@ -130,15 +130,23 @@ mutable struct Result{FloatType,TimeType}
130130 @assert (! haskey (info, xi_info. der_x_name))
131131 x_unit = xi_info. unit
132132 der_x_unit = x_unit == " " ? " 1/s" : unitAsParseableString (uparse (x_unit)/ u " s" )
133- x_var = Var (unit= x_unit, start= xi_info. startOrInit, fixed= xi_info. fixed, state= true , der= xi_info. der_x_name)
133+ if x_unit == " "
134+ x_var = Var (start= xi_info. startOrInit, fixed= xi_info. fixed, state= true , der= xi_info. der_x_name)
135+ else
136+ x_var = Var (unit= x_unit, start= xi_info. startOrInit, fixed= xi_info. fixed, state= true , der= xi_info. der_x_name)
137+ end
134138 if ! isnan (xi_info. nominal)
135139 x_var[:nominal ] = xi_info. nominal
136140 end
137141 if xi_info. unbounded
138142 x_var[:unbounded ] = true
139143 end
140- info[xi_info. x_name] = ResultInfo (RESULT_X , x_var, FloatType)
141- info[xi_info. der_x_name] = ResultInfo (RESULT_DER_X, Var (unit= der_x_unit), FloatType)
144+ info[xi_info. x_name] = ResultInfo (RESULT_X, x_var, FloatType)
145+ if der_x_unit == " "
146+ info[xi_info. der_x_name] = ResultInfo (RESULT_DER_X, Var (), FloatType)
147+ else
148+ info[xi_info. der_x_name] = ResultInfo (RESULT_DER_X, Var (unit= der_x_unit), FloatType)
149+ end
142150 end
143151
144152 # Fill info with w_invariant
@@ -214,12 +222,12 @@ function signalResultValues(t::AbstractVector, s::AbstractVector, resultInfo::Re
214222 id = resultInfo. id
215223 @assert (length (id) > 0 )
216224 inlineValues = resultInfo. kind == RESULT_X || resultInfo. kind == RESULT_DER_X
217- _basetype = resultInfo. _basetype
225+ _eltypeOrType = resultInfo. _eltypeOrType
218226 ndims_s = length (id[1 ]. dims)
219227 if id[1 ]. segment == - 1 && ndims_s == 0
220228 # Scalar signal that is defined in every segment
221229 index = id[1 ]. index
222- sc = _basetype [ustrip .(ti[index]) for sk in s for ti in sk]
230+ sc = _eltypeOrType [ustrip .(ti[index]) for sk in s for ti in sk]
223231
224232 else
225233 # Find largest dims = dimsMax in all segments
@@ -248,10 +256,10 @@ function signalResultValues(t::AbstractVector, s::AbstractVector, resultInfo::Re
248256 dims = (dims1, dimsMax... )
249257 if hasMissing
250258 # Allocate target memory with missing values
251- sc = Array {Union{_basetype ,Missing}, length(dims)} (missing , dims)
259+ sc = Array {Union{_eltypeOrType ,Missing}, length(dims)} (missing , dims)
252260 else
253261 # Allocate target memory with undef values
254- sc = Array {_basetype , length(dims)} (undef, dims)
262+ sc = Array {_eltypeOrType , length(dims)} (undef, dims)
255263 end
256264
257265 # Copy subset of s-values to target sc
0 commit comments