PySimultan 0.1.54__py3-none-any.whl → 0.2.1__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.1.dist-info/LICENSE.txt +17 -0
  2. PySimultan-0.2.1.dist-info/METADATA +36 -0
  3. PySimultan-0.2.1.dist-info/RECORD +82 -0
  4. {PySimultan-0.1.54.dist-info → PySimultan-0.2.1.dist-info}/WHEEL +1 -1
  5. PySimultan-0.2.1.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 -631
  168. PySimultan/utils.py +0 -298
  169. PySimultan-0.1.54.dist-info/LICENSE +0 -674
  170. PySimultan-0.1.54.dist-info/LICENSE.txt +0 -674
  171. PySimultan-0.1.54.dist-info/METADATA +0 -690
  172. PySimultan-0.1.54.dist-info/RECORD +0 -119
  173. PySimultan-0.1.54.dist-info/entry_points.txt +0 -3
  174. PySimultan-0.1.54.dist-info/top_level.txt +0 -1
  175. PySimultan-0.1.54.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,1771 +0,0 @@
1
- from __future__ import annotations
2
- from collections import UserList
3
- from functools import lru_cache
4
- import pandas as pd
5
- import numpy as np
6
- from weakref import WeakSet
7
- import colorlog
8
- import re
9
-
10
- # from typing import List as TypeList
11
- from typing import NewType, Union, Optional
12
-
13
- # from System.Collections.Generic import List as CSList
14
- # from System import Array, Double
15
-
16
- from ParameterStructure.Values import SimMultiValueBigTable, SimMultiValueBigTableHeader, SimMultiValuePointer
17
- from ParameterStructure.Instances import SimInstancePlacementGeometry, SimInstanceType
18
- from ParameterStructure.Parameters import SimParameter
19
- from ParameterStructure.Components import SimComponent, SimSlot, SimSlotBase, SimChildComponentEntry, ComponentUtils
20
- from ParameterStructure.Algorithms.Components import ComponentManagement, ComponentMapping
21
- from ParameterStructure.Assets import ContainedResourceFileEntry
22
- from ParameterStructure.SimObjects import SimId
23
-
24
- from .config import continue_on_error
25
- from .utils import sort_references, sort_component_list, sort_slots, parse_slot
26
- from .simultan_utils import create_parameter
27
- from . import create_component
28
- from .slots import SimSlotBase
29
- from .data_model import data_models
30
-
31
-
32
- SimMultiValueBigTableType = NewType('SimMultiValueBigTable', SimMultiValueBigTable)
33
- ContainedResourceFileEntryType = NewType('ContainedResourceFileEntry', ContainedResourceFileEntry)
34
- SimParameterType = NewType('SimParameter', SimParameter)
35
- SimComponentType = NewType('SimComponent', SimComponent)
36
-
37
-
38
- logger = colorlog.getLogger('PySimultan')
39
-
40
-
41
- class classproperty(object):
42
-
43
- def __init__(self, getter):
44
- self.getter = getter
45
-
46
- def __get__(self, instance, owner):
47
- return self.getter(owner)
48
-
49
-
50
- def init_parameter(cls, comp, param_name, val, user, slot_parameter_variable=False):
51
-
52
- if val is None:
53
- return
54
- if isinstance(val, (int, float, str)):
55
- if param_name in cls._slots.keys():
56
- if not slot_parameter_variable:
57
- raise TypeError((f'Error initializing instance of {cls.__name__}:\n'
58
- f'{param_name} is associated with a slot.'
59
- f'Valid parameter values are SimComponent or SimultanObject.'
60
- f'but the value is of type {type(val)}.\n'
61
- f'If this is intentional, initialize with option slot_parameter_variable=True'))
62
-
63
- if hasattr(comp, param_name):
64
- setattr(comp, param_name, val)
65
- else:
66
- # create parameter:
67
- unit = str(cls._units.get(param_name, ''))
68
- if isinstance(val, str):
69
- param = create_parameter(name=param_name,
70
- value=0.0,
71
- unit=unit)
72
- param.set_TextValue(val)
73
- else:
74
- param = create_parameter(name=param_name,
75
- value=float(val),
76
- unit=unit)
77
- param.set_ValueCurrent(float(val))
78
- comp.Parameters.Add(param)
79
- elif isinstance(val, (SimComponent, SimultanObject)):
80
- # if the parameter is associated with a slot:
81
- if param_name in cls._slots.keys():
82
- # create sub component or reference
83
- full_slot_name = cls._slots[param_name]
84
- slot_name, slot_extension = parse_slot(full_slot_name)
85
-
86
- if isinstance(val, SimultanObject) or (val is None):
87
- slot = SimSlot(SimSlotBase(slot_name), str(slot_extension))
88
- ComponentManagement.AddReferencedComponentSlot(comp, slot, user)
89
- if val is not None:
90
- ComponentManagement.AddReferencedComponent(comp, slot, val._wrapped_obj, user)
91
- elif isinstance(val, SimComponent):
92
- entry = SimChildComponentEntry(SimSlot(SimSlotBase(slot_name), str(slot_extension)), val)
93
- comp.Components.Add(entry)
94
- else:
95
- raise TypeError(
96
- f'Error setting parameter {param_name}. Wrong type {type(val)}. This parameter is associated with a slot. The parameter value must be of type {SimultanObject} or {SimComponent}')
97
- else:
98
- raise TypeError(
99
- f'Error setting parameter {param_name}. Can not create sub-component or reference. There is no slot defined for this parameter')
100
- else:
101
- raise TypeError(
102
- f'Error setting parameter {param_name}. Wrong type {type(val)}. The value must be a instance of int, float, str, SimultanObject, SimultanObject')
103
-
104
-
105
- def create_simultan_component_from_template(cls, **kwargs):
106
- """
107
-
108
- :param cls:
109
- :param kwargs:
110
- @keyword create_undefined_parameters: if True create parameters for also for undefined keys
111
- @keyword slot_parameter_variable: if True automatically choose to create parameters, sub-components or references
112
- depending on the content value although a slot is defined in the template for the content
113
- :return:
114
- """
115
-
116
- create_undefined_parameters = kwargs.get('create_undefined_parameters', False)
117
- slot_parameter_variable = kwargs.get('slot_parameter_variable', False)
118
-
119
- comp = create_component()
120
-
121
- # add TYPE parameter:
122
- type_param = SimParameter('TYPE', '', 0.0)
123
- type_param.set_TextValue(cls._template_name)
124
- comp.Parameters.Add(type_param)
125
-
126
- user = kwargs['data_model'].user
127
-
128
- # create parameters:
129
- for param_name in cls._content:
130
-
131
- val = kwargs.get(param_name, None)
132
- init_parameter(cls, comp, param_name, val, user, slot_parameter_variable)
133
-
134
- # if val is None:
135
- # continue
136
- # if isinstance(val, (int, float, str)):
137
- # if param_name in cls._slots.keys():
138
- # if not slot_parameter_variable:
139
- # raise TypeError((f'Error initializing instance of {cls.__name__}:\n'
140
- # f'{param_name} is associated with a slot.'
141
- # f'Valid parameter values are SimComponent or SimultanObject.'
142
- # f'but the value is of type {type(val)}.\n'
143
- # f'If this is intentional, initialize with option slot_parameter_variable=True'))
144
- #
145
- # if hasattr(comp, param_name):
146
- # setattr(comp, param_name, kwargs.get(param_name))
147
- # else:
148
- # # create parameter:
149
- # unit = str(cls._units.get(param_name, ''))
150
- # if isinstance(val, str):
151
- # param = create_parameter(name=param_name,
152
- # value=0.0,
153
- # unit=unit)
154
- # param.set_TextValue(val)
155
- # else:
156
- # param = create_parameter(name=param_name,
157
- # value=float(val),
158
- # unit=unit)
159
- # param.set_ValueCurrent(float(val))
160
- # comp.Parameters.Add(param)
161
- # elif isinstance(val, (SimComponent, SimultanObject)):
162
- # # if the parameter is associated with a slot:
163
- # if param_name in cls._slots.keys():
164
- # # create sub component or reference
165
- # full_slot_name = cls._slots[param_name]
166
- # slot_name, slot_extension = parse_slot(full_slot_name)
167
- #
168
- # if isinstance(val, SimultanObject) or (val is None):
169
- # slot = SimSlot(SimSlotBase(slot_name), str(slot_extension))
170
- # user = kwargs['data_model'].user
171
- # ComponentManagement.AddReferencedComponentSlot(comp, slot, user)
172
- # if val is not None:
173
- # ComponentManagement.AddReferencedComponent(comp, slot, val._wrapped_obj, user)
174
- # elif isinstance(val, SimComponent):
175
- # entry = SimChildComponentEntry(SimSlot(SimSlotBase(slot_name), str(slot_extension)), val)
176
- # comp.Components.Add(entry)
177
- # else:
178
- # raise TypeError(f'Error setting parameter {param_name}. Wrong type {type(val)}. This parameter is associated with a slot. The parameter value must be of type {SimultanObject} or {SimComponent}')
179
- # else:
180
- # raise TypeError(
181
- # f'Error setting parameter {param_name}. Can not create sub-component or reference. There is no slot defined for this parameter')
182
- # else:
183
- # raise TypeError(f'Error setting parameter {param_name}. Wrong type {type(val)}. The value must be a instance of int, float, str, SimultanObject, SimultanObject')
184
-
185
- if create_undefined_parameters:
186
- logger.warning(f'Using option slot_parameter_variable. This is an experimental feature and may cause errors')
187
- undef_params = set(kwargs.keys()) - set(cls._content) - {'name',
188
- 'current_slot',
189
- 'create_undefined_parameters',
190
- 'data_model'}
191
-
192
- for param_name in undef_params:
193
- val = kwargs.get(param_name, None)
194
- init_parameter(cls, comp, param_name, val, user, slot_parameter_variable)
195
-
196
- return comp
197
-
198
-
199
- class SlotError(Exception):
200
- """Exception raised for errors concerning slot."""
201
-
202
-
203
- class MetaMock(type):
204
- def __call__(cls, *args, **kwargs):
205
- """
206
- Metaclass to implement object initialization either with wrapped_obj or keywords.
207
-
208
- If a wrapped_obj is defined, create new SimultanObject which wraps a SIMULTAN component (wrapped_obj).
209
-
210
- If no 'wrapped_obj' is defined, a new SimComponent is created with the content defined in the template and the
211
- values are set to the values defined in kwargs.
212
- """
213
-
214
- obj = cls.__new__(cls, *args, **kwargs)
215
-
216
- wrapped_obj = kwargs.get('wrapped_obj', None)
217
- if wrapped_obj is None:
218
-
219
- data_model = kwargs.get('data_model', None)
220
- if data_model is None:
221
- if list(data_models.data).__len__() == 1:
222
- data_model = list(data_models.data)[0]()
223
- kwargs['data_model'] = data_model
224
- else:
225
- raise TypeError((f'Error creating new instance of class {cls.__name__}:\n'
226
- f'Any data model was defined. Tried to use default data model but there are multiple datamodels.\n'
227
- f'Define the data model to use with the key: data_model'))
228
-
229
- wrapped_obj = create_simultan_component_from_template(cls, **kwargs)
230
- if 'name' in kwargs.keys():
231
- wrapped_obj.Name = kwargs.get('name')
232
- if 'current_slot' in kwargs.keys():
233
- value = kwargs.get('current_slot')
234
- if isinstance(value, str):
235
- value = SimSlotBase(value)
236
- elif isinstance(value, SimSlotBase):
237
- pass
238
- else:
239
- raise TypeError('Current slot must be of type str or SimSlotBase')
240
- elif cls._default_slot is not None:
241
- value = SimSlotBase(cls._default_slot)
242
- wrapped_obj.set_CurrentSlot(value)
243
-
244
- data_model.add_component(wrapped_obj)
245
-
246
- init_dict = {}
247
- init_dict['data_model_id'] = data_model.id
248
- init_dict['template_parser'] = cls._template_parser
249
- init_dict['wrapped_obj'] = wrapped_obj
250
- obj.__init__(*args, **init_dict)
251
- # instance = cls(**init_dict)
252
- else:
253
- obj.__init__(*args, **kwargs)
254
- return obj
255
-
256
-
257
- class SimultanObject(object, metaclass=MetaMock):
258
-
259
- # __metaclass__ = MetaMock
260
-
261
- _cls_instances = WeakSet() # weak set with all created objects
262
- _create_all = False # if true all properties are evaluated to create python objects when initialized
263
- _cls_instances_dict_cache = None
264
-
265
- @classproperty
266
- def _cls_instances_dict(cls):
267
- if cls._cls_instances_dict_cache is None:
268
- cls._cls_instances_dict_cache = dict(zip([x.id for x in cls._cls_instances], [x for x in cls._cls_instances]))
269
- return cls._cls_instances_dict_cache
270
-
271
- @classproperty
272
- def cls_instances(cls):
273
- return list(cls._cls_instances)
274
-
275
- def __new__(cls, *args, **kwargs):
276
-
277
- instance = super().__new__(cls)
278
-
279
- if "_cls_instances" not in cls.__dict__:
280
- cls._cls_instances = WeakSet()
281
- try:
282
- cls._cls_instances.add(instance)
283
- cls._cls_instances_dict_cache = None
284
- except Exception as e:
285
- logger.error(f'Error adding instance {instance} to _cls_instances: {e}')
286
-
287
- return instance
288
-
289
- def __init__(self, *args, **kwargs):
290
- """
291
- Initialize a SIMULTAN component from a template class
292
-
293
- There are two options to initialize a SimultanObject:
294
-
295
- 1. with a 'wrapped_obj', 'template_parser' and 'data_model_id':
296
- if the keyword 'wrapped_obj' with a SimComponent is passed, a new SimultanObject is created, which wraps the
297
- passed SimComponent. Additionally the 'template_parser' and 'data_model_id' must be defined. This is mostly
298
- intended to be done by the template parser to create python objects.
299
-
300
- Example:
301
- new_instance = template_class(wrapped_obj=sim_component,
302
- template_parser=self,
303
- data_model_id=self._current_data_model.id)
304
-
305
- 2. without a 'wrapped_obj' to create a new SimComponent:
306
-
307
- if no 'data_model' is passed, the default data model is used, which is the first loaded data model
308
-
309
- new_slot_comp_3 = SimultanObject(name='test_name',
310
- current_slot='Element',
311
- Param0='Test Text Value',
312
- Param1='Test Value',
313
- Param2=new_comp_1,
314
- Param3=new_comp_2,
315
- data_model=data_model)
316
-
317
- :param args:
318
- :param kwargs:
319
-
320
- To creat a new instance wrapping an existing SimComponent:
321
- @keyword wrapped_obj: SimComponent to be wrapped
322
- @keyword template_parser: Template parser instance
323
- @keyword data_model_id: Id of the data model the component belongs to
324
-
325
- If a new SimComponent is created:
326
- @keyword name: Name of the Component
327
- @keyword current_slot: Name of the Component's slot (for valid slots see SIMULTAN slot documentation)
328
- @keyword data_model: Id of the data model the component belongs to
329
-
330
- @keyword create_undefined_parameters: if True create parameters for also for undefined keys
331
- @keyword slot_parameter_variable: if True automatically choose to create parameters, sub-components or references
332
- """
333
-
334
- self._wrapped_obj = kwargs.get('wrapped_obj', None)
335
- self._contained_components = kwargs.get('contained_components', None)
336
- self._contained_parameters = kwargs.get('contained_parameters', None)
337
- self._flat_sub_comp_list = kwargs.get('flat_sub_comp_list', None)
338
- self._referenced_components = kwargs.get('referenced_components', None)
339
- self._template_parser = kwargs.get('template_parser', None)
340
- self._data_model_id = kwargs.get('data_model_id', None)
341
-
342
- self._slot_components = None
343
-
344
- # if self._create_all:
345
- # _ = self.contained_components
346
- # _ = self.contained_parameters
347
- # _ = self.referenced_components
348
-
349
- # _ = self.slot_components
350
-
351
- def __getattribute__(self, attr):
352
- try:
353
- return object.__getattribute__(self, attr)
354
- except (KeyError, AttributeError):
355
- wrapped = object.__getattribute__(self, '_wrapped_obj')
356
- if wrapped is not None:
357
- return object.__getattribute__(wrapped, attr)
358
- else:
359
- raise KeyError
360
-
361
- def __setattr__(self, attr, value):
362
- if hasattr(self, '_wrapped_obj'):
363
-
364
- if hasattr(self._wrapped_obj, attr) and (self._wrapped_obj is not None):
365
- object.__setattr__(self._wrapped_obj, attr, value)
366
- else:
367
- object.__setattr__(self, attr, value)
368
- else:
369
- object.__setattr__(self, attr, value)
370
-
371
- # if (attr in self.__dict__) or (attr in ['_wrapped_obj',
372
- # '_contained_components',
373
- # '_contained_parameters',
374
- # '_flat_sub_comp_list',
375
- # '_referenced_components',
376
- # '_template_parser',
377
- # '_data_model_id']):
378
- #
379
- # object.__setattr__(self, attr, value)
380
- # else:
381
- # object.__setattr__(self._wrapped_obj, attr, value)
382
-
383
- def __getstate__(self):
384
-
385
- logger.warning(f'__getstate__ in experimental state')
386
-
387
- obj_dict = dict()
388
- for key in dir(self.__class__):
389
- if type(getattr(self.__class__, key)) is property:
390
- print(key)
391
- obj_dict[key] = getattr(self, key)
392
-
393
- return obj_dict
394
-
395
- def __setstate__(self, state):
396
-
397
- logger.warning(f'__setstate__ in experimental state')
398
-
399
- for key, value in state.items():
400
- try:
401
- setattr(self, key, value)
402
- except AttributeError as e:
403
- pass
404
-
405
- def __repr__(self):
406
- return f'{self.name}: ' + object.__repr__(self)
407
-
408
- def __del__(self):
409
- self.__class__._cls_instances_dict_cache = None
410
-
411
- @property
412
- def id(self):
413
- if self._wrapped_obj is not None:
414
- return self._wrapped_obj.Id
415
-
416
- @property
417
- def name(self):
418
- if self._wrapped_obj is not None:
419
- return self._wrapped_obj.Name
420
-
421
- @name.setter
422
- def name(self, value: str):
423
- if self._wrapped_obj is not None:
424
- self._wrapped_obj.Name = value
425
-
426
- @property
427
- def contained_components(self):
428
- if self._contained_components is None:
429
- if self._wrapped_obj is not None:
430
- self._contained_components = [self._template_parser.create_python_object(x.Component) for x in self._wrapped_obj.Components.Items]
431
- return self._contained_components
432
-
433
- @property
434
- def contained_parameters(self):
435
- if self._contained_parameters is None:
436
- if self._wrapped_obj is not None:
437
- self._contained_parameters = {x.Name: x.get_ValueCurrent() for x in self._wrapped_obj.Parameters.Items}
438
- return self._contained_parameters
439
-
440
- # @property
441
- # def flat_sub_comp_list(self):
442
- # if self._flat_sub_comp_list is None:
443
- # if self._wrapped_obj is not None:
444
- # self._flat_sub_comp_list = [self._template_parser.create_python_object(x) for x in self._wrapped_obj.GetFlatSubCompList()]
445
- # return self._flat_sub_comp_list
446
-
447
- @property
448
- def referenced_components(self):
449
- if self._referenced_components is None:
450
- if self._wrapped_obj is not None:
451
- self._referenced_components = [self._template_parser.create_python_object(x.Target) for x in self._wrapped_obj.ReferencedComponents.Items]
452
- return self._referenced_components
453
-
454
- @property
455
- def referenced_assets(self):
456
- return [x.Resource for x in self._wrapped_obj.ReferencedAssets.Items]
457
-
458
- @lru_cache()
459
- def get_param_index(self, param: str) -> int:
460
- """
461
- Return the index of the parameter with the name 'param' in self self._wrapped_obj.Parameters.Items
462
- :param param: str; Example: 'Area'
463
- :return: Index of the parameter
464
- """
465
- idx = next((i for i, x in enumerate(self._wrapped_obj.Parameters.Items) if x.Name == param), None)
466
- return idx
467
-
468
- def get_param(self, param: str) -> SimParameterType:
469
- """
470
- Return the parameter of the parameter with the name 'param' in self self._wrapped_obj.Parameters.Items
471
- :param param: str; Example: 'Area'
472
- :return: SimParameter
473
- """
474
- idx = self.get_param_index(param)
475
- if idx is None:
476
- raise AttributeError(f'{self} {self.name} {self.id} has no parameter {param}')
477
- return self._wrapped_obj.Parameters.Items[idx].get_ValueCurrent()
478
-
479
- def set_param(self, param: str, value: float):
480
- """
481
- Set the value of a param
482
- :param param: name of the parameter
483
- :param value: value of the parameter
484
- """
485
- idx = self.get_param_index(param)
486
- if idx is None:
487
- raise AttributeError(f'{self} {self.name} has no parameter {param}')
488
- self._wrapped_obj.Parameters.Items[idx].set_ValueCurrent(value)
489
-
490
- @property
491
- def current_slot(self):
492
- return self._wrapped_obj.CurrentSlot
493
-
494
- @current_slot.setter
495
- def current_slot(self, value):
496
- if isinstance(value, str):
497
- value = SimSlotBase(value)
498
- elif isinstance(value, SimSlotBase):
499
- pass
500
- else:
501
- raise TypeError('Current slot must be of type str or SimSlotBase')
502
- self._wrapped_obj.set_CurrentSlot(value)
503
-
504
- @property
505
- def fits_in_slot(self):
506
- return self._wrapped_obj.CurrentSlot
507
-
508
- @property
509
- def slot_extension(self):
510
- """
511
- Returns the slot extension of the component
512
- :param
513
- """
514
- try:
515
- return int(re.findall("[-+]?[.]?[\d]+(?:,\d\d\d)*[\.]?\d*(?:[eE][-+]?\d+)?", self.current_slot)[-1])
516
- except Exception as e:
517
- return None
518
-
519
- @property
520
- def slot_components(self):
521
- if self._slot_components is None:
522
- self._slot_components = self.get_slot_components()
523
- return self._slot_components
524
-
525
- @slot_components.setter
526
- def slot_components(self, value):
527
- self._slot_components = value
528
-
529
- @property
530
- def parent(self):
531
- if not hasattr(self._wrapped_obj, 'Parent'):
532
- return None
533
-
534
- if self._wrapped_obj.Parent is not None:
535
- return self._template_parser.create_python_object(self._wrapped_obj.Parent)
536
- else:
537
- return None
538
-
539
- @property
540
- def referenced_by(self):
541
- return set([self._template_parser.create_python_object(x.Target) for x in self._wrapped_obj.ReferencedBy if not x.Target == self._wrapped_obj])
542
-
543
- def get_slot_components(self):
544
- """
545
- Return a DataFrame with the slot components.
546
- Dataframe columns: 'comp': component, 'slot': slot name, 'slot_extension': slot extension, 'comp_type': 0: subcomponent, 1: referenced component
547
- :return:
548
- """
549
- sc_df = pd.DataFrame(columns=['comp', 'slot', 'slot_extension', 'comp_type'])
550
-
551
- # subcomponents
552
- for comp in self._wrapped_obj.Components.Items:
553
- c_slot = comp.Slot.SlotBase.Base
554
- c_slot_extension = comp.Slot.SlotExtension
555
-
556
- sc_df = sc_df.append(
557
- pd.DataFrame(data={'comp': [self._template_parser.create_python_object(comp.Component)],
558
- 'slot': [c_slot],
559
- 'slot_extension': c_slot_extension,
560
- 'comp_type': 0}),
561
- ignore_index=True)
562
-
563
- # referenced components
564
- for comp in self._wrapped_obj.ReferencedComponents.Items:
565
- c_slot = comp.Slot.SlotBase.Base
566
- c_slot_extension = comp.Slot.SlotExtension
567
-
568
- sc_df = sc_df.append(
569
- pd.DataFrame(data={'comp': [self._template_parser.create_python_object(comp.Target)],
570
- 'slot': [c_slot],
571
- 'slot_extension': c_slot_extension,
572
- 'comp_type': 1}),
573
- ignore_index=True)
574
-
575
- return sc_df
576
-
577
- def add_sub_component(self,
578
- component: Union[SimComponentType, SimultanObject],
579
- slot_name: str,
580
- slot_extension: Union[int, float, str],
581
- alter_slot=False):
582
- """
583
- Add a sub-component to this component
584
- :param component: Component to add; Type: SimComponent or SimultanObject
585
- :param slot_name: name of the slot of the created sub-component
586
- :param slot_extension: slot extension
587
- :param alter_slot: if True change the slot of the component if it does not match the current slot of the component
588
- """
589
-
590
- sub_comp_slot = SimSlot(SimSlotBase(slot_name), str(slot_extension))
591
-
592
- if isinstance(component, SimultanObject):
593
- component = component._wrapped_obj
594
-
595
- if component.CurrentSlot is not None:
596
- if alter_slot:
597
- component.CurrentSlot = SimSlotBase(slot_name)
598
- else:
599
- raise SlotError(f'Component: {component.Name, component.Id.GlobalId} has already asigned slot:\n{component.CurrentSlot.Base}\nThis slot does not match template\'s slot:\n{slot_name}')
600
- else:
601
- component.CurrentSlot = SimSlotBase(slot_name)
602
-
603
- if not component.Id == SimId.Empty:
604
- component.Id = SimId.Empty
605
-
606
- entry = SimChildComponentEntry(sub_comp_slot, component)
607
- self._wrapped_obj.Components.Add(entry)
608
-
609
- self.slot_components = self.get_slot_components()
610
-
611
- def remove_sub_component(self,
612
- component: Union[SimComponent, SimultanObject] = None,
613
- slot_name: Optional[str] = None,
614
- slot_extension: Optional[Union[int, float, str]] = None):
615
- """
616
- Removes a sub component; Sub component defined either by component or slot_name and slot_extension
617
- :param component: Sub component to remove
618
- :param slot_name: [Optional]: slot name
619
- :param slot_extension: Optional]: slot extension
620
- """
621
- entry = None
622
-
623
- if isinstance(component, SimultanObject):
624
- component = component._wrapped_obj
625
-
626
- if component is not None:
627
- entry = next((x for x in self._wrapped_obj.Components.Items if x.Component == component), None)
628
-
629
- if None not in [slot_name, slot_extension, entry]:
630
- entry = next((x for x in self._wrapped_obj.Components.Items
631
- if all([x.Slot.SlotBase.Base == slot_name,
632
- x.Slot.SlotExtension == slot_extension])),
633
- None)
634
-
635
- if entry is not None:
636
- self._wrapped_obj.Components.Remove(entry)
637
- else:
638
- logger.warning(f'Could not remove sub component. Entry not found')
639
- raise ValueError(f'Could not remove sub component. Entry not found')
640
-
641
- self.slot_components = self.get_slot_components()
642
-
643
- def add_component_reference(self,
644
- component: Union[SimComponentType, SimultanObject],
645
- slot_name: str,
646
- slot_extension: Union[int, float, str]):
647
- """
648
- Add a reference of component to self
649
- :param component: Instance of PySimultan.default_types.SimultanObject, PySimultan.default_types.List, PySimultan.default_types.ReferenceList
650
- :param slot_name: Name of the slot
651
- :param slot_extension:
652
- """
653
- slot = SimSlot(SimSlotBase(slot_name), str(slot_extension))
654
- user = self._template_parser.current_data_model.user
655
- ComponentManagement.AddReferencedComponentSlot(self._wrapped_obj, slot, user)
656
- if isinstance(component, SimultanObject):
657
- component = component._wrapped_obj
658
- ComponentManagement.AddReferencedComponent(self._wrapped_obj, slot, component, user)
659
-
660
- self.slot_components = self.get_slot_components()
661
-
662
- def remove_component_reference(self, component: Union[SimComponentType, SimultanObject]):
663
- """
664
- Removes the reference to a component.
665
- :param component: Component which's reference to remove
666
- """
667
- if isinstance(component, SimultanObject):
668
- component = component._wrapped_obj
669
- ComponentManagement.RemoveReferencedComponent_Level0(self._wrapped_obj, component, True)
670
-
671
- self.slot_components = self.get_slot_components()
672
-
673
- def add_parameter(self, name: str, unit: str, value: Union[int, float], param_type: str = 'int'):
674
- """
675
- Add a parameter to this component. Additionally a property is added to access the parameter from this component.
676
- :param name: name of the parameter
677
- :param unit: unit of the parameter; Example: 'kg'
678
- :param value: value of the parameter: Example: 15.875
679
- :param param_type: type of the parameter; if param_type == 'str': param.get_TextValue()
680
- else: param.get_ValueCurrent() is returned
681
- """
682
- from .template_tools import add_properties
683
-
684
- new_param = SimParameter(name, unit, float(value))
685
- self._wrapped_obj.Parameters.Add(new_param)
686
- object.__setattr__(self, name, add_properties(name, param_type=param_type))
687
-
688
- def add_asset(self, resource: ContainedResourceFileEntryType):
689
- """
690
- Add a reference to a resource (file) to this component
691
- :param resource: Instance of ParameterStructure.Assets.ContainedResourceFileEntry
692
- """
693
- ComponentMapping.AddAsset(self._wrapped_obj, resource, '')
694
-
695
- def assign_table_to_parameter(self, param_name: str, table: SimMultiValueBigTableType):
696
- """
697
- set a prarameter's value to a SimMultiValueBigTable value
698
- :param param_name: name of the parameter
699
- :param table: ParameterStructure.Values.SimMultiValueBigTable
700
- """
701
- idx = self.get_param_index(param_name)
702
- param = self._wrapped_obj.Parameters.Items[idx]
703
- param.set_MultiValuePointer(table.DefaultPointer)
704
-
705
- def replace(self, key: str, new_component: Union[SimComponentType, SimultanObject]):
706
- """
707
- Replace a existing Component or reference associated with a attribute (parameter name) with a new component
708
- or reference.
709
-
710
- There are six different cases:
711
-
712
- 1. The old component is a sub-component and the new component is a SimComponent:
713
- the old component is exchanged with the new component
714
-
715
- 2. The old component is a sub-component and the new component is a SimultanObject:
716
- the old component deleted and a reference to the SimultanObject is created
717
-
718
- 3. The old component is a reference and the new component is a SimComponent:
719
- the reference to the old component is deleted a new sub-component is created
720
-
721
- 4. The old component is a reference and the new component is a SimultanObject:
722
- the reference to the old component updated to reference the new component
723
-
724
- 5. There is no old component and the new component is a SimComponent:
725
- A new sub-component is created
726
-
727
- 6. There is no old component and the new component is a SimultanObject:
728
- A new reference is created
729
-
730
- References of other components to the old component are updated to the new component.
731
-
732
- :param key: the name of the attribute (parameter name)
733
- :param new_component: the new component to replace the old component
734
- """
735
- full_slot_name = self._slots.get(key, None)
736
- slot_name, slot_extension = parse_slot(full_slot_name)
737
-
738
- component = getattr(self, key)
739
-
740
- if component is None:
741
- if new_component is None:
742
- pass
743
- if isinstance(new_component, SimultanObject):
744
- self.add_component_reference(component=new_component,
745
- slot_name=slot_name,
746
- slot_extension=slot_extension)
747
- elif isinstance(new_component, SimComponent):
748
- self.add_sub_component(component=new_component,
749
- slot_name=slot_name,
750
- slot_extension=slot_extension,
751
- alter_slot=True)
752
-
753
- # old component is not None:
754
- else:
755
- idx = self.slot_components.index[np.array([x.Id for x in self.slot_components['comp']]) == component.Id][0]
756
-
757
- references = []
758
- for ref_comp in set(component._wrapped_obj.ReferencedBy):
759
- ref = next((x for x in ref_comp.ReferencedComponents.Items if x.Target == component._wrapped_obj), None)
760
- references.append(ref)
761
-
762
- new_sim_component = new_component
763
-
764
- # old component is sub component
765
- if self.slot_components.iloc[idx].comp_type == 0:
766
- if isinstance(new_component, SimultanObject):
767
- if new_component is not None:
768
- new_sim_component = new_component._wrapped_obj
769
- # add reference to component:
770
- self.add_component_reference(component=new_component,
771
- slot_name=slot_name,
772
- slot_extension=slot_extension)
773
- self.remove_sub_component(component)
774
-
775
- elif isinstance(new_component, SimComponent):
776
- if new_component is not None:
777
- comp_ref = next((x for x in self._wrapped_obj.Components.Items
778
- if ((x.Slot.SlotBase.Base == slot_name) & (x.Slot.SlotExtension == slot_extension)))
779
- , None)
780
- new_component.CurrentSlot = comp_ref.Slot.SlotBase
781
- comp_ref.Component = new_component
782
-
783
- elif new_component is None:
784
- self.remove_sub_component(component)
785
-
786
- # old component is reference
787
- elif self.slot_components.iloc[idx].comp_type == 1:
788
- ref = next((x for x in self._wrapped_obj.ReferencedComponents.Items
789
- if ((x.Slot.SlotBase.Base == slot_name) & (
790
- x.Slot.SlotExtension == slot_extension))), None)
791
- if isinstance(new_component, SimultanObject):
792
- new_sim_component = new_component._wrapped_obj
793
- ref.Target = new_component._wrapped_obj
794
- elif isinstance(new_component, SimComponent):
795
- self.remove_component_reference(component)
796
- self.add_sub_component(new_component)
797
- elif new_component is None:
798
- self.remove_component_reference(component)
799
-
800
- for ref in references:
801
- ref.Target = new_sim_component
802
-
803
- # clear the cache of the attributes getter:
804
- getattr(self.__class__, key).fget.cache_clear()
805
-
806
- # update the 'slot_components'
807
- self.slot_components = self.get_slot_components()
808
-
809
- def get_components_with_slot(self, slot: str, slot_extension: list = None, sorted: bool = False):
810
- """
811
-
812
- :param slot: Name of the slot
813
- :param slot_extension: Slot extension
814
- :param sorted: if true, components and referenced are sorted by their slot-extension
815
- :return: List with components and references with given slot and slot-extension (optional)
816
- """
817
- components = []
818
- slot_extensions = []
819
-
820
- for comp in self._wrapped_obj.Components.Items:
821
- c_slot = comp.Slot.SlotBase.Base
822
- c_slot_extension = comp.Slot.SlotExtension
823
-
824
- if c_slot != slot:
825
- continue
826
- if slot_extension is not None:
827
- if c_slot_extension not in slot_extension:
828
- continue
829
- components.append(self._template_parser.create_python_object(comp.Component))
830
- slot_extensions.append(c_slot_extension)
831
-
832
- for comp in self._wrapped_obj.ReferencedComponents.Items:
833
- c_slot = comp.Slot.SlotBase.Base
834
- c_slot_extension = comp.Slot.SlotExtension
835
-
836
- if c_slot != slot:
837
- continue
838
- if slot_extension is not None:
839
- if c_slot_extension not in slot_extension:
840
- continue
841
- components.append(self._template_parser.create_python_object(comp.Target))
842
- slot_extensions.append(c_slot_extension)
843
-
844
- if sorted:
845
- try:
846
- return [components[i] for i in np.argsort(slot_extensions)]
847
- except Exception as e:
848
- logger.warning(f'{self.name}: Could not sort components with slot {slot}: {e}')
849
- return components
850
- else:
851
- return components
852
-
853
-
854
- class List(UserList):
855
-
856
- _create_all = False # if true all properties are evaluated to create python objects when initialized
857
-
858
- def __init__(self, *args, **kwargs):
859
- self._wrapped_obj = kwargs.get('wrapped_obj', None)
860
- self._contained_components = kwargs.get('contained_components', None)
861
- self._contained_parameters = kwargs.get('contained_parameters', None)
862
- self._template_parser = kwargs.get('template_parser', None)
863
- self._data_model_id = kwargs.get('data_model_id', None)
864
-
865
- # if self._create_all:
866
- # _ = self.contained_components
867
- # _ = self.contained_parameters
868
-
869
- @property
870
- def data(self):
871
- if self._wrapped_obj is None:
872
- return
873
- components = [x.Component for x in self._wrapped_obj.Components.Items]
874
- ref_components = [x.Target for x in self._wrapped_obj.ReferencedComponents.Items]
875
- all_components = [*components, *ref_components]
876
-
877
- slots = [*[x.Slot for x in self._wrapped_obj.Components.Items],
878
- *[x.Slot for x in self._wrapped_obj.ReferencedComponents.Items]]
879
-
880
- try:
881
- indices = sort_slots(slots)
882
- return [all_components[i] for i in np.argsort(indices)]
883
- except TypeError as e:
884
- logger.warning(f'Could not sort list {all_components}:\n{e}')
885
- return all_components
886
-
887
- def __getitem__(self, i):
888
- if isinstance(i, slice):
889
- if self._template_parser is None:
890
- return self.__class__(self.data[i])
891
- return [self._template_parser.create_python_object(x) for x in self.__class__(self.data[i])]
892
- else:
893
- if self._template_parser is None:
894
- return self.data[i]
895
- return self._template_parser.create_python_object(self.data[i])
896
-
897
- def __repr__(self):
898
- return f'{self.name}: ' + repr(list(self.data))
899
-
900
- @property
901
- def contained_components(self):
902
- if self._contained_components is None:
903
- if self._wrapped_obj is not None:
904
- self._contained_components = [self._template_parser.create_python_object(x.Component) for x in self._wrapped_obj.Components.Items]
905
- return self._contained_components
906
-
907
- @property
908
- def contained_parameters(self):
909
- if self._contained_parameters is None:
910
- if self._wrapped_obj is not None:
911
- self._contained_parameters = {x.Name: x.get_ValueCurrent() for x in self._wrapped_obj.Parameters.Items}
912
- return self._contained_parameters
913
-
914
- @property
915
- def name(self):
916
- if self._wrapped_obj is not None:
917
- if hasattr(self._wrapped_obj, 'Name'):
918
- return self._wrapped_obj.Name
919
-
920
- @name.setter
921
- def name(self, value):
922
- if self._wrapped_obj is not None:
923
- self._wrapped_obj.Name = value
924
-
925
- @property
926
- def parent(self):
927
- if not hasattr(self._wrapped_obj, 'Parent'):
928
- return None
929
-
930
- if self._wrapped_obj.Parent is not None:
931
- return self._template_parser.create_python_object(self._wrapped_obj.Parent)
932
- else:
933
- return None
934
-
935
- @property
936
- def current_slot(self):
937
- return self._wrapped_obj.CurrentSlot
938
-
939
- @current_slot.setter
940
- def current_slot(self, value):
941
- if isinstance(value, str):
942
- value = SimSlotBase(value)
943
- elif isinstance(value, SimSlotBase):
944
- pass
945
- else:
946
- raise TypeError('Current slot must be of type str or SimSlotBase')
947
- self._wrapped_obj.set_CurrentSlot(value)
948
-
949
- @property
950
- def referenced_by(self):
951
- return set([self._template_parser.create_python_object(x.Target) for x in self._wrapped_obj.ReferencedBy if
952
- not x.Target == self._wrapped_obj])
953
-
954
-
955
- class ComponentList(UserList):
956
-
957
- _create_all = False # if true all properties are evaluated to create python objects when initialized
958
-
959
- def __init__(self, *args, **kwargs):
960
- self._wrapped_obj = kwargs.get('wrapped_obj', None)
961
- self._contained_components = kwargs.get('contained_components', None)
962
- self._contained_parameters = kwargs.get('contained_parameters', None)
963
- self._template_parser = kwargs.get('template_parser', None)
964
- self._data_model_id = kwargs.get('data_model_id', None)
965
-
966
- # if self._create_all:
967
- # _ = self.contained_components
968
- # _ = self.contained_parameters
969
-
970
- @property
971
- def data(self):
972
- if self._wrapped_obj is None:
973
- return
974
- components = [x.Component for x in self._wrapped_obj.Components.Items]
975
- try:
976
- indices = sort_component_list(self._wrapped_obj.Components.Items)
977
- return [components[i] for i in np.argsort(indices)]
978
- except TypeError as e:
979
- logger.warning(f'Could not sort list {components}:\n{e}')
980
- return components
981
-
982
- def __getitem__(self, i):
983
- if isinstance(i, slice):
984
- if self._template_parser is None:
985
- return self.__class__(self.data[i])
986
- return [self._template_parser.create_python_object(x) for x in self.__class__(self.data[i])]
987
- else:
988
- if self._template_parser is None:
989
- return self.data[i]
990
- return self._template_parser.create_python_object(self.data[i])
991
-
992
- def __repr__(self):
993
- return f'{self.name}: ' + repr(list(self.data))
994
-
995
- @property
996
- def contained_components(self):
997
- if self._contained_components is None:
998
- if self._wrapped_obj is not None:
999
- self._contained_components = [self._template_parser.create_python_object(x.Component) for x in
1000
- self._wrapped_obj.Components.Items]
1001
- return self._contained_components
1002
-
1003
- @property
1004
- def contained_parameters(self):
1005
- if self._contained_parameters is None:
1006
- if self._wrapped_obj is not None:
1007
- self._contained_parameters = {x.Name: x.get_ValueCurrent() for x in self._wrapped_obj.Parameters.Items}
1008
- return self._contained_parameters
1009
-
1010
- @property
1011
- def name(self):
1012
- if self._wrapped_obj is not None:
1013
- if hasattr(self._wrapped_obj, 'Name'):
1014
- return self._wrapped_obj.Name
1015
-
1016
- @name.setter
1017
- def name(self, value):
1018
- if self._wrapped_obj is not None:
1019
- self._wrapped_obj.Name = value
1020
-
1021
- @property
1022
- def parent(self):
1023
- if not hasattr(self._wrapped_obj, 'Parent'):
1024
- return None
1025
-
1026
- if self._wrapped_obj.Parent is not None:
1027
- return self._template_parser.create_python_object(self._wrapped_obj.Parent)
1028
- else:
1029
- return None
1030
-
1031
- @property
1032
- def current_slot(self):
1033
- return self._wrapped_obj.CurrentSlot
1034
-
1035
- @current_slot.setter
1036
- def current_slot(self, value):
1037
- if isinstance(value, str):
1038
- value = SimSlotBase(value)
1039
- elif isinstance(value, SimSlotBase):
1040
- pass
1041
- else:
1042
- raise TypeError('Current slot must be of type str or SimSlotBase')
1043
- self._wrapped_obj.set_CurrentSlot(value)
1044
-
1045
- @property
1046
- def referenced_by(self):
1047
- return set([self._template_parser.create_python_object(x.Target) for x in self._wrapped_obj.ReferencedBy if
1048
- not x.Target == self._wrapped_obj])
1049
-
1050
-
1051
- class ReferenceList(UserList):
1052
-
1053
- def __init__(self, *args, **kwargs):
1054
- self._wrapped_obj = kwargs.get('wrapped_obj', None)
1055
- self._contained_components = kwargs.get('contained_components', None)
1056
- self._contained_parameters = kwargs.get('contained_parameters', None)
1057
- self._template_parser = kwargs.get('template_parser', None)
1058
- self._data_model_id = kwargs.get('data_model_id', None)
1059
-
1060
- def __getitem__(self, i):
1061
- if isinstance(i, slice):
1062
- if self._template_parser is None:
1063
- return self.__class__(self.data[i])
1064
- return [self._template_parser.create_python_object(x) for x in self.__class__(self.data[i])]
1065
- else:
1066
- if self._template_parser is None:
1067
- return self.data[i]
1068
- return self._template_parser.create_python_object(self.data[i])
1069
-
1070
- def __repr__(self):
1071
- return f'{self.name}: ' + repr(list(self.data))
1072
-
1073
- @property
1074
- def data(self):
1075
- if self._wrapped_obj is None:
1076
- return
1077
-
1078
- ref_components = [x.Target for x in self._wrapped_obj.ReferencedComponents.Items]
1079
- try:
1080
- indices = sort_references(self._wrapped_obj.ReferencedComponents.Items)
1081
- return [ref_components[i] for i in np.argsort(indices)]
1082
- except TypeError as e:
1083
- logger.warning(f'Could not sort list {ref_components}:\n{e}')
1084
- return ref_components
1085
-
1086
- @property
1087
- def contained_components(self):
1088
- if self._contained_components is None:
1089
- if self._wrapped_obj is not None:
1090
- self._contained_components = [self._template_parser.create_python_object(x) for x in
1091
- self._wrapped_obj.Components]
1092
- return self._contained_components
1093
-
1094
- @property
1095
- def contained_parameters(self):
1096
- if self._contained_parameters is None:
1097
- if self._wrapped_obj is not None:
1098
- self._contained_parameters = {x.Name: x.get_ValueCurrent() for x in
1099
- self._wrapped_obj.Parameters.Items}
1100
- return self._contained_parameters
1101
-
1102
- @property
1103
- def name(self):
1104
- if self._wrapped_obj is not None:
1105
- if hasattr(self._wrapped_obj, 'Name'):
1106
- return self._wrapped_obj.Name
1107
-
1108
- @name.setter
1109
- def name(self, value):
1110
- if self._wrapped_obj is not None:
1111
- self._wrapped_obj.Name = value
1112
-
1113
- @property
1114
- def parent(self):
1115
- if not hasattr(self._wrapped_obj, 'Parent'):
1116
- return None
1117
-
1118
- if self._wrapped_obj.Parent is not None:
1119
- return self._template_parser.create_python_object(self._wrapped_obj.Parent)
1120
- else:
1121
- return None
1122
-
1123
- @property
1124
- def current_slot(self):
1125
- return self._wrapped_obj.CurrentSlot
1126
-
1127
- @current_slot.setter
1128
- def current_slot(self, value):
1129
- if isinstance(value, str):
1130
- value = SimSlotBase(value)
1131
- elif isinstance(value, SimSlotBase):
1132
- pass
1133
- else:
1134
- raise TypeError('Current slot must be of type str or SimSlotBase')
1135
- self._wrapped_obj.set_CurrentSlot(value)
1136
-
1137
- @property
1138
- def referenced_by(self):
1139
- return set([self._template_parser.create_python_object(x.Target) for x in self._wrapped_obj.ReferencedBy if
1140
- not x.Target == self._wrapped_obj])
1141
-
1142
-
1143
- class ValueField(pd.DataFrame):
1144
-
1145
- _metadata = pd.DataFrame._metadata + ['_wrapped_obj', '_template_parser', '_data_model_id']
1146
-
1147
- def __init__(self, *args, **kwargs):
1148
-
1149
- # self._wrapped_obj = kwargs.get('wrapped_obj')
1150
- value_field = kwargs.pop('wrapped_obj', None)
1151
- if isinstance(value_field, SimMultiValuePointer):
1152
- value_field = value_field.ValueField
1153
- self._wrapped_obj = value_field
1154
- self._template_parser = kwargs.get('template_parser', None)
1155
- self._data_model_id = kwargs.get('data_model_id', None)
1156
-
1157
- row_headers = [x.Name for x in self._wrapped_obj.RowHeaders.Items]
1158
- column_headers = [x.Name for x in self._wrapped_obj.ColumnHeaders.Items]
1159
- values = self._wrapped_obj.Values
1160
-
1161
- super().__init__(dict(zip(column_headers, np.array(values).T)), index=row_headers)
1162
-
1163
- @property
1164
- def base_class_view(self):
1165
- # use this to view the base class, needed for debugging in some IDEs.
1166
- return pd.DataFrame(self)
1167
-
1168
-
1169
- class BuildInFace(SimultanObject):
1170
-
1171
- def __init__(self, *args, **kwargs):
1172
- SimultanObject.__init__(self, *args, **kwargs)
1173
-
1174
- self._geo_instances = kwargs.get('geo_instances', None)
1175
- self._boundaries = kwargs.get('boundaries', None)
1176
-
1177
- @property
1178
- def geo_ids(self):
1179
- if self.geo_instances is not None:
1180
- return [x.Id for x in self.geo_instances]
1181
-
1182
- @property
1183
- def area(self):
1184
- # idx = next((i for i, x in enumerate(self._wrapped_obj.ContainedParameters.Items) if x.Name == 'A'), None)
1185
- # param = self._wrapped_obj.ContainedParameters.Items[idx]
1186
- # return param.get_ValueCurrent()
1187
- return self.get_param('A')
1188
-
1189
- @property
1190
- def geo_ids(self):
1191
- geo_ids = []
1192
- for item in self._wrapped_obj.Instances.Items:
1193
-
1194
- geom_placement = next(x for x in item.Placements.Items if isinstance(x, SimInstancePlacementGeometry))
1195
-
1196
- file_id = geom_placement.FileId
1197
- geometry_id = geom_placement.GeometryId
1198
-
1199
- geo_ids.append({'FileId': file_id,
1200
- 'GeometryId': geometry_id})
1201
- return geo_ids
1202
-
1203
- @property
1204
- def geo_instances(self):
1205
- if self._geo_instances is None:
1206
- self._geo_instances = self.get_geo_instances()
1207
- return self._geo_instances
1208
-
1209
- @geo_instances.setter
1210
- def geo_instances(self, value):
1211
- self._geo_instances = value
1212
-
1213
- @property
1214
- def boundaries(self):
1215
- if self._boundaries is None:
1216
- if self.geo_instances is not None:
1217
- self._boundaries = [x.boundary for x in self.geo_instances]
1218
- return self._boundaries
1219
-
1220
- @property
1221
- def construction(self):
1222
- obj = next((x.Target for x in self._wrapped_obj.ReferencedComponents.Items if x.ReferenceFunction.SlotFull == 'Aufbau_0AG0'), None)
1223
- return self._template_parser.create_python_object(obj)
1224
-
1225
- def get_geo_instances(self):
1226
- try:
1227
- geo_instances = []
1228
-
1229
- for item in self._wrapped_obj.Instances.Items:
1230
-
1231
- if item.Placements.Items.__len__() == 0:
1232
- continue
1233
-
1234
- geom_placement = next(x for x in item.Placements.Items if isinstance(x, SimInstancePlacementGeometry))
1235
-
1236
- file_id = geom_placement.FileId
1237
- geometry_id = geom_placement.GeometryId
1238
-
1239
- # geo_model = self._template_parser.data_models[self._data_model_id].get_typed_model_by_file_id(file_id)
1240
- geo_model = self._template_parser.typed_geo_models[file_id]
1241
- geo_instance = geo_model.get_face_by_id(geometry_id)
1242
-
1243
- # geo_instance = self._template_parser.data_models[self._data_model_id].typed_geo_models[file_id].get_face_by_id(geometry_id)
1244
-
1245
- geo_instances.append(geo_instance)
1246
-
1247
- return geo_instances
1248
- except Exception as e:
1249
- logger.error(f'BuildInFace {self.name}; {self.id}: Error while getting geo instances: {e}')
1250
- return []
1251
-
1252
- def associate_with_geometry(self, face):
1253
-
1254
- try:
1255
- self.InstanceType = SimInstanceType.Entity3D
1256
- except Exception as e:
1257
- raise e
1258
-
1259
- exch = face.geometry_model.template_parser.current_data_model.exch
1260
- exch.Associate(self, face._wrapped_obj)
1261
-
1262
-
1263
- class BuildInVolume(SimultanObject):
1264
-
1265
- def __init__(self, *args, **kwargs):
1266
- """
1267
- Default python class for SIMULTAN 'Geometrische_Volumina' Slot
1268
- Grundflächen und Rauminhalte nach DIN 277
1269
-
1270
- @keyword geo_instances: List of geometric volume instances of type geo_default_types.GeometricVolume
1271
- @keyword surfaces: List of
1272
- """
1273
- SimultanObject.__init__(self, *args, **kwargs)
1274
-
1275
- self._geo_instances = kwargs.get('geo_instances', None)
1276
- self._surfaces = kwargs.get('surfaces', None)
1277
- self._volumes = kwargs.get('volumes', None)
1278
-
1279
- @property
1280
- def volumes(self):
1281
- return self.geo_instances
1282
-
1283
- @property
1284
- def geo_faces(self):
1285
- """
1286
- Faces of the Geometry-Model
1287
- :return: list with faces of type geo_defaut_types.GeometricFace
1288
- """
1289
- faces = []
1290
- try:
1291
- [faces.extend(x.faces) for x in self.geo_instances if x is not None]
1292
- except AttributeError as e:
1293
- raise e
1294
- return faces
1295
-
1296
- @property
1297
- def face_components(self):
1298
- return None
1299
-
1300
- @property
1301
- def geo_instances(self):
1302
- if self._geo_instances is None:
1303
- self._geo_instances = self.get_geo_instances()
1304
- return self._geo_instances
1305
-
1306
- @geo_instances.setter
1307
- def geo_instances(self, value):
1308
- self._geo_instances = value
1309
-
1310
- @property
1311
- @lru_cache(maxsize=None)
1312
- def v_a(self):
1313
- return next((x.ValueCurrent for x in self._wrapped_obj.Parameters.Items if x.Name == 'Vᴀ'), None)
1314
-
1315
- @property
1316
- @lru_cache(maxsize=None)
1317
- def v_nri(self):
1318
- """
1319
- Netto-Rauminhalt NRI: Anteil des Brutto-Rauminhalts (BRI), der das Volumen über der Netto-Raumfläche (NRF) umfasst; DIN 277
1320
- :return:
1321
- """
1322
- return next((x.ValueCurrent for x in self._wrapped_obj.Parameters.Items if x.Name == 'Vɴʀɪ'), None)
1323
-
1324
- @property
1325
- @lru_cache(maxsize=None)
1326
- def v_bri(self):
1327
- """
1328
- Brutto-Rauminhalt BRI: gesamtes Volumen eines Bauwerks oder eines Geschosses, das sich in Netto-Rauminhalt (NRI) und
1329
- Konstruktions-Rauminhalt (KRI) gliedert; DIN 277
1330
- :return:
1331
- """
1332
- return next((x.ValueCurrent for x in self._wrapped_obj.Parameters.Items if x.Name == 'Vᴃʀɪ'), None)
1333
-
1334
- @property
1335
- @lru_cache(maxsize=None)
1336
- def a_bgf(self):
1337
- """
1338
- Brutto-Grundfläche; gesamte Grundfläche eines Bauwerks oder eines Geschosses, die sich in Netto-Raumfläche (NRF)
1339
- und Konstruktions-Grundfläche (KGF) gliedert; DIN 277
1340
- :return:
1341
- """
1342
- return next((x.ValueCurrent for x in self._wrapped_obj.Parameters.Items if x.Name == 'Aᴃɢꜰ'), None)
1343
-
1344
- @property
1345
- @lru_cache(maxsize=None)
1346
- def a_ngf(self):
1347
- """
1348
- Netto-Grundfläche; DIN 277
1349
- :return:
1350
- """
1351
- return next((x.ValueCurrent for x in self._wrapped_obj.Parameters.Items if x.Name == 'Aɴɢꜰ'), None)
1352
-
1353
- def get_geo_instances(self):
1354
-
1355
- geo_instances = []
1356
-
1357
- for item in self._wrapped_obj.Instances.Items:
1358
-
1359
- try:
1360
- geom_placement = next(x for x in item.Placements.Items if isinstance(x, SimInstancePlacementGeometry))
1361
- except Exception as e:
1362
- logger.error(f'{self.__class__.__name__} {self.name} {self.id}: Could not find Geometry Placement for GeometryInstance {item}')
1363
- if continue_on_error:
1364
- continue
1365
- else:
1366
- raise e
1367
-
1368
- file_id = geom_placement.FileId
1369
- geometry_id = geom_placement.GeometryId
1370
-
1371
- # geo_model = self._template_parser.data_models[self._data_model_id].get_typed_model_by_file_id(file_id)
1372
- geo_model = self._template_parser.typed_geo_models[file_id]
1373
- geo_instance = geo_model.get_zone_by_id(geometry_id)
1374
-
1375
- if geo_instance is None:
1376
- logger.error(f'{self.__class__.__name__} {self.name} {self.id}: Geometry Instance with file id: {file_id}, geometry id: {geometry_id} not found')
1377
- if not continue_on_error:
1378
- raise KeyError(f'{self.__class__.__name__} {self.name} {self.id}: Geometry Instance with file id: {file_id}, geometry id: {geometry_id} not found')
1379
-
1380
- else:
1381
- geo_instances.append(geo_instance)
1382
-
1383
- return geo_instances
1384
-
1385
-
1386
- class BuildInZone(SimultanObject):
1387
-
1388
- def __init__(self, *args, **kwargs):
1389
- """
1390
-
1391
- """
1392
- SimultanObject.__init__(self, *args, **kwargs)
1393
-
1394
- @property
1395
- @lru_cache(maxsize=None)
1396
- def volumes(self):
1397
- return [x for x in self.contained_components if x._wrapped_obj.FitsInSlots[0] == 'Geometrische_Volumina']
1398
-
1399
- @property
1400
- @lru_cache(maxsize=None)
1401
- def faces(self):
1402
- return [x for x in self.contained_components if x._wrapped_obj.FitsInSlots[0] == 'Geometrische_Flächen']
1403
-
1404
-
1405
- class BaseBuildInConstruction(SimultanObject):
1406
-
1407
- def __init__(self, *args, **kwargs):
1408
- """
1409
- Default implementation for a wall construction (InstanceType == InstanceType.ALIGNED_WITH).
1410
- """
1411
- SimultanObject.__init__(self, *args, **kwargs)
1412
- self.check_type()
1413
-
1414
- @property
1415
- def is_window(self):
1416
- if self.get_param_index('gVergl') is None:
1417
- return False
1418
- else:
1419
- return True
1420
-
1421
- def check_type(self):
1422
- if self.is_window:
1423
- object.__setattr__(self, '__class__', BuildInWindowConstruction)
1424
- else:
1425
- object.__setattr__(self, '__class__', BuildInWallConstruction)
1426
-
1427
-
1428
- class BuildInWallConstruction(BaseBuildInConstruction):
1429
-
1430
- def __init__(self, *args, **kwargs):
1431
- """
1432
- Default implementation for a wall construction (InstanceType == InstanceType.ALIGNED_WITH).
1433
- """
1434
- BaseBuildInConstruction.__init__(self, *args, **kwargs)
1435
-
1436
- @property
1437
- def total_thickness(self):
1438
- idx = self.get_param_index('DickeGes')
1439
- # idx = next((i for i, x in enumerate(self._wrapped_obj.ContainedParameters.Items) if x.Name == 'DickeGes'), None)
1440
- param = self._wrapped_obj.Parameters.Items[idx]
1441
- return param.get_ValueCurrent()
1442
-
1443
- @property
1444
- def layers(self):
1445
- layers = [self._template_parser.create_python_object(x.Component, template_name='BuildInMaterialLayer') for x in self._wrapped_obj.Components.Items]
1446
-
1447
- # sort the layers by their slot_extension:
1448
- # slot_extensions = [x.slot_extension for x in layers]
1449
- slot_extensions = [x.Slot.SlotExtension for x in self._wrapped_obj.Components.Items]
1450
- # test with rotated
1451
- # layers = layers[1:] + layers[:1]
1452
-
1453
- return [layers[i] for i in np.argsort(slot_extensions)]
1454
- # return [x for _, x in sorted(zip(slot_extensions, layers))]
1455
-
1456
-
1457
- class BuildInWindowConstruction(BaseBuildInConstruction):
1458
-
1459
- def __init__(self, *args, **kwargs):
1460
- """
1461
- Default implementation for a window construction (InstanceType == InstanceType.ALIGNED_WITH).
1462
- """
1463
- BaseBuildInConstruction.__init__(self, *args, **kwargs)
1464
-
1465
- @property
1466
- def d(self):
1467
- """
1468
- layer thickness in m
1469
- :param
1470
- """
1471
- try:
1472
- return self.get_param('d')
1473
- except AttributeError:
1474
- return self.get_param('Dicke')
1475
-
1476
- @d.setter
1477
- def d(self, value):
1478
- # idx = self.get_param_index('d')
1479
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1480
- self.set_param('d', value)
1481
-
1482
- @property
1483
- def eps(self):
1484
- """
1485
- eps
1486
- :param
1487
- """
1488
- return self.get_param('eps')
1489
-
1490
- @eps.setter
1491
- def eps(self, value):
1492
- # idx = self.get_param_index('eps')
1493
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1494
- self.set_param('eps', value)
1495
-
1496
- @property
1497
- def gVergl(self):
1498
- """
1499
- Gesamtenergiedurchlassgrad
1500
- :param
1501
- """
1502
- return self.get_param('gVergl')
1503
-
1504
- @gVergl.setter
1505
- def gVergl(self, value):
1506
- # idx = self.get_param_index('gVergl')
1507
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1508
- self.set_param('gVergl', value)
1509
-
1510
- @property
1511
- def curtain_position(self):
1512
- """
1513
-
1514
- :param
1515
- """
1516
- return self.get_param('LageBehang')
1517
-
1518
- @curtain_position.setter
1519
- def curtain_position(self, value):
1520
- # idx = self.get_param_index('LageBehang')
1521
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1522
- self.set_param('LageBehang', value)
1523
-
1524
- @property
1525
- def openability(self):
1526
- """
1527
- openability of a window; 1=vollständig 0.1=kippen
1528
- :param
1529
- """
1530
- return self.get_param('Öffenbarkeit')
1531
-
1532
- @openability.setter
1533
- def openability(self, value):
1534
- # idx = self.get_param_index('Öffenbarkeit')
1535
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1536
- self.set_param('Öffenbarkeit', value)
1537
-
1538
- @property
1539
- def frame_width(self):
1540
- """
1541
- frame width in m
1542
- :param
1543
- """
1544
- return self.get_param('Rahmenbreite')
1545
-
1546
- @frame_width.setter
1547
- def frame_width(self, value):
1548
- # idx = self.get_param_index('Rahmenbreite')
1549
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1550
- self.set_param('Rahmenbreite', value)
1551
-
1552
- @property
1553
- def u_f(self):
1554
- """
1555
- U-Wert Rahmen in W/m²K
1556
- :param
1557
- """
1558
- return self.get_param('Uf')
1559
-
1560
- @u_f.setter
1561
- def u_f(self, value):
1562
- # idx = self.get_param_index('Uf')
1563
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1564
- self.set_param('Uf', value)
1565
-
1566
- @property
1567
- def u_g(self):
1568
- """
1569
- U-Wert Glas in W/m²K
1570
- :param
1571
- """
1572
- return self.get_param('Ug')
1573
-
1574
- @u_g.setter
1575
- def u_g(self, value):
1576
- self.set_param('Ug', value)
1577
-
1578
- @property
1579
- def alpha_curtain(self):
1580
- """
1581
- Absorption Behang
1582
- :param
1583
- """
1584
- return self.get_param('αeB')
1585
-
1586
- @alpha_curtain.setter
1587
- def alpha_curtain(self, value):
1588
- self.set_param('αeB', value)
1589
-
1590
- @property
1591
- def rho_curtain(self):
1592
- """
1593
- Reflexion Behang
1594
- :param
1595
- """
1596
- return self.get_param('ρeB')
1597
-
1598
- @rho_curtain.setter
1599
- def rho_curtain(self, value):
1600
- self.set_param('ρeB', value)
1601
-
1602
- @property
1603
- def tau_curtain(self):
1604
- """
1605
- Transmission Behang
1606
- :param
1607
- """
1608
- return self.get_param('τeB')
1609
-
1610
- @tau_curtain.setter
1611
- def tau_curtain(self, value):
1612
- self.set_param('τeB', value)
1613
-
1614
- @property
1615
- def psi(self):
1616
- """
1617
- Transmission Behang
1618
- :param
1619
- """
1620
- return self.get_param('ψ')
1621
-
1622
- @psi.setter
1623
- def psi(self, value):
1624
- self.set_param('ψ', value)
1625
-
1626
-
1627
- class BuildInMaterialLayer(SimultanObject):
1628
-
1629
- def __init__(self, *args, **kwargs):
1630
- """
1631
- Default implementation for a material layer of a wall construction.
1632
- """
1633
- SimultanObject.__init__(self, *args, **kwargs)
1634
- print('done')
1635
-
1636
- @property
1637
- def absorption_rate(self):
1638
- """
1639
- absorption rate (accoustic?)
1640
- :param
1641
- """
1642
- return self.get_param('aGr')
1643
-
1644
- @absorption_rate.setter
1645
- def absorption_rate(self, value):
1646
- # idx = self.get_param_index('aGr')
1647
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1648
- self.set_param('aGr', value)
1649
-
1650
- @property
1651
- def c(self):
1652
- """
1653
- specific heat capacity in J/kgK
1654
- :param
1655
- """
1656
- return self.get_param('c')
1657
-
1658
- @c.setter
1659
- def c(self, value):
1660
- # idx = self.get_param_index('c')
1661
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1662
- self.set_param('c', value)
1663
-
1664
- @property
1665
- def d(self):
1666
- """
1667
- layer thickness in m
1668
- :param
1669
- """
1670
- return self.get_param('d')
1671
-
1672
- @d.setter
1673
- def d(self, value):
1674
- # idx = self.get_param_index('d')
1675
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1676
- self.set_param('d', value)
1677
-
1678
- @property
1679
- def w20(self):
1680
- """
1681
- Ausgleichsfeuchte bei rli 20%
1682
- :param
1683
- """
1684
- return self.get_param('w20')
1685
-
1686
- @w20.setter
1687
- def w20(self, value):
1688
- # idx = self.get_param_index('w20')
1689
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1690
- self.set_param('w20', value)
1691
-
1692
- @property
1693
- def w80(self):
1694
- """
1695
- Ausgleichsfeuchte bei rli 80%
1696
- :param
1697
- """
1698
- return self.get_param('w80')
1699
-
1700
- @w80.setter
1701
- def w80(self, value):
1702
- # idx = self.get_param_index('w80')
1703
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1704
- self.set_param('w80', value)
1705
-
1706
- @property
1707
- def heat_conductivity(self):
1708
- """
1709
- heat conductivity in W/mK
1710
- :param
1711
- """
1712
- return self.get_param('λ')
1713
-
1714
- @heat_conductivity.setter
1715
- def heat_conductivity(self, value):
1716
- # idx = self.get_param_index('λ')
1717
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1718
- self.set_param('λ', value)
1719
-
1720
- @property
1721
- def mu(self):
1722
- """
1723
- Wasserdampfdiffusionswiderstand
1724
- :param
1725
- """
1726
- return self.get_param('μ')
1727
-
1728
- @mu.setter
1729
- def mu(self, value):
1730
- # idx = self.get_param_index('μ')
1731
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1732
- self.set_param('μ', value)
1733
-
1734
- @property
1735
- def rho(self):
1736
- """
1737
- Rohdichte in kg/m³
1738
- :param
1739
- """
1740
- return self.get_param('ρ')
1741
-
1742
- @rho.setter
1743
- def rho(self, value):
1744
- # idx = self.get_param_index('ρ')
1745
- # self._wrapped_obj.ContainedParameters.Items[idx].set_ValueCurrent(value)
1746
- self.set_param('ρ', value)
1747
-
1748
-
1749
- def create_component(name=None, parameters=None, slot=ComponentUtils.COMP_SLOT_UNDEFINED):
1750
- """
1751
- Creates a new SIMULTAN Component, optional add parameters
1752
- :param name: Name of the component
1753
- :param parameters: dictionary with parameters: {<parameter_name>: [<value>, <unit>]};
1754
- Example: {'length': [10, 'm'], 'weight': [13.0, 'kg']}
1755
- :param slot: Component Slot, sting or ComponentUtils
1756
- :return: SimComponent
1757
- """
1758
- new_comp = SimComponent()
1759
-
1760
- if name is not None:
1761
- new_comp.Name = 'Test'
1762
-
1763
- # set parameters
1764
- if parameters is not None:
1765
- for key, value in parameters.items():
1766
- new_comp.Parameters.Add(create_parameter(name=key,
1767
- value=value[0],
1768
- unit=value[1]))
1769
- # set slot:
1770
- new_comp.CurrentSlot = SimSlotBase(slot)
1771
- return new_comp