mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-02-08 19:31:03 +00:00
added debugging output when positioner fails
This commit is contained in:
parent
9e9b712e5d
commit
8ddaf79361
@ -26,17 +26,18 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: Positioner.java,v 1.2 2007/01/10 14:57:42 fros4943 Exp $
|
* $Id: Positioner.java,v 1.3 2009/02/18 13:55:01 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A positioner is used for determining positions of newly created motes.
|
* A positioner is used for determining initial positions of motes.
|
||||||
*
|
*
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
public abstract class Positioner {
|
public abstract class Positioner {
|
||||||
@ -46,7 +47,7 @@ public abstract class Positioner {
|
|||||||
* This method creates an instance of the given class with the given interval
|
* This method creates an instance of the given class with the given interval
|
||||||
* information as constructor arguments. Instead of calling the constructors
|
* information as constructor arguments. Instead of calling the constructors
|
||||||
* directly this method may be used.
|
* directly this method may be used.
|
||||||
*
|
*
|
||||||
* @param positionerClass
|
* @param positionerClass
|
||||||
* Positioner class
|
* Positioner class
|
||||||
* @param totalNumberOfMotes
|
* @param totalNumberOfMotes
|
||||||
@ -68,24 +69,37 @@ public abstract class Positioner {
|
|||||||
*/
|
*/
|
||||||
public static final Positioner generateInterface(
|
public static final Positioner generateInterface(
|
||||||
Class<? extends Positioner> positionerClass, int totalNumberOfMotes,
|
Class<? extends Positioner> positionerClass, int totalNumberOfMotes,
|
||||||
double startX, double endX, double startY, double endY, double startZ,
|
double startX, double endX,
|
||||||
double endZ) {
|
double startY, double endY,
|
||||||
|
double startZ, double endZ) {
|
||||||
try {
|
try {
|
||||||
// Generating positioner
|
Constructor<? extends Positioner> constr =
|
||||||
Constructor constr = positionerClass.getConstructor(new Class[] {
|
positionerClass.getConstructor(new Class[] {
|
||||||
int.class, double.class, double.class, double.class, double.class,
|
int.class,
|
||||||
double.class, double.class });
|
double.class, double.class,
|
||||||
return (Positioner) constr.newInstance(new Object[] { totalNumberOfMotes,
|
double.class, double.class,
|
||||||
startX, endX, startY, endY, startZ, endZ });
|
double.class, double.class
|
||||||
|
});
|
||||||
|
return constr.newInstance(new Object[] {
|
||||||
|
totalNumberOfMotes,
|
||||||
|
startX, endX,
|
||||||
|
startY, endY,
|
||||||
|
startZ, endZ
|
||||||
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.fatal("Exception when creating " + positionerClass + ": " + e);
|
|
||||||
|
if (e instanceof InvocationTargetException) {
|
||||||
|
logger.fatal("Exception when creating " + positionerClass + ": " + e.getCause());
|
||||||
|
} else {
|
||||||
|
logger.fatal("Exception when creating " + positionerClass + ": " + e.getMessage());
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next mote position.
|
* Returns the next mote position.
|
||||||
*
|
*
|
||||||
* @return Position
|
* @return Position
|
||||||
*/
|
*/
|
||||||
public abstract double[] getNextPosition();
|
public abstract double[] getNextPosition();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user