internal void RegisterOP(AppealCase ac, Hour opStartHour, Hour opEndHour) { Hour start = opStartHour.Subtract(OPPREPARATIONHOURS); Hour end = opEndHour; _opTimes.Add(ac, new SimulationTimeSpan(start, end)); }
private void _getNextCase() { if (_chairQueue.Count > 0) { _currentCase = _chairQueue.Dequeue(); _currentRole = Work.WorkRole.Chair; _initialiseCase(); return; } if (_otherQueue.Count > 0) { _currentCase = _otherQueue.Dequeue(); _currentRole = Work.WorkRole.Other; _initialiseCase(); return; } if (_rapporteurQueue.Count > 0) { _currentCase = _rapporteurQueue.Dequeue(); _currentRole = Work.WorkRole.Rapporteur; _initialiseCase(); return; } _currentCase = null; }
internal void Enqueue(AppealCase appealCase) { if (appealCase.Stage == AppealCaseState.Stage.New) { appealCase.AdvanceState(); } switch (appealCase.Stage) { case AppealCaseState.Stage.SummonsEnqueued: case AppealCaseState.Stage.SummonsStarted: case AppealCaseState.Stage.SummonsFinished: _summonsQueue.Enqueue(appealCase); break; case AppealCaseState.Stage.DecisionEnqueued: case AppealCaseState.Stage.DecisionStarted: case AppealCaseState.Stage.DecisionFinished: _decisionQueue.Enqueue(appealCase); break; default: throw new InvalidOperationException("Appeal is not in Summons or Decision stage."); } }
internal void NotifyOPSchedule(AppealCase ac, Hour opStartHour, Hour opEndHour) { foreach (Member member in _allocatedBoard) { member.RegisterOP(ac, opStartHour, opEndHour); } }
internal WorkReport DoWork() { AppealCase opCase = _opTimes.OPScheduledForCurrentHour; if (opCase != null) { return(new OPWorkReport(opCase)); } if (_currentCase == null) { _getNextCase(); } if (_currentCase == null) { return(new NullWorkReport()); } _workCase(); WorkReport report; if (_workCounter == 0) { report = new WorkReport(_currentCase, _currentWorkType, _currentRole, Work.WorkState.Finished); _currentCase = null; } else { report = new WorkReport(_currentCase, _currentWorkType, _currentRole, Work.WorkState.Ongoing); } return(report); }
private Hour _scheduleOP(AppealCase appealCase) { // TODO: make a proper scheduler Hour startHour = SimulationTime.Future(OPLEADTIME); _scheduledOPs[appealCase] = startHour; return(startHour); }
private void _processIncomingCases() { while (_incomingCases.Count > 0) { AppealCase appealCase = _incomingCases.Dequeue(); Allocation allocation = _allocate(appealCase); Member firstWorker = allocation.Enqueue(appealCase); _activeCases[appealCase] = allocation; } }
internal Member() { _rapporteurQueue = new CaseQueuePair(); _chairQueue = new CaseQueuePair(); _otherQueue = new CaseQueuePair(); _opTimes = new OPList(); _currentCase = null; _workCounter = 0; }
private void _processCirculatingCases() { while (_circulatingCases.Count > 0) { AppealCase appealCase = _circulatingCases.Dequeue(); Allocation allocation = _activeCases[appealCase]; Member nextWorker = allocation.Enqueue(appealCase); if (nextWorker == null) { appealCase.AdvanceState(); Hour opStartHour = _scheduleOP(appealCase); Hour opEndHour = opStartHour.Add(OPDURATION); allocation.NotifyOPSchedule(appealCase, opStartHour, opEndHour); } } }
internal BoardLog DoWork() { _processCirculatingCases(); _processIncomingCases(); BoardLog log = new BoardLog(); foreach (Member m in _members()) { WorkReport report = m.DoWork(); log.Add(m, report); if (report.State == Work.WorkState.Finished) { AppealCase appealCase = report.Case; _circulatingCases.Enqueue(appealCase); } } return(log); }
internal Member Enqueue(AppealCase appealCase) { switch (appealCase.Stage) { case AppealCaseState.Stage.New: appealCase.AdvanceState(); break; case AppealCaseState.Stage.SummonsEnqueued: appealCase.AdvanceState(); break; case AppealCaseState.Stage.SummonsStarted: break; case AppealCaseState.Stage.SummonsFinished: break; case AppealCaseState.Stage.OPPending: break; case AppealCaseState.Stage.OPFinsished: break; case AppealCaseState.Stage.DecisionEnqueued: break; case AppealCaseState.Stage.DecisionStarted: break; case AppealCaseState.Stage.DecisionFinished: break; default: break; } if (_allocatedBoard.SummonsWorkerCount == 0) { return(null); } Member member = _allocatedBoard.DequeueSummonsWorker(); switch (_allocatedBoard.SummonsWorkerCount) { case 2: member.EnqueueRapporteurWork(appealCase); break; case 1: member.EnqueueOtherWork(appealCase); break; case 0: member.EnqueueChairWork(appealCase); break; default: throw new InvalidOperationException("Something is wrong with the number of summons workers."); } return(member); }
internal void EnqueueRapporteurWork(AppealCase appealCase) { _rapporteurQueue.Enqueue(appealCase); }
internal void EnqueueNewCase(AppealCase appealCase) { _incomingCases.Enqueue(appealCase); }
private Allocation _allocate(AppealCase appealCase) { // TODO: make a proper allocation return(new Allocation(_chair, _technical[0], _legal[0])); }
internal void EnqueueChairWork(AppealCase appealCase) { _chairQueue.Enqueue(appealCase); }
internal void EnqueueOtherWork(AppealCase appealCase) { _otherQueue.Enqueue(appealCase); }
internal void Add(AppealCase ac, SimulationTimeSpan span) { _opTimes.Add(span); _cases[span] = ac; }