MockNode.java
Go to the documentation of this file.
00001 package org.ros.dynamic_reconfigure.test.reference;
00002 
00003 import org.ros.dynamic_reconfigure.server.Server;
00004 import org.ros.dynamic_reconfigure.server.Server.ReconfigureListener;
00005 import org.ros.namespace.GraphName;
00006 import org.ros.node.AbstractNodeMain;
00007 import org.ros.node.ConnectedNode;
00008 import org.ros.node.Node;
00009 
00010 public class MockNode extends AbstractNodeMain implements ReconfigureListener<AllTestConfig> {
00011 
00012     private Server<AllTestConfig> serverReconfig;
00013     private AllTestConfig configuration;
00014     private ConnectedNode connectedNode;
00015 
00016     @Override
00017     public void onStart(final ConnectedNode connectedNode) {
00018         super.onStart(connectedNode);
00019         this.connectedNode = connectedNode;
00020 
00021         this.configuration = new AllTestConfig(this.connectedNode);
00022         this.serverReconfig = new Server<AllTestConfig>(
00023                 this.connectedNode,
00024                 this.configuration,
00025                 this);
00026 
00027         this.logI(String.format("Start %s node...", this.getClass().getSimpleName()));
00028     }
00029 
00030     @Override
00031     public void onShutdown(Node node) {
00032         this.logI("Stop node !");
00033 
00034         if (this.serverReconfig != null)
00035             this.serverReconfig.close();
00036 
00037         super.onShutdown(node);
00038         this.connectedNode = null;
00039     }
00040 
00044     @Override
00045     public void onError(Node node, Throwable throwable) {
00046         super.onError(node, throwable);
00047         this.logE(throwable.getMessage());
00048     }
00049 
00050     @Override
00051     public GraphName getDefaultNodeName() {
00052         return GraphName.of(this.getClass().getSimpleName());
00053     }
00054 
00055     @Override
00056     public AllTestConfig onReconfigure(AllTestConfig config, int level) {
00057         return config;
00058     }
00059 
00060  // Log assessors
00065     public void logD(final Object message) {
00066         this.connectedNode.getLog().debug(message);
00067     }
00068 
00073     public void logI(final Object message) {
00074         this.connectedNode.getLog().info(message);
00075     }
00076 
00081     public void logE(final Object message) {
00082         this.connectedNode.getLog().error(message);
00083     }
00084 
00089     public void logE(final Exception message) {
00090         this.connectedNode.getLog().error(message.getStackTrace());
00091     }
00092 }


rosjava_dynamic_reconfigure
Author(s): Mickaƫl Gaillard , Erwan Le Huitouze
autogenerated on Thu Jun 6 2019 22:01:52