Browse Source

refactoring solution to separate new scenarios from old ones

Cláudio Gomes 8 years ago
parent
commit
ef3650e9c1
24 changed files with 65 additions and 38 deletions
  1. 4 1
      SemanticAdaptationForFMI/FMIAbstraction/src/units/AbstractSimulationUnit.py
  2. 2 1
      SemanticAdaptationForFMI/FMIAbstraction/src/units/CTSimulationUnit.py
  3. 4 1
      SemanticAdaptationForFMI/FMIAbstraction/src/units/CTSimulationUnit_Euler.py
  4. 4 1
      SemanticAdaptationForFMI/FMIAbstraction/src/units/StatechartSimulationUnit.py
  5. 0 0
      SemanticAdaptationForFMI/FMIAbstraction/src/abstract_units/Utils.py
  6. 0 0
      SemanticAdaptationForFMI/FMIAbstraction/src/abstract_units/__init__.py
  7. 0 0
      SemanticAdaptationForFMI/FMIAbstraction/src/case_study/__init__.py
  8. 0 0
      SemanticAdaptationForFMI/FMIAbstraction/src/case_study/scenarios/.gitignore
  9. 15 14
      SemanticAdaptationForFMI/FMIAbstraction/src/scenarios/ControlledScenario_EventController.py
  10. 7 3
      SemanticAdaptationForFMI/FMIAbstraction/src/scenarios/NoObstacleTest.py
  11. 6 2
      SemanticAdaptationForFMI/FMIAbstraction/src/scenarios/PowerFMU_Single.py
  12. 4 3
      SemanticAdaptationForFMI/FMIAbstraction/src/scenarios/UncontrolledScenario.py
  13. 0 0
      SemanticAdaptationForFMI/FMIAbstraction/src/case_study/scenarios/__init__.py
  14. 0 0
      SemanticAdaptationForFMI/FMIAbstraction/src/case_study/units/__init__.py
  15. 4 3
      SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/InacurateControllerArmatureAdaptation.py
  16. 5 3
      SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/PowerInputAdaptation.py
  17. 0 0
      SemanticAdaptationForFMI/FMIAbstraction/src/case_study/units/adaptations/__init__.py
  18. 2 1
      SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/ObstacleFMU.py
  19. 2 1
      SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/PowerFMU.py
  20. 2 1
      SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/WindowFMU.py
  21. 0 0
      SemanticAdaptationForFMI/FMIAbstraction/src/case_study/units/ct_based/__init__.py
  22. 2 2
      SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/DriverControllerStatechartFMU.py
  23. 2 1
      SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/EnvironmentStatechartFMU.py
  24. 0 0
      SemanticAdaptationForFMI/FMIAbstraction/src/case_study/units/de_based/__init__.py

+ 4 - 1
SemanticAdaptationForFMI/FMIAbstraction/src/units/AbstractSimulationUnit.py

@@ -3,9 +3,12 @@ Created on Mar 5, 2016
 
 @author: claudio gomes
 '''
-from units.Utils import Utils
 
 import logging
+
+from abstract_units.Utils import Utils
+
+
 l = logging.getLogger()
 
 INIT_MODE = "Initialization"

+ 2 - 1
SemanticAdaptationForFMI/FMIAbstraction/src/units/CTSimulationUnit.py

@@ -7,7 +7,8 @@ import logging
 
 import numpy
 
-from units.AbstractSimulationUnit import AbstractSimulationUnit, STEP_ACCEPT
+from abstract_units.AbstractSimulationUnit import AbstractSimulationUnit, \
+    STEP_ACCEPT
 
 
 l = logging.getLogger()

+ 4 - 1
SemanticAdaptationForFMI/FMIAbstraction/src/units/CTSimulationUnit_Euler.py

@@ -4,8 +4,11 @@ Created on Mar 5, 2016
 @author: claudio gomes
 '''
 
-from units.CTSimulationUnit import CTSimulationUnit
 import logging
+
+from abstract_units.CTSimulationUnit import CTSimulationUnit
+
+
 l = logging.getLogger()
 
 

+ 4 - 1
SemanticAdaptationForFMI/FMIAbstraction/src/units/StatechartSimulationUnit.py

@@ -7,7 +7,10 @@ import logging
 
 import numpy
 
-from units.AbstractSimulationUnit import AbstractSimulationUnit, STEP_ACCEPT
+from abstract_units.AbstractSimulationUnit import AbstractSimulationUnit, \
+    STEP_ACCEPT
+
+
 l = logging.getLogger()
 
 class StatechartSimulationUnit(AbstractSimulationUnit):

SemanticAdaptationForFMI/FMIAbstraction/src/units/Utils.py → SemanticAdaptationForFMI/FMIAbstraction/src/abstract_units/Utils.py


SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/__init__.py → SemanticAdaptationForFMI/FMIAbstraction/src/abstract_units/__init__.py


