Subversion Repositories programming

Rev

Rev 339 | Rev 344 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 339 Rev 340
Line 141... Line 141...
141
        case MOVE_UP:
141
        case MOVE_UP:
142
 
142
 
143
            /* Decide if we should stop at the floor we're at */
143
            /* Decide if we should stop at the floor we're at */
144
            if (should_stop_at_current_floor ())
144
            if (should_stop_at_current_floor ())
145
            {
145
            {
146
#ifndef QUIET
-
 
147
                printf ("stop at floor %d -- while going up\n", (int)(current_floor+0.5));
-
 
148
#endif
-
 
149
                stop_at_floors.at((int)(current_floor+0.5)) = false;
-
 
150
                have_user_enter_buttons ();
146
                stop_at_floor (MOVE_UP);
151
            }
147
            }
152
 
148
 
153
            /* Decide to sit idle if we have no more floors to stop at */
149
            /* Decide to sit idle if we have no more floors to stop at */
154
            if (!has_floors_to_stop_at ())
150
            if (!has_floors_to_stop_at ())
155
            {
151
            {
Line 184... Line 180...
184
        case MOVE_DOWN:
180
        case MOVE_DOWN:
185
 
181
 
186
            /* Decide if we should stop at the floor we're at */
182
            /* Decide if we should stop at the floor we're at */
187
            if (should_stop_at_current_floor ())
183
            if (should_stop_at_current_floor ())
188
            {
184
            {
189
#ifndef QUIET
-
 
190
                printf ("stop at floor %d -- while going down\n", (int)(current_floor+0.5));
-
 
191
#endif
-
 
192
                stop_at_floors.at((int)(current_floor+0.5)) = false;
-
 
193
                have_user_enter_buttons ();
185
                stop_at_floor (MOVE_DOWN);
194
            }
186
            }
195
 
187
 
196
            /* Decide to sit idle if we have no more floors to stop at */
188
            /* Decide to sit idle if we have no more floors to stop at */
197
            if (!has_floors_to_stop_at ())
189
            if (!has_floors_to_stop_at ())
198
            {
190
            {
Line 227... Line 219...
227
        default:
219
        default:
228
            
220
            
229
            assert (false); // bad value of direction
221
            assert (false); // bad value of direction
230
            break;
222
            break;
231
    }
223
    }
-
 
224
 
-
 
225
    controller->update_elevator_position (this);
232
}
226
}
233
 
227
 
234
/**
228
/**
235
 * Call this to stop the thread from running.
229
 * Call this to stop the thread from running.
236
 */
230
 */
Line 346... Line 340...
346
    }
340
    }
347
 
341
 
348
    controller->unpause_all_elevators ();
342
    controller->unpause_all_elevators ();
349
}
343
}
350
 
344
 
-
 
345
void Elevator::stop_at_floor (int in_direction)
-
 
346
{
-
 
347
    int the_floor = (int)(current_floor+0.5);
-
 
348
 
-
 
349
#ifndef QUIET
-
 
350
    if (in_direction == MOVE_UP)
-
 
351
        printf ("stop at floor %d -- while going up\n", the_floor);
-
 
352
    else
-
 
353
        printf ("stop at floor %d -- while going down\n", the_floor);
-
 
354
#endif
-
 
355
    stop_at_floors.at(the_floor) = false;
-
 
356
    //have_user_enter_buttons ();
-
 
357
 
-
 
358
    controller->stop_at_floor (this, the_floor);
-
 
359
}
-
 
360