Пример #1
0
/* There shall be one task, called lift_task, for the lift.  */
void lift_task(void)//TODO
{

	int next;
	int dirchange;

    int send_task_id;
    int length;//DUMMY	
    message_data_type msg;

	draw_lift(mainlift);


    while (1)
    {
        si_message_receive((char *) &msg, &length, &send_task_id);

        if(msg.type == MOVE_MESSAGE)
        {
			lift_next_floor(mainlift, &next, &dirchange);
			lift_move(mainlift, next, dirchange);
			lift_has_arrived(mainlift);
        }
        else if(msg.type == TRAVEL_MESSAGE)
        {
            /* a travel message is sent to the lift task when a 
               person would like to make a lift travel */ 
		    enter_floor(mainlift, msg.id, msg.from_floor, msg.to_floor);
        }
		
		draw_lift(mainlift);
    }

}
Пример #2
0
static void *lift_thread(void *unused)
{
	int next_floor=0;
	int change_direction=0;
	while(1){
		// Move lift one floor
		lift_next_floor(Lift, &next_floor, &change_direction);
		lift_move(Lift, next_floor, change_direction);
		lift_has_arrived(Lift);
	}
	return NULL;
}
Пример #3
0
static void *lift_thread(void *unused)
{
  //printf("Started lift_thread\n");
  //The functions lift_next_floor, lift_move and lift_has_arrived shall be called by the lift thread
	while(1){
	  int next_floor, change_direction;
	  lift_next_floor(Lift, &next_floor, &change_direction);
	  lift_move(Lift, next_floor, change_direction);
	  lift_has_arrived(Lift);
	  // Move lift one floor
	}
	return NULL;
}
Пример #4
0
static void *lift_thread(void *unused)
{
	int next_floor=0;
	int change_direction=0;
	while(1){
		// Move lift one floor
		lift_next_floor(Lift, &next_floor, &change_direction);
		lift_move(Lift, next_floor, change_direction);
		lift_has_arrived(Lift);
		//usleep(3000000);
		//fprintf(stderr, "Number of iterations: %d\n", iterations);
	}
	return NULL;
}
Пример #5
0
/* There shall be one task, called lift_task, for the lift.  */
void lift_task(void)
{

	int next;
	int dirchange;
	
	draw_lift(mainlift);

    while (1)
    {
	
	lift_next_floor(mainlift, &next, &dirchange);
	lift_move(mainlift, next, dirchange);
	lift_has_arrived(mainlift);
	
	
	/* För debug
		lift_next_floor(mainlift, &next, &dirchange);
		printf("|%d %d %d |", mainlift->floor, next, dirchange); 
		lift_move(mainlift, next, dirchange);
		
		lift_next_floor(mainlift, &next, &dirchange);
		printf("|%d %d %d |", mainlift->floor, next, dirchange); 
		lift_move(mainlift, next, dirchange);
		
		lift_next_floor(mainlift, &next, &dirchange);
		printf("|%d %d %d |", mainlift->floor, next, dirchange); 
		lift_move(mainlift, next, dirchange);
		
		lift_next_floor(mainlift, &next, &dirchange);
		printf("|%d %d %d |", mainlift->floor, next, dirchange); 
		lift_move(mainlift, next, dirchange);
		
	    lift_next_floor(mainlift, &next, &dirchange);
		printf("|%d %d %d |", mainlift->floor, next, dirchange); 
		lift_move(mainlift, next, dirchange);
		
		lift_next_floor(mainlift, &next, &dirchange);
		printf("|%d %d %d |", mainlift->floor, next, dirchange); 
		lift_move(mainlift, next, dirchange);
		
		lift_next_floor(mainlift, &next, &dirchange);
		printf("|%d %d %d |", mainlift->floor, next, dirchange); 
		lift_move(mainlift, next, dirchange);
		
		lift_next_floor(mainlift, &next, &dirchange);
		printf("|%d %d %d |", mainlift->floor, next, dirchange); 
		lift_move(mainlift, next, dirchange);
		
		lift_next_floor(mainlift, &next, &dirchange);
		printf("|%d %d %d |", mainlift->floor, next, dirchange); 
		lift_move(mainlift, next, dirchange);
		
		lift_next_floor(mainlift, &next, &dirchange);
		printf("|%d %d %d |", mainlift->floor, next, dirchange); 
		lift_move(mainlift, next, dirchange);
		
		lift_next_floor(mainlift, &next, &dirchange);
		printf("|%d %d %d |", mainlift->floor, next, dirchange); 
		lift_move(mainlift, next, dirchange);
		
		lift_has_arrived(mainlift);
		
		printf("| %d %d |", next, dirchange);
		exit(mainlift->floor);
		*/
    }
}