Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ToJSON errors when called on elements #102

Closed
John-Boik opened this issue Jun 20, 2024 · 1 comment
Closed

ToJSON errors when called on elements #102

John-Boik opened this issue Jun 20, 2024 · 1 comment

Comments

@John-Boik
Copy link

It appears that the element.ToJSON() function is not working properly, or at least not working as I expect. Apparently, it should be called with an Int64, but this throws a UndefVarError: getstring not defined error.

Here is an example, using the simple DSS file from Issue 101, where the file is saved as filename.dss:

import OpenDSSDirect as DSS
DSS.Basic.AllowEditor(false)
DSS.dss("""
    clear
    redirect "filename.dss"
    """)

DSS.Transformers.First()
1

infil> DSS.Element.Name()
"Transformer.tx1"

infil> DSS.Element.ToJSON()
ERROR: MethodError: no method matching ToJSON()

Closest candidates are:
  ToJSON(::Int64)
   @ OpenDSSDirect ~/.julia/packages/OpenDSSDirect/TOPxW/src/element.jl:41
  ToJSON(::OpenDSSDirect.DSSContext, ::Int64)
   @ OpenDSSDirect ~/.julia/packages/OpenDSSDirect/TOPxW/src/element.jl:38

infil> DSS.Element.ToJSON(0)
ERROR: UndefVarError: `getstring` not defined
Stacktrace:
 [1] ToJSON(dss::OpenDSSDirect.DSSContext, Flags::Int64)
   @ OpenDSSDirect.Element ~/.julia/packages/OpenDSSDirect/TOPxW/src/element.jl:39
 [2] ToJSON(Flags::Int64)
   @ OpenDSSDirect.Element ~/.julia/packages/OpenDSSDirect/TOPxW/src/element.jl:41

The same error occurs with other Int64s, such as ToJSON(1). I suspect it should accept an Int32, rather than Int64. For example, this works: DSS.Circuit.ToJSON(Int32(1)).

@PMeira, thanks for your help and the excellent explanation on Issue 101. I thought I would also create an issue for this ToJSON problem in case you want to include a fix in the upcoming release.

@PMeira PMeira closed this as completed in 92701b3 Oct 30, 2024
@PMeira
Copy link
Member

PMeira commented Oct 30, 2024

Sorry, @John-Boik, forgot to push the commit earlier. Fixed and added tests for that function for v0.9.9. We're planning an engine update for next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants