Beispiel #1
0
        }//End Constructor.

        /***********************************************************
         * Takes an event code and an entity and returns a SimEvent.
         **********************************************************/
        public SimEvent CreateEvent(int eventCode, Entity e)
        {
            SimEvent newEvent = null;

            //Determine the type of event to return based on the given event code.
            switch (eventCode)
            {
            //ArriveAtCallCenter event.
            case EventCode.ArriveAtCallCenter:
                newEvent = CreateArriveAtCallCenter(e);
                break;

            //CompleteIVRServiceEvent.
            case EventCode.CompleteIVRService:
                newEvent = CreateCompleteIVRService(e);
                break;

            //EndWaitInQueue and CompleteServiceDesk event.  To determine the return event,
            //this factory has to check if their is room in the service desk for the entity.
            case EventCode.EndWaitInQueue:
            case EventCode.CompleteServiceDesk:
                newEvent = CheckDesk(e);
                break;
            }
            return(newEvent);
        }//End CreateEvent.
Beispiel #2
0
        }//End DisplayControl.

        /****************************************************
        * Formats the event in a row of data and displays it.
        ****************************************************/
        protected void DisplayRowData(SimEvent se)
        {
            //Convert the event's entity id value to string.
            string entityID = Convert.ToString(se.EventEntity.EntityID);

            string eventName = se.EventName;

            //Convert the event time to string.
            string eventTime = (se.EventTime != null ? se.EventTime.Value.ToString(TIME_FORMAT) : NULL_VALUE);


            //Convert the event's entity begin wait value to string.
            string beginWait = (se.EventEntity.BeginWait != null ?se.EventEntity.BeginWait.Value.ToString(TIME_FORMAT) : NULL_VALUE);

            //Convert the event's entity start time value to string.
            string startTime = (se.EventEntity.StartTime != null ? se.EventEntity.StartTime.Value.ToString(TIME_FORMAT) : NULL_VALUE);

            //Put the event's entity product type value in a local string.
            string productType = se.EventEntity.ProductType;

            //Create a display string.
            string s = string.Format(FORMAT, entityID.PadRight(ENTITY_ID_PAD, ' '),
                                     eventName.PadRight(EVENT_NAME_PAD, ' '), eventTime.PadRight(EVENT_TIME_PAD, ' '), beginWait.PadRight(BEGIN_WAIT_PAD, ' '),
                                     startTime.PadRight(START_TIME_PAD, ' '), productType.PadRight(PRODUCT_TYPE_PAD, ' '));

            //Display the row data.
            displayOutput.Items.Add(s);
        }//End DisplayRowData.
Beispiel #3
0
        }//End InitServiceDesksandQueues.

        /************************************************************************************************************
        * Runs the discrete event simulator.  Responible for adding events to the calendar and executing the current
        * event until the simulation clock reaches the end time.
        ************************************************************************************************************/
        public void RunSimulation()
        {
            //Add the first entity/event to the simulation.
            AddEntity();

            //Run the simulation...
            while (calendar.SimClock.TimeOfDay <= simEndTime.TimeOfDay)
            {
                //Set the simulation time to that of the next event.
                calendar.UpdateClock();

                //Retrieve the next event to be executed from the calendar.
                SimEvent curEvent = calendar.FetchEvent();

                //Check if the current event falls within the simulation time
                //(prevents a bug that lets events run after the simEndTime).
                if (curEvent.EventTime <= simEndTime)
                {
                    //Execute the event and set result equal to the return code.
                    int?result = curEvent.ExecuteEvent();

                    //If the result is not null...
                    if (result != null)
                    {
                        //Create an event code equal to the event result.
                        int eventCode = Convert.ToInt16(result);

                        //Create a new event using the entity from the current event and the returned event code.
                        SimEvent newEvent = eventFactory.CreateEvent(eventCode, curEvent.EventEntity);

                        //Add the new event to the calendar.
                        calendar.AddEvent(newEvent);
                    }
                    else
                    {
                        //If the result is null, remove the entity from the master entity list.
                        entityList.Remove(curEvent.EventEntity);
                    }

                    //If the executed event was an arrive at call center event...
                    if (curEvent is ArriveAtCallCenter)
                    {
                        //Add a new entity/event to the simulation.
                        AddEntity();
                    }

                    //Pause.
                    Thread.Sleep(threadSleepTime);
                }
            }
            //Update the statistics handler observe time.
            TimeSpan span = simEndTime - simStartTime;

            stats.ObserveTime = (int)span.TotalMinutes;

            //Perform the calculations required at the end of a simulation.
            stats.PerformSimEndCalculations(serviceDeskList);
        }//End RunSimulation.
Beispiel #4
0
        }//End UpdateClock

        /***************************************************
         * Add the given event to the calendar's event list.
         **************************************************/
        public void AddEvent(SimEvent newEvent)
        {
            eventList.Add(newEvent);
            //Sort the events by time.
            eventList.Sort();

            //Fire calendar update event.
            OnCalendarUpdate();
        }//End AddEvent.
Beispiel #5
0
        }//End RunSimulation.

        /***********************************************************************************************
         * Creates a new entity, puts it in an arrive at call center event, and adds it to the calendar.
         **********************************************************************************************/
        private void AddEntity()
        {
            //Create a new entity.
            Entity newEntity = entityFactory.MakeEntity();

            //Use the new entity to create an arrive at call center event.
            SimEvent newEvent = eventFactory.CreateEvent(EventCode.ArriveAtCallCenter, newEntity);

            //Add the event to the calendar.
            calendar.AddEvent(newEvent);

            //Add the entity to the master entity list.
            entityList.Add(newEntity);
        }//End AddEntity.
Beispiel #6
0
        }//End AddEvent.

        /****************************************
         * Returns the next event to be executed.
         ***************************************/
        public SimEvent FetchEvent()
        {
            SimEvent curEvent = null;

            //Sort the events by time.
            eventList.Sort();

            //Check that an event exists in the system...
            if (eventList.Count() > 0)
            {
                //Set the return event to the next event to be executed.
                curEvent = eventList[0];

                //Remove the return event from the event list.
                eventList.Remove(curEvent);

                //Fire calendar update event.
                OnCalendarUpdate();
            }
            return(curEvent);
        }//End FetchEvent.