fmu-manipulation-toolbox 1.9rc2__tar.gz → 1.9rc4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/PKG-INFO +1 -1
  2. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/__version__.py +1 -0
  3. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/container.py +24 -22
  4. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/gui.py +2 -0
  5. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/operations.py +1 -61
  6. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/remoting.py +105 -0
  7. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/darwin64/container.dylib +0 -0
  8. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/linux32/client_sm.so +0 -0
  9. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/linux32/server_sm +0 -0
  10. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/linux64/client_sm.so +0 -0
  11. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/linux64/container.so +0 -0
  12. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/linux64/server_sm +0 -0
  13. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/win32/client_sm.dll +0 -0
  14. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/win32/server_sm.exe +0 -0
  15. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/win64/client_sm.dll +0 -0
  16. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/win64/container.dll +0 -0
  17. fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/win64/server_sm.exe +0 -0
  18. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox.egg-info/PKG-INFO +1 -1
  19. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox.egg-info/SOURCES.txt +1 -0
  20. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/tests/test_suite.py +7 -0
  21. fmu_manipulation_toolbox-1.9rc2/fmu_manipulation_toolbox/__version__.py +0 -1
  22. fmu_manipulation_toolbox-1.9rc2/fmu_manipulation_toolbox/resources/darwin64/container.dylib +0 -0
  23. fmu_manipulation_toolbox-1.9rc2/fmu_manipulation_toolbox/resources/linux32/client_sm.so +0 -0
  24. fmu_manipulation_toolbox-1.9rc2/fmu_manipulation_toolbox/resources/linux32/server_sm +0 -0
  25. fmu_manipulation_toolbox-1.9rc2/fmu_manipulation_toolbox/resources/linux64/client_sm.so +0 -0
  26. fmu_manipulation_toolbox-1.9rc2/fmu_manipulation_toolbox/resources/linux64/container.so +0 -0
  27. fmu_manipulation_toolbox-1.9rc2/fmu_manipulation_toolbox/resources/linux64/server_sm +0 -0
  28. fmu_manipulation_toolbox-1.9rc2/fmu_manipulation_toolbox/resources/win32/client_sm.dll +0 -0
  29. fmu_manipulation_toolbox-1.9rc2/fmu_manipulation_toolbox/resources/win32/server_sm.exe +0 -0
  30. fmu_manipulation_toolbox-1.9rc2/fmu_manipulation_toolbox/resources/win64/client_sm.dll +0 -0
  31. fmu_manipulation_toolbox-1.9rc2/fmu_manipulation_toolbox/resources/win64/container.dll +0 -0
  32. fmu_manipulation_toolbox-1.9rc2/fmu_manipulation_toolbox/resources/win64/server_sm.exe +0 -0
  33. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/LICENSE.txt +0 -0
  34. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/README.md +0 -0
  35. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/__init__.py +0 -0
  36. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/__main__.py +0 -0
  37. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/assembly.py +0 -0
  38. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/checker.py +0 -0
  39. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/gui_style.py +0 -0
  40. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/help.py +0 -0
  41. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/checkbox-checked-disabled.png +0 -0
  42. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/checkbox-checked-hover.png +0 -0
  43. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/checkbox-checked.png +0 -0
  44. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/checkbox-unchecked-disabled.png +0 -0
  45. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/checkbox-unchecked-hover.png +0 -0
  46. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/checkbox-unchecked.png +0 -0
  47. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/container.png +0 -0
  48. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/drop_fmu.png +0 -0
  49. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2Annotation.xsd +0 -0
  50. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2AttributeGroups.xsd +0 -0
  51. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2ModelDescription.xsd +0 -0
  52. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2ScalarVariable.xsd +0 -0
  53. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2Type.xsd +0 -0
  54. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2Unit.xsd +0 -0
  55. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2VariableDependency.xsd +0 -0
  56. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Annotation.xsd +0 -0
  57. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3AttributeGroups.xsd +0 -0
  58. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3BuildDescription.xsd +0 -0
  59. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3InterfaceType.xsd +0 -0
  60. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3LayeredStandardManifest.xsd +0 -0
  61. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3ModelDescription.xsd +0 -0
  62. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Terminal.xsd +0 -0
  63. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3TerminalsAndIcons.xsd +0 -0
  64. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Type.xsd +0 -0
  65. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Unit.xsd +0 -0
  66. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Variable.xsd +0 -0
  67. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3VariableDependency.xsd +0 -0
  68. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmu.png +0 -0
  69. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/fmu_manipulation_toolbox.png +0 -0
  70. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/help.png +0 -0
  71. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/icon-round.png +0 -0
  72. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/icon.png +0 -0
  73. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/icon_fmu.png +0 -0
  74. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/license.txt +0 -0
  75. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/mask.png +0 -0
  76. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/resources/model.png +0 -0
  77. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/split.py +0 -0
  78. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox/version.py +0 -0
  79. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox.egg-info/dependency_links.txt +0 -0
  80. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox.egg-info/entry_points.txt +0 -0
  81. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox.egg-info/requires.txt +0 -0
  82. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/fmu_manipulation_toolbox.egg-info/top_level.txt +0 -0
  83. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/setup.cfg +0 -0
  84. {fmu_manipulation_toolbox-1.9rc2 → fmu_manipulation_toolbox-1.9rc4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmu_manipulation_toolbox
3
- Version: 1.9rc2
3
+ Version: 1.9rc4
4
4
  Summary: FMU Manipulation Toolbox is a python application for modifying Functional Mock-up Units (FMUs) without recompilation or bundling them into FMU Containers
5
5
  Home-page: https://github.com/grouperenault/fmu_manipulation_toolbox/
6
6
  Author: Nicolas.LAURENT@Renault.com
@@ -1,5 +1,6 @@
1
1
  import logging
2
2
  import getpass
3
+ import math
3
4
  import os
4
5
  import shutil
5
6
  import uuid
@@ -162,7 +163,8 @@ class EmbeddedFMUPort:
162
163
 
163
164
  class EmbeddedFMU(OperationAbstract):
164
165
  capability_list = ("needsExecutionTool",
165
- "canBeInstantiatedOnlyOncePerProcess")
166
+ "canBeInstantiatedOnlyOncePerProcess",
167
+ "canHandleVariableCommunicationStepSize")
166
168
 
