public void AddPublisher_AlreadyAdded() { var container = new TopicContainer(); IPublisher pub; container.HasPublisher("pub1").Is(false); container.GetPublishers().Count.Is(0); container.AddPublisher(new Publisher <std_msgs.String>("pub1", "test")).Is(true); container.HasPublisher("pub1").Is(true); container.GetPublishers().Count.Is(1); container.GetPublisher("pub1", out pub).Is(true); container.AddPublisher(new Publisher <std_msgs.String>("pub1", "test")).Is(false); container.HasPublisher("pub1").Is(true); container.GetPublishers().Count.Is(1); container.GetPublisher("pub1", out pub).Is(true); }
/// <summary> /// Retrieve a list of topics that this node publishes. /// </summary> /// <param name="callerId"> ROS caller ID. </param> /// <returns> /// [0] = int: code <br/> /// [1] = str: status message <br/> /// [2] = topicList is a list of topics published by this node and is of the form [ [topic1, topicType1]...[topicN, topicTypeN]]] /// </returns> public object[] GetPublications(string callerId) { _logger.Debug(m => m("GetPublications(callerId={0})", callerId)); return(new object[] { StatusCode.Success, "Success", _topicContainer.GetPublishers().Select(x => new object[] { x.TopicName, x.MessageType }).ToArray() }); }
public Task DisposeAsync() { if (_disposed) { throw new ObjectDisposedException("Node"); } _disposed = true; var tasks = new List <Task>(); tasks.AddRange(_topicContainer.GetPublishers().Select(pub => pub.DisposeAsync())); tasks.AddRange(_topicContainer.GetSubscribers().Select(sub => sub.DisposeAsync())); tasks.AddRange(_serviceProxies.Values.Select(proxy => proxy.DisposeAsync())); tasks.AddRange(_serviceServers.Values.Select(service => service.DisposeAsync())); tasks.AddRange(_parameters.Values.Select(param => param.DisposeAsync())); return(Task.Factory.StartNew(() => { try { Task.WaitAll(tasks.ToArray()); } catch (Exception ex) { _logger.Error("Node Dispose Error", ex); } var handler = Disposing; Disposing = null; if (handler != null) { handler(NodeId); } _slaveServer.Dispose(); })); }