Skip to content

Commit

Permalink
.NET port - minor changes, mostly in comments
Browse files Browse the repository at this point in the history
git-svn-id: https://lcm.googlecode.com/svn/trunk@474 989093bb-e83e-0410-a25a-9184cbcad8d0
  • Loading branch information
jan.hrbacek committed Jun 7, 2010
1 parent 7022f61 commit e6e3e95
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lcm-dotnet/lcm-server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void Main(string[] args)
}
catch (System.IO.IOException ex)
{
Console.Out.WriteLine("Ex: " + ex);
Console.Error.WriteLine("Ex: " + ex);
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions lcm-dotnet/lcm/lcm/LCM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace LCM.LCM
{
/// <summary>
/// Lightweight Communications and Marshalling C#.NET implementation *
/// Lightweight Communications and Marshalling C#.NET implementation
/// </summary>
public class LCM
{
Expand Down Expand Up @@ -55,7 +55,7 @@ public static LCM Singleton
}

/// <summary>
/// Return the number of subscriptions. *
/// The number of subscriptions.
/// </summary>
public int NumSubscriptions
{
Expand Down Expand Up @@ -239,7 +239,10 @@ public void Subscribe(string regex, LCMSubscriber sub)
}
}

/// <summary>A convenience function that subscribes to all LCM channels. *</summary>
/// <summary>
/// A convenience function that subscribes to all LCM channels.
/// </summary>
/// <param name="sub">subscribing object providing callback</param>
public void SubscribeAll(LCMSubscriber sub)
{
Subscribe(".*", sub);
Expand Down
8 changes: 4 additions & 4 deletions lcm-dotnet/lcm/lcm/LCMDataInputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace LCM.LCM
{
/// <summary>
/// Will not throw EOF. *
/// Will not throw EOF.
/// </summary>
public sealed class LCMDataInputStream : System.IO.BinaryReader
{
Expand All @@ -13,15 +13,15 @@ public sealed class LCMDataInputStream : System.IO.BinaryReader
private int endpos; // index of byte after last valid byte

/// <summary>
/// Returns the internal buffer representation. *
/// Returns the internal buffer representation.
/// </summary>
public byte[] Buffer
{
get { return buf; }
}

/// <summary>
/// Returns the current position in the internal buffer representation. *
/// Returns the current position in the internal buffer representation.
/// </summary>
public int BufferOffset
{
Expand Down Expand Up @@ -163,7 +163,7 @@ public override string ReadString()
}

/// <summary>
/// Read a string of 8-bit characters terminated by a zero. The zero is consumed. *
/// Read a string of 8-bit characters terminated by a zero. The zero is consumed.
/// </summary>
public string ReadStringZ()
{
Expand Down
6 changes: 3 additions & 3 deletions lcm-dotnet/lcm/lcm/LCMDataOutputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public byte[] Buffer
}

/// <summary>
/// Get the number of bytes that have been written to the buffer. *
/// Get the number of bytes that have been written to the buffer.
/// </summary>
public int Length
{
Expand Down Expand Up @@ -116,7 +116,7 @@ public void WriteChars(string s)
}

/// <summary>
/// Write a zero-terminated string consisting of 8 bit characters. *
/// Write a zero-terminated string consisting of 8 bit characters.
/// </summary>
public void WriteStringZ(string s)
{
Expand Down Expand Up @@ -162,7 +162,7 @@ public void WriteUTF(string s)
}

/// <summary>
/// Makes a copy of the internal buffer. *
/// Makes a copy of the internal buffer.
/// </summary>
public byte[] ToByteArray()
{
Expand Down
2 changes: 1 addition & 1 deletion lcm-dotnet/lcm/lcm/LCMSubscriber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace LCM.LCM
{
/// <summary>
/// A class which listens for messages on a particular channel. *
/// A class which listens for messages on a particular channel.
/// </summary>
public interface LCMSubscriber
{
Expand Down
51 changes: 36 additions & 15 deletions lcm-dotnet/lcm/lcm/MessageAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

namespace LCM.LCM
{
/// <summary> Accumulates received LCM messages in a queue.
/// <summary>
/// Accumulates received LCM messages in a queue.
/// <p>
/// {@link LCM} normally delivers messages asynchronously by invoking the
/// {@link LCMSubscriber#messageReceived messageReceived}
Expand All @@ -16,15 +17,26 @@ namespace LCM.LCM
/// </summary>
public class MessageAggregator : LCMSubscriber
{
/// <summary> A received message.</summary>
/// <summary>
/// A received message.
/// </summary>
public class Message
{
/// <summary> The raw data bytes of the message body.</summary>
/// <summary>
/// The raw data bytes of the message body.
/// </summary>
public byte[] Data;

/// <summary> Channel on which the message was received.</summary>
/// <summary>
/// Channel on which the message was received.
/// </summary>
public string Channel;

/// <summary>
/// Constructor.
/// </summary>
/// <param name="channel">channel name</param>
/// <param name="data">raw data</param>
public Message(string channel, byte[] data)
{
Data = data;
Expand All @@ -37,34 +49,40 @@ public Message(string channel, byte[] data)
private long maxQueueDataSize = 100 * (1 << 20); // 100 megabytes
private int maxQueueLength = Int32.MaxValue;

/// <summary> Retrieves and sets the maximum amount of memory that will be used to store messages.
/// <summary>
/// Retrieves and sets the maximum amount of memory that will be used to store messages.
/// This is an alternative way to limit the messages stored by the
/// aggregator. Messages are discarded oldest-first to ensure that the
/// total size of unretrieved messages stays under this limit.
/// </summary>
/// <param name="val">memory limit, in bytes.
/// </param>
/// <param name="val">memory limit, in bytes.</param>
public long MaxBufferSize
{
get { lock (this) { return maxQueueDataSize; } }
set { lock (this) { maxQueueDataSize = value; } }
}

/// <summary> Retrieves and sets the maximum number of unretrieved message that will be queued up by the aggregator.
/// Messages are discarded oldest-first to ensure that the number of unretrieved messages stays under this limit.</summary>
/// <summary>
/// Retrieves and sets the maximum number of unretrieved message that will be queued up by the aggregator.
/// Messages are discarded oldest-first to ensure that the number of unretrieved messages stays under this limit.
/// </summary>
public int MaxMessages
{
get { lock (this) { return maxQueueLength; } }
set { lock (this) { maxQueueLength = value; } }
}

/// <summary> Returns the number of received messages waiting to be retrieved.</summary>
/// <summary>
/// The number of received messages waiting to be retrieved.
/// </summary>
public int MessagesAvailable
{
get { lock (this) { return messages.Count; } }
}

/// <summary>Internal method, called by LCM when a message is received.</summary>
/// <summary>
/// Internal method, called by LCM when a message is received.
/// </summary>
public void MessageReceived(LCM lcm, string channel, LCMDataInputStream dins)
{
lock (this)
Expand All @@ -91,10 +109,11 @@ public void MessageReceived(LCM lcm, string channel, LCMDataInputStream dins)
}
}

/// <summary> Attempt to retrieve the next received LCM message.</summary>
/// <summary>
/// Attempt to retrieve the next received LCM message.
/// </summary>
/// <param name="timeout_ms">Max # of milliseconds to wait for a message. If 0,
/// then don't wait. If less than 0, then wait indefinitely.
/// </param>
/// then don't wait. If less than 0, then wait indefinitely.</param>
/// <returns>a Message, or null if no message was received.</returns>
public Message GetNextMessage(long timeoutMs)
{
Expand Down Expand Up @@ -138,7 +157,9 @@ public Message GetNextMessage(long timeoutMs)
}
}

/// <summary> Retrieves the next message, waiting if necessary.</summary>
/// <summary>
/// Retrieves the next message, waiting if necessary.
/// </summary>
public Message GetNextMessage()
{
return GetNextMessage(-1);
Expand Down
4 changes: 1 addition & 3 deletions lcm-dotnet/lcm/lcm/Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ namespace LCM.LCM
/// <summary>
/// A provider implements a communications modality for LCM. (I.e., a
/// URL handler.)
/// </summary>
/// <summary>
/// The provider should call LC.receiveMessage() upon receipt of a
/// message. LCM.receiveMessage() is thread-safe and can be called from
/// message. LCM.ReceiveMessage() is thread-safe and can be called from
/// any thread.
/// </summary>
public interface Provider
Expand Down
5 changes: 3 additions & 2 deletions lcm-dotnet/lcm/lcm/UDPMulticastProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

namespace LCM.LCM
{
/// <summary>LCM provider for the udpm: URL. All messages are broadcast over a
/// <summary>
/// LCM provider for the udpm: URL. All messages are broadcast over a
/// pre-arranged UDP multicast address. Subscription operations are a
/// no-op, since all messages are always broadcast.
///
Expand Down Expand Up @@ -261,7 +262,7 @@ public FragmentBuffer(SocketAddress from, string channel, int msgSeqNumber, int
}
}

public void ReaderThreadRun()
private void ReaderThreadRun()
{
byte[] packetData;
IPEndPoint from = new IPEndPoint(IPAddress.Any, 0);
Expand Down

0 comments on commit e6e3e95

Please sign in to comment.