Skip to content

Commit c399c1f

Browse files
authored
Merge pull request #236 from JuliaRobotics/twig/4Q19/fcttime_fix
Updates to branch
2 parents f1cd474 + 1ec840d commit c399c1f

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

src/CommonAccessors.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
export getLabel, label
66
export getTags, setTags!, tags
77
export getTimestamp, setTimestamp!, timestamp
8-
export getInternalId, interalId
8+
export getInternalId, internalId
99

1010

1111
const DataLevel0 = Union{VariableDataLevel0, FactorDataLevel0}
@@ -50,15 +50,18 @@ DEPRECATED, tags -> getTags
5050
"""
5151
function tags(v::DataLevel0)
5252
@warn "tags deprecated, use getTags instead"
53-
getTags
53+
getTags(v)
5454
end
5555

5656
"""
5757
$SIGNATURES
5858
5959
Set the tags for a factor.
6060
"""
61-
setTags!(f::DataLevel0, tags::Vector{Symbol}) = f.tags = tags
61+
function setTags!(f::DataLevel0, tags::Vector{Symbol})
62+
resize!(f.tags, length(tags))
63+
f.tags .= tags
64+
end
6265

6366

6467
"""

src/entities/DFGFactor.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ mutable struct DFGFactor{T, S} <: AbstractDFGFactor
4444
_internalId::Int64
4545
_variableOrderSymbols::Vector{Symbol}
4646
# TODO back to front ts and _internalId for legacy reasons
47-
DFGFactor{T, S}(label::Symbol, _internalId::Int64=0, ts::DateTime=now()) where {T, S} = new{T, S}(label, Symbol[], GenericFunctionNodeData{T, S}(), 0, ts, 0, Symbol[])
47+
DFGFactor{T, S}(label::Symbol, _internalId::Int64=0, timestamp::DateTime=now()) where {T, S} = new{T, S}(label, Symbol[], GenericFunctionNodeData{T, S}(), 0, timestamp, 0, Symbol[])
4848
# DFGFactor{T, S}(label::Symbol, _internalId::Int64) where {T, S} = new{T, S}(label, Symbol[], GenericFunctionNodeData{T, S}(), 0, now(), _internalId, Symbol[])
4949
end
5050

src/entities/DFGVariable.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,22 +248,21 @@ end
248248
"""
249249
$SIGNATURES
250250
251-
Retrieve the soft type name symbol for a DFGVariable or DFGVariableSummary. ie :Point2, Pose2, etc.
252-
251+
Retrieve the soft type name symbol for a DFGVariableSummary. ie :Point2, Pose2, etc.
253252
TODO, DO NOT USE v.softtypename in DFGVariableSummary
254253
"""
255-
getSofttype(v::DFGVariableSummary) = v.softtypename
254+
getSofttype(v::DFGVariableSummary)::Symbol = v.softtypename
256255

257256

258257

259258
"""
260259
$SIGNATURES
261260
262-
Return the softtype name for a variable.
261+
Return the softtype for a variable.
263262
264263
DEPRECATED, softtype -> getSofttype
265264
"""
266-
function softtype(v::VariableDataLevel1)::Symbol
265+
function softtype(v::VariableDataLevel1)
267266
@warn "Deprecated softtype, use getSofttype instead."
268267
getSofttype(v)
269268
end

src/services/DFGFactor.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function packFactor(dfg::G, f::DFGFactor)::Dict{String, Any} where G <: Abstract
88
# Construct the properties to save
99
props = Dict{String, Any}()
1010
props["label"] = string(f.label)
11+
props["timestamp"] = string(f.timestamp)
1112
props["tags"] = JSON2.write(f.tags)
1213
# Pack the node data
1314
fnctype = f.data.fnc.usrfnc!
@@ -32,6 +33,7 @@ end
3233

3334
function unpackFactor(dfg::G, packedProps::Dict{String, Any}, iifModule)::DFGFactor where G <: AbstractDFG
3435
label = packedProps["label"]
36+
timestamp = DateTime(packedProps["timestamp"])
3537
tags = JSON2.read(packedProps["tags"], Vector{Symbol})
3638

3739
data = packedProps["data"]
@@ -56,7 +58,7 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any}, iifModule)::DFGFac
5658
solvable = packedProps["solvable"]
5759

5860
# Rebuild DFGVariable
59-
factor = DFGFactor{typeof(fullFactor.fnc), Symbol}(Symbol(label))
61+
factor = DFGFactor{typeof(fullFactor.fnc), Symbol}(Symbol(label), 0, timestamp)
6062
factor.tags = tags
6163
factor.data = fullFactor
6264
factor._variableOrderSymbols = _variableOrderSymbols

test/iifInterfaceTests.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ end
160160
@test solverDataDict(v1) == v1.solverDataDict
161161
@test internalId(v1) == v1._internalId
162162

163-
@test softtype(v1) == :ContinuousScalar#Symbol(typeof(st1))
164-
@test softtype(v2) == :ContinuousScalar#Symbol(typeof(st2))
165-
@test typeof(getSofttype(v1)) == typeof(ContinuousScalar())
163+
@test typeof(softtype(v1)) == ContinuousScalar
164+
@test typeof(softtype(v2)) == ContinuousScalar
165+
@test typeof(getSofttype(v1)) == ContinuousScalar
166166

167167
@test label(f1) == f1.label
168168
@test tags(f1) == f1.tags
@@ -441,9 +441,10 @@ end
441441
for v in ls(summaryGraph)
442442
for field in variableFields
443443
if field != :softtypename
444-
@test getfield(getVariable(dfg, v), field) == getfield(getVariable(summaryGraph, v), field)
444+
@test getfield(getVariable(dfg, v), field) == getfield(getVariable(summaryGraph, v), field)
445445
else
446-
@test softtype(getVariable(dfg, v)) == softtype(getVariable(summaryGraph, v))
446+
# Special case to check the symbol softtype is equal to the full softtype.
447+
@test Symbol(typeof(softtype(getVariable(dfg, v)))) == softtype(getVariable(summaryGraph, v))
447448
end
448449
end
449450
end

test/interfaceTests.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ end
161161
@test solverDataDict(v1) == v1.solverDataDict
162162
@test internalId(v1) == v1._internalId
163163

164-
@test softtype(v1) == Symbol(typeof(st1))
165-
@test softtype(v2) == Symbol(typeof(st2))
164+
@test softtype(v1) == st1
165+
@test softtype(v2) == st2
166166
@test getSofttype(v1) == st1
167167

168168
@test label(f1) == f1.label
@@ -446,7 +446,8 @@ end
446446
if field != :softtypename
447447
@test getfield(getVariable(dfg, v), field) == getfield(getVariable(summaryGraph, v), field)
448448
else
449-
@test softtype(getVariable(dfg, v)) == softtype(getVariable(summaryGraph, v))
449+
# Special case to check the symbol softtype is equal to the full softtype.
450+
@test Symbol(typeof(softtype(getVariable(dfg, v)))) == softtype(getVariable(summaryGraph, v))
450451
end
451452
end
452453
end

0 commit comments

Comments
 (0)