SlaveClient.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 com.google.common.collect.Lists;
00020 
00021 import org.ros.internal.node.response.IntegerResultFactory;
00022 import org.ros.internal.node.response.ProtocolDescriptionResultFactory;
00023 import org.ros.internal.node.response.Response;
00024 import org.ros.internal.node.response.TopicListResultFactory;
00025 import org.ros.internal.node.response.UriResultFactory;
00026 import org.ros.internal.node.response.VoidResultFactory;
00027 import org.ros.internal.node.topic.TopicDeclaration;
00028 import org.ros.internal.node.xmlrpc.SlaveXmlRpcEndpoint;
00029 import org.ros.internal.transport.ProtocolDescription;
00030 import org.ros.namespace.GraphName;
00031 
00032 import java.net.URI;
00033 import java.util.Collection;
00034 import java.util.List;
00035 import java.util.Map;
00036 
00040 public class SlaveClient extends Client<SlaveXmlRpcEndpoint> {
00041 
00042   private final GraphName nodeName;
00043 
00044   public SlaveClient(GraphName nodeName, URI uri) {
00045     super(uri, SlaveXmlRpcEndpoint.class);
00046     this.nodeName = nodeName;
00047   }
00048 
00049   public List<Object> getBusStats() {
00050     throw new UnsupportedOperationException();
00051   }
00052 
00053   public List<Object> getBusInfo() {
00054     throw new UnsupportedOperationException();
00055   }
00056 
00057   public Response<URI> getMasterUri() {
00058     return Response.fromListChecked(xmlRpcEndpoint.getMasterUri(nodeName.toString()), new UriResultFactory());
00059   }
00060 
00061   public Response<Void> shutdown(String message) {
00062     return Response.fromListChecked(xmlRpcEndpoint.shutdown("/master", message), new VoidResultFactory());
00063   }
00064 
00065   public Response<Integer> getPid() {
00066     return Response.fromListChecked(xmlRpcEndpoint.getPid(nodeName.toString()), new IntegerResultFactory());
00067   }
00068 
00069   public Response<List<TopicDeclaration>> getSubscriptions() {
00070     return Response.fromListChecked(xmlRpcEndpoint.getSubscriptions(nodeName.toString()),
00071         new TopicListResultFactory());
00072   }
00073 
00074   public Response<List<TopicDeclaration>> getPublications() {
00075     return Response.fromListChecked(xmlRpcEndpoint.getPublications(nodeName.toString()),
00076         new TopicListResultFactory());
00077   }
00078 
00079   public Response<Void> paramUpdate(GraphName name, boolean value) {
00080     return Response.fromListChecked(xmlRpcEndpoint.paramUpdate(nodeName.toString(), name.toString(), value),
00081         new VoidResultFactory());
00082   }
00083 
00084   public Response<Void> paramUpdate(GraphName name, char value) {
00085     return Response.fromListChecked(xmlRpcEndpoint.paramUpdate(nodeName.toString(), name.toString(), value),
00086         new VoidResultFactory());
00087   }
00088 
00089   public Response<Void> paramUpdate(GraphName name, int value) {
00090     return Response.fromListChecked(xmlRpcEndpoint.paramUpdate(nodeName.toString(), name.toString(), value),
00091         new VoidResultFactory());
00092   }
00093 
00094   public Response<Void> paramUpdate(GraphName name, double value) {
00095     return Response.fromListChecked(xmlRpcEndpoint.paramUpdate(nodeName.toString(), name.toString(), value),
00096         new VoidResultFactory());
00097   }
00098 
00099   public Response<Void> paramUpdate(GraphName name, String value) {
00100     return Response.fromListChecked(xmlRpcEndpoint.paramUpdate(nodeName.toString(), name.toString(), value),
00101         new VoidResultFactory());
00102   }
00103 
00104   public Response<Void> paramUpdate(GraphName name, List<?> value) {
00105     return Response.fromListChecked(xmlRpcEndpoint.paramUpdate(nodeName.toString(), name.toString(), value),
00106         new VoidResultFactory());
00107   }
00108 
00109   public Response<Void> paramUpdate(GraphName name, Map<?, ?> value) {
00110     return Response.fromListChecked(xmlRpcEndpoint.paramUpdate(nodeName.toString(), name.toString(), value),
00111         new VoidResultFactory());
00112   }
00113 
00114   public Response<Void> publisherUpdate(GraphName topic, Collection<URI> publisherUris) {
00115     List<String> publishers = Lists.newArrayList();
00116     for (URI uri : publisherUris) {
00117       publishers.add(uri.toString());
00118     }
00119     return Response.fromListChecked(
00120         xmlRpcEndpoint.publisherUpdate(nodeName.toString(), topic.toString(), publishers.toArray()),
00121         new VoidResultFactory());
00122   }
00123 
00124   public Response<ProtocolDescription> requestTopic(GraphName topic,
00125       Collection<String> requestedProtocols) {
00126     return Response.fromListChecked(xmlRpcEndpoint.requestTopic(nodeName.toString(), topic.toString(),
00127         new Object[][] { requestedProtocols.toArray() }), new ProtocolDescriptionResultFactory());
00128   }
00129 }


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