rwl / PyCIM

Python implementation of the Common Information Model.
http://rwl.github.io/PyCIM/api/
MIT License
77 stars 35 forks source link

Code generation flow #26

Open stv0g opened 7 years ago

stv0g commented 7 years ago

Dear Mr. Lincoln,

We are currently considering to use your PyCIM project to perform load flow analysis with PYPOWER / PyPSA of CIM models.

However, we face a little problem. Our CIM models are based on the latest version 16 of the CIM standard.

In section 6.2.6 of the book “The Common Information Model CIM” by Mathiuas Uslar, the code generation flow used for PyCIM is described.

Could you provide us some details about this flow? In particular, the JET templates for Enerate are missing?

Thank you very much

stv0g commented 7 years ago

My current understanding of the workflow looks like this:

+------------+           +---------+            +---------+            +--------+
| EA+Project |\  +---->  | CIMTool |  +---->    | Enerate |  +----->  /| Python |
| CIM16 UML  |/          +---------+            +---------+           \|  Code  |
+------------+    XMI                  Ecore                   Code    +--------+
                 Export               Export         ^      Generation
                                                     |
                                                     |
                                                     |
                         +-----------------+         |
                         |  Java Emitter   |\   +----+
                         | Templates (JET) |/
                         +-----------------+     
rwl commented 7 years ago

The ECore models are generated using a modified version of CIMTool:

https://github.com/rwl/CIMTool

The IEC61968 and IEC62325 packages would be deleted in Enterprise Architect and the remaining packages exported according to the instructions here:

http://wiki.cimtool.org/Using_CIMTool_with_Enterprise_Architect.html

ea_export

The code is then generated using a project called Enerate:

http://rwl.github.io/enerate/ https://github.com/rwl/enerate

It takes an ECore model and generates code using JET templates:

www.eclipse.org/emft/projects/jet/

You have to add an annotation to the base package in the ECore model so the code generator knows where to start. Here are some of my old projects that include ECore models that once worked

enerate.zip

I am thinking of marking PyCIM as deprecated. It is simpler to just read the RDF/XML into a DOM tree and use XPath to extract the data as required. Here is a Python 3 script that demonstrates how to extract the lat/lng coordinates from a snippet of a GeographicalLocation model:

https://gist.github.com/rwl/396e35aa41919714b0a1