This project contains SunSpec object models converted to annotated Kotlin objects. Software wishing to interact with the SunSpec model can then convert Modbus messages into instances of these models.
Model classes include an annotation indicating the model number, its expected length, and its name, for example:
@SunSpecModel(id=1, len=66, name="common")
class Model_1 {
// ...
}
Individual fields within each model are annotated with additional descriptive information, indicating the name, description, type, and where in the register map (within this model) the value can be found:
@SunSpecPoint(id="Mn", label="Manufacturer", offset=0, len=16, type="string",
description="Well known value registered with SunSpec for compliance",
notes="Well known value registered with SunSpec for compliance")
var Mn: String? = null
Note that fields are given names that match the id attribute within the model XML. Unforunately, model classes themselves cannot be named this way, because many models have the same 'name' in their corresponding XML (for example, models 111, 112, and 113 all have the name inverter).
Here are the semantics of the definition content:
A group can contain a set of 0 or more points and a set of 0 or more groups. Points come before groups in any context where there is a concept of order such as Modbus.
Models have a single top-level group that represents the model content.
All models start with an ID point and L point in the top-level group. The L point contains the remaining length of the model in any context where length has meaning such as Modbus.
The group ‘count’ attribute indicates if the group repeats. The following cases apply for repeating group count:
If the value of count is 0, it is a legacy model where the number of repeating instances of the group are calculated by using this formula: ( L – points length)/group length. In the legacy case, the group can only contain points and no groups.
If the value of count is a number > 0, there are always that many instances of the group in a model instance.
If the value of count is a point name in the top-level model group, the number of group instances in the model instance is contained in the point for that model instance.