Browse Source

Merge branch 'master' of git@git.tk.informatik.tu-darmstadt.de:andreas.meyer-berg/SmartHomeNetworkSim.git

Andreas T. Meyer-Berg 5 years ago
parent
commit
6f471e306a

+ 1 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/ConnectionPerformance.java

@@ -100,7 +100,7 @@ public class ConnectionPerformance implements Connection {
 				returnPackets.addAll(protocol.generateNextPakets(p, (long) (startTime+p.getJitter()*Math.random()),Math.random()<packetLossRate));
 			}
 			while(p.getLastTrigger()+p.getTriggerInterval()<startTime+duration &&p.getStatus()==Port.SENDING)
-				returnPackets.addAll(protocol.generateNextPakets(p, (long) Math.max((p.getLastTrigger()+p.getTriggerInterval()+p.getJitter()*(Math.random())),p.getLastTrigger()+p.getTriggerInterval()+1),Math.random()<packetLossRate));
+				returnPackets.addAll(protocol.generateNextPakets(p, (long) Math.max((p.getLastTrigger()+p.getTriggerInterval()+p.getJitter()*(Math.random())),p.getLastTrigger()+p.getTriggerInterval()),Math.random()<packetLossRate));
 		}
 		returnPackets.sort((a,b)->(Long.compare(a.getTimestamp(),b.getTimestamp())));
 		return returnPackets;

+ 1 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/ConnectionPrecision.java

@@ -81,7 +81,7 @@ public class ConnectionPrecision extends ConnectionPerformance {
 					/**
 					 * Generate first package in the simulation interval (not before startTime though), and at least 1ms after the last Trigger Time
 					 */
-					returnPackets.addAll(protocol.generateNextPakets(p, (long)Math.max( p.getLastTrigger()+p.getTriggerInterval()+p.getJitter()*Math.random(),Math.max(p.getLastTrigger()+1,startTime)),Math.random()<packetLossRate));
+					returnPackets.addAll(protocol.generateNextPakets(p, (long)Math.max( p.getLastTrigger()+p.getTriggerInterval()+p.getJitter()*Math.random(),Math.max(p.getLastTrigger(),startTime)),Math.random()<packetLossRate));
 					/**
 					 * If Port should simulate again in this interval -> add back to the tree
 					 */

+ 5 - 2
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/SimulationManager.java

@@ -179,7 +179,7 @@ public class SimulationManager extends Observable {
 	 * 
 	 * @param timestep new timestep of ports after the reset
 	 */
-	public void resetSimulation(long timestep) {
+	private void resetSimulation(long timestep) {
 		for (SmartDevice d : model.getDevices())
 			for (Port p : d.getPorts())
 				if (p.getLastTrigger() > timestep)
@@ -265,7 +265,10 @@ public class SimulationManager extends Observable {
 	 *            duration in milliseconds of a step
 	 */
 	public void setStepDuration(long duration) {
-		this.duration = duration;
+		if(duration>0)
+			this.duration = duration;
+		else
+			this.duration = 1;
 		notifyPanels();
 	}
 

+ 4 - 2
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/popups/SimulationConfigurator.java

@@ -177,15 +177,16 @@ public class SimulationConfigurator extends JFrame implements Observer{
 		JButton btnEditAlgorithms = new JButton("Edit Algorithms");
 		btnEditAlgorithms.setBounds(250, 100, 180, 20);
 		getContentPane().add(btnEditAlgorithms);
+		btnEditAlgorithms.setToolTipText("Edit which user defined algorithms should run during the simulation.");
 		btnEditAlgorithms.addActionListener(a->{ 
 			new EditAlgorithmsPopUp(controller, that);
 			});
 
-		chckbxPrintpackets = new JCheckBox("print Packets");
+		chckbxPrintpackets = new JCheckBox("Save packets");
 		chckbxPrintpackets.setBounds(10, 130, 120, 20);
 		getContentPane().add(chckbxPrintpackets);
 		chckbxPrintpackets
-		.setToolTipText("Print Packets as human readable String to testPackets.log in the projekt folder.");
+		.setToolTipText("Save packets as human readable Strings to the configured File");
 		
 		chckbxSplitLinks = new JCheckBox("Split Links");
 		chckbxSplitLinks.setBounds(130, 130, 100, 20);
@@ -383,6 +384,7 @@ public class SimulationConfigurator extends JFrame implements Observer{
 				if(mutex)return;
 				try{
 					long l = Long.parseLong(tfStepDuration.getText());
+					if(l<=0)throw new NumberFormatException("Duration shall not be negative");
 					if(!sim.isRunning()){
 						mutex = true;
 						try{