SemanticAdaptationForFMI/FMIAbstraction/src/scenarios/__init__.py → SemanticAdaptationForFMI/FMIAbstraction/src/case_study/__init__.py


SemanticAdaptationForFMI/FMIAbstraction/src/scenarios/.gitignore → SemanticAdaptationForFMI/FMIAbstraction/src/case_study/scenarios/.gitignore


+ 15 - 14
SemanticAdaptationForFMI/FMIAbstraction/src/scenarios/ControlledScenario_EventController.py

@@ -1,21 +1,22 @@
-import logging
-
-from bokeh.plotting import figure, output_file, show
-
-from sampleunits.DriverControllerStatechartFMU import DriverControllerStatechartFMU
-from sampleunits.EnvironmentStatechartFMU import EnvironmentStatechartFMU
-from sampleunits.InacurateControllerArmatureAdaptation import InacurateControllerArmatureAdaptation
-from sampleunits.ObstacleFMU import ObstacleFMU
-from sampleunits.PowerFMU import PowerFMU
-from sampleunits.PowerInputAdaptation import PowerInputAdaptation
-from sampleunits.WindowFMU import WindowFMU
-
 """
 In this scenario, the controller is a statchart that receives events at his input.
 The main semantic adaptation is getting the continuous armature signal coming from the power system,
 and converting it into an event.
 """
 
+import logging
+
+from bokeh.plotting import figure, output_file, show
+
+from case_study.units.adaptations.InacurateControllerArmatureAdaptation_Event import InacurateControllerArmatureAdaptation_Event
+from case_study.units.adaptations.PowerInputAdaptation_Event import PowerInputAdaptation_Event
+from case_study.units.ct_based.ObstacleFMU import ObstacleFMU
+from case_study.units.ct_based.PowerFMU import PowerFMU
+from case_study.units.ct_based.WindowFMU import WindowFMU
+from case_study.units.de_based.DriverControllerStatechartFMU import DriverControllerStatechartFMU
+from case_study.units.de_based.EnvironmentStatechartFMU import EnvironmentStatechartFMU
+
+
 NUM_RTOL = 1e-08
 NUM_ATOL = 1e-08
 
@@ -39,9 +40,9 @@ power = PowerFMU("power", NUM_RTOL, NUM_ATOL, cosim_step_size/num_internal_steps
                      V=12)
 
 armature_threshold = 20.0
-adapt_armature = InacurateControllerArmatureAdaptation("arm_adapt", NUM_RTOL, NUM_ATOL, armature_threshold, True)
+adapt_armature = InacurateControllerArmatureAdaptation_Event("arm_adapt", NUM_RTOL, NUM_ATOL, armature_threshold, True)
 
-adapt_power_input = PowerInputAdaptation("power_adapt")
+adapt_power_input = PowerInputAdaptation_Event("power_adapt")
 
 window_radius = 0.017
 

+ 7 - 3
SemanticAdaptationForFMI/FMIAbstraction/src/scenarios/NoObstacleTest.py

@@ -1,7 +1,11 @@
-from bokeh.plotting import figure, output_file, show
-from sampleunits.PowerFMU import PowerFMU
 import logging
-from sampleunits.WindowFMU import WindowFMU
+
+from bokeh.plotting import figure, output_file, show
+
+from case_study.units.ct_based.PowerFMU import PowerFMU
+from case_study.units.ct_based.WindowFMU import WindowFMU
+
+
 l = logging.getLogger()
 l.setLevel(logging.DEBUG)
 

+ 6 - 2
SemanticAdaptationForFMI/FMIAbstraction/src/scenarios/PowerFMU_Single.py

@@ -1,6 +1,10 @@
-from bokeh.plotting import figure, output_file, show
-from sampleunits.PowerFMU import PowerFMU
 import logging
+
+from bokeh.plotting import figure, output_file, show
+
+from case_study.units.ct_based.PowerFMU import PowerFMU
+
+
 l = logging.getLogger()
 l.setLevel(logging.DEBUG)
 

+ 4 - 3
SemanticAdaptationForFMI/FMIAbstraction/src/scenarios/UncontrolledScenario.py

@@ -2,9 +2,10 @@ import logging
 
 from bokeh.plotting import figure, output_file, show
 
-from sampleunits.ObstacleFMU import ObstacleFMU
-from sampleunits.PowerFMU import PowerFMU
-from sampleunits.WindowFMU import WindowFMU
+from case_study.units.ct_based.ObstacleFMU import ObstacleFMU
+from case_study.units.ct_based.PowerFMU import PowerFMU
+from case_study.units.ct_based.WindowFMU import WindowFMU
+
 
 l = logging.getLogger()
 l.setLevel(logging.DEBUG)

SemanticAdaptationForFMI/FMIAbstraction/src/units/__init__.py → SemanticAdaptationForFMI/FMIAbstraction/src/case_study/scenarios/__init__.py


+ 0 - 0
SemanticAdaptationForFMI/FMIAbstraction/src/case_study/units/__init__.py