167
169
  def __init__(self, filename):
168
170
  self.fmu = FMU(filename)
@@ -211,7 +213,7 @@ class EmbeddedFMU(OperationAbstract):
211
213
  self.ports[port.name] = port
212
214
 
213
215
  def __repr__(self):
214
- return f"FMU '{self.name}' ({len(self.ports)} variables)"
216
+ return f"FMU '{self.name}' ({len(self.ports)} variables, ts={self.step_size}s)"
215
217
 
216
218
 
217
219
  class FMUContainerError(Exception):
@@ -491,8 +493,8 @@ class FMUContainer:
491
493
 
492
494
  try:
493
495
  fmu = EmbeddedFMU(self.fmu_directory / fmu_filename)
494
- if fmu.fmi_version > self.fmi_version:
495
- logger.warning(f"Try to embed FMU-{fmu.fmi_version} into container FMI-{self.fmi_version}")
496
+ if not fmu.fmi_version == self.fmi_version:
497
+ logger.warning(f"Try to embed FMU-{fmu.fmi_version} into container FMI-{self.fmi_version}.")
496
498
  self.involved_fmu[fmu.name] = fmu
497
499
 
498
500
  logger.debug(f"Adding FMU #{len(self.involved_fmu)}: {fmu}")
@@ -642,16 +644,16 @@ class FMUContainer:
642
644
 
643
645
  return auto_wired
644
646
 
645
- def minimum_step_size(self) -> float:
646
- step_size = None
647
+ def default_step_size(self) -> float:
648
+ freq_set = set()
647
649
  for fmu in self.involved_fmu.values():
648
- if step_size:
649
- if fmu.step_size and fmu.step_size < step_size:
650
- step_size = fmu.step_size
651
- else:
652
- step_size = fmu.step_size
650
+ if fmu.step_size and fmu.capabilities["canHandleVariableCommunicationStepSize"] == "false":
651
+ freq_set.add(int(1.0/fmu.step_size))
653
652
 
654
- if not step_size:
653
+ common_freq = math.gcd(*freq_set)
654
+ try:
655
+ step_size = 1.0 / float(common_freq)
656
+ except ZeroDivisionError:
655
657
  step_size = 0.1
656
658
  logger.warning(f"Defaulting to step_size={step_size}")
657
659
 
@@ -659,15 +661,15 @@ class FMUContainer:
659
661
 
660
662
  def sanity_check(self, step_size: Optional[float]):
661
663
  for fmu in self.involved_fmu.values():
