Commit 6c4db32e authored by Julian Zobel's avatar Julian Zobel
Browse files

Merge remote-tracking branch 'origin/jz/integration' into jz/master

# Conflicts:
#	pom.xml
parents 6fc1b75b 9e3b2ede
......@@ -59,32 +59,7 @@
<updatePolicy>always</updatePolicy>
</releases>
</repository>
<!-- local kom repository -->
<!--
<repository>
<id>maven.kom</id>
<url>http://www.kom.tu-darmstadt.de/~stingl/PeerfactSim.KOM-Libraries/maven2/</url>
</repository> -->
<!-- -->
<!-- jgrapht can be found there -->
<!--
<repository>
<id>conjars.org</id>
<url>http://conjars.org/repo</url>
</repository>
-->
<!-- uk maven central, since the local central server is slow as hell -->
<!--
<repository>
<id>uk.maven.org</id>
<url>http://uk.maven.org/maven2</url>
</repository>
-->
<repository>
<id>Google Maven Central</id>
<url>https://maven-central.storage.googleapis.com/repos/central/data/</url>
......@@ -101,248 +76,144 @@
<dependencies>
<!-- XML -->
<!-- https://mvnrepository.com/artifact/javax.xml/jsr173 -->
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jsr173</artifactId>
<version>1.0</version>
</dependency>
<!-- XML -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>txw2</artifactId>
<version>3.0.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/stax/stax -->
<dependency>
<groupId>stax</groupId>
<artifactId>stax</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
<version>2.12.2</version>
</dependency>
<!-- SVG -->
<!-- XML Documents -->
<!-- https://mvnrepository.com/artifact/org.dom4j/dom4j -->
<dependency>
<groupId>batik</groupId>
<artifactId>batik-1.5-fop</artifactId>
<version>0.20-5</version>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
</dependency>
<!-- SVG -->
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop -->
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>2.7</version>
</dependency>
<!-- unused? <dependency> <groupId>batik</groupId> <artifactId>batik-parser</artifactId>
<version>1.5</version> </dependency> <dependency> <groupId>batik</groupId>
<artifactId>batik-awt-util</artifactId> <version>1.5</version> </dependency> -->
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<version>1.4</version>
</dependency>
<!-- Logging with Log4j -->
<version>4.13.2</version>
</dependency>
<!-- Logging with Log4j: Requires API and CORE -->
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
<version>2.19.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
<version>2.19.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<!-- Parsing, Bytecode, ... -->
<!-- Unused <dependency> <groupId>antlr</groupId> <artifactId>antlr</artifactId>
<version>2.7.6</version> </dependency> <dependency> <groupId>org.antlr</groupId>
<artifactId>antlr-runtime</artifactId> <version>3.2</version> </dependency>
<dependency> <groupId>javassist</groupId> <artifactId>javassist</artifactId>
<version>3.12.0.GA</version> </dependency> -->
<!-- Geometric calculations -->
<!-- deprecated
<dependency>
<groupId>com.vividsolutions</groupId>
<artifactId>jts</artifactId>
<version>1.12</version>
</dependency>
-->
<!-- Graphs -->
<!--
<dependency>
<groupId>thirdparty</groupId>
<artifactId>jgrapht-jdk1.6</artifactId>
<version>0.8.2</version>
</dependency>
-->
<!-- Graphs -->
<dependency>
<groupId>org.jgrapht</groupId>
<artifactId>jgrapht-core</artifactId>
<version>1.5.0</version>
<version>1.5.1</version>
</dependency>
<!-- Chart creation -->
<!-- unused? <dependency> <groupId>jfree</groupId> <artifactId>jcommon</artifactId>
<version>1.0.16</version> </dependency> -->
<!-- Chart creation -->
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.19</version>
<version>1.5.3</version>
</dependency>
<!-- Database -->
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.14</version>
<version>8.0.30</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.10.Final</version>
<version>6.1.3.Final</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.7.2</version>
</dependency>
<!-- Glab Database -->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.9</version>
</dependency>
<!-- Dependencies and convenience libraries -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
<version>31.1-jre</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.inject/guice -->
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.1</version>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>5.1.0</version>
</dependency>
<!-- SimCfg, Xtext, EMF dependencies -->
<!-- unused <dependency> <groupId>org.eclipse</groupId> <artifactId>xtext</artifactId>
<version>2.3.0</version> </dependency> <dependency> <groupId>org.eclipse</groupId>
<artifactId>xtext.util</artifactId> <version>2.3.0</version> </dependency>
<dependency> <groupId>org.eclipse.emf</groupId> <artifactId>ecore</artifactId>
<version>2.8.1</version> </dependency> <dependency> <groupId>org.eclipse.emf</groupId>
<artifactId>ecore.xmi</artifactId> <version>2.8.0</version> </dependency>
<dependency> <groupId>org.eclipse.emf</groupId> <artifactId>ecore.xmi</artifactId>
<version>2.8.0</version> </dependency> <dependency> <groupId>org.eclipse.emf</groupId>
<artifactId>common</artifactId> <version>2.8.0</version> </dependency> <dependency>
<groupId>org.eclipse</groupId> <artifactId>xtext.common.types</artifactId>
<version>2.3.0</version> </dependency> <dependency> <groupId>org.eclipse</groupId>
<artifactId>xtext.util</artifactId> <version>2.3.0</version> </dependency>
<dependency> <groupId>org.eclipse.emf</groupId> <artifactId>mwe2.runtime</artifactId>
<version>2.3.0</version> </dependency> <dependency> <groupId>org.eclipse.emf</groupId>
<artifactId>mwe.core</artifactId> <version>1.2.1</version> </dependency>
<dependency> <groupId>org.eclipse.emf</groupId> <artifactId>mwe.utils</artifactId>
<version>1.2.1</version> </dependency> -->
<!-- Math -->
<!-- https://mvnrepository.com/artifact/ca.umontreal.iro.simul/ssj -->
<!-- https://mvnrepository.com/artifact/commons-net/commons-net -->
<dependency>
<groupId>ca.umontreal.iro.simul</groupId>
<artifactId>ssj</artifactId>
<version>3.3.1</version>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.8.0</version>
</dependency>
<!-- Date & Time calculations -->
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.1</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<!-- Other dependencies -->
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-compress -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.21</version>
</dependency>
<!-- unused <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId>
<version>1.0.4</version> </dependency> <dependency> <groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId> <version>1.2</version> </dependency>
<dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId>
<version>2.1</version> </dependency> -->
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<!-- Math -->
<!-- https://mvnrepository.com/artifact/ca.umontreal.iro.simul/ssj -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.4.1</version>
<groupId>ca.umontreal.iro.simul</groupId>
<artifactId>ssj</artifactId>
<version>3.3.2</version>
</dependency>
<!-- <dependency> <groupId>com.baulsupp.kolja</groupId> <artifactId>jcurses</artifactId>
<version>0.9.5.3</version> </dependency> -->
<!-- Geodemlia -->
<!-- unused <dependency> <groupId>org.swinglabs</groupId> <artifactId>jxmapviewer</artifactId>
<version>1.0</version> </dependency> <dependency> <groupId>org.swinglabs</groupId>
<artifactId>swingx</artifactId> <version>1.6.1</version> </dependency> -->
<!-- JUNG Graph Library -->
<!-- unused<dependency> <groupId>net.sf.jung</groupId> <artifactId>jung2</artifactId>
<version>2.0.1</version> <type>pom</type> </dependency> -->
<dependency>
<groupId>net.sf.jung</groupId>
<artifactId>jung-api</artifactId>
<version>2.0.1</version>
</dependency>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>net.sf.jung</groupId>
<artifactId>jung-graph-impl</artifactId>
......@@ -358,41 +229,23 @@
<artifactId>jung-io</artifactId>
<version>2.0.1</version>
</dependency>
<!-- unused <dependency> <groupId>net.sf.jung</groupId> <artifactId>jung-visualization</artifactId>
<version>2.0.1</version> </dependency> <dependency> <groupId>net.sf.jung</groupId>
<artifactId>jung-samples</artifactId> <version>2.0.1</version> </dependency> -->
<!-- OSM-Data for movement models -->
<!--
<dependency>
<groupId>com.graphhopper</groupId>
<artifactId>graphhopper</artifactId>
<version>0.8.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
-->
<!-- Routing and navigation -->
<!-- https://mvnrepository.com/artifact/com.graphhopper/graphhopper-core -->
<dependency>
<groupId>com.graphhopper</groupId>
<artifactId>graphhopper-core</artifactId>
<version>0.13.0</version>
<version>6.0</version>
</dependency>
<!-- JSON in Java -->
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>com.graphhopper</groupId>
<artifactId>graphhopper-reader-osm</artifactId>
<version>0.13.0</version>
</dependency>
<!-- Json (used for OSM-Movement-Model) -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220924</version>
</dependency>
......@@ -402,14 +255,6 @@
<artifactId>simonstrator-api</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Traci as a Service -->
<dependency>
<groupId>maki</groupId>
<artifactId>simonstrator-traci</artifactId>
<version>0.2-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
......@@ -22,12 +22,11 @@ package de.tud.kom.p2psim.api.topology.component;
import java.util.LinkedList;
import de.tud.kom.p2psim.impl.topology.component.BaseTopologyComponent;
import de.tud.kom.p2psim.impl.topology.placement.UAVBasePlacement;
import de.tud.kom.p2psim.impl.topology.component.UAVTopologyComponent.UAVstate;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.LocationSensor;
import de.tudarmstadt.maki.simonstrator.api.uavsupport.Actuator;
import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BaseConnectedCallback;
import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BaseDisconnectedCallback;
import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BaseConnectionCallback;
import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BatteryReplacementCallback;
import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.ReachedLocationCallback;
......@@ -39,13 +38,15 @@ import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.ReachedLocation
* @author Julian Zobel
*
*/
public interface ControllableLocationActuator extends Actuator {
public interface ControllableLocationActuator extends Actuator, LocationSensor {
public boolean isActive();
public boolean activate();
public boolean deactivate();
public UAVstate getState();
public PositionVector getCurrentLocation();
......@@ -70,16 +71,16 @@ public interface ControllableLocationActuator extends Actuator {
public void setTargetLocationRoute(LinkedList<PositionVector> route, ReachedLocationCallback cb);
public void removeAllTargetLocations();
public void batteryReplacement(BatteryReplacementCallback cb);
public void returnToBase(ReachedLocationCallback cb);
public void connectToBase(BaseConnectedCallback cb);
public void batteryReplacement(BatteryReplacementCallback cb);
public void returnToBase(double velocity, ReachedLocationCallback cb);
public void disconnectFromBase(BaseDisconnectedCallback cb);
public boolean landAtBase(BaseConnectionCallback cb);
public boolean startFromBase(ReachedLocationCallback cb);
public void setMovementSpeed(double speed);
public void setMovementSpeed(double velocity);
public double getMinMovementSpeed();
......@@ -89,5 +90,14 @@ public interface ControllableLocationActuator extends Actuator {
public double estimatePowerConsumptionWatt(double velocity);
public double estimateFlightDistance(double velocity, double batterylevel, double batterythreshold);
/**
*
* @param velocity
* @param batterylevel [0.0, 1.0]
* @param batterythreshold [0.0, 1.0]
* @return
*/
public double estimateFlightDistance(double velocity, double batterylevel, double batterythreshold);
public double getOptimalMovementSpeed();
}
......@@ -21,8 +21,6 @@
package de.tud.kom.p2psim.api.topology.movement;
import de.tud.kom.p2psim.api.topology.component.ControllableLocationActuator;
import de.tud.kom.p2psim.impl.energy.components.StatefulActuatorComponent;
import de.tud.kom.p2psim.impl.energy.components.StatelessActuatorComponent;
public interface SimUAVLocationActuator extends SimLocationActuator, ControllableLocationActuator {
......
......@@ -32,11 +32,7 @@ import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.ReachedLocation
* @version 1.0, 20.01.2020
*/
public interface UAVMovementModel {
// NO - NO CHANGY
public final double AIRDENSITY = 1.2045; // kg/m^3
public final double GRAVITY = 9.807; // m/s^2
public void setMotorControl(ActuatorComponent motor);
/**
......@@ -45,18 +41,9 @@ public interface UAVMovementModel {
* @param targetVelocity
*/
public void setTargetVelocity(double targetVelocity);
public double getVerticalAscentMaxVelocity();
public double getHorizontalMaxVelocity();
public double getCurrentVelocity();
public double getHorizontalMinVelocity();
/**
* Estimate the power consumption for a given velocity
* @param velocity
* @return The power consumption in W for the given velocity.
*/
public double estimatePowerConsumptionWatt(double velocity);
public double getMinimumVelocity();
public double getMaximumVelocity();
public void move(long timeBetweenMovementOperations);
......@@ -72,4 +59,9 @@ public interface UAVMovementModel {
public LinkedList<PositionVector> getTargetLocations();
public void removeTargetLocations();
public double powerConsumptionWatt(double velocity);
public double optimalSpeed();
}
......@@ -22,7 +22,7 @@ package de.tud.kom.p2psim.api.topology.obstacles;
import java.util.List;
import com.vividsolutions.jts.geom.Geometry;
import org.locationtech.jts.geom.Geometry;
import de.tud.kom.p2psim.api.topology.views.TopologyView;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
......
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.api.uav;
import de.tud.kom.p2psim.impl.energy.components.ActuatorComponent;
/**
* Interface for thrust/acceleration-based UAV models. Multicopter!
*
* @author Julian Zobel
* @version 1.0, 19.01.2022
*/
public interface MulticopterModel {
// NO - NO CHANGY
public final double AIRDENSITY = 1.2045; // kg/m^3
public final double GRAVITY = 9.807; // m/s^2
/**
* Query if the multicopter's motors are active and usable.
*
* @return
*/
public boolean isOn();
/**
* Maximum provided thrust by the multicopter motors (full throttle, maximum rotation).
*
* @return
*/
public double maxThrust();
/**
* Minimum provided thrust by the multicopter motors (idle, minimum rotation)
*
* @return
*/
public double minThrust();
/**
* Thrust requires to hold the multicopter on a stable level in the air.
*
* @return
*/
public double hoverThrust();
/**
* Thrust required for a certain horizontal velocity. Includes vertical thrust component.
*
* @param velocity
* @return
*/
public double thrustForHorizontalVelocity(double velocity);
/**
* Thrust required for the maximum possible horizontal velocity. Includes vertical
* thrust component.
*
* @return
*/
public double thrustForHorizontalMaxVelocity();
/**
* Thrust required for a controlled vertical descent.
*
* @param velocity
* @return
*/
public double verticalDescentThrust(double velocity);
/**
* Thrust required for vertical ascent.
*
* @param velocity
* @return
*/
public double verticalAscentThrust(double velocity);
/**
* Optimal horizontal speed of the multicopter w.r.t. energy consumption.
* @return
*/
public double optimalSpeed();
/**
* Maximum horizontal velocity.
* @return
*/
public double horizontalMaxVelocity();
/**
* Minimum horizontal velocity.
* @return
*/
public double horizontalMinVelocity();
/**
* Maximum velocity for vertical ascent.
* @return
*/
public double verticalAscentMaxVelocity();
/**
* Maximum velocity for vertical descent.
* @return
*/
public double verticalDescentMaxVelocity();
/**
* Optimal velocity when flying a curve.
* @return
*/
public double curveVelocity();
/**
* Maximum acceleration for horizontal flight.
* @return
*/
public double horizontalMaxAcceleration();
/**
* Maximum deceleration in horizontal flight.
* @return
*/
public double horizontalMaxDeceleration();
/**
* Maximum acceleration for vertical descent.
* @return
*/
public double verticalDescentMaxAcceleration();
/**
* Maximum acceleration for vertical ascent.
* @return
*/
public double verticalAscentMaxAcceleration();
/**
* Maximum turn angle (rad per second), that the multicopter can change its facing while hovering.
* @return
*/
public double getMaximumTurnAngle();
/**
* The radius of the curve/circle the multicopter can fly with a given velocity.
* @param curveVelocity
* @return
*/
public double getCurveRadius(double curveVelocity);
/**
* The acceleration, the multicopter is subject to when flying a curve/in a circle with a given velocity.
* @param curveVelocity
* @return
*/
public double getCurveCentripedalAcceleration(double curveVelocity);
/**
* Pitch angle (Angle of attack) required to achieve a given velocity.
* @param velocity
* @return
*/
public double pitchAngleForHorizontalVelocity(double velocity);
/**
* Power consumption in watt, when flying a given velocity.
* @param velocity
* @return
*/
public double powerConsumptionWatt(double velocity);
/**
* Sets the actuator of the multicopter.
* @param motor
*/
public void setMotor(ActuatorComponent motor);
/**
* Puts load on the multicopter's motors for a given phase time, such that the
* given thrust is provided within that time.
*
* @param thrust
* @param phaseTime
*/
public void thrust(double thrust, long phaseTime);
/**
* Hacky factory interface for multicopter model factories.
*
* @author Julian Zobel
* @version 1.0, 20.01.2022
*/
public interface Factory {
public MulticopterModel createComponent();
}
}
......@@ -207,7 +207,7 @@ public class DefaultHost implements SimHost {
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("Host {");
sb.append("Host " + this.getId().value() +" {");
sb.append("GroupID=");
if (this.properties != null)
sb.append(this.properties.getGroupID());
......
......@@ -29,11 +29,13 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.tud.kom.p2psim.api.simengine.SimulatorObserver;
import de.tud.kom.p2psim.impl.simengine.Simulator;
import de.tud.kom.p2psim.impl.util.db.dao.DAO;
import de.tud.kom.p2psim.impl.util.db.dao.metric.ExperimentDAO;
import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.Monitor;
......@@ -94,7 +96,7 @@ public class DefaultMonitor implements MonitorComponent, EventHandler,
public void log(Class<?> subject, Level level, String msg, Object... data) {
Logger log = loggers.get(subject);
if (log == null) {
log = Logger.getLogger(subject);
log = LogManager.getLogger(subject);
loggers.put(subject, log);
}
switch (level) {
......@@ -208,14 +210,20 @@ public class DefaultMonitor implements MonitorComponent, EventHandler,
public void close() {
if (this.isMonitoring && analyzers.size() != 0) {
try {
output.write("*******************************************************\n");
output.write("# Monitoring results \n");
output.newLine();
output.write(Time.getFormattedTime() + ": DefaultMonitor closing, stop all analyzers.. \n");
for (Analyzer analyzer : analyzers) {
analyzer.stop(output);
}
output.write("*******************************************************\n");
output.close();
output.write("[DefaultMonitor] Stopped. \n");
String wl = ExperimentDAO.getExperimentWorkload();
if(wl != null) {
output.write("-- Workload -- \n");
output.write(wl + " \n");
output.write("---- \n");
}
//output.close();
} catch (IOException e) {
throw new AssertionError();
}
......@@ -230,10 +238,18 @@ public class DefaultMonitor implements MonitorComponent, EventHandler,
for (Analyzer analyzer : analyzers) {
analyzer.start();
}
try {
output.write("[DefaultMonitor] started, initialized all analyzers.. \n");
} catch (IOException e) {
throw new AssertionError();
}
} else if (type == MONITOR_TEST) {
//
} else if (type == MONITOR_STOP) {
this.close();
// this.close();
} else {
throw new AssertionError("Unknown event type.");
}
......
......@@ -43,7 +43,7 @@ public class StatefulActuatorComponent implements ActuatorComponent {
*
* TODO More states reflecting a more accurate energy consumption?
*/
public final EnergyState OFF, FLY, MAX;
public final EnergyState OFF, HOVER, MIN, MAX;
private EnergyState currentState;
......@@ -53,9 +53,10 @@ public class StatefulActuatorComponent implements ActuatorComponent {
private double actuatorLoad;
public StatefulActuatorComponent(int numberOfActuators, double volt, double hoverAmp, double maxAmp) {
public StatefulActuatorComponent(int numberOfActuators, double volt, double hoverAmp, double minAmp, double maxAmp) {
OFF = new DefaultEnergyState("OFF", 0);
FLY = new DefaultEnergyState("FLY", numberOfActuators * (hoverAmp * volt) * Battery.uJconverison);
HOVER = new DefaultEnergyState("HOVER", numberOfActuators * (hoverAmp * volt) * Battery.uJconverison);
MIN = new DefaultEnergyState("MIN", numberOfActuators * (minAmp * volt) * Battery.uJconverison);
MAX = new DefaultEnergyState("MAX", numberOfActuators * (maxAmp * volt) * Battery.uJconverison);
this.currentState = OFF;
......@@ -74,9 +75,16 @@ public class StatefulActuatorComponent implements ActuatorComponent {
@Override
public double calculateEnergyConsumation(EnergyState state, long timeInState) {
if(state.equals(FLY)) {
double consumationDelta = MAX.getEnergyConsumption() - FLY.getEnergyConsumption();
double consumation = FLY.getEnergyConsumption() + consumationDelta * actuatorLoad;
if(state.equals(HOVER)) {
return HOVER.getEnergyConsumption() * ( (double) timeInState / (double) Time.SECOND);
}
else if(state.equals(MIN)) {
double consumationDelta = MAX.getEnergyConsumption() - MIN.getEnergyConsumption();
double consumation = MIN.getEnergyConsumption() + consumationDelta * actuatorLoad;
return consumation * ( (double) timeInState / (double) Time.SECOND);
}
else if(state.equals(MAX)) {
double consumation = 0.5 * MAX.getEnergyConsumption() + MAX.getEnergyConsumption() * actuatorLoad;
return consumation * ( (double) timeInState / (double) Time.SECOND);
}
else
......@@ -84,12 +92,20 @@ public class StatefulActuatorComponent implements ActuatorComponent {
}
public void useActuator(double load) {
if(load < 0 || load > 1.0) {
throw new AssertionError("Actuator load must be between 0 and 1!");
}
else {
if(load < 0) {
throw new AssertionError("Actuator load cannot be < 0.0!");
}
else {
this.actuatorLoad = load;
doStateChange(FLY);
if(load == 0) {
doStateChange(HOVER);
}
else if(load <= 1.0) {
doStateChange(MIN);
}
else if(load > 1.0) {
doStateChange(MAX);
}
}
}
......@@ -99,8 +115,20 @@ public class StatefulActuatorComponent implements ActuatorComponent {
* @return Energy consumption in J/s
*/
public double estimateEnergyConsumptionWatt(double load) {
double consumationDelta = MAX.getEnergyConsumption() - FLY.getEnergyConsumption();
double estimation = FLY.getEnergyConsumption() + consumationDelta * load;
double estimation = -1;
if(load == 0) {
estimation = HOVER.getEnergyConsumption();
}
else if(load <= 1.0) {
double consumationDelta = MAX.getEnergyConsumption() - MIN.getEnergyConsumption();
estimation = MIN.getEnergyConsumption() + consumationDelta * load;
}
else if(load > 1.0) {
estimation = 0.5 * MAX.getEnergyConsumption() + MAX.getEnergyConsumption() * load;
}
// System.out.println("MAX " + ((MAX.getEnergyConsumption() / 14.8) / Battery.uJconverison));
// System.out.println("MIN" + ((FLY.getEnergyConsumption() / 14.8) / Battery.uJconverison));
......@@ -129,7 +157,7 @@ public class StatefulActuatorComponent implements ActuatorComponent {
public boolean turnOn() {
if (isAvailable()) {
if (currentState.equals(OFF)) {
doStateChange(FLY);
doStateChange(MIN);
}
return true;
}
......
......@@ -47,7 +47,7 @@ public class StatelessActuatorComponent implements ActuatorComponent {
private EnergyEventListener energyModel;
private long lastEnergyConsumationTime;
//private long lastEnergyConsumationTime;
private double volts;
private final double uJconversionFactor = 1000000;
......@@ -63,7 +63,7 @@ public class StatelessActuatorComponent implements ActuatorComponent {
this.volts = volt;
this.numberOfActuators = numberOfActuators;
this.state = componentState.OFF;
this.lastEnergyConsumationTime = Time.getCurrentTime();
//this.lastEnergyConsumationTime = Time.getCurrentTime();
thrust = 0;
amps = 0;
......@@ -78,10 +78,18 @@ public class StatelessActuatorComponent implements ActuatorComponent {
return characteristics.getLast().getThrust() * numberOfActuators;
}
/**
* Get the minimum thrust probided by this component. (idle)
* @return
*/
public double getMinThrust() {
return characteristics.getFirst().getThrust() * numberOfActuators;
}
/**
* Set the new energy state and calculate the energy consumption from the last state
*/
private void setEnergyState() {
private void setEnergyState(long stateDuration) {
// set the new energy state
EnergyState newState;
......@@ -94,25 +102,26 @@ public class StatelessActuatorComponent implements ActuatorComponent {
}
// calculate energy consumption for the previous state
long timeSpentInState = Time.getCurrentTime() - lastEnergyConsumationTime;
//long timeSpentInState = Time.getCurrentTime() - lastEnergyConsumationTime;
double cons = calculateEnergyConsumation(energyState, timeSpentInState);
double cons = calculateEnergyConsumation(energyState, stateDuration);
energyModel.componentConsumedEnergy(this, cons);
// set new state
energyState = newState;
lastEnergyConsumationTime = Time.getCurrentTime();
//lastEnergyConsumationTime = Time.getCurrentTime();
}
/**
* Request a given amount of thrust to be provided from this component. If the amount is less than the minimum
* or more than the maximum, the minimum or maximum thrust values, respectively, are enforced.
*
* @param targetThrust
* @param targetThrust Requested Thrust
* @param thrustDuration Time the thrust is needed
* @return The amount of thrust this component now generates.
*/
public double requestThrust(double targetThrust) {
public double requestThrust(double targetThrust, long thrustDuration) {
if(targetThrust == 0 || targetThrust <= numberOfActuators * characteristics.getFirst().getThrust()) {
setLoad(characteristics.getFirst());
......@@ -124,6 +133,18 @@ public class StatelessActuatorComponent implements ActuatorComponent {
calculateAndSetThrustRelatedAmpereDraw(targetThrust);
}
this.setEnergyState(thrustDuration);
return this.thrust;
}
/**
* Request the current thrust for a certain time.
* @param thrustDuration
* @return
*/
public double requestThrust(long thrustDuration) {
this.setEnergyState(thrustDuration);
return this.thrust;
}
......@@ -212,13 +233,11 @@ public class StatelessActuatorComponent implements ActuatorComponent {
private void setLoad(double thrust, double amps) {
this.thrust = thrust;
this.amps = amps;
setEnergyState();
}
private void setLoad(MotorCharacteristic ch) {
this.thrust = ch.getThrust();
this.amps = ch.getCurrent();
setEnergyState();
this.amps = ch.getCurrent();
}
/**
......@@ -258,7 +277,7 @@ public class StatelessActuatorComponent implements ActuatorComponent {
this.thrust = 0;
this.amps = 0;
this.state = componentState.OFF;
setEnergyState();
setEnergyState(0);
return true;
}
......@@ -268,7 +287,7 @@ public class StatelessActuatorComponent implements ActuatorComponent {
if (isAvailable()) {
if(this.state != componentState.ON) {
this.state = componentState.ON;
requestThrust(0);
requestThrust(0, 0);
}
return true;
}
......
......@@ -35,11 +35,12 @@ public class StatefulActuatorConfiguration implements EnergyConfiguration<Statef
private int numberOfActuators;
private double volt;
private double hoverAmp; // in ampere
private double flyAmp; // in ampere
private double minAmp; // in ampere
private double maxAmp; // in ampere
@Override
public StatefulActuatorComponent getConfiguredEnergyComponent(SimHost host) {
return new StatefulActuatorComponent(numberOfActuators, volt, hoverAmp, flyAmp);
return new StatefulActuatorComponent(numberOfActuators, volt, hoverAmp, minAmp, maxAmp);
}
@Override
......@@ -50,7 +51,7 @@ public class StatefulActuatorConfiguration implements EnergyConfiguration<Statef
@Override
public boolean isWellConfigured() {
if(numberOfActuators >= 1 && volt > 0
&& hoverAmp > 0 && flyAmp > 0)
&& hoverAmp > 0 && minAmp > 0 && maxAmp > 0)
return true;
return false;
......@@ -64,8 +65,12 @@ public class StatefulActuatorConfiguration implements EnergyConfiguration<Statef
this.hoverAmp = ampereHovering;
}
public void setFlyAmp(double ampereFlying) {
this.flyAmp = ampereFlying;
public void setMinAmp(double minamp) {
this.minAmp = minamp;
}
public void setMaxAmp(double maxamp) {
this.maxAmp = maxamp;
}
public void setVolt(double voltage) {
......
......@@ -50,6 +50,7 @@ import de.tud.kom.p2psim.impl.util.LiveMonitoring.ProgressValue;
import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.Message;
import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Monitor.Level;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.core.MonitorComponent.AnalyzerNotAvailableException;
......@@ -249,15 +250,15 @@ public abstract class AbstractMacLayer implements MacLayer {
for (EnergyCommunicationComponent comp : energyComponents) {
if (comp.getPhyType().equals(phy)) {
energyComponent = comp;
break;
}
}
}
if (energyComponent == null) {
// Log.warn("The MAC-Layer did not find an Energy-Component for "
// + phy.toString()
// +
// ". This is fine, if you did not intend to measure energy consumption. Otherwise, please check your configuration!");
if (energyComponent == null) {
Monitor.log(getClass(), Level.INFO, "The MAC-Layer did not find an Energy-Component for "
+ phy.toString() + ". This is fine, if you did not intend to measure energy consumption. "
+ "Otherwise, please check your configuration!", "");
energyComponent = new EnergyComponentStub(phy);
}
......
......@@ -232,7 +232,7 @@ public class DefaultConfigurator implements Configurator {
*/
}
factory.setNamespaceAware(false);
factory.setNamespaceAware(true);
factory.setValidating(false);
SAXParser parser = factory.newSAXParser();
......@@ -867,10 +867,13 @@ public class DefaultConfigurator implements Configurator {
@SuppressWarnings("unchecked")
public static <T extends Number> T parseNumber(String value,
Class<T> targetClass) {
assert value != null;
//assert value != null;
if(value == null)
System.out.println("");
if(value == null) {
System.out.println(targetClass);
throw new UnsupportedOperationException("[DefaultConfigurator]: value cannot be null! " );
}
String number = value;
double factor = 1;
......
......@@ -28,7 +28,6 @@ import de.tud.kom.p2psim.impl.scenario.simcfg2.configuration.beans.Value;
import de.tud.kom.p2psim.impl.scenario.simcfg2.configuration.beans.Variation;
import de.tud.kom.p2psim.impl.scenario.simcfg2.utils.SimCfgUtil;
import de.tud.kom.p2psim.impl.util.Tuple;
import org.apache.commons.lang.StringUtils;
import java.io.File;
import java.util.Collection;
......
......@@ -75,7 +75,7 @@ public class SimCfgFileParser {
}
private File extractImportedFile(String filename, File relativeFile) {
String importedFile = CharMatcher.WHITESPACE.and(CharMatcher.JAVA_ISO_CONTROL).removeFrom(filename);
String importedFile = CharMatcher.whitespace().and(CharMatcher.javaIsoControl()).removeFrom(filename);
if (importedFile.contains("~")) {
return new File(importedFile.replace("~", "config"));
......
......@@ -20,7 +20,9 @@
package de.tud.kom.p2psim.impl.scenario.simcfg2.utils;
import de.tud.kom.p2psim.impl.scenario.simcfg2.configuration.SimCfgConfiguration;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.script.*;
import java.util.Map;
......@@ -30,7 +32,7 @@ import java.util.Map;
* @version 1.0, 12.07.13
*/
public class SimCfgExpressionExecutor {
private static final Logger log = Logger.getLogger(SimCfgExpressionExecutor.class);
private static final Logger log = LogManager.getLogger(SimCfgExpressionExecutor.class);
private ScriptEngine javascriptEngine = null;
public SimCfgExpressionExecutor() {
......
......@@ -32,7 +32,7 @@ import de.tud.kom.p2psim.impl.scenario.simcfg2.annotations.Configure;
import de.tud.kom.p2psim.impl.scenario.simcfg2.annotations.UnknownSetting;
import de.tud.kom.p2psim.impl.scenario.simcfg2.configuration.beans.Value;
import de.tud.kom.p2psim.impl.util.Tuple;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
/**
* Contains a some convenience methods used by the SimCfgConfigurator and
......
......@@ -252,18 +252,21 @@ public class Simulator implements RandomGeneratorComponent, GlobalComponent {
this.running = false;
if (finishedWithoutError) {
Monitor.log(Simulator.class, Level.INFO,
"Simulation successfully finished :)");
"Simulation successfully finished :)");
System.out.println("Simulation successfully finished");
} else {
if(reason == null) {
Monitor.log(Simulator.class, Level.ERROR,
"Simulation finished with unresolved errors ???");
System.out.println("Simulation finished with unresolved errors ???");
}
else {
Monitor.log(Simulator.class, Level.ERROR,
"Simulation finished with errors :( \n " +
reason.toString() + " : " + reason.getStackTrace());
}
System.out.println("Simulation finished with errors :( \n " +
reason.toString() + " : " + reason.getStackTrace());
}
}
long runTime = System.currentTimeMillis() - startTime;
long minutes = (long) Math.floor((runTime) / 60000);
......@@ -288,8 +291,12 @@ public class Simulator implements RandomGeneratorComponent, GlobalComponent {
for (SimulatorObserver so : observers) {
so.simulationFinished();
}
ExperimentDAO.simulationFinished();
ExperimentDAO.simulationFinished(finishedWithoutError);
// FIXME Hack?
// closing the monitor before also closes the stream and makes it impossible to track erros on simulation termination
DefaultMonitor.getInstance().close();
}
/**
......
......@@ -58,13 +58,14 @@ import de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.N
* Abstract implementation of the topology component interface, to support basic
* functionalities to all topology components.
*
* @author Julian Zobel
* @author Julian Zobel, others before
* @version 1.0, 6 Sep 2018
*/
public abstract class AbstractTopologyComponent implements TopologyComponent {
protected SimHost host;
protected final PositionVector position;
protected final Double POSITION_REQUEST_UPDATE_ACCURACY = 0.1; // accuracy for location request updates
protected Topology topology;
protected MovementModel movementModel;
......@@ -196,6 +197,7 @@ public abstract class AbstractTopologyComponent implements TopologyComponent {
return host;
}
@Deprecated
@Override
public Topology getTopology() {
return topology;
......@@ -224,12 +226,21 @@ public abstract class AbstractTopologyComponent implements TopologyComponent {
}
@Override
public void updateCurrentLocation(Location location) {
position.set(location);
public void updateCurrentLocation(Location location) {
for (LocationListener locationListener : listeners) {
locationListener.onLocationChanged(getHost(), getLastLocation());
boolean informListeners = false;
// only inform listeners if the location has changed
if(location.distanceTo(position) >= POSITION_REQUEST_UPDATE_ACCURACY) {
informListeners = true;
}
position.set(location);
if(informListeners) {
for (LocationListener locationListener : listeners) {
locationListener.onLocationChanged(getHost(), getLastLocation());
}
}
}
@Override
......
......@@ -32,8 +32,6 @@ import de.tud.kom.p2psim.api.topology.placement.PlacementModel;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
/**
* Default implementation of a {@link TopologyComponent}.
*
......@@ -100,18 +98,16 @@ public class DefaultTopologyComponent extends AbstractTopologyComponent {
@Override
public double getMovementSpeed() {
try {
if (currentMovementSpeed == -1) {
this.currentMovementSpeed = movementModel.getMovementSpeedDistribution().calculateSpeed();
}
this.currentMovementSpeed = movementModel.getMovementSpeedDistribution().calculateSpeed();
}
}
catch (UnsupportedOperationException e) {
if (currentMovementSpeed == -1) {
calcRandomMovementSpeed();
}
calcRandomMovementSpeed();
}
return this.currentMovementSpeed;
}
......@@ -135,8 +131,7 @@ public class DefaultTopologyComponent extends AbstractTopologyComponent {
public Set<IAttractionPoint> getAllAttractionPoints() {
return movementModel.getAllAttractionPoints();
}
public static class Factory implements TopologyComponentFactory {
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment