Przeglądaj źródła

Modelation removed

dominik.rieder 7 lat temu
rodzic
commit
ff2805a1c8

+ 2 - 5
src/classes/CpsEdge.java

@@ -138,13 +138,10 @@ public class CpsEdge {
 	 *            Simulation Mode
 	 */
 
-	public void calculateState(boolean simMode) {
+	public void calculateState() {
 		if (flow > maxCapacity && maxCapacity != -1 && maxCapacity != -2) {
 			isWorking = false;
-		} else {
-			if (!simMode && (flow <= maxCapacity || maxCapacity == -1 || maxCapacity == -2)) {
-				isWorking = true;
-			}
+			flow = 0;
 		}
 	}
 

+ 4 - 4
src/tests/PraktikumHolonsTestClasses.java

@@ -150,15 +150,15 @@ public class PraktikumHolonsTestClasses {
 		assertTrue("Flow was not changed", edge1.getFlow() == 50);
 		assertTrue("Capacity not right", edge1.getCapacity() == 200);
 		assertTrue("line broken", edge2.getState());
-		edge2.calculateState(false);
+		edge2.calculateState();
 		assertTrue("line broken", edge2.getState());
 		edge2.setFlow(200);
-		edge2.calculateState(false);
+		edge2.calculateState();
 		assertTrue("line not broken", !edge2.getState());
 		edge1.setCapacity(-1);
-		edge1.calculateState(false);
+		edge1.calculateState();
 		edge1.setCapacity(500);
-		edge1.calculateState(true);
+		edge1.calculateState();
 		node1 = (CpsNode) edge1.getB();
 		node2 = (CpsNode) edge2.getA();
 		assertTrue("Not Same", node1 == node2);

+ 0 - 3
src/tests/PraktikumHolonsTestGlobalController.java

@@ -37,20 +37,17 @@ public class PraktikumHolonsTestGlobalController {
 		int prevScale = controller.getScale();
 		int prevScaleDiv2 = controller.getScaleDiv2();
 		int prevNumberSav = controller.getNumbersOfSaves();
-		boolean sim = model.getIsSimulation();
 		int timer = model.getTimerSpeed();
 		int it = model.getCurIteration();
 
 		controller.setScale(100);
 		controller.setNumberOfSaves(50);
-		controller.setIsSimulation(true);
 		controller.setTimerSpeed(2000);
 		controller.setCurIteration(10);
 
 		assertTrue("Scale was not changed", controller.getScale() != prevScale);
 		assertTrue("ScaleDiv2 was not changed ", model.getScaleDiv2() != prevScaleDiv2);
 		assertTrue("Number of Saves was not changed", controller.getNumbersOfSaves() != prevNumberSav);
-		assertTrue("Simulation State was not Set", sim != model.getIsSimulation());
 		assertTrue("Timer speed was not changed", timer != model.getTimerSpeed());
 		assertTrue("Curr Iteration was not Set", it != model.getCurIteration());
 

+ 0 - 10
src/ui/controller/Control.java

@@ -629,16 +629,6 @@ public class Control {
 		globalController.setTimerSpeed(t);
 	}
 
-	/**
-	 * Set if its simulating or not.
-	 * 
-	 * @param b
-	 *            isSimulation
-	 */
-	public void setIsSimulation(boolean b) {
-		globalController.setIsSimulation(b);
-	}
-
 	/**
 	 * Set the Canvas X Size.
 	 * 

+ 0 - 10
src/ui/controller/GlobalController.java

@@ -90,16 +90,6 @@ public class GlobalController {
 		model.setTimerSpeed(t);
 	}
 
-	/**
-	 * Set isSimulation.
-	 * 
-	 * @param b
-	 *            boolean for for isSimulation
-	 */
-	public void setIsSimulation(boolean b) {
-		model.setIsSimulation(b);
-	}
-
 	/**
 	 * Set the Canvas X Size.
 	 * 

+ 5 - 42
src/ui/controller/SimulationManager.java

@@ -26,7 +26,6 @@ public class SimulationManager {
 	private ArrayList<SubNet> subNets;
 	private MyCanvas canvas;
 	private int timeStep;
-	private boolean simMode;
 	private HashMap<Integer, Float> tagTable = new HashMap<Integer, Float>();
 	/**
 	 * Constructor.
@@ -38,7 +37,6 @@ public class SimulationManager {
 		canvas = null;
 		model = m;
 		subNets = new ArrayList<SubNet>();
-		simMode = model.getIsSimulation();
 	}
 
 	/**
@@ -48,7 +46,6 @@ public class SimulationManager {
 	 *            current Iteration
 	 */
 	public void calculateStateForTimeStep(int x) {
-		simMode = model.getIsSimulation();
 		timeStep = x;
 		searchForSubNets();
 		for (SubNet singleSubNet : subNets) {
@@ -58,7 +55,7 @@ public class SimulationManager {
 			float production = calculateEnergy("prod", singleSubNet, timeStep);
 			float consumption = calculateEnergy("cons", singleSubNet, timeStep);
 			float minConsumption = calculateMinimumEnergy(singleSubNet, timeStep);
-			setFlow(singleSubNet, simMode);
+			setFlowSimulation(singleSubNet);
 			for (HolonObject hl : singleSubNet.getObjects()) {
 				if (!(hl.getState() == 0) && !(hl.getState() == 3)) {
 					for (int i = 0; i < hl.getConnections().size(); i++) {
@@ -92,40 +89,6 @@ public class SimulationManager {
 		//printNet();
 	}
 
-	/**
-	 * Sets the Flow.
-	 * 
-	 * @param sN
-	 *            Subnet
-	 * @param simulation
-	 *            boolean if Simulation is on
-	 */
-	public void setFlow(SubNet sN, boolean simulation) {
-		if (simulation) {
-			setFlowSimulation(sN);
-		} else {
-			setFlowModelation(sN);
-		}
-	}
-
-	/**
-	 * set the Flow Modelation.
-	 * 
-	 * @param sN
-	 *            Subnet
-	 */
-	public void setFlowModelation(SubNet sN) {
-		for (HolonObject hl : sN.getObjects()) {
-			float energy = hl.getCurrentEnergyAtTimeStep(timeStep);
-			if (energy > 0) {
-				for (CpsEdge e : sN.getEdges()) {
-					e.setFlow(e.getFlow() + energy);
-					e.calculateState(simMode);
-				}
-			}
-		}
-	}
-
 	/**
 	 * Set Flow Simulation.
 	 * 
@@ -152,7 +115,7 @@ public class SimulationManager {
 							tmp = edge.getA();
 						}
 						edge.setFlow(edge.getFlow() + energy);
-						edge.calculateState(true);
+						edge.calculateState();
 						edge.addTag(hl.getId());
 						if (edge.getState() && !producers.contains(tmp)) {
 							if(tmp instanceof HolonSwitch){
@@ -208,7 +171,7 @@ public class SimulationManager {
 									}
 								}
 							}
-							edge.calculateState(true);
+							edge.calculateState();
 							if(edge.getState() && !(tmp instanceof CpsUpperNode)){
 								tmp.addAllPseudoTags(cps.getTag());
 								if(!newNodes.contains(tmp)){
@@ -310,7 +273,7 @@ public class SimulationManager {
 		for (CpsEdge e : cps.getConnections()) {
 			if (!(visitedEdges.contains(e))) {
 				e.setFlow(0);
-				e.calculateState(simMode);
+				e.calculateState();
 				e.setTags(new ArrayList<Integer>());
 				visitedEdges.add(e);
 				if (!(visitedObj.contains(e.getA().getId()))) {
@@ -433,7 +396,7 @@ public class SimulationManager {
 		AbstractCpsObject a;
 		AbstractCpsObject b;
 		for (CpsEdge edge : cps.getConnections()) {
-			if(!(simMode && !edge.getState())){
+			if(edge.getState()){
 				a = edge.getA();
 				b = edge.getB();
 				if (!(cps instanceof HolonSwitch)) {

+ 0 - 22
src/ui/model/Model.java

@@ -68,9 +68,6 @@ public class Model {
 	// Iteration Speed
 	private int timerSpeed = 1000;
 
-	// Simulation boolean
-	private boolean isSimulation = false;
-
 	private int selectedID = 0;
 	// number of the current autosave
 	private int autoSaveNr = -1;
@@ -584,25 +581,6 @@ public class Model {
 		return this.timerSpeed;
 	}
 
-	/**
-	 * Sets the Simulation state (true = simulation, false = modeling).
-	 * 
-	 * @param isSimulation
-	 *            boolean for for isSimulation
-	 */
-	public void setIsSimulation(boolean isSimulation) {
-		this.isSimulation = isSimulation;
-	}
-
-	/**
-	 * Returns the Simulation state (true = simulation, false = modeling).
-	 * 
-	 * @return isSimulation boolean for for isSimulation
-	 */
-	public boolean getIsSimulation() {
-		return this.isSimulation;
-	}
-
 	/**
 	 * Get Canvas X Size.
 	 * 

+ 1 - 4
src/ui/view/GUI.java

@@ -1686,9 +1686,7 @@ public class GUI<E> implements CategoryListener {
 			@Override
 			public void stateChanged(ChangeEvent e) {
 				int i = model.getCurIteration();
-				if (model.getIsSimulation()) {
-					controller.runAlgorithm(model, controller);
-				}
+				controller.runAlgorithm(model, controller);
 				controller.calculateStateForTimeStep(i);
 				contentPane.updateUI();
 				unitGraph.repaint();
@@ -1944,7 +1942,6 @@ public class GUI<E> implements CategoryListener {
 		eraseCategory = tempArray[29];
 		selectObjBeforeErase = tempArray[30];
 		// SimMenu
-		simMenu.simButton.setText(Languages.getLanguage()[83]);
 		simMenu.simSpeedLabel.setText(Languages.getLanguage()[84]);
 		simMenu.algoFolderButton.setText(Languages.getLanguage()[85]);
 		// TimePanel

+ 0 - 17
src/ui/view/SimulationMenu.java

@@ -40,7 +40,6 @@ public class SimulationMenu extends JMenuBar {
 	private static final long serialVersionUID = 1L;
 
 	private JPanel menuPanel = new JPanel();
-	JRadioButton simButton = new JRadioButton(Languages.getLanguage()[83]);
 	JLabel simSpeedLabel = new JLabel(Languages.getLanguage()[84]);
 	private JTextField simSpeedText = new JTextField("1000");
 	private JComboBox<Object> algoCombo = new JComboBox<>();
@@ -132,22 +131,6 @@ public class SimulationMenu extends JMenuBar {
 		gblmenuPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
 		menuPanel.setLayout(gblmenuPanel);
 
-		// isSimulation
-		simButton.addActionListener(new ActionListener() {
-
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				controller.setIsSimulation(simButton.isSelected());
-				controller.calculateStateForCurrentTimeStep();
-			}
-		});
-
-		GridBagConstraints gbcsimButton = new GridBagConstraints();
-		gbcsimButton.anchor = GridBagConstraints.NORTHWEST;
-		gbcsimButton.insets = new Insets(0, 0, 0, 5);
-		gbcsimButton.gridx = 0;
-		gbcsimButton.gridy = 0;
-		menuPanel.add(simButton, gbcsimButton);
 		GridBagConstraints gbcsimSpeedLabel = new GridBagConstraints();
 		gbcsimSpeedLabel.anchor = GridBagConstraints.WEST;
 		gbcsimSpeedLabel.insets = new Insets(0, 0, 0, 5);

+ 1 - 1
src/ui/view/StatisticGraph.java

@@ -83,7 +83,7 @@ public class StatisticGraph extends JPanel {
 			g2.drawLine(0, i, this.getWidth(), i);
 		}
 
-		isSimRunning = model.getIsSimulation();
+		isSimRunning = true;
 
 		// if sim is on
 		if (isSimRunning) {