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

JSON models do not conform with current specifications #62

Open
sgvolt opened this issue Mar 30, 2020 · 13 comments
Open

JSON models do not conform with current specifications #62

sgvolt opened this issue Mar 30, 2020 · 13 comments

Comments

@sgvolt
Copy link

sgvolt commented Mar 30, 2020

I'm currently implementing a parser for the JSON models according to the information model specification and found some issues when using the current models as a test case, because the currently provided models do not fully conform to the (admittedly also not quite yet consistent or final) information model specification:

  • Models currently lack the (qua specification) required "label" field
  • Models are not declared as "model" explicitly (I personally wouldn't object to that, honestly, but the specification disagrees)
  • For parsers' sake, model "id" fields should not be purely numeric types (e.g. 1, 102, ...), given that the specification allows "alphanumeric characters and the underscore character", so even if only numeric IDs should be used for model IDs, they should still be stringly-typed (i.e. "1", "102", ...).
  • Points' "access" fields have lowercase values (in contrast to the specification's uppercase "R" and "RW" definitions)
  • Points' "mandatory" fields currently hold bool-ish strings ("true", "false") instead of the specification's "M" or "O" strings.
  • Groups are missing their "type" attribute.
  • some scaling factors are ascribed type "sunssf" instead of the specification's "sf"
  • Points' "size" attribute is encoded as "len"
@bobfox
Copy link
Contributor

bobfox commented Apr 17, 2020

Thanks for the detailed comments. As you can see it was a first approximation but needs some work. We are working through it now and should have an update shortly.

@altendky
Copy link
Contributor

Is there any schema file that defines the form of the JSON?

@bobfox
Copy link
Contributor

bobfox commented Apr 17, 2020

Currently, there is not. We are certainly open to seeing if there is a productive way to make use of one. We would like to get pysunpec to the point of being a good validator of information models in all of the encodings.

@altendky
Copy link
Contributor