662
- if not fmu.step_size:
663
- continue
664
- ts_ratio = step_size / fmu.step_size
665
- if ts_ratio < 1.0:
666
- logger.warning(f"Container step_size={step_size}s is lower than FMU '{fmu.name}' "
667
- f"step_size={fmu.step_size}s.")
668
- if ts_ratio != int(ts_ratio):
669
- logger.warning(f"Container step_size={step_size}s should divisible by FMU '{fmu.name}' "
670
- f"step_size={fmu.step_size}s.")
664
+ if fmu.step_size and fmu.capabilities["canHandleVariableCommunicationStepSize"] == "false":
665
+ ts_ratio = step_size / fmu.step_size
666
+ logger.debug(f"container step_size: {step_size} = {fmu.step_size} x {ts_ratio} for {fmu.name}")
667
+ if ts_ratio < 1.0:
668
+ logger.warning(f"Container step_size={step_size}s is lower than FMU '{fmu.name}' "
669
+ f"step_size={fmu.step_size}s.")
670
+ if ts_ratio != int(ts_ratio):
671
+ logger.warning(f"Container step_size={step_size}s should divisible by FMU '{fmu.name}' "
672
+ f"step_size={fmu.step_size}s.")
671
673
  for port_name in fmu.ports:
672
674
  cport = ContainerPort(fmu, port_name)
673
675
  if cport not in self.rules:
@@ -683,7 +685,7 @@ class FMUContainer:
683
685
 
684
686
  if step_size is None:
685
687
  logger.info(f"step_size will be deduced from the embedded FMU's")
686
- step_size = self.minimum_step_size()
688
+ step_size = self.default_step_size()
687
689
  self.sanity_check(step_size)
688
690
 
689
691
  logger.info(f"Building FMU '{fmu_filename}', step_size={step_size}")
@@ -13,6 +13,8 @@ from functools import partial
13
13
 
14
14
  from .gui_style import gui_style, log_color
15
15
  from .operations import *
16
+ from .remoting import (OperationAddRemotingWin32, OperationAddRemotingWin64, OperationAddFrontendWin32,
17
+ OperationAddFrontendWin64)
16
18
  from .assembly import Assembly, AssemblyNode
17
19
  from .checker import checker_list
18
20
  from .help import Help
@@ -8,7 +8,6 @@ import tempfile
8
8
  import xml.parsers.expat
9
9
  import zipfile
10
10
  import hashlib
11
- from pathlib import Path
12
11
  from typing import *
13
12
 
14
13
  logger = logging.getLogger("fmu_manipulation_toolbox")
@@ -279,7 +278,7 @@ class OperationAbstract:
279
278
  def experiment_attrs(self, attrs):
280
279
  pass
281
280
 
282
- def port_attrs(self, fmu_port) -> int:
281
+ def port_attrs(self, fmu_port: FMUPort) -> int:
283
282
  """ return 0 to keep port, otherwise remove it"""
284
283
  return 0
285
284
 
@@ -366,65 +365,6 @@ class OperationRenameFromCSV(OperationAbstract):
366
365
  return 1
367
366
 
368
367
 
