Update documentation

This commit is contained in:
Pascal Serrarens 2025-04-28 10:59:29 +02:00
parent 76f28e10b7
commit b2b5ebbce0
3 changed files with 35 additions and 11 deletions

View File

@ -6,5 +6,4 @@ Includes support for the Unity game engine.
# Basic components # Basic components
- RoboidControl::Thing - RoboidControl::Thing
- RoboidControl::LocalParticipant - RoboidControl::Participant
- RoboidControl::SiteServer

View File

@ -37,12 +37,12 @@ namespace RoboidControl {
/// <summary> /// <summary>
/// The network ID of the participant /// The network ID of the participant
/// </summary> /// </summary>
public byte networkId; public byte networkId = 0;
/// <summary> /// <summary>
/// The things managed by this participant /// The things managed by this participant
/// </summary> /// </summary>
public readonly List<Thing> things = new List<Thing>(); public readonly List<Thing> things = new();
public virtual void Update(ulong currentTimeMS = 0) { public virtual void Update(ulong currentTimeMS = 0) {
int n = this.things.Count; int n = this.things.Count;
@ -51,11 +51,19 @@ namespace RoboidControl {
if (thing != null) if (thing != null)
thing.Update(currentTimeMS, true); thing.Update(currentTimeMS, true);
} }
} }
public static List<Participant> participants = new List<Participant>(); /// <summary>
/// The collection of known participants.
/// </summary>
public readonly static List<Participant> participants = new();
/// <summary>
/// Retrieve a participant using ip address and port number
/// </summary>
/// <param name="ipAddress">The ip address of the participant</param>
/// <param name="port">The port number used to send messages to the participant</param>
/// <returns>The participant or null if it is not found.</returns>
public static Participant GetParticipant(string ipAddress, int port) { public static Participant GetParticipant(string ipAddress, int port) {
//Console.WriteLine($"Get Participant {ipAddress}:{port}"); //Console.WriteLine($"Get Participant {ipAddress}:{port}");
foreach (Participant participant in Participant.participants) { foreach (Participant participant in Participant.participants) {
@ -64,14 +72,26 @@ namespace RoboidControl {
} }
return null; return null;
} }
public static Participant GetParticipant(int participantId) { /// <summary>
//Console.WriteLine($"Get Participant [participantId]"); /// Retrieve a participant using a network ID
/// </summary>
/// <param name="networkId">The network ID of the participant</param>
/// <returns>The participant or null if it is not found.</returns>
public static Participant GetParticipant(int networkId) {
//Console.WriteLine($"Get Participant [networkId]");
foreach (Participant participant in Participant.participants) { foreach (Participant participant in Participant.participants) {
if (participant.networkId == participantId) if (participant.networkId == networkId)
return participant; return participant;
} }
return null; return null;
} }
/// <summary>
/// Add a new participant to the collection of participants
/// </summary>
/// <param name="ipAddress">The IP address of the participant</param>
/// <param name="port">The port used to send messages to this participant</param>
/// <returns>The added participant</returns>
public static Participant AddParticipant(string ipAddress, int port) { public static Participant AddParticipant(string ipAddress, int port) {
Console.WriteLine($"New Participant {ipAddress}:{port}"); Console.WriteLine($"New Participant {ipAddress}:{port}");
Participant participant = new(ipAddress, port) { Participant participant = new(ipAddress, port) {
@ -80,6 +100,11 @@ namespace RoboidControl {
Participant.participants.Add(participant); Participant.participants.Add(participant);
return participant; return participant;
} }
/// <summary>
/// Add a new participant to the collection of participants
/// </summary>
/// <param name="participant">The participant to add</param>
/// <note>This function only adds the participant if it is not yet in the collection</note>
public static void AddParticipant(Participant participant) { public static void AddParticipant(Participant participant) {
Participant foundParticipant = Participant.GetParticipant(participant.networkId); Participant foundParticipant = Participant.GetParticipant(participant.networkId);
if (foundParticipant == null) if (foundParticipant == null)

View File

@ -269,7 +269,7 @@ namespace RoboidControl {
/// <summary> /// <summary>
/// Event triggered when the pose has changed /// Event triggered when the pose has changed
/// </summary> /// </summary>
public event ChangeHandler OnPoseChanged = null; //delegate { }; public event ChangeHandler OnPoseChanged = delegate { };
/// <summary> /// <summary>
/// Boolean indicating that the thing has an updated position /// Boolean indicating that the thing has an updated position
/// </summary> /// </summary>