Beispiel #1
0
 protected virtual void processMessage(Message rxMessage)
 {
     this.PendingPositionX = (rxMessage.Content as ConvoyMessage).PositionX;
     this.PendingPositionY = (rxMessage.Content as ConvoyMessage).PositionY;
 }
Beispiel #2
0
 protected virtual Message generateMessage()
 {
     Message message = new Message();
     message.Destination = this.Id+1;
     message.Source = this.Id;
     message.Content = new ConvoyMessage(this.PositionX, this.PositionY);
     return message;
 }
Beispiel #3
0
 protected override Message generateMessage()
 {
     Message message = new Message();
     message.Destination = this.Id + 1;
     message.Source = this.Id;
     message.Content = new FrameInfoMessage(this.PositionX, this.PositionY, this.timeSegments, 
         this.frequencySegments, this.FrameInformation);
     return message;
 }
Beispiel #4
0
        protected override void processMessage(Message rxMessage)
        {
            if (rxMessage.Destination == this.Id)
            {
                this.PendingPositionX = (rxMessage.Content as FrameInfoMessage).PositionX;
                this.PendingPositionY = (rxMessage.Content as FrameInfoMessage).PositionY;
            }

            int[,] messageFrameInformation = (rxMessage.Content as FrameInfoMessage).FrameInformation;

            int totalRegions = this.frequencySegments * this.timeSegments;
            for (int idx = 1; idx <= totalRegions; idx++)
            {
                KeyValuePair<int, int> indexes = Spectrum.GetIndexesFromAccess(idx, this.frequencySegments);
                int incomingValue = messageFrameInformation[indexes.Key, indexes.Value];
                if (incomingValue == 0)
                {
                    if (this.FrameInformation[indexes.Key, indexes.Value] == rxMessage.Source)
                    {
                        //vehicle that has released the region
                        this.FrameInformation[indexes.Key, indexes.Value] = incomingValue;
                    }
                }
                else //(incomingValue != 0)
                {
                    if (this.FrameInformation[indexes.Key, indexes.Value] == this.Id) //selected region for this vehicle
                    {
                        if (incomingValue != this.Id)
                        {
                            //This vehicle must select a new region because a previous collision
                            this.Access = 0; //force the selection of a new region
                            this.IsMacPending = true;
                        }
                    }
                    this.FrameInformation[indexes.Key, indexes.Value] = incomingValue;
                }
            }
        }
Beispiel #5
0
        public void SetMessage(Message message, int access)
        {
            if (access >= 1 && access <= this.TotalRegions)
            {
                KeyValuePair<int, int> indexes = this.GetIndexesFromAccess(access);

                this.Information[indexes.Key, indexes.Value] = message;
            }
        }