MasterClient.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 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.internal.node.client;
00018 
00019 import org.ros.internal.node.response.IntegerResultFactory;
00020 import org.ros.internal.node.response.Response;
00021 import org.ros.internal.node.response.SystemStateResultFactory;
00022 import org.ros.internal.node.response.TopicListResultFactory;
00023 import org.ros.internal.node.response.TopicTypeListResultFactory;
00024 import org.ros.internal.node.response.UriListResultFactory;
00025 import org.ros.internal.node.response.UriResultFactory;
00026 import org.ros.internal.node.response.VoidResultFactory;
00027 import org.ros.internal.node.server.NodeIdentifier;
00028 import org.ros.internal.node.server.SlaveServer;
00029 import org.ros.internal.node.server.master.MasterServer;
00030 import org.ros.internal.node.topic.PublisherDeclaration;
00031 import org.ros.internal.node.topic.PublisherIdentifier;
00032 import org.ros.internal.node.topic.TopicDeclaration;
00033 import org.ros.internal.node.xmlrpc.MasterXmlRpcEndpoint;
00034 import org.ros.master.client.SystemState;
00035 import org.ros.master.client.TopicSystemState;
00036 import org.ros.master.client.TopicType;
00037 import org.ros.namespace.GraphName;
00038 import org.ros.node.service.ServiceServer;
00039 import org.ros.node.topic.Publisher;
00040 import org.ros.node.topic.Subscriber;
00041 
00042 import java.net.URI;
00043 import java.util.List;
00044 
00050 public class MasterClient extends Client<MasterXmlRpcEndpoint> {
00051 
00059   public MasterClient(URI uri) {
00060     super(uri, MasterXmlRpcEndpoint.class);
00061   }
00062 
00073   public Response<Void> registerService(NodeIdentifier slave, ServiceServer<?, ?> service) {
00074     return Response.fromListChecked(xmlRpcEndpoint.registerService(slave.getName().toString(),
00075         service.getName().toString(), service.getUri().toString(), slave.getUri().toString()),
00076         new VoidResultFactory());
00077   }
00078 
00089   public Response<Integer> unregisterService(NodeIdentifier slave, ServiceServer<?, ?> service) {
00090     return Response.fromListChecked(xmlRpcEndpoint.unregisterService(
00091         slave.getName().toString(), service.getName().toString(), service.getUri().toString()),
00092         new IntegerResultFactory());
00093   }
00094 
00109   public Response<List<URI>> registerSubscriber(NodeIdentifier slave, Subscriber<?> subscriber) {
00110     return Response.fromListChecked(xmlRpcEndpoint.registerSubscriber(slave.getName()
00111         .toString(), subscriber.getTopicName().toString(), subscriber.getTopicMessageType(), slave
00112         .getUri().toString()), new UriListResultFactory());
00113   }
00114 
00124   public Response<Integer> unregisterSubscriber(NodeIdentifier slave, Subscriber<?> subscriber) {
00125     return Response.fromListChecked(xmlRpcEndpoint.unregisterSubscriber(slave.getName()
00126         .toString(), subscriber.getTopicName().toString(), slave.getUri().toString()),
00127         new IntegerResultFactory());
00128   }
00129 
00139   public Response<List<URI>> registerPublisher(PublisherDeclaration publisherDeclaration) {
00140     String slaveName = publisherDeclaration.getSlaveName().toString();
00141     String slaveUri = publisherDeclaration.getSlaveUri().toString();
00142     String topicName = publisherDeclaration.getTopicName().toString();
00143     String messageType = publisherDeclaration.getTopicMessageType();
00144     return Response.fromListChecked(
00145         xmlRpcEndpoint.registerPublisher(slaveName, topicName, messageType, slaveUri),
00146         new UriListResultFactory());
00147   }
00148 
00157   public Response<Integer> unregisterPublisher(PublisherIdentifier publisherIdentifier) {
00158     String slaveName = publisherIdentifier.getNodeName().toString();
00159     String slaveUri = publisherIdentifier.getNodeUri().toString();
00160     String topicName = publisherIdentifier.getTopicName().toString();
00161     return Response.fromListChecked(
00162         xmlRpcEndpoint.unregisterPublisher(slaveName, topicName, slaveUri),
00163         new IntegerResultFactory());
00164   }
00165 
00173   public Response<URI> lookupNode(GraphName slaveName, String nodeName) {
00174     return Response.fromListChecked(xmlRpcEndpoint.lookupNode(slaveName.toString(), nodeName),
00175         new UriResultFactory());
00176   }
00177 
00183   public Response<URI> getUri(GraphName slaveName) {
00184     return Response.fromListChecked(xmlRpcEndpoint.getUri(slaveName.toString()),
00185         new UriResultFactory());
00186   }
00187 
00196   public Response<URI> lookupService(GraphName callerName, String serviceName) {
00197     return Response.fromListCheckedFailure(
00198         xmlRpcEndpoint.lookupService(callerName.toString(), serviceName), new UriResultFactory());
00199   }
00200 
00208   public Response<List<TopicDeclaration>> getPublishedTopics(GraphName callerName, String subgraph) {
00209     return Response.fromListChecked(
00210         xmlRpcEndpoint.getPublishedTopics(callerName.toString(), subgraph),
00211         new TopicListResultFactory());
00212   }
00213 
00221   public Response<List<TopicType>> getTopicTypes(GraphName callerName) {
00222     return Response.fromListChecked(xmlRpcEndpoint.getTopicTypes(callerName.toString()),
00223         new TopicTypeListResultFactory());
00224   }
00225 
00231   public Response<SystemState> getSystemState(GraphName callerName) {
00232     return Response.fromListChecked(xmlRpcEndpoint.getSystemState(callerName.toString()),
00233         new SystemStateResultFactory());
00234   }
00235 }


rosjava_core
Author(s):
autogenerated on Wed Aug 26 2015 16:06:49