Skip to content

JSON: PIDLOOP becomes String on reloading and also not save MAXOUTPUT and MINOUTPUT. #2743

@HaullyGames

Description

@HaullyGames

Serialization mangles the type of a PIDLOOP.
Upon reloading back in it becomes just a vanilla string who's value happens to be the ToString dump of the PIDLOOP, but is not behaving like a PIDLOOP.

It also is not saving the MAXOUTPUT and MINOUTPUT.

Sample:
test.ks

local pidsample is lexicon("mypid",pidloop(1,0.1,0.5, 50, -50)).
set pidsample["mypid"]:SETPOINT TO 100.
print "Before Serialization:".
print "pidsample[0] type: " + pidsample["mypid"]:typename.
print "pidsample[0] value: " + pidsample["mypid"].
writejson(pidsample, "example.json").

local read_lexicon is readjson("example.json").
print "After Serialization:".
print "type of read_lexicon[""mypid""] type: " + read_lexicon["mypid"]:typename.
print "type of read_lexicon[""mypid""] value: " + read_lexicon["mypid"].
Before Serialization:
pidsample[0] type: PIDLoop
pidsample[0] value: PIDLoop(Kp:1, Ki:0.1, Kd:0.5, Setpoint:100, Error:0, Output:0)
After Serialization:
type of read_lexicon[""mypid""] type: String
type of read_lexicon[""mypid""] value: PIDLoop(Kp:1, Ki:0.1, Kd:0.5, Setpoint:100, Error:0, Output:0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions