} // end of AffectedEntities #endregion //-------------------------------------------------------------------------------------------------- // Events //-------------------------------------------------------------------------------------------------- #region TriggerStartEvent /// <summary> /// Overrides the state change at start. Server is not idle, and end event is triggered. /// </summary> override public void StateChangeStartEvent(DateTime time, ISimulationEngine simEngine) { double serviceTimeMinutes = ((SimulationModelQueuing)ParentControlUnit.ParentSimulationModel).ServiceTime; Server.IsIdle = false; simEngine.AddScheduledEvent(EndEvent, time + TimeSpan.FromMinutes(Distributions.Instance.Exponential(serviceTimeMinutes))); } // end of TriggerStartEvent
} // end of TreatmentFacilities #endregion //-------------------------------------------------------------------------------------------------- // Methods //-------------------------------------------------------------------------------------------------- #region StopCurrentActivities /// <summary> /// Method to stop all activities the staff resources are involved in. /// To be used before the start of a new action. /// </summary> /// <param name="time">The time activities are stopped</param> /// <param name="simEngine">The simulation engine responsible for stopping</param> public void StopCurrentActivities(DateTime time, ISimulationEngine simEngine) { if (MainDoctor != null) { MainDoctor.StopCurrentActivities(time, simEngine); } if (AssistingDoctors != null) { foreach (EntityDoctor doc in AssistingDoctors) { doc.StopCurrentActivities(time, simEngine); } // end foreach } // end if if (MainNurse != null) { MainNurse.StopCurrentActivities(time, simEngine); } if (AssistingNurses != null) { foreach (EntityNurse nurse in AssistingNurses) { nurse.StopCurrentActivities(time, simEngine); } // end foreach } // end if } // end of StopCurrentActivities
} // end of Event #endregion //-------------------------------------------------------------------------------------------------- // State Change //-------------------------------------------------------------------------------------------------- #region Trigger /// <summary> /// Acutal state change of arrival. If patient arrives from waiting list path is set, otherwise /// next action is taken. /// </summary> /// <param name="time">Time the patient arrives</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> protected override void StateChange(DateTime time, ISimulationEngine simEngine) { //-------------------------------------------------------------------------------------------------- // In case Patient is returning from special service facility the path // has already been set and needs update to next action //-------------------------------------------------------------------------------------------------- if (Patient.OutpatientTreatmentPath != null) { Patient.OutpatientTreatmentPath.UpdateNextAction(); } else { Patient.OutpatientTreatmentPath = InputData.CreateOutpatientTreatmentPath(Patient, Admission, ScheduledTime, false); ParentControlUnit.AddEntity(Patient); } // end if if (Patient.OutpatientTreatmentPath.TakeNextAction(simEngine, this, time, ParentControlUnit)) { if (Patient.OccupiedFacility == null || Patient.OccupiedFacility.ParentDepartmentControl != ParentControlUnit) { SequentialEvents.Add(Patient.StartWaitingActivity(((ControlUnitOutpatient)ParentControlUnit).WaitingAreaPatientForNextActionType(Patient.OutpatientTreatmentPath.GetCurrentActionType()))); } else { ActivityWaitInFacility waitInFacility = new ActivityWaitInFacility(ParentControlUnit, Patient, Patient.OccupiedFacility); SequentialEvents.Add(waitInFacility.StartEvent); } // end if } // end if } // end of Trigger
} // end of AffectedEntities #endregion //-------------------------------------------------------------------------------------------------- // Events //-------------------------------------------------------------------------------------------------- #region TriggerStartEvent /// <summary> /// Overrides the state change at start. If an holding entity was passed as parameter /// the waiting entity is added /// </summary> override public void StateChangeStartEvent(DateTime time, ISimulationEngine simEngine) { if (WaitingArea != null) { WaitingArea.HoldedEntities.Add(WaitingEntity); } } // end of TriggerStartEvent
} // end of Event #endregion //-------------------------------------------------------------------------------------------------- // Statechange //-------------------------------------------------------------------------------------------------- #region Trigger /// <summary> /// Overriden state change of the event. If the patient's path indicates a inpatient or outpatient /// admission the corresponding request is sent up the control tree. /// </summary> /// <param name="time">Time the patient leaves</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> protected override void StateChange(DateTime time, ISimulationEngine simEngine) { ParentControlUnit.RemoveEntity(Patient); Patient.CorrespondingDoctor = null; if (Patient.OutpatientTreatmentPath.InpatientAdmission != null) { RequestMoveInpatient reqMoveInpatient = new RequestMoveInpatient(Patient.ToArray(), time, Patient, ParentControlUnit, Patient.OutpatientTreatmentPath.InpatientAdmission); ParentControlUnit.DelegateOutBox.Add(reqMoveInpatient); } // end if if (Patient.OutpatientTreatmentPath.OutpatientAdmission != null) { RequestMoveOutpatient reqMoveOutPatient = new RequestMoveOutpatient(Patient.ToArray(), time, Patient, ParentControlUnit, Patient.OutpatientTreatmentPath.OutpatientAdmission); ParentControlUnit.DelegateOutBox.Add(reqMoveOutPatient); } // end if Patient.OutpatientTreatmentPath = null; } // end of Trigger
} // end of Initialize #endregion //-------------------------------------------------------------------------------------------------- // Rule Handling //-------------------------------------------------------------------------------------------------- #region PerformCustomRules protected override bool PerformCustomRules(DateTime time, ISimulationEngine simEngine) { bool eventLaunched = false; bool newEventLauchned = true; while (newEventLauchned) { if (PerformAssessment(time, simEngine)) { eventLaunched = true; continue; } // end if if (PerformDisptatching(time, simEngine)) { eventLaunched = true; continue; } // end if if (PerformControlled(time, simEngine)) { eventLaunched = true; continue; } // end if newEventLauchned = false; } // end while return(eventLaunched); } // end of PerformAssessment
} // end of RemoveActivity #endregion #region StopCurrentActivities public void StopCurrentActivities(DateTime time, ISimulationEngine simEngine) { while (CurrentActivities.Count > 0) { CurrentActivities.First().EndEvent.Trigger(time, simEngine); } // end while } // end of StopCurrentActivites
/// <summary> /// Initialization: Patient arrival stream for waiting list patients is initialized. /// If dispatching is done at discrete events this stream is initialized as well. /// </summary> /// <param name="startTime">Time the simulation starts</param> /// <param name="simEngine">SimEngine that handles the simulation run</param> protected override void CustomInitialize(DateTime startTime, ISimulationEngine simEngine) { WaitingListSchedule.Initialize(startTime); AddEntity((EntityWaitingListSchedule)WaitingListSchedule); DateTime nextArrivalTime; Admission admission; EntityPatient newPatient = InputData.GetNextWaitingListPatient(out nextArrivalTime, out admission, this, startTime); if (newPatient != null) { EventOutpatientWaitingListPatientArrival nextArrival = new EventOutpatientWaitingListPatientArrival(this, (ControlUnitOutpatient)ParentControlUnit, newPatient, admission, InputData); simEngine.AddScheduledEvent(nextArrival, nextArrivalTime); } // end if WaitingListSchedule.ReadyForDispatch = true; if (AssigningSlotsAtEvents) { EventOutpatientStartDispatching nextDispatch = new EventOutpatientStartDispatching(this, WaitingListSchedule, InputData); simEngine.AddScheduledEvent(nextDispatch, InputData.NextDispatching(startTime)); WaitingListSchedule.ReadyForDispatch = false; } } // end of Initialize
} // end of InputData #endregion //-------------------------------------------------------------------------------------------------- // Enter Leave //-------------------------------------------------------------------------------------------------- #region EntityEnterControlUnit public override Event EntityEnterControlUnit(DateTime time, ISimulationEngine simEngine, Entity entity, IDelegate originDelegate) { if (entity is EntityHealthCareStaff) { return(new EventControlUnitStaffEnterLeave(this, true, (EntityStaff)entity, originDelegate, WaitingRoomForStaff((EntityHealthCareStaff)entity))); } EntityPatient patient = (EntityPatient)entity; if (originDelegate is RequestSpecialFacilitiyService) { return(new EventOutpatientArrival(this, patient, time, InputData, null)); } else if (originDelegate is RequestMoveOutpatient) { RequestMoveOutpatient outDel = (RequestMoveOutpatient)originDelegate; return(new EventOutpatientWaitingListPatientArrival( WaitingListControlUnit, this, patient, outDel.OutpatientAdmission, InputData)); } // end if return(null); } // end of EntityEnterControlUnit
} // end of PerformDisptatching #endregion #region PerformControlled protected bool PerformControlled(DateTime time, ISimulationEngine simEngine) { IReadOnlyList <EntityDoctor> doctors = ControlledDoctors; if (RoundsDue) { List <EntityDoctor> availableDoctors = doctors.Where(p => p.IsWaiting()).ToList(); if (availableDoctors.Count > 0) { ActivityInpatientRound newRound = new ActivityInpatientRound(this, availableDoctors, Wards); foreach (EntityDoctor doc in availableDoctors) { doc.StopWaitingActivity(time, simEngine); } // end foreach newRound.StartEvent.Trigger(time, simEngine); foreach (EntityDoctor doc in doctors) { doc.BlockedForDispatching = false; } // end foreach RoundsDue = false; } // end if } // end foreach return(false); } // end of PerformControlled
} // end of StopCurrentActivites #endregion #region StopWaitingActivity public void StopWaitingActivity(DateTime time, ISimulationEngine simEngine) { if (CurrentActivities.Count == 1 && CurrentActivities.First().GetType() == typeof(ActivityWait)) { StopCurrentActivities(time, simEngine); } } // end of StopCurrentActivites
public RobotPlayerNormalMovementPart(IUserMovementInput movementInput, ISimulationEngine simulationEngine, IWorldLocator worldLocator, IPositionComponent physical, BasicPhysicsPart physics) { MovementInput = movementInput; SimulationEngine = simulationEngine; WorldLocator = worldLocator; Physical = physical; Physics = physics; }
} // end of InitializeVisualization #endregion #region Initialize /// <summary> /// Default initialization of model. Adds and initializes all control units /// and calls the custom initalize method /// </summary> /// <param name="simEngine"></param> public void Initialize(ISimulationEngine simEngine) { AddControlUnit(RootControlUnit); RootControlUnit.Initialize(StartTime, simEngine); CustomInitializeModel(); } // end of Initialize
} // end of ControlUnit #endregion #region Initialize /// <summary> /// Initializes patient stream /// </summary> /// <param name="startTime">Start time of the simulation model</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> protected override void CustomInitialize(DateTime startTime, ISimulationEngine simEngine) { EntityPatient patient = InputData.GetNextPatient(); EventEmergencyPatientArrival firstPatient = new EventEmergencyPatientArrival(this, patient, InputData); simEngine.AddScheduledEvent(firstPatient, startTime + InputData.PatientArrivalTime(startTime)); } // end of Initialize
} // end of Event #endregion //-------------------------------------------------------------------------------------------------- // State Change //-------------------------------------------------------------------------------------------------- #region Trigger /// <summary> /// State change of event. Sets Dispatching flag to true and schedules next event. /// </summary> /// <param name="time">Current time</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> protected override void StateChange(DateTime time, ISimulationEngine simEngine) { WaitingListSchedule.ReadyForDispatch = true; EventOutpatientStartDispatching nextDispatch = new EventOutpatientStartDispatching(ParentControlUnit, WaitingListSchedule, InputData); simEngine.AddScheduledEvent(nextDispatch, InputData.NextDispatching(time)); } // end of Trigger
} // end of Initialize #endregion //-------------------------------------------------------------------------------------------------- // Rule Handling //-------------------------------------------------------------------------------------------------- #region PerformCustomRules /// <summary> /// Dispatches slot requests by booking in the booking model, further, now show probabilities /// and arrival deviations of patients are calculated. Corresponding events for arrival are scheduled. /// </summary> /// <param name="startTime">Time rules are executed</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> /// <returns>False</returns> protected override bool PerformCustomRules(DateTime time, ISimulationEngine simEngine) { if (RAEL.Count == 0) { return(false); } if (!WaitingListSchedule.ReadyForDispatch) { return(false); } while (RAEL.Count > 0) { RequestOutpatientWaitingListPatientToAssignSlot reqToDisptatch = (RequestOutpatientWaitingListPatientToAssignSlot)RAEL.First(); DateTime earliestTime = time; earliestTime = reqToDisptatch.EarliestTime; Slot slot = WaitingListSchedule.GetEarliestSlotTime(time, earliestTime, reqToDisptatch.Patient, reqToDisptatch.AdmissionType); WaitingListSchedule.BookSlot(slot, reqToDisptatch.AdmissionType); reqToDisptatch.Patient.StopCurrentActivities(time, simEngine); ParentControlUnit.RemoveRequest(reqToDisptatch); RemoveRequest(reqToDisptatch); if (InputData.NoShowForAppointment(reqToDisptatch.Patient, reqToDisptatch.AdmissionType, slot, time)) { continue; } DateTime arrivalTime = slot.StartTime + InputData.PatientArrivalDeviationFromSlotTime(reqToDisptatch.Patient, reqToDisptatch.AdmissionType); arrivalTime = new DateTime(Math.Max(time.Ticks, arrivalTime.Ticks)); EventOutpatientArrival arrival = new EventOutpatientArrival(ParentControlUnit, reqToDisptatch.Patient, slot.StartTime, InputData, reqToDisptatch.AdmissionType); simEngine.AddScheduledEvent(arrival, arrivalTime); Event patientWait = reqToDisptatch.Patient.StartWaitingActivity(null); patientWait.Trigger(time, simEngine); } // end while WaitingListSchedule.ReadyForDispatch = false; return(false); } // end of PerformCustomRules
} // end of CustomInitialize #endregion #region Initialize /// <summary> /// Initializes the control unit, this may happen after creation of object, e.g. when start and end times /// of the model are adjusted after instanciation. Calls a custom initialize that can be overwritten by /// the user and initializes sub trees /// </summary> /// <param name="startTime">Time the simulation starts</param> /// <param name="simEngine">SimEngine that handles the simulation run</param> public virtual void Initialize(DateTime startTime, ISimulationEngine simEngine) { CustomInitialize(startTime, simEngine); foreach (ControlUnit childControl in ChildControlUnits) { childControl.Initialize(startTime, simEngine); } // end foreach } // end of InitializeActiveEntities
public void StopSimulation() { if (_simulationEngine == null) { return; } _simulationEngine.Stop(); _simulationEngine = null; }
protected override void CustomInitialize(DateTime startTime, ISimulationEngine simEngine) { if (startTime.Date + InputData.InPatientStartTime() >= startTime) { simEngine.AddScheduledEvent(new EventInpatientDayStart(this), startTime + InputData.InPatientStartTime()); } else { simEngine.AddScheduledEvent(new EventInpatientDayStart(this), startTime.Date + TimeSpan.FromDays(1) + InputData.InPatientStartTime()); } // end if } // end of Initialize
} // end of Initialize #endregion //-------------------------------------------------------------------------------------------------- // Rule Handling //-------------------------------------------------------------------------------------------------- #region PerformCustomRules /// <summary> /// Custom rules of diagnostic control, just calls dispatching method as long as no further event is triggered /// </summary> /// <param name="startTime">Time rules are executed</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> /// <returns>False</returns> protected override bool PerformCustomRules(DateTime time, ISimulationEngine simEngine) { bool eventLaunched = false; while (PerformDisptatching(time, simEngine)) { eventLaunched = true; } // end while return(eventLaunched); } // end of PerformCustomRules
} // end of AdmissionType #endregion //-------------------------------------------------------------------------------------------------- // Events //-------------------------------------------------------------------------------------------------- #region TriggerStartEvent /// <summary> /// State changes of the activities start event. Request for slot assigning is filed /// </summary> /// <param name="time"> Time of activity start</param> /// <param name="simEngine"> SimEngine the handles the activity triggering</param> override public void StateChangeStartEvent(DateTime time, ISimulationEngine simEngine) { RequestOutpatientWaitingListPatientToAssignSlot requestAssign = new RequestOutpatientWaitingListPatientToAssignSlot(Patient, time, AdmissionType, EarliestTime, LatestTime); ParentControlUnit.AddRequest(requestAssign); } // end of TriggerStartEvent
} // end of #endregion #region Initialize /// <summary> /// Arrival stream of clients is initialized /// </summary> /// <param name="startTime">Start time of simulation</param> /// <param name="simEngine">End time of simulation</param> protected override void CustomInitialize(DateTime startTime, ISimulationEngine simEngine) { EntityClient nextClient = new EntityClient(); EventClientArrival nextClientArrival = new EventClientArrival(this, nextClient); double arrivalTimeMinutes = ((SimulationModelQueuing)ParentSimulationModel).ArrivalTime; simEngine.AddScheduledEvent(nextClientArrival, startTime + TimeSpan.FromMinutes(Distributions.Instance.Exponential(arrivalTimeMinutes))); } // end of CustomInitialize
} // end of PerformAssessment #endregion #region PerformAssessment protected bool PerformAssessment(DateTime time, ISimulationEngine simEngine) { PossibleRAEL.Clear(); PossibleEmergencyStayInBed.Clear(); PossibleScheduledStayInBed.Clear(); PossibleChangeWard.Clear(); bool bedsAvailable = AllAvailableBeds > 0; foreach (ActivityRequest request in RAEL) { if (request.Activity == "ActivityInpatientStayInBed" && bedsAvailable) { if (((RequestInpatientStayInBed)request).InpatientOrigin == InpatientOrigin.Scheduled) { PossibleScheduledStayInBed.Add((RequestInpatientStayInBed)request); } else if (((RequestInpatientStayInBed)request).InpatientOrigin == InpatientOrigin.Emergency) { PossibleEmergencyStayInBed.Add((RequestInpatientStayInBed)request); } } else if (request is RequestInpatientActivity && ((RequestInpatientActivity)request).InpatientTreatment.IsEmergencyTreatment) { PossibleRAEL.Add(request); } else if (request is RequestInpatientActivity && ((RequestInpatientActivity)request).Patient.StaysInBed && !RoundsDue && DuringWeekday) { PossibleRAEL.Add(request); } else if (request is RequestInpatientResumeActivity && ((RequestInpatientResumeActivity)request).Patient.StaysInBed && !RoundsDue && DuringWeekday) { PossibleRAEL.Add(request); } else if (request is RequestInpatientDoctorOrganziationalWork && ((RequestInpatientDoctorOrganziationalWork)request).Doctor.IsWaiting() && !RoundsDue && (((RequestInpatientDoctorOrganziationalWork)request).Doctor).ParentControlUnit == this) { PossibleRAEL.Add(request); } else if (bedsAvailable && request is RequestInpatientChangeWard && ((RequestInpatientChangeWard)request).Patient.StaysInBed) { PossibleChangeWard.Add((RequestInpatientChangeWard)request); } } // end foreach return(false); } // end of PerformAssessment
} // end of OutpatientControlUnit #endregion #region Initialize /// <summary> /// Initializes walk in patient stream /// </summary> /// <param name="startTime">Start time of the simulation model</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> protected override void CustomInitialize(DateTime startTime, ISimulationEngine simEngine) { DateTime arrivalWalkIn; EntityPatient patient = InputData.GetNextWalkInPatient(out arrivalWalkIn, ParentControlUnit, startTime); if (patient != null) { EventOutpatientWalkInPatientArrival firstPatient = new EventOutpatientWalkInPatientArrival(this, InputData, patient); simEngine.AddScheduledEvent(firstPatient, arrivalWalkIn); } // end if } // end of Initialize
} // end of OutpatientAdmission #endregion //-------------------------------------------------------------------------------------------------- // Methods //-------------------------------------------------------------------------------------------------- #region TakeNextAction /// <summary> /// Action taking along path. Different actions for diagnostics, leaving and /// actions within the emergency department /// </summary> /// <param name="simEngine">SimEngine responsible for simulation execution</param> /// <param name="currentEvent">Event after which next action is taken</param> /// <param name="time">Time next action is taken</param> /// <param name="parentControlUnit">Control unit that hosts the next action</param> /// <returns>Returns true if Patient goes in an waiting activitiy before next action, else false </returns> public override bool TakeNextAction( ISimulationEngine simEngine, Event currentEvent, DateTime time, ControlUnit parentControlUnit) { ControlUnit parentDepartmentControl = parentControlUnit; if (parentControlUnit is ControlUnitOrganizationalUnit) { parentDepartmentControl = ((ControlUnitOrganizationalUnit)parentControlUnit).ParentDepartmentControl; } if (GetCurrentActionType().Type == "Diagnostics") { RequestSpecialFacilitiyService reqeustForDiagnostics = new RequestSpecialFacilitiyService(parentDepartmentControl, ParentPatient, time, new SpecialServiceAdmissionTypes(GetCurrentActionType().Identifier)); parentDepartmentControl.DelegateOutBox.Add(reqeustForDiagnostics); return(false); } // end if if (GetCurrentActionType().Type == "Leave") { EventEmergencyPatientLeave patientLeave = new EventEmergencyPatientLeave(parentDepartmentControl, ParentPatient, ((ControlUnitEmergency)parentDepartmentControl).InputData); currentEvent.SequentialEvents.Add(patientLeave); return(false); } // end if EmergencyActionTypeClass currentType = GetCurrentActionType(); RequestEmergencyAction req = new RequestEmergencyAction(ParentPatient, 0, currentType, time, new ResourceSet(ParentPatient.CorrespondingDoctor, ParentPatient.CorrespondingNurse, null)); parentControlUnit.AddRequest(req); if (currentType.IsHold) { return(false); } return(true); } // end of TakeNextAction
} // end of Event #endregion //-------------------------------------------------------------------------------------------------- // State Change //-------------------------------------------------------------------------------------------------- #region Trigger /// <summary> /// Overriden state change of the event. The patient path is set and the first action is taken. /// </summary> /// <param name="time">Time the patient arrives</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> protected override void StateChange(DateTime time, ISimulationEngine simEngine) { Patient.SpecialFacilityPath = InputData.CreatePatientPath(OriginalRequest.SpecialFacilityAdmissionTypes, Patient, OriginalRequest); if (Patient.SpecialFacilityPath.TakeNextAction(simEngine, this, time, ParentControlUnit)) { ActivityWait waitPatient = new ActivityWait(ParentControlUnit, Patient, (((ControlUnitSpecialServiceModel)ParentControlUnit).WaitingAreaPatientForNextActionType(Patient.SpecialFacilityPath.GetCurrentActionType()))); SequentialEvents.Add(waitPatient.StartEvent); } // end if } // end of Trigger
public EnemyBehaviourFactory(EnemyBrain brain, ISimulationEngine simulationEngine, IWorldLocator worldLocator, TraderPart.IItemFactory itemFactory, Random random, IPositionComponent physical) { this.Brain = brain; SimulationEngine = simulationEngine; WorldLocator = worldLocator; ItemFactory = itemFactory; Random = random; Physical = physical; }
} // end of ControlUnitOutpatient #endregion #region Initialize /// <summary> /// Overrides basic initialiing method. Besides standard operations a possible walk in stream of /// patients is /// </summary> /// <param name="startTime">Time the simulation starts</param> /// <param name="simEngine">SimEngine that handles the simulation run</param> public override void Initialize(DateTime startTime, ISimulationEngine simEngine) { base.Initialize(startTime, simEngine); EntityPatient nextPatient = null; DateTime nextArrivalTime; if ((nextPatient = InputData.GetNextWalkInPatient(out nextArrivalTime, this, startTime)) != null) { EventOutpatientWalkInPatientArrival nextArrival = new EventOutpatientWalkInPatientArrival(this, InputData, nextPatient); simEngine.AddScheduledEvent(nextArrival, nextArrivalTime); } // end if } // end of CustomInitialize
} // end of ControlUnitEmergency #endregion //-------------------------------------------------------------------------------------------------- // Enter Leave //-------------------------------------------------------------------------------------------------- #region EntityEnterControlUnit /// <summary> /// Entity arriving hanlding. Patients are handled with an arrival event, staff with a different arrive/leave event /// </summary> /// <param name="time">Time entity arrives</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> /// <param name="entity">Arriving entity</param> /// <param name="originDelegate">A possible delegate that is associated with the arrival</param> /// <returns></returns> public override Event EntityEnterControlUnit(DateTime time, ISimulationEngine simEngine, Entity entity, IDelegate originDelegate) { if (entity is EntityPatient) { return(new EventEmergencyPatientArrival(this, (EntityPatient)entity, InputData)); } if (entity is EntityStaff) { return(new EventControlUnitStaffEnterLeave(this, true, (EntityStaff)entity, originDelegate, WaitingRoomForStaff((EntityHealthCareStaff)entity))); } return(null); } // end of EntityEnterControlUnit
} // end of DelegateOutBox #endregion #region SendDelegates /// <summary> /// Sends all delegates in the outbox to their destination control unit. /// </summary> /// <param name="time">Time of sending.</param> /// <param name="simEngine">SimEngine that handles simulation execution</param> /// <returns></returns> public virtual bool SendAllDelegates(DateTime time, ISimulationEngine simEngine) { bool delSent = false; foreach (IDelegate del in DelegateOutBox) { SendDelegateTo(ParentControlUnit, del); delSent = true; } // end foreach DelegateOutBox.Clear(); return(delSent); } // end of SendDelegates
public void Run(ref bool isSimulateCanceled) { this.m_result = null; Coefficient coefficient = new Coefficient(); SimulationInfo initinfo = new SimulationInfo(); initinfo.Nsnapshot = Convert.ToInt16(this.m_param.NumOfSnapShot); SimulationConstant.IS_HARQ_ON = this.m_param.IsHARQ; SimulationConstant.IS_IRC_ON = this.m_param.IsIRC; SimulationConstant.FDD_ON = this.m_param.IsFDD; SimulationConstant.UL_TTI_BUNDLING_ON = this.m_param.IsTTIBundling; SimulationConstant.UL_VMIMO_ON = this.m_param.IsVMIMO; SimulationConstant.CONV_ULLOAD_THRESHOLD = this.m_param.ULLoadConThreshold; SimulationConstant.CONV_DLLOAD_THRESHOLD = this.m_param.DLLoadConThreshold; SimulationConstant.CONV_ULTH_THRESHOLD = this.m_param.ULThroughputConThreshold; SimulationConstant.CONV_DLTH_THRESHOLD = this.m_param.DLThroughputConThreshold; SimulationConstant.CONV_ULIOT_THRESHOLD = this.m_param.IOTConThreshold; initinfo.TtiWarmup = Convert.ToInt16((int)(this.m_param.NumOfTTI - SimulationConstant.DELTA_TTI)); this.m_SnapShotNum = this.m_param.NumOfSnapShot; initinfo.NttiLmd = Convert.ToInt16(this.m_param.NumOfTTI); initinfo.Name = this.m_param.NameOfSimulation; coefficient.m_SiteCorr = this.m_param.SiteCorr; coefficient.m_CellCorr = this.m_param.CellCorr; coefficient.m_UserCorr = this.m_param.UserCorr; initinfo.Coefficientabc = coefficient; if (!this.GetCellCollection()) { isSimulateCanceled = true; MessageBoxUtil.ShowError(SimulationResource.SIMULATION_CAL_IS_WRONG); this.m_calcCells.Clear(); } else { initinfo.CalCells = this.m_calcCells; this.getCloneService(); this.getCloneMobility(); this.getCloneTerminal(); this.m_GroupChildNodeStateImage = new Dictionary<short, List<short>>(); CarrierManager.getInstance().Carriers = new List<LTECell>(); foreach (Transceiver transceiver in this.m_calcCells) { foreach (IACell cell in transceiver.Cells) { if ((cell is LTECell) && cell.Active) { CarrierManager.getInstance().Carriers.Add(cell as LTECell); } } } UserManager.getInstance().UserBuilder = new UserManager.LTEUserBuilder(this.GenUsers); initinfo.SubSysInterface = this.m_otherSubSysInterface; this.m_otherSubSysInterface.SetProgressScope(initinfo.Name, 0, 100); this.m_otherSubSysInterface.ReportProgress(initinfo.Name, 0, SimulationResource.SIMULATION_INIT_4); #region 添加制式选择 if (m_param .IsFDD ) { this.m_SimulateEngine = new SimulationEngine(initinfo); } else { this.m_SimulateEngine = new TDDSimulationEngine(initinfo); } #endregion this.m_SimulateEngine.Execute(); if (this.m_SimulateEngine.IsSimulateCanceled) { this.m_otherSubSysInterface.ResetProgress(initinfo.Name); this.m_calcCells.Clear(); isSimulateCanceled = true; } else { this.m_otherSubSysInterface.ReportProgress(initinfo.Name, 100, SimulationResource.SIMULATION_GENERATE_STATISTICS); this.m_result = this.m_SimulateEngine.Statistic(); if (this.m_result == null) { this.m_otherSubSysInterface.ResetProgress(initinfo.Name); isSimulateCanceled = true; this.m_calcCells.Clear(); } else { this.GetGraghResult(); this.m_otherSubSysInterface.ResetProgress(initinfo.Name); this.m_calcCells.Clear(); } } } }
public CaculateParam(ISimulationGroup group, ISimulationEngine engine) { this.m_Group = group; this.m_Engine = engine; }