JSON Schema with a check script (there's https://github.com/Julian/jsonschema) and Travis turned on would go a long way. Or if you won't be clicking the button to enable Travis then we could put together a quick GitHub Actions for you.

shelcrow pushed a commit that referenced this issue Apr 27, 2020
… working group decisions (#62) (#69)

* Partially fix up units in 126

* Update license

* Remove duplicate 'RESERVED' symbol IDs (#67) (#68)

* Corrected some smdx translation issues (#62)

Co-authored-by: Kyle Altendorf <sda@fstab.net>
@bobfox
Copy link
Contributor

bobfox commented Apr 29, 2020

The latest pull request (#74) has an initial JSON schema to take a look at.

shelcrow pushed a commit that referenced this issue Apr 29, 2020
* Corrected some smdx translation issues (#62)

* Corrected issues in models 701-705 and added information model schema.

Corrected issues outlined in #74 and added JSON schema for information models.

All:
- Add static attribute to applicable points
- Add 'group' or 'sync' type to all groups

701:

- Add static designation to scale factors

702:
- Add reactive susceptance point and scale factor
- Add supported control modes
- Add intentional island categories (need bit values)

703:
- Increase frequent point size to 32-bits

704:
- Some points should be changed to enum instead of uint16
- Some enum32 can be changed to enum16
- Remove Ctl group level and accompanying counts
- Remove duplicate DERCtlAC.Ctl.PFWInj.Pt
- Add IEEE_1547 to enumeration for reactive power priority
- Add PF to enumeration for reactive power priority
- Add other to enumeration for reactive power priority
- Add RGra for Ramp gradiant with enum for power and current based ramping

705:
  Update power priority enum with additional options
@nielsbasjes
Copy link
Contributor

nielsbasjes commented Jun 24, 2020

I'm wondering:
Why have you chosen to duplicate the specs into json files and manually maintain those?
I would have gone for a fully automated conversion between the formats instead.

In all of my projects I prefer having a single source of truth and an automated process converting between the various formats.

@wz2b
Copy link

wz2b commented Nov 6, 2020

You will continue to support the XML models as well, right? JSON is just an alternative? I have software written around the XML schema, I would prefer to not rewrite that.

@bobfox
Copy link
Contributor

bobfox commented Nov 6, 2020

Sorry for the delay in response. We have refining the tools and process to try to make it as automated as possible. We now have a feature in the SVP Dashboard to convert from xml to spreadsheet, json to spreadsheet, spreadsheet to json, and spreadsheet to spreadsheet. We consider Excel (or application with .xlsx support) to be the information model editor. json files should not be edited by hand so that we can be provide a uniform json encoding. Once models are created/updated in the spreadsheet that can be cleaned up by generating a new spreadsheet from that one. Once the spreadsheet version is correct, the json version can be generated from that.
We have extended the modelling capabilities as specified in the SunSpec Device Information Model Specification which is in the new technology section on the sunspec website. In general, the intention is to deprecate xml and only use json going forward. The new modelling features are only supported in the json encoding. I am sorry for the inconvenience this may cause some in the short term but json was the more popular choice and we would like to have a single official definition,
We are trying to correct both process and content issues with the model definitions, so all comments and questions are really helpful. We have been focused on finalizing models 701-713 which provide DER support for IEEE 1557-2018 and putting processes and tools in place to help support the effort.
We are currently doing an update to the spec so the json schema should be used for model definition information.

@wz2b
Copy link

wz2b commented Nov 6, 2020

In general, the intention is to deprecate xml and only use json going forward. The new modelling features are only supported in the json encoding. I am sorry for the inconvenience this may cause some in the short term but json was the more popular choice and we would like to have a single official definition,

I agree one format should be authoritative and everything else derived from that. It sounds like this decision has already been made, so my comment here may very well be moot - which is okay, I'll live with whatever you decide.

It is my experience that JSON schema is not as robust, and that validation tools (including editors) aren't as good. The XSD you developed is very high quality. If it were me, I would consider the XML to be authoritative, and derive everything else from that - including writing one or two .XSLTs to go back and forth between the different formats. I say that knowing that, while I love xsl transformation, it's basically greek to a lot of people.

I currently use Xpaths to take all you .XML files and build Kotlin objects. I'm making this public, so you can see what I'm doing if you're interested. I don't mind at some point converting that to use the JSON instead of the XML ... it's just work (it took me a few days to get the code generator working).

One piece of feedback I would really like to add (but it's off topic here) is giving models unique names. 111, 112, 113 are all named "inverter." They have different labels, but I can't use the labels to name objects, so I've created a bunch of objects named Model_111, Model_112, etc. That is not especially convenient for users of this library.

@bobfox
Copy link
Contributor

bobfox commented Nov 11, 2020

I agree that XML is a more robust solution for model definition and validation. The motivation for moving to JSON involved multiple factors. The SunSpec model definitions are fairly simple system that JSON can handle. Most companies have more developers that understand JSON than XML so it is preferred by many. We will be developing a simple HTTP based web service interface for SunSpec data exchange once we can all the 1547 content completed and frozen. It will be specified using JSON. We have migrated our file based sample devices to JSON encoding and they are easier to work with as well. So these are some of the factors that influenced the decision. At the end of the day, it seemed better to use one encoding strategy for all of the use cases.
I also agree that the models should have unique names. The original naming was rather haphazard for which I am to blame. There was a rational for the choices but it seems that it should be revisited. In general, the models are frozen, but I think this may be something that makes sense to update if there are no objections.

@wz2b
Copy link

wz2b commented Nov 12, 2020

No worries, it's obvious you've thought this through and made careful decisions. I'm on board. The next thing I'm wondering is: any thought been given to a set of COAP models bindings as well? That's going to be my next task - communicating with SunSpec compliant DERs but over the AMI network using COAP.

@andig
Copy link

andig commented Oct 21, 2022

To add to the initial list:

  • some scale factors are -1 instead of point name

@andig
Copy link

andig commented Oct 23, 2022

@bobfox I'm currently trying to migrate https://github.com/andig/gosunspec from smdx to json. It is painful. Even two years later now, the JSON models still appear inconsistent. I'll try to post a diff of the prior/after results to give an indication of the amount of differences. Not necessarily every difference is an issue with the newer JSON definitions, but the diff will show that the differences are unpredictable instead of following a clear forward-improvement pattern.

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

6 participants