+ 4 - 3
SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/InacurateControllerArmatureAdaptation.py

@@ -2,12 +2,13 @@ import logging
 
 import numpy
 
-from units.AbstractSimulationUnit import AbstractSimulationUnit, STEP_ACCEPT
+from abstract_units.AbstractSimulationUnit import AbstractSimulationUnit, \
+    STEP_ACCEPT
 
 
 l = logging.getLogger()
 
-class InacurateControllerArmatureAdaptation(AbstractSimulationUnit):
+class InacurateControllerArmatureAdaptation_Event(AbstractSimulationUnit):
     """
     This is the adaptation of the armature signal coming from the power system and into the controller statechart.
     It therefore gets a continuous input and outputs events.
@@ -22,7 +23,7 @@ class InacurateControllerArmatureAdaptation(AbstractSimulationUnit):
         
     The detailed behaviour of this block is as follows:
     ______________________________
-    f = InacurateControllerArmatureAdaptation(...)
+    f = InacurateControllerArmatureAdaptation_Event(...)
     f.enterInitMode()
     f.setValues(...,armature)
         The FMU records this value in its internal state.

+ 5 - 3
SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/PowerInputAdaptation.py

@@ -1,10 +1,12 @@
 import logging
 
-from units.AbstractSimulationUnit import AbstractSimulationUnit, STEP_ACCEPT
+from abstract_units.AbstractSimulationUnit import AbstractSimulationUnit, \
+    STEP_ACCEPT
+
 
 l = logging.getLogger()
 
-class PowerInputAdaptation(AbstractSimulationUnit):
+class PowerInputAdaptation_Event(AbstractSimulationUnit):
     """
     This is the adaptation of the events coming out of the Controller Statechart.
     It gets as input an event, and output two signals, to be coupled to the power system.
@@ -12,7 +14,7 @@ class PowerInputAdaptation(AbstractSimulationUnit):
     It's basically a ZOH.
     
     Example interaction:_______________
-    f = PowerInputAdaptation(...)
+    f = PowerInputAdaptation_Event(...)
     f.enterInitMode()
     f.setValues(...,"SomeInEvent")
         This tells the FMU what the input is.

+ 0 - 0
SemanticAdaptationForFMI/FMIAbstraction/src/case_study/units/adaptations/__init__.py


+ 2 - 1
SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/ObstacleFMU.py

@@ -1,4 +1,5 @@
-from units.CTSimulationUnit_Euler import CTSimulationUnit_Euler
+from abstract_units.CTSimulationUnit_Euler import CTSimulationUnit_Euler
+
 
 class ObstacleFMU(CTSimulationUnit_Euler):
     

+ 2 - 1
SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/PowerFMU.py

@@ -1,4 +1,5 @@
-from units.CTSimulationUnit_Euler import CTSimulationUnit_Euler
+from abstract_units.CTSimulationUnit_Euler import CTSimulationUnit_Euler
+
 
 class PowerFMU(CTSimulationUnit_Euler):
     

+ 2 - 1
SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/WindowFMU.py

@@ -1,4 +1,5 @@
-from units.CTSimulationUnit_Euler import CTSimulationUnit_Euler
+from abstract_units.CTSimulationUnit_Euler import CTSimulationUnit_Euler
+
 
 class WindowFMU(CTSimulationUnit_Euler):
     

+ 0 - 0
SemanticAdaptationForFMI/FMIAbstraction/src/case_study/units/ct_based/__init__.py


+ 2 - 2
SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/DriverControllerStatechartFMU.py

@@ -1,4 +1,4 @@
-from units.StatechartSimulationUnit import StatechartSimulationUnit
+from abstract_units.StatechartSimulationUnit import StatechartSimulationUnit
 
 
 class DriverControllerStatechartFMU(StatechartSimulationUnit):
@@ -6,7 +6,7 @@ class DriverControllerStatechartFMU(StatechartSimulationUnit):
     This is a simple controller for the power window case study.
     It takes input events (dup, ddown, dstop, obj) representing the wishes of the driver 
         and whether an object has been detected,
-        and produces output events (up, down, stop), 
+        and produces *output events* (up, down, stop), 
         representing instructions for the power system.
     It has the states
         Neutral    (initial)

+ 2 - 1
SemanticAdaptationForFMI/FMIAbstraction/src/sampleunits/EnvironmentStatechartFMU.py

@@ -1,6 +1,6 @@
 import logging
 
-from units.StatechartSimulationUnit import StatechartSimulationUnit
+from abstract_units.StatechartSimulationUnit import StatechartSimulationUnit
 
 
 l = logging.getLogger()
@@ -13,6 +13,7 @@ class EnvironmentStatechartFMU(StatechartSimulationUnit):
         Up
         Down
     And the transitions are self explanatory.
+    The outputs are events.
     """
     
     def __init__(self, name, num_rtol, num_atol):

+ 0 - 0
SemanticAdaptationForFMI/FMIAbstraction/src/case_study/units/de_based/__init__.py