Пример #1
0
        public void GenerateActiveState(int opsCount)
        {
            List <String> arrived    = new List <String>();
            List <String> allocated  = new List <String>();
            List <String> departured = new List <String>();

            for (int i = 0; i < opsCount; i++)
            {
                if (i % 7 == 0)
                {   // Count -1 to test upper type sub
                    Planes.Add(new Plane("Producer " + i, "Type " + i, "" + i, TrackTypesLengthList[i % TrackTypesLengthList.Count],
                                         SystemTime, 0));
                    if (NotifyArrival("" + i))
                    {
                        arrived.Add("" + i);
                    }
                }
                else
                if (i % 7 == 1 && departured.Count > 0)
                {
                    String randomID = departured[i % departured.Count];
                    if (NotifyArrival(randomID))
                    {
                        departured.Remove(randomID);
                        arrived.Add(randomID);
                    }
                }
                else
                if ((i % 7 == 2 || i % 7 == 3 || i % 7 == 6) && allocated.Count > 0)
                {
                    String randomID = allocated[i % allocated.Count];
                    if (NotifyDeparture(randomID))
                    {
                        allocated.Remove(randomID);
                        departured.Add(randomID);
                    }
                }
                else
                if ((i % 7 == 4 || i % 7 == 5) && arrived.Count > 0)
                {
                    String randomID = arrived[i % arrived.Count];
                    if (NotifyTrackRequirement(randomID, i % 11))
                    {
                        arrived.Remove(randomID);
                        allocated.Add(randomID);
                    }
                }
                SystemTime = SystemTime.AddMinutes(10);
            }
        }