예제 #1
0
        private void output(SimEvent se)
        {
            string tname = se.targName;
            string time  = se.time.ToString();
            string target;
            string floor;
            string etype;

            if (se.eTarg == EventTarg.Elevator)
            {
                target = "Elev";
            }
            else
            {
                target = "Prsn";
            }

            if (se.flr == SimObject.floor.first)
            {
                floor = "1st";
            }
            else
            {
                floor = "2nd";
            }

            if (se.eType == EventType.Initialize)
            {
                etype = "Init";
            }
            else if (se.eType == EventType.Spawn)
            {
                etype = "Spwn";
            }
            else if (se.eType == EventType.Load)
            {
                etype = "Load";
            }
            else if (se.eType == EventType.Unload)
            {
                etype = "Ulod";
            }
            else if (se.eType == EventType.Seek)
            {
                etype = "Seek";
            }
            else if (se.eType == EventType.Idle)
            {
                etype = "Idle";
            }
            else
            {
                etype = "Term";
            }

            outFile.WriteLine(String.Format("{0}, {1}, {2}, {3}, {4}", tname, time, target, floor, etype));
        }
예제 #2
0
        private void process(SimEvent se)
        {
            switch (se.eType)
            {
            case EventType.Initialize:
                updates = 0;
                break;

            case EventType.Spawn:
                if (se.eTarg == EventTarg.Person)
                {
                    if (se.flr == SimObject.floor.first)
                    {
                        Person p = new Person(SimConsts.points[(int)SimConsts.point.PS1], personTexture, se.flr);
                        p.Name   = se.targName;
                        p.Target = SimConsts.points[(int)SimConsts.point.PQ1];
                        SimThings.AddLast(p);
                    }
                    else
                    {
                        Person p = new Person(SimConsts.points[(int)SimConsts.point.PS2], personTexture, se.flr);
                        p.Name   = se.targName;
                        p.Target = SimConsts.points[(int)SimConsts.point.PQ2];
                        SimThings.AddLast(p);
                    }
                }
                else
                {
                    elevate      = new ElevatorCar(SimConsts.points[(int)SimConsts.point.E1f], elevatorTexture, simOut);
                    elevate.Name = se.targName;
                    SimThings.AddLast(elevate);
                }
                break;

            case EventType.Seek:
                foreach (SimObject so in SimThings)
                {
                    if (so.Name == se.targName)
                    {
                        so.Fl = se.flr;
                        so.ChangeMode(SimObject.AIMode.Seek);
                    }
                }
                break;

            case EventType.Load:
                foreach (SimObject so in SimThings)
                {
                    if (so.Name == se.targName)
                    {
                        so.Fl = se.flr;
                        so.ChangeMode(SimObject.AIMode.Load);
                    }
                }
                break;

            case EventType.Unload:
                foreach (SimObject so in SimThings)
                {
                    if (so.Name == se.targName)
                    {
                        so.Fl = se.flr;
                        so.ChangeMode(SimObject.AIMode.Unload);
                    }
                }
                break;

            case EventType.Terminate:
                if (se.eTarg == EventTarg.Elevator)
                {
                    //MessageBox.Show("End of simulation", "End of simulation", new string[] { "OK" });
                    this.Exit();
                }
                SimObject kill = null;
                foreach (SimObject so in SimThings)
                {
                    if (so.Name == se.targName)
                    {
                        kill = so;
                    }
                }

                SimThings.Remove(kill);
                kill = null;

                break;

            default:
                break;
            }
        }