ui.controller

## Class SimulationManager

- java.lang.Object
- - ui.controller.SimulationManager

    public class SimulationManager
    extends java.lang.Object

Controller for Simulation.

Author:
  Gruppe14

### Constructor Summary

Constructors
Constructor and Description
`SimulationManager(Model m)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`SubNet` `buildSubNet(AbstractCpsObject cps, java.util.ArrayList<java.lang.Integer> visited, SubNet sN)` recursivly generates a subnet of all objects, that one specific object is connected to.
`float` `calculateEnergy(java.lang.String type, SubNet sN, int x)` calculates the energy of either all producers or consumers.
`float` `calculateMinimumEnergy(SubNet sN, int x)` Calculate the Minimum Energy.
`void` `calculateStateForTimeStep(int x)` calculates the flow of the edges and the supply for objects.
`void` `cleanObjectsToHandle()` ensures that objectsToHandle only contains HolonObjects.
`void` `copyObjects(java.util.ArrayList<AbstractCpsObject> toCopy)` copies the data of an array of Objects.
`java.lang.String` `getString(java.util.ArrayList<java.lang.Integer> tags)` Get String.
`java.util.ArrayList<SubNet>` `getSubNets()` Get all Subnets.
`boolean` `legitState(AbstractCpsObject neighbor, AbstractCpsObject current)` is the Switch in a legitimate State.
`java.util.ArrayList<java.lang.Integer>` `mergeLists(java.util.ArrayList<java.lang.Integer> a, java.util.ArrayList<java.lang.Integer> b)` Merge the Lists.
`void` `printNet()` Prints the Components auf all subnets.
`void` `printNodes(java.util.ArrayList<AbstractCpsObject> nodes)` Print the nodes.
`void` `removeFromToHandle(int id)` removes an Object that already has been handled with.
`void` `reset()` Reset all Data to the current state of the Model.
`void` `resetConnections(AbstractCpsObject cps, java.util.ArrayList<java.lang.Integer> visitedObj, java.util.ArrayList<CpsEdge> visitedEdges)` Reset the Connection.
`void` `searchForSubNets()` generates all subNets from all objectsToHandle.
`void` `setCanvas(MyCanvas can)` Set the Canvas.
`void` `setFlow(SubNet sN, boolean simulation)` Sets the Flow.
`void` `setFlowModelation(SubNet sN)` set the Flow Modelation.
`void` `setFlowSimRec(java.util.ArrayList<AbstractCpsObject> nodes, int iter)` Set Flow Rimulation Rec.
`void` `setFlowSimulation(SubNet sN)` Set Flow Simulation.
`void` `setPseudoTags(java.util.ArrayList<AbstractCpsObject> nodes)` Set the Pseudo Tags.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SimulationManager

    public SimulationManager(Model m)

Constructor.

Parameters:
  `m` - Model

### Method Detail

#### calculateStateForTimeStep

    public void calculateStateForTimeStep(int x)

calculates the flow of the edges and the supply for objects.

Parameters:
  `x` - current Iteration

#### setFlow

    public void setFlow(SubNet sN,
                        boolean simulation)

Sets the Flow.

Parameters:
  `sN` - Subnet
  `simulation` - boolean if Simulation is on

#### setFlowModelation

    public void setFlowModelation(SubNet sN)

set the Flow Modelation.

Parameters:
  `sN` - Subnet

#### setFlowSimulation

    public void setFlowSimulation(SubNet sN)

Set Flow Simulation.

Parameters:
  `sN` - Subnet

#### setFlowSimRec

    public void setFlowSimRec(java.util.ArrayList<AbstractCpsObject> nodes,
                              int iter)

Set Flow Rimulation Rec.

Parameters:
  `nodes` - the nodes
  `iter` - the Iteration

#### setPseudoTags

    public void setPseudoTags(java.util.ArrayList<AbstractCpsObject> nodes)

Set the Pseudo Tags.

Parameters:
  `nodes` - Array of AbstractCpsObjects

#### printNodes

    public void printNodes(java.util.ArrayList<AbstractCpsObject> nodes)

Print the nodes.

Parameters:
  `nodes` - Array of AbstractCpsObject

#### getString

    public java.lang.String getString(java.util.ArrayList<java.lang.Integer> tags)

Get String.

Parameters:
  `tags` - the tags
Returns:
  the String

#### mergeLists

    public java.util.ArrayList<java.lang.Integer> mergeLists(java.util.ArrayList<java.lang.Integer> a,
                                                             java.util.ArrayList<java.lang.Integer> b)

Merge the Lists.

Parameters:
  `a` - first liust
  `b` - second list
Returns:
  the Result

#### resetConnections

    public void resetConnections(AbstractCpsObject cps,
                                 java.util.ArrayList<java.lang.Integer> visitedObj,
                                 java.util.ArrayList<CpsEdge> visitedEdges)

Reset the Connection.

Parameters:
  `cps` - CpsObject
  `visitedObj` - the visited Objects
  `visitedEdges` - the visited Edges

#### calculateEnergy

    public float calculateEnergy(java.lang.String type,
                                 SubNet sN,
                                 int x)

calculates the energy of either all producers or consumers.

Parameters:
  `type` - Type
  `sN` - Subnet
  `x` - Integer
Returns:
  The Energy

#### calculateMinimumEnergy

    public float calculateMinimumEnergy(SubNet sN,
                                        int x)

Calculate the Minimum Energy.

Parameters:
  `sN` - Subnet
  `x` - Integer
Returns:
  the Calculated minimum Energy

#### searchForSubNets

    public void searchForSubNets()

generates all subNets from all objectsToHandle.

#### buildSubNet

    public SubNet buildSubNet(AbstractCpsObject cps,
                              java.util.ArrayList<java.lang.Integer> visited,
                              SubNet sN)

recursivly generates a subnet of all objects, that one specific object is connected to.

Parameters:
  `cps` - AbstractCpsObject
  `visited` - visited Array of Integer
  `sN` - Subnets
Returns:
  Subnet

#### legitState

    public boolean legitState(AbstractCpsObject neighbor,
                              AbstractCpsObject current)

is the Switch in a legitimate State.

Parameters:
  `neighbor` - AbstractCpsObject
  `current` - AbstractCpsObject
Returns:
  boolean

#### removeFromToHandle

    public void removeFromToHandle(int id)

removes an Object that already has been handled with.

Parameters:
  `id` - the Object ID

#### cleanObjectsToHandle

    public void cleanObjectsToHandle()

ensures that objectsToHandle only contains HolonObjects.

#### copyObjects

    public void copyObjects(java.util.ArrayList<AbstractCpsObject> toCopy)

copies the data of an array of Objects.

Parameters:
  `toCopy` - the ArrayList of CpsObjects co Copy

#### printNet

    public void printNet()

Prints the Components auf all subnets.

#### setCanvas

    public void setCanvas(MyCanvas can)

Set the Canvas.

Parameters:
  `can` - the Canvas

#### reset

    public void reset()

Reset all Data to the current state of the Model.

#### getSubNets

    public java.util.ArrayList<SubNet> getSubNets()

Get all Subnets.

Returns:
  all Subnets