Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cdf913d
[Communication] Added Latency Table.
Joseph0120 Mar 31, 2026
53cd702
[Communication] Added Message base envelope. Message.cs.
Joseph0120 Mar 31, 2026
0ff1f92
[Communication] Created IMessagePayload and MessagePayload.
Joseph0120 Mar 31, 2026
7e407e5
[Communication] Created PendingMessage.cs.
Joseph0120 Mar 31, 2026
5814aa6
[Comms_Proto] Minor Fix: format
Joseph0120 Apr 5, 2026
ae73009
[Comms_Proto] Fixing LatencyTable enum casting
Joseph0120 Apr 5, 2026
90490c0
[Comms_Proto] PendingMessage.cs extends IComparable
Joseph0120 Apr 5, 2026
96cabf4
[Comms_Proto] Minor Fix: LatencyTable
Joseph0120 Apr 5, 2026
ebff605
[Comms_Proto] Minor Fix: Format
Joseph0120 Apr 5, 2026
a7438b5
Apply formatting and regenerate proto files
Joseph0120 Apr 23, 2026
668fe70
Delete Assets/Scripts/Agents/Messaging/IMessagePayload.cs.meta
Joseph0120 Apr 28, 2026
9960ee9
Delete Assets/Scripts/Agents/Messaging/LatencyTable.cs.meta
Joseph0120 Apr 28, 2026
b180ffa
Delete Assets/Scripts/Agents/Messaging/LatencyTable.cs
Joseph0120 Apr 28, 2026
fa84cde
Delete Assets/Scripts/Agents/Messaging/Message.cs.meta
Joseph0120 Apr 28, 2026
640c5aa
Delete Assets/Scripts/Agents/Messaging/MessagePayload.cs.meta
Joseph0120 Apr 28, 2026
0a03fe4
Delete Assets/Scripts/Agents/Messaging.meta
Joseph0120 Apr 28, 2026
9f05642
[Communication] Resolved git comments
Joseph0120 May 6, 2026
771e3f6
[Communication] Change to generic base class, pass in different paylo…
Joseph0120 May 6, 2026
93808a9
Delete Assets/Scripts/Generated/Proto/CommunicationConfig.cs
Joseph0120 May 6, 2026
d3de35d
[Communication] Address Coderabbit comments
Joseph0120 May 9, 2026
70e14d3
Merge branch 'joseph/communication_delay_PR1' of github.com:PisterLab…
Joseph0120 May 9, 2026
f2d5195
[Communication] Added meta and config files
Joseph0120 May 10, 2026
fa16266
[Communication] Fix format
Joseph0120 May 10, 2026
2b73870
[Communication] Added comments
Joseph0120 May 10, 2026
11a25d8
Clean up some comments
tryuan99 May 11, 2026
43f2e16
More cleanup
tryuan99 May 11, 2026
c712399
Undo accidental JSON reformatting
tryuan99 May 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Assets/Scripts/Communication.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/Scripts/Communication/IMessagePayload.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Interface for a message payload.

public interface IMessagePayload {}
Comment thread
Joseph0120 marked this conversation as resolved.
2 changes: 2 additions & 0 deletions Assets/Scripts/Communication/IMessagePayload.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions Assets/Scripts/Communication/Message.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// The message is a base class for the different types of messages being sent and received among the
// agents. It always carries a sender, a receiver, a message type, and a payload.

using System;

// Message type enumeration that defines the message payload.
public enum MessageType {
AssignTargetRequest,
AssignTargetResponse,
ReassignTargetRequest,
}

public abstract class Message {
public IAgent Sender { get; }
public IAgent Receiver { get; }
public MessageType Type { get; }

public abstract IMessagePayload Payload { get; }

protected Message(IAgent sender, IAgent receiver, MessageType type) {
Sender = sender ?? throw new ArgumentNullException(nameof(sender));
Receiver = receiver ?? throw new ArgumentNullException(nameof(receiver));
Type = type;
}
}

// Generic message that stores a payload. The generic type refers to the payloa type.
public abstract class Message<TPayload> : Message
where TPayload : class, IMessagePayload {
public TPayload PayloadData { get; }
public sealed override IMessagePayload Payload => PayloadData;
protected Message(IAgent sender, IAgent receiver, MessageType type, TPayload payload)
: base(sender, receiver, type) {
PayloadData = payload ?? throw new ArgumentNullException(nameof(payload));
}
}

