PySimultan 0.1.53__py3-none-any.whl → 0.2__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. PySimultan-0.2.dist-info/LICENSE.txt +17 -0
  2. PySimultan-0.2.dist-info/METADATA +36 -0
  3. PySimultan-0.2.dist-info/RECORD +82 -0
  4. {PySimultan-0.1.53.dist-info → PySimultan-0.2.dist-info}/WHEEL +1 -1
  5. PySimultan-0.2.dist-info/top_level.txt +1 -0
  6. {PySimultan → PySimultan2}/__init__.py +11 -6
  7. PySimultan2/config.py +52 -0
  8. PySimultan2/data_model.py +713 -0
  9. PySimultan2/default_types.py +507 -0
  10. PySimultan2/files.py +371 -0
  11. PySimultan2/geometry/__init__.py +4 -0
  12. PySimultan2/geometry/geometry_base.py +654 -0
  13. PySimultan2/geometry/utils.py +181 -0
  14. PySimultan2/multi_values.py +277 -0
  15. PySimultan2/object_mapper.py +200 -0
  16. PySimultan2/resources/AssimpNet.dll +0 -0
  17. PySimultan2/resources/AvalonDock.dll +0 -0
  18. PySimultan2/resources/BruTile.dll +0 -0
  19. PySimultan2/resources/ClosedXML.dll +0 -0
  20. PySimultan2/resources/ComponentBuilder.dll +0 -0
  21. PySimultan/resources/ComponentBuilder.exe.config → PySimultan2/resources/ComponentBuilder.dll.config +6 -2
  22. PySimultan2/resources/ComponentBuilder.runtimeconfig.json +18 -0
  23. {PySimultan → PySimultan2}/resources/ComponentBuilder.xml +11877 -6754
  24. PySimultan2/resources/ControlzEx.dll +0 -0
  25. PySimultan2/resources/Cyotek.Drawing.BitmapFont.dll +0 -0
  26. PySimultan2/resources/DocumentFormat.OpenXml.dll +0 -0
  27. PySimultan2/resources/ExcelNumberFormat.dll +0 -0
  28. PySimultan2/resources/Fluent.dll +0 -0
  29. PySimultan2/resources/GeometryViewer.dll +0 -0
  30. {PySimultan → PySimultan2}/resources/GeometryViewer.xml +2201 -1155
  31. PySimultan2/resources/HelixToolkit.Core.Wpf.dll +0 -0
  32. PySimultan2/resources/HelixToolkit.SharpDX.Core.Wpf.dll +0 -0
  33. PySimultan2/resources/HelixToolkit.SharpDX.Core.dll +0 -0
  34. PySimultan2/resources/HelixToolkit.dll +0 -0
  35. PySimultan2/resources/MathNet.Numerics.dll +0 -0
  36. PySimultan2/resources/Microsoft.AspNetCore.Authorization.dll +0 -0
  37. PySimultan2/resources/Microsoft.AspNetCore.Metadata.dll +0 -0
  38. PySimultan2/resources/Microsoft.Extensions.DependencyInjection.Abstractions.dll +0 -0
  39. PySimultan2/resources/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
  40. PySimultan2/resources/Microsoft.Extensions.Options.dll +0 -0
  41. PySimultan2/resources/Microsoft.Extensions.Primitives.dll +0 -0
  42. PySimultan2/resources/Microsoft.WindowsAPICodePack.Shell.dll +0 -0
  43. PySimultan2/resources/Microsoft.WindowsAPICodePack.dll +0 -0
  44. PySimultan2/resources/Microsoft.Xaml.Behaviors.dll +0 -0
  45. PySimultan2/resources/Newtonsoft.Json.Bson.dll +0 -0
  46. PySimultan2/resources/Newtonsoft.Json.dll +0 -0
  47. PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll +0 -0
  48. PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll +0 -0
  49. PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll.config +15 -0
  50. PySimultan2/resources/SIMULTAN.Lang.dll +0 -0
  51. {PySimultan → PySimultan2}/resources/SIMULTAN.Lang.xml +5282 -3252
  52. PySimultan2/resources/SIMULTAN.Plugins.dll +0 -0
  53. {PySimultan → PySimultan2}/resources/SIMULTAN.Plugins.xml +110 -0
  54. PySimultan2/resources/SIMULTAN.UI.dll +0 -0
  55. {PySimultan → PySimultan2}/resources/SIMULTAN.UI.xml +10483 -4937
  56. PySimultan2/resources/SIMULTAN.dll +0 -0
  57. PySimultan2/resources/SIMULTAN.xml +34122 -0
  58. PySimultan2/resources/SharpDX.D3DCompiler.dll +0 -0
  59. PySimultan2/resources/SharpDX.DXGI.dll +0 -0
  60. PySimultan2/resources/SharpDX.Direct2D1.dll +0 -0
  61. PySimultan2/resources/SharpDX.Direct3D11.dll +0 -0
  62. PySimultan2/resources/SharpDX.Direct3D9.dll +0 -0
  63. {PySimultan → PySimultan2}/resources/SharpDX.Mathematics.dll +0 -0
  64. PySimultan2/resources/SharpDX.dll +0 -0
  65. {PySimultan → PySimultan2}/resources/SitePlanner.dll +0 -0
  66. {PySimultan → PySimultan2}/resources/SitePlanner.xml +959 -1110
  67. PySimultan2/resources/Sprache.dll +0 -0
  68. PySimultan2/resources/System.Data.OleDb.dll +0 -0
  69. PySimultan2/resources/System.Net.Http.Formatting.dll +0 -0
  70. PySimultan2/resources/XAMLMarkupExtensions.dll +0 -0
  71. PySimultan2/resources/assimp.dll +0 -0
  72. {PySimultan → PySimultan2}/resources/defaultsettings.xml +0 -0
  73. PySimultan2/simultan_object.py +366 -0
  74. PySimultan2/taxonomy_maps.py +169 -0
  75. PySimultan2/utils.py +1383 -0
  76. PySimultan/config.py +0 -57
  77. PySimultan/data_model.py +0 -376
  78. PySimultan/default_types.py +0 -1771
  79. PySimultan/geo_default_types.py +0 -763
  80. PySimultan/geometry.py +0 -309
  81. PySimultan/resources/AssimpNet.dll +0 -0
  82. PySimultan/resources/AssimpNet.xml +0 -12074
  83. PySimultan/resources/BruTile.dll +0 -0
  84. PySimultan/resources/BruTile.xml +0 -1845
  85. PySimultan/resources/ControlzEx.dll +0 -0
  86. PySimultan/resources/Cyotek.Drawing.BitmapFont.dll +0 -0
  87. PySimultan/resources/DXFImportExport.dll +0 -0
  88. PySimultan/resources/DotSpatial.Projections.xml +0 -5879
  89. PySimultan/resources/EXCELImportExport.dll +0 -0
  90. PySimultan/resources/Fluent.dll +0 -0
  91. PySimultan/resources/Fluent.xml +0 -9103
  92. PySimultan/resources/GeoJSON.Net.dll +0 -0
  93. PySimultan/resources/GeometryViewer.Data.dll +0 -0
  94. PySimultan/resources/GeometryViewer.Data.xml +0 -4443
  95. PySimultan/resources/GeometryViewer.Shared.dll +0 -0
  96. PySimultan/resources/GeometryViewer.Shared.xml +0 -588
  97. PySimultan/resources/GeometryViewer.dll +0 -0
  98. PySimultan/resources/HelixToolkit.Wpf.SharpDX.dll +0 -0
  99. PySimultan/resources/HelixToolkit.Wpf.SharpDX.xml +0 -43219
  100. PySimultan/resources/HelixToolkit.Wpf.dll +0 -0
  101. PySimultan/resources/HelixToolkit.Wpf.xml +0 -22363
  102. PySimultan/resources/HelixToolkit.dll +0 -0
  103. PySimultan/resources/HelixToolkit.xml +0 -144
  104. PySimultan/resources/ImportLog_SMART_CAMPUS_TU_WIEN_BIBLIOTHEK_20210305_ZONENMODELL_23_11_2021-06_54_54.txt +0 -1
  105. PySimultan/resources/LibGit2Sharp.dll +0 -0
  106. PySimultan/resources/LibGit2Sharp.dll.config +0 -4
  107. PySimultan/resources/LibGit2Sharp.xml +0 -13770
  108. PySimultan/resources/MathNet.Numerics.dll +0 -0
  109. PySimultan/resources/MathNet.Numerics.xml +0 -57152
  110. PySimultan/resources/Microsoft.WindowsAPICodePack.Shell.dll +0 -0
  111. PySimultan/resources/Microsoft.WindowsAPICodePack.Shell.xml +0 -25496
  112. PySimultan/resources/Microsoft.WindowsAPICodePack.dll +0 -0
  113. PySimultan/resources/Microsoft.WindowsAPICodePack.xml +0 -2934
  114. PySimultan/resources/Newtonsoft.Json.dll +0 -0
  115. PySimultan/resources/Newtonsoft.Json.xml +0 -11305
  116. PySimultan/resources/ParameterStructure.dll +0 -0
  117. PySimultan/resources/ParameterStructure.xml +0 -10750
  118. PySimultan/resources/SIMULTAN.AutoUpdate.Client.dll +0 -0
  119. PySimultan/resources/SIMULTAN.DataExchange.dll +0 -0
  120. PySimultan/resources/SIMULTAN.Lang.dll +0 -0
  121. PySimultan/resources/SIMULTAN.Legacy.dll +0 -0
  122. PySimultan/resources/SIMULTAN.Legacy.xml +0 -254
  123. PySimultan/resources/SIMULTAN.Plugins.dll +0 -0
  124. PySimultan/resources/SIMULTAN.Project.dll +0 -0
  125. PySimultan/resources/SIMULTAN.Project.dll.config +0 -11
  126. PySimultan/resources/SIMULTAN.UI.dll +0 -0
  127. PySimultan/resources/SIMULTAN.Util.dll +0 -0
  128. PySimultan/resources/SIMULTAN.Util.xml +0 -3430
  129. PySimultan/resources/SharpDX.D3DCompiler.dll +0 -0
  130. PySimultan/resources/SharpDX.D3DCompiler.xml +0 -5897
  131. PySimultan/resources/SharpDX.DXGI.dll +0 -0
  132. PySimultan/resources/SharpDX.DXGI.xml +0 -8737
  133. PySimultan/resources/SharpDX.Direct2D1.dll +0 -0
  134. PySimultan/resources/SharpDX.Direct2D1.xml +0 -46691
  135. PySimultan/resources/SharpDX.Direct3D11.dll +0 -0
  136. PySimultan/resources/SharpDX.Direct3D11.xml +0 -31826
  137. PySimultan/resources/SharpDX.Direct3D9.dll +0 -0
  138. PySimultan/resources/SharpDX.Direct3D9.xml +0 -36489
  139. PySimultan/resources/SharpDX.Mathematics.xml +0 -16449
  140. PySimultan/resources/SharpDX.dll +0 -0
  141. PySimultan/resources/Sprache.dll +0 -0
  142. PySimultan/resources/Sprache.xml +0 -1199
  143. PySimultan/resources/System.Net.Http.Formatting.dll +0 -0
  144. PySimultan/resources/System.Net.Http.Formatting.xml +0 -2094
  145. PySimultan/resources/System.Windows.Interactivity.dll +0 -0
  146. PySimultan/resources/TalkGit.dll +0 -0
  147. PySimultan/resources/TalkGit.dll.config +0 -11
  148. PySimultan/resources/WebServiceConnector.dll +0 -0
  149. PySimultan/resources/WebServiceConnector.dll.config +0 -11
  150. PySimultan/resources/XAMLMarkupExtensions.dll +0 -0
  151. PySimultan/resources/XAMLMarkupExtensions.xml +0 -862
  152. PySimultan/resources/Xceed.Wpf.AvalonDock.Themes.Aero.dll +0 -0
  153. PySimultan/resources/Xceed.Wpf.AvalonDock.Themes.Metro.dll +0 -0
  154. PySimultan/resources/Xceed.Wpf.AvalonDock.Themes.VS2010.dll +0 -0
  155. PySimultan/resources/Xceed.Wpf.AvalonDock.dll +0 -0
  156. PySimultan/resources/Xceed.Wpf.Toolkit.dll +0 -0
  157. PySimultan/resources/assimp.dll +0 -0
  158. PySimultan/resources/schema.yaml +0 -13
  159. PySimultan/resources/simultan_exception_07_10_2021-08_34_24.txt +0 -17
  160. PySimultan/resources/simultan_exception_07_10_2021-10_13_31.txt +0 -17
  161. PySimultan/resources/simultan_exception_11_10_2021-19_45_42.txt +0 -17
  162. PySimultan/resources/simultan_exception_22_11_2021-16_41_52.txt +0 -14
  163. PySimultan/resources/simultan_exception_22_11_2021-17_37_40.txt +0 -14
  164. PySimultan/simultan_geometry_utils.py +0 -81
  165. PySimultan/simultan_utils.py +0 -165
  166. PySimultan/slots.py +0 -51
  167. PySimultan/template_tools.py +0 -628
  168. PySimultan/utils.py +0 -298
  169. PySimultan-0.1.53.dist-info/LICENSE +0 -674
  170. PySimultan-0.1.53.dist-info/LICENSE.txt +0 -674
  171. PySimultan-0.1.53.dist-info/METADATA +0 -690
  172. PySimultan-0.1.53.dist-info/RECORD +0 -119
  173. PySimultan-0.1.53.dist-info/entry_points.txt +0 -3
  174. PySimultan-0.1.53.dist-info/top_level.txt +0 -1
  175. PySimultan-0.1.53.dist-info/zip-safe +0 -1
  176. {PySimultan → PySimultan2}/resources/DotSpatial.Projections.dll +0 -0
  177. {PySimultan → PySimultan2}/resources/GeometryViewer.dll.config +0 -0
  178. {PySimultan → PySimultan2}/resources/SIMULTAN.AutoUpdate.Client.dll.config +0 -0
  179. {PySimultan → PySimultan2}/resources/SitePlanner.dll.config +0 -0
  180. {PySimultan → PySimultan2}/resources/Sprache.Calc.dll +0 -0
  181. {PySimultan → PySimultan2}/resources/__init__.py +0 -0
  182. {PySimultan → PySimultan2}/resources/setup.bat +0 -0
