Example #1
0
        /// <summary>
        /// When the dispatcher receives data, it parses out the ; to obtain the location, type, and name from the EV and then
        /// Adds that EV to the list, generates a Unique ID for the EV and sends the EV that ID
        /// </summary>
        /// <param name="ipAddr"></param>
        /// <param name="data"></param>
        public void DataRecieved(string ipAddr, byte[] data)
        {
            string stuff = Encoding.ASCII.GetString(data);

            string[]         tempStuff = stuff.Split(';');
            string           location  = tempStuff[0];
            string           type      = tempStuff[1];
            string           name      = tempStuff[2];
            EmergencyVehicle newCar    = new EmergencyVehicle(location, type, name);

            eMan.registerEV(newCar);
            var i = IpId.FindIndex(x => x.Item1 == ipAddr);

            IpId[i] = new Tuple <string, int>(ipAddr, newCar.getID());
            string toBecomeData = '_' + newCar.getID().ToString() + ';';

            byte[] carID = Encoding.ASCII.GetBytes(toBecomeData);
            networkMan.Send(ipAddr, carID);
        }
        /// <summary>
        /// Adds an Emergency Vehicle into the List
        /// </summary>
        /// <param name="newCar">Emergency Vehicle to be added</param>
        public void registerEV(EmergencyVehicle newCar)
        {
            //generates a newID until there is one that isn't one the list.
            int newID;

            if (size + 1 < ID_MAX)
            {
                do
                {
                    newID = generateID();
                } while (registerID(newID) == false);

                newCar.setID(newID);
                EVList.Add(newCar);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("EVLIST is full");
            }
        }
Example #3
0
 /// <summary>
 /// When the dispatcher receives data, it parses out the ; to obtain the location, type, and name from the EV and then
 /// Adds that EV to the list, generates a Unique ID for the EV and sends the EV that ID
 /// </summary>
 /// <param name="ipAddr"></param>
 /// <param name="data"></param>
 public void DataRecieved(string ipAddr, byte[] data)
 {
     string stuff = Encoding.ASCII.GetString(data);
     string[] tempStuff = stuff.Split(';');
     string location = tempStuff[0];
     string type = tempStuff[1];
     string name = tempStuff[2];
     EmergencyVehicle newCar = new EmergencyVehicle(location, type, name);
     eMan.registerEV(newCar);
     var i = IpId.FindIndex(x => x.Item1 == ipAddr);
     IpId[i] = new Tuple<string, int>(ipAddr, newCar.getID());
     string toBecomeData = '_' + newCar.getID().ToString() + ';';
     byte[] carID = Encoding.ASCII.GetBytes(toBecomeData);
     networkMan.Send(ipAddr, carID);
 }
        /// <summary>
        /// Adds an Emergency Vehicle into the List
        /// </summary>
        /// <param name="newCar">Emergency Vehicle to be added</param>
        public void registerEV(EmergencyVehicle newCar)
        {
            //generates a newID until there is one that isn't one the list.
            int newID;
            if (size + 1 < ID_MAX)
            {
                do
                {
                   newID = generateID();
                } while (registerID(newID) == false);

                newCar.setID(newID);
                EVList.Add(newCar);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("EVLIST is full");
            }
        }