Ecore functionality in pyESDL
As described in Technical foundation, pyESDL and ESDL are build upon ECore. This offers some extra functionality that is usually not available in other data structure libraries.
Tips & Tricks
The ESDL ECore model describes the classes that are available in the ESDL language. Classes, such
as esdl.GenericProdcuer are the specification of the objects present in the language,
while objects are the instantiation of the classes at runtime (gp = esdl.GenericProducer()).
All Ecore related methods/attributes start with the letter ‘e’.
Code |
Explanation |
|---|---|
|
Refers to the Class it belongs to (name, references, attributes). Both references and attributes are called features in Ecore terminology |
|
Lists all objects contained in an object in ESDL. When you use the energySystem object here, it will iterate over all objects in the ESDL. It returns an iterator. |
|
Returns the container this object belongs to, e.g. its parent. |
|
Gets the value of the attribute (same as |
|
Sets the value of the attribute (same as |
|
Checks if the attribute is set in the model (otherwise it will return the default value) |
As shown above, each runtime object has a reference to its EClass. To get the name of the class of an ESDL object you can do the following:
import esdl
gp = esdl.GenericProducer()
class_name = gp.eClass.name
print(class_name)
>> GenericProducer