Beispiel #1
0
 /**************
  * Constructor.
  *************/
 public CompleteServiceDesk(Entity eventEntity, DateTime eventTime, StatisticsHandler stats, Calendar calendar, ServiceDesk serviceDesk, int serviceTime)
     : base(eventEntity, eventTime, stats, calendar)
 {
     this.eventName   = EVENT_NAME;
     this.serviceDesk = serviceDesk;
     this.serviceDesk.AddEntity(eventEntity, serviceTime);
 }//End Constructor.
Beispiel #2
0
        }//End PerformSimEndCalculations.

        /*******************************************************************
         * Calculates representative utilization for the given service desk.
         ******************************************************************/
        private void CalculateRepUtiliziation(ServiceDesk serviceDesk)
        {
            //Get the sum of total workable seconds.
            double totalTime = observeTime * serviceDesk.ServiceReps.Count() * TO_SECONDS;

            //workTime is the total seconds worked for all service reps combined.
            double workTime = 0;

            //Get the total seconds worked for each service rep and put in workTime.
            foreach (ServiceRep rep in serviceDesk.ServiceReps)
            {
                workTime += rep.WorkTime;
            }

            //Calculate the representative utilization and store in the dictionary.
            try
            {
                double utilization = workTime / totalTime;
                repUtilization[serviceDesk.ProductType] = utilization;
            }
            catch (DivideByZeroException e)
            {
                //  repUtilization[serviceDesk.ProductType] = 0;
            }
        }//End CalculateRepUtilization.
Beispiel #3
0
        /*************
         * Constructor
         ************/
        public Queue(ServiceDesk serviceDesk, string productType)
        {
            entitiesInQueue  = new List <Entity>();
            this.serviceDesk = serviceDesk;
            this.productType = productType;

            //Observe when a service rep is made available at the service desk.
            serviceDesk.ResourceFree += new ServiceDesk.ResourceFreeHandler(GetEntityReady);
        }//End Constructor.
Beispiel #4
0
        }//End CreateEvent.

        /**************************************************************************************
         * Checks to see if the service desk that supports the entitie's product type has space
         * available to service the entity.  If it does it returns a CompleteServiceDesk event,
         * otherwise it returns a EndQueueWait event.
         *************************************************************************************/
        private SimEvent CheckDesk(Entity e)
        {
            SimEvent newEvent;

            //Find the target service desk.
            ServiceDesk target = sim.serviceDeskList.Find(sd => sd.ProductType == e.ProductType);

            //Check if its busy.
            if (target.IsResourceBusy())
            {
                //If it is, place entity in wait queue.
                newEvent = CreateEndQueueWait(e);
            }
            else
            {
                //If it isn't, place entity on service desk.
                newEvent = CreateCompleteServiceDesk(e);
            }

            return(newEvent);
        }//End CheckDesk.
Beispiel #5
0
        }//End InitFactories.

        /*************************************************************************************************
         * Initializes the service desks and queues used in this simulation, and adds them to their lists.
         ************************************************************************************************/
        private void InitServiceDesksAndQueues(int serviceRepsCarAudio, int serviceRepsOther, double timeModCarStereoService, double timeModOtherService)
        {
            //Initialize the service desk and queue lists.
            this.serviceDeskList = new List <ServiceDesk>();
            this.queueList       = new List <Queue>();

            //Initialize the service desks.
            ServiceDesk carStereoDesk = new ServiceDesk(ProductData.CAR_STEREO_PRODUCT, serviceRepsCarAudio, timeModCarStereoService, dice);
            ServiceDesk otherDesk     = new ServiceDesk(ProductData.OTHER_PRODUCT, serviceRepsOther, timeModOtherService, dice);

            //Initialize the queues.
            Queue carStereoQueue = new Queue(carStereoDesk, ProductData.CAR_STEREO_PRODUCT);
            Queue otherQueue     = new Queue(otherDesk, ProductData.OTHER_PRODUCT);

            //Add the servce desks to the service desk list.
            serviceDeskList.Add(carStereoDesk);
            serviceDeskList.Add(otherDesk);

            //Add the queues to the queue list.
            queueList.Add(carStereoQueue);
            queueList.Add(otherQueue);
        }//End InitServiceDesksandQueues.
Beispiel #6
0
        }//End CreateEndQueueWait.

        /**************************************************
         * Creates and returns a CompleteServiceDesk event.
         *************************************************/
        private SimEvent CreateCompleteServiceDesk(Entity e)
        {
            //Find the target service desk.
            ServiceDesk desk = sim.serviceDeskList.Find(sd => sd.ProductType == e.ProductType);

            //Calculate the amount of time until this event is complete.
            int eventTimeSeconds = desk.GetDelayTime();

            //Create a new event time.
            DateTime eventTime = new DateTime(sim.Calendar.SimClock.Year, sim.Calendar.SimClock.Month, sim.Calendar.SimClock.Day,
                                              sim.Calendar.SimClock.Hour, sim.Calendar.SimClock.Minute, sim.Calendar.SimClock.Second);

            eventTime = eventTime.AddSeconds(eventTimeSeconds);


            //The time the service rep will be working with this client.
            int serviceRepWorkTime;

            //Check that the event time happens within the bounds of the simulation time.
            if (eventTime <= sim.simEndTime)
            {
                //If it does, the service rep work time will be equal to the event time seconds.
                serviceRepWorkTime = eventTimeSeconds;
            }
            else
            {
                //If it isn't, the service rep work time equals the difference between the end time and now.
                //This is done to prevent errors calculating representative utiliziation.
                TimeSpan span = (TimeSpan)(sim.simEndTime - sim.Calendar.SimClock);
                serviceRepWorkTime = span.Seconds;
            }

            //Create and return a new CompleteServiceDesk event.
            SimEvent newEvent = new CompleteServiceDesk(e, eventTime, sim.Stats, sim.Calendar, desk, serviceRepWorkTime);

            return(newEvent);
        }//End CreateCompleteServiceDesk.