369
- class OperationAddRemotingWinAbstract(OperationAbstract):
370
- bitness_from = None
371
- bitness_to = None
372
-
373
- def __repr__(self):
374
- return f"Add '{self.bitness_to}' remoting on '{self.bitness_from}' FMU"
375
-
376
- def fmi_attrs(self, attrs):
377
- if not attrs["fmiVersion"] == "2.0":
378
- raise OperationError(f"Adding remoting is only available for FMI-2.0")
379
-
380
- def cosimulation_attrs(self, attrs):
381
- fmu_bin = {
382
- "win32": os.path.join(self.fmu.tmp_directory, "binaries", f"win32"),
383
- "win64": os.path.join(self.fmu.tmp_directory, "binaries", f"win64"),
384
- }
385
-
386
- if not os.path.isdir(fmu_bin[self.bitness_from]):
387
- raise OperationError(f"{self.bitness_from} interface does not exist")
388
-
389
- if os.path.isdir(fmu_bin[self.bitness_to]):
390
- logger.info(f"{self.bitness_to} already exists. Add front-end.")
391
- shutil.move(os.path.join(fmu_bin[self.bitness_to], attrs['modelIdentifier'] + ".dll"),
392
- os.path.join(fmu_bin[self.bitness_to], attrs['modelIdentifier'] + "-remoted.dll"))
393
- else:
394
- os.mkdir(fmu_bin[self.bitness_to])
395
-
396
- to_path = Path(__file__).parent / "resources" / self.bitness_to
397
- shutil.copyfile(to_path / "client_sm.dll",
398
- Path(fmu_bin[self.bitness_to]) / Path(attrs['modelIdentifier']).with_suffix(".dll"))
399
-
400
- from_path = Path(__file__).parent / "resources" / self.bitness_from
401
- shutil.copyfile(from_path / "server_sm.exe",
402
- Path(fmu_bin[self.bitness_from]) / "server_sm.exe")
403
-
404
- shutil.copyfile(Path(__file__).parent / "resources" / "license.txt",
405
- Path(fmu_bin[self.bitness_to]) / "license.txt")
406
-
407
-
408
- class OperationAddRemotingWin64(OperationAddRemotingWinAbstract):
409
- bitness_from = "win32"
410
- bitness_to = "win64"
411
-
412
-
413
- class OperationAddFrontendWin32(OperationAddRemotingWinAbstract):
414
- bitness_from = "win32"
415
- bitness_to = "win32"
416
-
417
-
418
- class OperationAddFrontendWin64(OperationAddRemotingWinAbstract):
419
- bitness_from = "win64"
420
- bitness_to = "win64"
421
-
422
-
423
- class OperationAddRemotingWin32(OperationAddRemotingWinAbstract):
424
- bitness_from = "win64"
425
- bitness_to = "win32"
426
-
427
-
428
368
  class OperationRemoveRegexp(OperationAbstract):
429
369
  def __repr__(self):
430
370
  return f"Remove ports matching '{self.regex_string}'"
@@ -0,0 +1,105 @@
1
+ import logging
2
+ import shutil
3
+
4
+ from pathlib import Path
5
+ from .operations import OperationAbstract, OperationError
6
+
7
+ logger = logging.getLogger("fmu_manipulation_toolbox")
8
+
9
+ class OperationAddRemotingWinAbstract(OperationAbstract):
10
+ bitness_from = None
11
+ bitness_to = None
12
+
13
+ def __repr__(self):
14
+ return f"Add '{self.bitness_to}' remoting on '{self.bitness_from}' FMU"
15
+
16
+ def __init__(self):
17
+ self.vr = {
18
+ "Real": [],
19
+ "Integer": [],
20
+ "Boolean": []
21
+ }
22
+ self.nb_input = 0;
23
+ self.nb_output = 0;
24
+
25
+ def fmi_attrs(self, attrs):
26
+ if not attrs["fmiVersion"] == "2.0":
27
+ raise OperationError(f"Adding remoting is only available for FMI-2.0")
28
+
29
+ def cosimulation_attrs(self, attrs):
30
+ fmu_bin = {
31
+ "win32": Path(self.fmu.tmp_directory) / "binaries" / "win32",
32
+ "win64": Path(self.fmu.tmp_directory) / "binaries" / "win64",
33
+ }
34
+
35
+ if not fmu_bin[self.bitness_from].is_dir():
36
+ raise OperationError(f"{self.bitness_from} interface does not exist")
37
+
38
+ if fmu_bin[self.bitness_to].is_dir():
39
+ logger.info(f"{self.bitness_to} already exists. Add front-end.")
40
+ shutil.move(fmu_bin[self.bitness_to] / Path(attrs['modelIdentifier']).with_suffix(".dll"),
41
+ fmu_bin[self.bitness_to] / Path(attrs['modelIdentifier']).with_suffix("-remoted.dll"))
42
+ else:
43
+ fmu_bin[self.bitness_to].mkdir()
44
+
45
+ to_path = Path(__file__).parent / "resources" / self.bitness_to
46
+ try:
47
+ shutil.copyfile(to_path / "client_sm.dll",
48
+ fmu_bin[self.bitness_to] / Path(attrs['modelIdentifier']).with_suffix(".dll"))
49
+ except FileNotFoundError as e:
50
+ logger.critical(f"Cannot add remoting client: {e}")
51
+
52
+ from_path = Path(__file__).parent / "resources" / self.bitness_from
53
+ try:
54
+ shutil.copyfile(from_path / "server_sm.exe",
55
+ fmu_bin[self.bitness_from] / "server_sm.exe")
56
+ except FileNotFoundError as e:
57
+ logger.critical(f"Cannot add remoting server: {e}")
58
+
59
+ shutil.copyfile(Path(__file__).parent / "resources" / "license.txt",
60
+ fmu_bin[self.bitness_to] / "license.txt")
61
+
62
+ def port_attrs(self, fmu_port) -> int:
63
+ try:
64
+ self.vr[fmu_port.fmi_type].append(fmu_port["valueReference"])
65
+ if fmu_port["causality"] in ("input", "parameter"):
66
+ self.nb_input += 1
67
+ else:
68
+ self.nb_output += 1
69
+ except KeyError:
70
+ logger.error(f"Type '{fmu_port.fmi_type}' is not supported by remoting.")
71
+
72
+ return 0
73
+
74
+ def closure(self):
75
+ target_dir = Path(self.fmu.tmp_directory) / "resources"
76
+ if not target_dir.is_dir():
77
+ target_dir.mkdir()
78
+
79
+ logger.info(f"Remoting nb input port: {self.nb_input}")
80
+ logger.info(f"Remoting nb output port: {self.nb_output}")
81
+ with open(target_dir/ "remoting_table.txt", "wt") as file:
82
+ for fmi_type in ('Real', 'Integer', 'Boolean'):
83
+ print(len(self.vr[fmi_type]), file=file)
84
+ for fmi_type in ('Real', 'Integer', 'Boolean'):
85
+ for vr in sorted(self.vr[fmi_type]):
86
+ print(vr, file=file)
87
+
88
+ class OperationAddRemotingWin64(OperationAddRemotingWinAbstract):
89
+ bitness_from = "win32"
90
+ bitness_to = "win64"
91
+
92
+
93
+ class OperationAddFrontendWin32(OperationAddRemotingWinAbstract):
94
+ bitness_from = "win32"
95
+ bitness_to = "win32"
96
+
97
+
98
+ class OperationAddFrontendWin64(OperationAddRemotingWinAbstract):
99
+ bitness_from = "win64"
100
+ bitness_to = "win64"
101
+
102
+
103
+ class OperationAddRemotingWin32(OperationAddRemotingWinAbstract):
104
+ bitness_from = "win64"
105
+ bitness_to = "win32"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmu_manipulation_toolbox
3
- Version: 1.9rc2
3
+ Version: 1.9rc4
4
4
  Summary: FMU Manipulation Toolbox is a python application for modifying Functional Mock-up Units (FMUs) without recompilation or bundling them into FMU Containers
