MainActivity.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2012 Google Inc.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
00005  * use this file except in compliance with the License. You may obtain a copy of
00006  * the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
00013  * License for the specific language governing permissions and limitations under
00014  * the License.
00015  */
00016 
00017 package org.ros.android.android_benchmarks;
00018 
00019 import android.os.Bundle;
00020 import org.ros.android.MessageCallable;
00021 import org.ros.android.RosActivity;
00022 import org.ros.android.view.RosTextView;
00023 import org.ros.node.NodeConfiguration;
00024 import org.ros.node.NodeMainExecutor;
00025 import org.ros.rosjava_benchmarks.MessagesBenchmark;
00026 
00030 public class MainActivity extends RosActivity {
00031 
00032   private RosTextView<std_msgs.String> rosTextView;
00033 
00034   public MainActivity() {
00035     super("Benchmarks", "Benchmarks");
00036   }
00037 
00038   @SuppressWarnings("unchecked")
00039   @Override
00040   public void onCreate(Bundle savedInstanceState) {
00041     super.onCreate(savedInstanceState);
00042     setContentView(R.layout.main);
00043     rosTextView = (RosTextView<std_msgs.String>) findViewById(R.id.text);
00044     rosTextView.setTopicName("status");
00045     rosTextView.setMessageType(std_msgs.String._TYPE);
00046     rosTextView.setMessageToStringCallable(new MessageCallable<String, std_msgs.String>() {
00047       @Override
00048       public String call(std_msgs.String message) {
00049         return message.getData();
00050       }
00051     });
00052   }
00053 
00054   @Override
00055   protected void init(NodeMainExecutor nodeMainExecutor) {
00056     NodeConfiguration nodeConfiguration = NodeConfiguration.newPrivate();
00057     nodeConfiguration.setMasterUri(getMasterUri());
00058     nodeMainExecutor.execute(rosTextView, nodeConfiguration);
00059     // TODO(damonkohler): Support launching different benchmarks via the UI.
00060     // nodeMainExecutor.execute(new PubsubBenchmark(), nodeConfiguration);
00061     // nodeMainExecutor.execute(new TransformBenchmark(), nodeConfiguration);
00062     nodeMainExecutor.execute(new MessagesBenchmark(), nodeConfiguration);
00063   }
00064 }


android_core
Author(s): Damon Kohler
autogenerated on Thu Aug 27 2015 12:11:33