@@ -1,690 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: PySimultan
3
- Version: 0.1.53
4
- Summary: Python Package to import and work with the SIMULTAN Data model
5
- Home-page: https://github.com/bph-tuwien/PySimultan
6
- Author: Max Buehler
7
- License: MIT
8
- Keywords: python
9
- Platform: UNKNOWN
10
- Classifier: Development Status :: 4 - Beta
11
- Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Programming Language :: Python
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3 :: Only
16
- Classifier: Programming Language :: Python :: 3.8
17
- Classifier: Programming Language :: Python :: 3.9
18
- Requires-Python: >=3.7
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE.txt
21
- Requires-Dist: numpy
22
- Requires-Dist: pandas
23
- Requires-Dist: colorlog
24
- Requires-Dist: pythonnet (>=3.0.0a2)
25
- Requires-Dist: ruamel.yaml
26
- Requires-Dist: tqdm
27
- Requires-Dist: yamale
28
-
29
- # PySimultan
30
-
31
- Simultan version: 0.2.147
32
-
33
- Python Package to import and work with the SIMULTAN Data model
34
- [[SIMULTAN REPORT](https://simlab.tuwien.ac.at/wp-content/uploads/2018/03/183101-Endbericht_Simultan.pdf)].
35
-
36
- ### What is it?
37
-
38
- This package tries to provide a simple and seamless integration of SIMULTAN in python.
39
-
40
- With only three lines of code and a template you can import a SIMULTAN-Project:
41
-
42
- ```python
43
- from PySimultan import DataModel, TemplateParser
44
-
45
- template_parser = TemplateParser(template_filepath='my_template.yml')
46
- data_model = DataModel(project_path='my_project.simultan',
47
- user_name='SomeUser',
48
- password='UserPwd')
49
- typed_data = data_model.get_typed_data(template_parser=template_parser)
50
- ```
51
-
52
- You can also integrate SIMULTAN in your existing Project with PySimultan and a few lines of code:
53
-
54
- See [readme_test_5](tests/readme_examples/readme_test_5.py):
55
- ```python
56
- from PySimultan import DataModel, TemplateParser
57
-
58
-
59
- class MyWindow(object):
60
-
61
- def __init__(self, *args, **kwargs):
62
-
63
- pass
64
-
65
- def open(self):
66
- print(f'Window {self.Name} with area {self.Area} m² opened')
67
-
68
-
69
- template_parser = TemplateParser()
70
- template_parser.bases['Window'] = MyWindow
71
- template_parser.create_template_classes()
72
- data_model = DataModel(project_path='test.simultan',
73
- user_name='SomeUser',
74
- password='UserPwd')
75
- typed_data = data_model.get_typed_data(template_parser=template_parser)
76
-
77
- # assuming the fist object in the data-model is of the TYPE 'Window'
78
- typed_data[0].open()
79
- ```
80
-
81
- # Installation
82
-
83
- PySimultan can be installed via pip. To install PySimultan run:
84
-
85
- ```
86
- # PyPI
87
- pip install PySimultan
88
- ```
89
-
90
- ### Background:
91
-
92
- As SIMULTAN is written in C#, the package uses [Python.NET](https://github.com/pythonnet/pythonnet) to import the Simultan libraries.
93
- With Python.NET all functions of the dlls are preserved, and you are able to develop in python without any changes
94
- (except for cases that are .NET specific).
95
-
96
- To make life easier for developers, we have implemented a typing process that imports components
97
- as instances of the type you have defined! Using simple text templates, the 'TYPE' of a
98
- SIMULTAN component is assigned to a class in Python.
99
-
100
- Best explained with an example:
101
-
102
- _A component with the 'TYPE' parameter 'Room' is imported from a project.
103
- With the template a python class `Room` is assigned to the 'TYPE': 'Room'.
104
- The new class `Room` is created when parsing the template. It inherits from:_
105
- * _a default class which wraps the imported object (like `SimultanObject`)_
106
- * _a class created from the template, adding properties for the content._
107
- * _a user defined class defined in the templates 'inherit_from' entry_
108
-
109
-
110
- This way SIMULTAN can be integrated into existing packages with minimal adjustments!
111
-
112
- ### Features:
113
-
114
- * fast: use of lazy loading, caching and parallelization
115
- * variable search depth for references
116
- * minimal dependencies
117
- * easy to integrate
118
-
119
- ### To Do:
120
- * Only read access. Write and save has not been tested yet.
121
- * Calculations not implemented
122
- * Networks not implemented
123
-
124
- Usage
125
- -----
126
-
127
- ### Data model Typing
128
-
129
- Since SIMULTAN is a dynamic data model, the data must first be typed.
130
- To do this, the TYPE parameter is created in a component to be typed and a corresponding value is set.
131
-
132
- _For example, the user creates a component 'Living Room 1 Floor',
133
- which he can identify and assign as a room on the first floor based on the name.
134
- However, for an application it is not clear which data corresponds to what.
135
- Therefore, the data must first be typed. For typing, the parameter 'TYPE' is created in
136
- a component and a corresponding value is set._
137
-
138
- ![](resources/doc/first_type_component.png)
139
-
140
- _In this example the `TYPE` of the component is 'Room' and every application which imports the project
141
- can identify it as of the type 'Room'._
142
-
143
- In Python [readme_test_1](tests/readme_examples/readme_test_1.py):
144
- ```python
145
- from PySimultan import DataModel
146
- data_model = DataModel(project_path='example1.simultan',
147
- user_name='SomeUser',
148
- password='UserPwd')
149
- print(data_model.data.Items)
150
- print(f'Component type: {data_model.data.Items[0].ContainedParameters.Items[1].TextValue}')
151
- ```
152
-
153
- prints a list for the components and the type of the first component:
154
- ```python
155
- [<ParameterStructure.Component.Component object at 0x00000157F77AA7C0>]
156
- Component type: Room
157
- ```
158
-
159
- Now we can import and determine the type of the component
160
-
161
- ### TemplateParser
162
-
163
- We can determine the type of our component, but to do this with a lots
164
- of components and sub-components is getting annoying fast. This is where we
165
- can use the `TemplateParser`.
166
-
167
- The TemplateParser is a class which scans the data model and creates instances of
168
- types, defined in a template.
169
-
170
- We want to load the following components in python:
171
-
172
- ![](resources/doc/example3_simultan.png)
173
-
174
- Therefore, we have to create a template which defines how our class should look like.
175
- Let's look at this template-file [template_example3.yml](tests/readme_examples/resources/template_example3.yml):
176
-
177
- ```yaml
178
- - !Template
179
- template_name: Room
180
- template_id: '1'
181
- inherits_from:
182
- content: [Internal heat gains, Volume, Room Name, Furniture]
183
- documentation: 'Room: defines a Room or a Zone'
184
- units: {Internal heat gains: W, Volume: m³, Room Name: '-', Furniture: '-'}
185
- types: {Internal heat gains: float, Volume: float, Room Name: str}
186
- slots: {Furniture: Element_00}
187
- - !Template
188
- template_name: Table
189
- template_id: '2'
190
- inherits_from:
191
- content: [Number Persons]
192
- documentation: 'Table: defines a table with number of persons'
193
- units: {Number Persons: '-'}
194
- types: {Number Persons: float}
195
- slots: {}
196
- ```
197
-
198
- In this yaml-file is one 'Room'-template which defines how components of the TYPE 'Room' should be handled.
199
- There is a entry called `content` which defines which content for this type is expected. The content in the
200
- SIMULTAN data model can be a Parameter, a sub-component or a linked component. In this example four items in
201
- the SIMULTAN-component are expected: 'Internal heat gains', 'Volume', 'Room Name' and 'Furniture'.
202
-
203
- What the Template parser does is that it checks in the SIMULTAN-Component if there is a TYPE-Parameter defined.
204
- If the TYPE is found, there is a check for each item in the content if a parameter with the name of the content is
205
- defined.
206
-
207
- _For example the first item of the content is 'Internal heat gains'. If a parameter with this name
208
- is found in the component, the property of the generated python-component will return the value of the SIMULTAN-parameter
209
- 'Internal heat gains'._
210
-
211
- If no parameter is found, PySimultan checks if there is a slot defined for the content. Sub-components or
212
- linked components in the SIMULTAN data model have a slot and a slot-extension. With this slot- /extension
213
- PySimultan can determine which component or sub-component is the value of the content.
214
-
215
- _In this example for the content 'Furniture' the slot 'Element_00' is defined. If no Parameter
216
- 'Furniture' is found, PySimultan checks if there is a entry with the slot 'Element' and the slot-extension
217
- '0' in the component and return this instance._
218
-
219
- To load the 'Room' component run [readme_test_3](tests/readme_examples/readme_test_3.py):
220
- ```python
221
- from PySimultan import DataModel, TemplateParser
222
-
223
- # use pkg_resources to load package example files
224
- with pkg_resources.path(readme_examples, 'template_example3.yml') as r_path:
225
- template_file = str(r_path)
226
-
227
- # create and write the templates
228
- create_template(template_file)
229
-
230
- # create the template parser
231
- template_parser = TemplateParser(template_filepath=template_file)
232
-
233
- # load the SIMULTAN project
234
- data_model = DataModel(project_path=project_file,
235
- user_name='SomeUser',
236
- password='UserPwd')
237
-
238
- # create the typed datamodel form the loaded SIMULTAN project and the template_parser
239
- typed_data = data_model.get_typed_data(template_parser=template_parser, create_all=False)
240
- ```
241
-
242
- If we inspect `typed_data` we can see that there is a instance of the type 'Room' with
243
- the attributes we defined in the template. The attribute 'Furniture' is the linked component
244
- with the Slot 'Element' and the slot-extension 0.
245
-
246
- ![](resources/doc/example3_inspect.png)
247
-
248
- We can easily access all content which was defined in the template with python .dot synatx:
249
-
250
- ```python
251
- print(typed_data[0].Furniture)
252
- print(typed_data[0].Volume)
253
-
254
- # Properties with blanks: use getattr
255
- print(getattr(typed_data[0], 'Internal heat gains'))
256
- ```
257
-
258
- ## Templates
259
-
260
- ### File Description
261
-
262
- Template-files are yaml files which define one or more templates. A template has the following keywords:
263
-
264
- * **template_name**:
265
- The name of the template; [str]; This name is also used for the 'TYPE' value of a SIMULTAN-component and
266
- the class name in python: _Example: 'TestTemplate'_
267
-
268
-
269
- * **template_id**:
270
- ID of the template; [int]; There is currently no functionality for the ID of the template; _Example: 1_
271
-
272
-
273
- * **inherits_from**:
274
- parent class of the template; [-]; Template from which this template inherits. Can be another Template
275
- or the name of another template. _Example: see Table and ModifiedTable template_
276
-
277
-
278
- * **content**:
279
- List of the content names; [-]; this list defines which attributes the python class for this template has.
280
- The values of these attributes are either the value of the parameter with the name of the SIMULTAN-component
281
- or the value of the defined slot (see slots); _Example: [Internal heat gains, Volume, Room Name, Furniture]_
282
-
283
-
284
- * **documentation**:
285
- Documentation of the template; [str]; Documentation for other developers and users;_Example:_
286
-
287
-
288
- * **units**:
289
- Units of the content; [dict]; dictionary with the name of the content as key and unit as value. No further functionality.
290
- _Example: {Internal heat gains: W, Volume: m³, Room Name: '-', Furniture: '-'}_
291
-
292
-
293
- * **types**:
294
- Type of the content; [dict]; The type defines if the current_value or the text_value of a SIMULTAN-component
295
- is returned. If the type is str the text_value is returned, otherwise the current_value, the sub-component or
296
- the refence is returned; _Example: {Internal heat gains: float, Volume: float, Room Name: str}_
297
-
298
-
299
- * **slots**:
300
- slots of the content; [dict]; if no parameter with the content name is found, the reference or the sub-component
301
- with the here defined slot is returned; _Example: {Furniture: Element_00}_
302
-
303
- * **synonyms**:
304
- synonyme names of the python attributes; [dict]; in python class: the content is accessed through the synonym instead
305
- of the content name
306
-
307
- #### Template Example
308
-
309
- ```yaml
310
- - !Template
311
- template_name: Room
312
- template_id: '1'
313
- inherits_from:
314
- content: [Internal heat gains, Volume, Room Name, Furniture]
315
- documentation: 'Room: defines a Room or a Zone'
316
- units: {Internal heat gains: W, Volume: m³, Room Name: '-', Furniture: '-'}
317
- types: {Internal heat gains: float, Volume: float, Room Name: str}
318
- slots: {Furniture: Element_00}
319
- - &id001 !Template
320
- template_name: Table
321
- template_id: '2'
322
- inherits_from:
323
- content: [Number Persons]
324
- documentation: 'Table: defines a table with number of persons'
325
- units: {Number Persons: '-'}
326
- types: {Number Persons: float}
327
- slots: {}
328
- - !Template
329
- template_name: ModifiedTable
330
- template_id: '3'
331
- inherits_from: *id001
332
- content:
333
- documentation: See Table
334
- units:
335
- types:
336
- slots: {}
337
- - !Template
338
- template_name: MaterialList
339
- template_id: '4'
340
- inherits_from: List
341
- content: []
342
- documentation: List with Materials. This list inherits from the build-in type List
343
- units: {}
344
- types: {}
345
- slots: {}
346
- - !Template
347
- template_name: MyFace
348
- template_id: '101'
349
- inherits_from: Geometric Area
350
- content: []
351
- documentation: Face. This type inherits from the build-in type Geometric Area
352
- units: {}
353
- types: {}
354
- slots: {}
355
- ```
356
-
357
- ### Template generation in python
358
-
359
- With PySimultan template-files can be generated in an easy way. Templates can be created as instances of
360
- `PySimultan.Template` and dumped to a file:
361
-
362
- ```python
363
- from PySimultan import Template, yaml
364
-
365
- # create several templates:
366
- face_template = Template(template_name='MyFace',
367
- template_id='1',
368
- content=[],
369
- inherits_from='Geometric Area',
370
- documentation='',
371
- units={},
372
- types={},
373
- slots={}
374
- )
375
-
376
- building_template = Template(template_name='Building',
377
- template_id='2',
378
- content=['FloorList'],
379
- documentation='',
380
- units={},
381
- types={},
382
- slots={'FloorList': 'Liste_00'},
383
- inherits_from='SmartCampusBuilding'
384
- )
385
-
386
- floor_list_template = Template(template_name='FloorList',
387
- template_id='3',
388
- content=[],
389
- inherits_from='List',
390
- documentation='List with Floors',
391
- units={},
392
- types={},
393
- slots={}
394
- )
395
-
396
- # create a list of the templates to write to a file:
397
- templates = [face_template, building_template, floor_list_template]
398
-
399
- # write the templates to a file:
400
- with open(r'test.yml',
401
- mode='w',
402
- encoding="utf-8") as f_obj:
403
- yaml.dump(templates, f_obj)
404
- ```
405
-
406
-
407
-
408
-
409
-
410
-
411
- ## Geometry
412
-
413
- In SIMULTAN geometry is handled in a different way. The geometry is seperated from the data-model and there can be multiple geometry files and modles.
414
- The geometry-model is also loaded separately from the data-model.
415
-
416
- When a project with a geometry model is loaded, there are automatically `typed_geo_models` generated. These geometry
417
- models are python objects with python objects of vertices, edges, faces ...
418
-
419
- These python instances are also used in the typed data model. These instances inherit from
420
-
421
-
422
- ## Default Types
423
-
424
- There are default types for components of these slots (or TYPE):
425
-
426
- ### SimultanObject
427
- By default all Components in a SIMULTAN-project inherit from `SimultanObject`. This class wraps the SIMULTAN-objects
428
- in Python and makes basic attributes accessible.
429
-
430
- `SimultanObject` class documentation:
431
-
432
- **classproperties:**<br />
433
- + cls_instances: a list with all instances of the class
434
- + _cls_instances_dict: a dictionary with `id`: `instance` of all instances of the class
435
-
436
- **properties:**<br />
437
- + id: ID of the component
438
- + name: Name of the Component
439
- + contained_components: List of the contained components of the instance
440
- + contained_parameters: Dictionary of the contained parameters of the instance `name`: `ValueCurrent`
441
- + flat_sub_comp_list: flat list of subcomponents
442
- + referenced_components: List of all referenced components
443
- + current_slot: Current Slot of the component
444
- + slot_extension: Slot extension of the component
445
- + referenced_assets: List of referenced assets
446
-
447
- **methods:**<br />
448
- + get_param(param): get component parameter by name
449
- + set_param(param, value): set component parameter by name to value
450
-
451
-
452
- ### List
453
- A 'Liste'-object is list with a component's subcomponents.
454
- Additionaly the items in the list are sorted by their slot extension, if the slot is the same for all elements.
455
- A SIMULTAN component is automatically interpreted as a list if the 'slot' of the component is 'Liste' and no `Type` is defined.
456
- Additionally, components can be interpreted as list by setting `inherits_from`: ['Liste'].
457
- _<br /><br /> Example [readme_test_6](tests/readme_examples/readme_test_6.py): <br /><br />
458
- ![](resources/doc/lists_simultan_project.PNG)
459
- This SIMULTAN-Project contains the component `NormalList`. The component has the slot `Liste` and
460
- therefore is interpreted as a list in python if no `TYPE`-parameter is defined_
461
-
462
- `List` class documentation:
463
-
464
- **properties:**<br />
465
- + data: sorted (if possible) list of contained sub-components
466
- + contained_components: List of the contained components of the instance
467
- + name: Name of the Component
468
-
469
- **methods:**<br />
470
- + same as a python `list`
471
-
472
- <br /><br />
473
-
474
- ### ReferenceList
475
- A 'ReferenceList'-object is a list with a component's referenced components in python.
476
- Additionaly, the items in the list are sorted by their slot extension, if the slot is the same for all elements.
477
- To implement a `ReferenceList` set the `TYPE` of a SIMULTAN-component to `ReferenceList` or inherit from `ReferenceList` in the template.
478
- _<br /><br /> Example [readme_test_6](tests/readme_examples/readme_test_6.py): <br /><br />
479
- ![](resources/doc/lists_simultan_project.PNG)
480
- This SIMULTAN-Project contains the component `ReferenceList`. The component's `TYPE` parameter is set to 'ReferenceList' and therefore is interpreted as a ReferenceList in python._
481
-
482
- `ReferenceList` class documentation:
483
-
484
- **properties:**<br />
485
- + data: sorted (if possible) list of contained sub-components
486
- + contained_components: List of the contained components of the instance
487
- + name: Name of the Component
488
-
489
- **methods:**<br />
490
- + same as a python `list`
491
-
492
- <br /><br />
493
-
494
- ### ValueField
495
- slot: 'ValueField'; returns a pandas dataframe for the value-field
496
-
497
-
498
- ### BuildInFace
499
- slot: 'Geometrische_Flächen' ('Geometric Area'); returns a instance of the class BuildInFace, has the link to `GeometricFace`.
500
- BuildInFace inherits from `SimultanObject`
501
-
502
- `BuildInFace` class documentation:
503
-
504
- **properties:**<br />
505
- + geo_ids: List of IDs of the faces in the geometry model
506
- + geo_instances: List of the contained geometry instances (of type `GeometricFace`)
507
- + area: Area of the face; in [m³]
508
- + boundaries: List of the boundaries of the face (usually one)
509
- + construction: Construction of the face
510
-
511
- **methods:**<br />
512
- + get_geo_instances: returns the geometry instances of the geometry viewer
513
-
514
- <br /><br />
515
-
516
-
517
- ### BuildInVolume
518
- slot: 'Geometrische_Volumina'; returns a instance of the class BuildInVolume, has the link to `GeometricVolume`
519
-
520
-
521
- ### BuildInZone
522
- type: 'BuildInZone'; returns a instance of the class BuildInZone (a zone can consist of multiple volumes)
523
-
524
- ### BuildInConstruction
525
- Identified by InstanceType.ALIGNED_WITH
526
-
527
- `BuildInConstruction` class documentation:
528
-
529
- **properties:**<br />
530
- + is_window: Is window or not, identified by parameter 'gVergl'; if is_window: type cast to `BuildInWindowConstruction`,
531
- else type cast to `BuildInWallConstruction`
532
-
533
- **methods:**<br />
534
- + check_type: returns the geometry instances of the geometry viewer
535
-
536
- <br /><br />
537
-
538
- ### BuildInWallConstruction
539
-
540
- `BuildInWallConstruction` class documentation:
541
-
542
- **properties:**<br />
543
- + total_thickness: total Thickness of the construction in [m]
544
- + layers: List of the material layers
545
-
546
- **methods:**<br />
547
- + check_type: returns the geometry instances of the geometry viewer
548
-
549
- <br /><br />
550
-
551
- ### BuildInWindowConstruction
552
-
553
- `BuildInWindowConstruction` class documentation:
554
-
555
- **properties:**<br />
556
- lots of :-D; see GitHub class definition
557
-
558
- **methods:**<br />
559
- lots of :-D; see GitHub class definition
560
-
561
- <br /><br />
562
-
563
- ### BuildInMaterialLayer
564
-
565
- `BuildInMaterialLayer` class documentation:
566
-
567
- **properties:**<br />
568
- lots of :-D; see GitHub class definition
569
-
570
- **methods:**<br />
571
- lots of :-D; see GitHub class definition
572
-
573
- <br /><br />
574
-
575
-
576
- ## Geometry default Types:
577
-
578
- ### GeometricLayer
579
- ### GeometricVertex
580
- ### GeometricEdge
581
- ### GeometricEdgeLoop
582
-
583
- ### GeometricFace
584
- `GeometricFace` class documentation:
585
-
586
- **properties:**<br />
587
- + area: Area of the face; in [m³]
588
- + boundary: Boundary of the face; returns `GeometricEdgeLoop`
589
- + components: List of components linked to the face; usually a `BuildInFace` and a `BuildInConstruction`
590
- + construction: Construction of the face
591
- + geo_instances: List of the contained geometry instances (of type `GeometricFace`)
592
- + holes: List of holes in the face; returns [`GeometricEdgeLoop`]
593
- + hole_faces: Faces of the holes; returns [`GeometricFace`]
594
- + hull_face
595
- + normal: Normal of the face; np.ndarray
596
- + orientation: Orientation of the face: 1: in normal direction; -1: reverse normal direction
597
- + points: Edge-Points of the face; returns np.ndarray
598
- + side_1_volume: volume on side 1 of the face (in normal direction)
599
- + side_2_volume: volume on side 2 of the face (in reverse normal direction)
600
-
601
- **methods:**<br />
602
-
603
- <br /><br />
604
-
605
- ### GeometricVolume
606
-
607
-
608
- ## Tips and tricks:
609
-
610
- ### get all instances of a type
611
-
612
- The `TemplateParser` keeps track of all classes and instances. So it's easy to find all instances of
613
- a certain type in the data-model. `TemplateParser.template_classes` returns a dictionary with all generated python classes.
614
- These classes have an attribute `cls_instances` which returns a list with all instances of this type. `ValueField`, `List` and
615
- all classes which inherit from these do not have `cls_instances`.
616
-
617
- After loading the data-model:
618
- ```python
619
- from PySimultan import TemplateParser, DataModel
620
- template_parser = TemplateParser(template_filepath='my_template.yml')
621
- data_model = DataModel(project_path='my_project.simultan',
622
- user_name='SomeUser',
623
- password='UserPwd')
624
- typed_data = data_model.get_typed_data(template_parser=template_parser, create_all=True)
625
-
626
- for cls in template_parser.template_classes.values():
627
- if hasattr(cls, 'cls_instances'):
628
- print(f'{cls.__name__}: {cls.cls_instances}')
629
-
630
- ```
631
-
632
- ![](resources/doc/all_instances.PNG)
633
-
634
- # Integrate PySimultan in your package
635
-
636
- PySimultan tries to make the integration of the SIMULTAN data model as simple as possible. The integration
637
- is done by using user-defined classes to inherit from when the template classes are created.
638
-
639
- All generated classes must inherit from a PySimultan base class which wraps the imported SIMULTAN-component.
640
- This class tracks created instances and wraps the SIMULTAN-component.
641
-
642
- There are two methods to use your own implementation for the classes of the imported components.
643
-
644
- ## Use TemplateParser's bases and geo_bases
645
- The `TemplateParser` has the two dictionaries `bases` and `geo_bases` from which the created template-classes inherit
646
- if the 'inherit_from' entry in a Template is not empty or a 'default type' is detected.
647
- To use your own implementation of a class you just have to create or overwrite a entry in the `bases` or `geo_bases`
648
- with the template name as key and your class as value:
649
-
650
- Example [readme_test_5](tests/readme_examples/readme_test_5.py):
651
- ```python
652
- from PySimultan import DataModel, TemplateParser
653
-
654
-
655
- class MyWindow(object):
656
-
657
- def __init__(self, *args, **kwargs):
658
-
659
- self.another_attribute = kwargs.get('another_attribute', None)
660
-
661
- def open(self):
662
- print(f'Window {self.Name} with area {self.Area} m² opened')
663
-
664
-
665
- template_parser = TemplateParser(template_filepath=template_file)
666
- template_parser.bases['Window'] = MyWindow
667
- template_parser.create_template_classes()
668
- data_model = DataModel(project_path=project_file,
669
- user_name='SomeUser',
670
- password='UserPwd')
671
- typed_data = data_model.get_typed_data(template_parser=template_parser)
672
-
673
- typed_data[0].open()
674
- ```
675
-
676
- Limitations:
677
- * the `__init__` method must be implemented with *args and **kwargs as arguments
678
- * in the `__init__` method, the attributes defined in content must not be initialized or skipped.
679
- Background:
680
- For the defined content in the template are `properties` created who's getters and setters access the SIMULTAN-component.
681
- Therefore, the attributes must not be initialized. A workaround is to inherit directly from `SimultanObject` and
682
- overwrite the `__init__`-method.
683
-
684
-
685
- ## Use monkey patching
686
-
687
-
688
- ## More infos
689
-
690
-