// This message is sent upwards to a parent interceptor or IADS when a sub-interceptor has no target
// and is requesting a new target.
public sealed class AssignTargetRequestMessage : Message<AssignTargetRequestPayload> {
public AssignTargetRequestMessage(IAgent sender, IAgent receiver, IInterceptor subInterceptor)
: base(sender, receiver, MessageType.AssignTargetRequest,
new AssignTargetRequestPayload(subInterceptor)) {}
}

// This message is sent downwards from the IADS or a parent interceptor to inform the
// sub-interceptor of a new target.
public sealed class AssignTargetResponseMessage : Message<AssignTargetResponsePayload> {
public AssignTargetResponseMessage(IAgent sender, IAgent receiver, IHierarchical target)
: base(sender, receiver, MessageType.AssignTargetResponse,
new AssignTargetResponsePayload(target)) {}
}

// This message is sent upwards to a parent interceptor or IADS when a sub-interceptor can no longer
// pursue the current target and is requesting the parent interceptor or IADS to reassign that
// target elsewhere.
public sealed class ReassignTargetRequestMessage : Message<ReassignTargetRequestPayload> {
public ReassignTargetRequestMessage(IAgent sender, IAgent receiver, IHierarchical target)
: base(sender, receiver, MessageType.ReassignTargetRequest,
new ReassignTargetRequestPayload(target)) {}
}
2 changes: 2 additions & 0 deletions Assets/Scripts/Communication/Message.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions Assets/Scripts/Communication/MessagePayload.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// The message payload defines different types of payloads carried by messages.

using System;

// The payload carries the sub-interceptor that is requesting a parent interceptor or IADS for a new
// target assignment.
public sealed class AssignTargetRequestPayload : IMessagePayload {
public IInterceptor SubInterceptor { get; }

public AssignTargetRequestPayload(IInterceptor subInterceptor) {
SubInterceptor = subInterceptor ?? throw new ArgumentNullException(nameof(subInterceptor));
}
}

// The payload carries the target that a parent interceptor or IADS has selected for a requesting
// sub-interceptor.
public sealed class AssignTargetResponsePayload : IMessagePayload {
public IHierarchical Target { get; }

public AssignTargetResponsePayload(IHierarchical target) {
Target = target ?? throw new ArgumentNullException(nameof(target));
}
}

// The payload carries the target that a sub-interceptor is requesting its parent interceptor or
// IADS to reassign.
public sealed class ReassignTargetRequestPayload : IMessagePayload {
public IHierarchical Target { get; }

public ReassignTargetRequestPayload(IHierarchical target) {
Target = target ?? throw new ArgumentNullException(nameof(target));
}
}
2 changes: 2 additions & 0 deletions Assets/Scripts/Communication/MessagePayload.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions Assets/Scripts/Communication/PendingMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// The pending message is the mailbox's internal queue item. It stores the message object and the
// scheduled delivery time in simulation seconds. The mailbox dequeues this item once the simulation
// time reaches the deliver at time.

using System;

public readonly struct PendingMessage : IComparable<PendingMessage> {
public Message Message { get; }

// Absolute simulation time in seconds when the mailbox should deliver this message.
public float DeliverAt { get; }

public IAgent Sender => Message?.Sender;
Comment thread
Joseph0120 marked this conversation as resolved.
public IAgent Receiver => Message?.Receiver;
Comment thread
Joseph0120 marked this conversation as resolved.

public PendingMessage(Message message, float deliverAt) {
if (float.IsNaN(deliverAt) || float.IsInfinity(deliverAt) || deliverAt < 0f) {
throw new ArgumentOutOfRangeException(nameof(deliverAt), deliverAt,
"DeliverAt must be finite and non-negative.");
}
Message = message ?? throw new ArgumentNullException(nameof(message));
DeliverAt = deliverAt;
}

// Pending messages are sorted based on the deliver at time.
public int CompareTo(PendingMessage other) => DeliverAt.CompareTo(other.DeliverAt);
}
2 changes: 2 additions & 0 deletions Assets/Scripts/Communication/PendingMessage.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Assets/Scripts/Generated/Proto/CommunicationConfig.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Assets/Scripts/Generated/Proto/CommunicationConfig.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
}
]
}
}
}
Loading