Class Pin
Developer API for pins.
This is part of the pin configuration API, see PinConfiguration.
A pin represents a connection point on the edge of a particle through which it can communicate with neighboring particles using beeps or entire messages. Each edge incident to a particle has the same number of pins and the pins are ordered according to each particle's chirality. This means that the same pin may have different IDs for the two particles. Pins are locally identified by IDs computed from the label of the edge to which they belong and their offset on that edge.
Every pin is part of a pin configuration and as such, it belongs to a partition set at all times. Pins cannot be created or destroyed, they can only be moved from one partition set to another.
Namespace: AS2.Sim
Assembly: .dll
Syntax
public abstract class Pin
Properties
| Edit this page View SourceDirection
The local direction of the edge on which this pin is located.
Declaration
public abstract Direction Direction { get; }
Property Value
Type | Description |
---|---|
Direction |
Id
The ID of this pin.
Declaration
public abstract int Id { get; }
Property Value
Type | Description |
---|---|
int |
IsOnHead
Whether the edge this pin belongs to is on the particle's head.
See also IsOnTail.
Declaration
public abstract bool IsOnHead { get; }
Property Value
Type | Description |
---|---|
bool |
IsOnTail
Whether the edge this pin belongs to is on the particle's tail.
See also IsOnHead.
Declaration
public abstract bool IsOnTail { get; }
Property Value
Type | Description |
---|---|
bool |
Offset
The offset of this pin on its edge.
The pins on an edge are ordered according to the chirality of
the particle. Their offsets range from 0
to
PinsPerEdge - 1
.
Declaration
public abstract int Offset { get; }
Property Value
Type | Description |
---|---|
int |
PartitionSet
The partition set to which this pin currently belongs.
Declaration
public abstract PartitionSet PartitionSet { get; }
Property Value
Type | Description |
---|---|
PartitionSet |
Methods
| Edit this page View SourceGetReceivedMessage()
Returns the message this pin has received in the last round, if it has received one and it belongs to the current pin configuration.
Declaration
public abstract Message GetReceivedMessage()
Returns
Type | Description |
---|---|
Message | The message received by this pin in the
last round, if it exists, otherwise |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if this pin does not belong to the current pin configuration. |
HasReceivedMessage()
Checks whether this pin has received a message in the last round, if the pin configuration it belongs to is the current one.
Declaration
public abstract bool HasReceivedMessage()
Returns
Type | Description |
---|---|
bool |
|
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if this pin does not belong to the current pin configuration. |
ReceivedBeep()
Checks whether this pin has received a beep in the last round, if the pin configuration it belongs to is the current one.
Declaration
public abstract bool ReceivedBeep()
Returns
Type | Description |
---|---|
bool |
|
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if this pin does not belong to the current pin configuration. |
SendBeep()
Sends a beep on this pin if the pin configuration it belongs to is the next one.
Declaration
public abstract void SendBeep()
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if this pin does not belong to the next pin configuration. |
SendMessage(Message)
Sends a message on this pin if the pin configuration it belongs to is the next one.
Declaration
public abstract void SendMessage(Message msg)
Parameters
Type | Name | Description |
---|---|---|
Message | msg | The message to be sent. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if this pin does not belong to the next pin configuration. |