mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-10-19 00:24:14 +00:00
added debugging output when positioner fails
This commit is contained in:
parent
9e9b712e5d
commit
8ddaf79361
@ -26,16 +26,17 @@
|
|||||||
* 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
|
||||||
*/
|
*/
|
||||||
@ -68,17 +69,30 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user