Coverage for bim2sim/plugins/PluginAixLib/bim2sim_aixlib/__init__.py: 68%

25 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-03-12 17:09 +0000

1import re 

2from ast import literal_eval 

3 

4from bim2sim.export.modelica import standardlibrary 

5from bim2sim.plugins import Plugin 

6from bim2sim.plugins.PluginAixLib.bim2sim_aixlib.models import AixLib 

7from bim2sim.tasks import base, common, hvac 

8from bim2sim.plugins.PluginAixLib.bim2sim_aixlib.sim_settings import \ 

9 AixLibSimSettings 

10 

11 

12class LoadLibrariesAixLib(base.ITask): 

13 """Load AixLib library for export""" 

14 touches = ('libraries',) 

15 

16 def run(self, **kwargs): 

17 return (standardlibrary.StandardLibrary, AixLib), 

18 

19 def overwrite_standarlib_models(self): 

20 pass 

21 

22 

23class PluginAixLib(Plugin): 

24 name = 'AixLib' 

25 sim_settings = AixLibSimSettings 

26 tasks = {LoadLibrariesAixLib} 

27 default_tasks = [ 

28 common.LoadIFC, 

29 common.CheckIfc, 

30 common.CreateElementsOnIfcTypes, 

31 hvac.ConnectElements, 

32 hvac.MakeGraph, 

33 hvac.ExpansionTanks, 

34 hvac.Reduce, 

35 hvac.DeadEnds, 

36 LoadLibrariesAixLib, 

37 hvac.Export, 

38 ] 

39 

40 def create_modelica_table_from_list(self, curve): 

41 """ 

42 

43 :param curve: 

44 :return: 

45 """ 

46 curve = literal_eval(curve) 

47 for key, value in curve.iteritems(): 

48 # add first and last value to make sure there is a constant 

49 # behaviour before and after the given heating curve 

50 value = [value[0] - 5, value[1]] + value + [value[-2] + 5, 

51 value[-1]] 

52 # transform to string and replace every second comma with a 

53 # semicolon to match_graph modelica syntax 

54 value = str(value) 

55 value = re.sub('(,[^,]*),', r'\1;', value) 

56 setattr(self, key, value)