Exemple #1
0
        public static void InitializeSensorField(int dataCount)
        {
            Random r = new Random();
            int messageType;
            string messageContent;

            for (int i = 0; i < dataCount; i++)
            {
                messageType = r.Next(1, 6);
                if (messageType == 1)
                    messageContent = "Priority 1";
                else if (messageType == 2)
                    messageContent = "Priority 2";
                else if (messageType == 3)
                    messageContent = "Priority 3";
                else if (messageType == 4)
                    messageContent = "Priority 4";
                else
                    messageContent = "Priority 5";

                Message msg = new Message(i, messageType, messageContent);
                dataSensed.Enqueue(msg);
            }
            Console.WriteLine("Sensor field initialized!\n");
            //Thread.Sleep(1000);
            //OutputSensorFieldData();
        }
Exemple #2
0
        public static Message DequeueFromSensorField()
        {
            Message dq = new Message();

            lock (locker)
            {
                dq = (Message)dataSensed.Dequeue();
            }

            return dq;
        }
 public static void ReceiveMessage(int nodeID, Message rm, int second)
 {
     Message receivedMessage;
     receivedMessage = rm;
     Supercapacitor.SCUsage("RCV", receivedMessage.MessageType);
     Console.WriteLine("{0} node {1} --- RCV --- PN {2} --- ID {3}",
         second,
         nodeID,
         receivedMessage.MessageType,
         receivedMessage.MessageID);
     RecordStatistics.RecordReceived(receivedMessage.MessageType);
     Supercapacitor.SCUsage("SND", receivedMessage.MessageType);
 }
Exemple #4
0
        /// <summary>
        /// This initializes the data source for the node
        /// </summary>
        public void GenerateSource()
        {
            Random r1 = new Random();
            Random r2 = new Random();
            Message messageToQueue = new Message();

            while (SensorField.SensorFieldDataCount() != 0)
            {
                messageToQueue = (Message)SensorField.DequeueFromSensorField();
                dataSource.Enqueue(messageToQueue);
                Thread.Sleep(10);
            }

            //Console.WriteLine("Total Messages: {0}", dataSource.Count);
        }
Exemple #5
0
        /// <summary>
        /// This initializes the data source for the node
        /// </summary>
        public void GenerateSource()
        {
            Message messageToQueue = new Message();

            while (SensorField.SensorFieldDataCount() != 0)
            {
                messageToQueue = (Message)SensorField.DequeueFromSensorField();
                RecordStatistics.RecordMessageTypeOccurence(messageToQueue.MessageType);
                dataSource.Enqueue(messageToQueue);
                Thread.Sleep(10);
            }
        }