Пример #1
0
        private List<Pair<Lift, WaitTime>> WaitTimes(Dir dir)
        {
            List<Pair<Lift, WaitTime>> wait = new List<Pair<Lift, WaitTime>>();

              foreach (Lift lift in mLifts) {
            Buffer<Pair<Time, Buffer<bool>>> b = new Buffer<Pair<Time, Buffer<bool>>>();
            lift.HowLong(Helpers.pair(Helpers.pair(mNum, dir), b));
            WaitTime waittime = b.Get();
            wait.Add(Helpers.pair(lift, waittime));
              }

              return wait;
        }
Пример #2
0
 private void CabinLoop()
 {
     Buffer<Action> b = new Buffer<Action>();
       while (true) {
     mLift.Arrived(Helpers.pair(mFloors[mFloor], b));
     switch (b.Get()) {
       case Action.Wait:
     UnderViewLock(delegate { mState = CabinState.Waiting; });
     break;
       case Action.Stop:
     mFloors[mFloor].Arrived(mLift);
     UnderViewLock(delegate { mState = CabinState.Stopping; });
     WaitForEndTransition();
     break;
       case Action.Up:
     UnderViewLock(delegate {
        nextY = (mFloor + 1) * Program.COLUMNHEIGHT;
        mState = CabinState.GoingUp;
     });
     WaitForEndTransition();
     mFloor++;
     break;
       case Action.Down:
     UnderViewLock(delegate {
       nextY = (mFloor - 1) * Program.COLUMNHEIGHT;
       mState = CabinState.GoingDown;
     });
     WaitForEndTransition();
     mFloor--;
     break;
       default: Debug.Assert(false);
     break;
     }
       }
 }