5
5
  Home-page: https://github.com/grouperenault/fmu_manipulation_toolbox/
6
6
  Author: Nicolas.LAURENT@Renault.com
@@ -12,6 +12,7 @@ fmu_manipulation_toolbox/gui.py
12
12
  fmu_manipulation_toolbox/gui_style.py
13
13
  fmu_manipulation_toolbox/help.py
14
14
  fmu_manipulation_toolbox/operations.py
15
+ fmu_manipulation_toolbox/remoting.py
15
16
  fmu_manipulation_toolbox/split.py
16
17
  fmu_manipulation_toolbox/version.py
17
18
  fmu_manipulation_toolbox.egg-info/PKG-INFO
@@ -4,6 +4,7 @@ from pathlib import Path
4
4
 
5
5
  sys.path.insert(0, str(Path(__file__).parent.parent))
6
6
  from fmu_manipulation_toolbox.operations import *
7
+ from fmu_manipulation_toolbox.remoting import *
7
8
  from fmu_manipulation_toolbox.container import *
8
9
  from fmu_manipulation_toolbox.assembly import *
9
10
 
@@ -143,6 +144,12 @@ class FMUManipulationToolboxTestSuite(unittest.TestCase):
143
144
  self.assert_identical_files_but_guid("containers/start/REF-modelDescription.xml",
144
145
  "containers/start/container-slx/modelDescription.xml")
145
146
 
147
+ def test_fmi3_pt2(self):
148
+ assembly = Assembly("passthrough.json", fmu_directory=Path("fmi3/passthrough"), debug=True)
149
+ assembly.make_fmu(fmi_version=2)
150
+ self.assert_identical_files("fmi3/passthrough/REF-container.txt",
151
+ "fmi3/passthrough/container-passthrough/resources/container.txt")
152
+
146
153
  def test_container_move(self):
147
154
  #bb = Assembly("bouncing.csv", fmu_directory=Path("containers/bouncing_ball"))
148
155
  #links = bb.root.get_fmu_connections("bb_position.fmu")