/// <summary> /// Add a destination to our queue. This function will call MoveNext() to recheck the /// queue and move to the new floor if it's between our current location and our original /// destination. /// </summary> /// <param name="floor">The floor to add to the queue.</param> public void AddDest(int floor) { if (currentFloor == floor) { return; } destQueue[floor] = 1; mainForm.AddToLog("Lift " + liftID + " destination added: " + floor.ToString()); //mainForm.AddToLog(destQueue[0] + " " + destQueue[1] + " " + destQueue[2] + " " + destQueue[3] + " " + destQueue[4]); if (!dtWait.IsEnabled) { // If we're waiting already then the timer will call MoveNext for us. MoveNext(); } }
/************************************************************************************************/ /// <summary> /// Create a new Lift object. /// </summary> /// <param name="limg">The PictureBox control this Lift object is associated to.</param> /// <param name="fy">The list of floor y coordinates</param> /// <param name="sf">The floor the lift will idle/start on</param> /// <param name="mf">The main form (pass in 'this')</param> public Lift(PictureBox limg, int[] fy, int sf, frmLiftSim mf, int id) { liftImage = limg; floor_y = fy; idleFloor = sf; mainForm = mf; liftID = id; liftImage.Top = floor_y[idleFloor]; // Move lift to the start position currentFloor = idleFloor; // Set the lift's current position mainForm.AddToLog("Lift " + liftID + " initialised. Start floor: " + currentFloor); dtMove.Interval = TimeSpan.FromMilliseconds(20); dtMove.Tick += new EventHandler(dtMove_Tick); dtWait.Interval = TimeSpan.FromSeconds(2); dtWait.Tick += new EventHandler(dtWait_Tick); mainForm.UpdateFloorDisp(currentFloor, liftID); }
private int nextDestFloor; // Next floor the lift is heading to #endregion Fields #region Constructors /************************************************************************************************/ /// <summary> /// Create a new Lift object. /// </summary> /// <param name="limg">The PictureBox control this Lift object is associated to.</param> /// <param name="fy">The list of floor y coordinates</param> /// <param name="sf">The floor the lift will idle/start on</param> /// <param name="mf">The main form (pass in 'this')</param> public Lift(PictureBox limg, int[] fy, int sf, frmLiftSim mf, int id) { liftImage = limg; floor_y = fy; idleFloor = sf; mainForm = mf; liftID = id; liftImage.Top = floor_y[idleFloor]; // Move lift to the start position currentFloor = idleFloor; // Set the lift's current position mainForm.AddToLog("Lift " + liftID + " initialised. Start floor: " + currentFloor); dtMove.Interval = TimeSpan.FromMilliseconds(20); dtMove.Tick += new EventHandler(dtMove_Tick); dtWait.Interval = TimeSpan.FromSeconds(2); dtWait.Tick += new EventHandler(dtWait_Tick); mainForm.UpdateFloorDisp(currentFloor, liftID); }