Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 package org.ros;
00018
00019 import com.google.common.annotations.VisibleForTesting;
00020
00021 import org.ros.address.AdvertiseAddress;
00022 import org.ros.address.BindAddress;
00023 import org.ros.internal.node.server.master.MasterServer;
00024
00025 import java.net.URI;
00026 import java.util.concurrent.TimeUnit;
00027
00028
00039 public class RosCore {
00040
00041 private final MasterServer masterServer;
00042
00043 public static RosCore newPublic(String host, int port) {
00044 return new RosCore(BindAddress.newPublic(port), new AdvertiseAddress(host));
00045 }
00046
00047 public static RosCore newPublic(int port) {
00048 return new RosCore(BindAddress.newPublic(port), AdvertiseAddress.newPublic());
00049 }
00050
00051 public static RosCore newPublic() {
00052 return new RosCore(BindAddress.newPublic(), AdvertiseAddress.newPublic());
00053 }
00054
00055 public static RosCore newPrivate(int port) {
00056 return new RosCore(BindAddress.newPrivate(port), AdvertiseAddress.newPrivate());
00057 }
00058
00059 public static RosCore newPrivate() {
00060 return new RosCore(BindAddress.newPrivate(), AdvertiseAddress.newPrivate());
00061 }
00062
00063 private RosCore(BindAddress bindAddress, AdvertiseAddress advertiseAddress) {
00064 masterServer = new MasterServer(bindAddress, advertiseAddress);
00065 }
00066
00067 public void start() {
00068 masterServer.start();
00069 }
00070
00071 public URI getUri() {
00072 return masterServer.getUri();
00073 }
00074
00075 public void awaitStart() throws InterruptedException {
00076 masterServer.awaitStart();
00077 }
00078
00079 public boolean awaitStart(long timeout, TimeUnit unit) throws InterruptedException {
00080 return masterServer.awaitStart(timeout, unit);
00081 }
00082
00083 public void shutdown() {
00084 masterServer.shutdown();
00085 }
00086
00087 @VisibleForTesting
00088 public MasterServer getMasterServer() {
00089 return masterServer;
00090 }
00091 }