Mr-Markus / ZigbeeNet

A .NET Standard library for working with ZigBee
Eclipse Public License 1.0
131 stars 47 forks source link

Code generator for cluster classes and commands #31

Closed Mr-Markus closed 5 years ago

Mr-Markus commented 5 years ago

There are many clusters and commands in the ZigBee standard which have all the same structure and methods. So it should be possible to create them by a code generator and a ressource file.

As an existing resource file it could be used this file from zsmartsystems

The generated code should be outputted here: ZigbeeNet/ZigBeeNet/ZCL/Clusters/

At the moment there are already some clusters which were written by hand, but they can be overwritten with generated code.

It would be important that the documentation will be generated as XML comments, too.

nicolaiw commented 5 years ago

The generatet clusters seems to be fine now (except the generatet comments). The command classes needs further work (getter/setter to C# properties).

nicolaiw commented 5 years ago

@Mr-Markus could you please have a look at the type mapping ?

https://github.com/Mr-Markus/ZigbeeNet/blob/master/src/ZigBeeNet/ZCL/Protocol/ZclDataType.cs#L93

https://github.com/Mr-Markus/ZigbeeNet/blob/master/src/ZigBeeNet/Serialization/DefaultDeserializer.cs#L56

https://github.com/Mr-Markus/ZigbeeNet/blob/master/src/ZigBeeNet.CodeGenerator/Zcl/ZclDataType.cs#L38

Thx

Mr-Markus commented 5 years ago

@nicolaiw Done with commit 8fc14d2cd677f36693e7cb9a5664fc779ae081a5

As next I would check if code generation works with fixed code

nicolaiw commented 5 years ago

@Mr-Markus Thx

nicolaiw commented 5 years ago

As a next step I will try to generate Attribute and Field Enums.

Mr-Markus commented 5 years ago

I added a appsettings.json file with outputPath setting in bd2880d81aa2a389a498aed5fd075975d8588e16 and added generated classes to library in d036bb69be65a2af41e5b4cc2fd157565320e765 and 04ba3cb6b988d710e2c223035b9582aca62602b1

nicolaiw commented 5 years ago

@Mr-Markus maybe you could run the generator again, include the new generated Enums and try to recompile.

Mr-Markus commented 5 years ago

Thx @nicolaiw Great job 👌