Beispiel #1
0
        private void _work()
        {
            OPScheduled = false;

            // see if anyone is busy with op prepration of the op itself
            bool            chairBusyWithOP;
            bool            rapporteurBusyWithOP;
            TechnicalMember opRapporteur;

            if (_opQueue.Count > 0)
            {
                OP op = _opQueue.Peek();
                chairBusyWithOP      = op.ChairIsBusy(_hour);
                rapporteurBusyWithOP = op.RapporteurIsbusy(_hour);
                if (rapporteurBusyWithOP)
                {
                    opRapporteur = op.Rapporteur;
                }
                else
                {
                    opRapporteur = null;
                }
            }
            else
            {
                chairBusyWithOP      = false;
                rapporteurBusyWithOP = false;
                opRapporteur         = null;
            }

            // make sure each tech member has a summons to work on
            foreach (TechnicalMember m in _technicalMembers)
            {
                if (m.SummonsQueueIsEmpty)
                {
                    m.EnqueueSummons(new Summons(m), _hour);
                }
            }

            // chair and each tech member works
            if (chairBusyWithOP)
            {
                _chair.DoOPWork();
            }
            else
            {
                _chair.Work();
            }
            foreach (TechnicalMember m in _technicalMembers)
            {
                if (opRapporteur == m)
                {
                    m.DoOPWork();
                }
                else
                {
                    m.Work();
                }
            }

            // process chair output
            if (!chairBusyWithOP)
            {
                switch (_chair.OutputType)
                {
                case OutputTypes.Summons:
                    _scheduleOP(_chair.Output.Rapporteur);
                    OPScheduled = true;
                    break;

                case OutputTypes.Decision:
                    break;

                case OutputTypes.Nothing:
                    break;
                }
            }

            //process member outputs
            foreach (TechnicalMember m in _technicalMembers)
            {
                if (!(opRapporteur == m))
                {
                    switch (m.OutputType)
                    {
                    case Board.OutputTypes.Summons:
                        _chair.EnqueueSummons(m.Output as Summons, _hour);
                        break;

                    case Board.OutputTypes.Decision:
                        _chair.EnqueueDecision(m.Output as Decision, _hour);
                        break;

                    case Board.OutputTypes.Nothing:
                        break;
                    }
                }
            }

            // if OP is finished, dequeue it and push a decision onto the member's queue
            if (_opQueue.Count > 0)
            {
                if (_opQueue.Peek().IsOver(_hour))
                {
                    TechnicalMember member = _opQueue.Peek().Rapporteur;
                    member.EnqueueDecision(new Decision(member), _hour);
                    _opQueue.Dequeue();
                }
            }

            // if OP has been scheduled, keep track of the time it is scheduled for
            if (OPScheduled)
            {
                OPScheduledForDay = _opQueue.Last().StartDay;
            }
            else
            {
                OPScheduledForDay = 0;
            }
        }