Example #1
0
 //-------------------------------------------------------------------
 //- METHODS                                                         -
 //-------------------------------------------------------------------
 /// <summary>
 /// Creates a new instance of the SwitchCompleteProcessArgs class
 /// </summary>
 /// <param name="eventFactory">The instance of the EventFactory class</param>
 /// <param name="queueManager">The instance of the QueueManager class</param>
 /// <param name="salesManager">The instance of the SalesManager class</param>
 /// <exception cref="System.ArgumentNullException">Thrown when any of the given arguments are null</exception>
 public SwitchCompleteProcessArgs(EventFactory eventFactory, QueueManager queueManager, SalesForceManager salesManager)
     : base(eventFactory, queueManager)
 {
     //Check that eventFactory is not null
     if (eventFactory != null)
     {
         //Check that queue manager is not null
         if (queueManager != null)
         {
             //check that sales manager is not null
             if (salesManager != null)
             {
                 this.salesManager = salesManager;
             }
             else //The given salesManager
             {
                 throw new ArgumentNullException("salesManager", "Attempted to pass null SalesManager to SwitchCompleteProcessArgs.Process");
             }
         }
         else // The given QueueManager was null
         {
             throw new ArgumentNullException("queueManager", "Attempted to pass null QueueManager to SwitchCompleteProcessArgs constructor");
         }
     }
     else // The given EventFactory was null
     {
         throw new ArgumentNullException("eventFactory", "Attempted to pass null EventFactory to SwitchCompleteProcessArgs constructor");
     }
 }
Example #2
0
        //-------------------------------------------------------------------
        //- METHODS                                                         -
        //-------------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of the Simulator class with the given parameters
        /// </summary>
        /// <param name="beginTime">The time that simulation is set to begin</param>
        /// <param name="runningTime">The duration that the simulation will run for</param>
        /// <param name="callArriveMultiplier">The multiplier used to calculate the time between calls</param>
        /// <param name="switchDelayMultiplier">The multiplier used to calculate the time calls spend at the switch</param>
        /// <param name="productTypes">The List of all product types</param>
        /// <param name="maxQueueLength">The maximum number of calls in a queue</param>
        /// <param name="singleQueueLength">Whether or not the QueueManager is set to count all queues as one or not</param>
        /// <param name="excessiveWaitTime">The TimeSpan that beyond which a call is considered having waited to long</param>
        /// <param name="representativeNumbers">The Dictionary containing the Types and numbers of SalesRepresentatives</param>
        public Simulator(
            DateTime beginTime,
            TimeSpan runningTime,
            double callArriveMultiplier,
            double switchDelayMultiplier,
            List <ProductType> productTypes,
            int maxQueueLength,
            bool singleQueueLength,
            TimeSpan excessiveWaitTime,
            Dictionary <SalesRepType, int> representativeNumbers)
        {
            this.beginTime             = beginTime;
            this.callArriveMultiplier  = callArriveMultiplier;
            this.switchDelayMultiplier = switchDelayMultiplier;
            this.productTypes          = productTypes;
            this.calendar           = new Calendar();
            this.callFactory        = new CallFactory();
            this.eventFactory       = new EventFactory();
            this.clock              = beginTime;
            this.excessiveWaitTime  = excessiveWaitTime;
            this.queueManager       = new QueueManager(maxQueueLength, productTypes, singleQueueLength);
            this.salesManager       = new SalesForceManager(representativeNumbers);
            this.processArgsFactory = new ProcessArgsFactory(this);

            //Create the end simulation event
            DateTime finishingTime  = beginTime + runningTime;
            Event    endReplication = eventFactory.CreateEvent(EEventType.EndReplication, finishingTime, null);

            calendar.AddEvent(endReplication);

            //Create the first call arrive event
            Call  call      = callFactory.CreateCall();
            Event firstCall = eventFactory.CreateEvent(EEventType.CallArrive, beginTime, call);

            calendar.AddEvent(firstCall);
        }