private void button2_Click(object sender, EventArgs e) { //Button Two is for testing CalendarClass newCalendar = new CalendarClass(); EntityClass newEntity = new EntityClass(0, ECallType.stereo); EventClass newCallEvent = new EventClass(newEntity, EEventType.CallArrive, 0); newCalendar.addEvent(newCallEvent); /*EntityClass newEntity1 = new EntityClass(1, ECallType.other); * EventClass newCallEvent1 = new EventClass(newEntity1, EEventType.CompleteServiceCall, 100); * newCalendar.addEvent(newCallEvent1); * * EntityClass newEntity2 = new EntityClass(2, ECallType.other); * EventClass newCallEvent2 = new EventClass(newEntity2, EEventType.CompleteIVR, 50); * newCalendar.addEvent(newCallEvent2); * * newCalendar.displayCalendar(listBox1);*/ //VARS /*activeEvent = mainCalendar.getTopEvent(); * activeEntity = activeEvent.currentEntity; * int currentTime = 0; * * //While Loop to see what the simulation will load (call Types) * while (activeEvent.currentEventType != EEventType.EndSim) * { * //Update the System Time * currentTime = activeEvent.schedualedTime; * //If conditions (UPDATE TO CASE STATEMENTS) * if (activeEvent.currentEventType == EEventType.CallArrive) * { * //Process the call * simClass.ProcessCallArrive(); * //Console.WriteLine("ONE"); * } * if (activeEvent.currentEventType == EEventType.CompleteIVR) * { * //Process the Switch * simClass.CompleteIVR(); * Console.WriteLine("TWO"); * } * if (activeEvent.currentEventType == EEventType.CompleteServiceCall) * { * //Process the Completed call * simClass.CompleteServiceCall(); * Console.WriteLine("THREE"); * } * if (activeEvent.currentEventType == EEventType.EndSim) * { * //End the Simulation * simClass.EndSim(); * Console.WriteLine("FOUR"); * } * }*/ newCalendar.displayCalendar(listBox1); }
//**************************************************************** // PROCESS THE CALL ARRIVE EVENT //**************************************************************** public void ProcessCallArrive() { if (totalQueueLength < GlobalVars.MAX_ON_HOLD) { //Continues through the system int interval = Convert.ToInt16(diceRoller.DiceRoll() * 0.333); int scheduledTime = currentTime + interval; EventClass newEvent = new EventClass(activeEntity, EEventType.CompleteIVR, scheduledTime); mainCalendar.addEvent(newEvent); //This is the new completeSwitchEvent } else { //Too many calls, hangs up hangupCount++; } //CREATES A NEW CALL ARRIVE EVENT int newInterval = Convert.ToInt16(diceRoller.DiceRoll() * 0.333); int newscheduledTime = currentTime + newInterval; //Choose call type. Rule: 16% stereo, rest % is other //ran num 1-100 if <=16 streoo Random rand = new Random(); int newRandom = rand.Next(1, 100); ECallType newCallType; if (newRandom <= 16) { //Stereo newCallType = ECallType.stereo; } else { //Other newCallType = ECallType.other; } EntityClass newEntity = new EntityClass(GLOBALENTITYID, newCallType); GLOBALENTITYID++; EventClass newArriveEvent = new EventClass(newEntity, EEventType.CallArrive, newscheduledTime); //Create new arrivalEvent, Another caller //Add to calendar mainCalendar.addEvent(newArriveEvent); }