Exemple #1
0
void draw_lift(lift_type lift)
{
    int floor, i; 

    si_ui_draw_begin(); 

    si_ui_draw_string(
        "Lift Simulation (send \"new\" to create new passengers)",
        info_x, info_y); 

    si_ui_draw_image("building", xBuilding, yBuilding); 

    si_ui_draw_image("lift", xLift, yLift[lift->floor]); 

    /* draw lift passengers */ 
    for (i = 0; i < MAX_N_PASSENGERS; i++)
    {
        if (lift->passengers_in_lift[i].id != NO_ID)
        {
            si_ui_draw_image("gubbe", 
                           xLift + i*cxGubbe, yLift[lift->floor] - cyGubbe + delta_y_Gubbe); 

            si_string_copy(message, "%x   %x"); 
            si_insert_int_as_hex_no_leading_zeros(message, lift->passengers_in_lift[i].id); 
            si_insert_int_as_hex_no_leading_zeros(message, lift->passengers_in_lift[i].to_floor); 
            si_ui_draw_string(message, xLift + i*cxGubbe + id_x_offset, 
                            yLift[lift->floor] - cyGubbe + delta_y_Gubbe + id_y_offset);
        }
    }

    /* draw waiting persons */ 
    for (floor = 0; floor < N_FLOORS; floor++)
    {
        si_string_copy(message, " %x "); 
        si_insert_int_as_hex_no_leading_zeros(message, floor); 
        si_ui_draw_string(message, xLift - LEVEL_OFFSET/2 + 5, yLift[floor] - 3); 

        for (i = 0; i < MAX_N_PERSONS; i++)
        {
            if (lift->persons_to_enter[floor][i].id != NO_ID)
            {
                si_ui_draw_image("gubbe", xLift - LEVEL_OFFSET - i*(cxGubbe + 2), 
                               yLift[floor] - cyGubbe); 
                si_string_copy(message, "%x"); 
                si_insert_int_as_hex_no_leading_zeros(message, lift->persons_to_enter[floor][i].id); 
                si_ui_draw_string(message, xLift  - LEVEL_OFFSET - i*(cxGubbe + 2) - 3, 
                                yLift[floor] - cyGubbe + 5);

            }
        }
    }

    si_ui_draw_end();
}
Exemple #2
0
void si_ui_show_error(char message[])
{
    si_ui_draw_begin(); 

    pthread_mutex_lock(&Si_Ui_Mutex); 

    sprintf(Message_String, "show_error:%s", message); 

    append_to_buffer(Message_String); 

    pthread_mutex_unlock(&Si_Ui_Mutex); 

    si_ui_draw_end(); 
}
Exemple #3
0
void si_ui_set_size(int x_size, int y_size)
{
    si_ui_draw_begin(); 

    pthread_mutex_lock(&Si_Ui_Mutex); 

    sprintf(Message_String, "set_size:%08X:%08X", x_size, y_size); 

    append_to_buffer(Message_String); 

    pthread_mutex_unlock(&Si_Ui_Mutex); 

    si_ui_draw_end(); 
}
Exemple #4
0
/* display_time: displays hours, minutes and seconds by 
   sending them to the user interface */ 
void display_time(int hours, int minutes, int seconds)
{
    char display_message[20]; 

    char draw_message[100]; 

    /* convert hours, minutes and seconds to display format */ 
    make_display_message(display_message, hours, minutes, seconds); 

    sprintf(draw_message, "Time: %s", display_message); 

    /* write to user interface */ 
    si_ui_draw_begin(); 
    si_ui_draw_string("send \"set:hh:mm:ss\" to set time", 90, 20); 
    si_ui_draw_string(draw_message, 145, 55);
    si_ui_draw_end(); 
}
Exemple #5
0
/* print_number: prints an integer number, together with information
   whether the number is odd or even */
void print_number(int number, int even_number) 
{
    /* value which should have the same value as the common variable
       Even_Number if everything is Ok */
    int check_even_number;

    /* string for the text to be printed */
    char write_str[40];

    /* conversion of number from integer to string */
    sprintf(write_str,"The number is: %d ",number);

    /* display information on odd or even number */
    if (even_number) 
    {
        strcat(write_str,"The number is EVEN");
    } 
    else 
    {
        strcat(write_str,"The number is ODD");
    }

    /* start drawing, i.e. prepare for writing to user interface */ 
    si_ui_draw_begin(); 

    /* display number information */ 
    si_ui_draw_string(write_str, 70, 50);

    /* check if the number really is odd or even */
    if (number % 2 == 0) 
    {
        check_even_number = 1;
    } 
    else 
    {
        check_even_number = 0;
    }

    /* display error message if necessary */
    if (even_number != check_even_number) 
    {
        if (check_even_number) 
        {
            sprintf(write_str,"ERROR: The number is really EVEN");
        } 
        else 
        {
            sprintf(write_str,"ERROR: The number is really ODD");
        } 
    }
    else
    {
        sprintf(write_str, "odd/even check without errors"); 
    }

    /*  display odd/even information */ 
    si_ui_draw_string(write_str, 70, 70);

    /* finish drawing */ 
    si_ui_draw_end(); 

}