sunspec / models

SunSpec Model Definitions
Apache License 2.0
93 stars 52 forks source link

Length-field for repeating blocks #202

Closed FW22 closed 3 years ago

FW22 commented 3 years ago

We are facing similar problems as #198 with calculating the size of a repeating block. The size depends on several parameters:

The calculation logic is model specific and takes several requests per model.

Is this intended or am I missing something? Would it be possible to add a mandatory length-field right in front of a repeating block? Similar to length-field on model level?

bobfox commented 3 years ago

In general, the processing for supporting the variable group count in a point is more complicated but allows for better customization by implementers. The fixed 20 point curve model of the past was difficult and the ability to support more groups and nested groups provides for better information models.

There are two basic types of users, those that are looking for specific information and those that are processing models generically and must be able to process them all. Most clients such as gateways and EMS fall into the first category. Tools such as the SunSpec Dashboard fall into the second.

Those that are looking for specific information must already understand what each point in the model is and where to find it. As you point out, if a model contains points that are groups count, it is necessary to read the group count points to know where everything is. This can be accomplished in one initial read of the top-level points in the model during initialization. Once you have that information, a few calculations gives you the model layout. I am not sure additional length fields will make model discovery any more efficient. It really depends the amount of information you are reading during the initialization phase.

It does make life more complicated for the second type of client that is processing models generically like pysunspec2 and the Dashboard. It is the same process, but the model definition must be used to figure out if the model contains any group count points and where they are. For models with a length greater than will fit in a single read, this analysis has to be done to get all the model content without potentially violating the point boundary restriction as we were previously doing during discovery. I think this type of client is much less common than the first and we will publish more information on this to make sure it is completely understood.

I am probably not telling you anything you don't already know but if there is something I am missing here, please let me know.

FW22 commented 3 years ago

Bob, thank you for clarifying this. I think we can close this issue.