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

Add profile class and writer to cpp #41

Merged

Conversation

tom-hg57
Copy link
Collaborator

@tom-hg57 tom-hg57 commented Oct 27, 2024

Only changes for cpp:

  • Improve generated classes: add rdfid to BaseClass
  • Add generation of CGMESProfile class, add profile URIs and cim namespace
  • Add generation of getter functions (this will be used by CIM writer to export CIM data into several files based on CGMES profiles)

@chicco785
Copy link
Collaborator

@tom-hg57 I see many PRs open with several deep changes, some may even be conflicting, this makes a bit complicate for us to contribute, can you update us a bit?

fyi @HUG0-D

@tom-hg57
Copy link
Collaborator Author

@tom-hg57 I see many PRs open with several deep changes, some may even be conflicting, this makes a bit complicate for us to contribute, can you update us a bit?

Most of the changes are fixes for class or attribute types in the generated code plus generation of profile class.

Furtermore I try to minimize the interface between cimgen.py and lang_pack.py. Ideally there should be only 3 called functions:

  • setup
  • run_template for each class
  • resolve_headers

The call to set_float_classes and set_enum_classes are now not needed anymore. I hope to get rid of the confusing calls to class_details["langPack"].base["base_class"] and class_details["langPack"].base"class_location", too.

@chicco785
Copy link
Collaborator

@tom-hg57 I see many PRs open with several deep changes, some may even be conflicting, this makes a bit complicate for us to contribute, can you update us a bit?

Most of the changes are fixes for class or attribute types in the generated code plus generation of profile class.

Furtermore I try to minimize the interface between cimgen.py and lang_pack.py. Ideally there should be only 3 called functions:

  • setup
  • run_template for each class
  • resolve_headers

The call to set_float_classes and set_enum_classes are now not needed anymore. I hope to get rid of the confusing calls to class_details["langPack"].base["base_class"] and class_details["langPack"].base"class_location", too.

ok, when do you think this will be merged, so that @HUG0-D can rebase his PRs on top?
for modern python we would like to:

  • model Float, String, ect, as instance of a class Primitive and similarly, derived datatypes as instances of a class CIMDatatype (cf. Primitives, enum and CIM_datatype #39)
  • use them to annotate attributes data types as part of json_schema_extra annotation
  • leverage the above (and @HUG0-D is working already on a prototype) to use self reflection to generated RDF out of python dataclass instances.
  • next work on a reader that builds python dataclass instances by parsing rdf files.

we think reflection is a more flexible approach with dataclasses because we can easily create serialisers and parsers without needs of templates and similar things (this should work also for JSON-LD, for example).

what do you think? we are happy to have a call next week if you think the approach is interesting :)

@tom-hg57
Copy link
Collaborator Author

tom-hg57 commented Oct 31, 2024

ok, when do you think this will be merged,

I'm not maintainer of the cimgen project.

we think reflection is a more flexible approach with dataclasses because we can easily create serialisers and parsers without needs of templates and similar things (this should work also for JSON-LD, for example).

If there is a better solution, I can remove the modernpython writer (including is_used..is_primitive_attribute in modernpython\templates\cimpy_class_template.mustache if not needed). I'm working currently more with cpp and java. I use the python stuff only for tests.

Your function is_a_cim_datatype seems useful for cpp/java, too. It could make the detection of float classes easier.

BTW: Do you think CIMDatatype is always only used as float, with fixed multiplier and unit? Like:
<cim:BaseVoltage.nominalVoltage>110.0</cim:BaseVoltage.nominalVoltage>

Or should we be prepared to parse data with value, multiplier and unit, too:
<cim:BaseVoltage.nominalVoltage.value>110.0</cim:BaseVoltage.nominalVoltage.value>
<cim:BaseVoltage.nominalVoltage.multiplier rdf:resource="http://iec.ch/TC57/2008/CIM-schema-12#UnitMultiplier.k" />
<cim:BaseVoltage.nominalVoltage.unit rdf:resource="http://iec.ch/TC57/2008/CIM-schema-12#UnitSymbol.V" />

This example is from an older CIM file. But would it be valid to use value, multiplier and unit with CGMES 2.4.15/3.0.0?

@tom-hg57 tom-hg57 force-pushed the add-profile-class-and-writer-to-cpp branch from fdc2279 to ee3b6a1 Compare October 31, 2024 02:32
@tom-hg57 tom-hg57 marked this pull request as draft November 16, 2024 14:39
@tom-hg57 tom-hg57 force-pushed the add-profile-class-and-writer-to-cpp branch from ee3b6a1 to 17986d1 Compare November 24, 2024 00:14
…writer to export CIM data into several files based on CGMES profiles)

Signed-off-by: Thomas Günther <[email protected]>
@tom-hg57 tom-hg57 force-pushed the add-profile-class-and-writer-to-cpp branch from 17986d1 to 2ead869 Compare December 17, 2024 18:38
@tom-hg57 tom-hg57 marked this pull request as ready for review December 17, 2024 18:42
@tom-hg57 tom-hg57 requested a review from m-mirz December 17, 2024 18:42
@tom-hg57 tom-hg57 mentioned this pull request Dec 24, 2024
@m-mirz m-mirz merged commit 38d5b98 into sogno-platform:master Dec 26, 2024
14 checks passed
@tom-hg57 tom-hg57 deleted the add-profile-class-and-writer-to-cpp branch December 26, 2024 22:35
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

Successfully merging this pull request may close these issues.

3 participants