Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed

/*
 * Project: S.Ha.R.K.
 *
 * Coordinators:
 *   Giorgio Buttazzo    <giorgio@sssup.it>
 *   Paolo Gai           <pj@gandalf.sssup.it>
 *
 * Authors     :
 *   Paolo Gai           <pj@gandalf.sssup.it>
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
 *   Luca Abeni          <luca@gandalf.sssup.it>
 *   (see the web pages for full authors list)
 *
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
 *
 * http://www.sssup.it
 * http://retis.sssup.it
 * http://shark.sssup.it
 */



/**
 ------------
 CVS :        $Id: info.c,v 1.1.1.1 2004-05-24 18:03:39 giacomo Exp $

 File:        $File$
 Revision:    $Revision: 1.1.1.1 $
 Last update: $Date: 2004-05-24 18:03:39 $
 ------------
**/


/*
 * Copyright (C) 2000 Marco Dallera and Marco Fiocca
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */


/*
 *              AUTO
 *
 * Another Unuseful Track simulatOr
 *
 * Authors: Marco Dallera
 *          Marco Fiocca
 *
 */


/* ------------------- */
/*  Information panel  */
/* ------------------- */

#include "include/auto.h"
#include "include/const.h"
#include "include/utils.h"

extern sem_t grx_mutex;

/* ------------------------------------------------------------------ */

void bar_display(point p1, int width, int height, int border, float var, float max, int color, char *name)
{
  int background = BLACK;
  int amp = 0;
  point p2;

  p2.x = p1.x + width;
  p2.y = p1.y + height;

  sem_wait(&grx_mutex);

  grx_text(name, p1.x, p1.y + height + 3, color, background);
  grx_rect(p1.x - 1, p1.y - 1, p2.x + 1, p2.y + 1, border);

  grx_box(p1.x, p1.y, p2.x, p2.y, BLACK);
  amp = abs(round( var * (float)(p2.x - p1.x) / max ));
  grx_box(p1.x, p1.y, p1.x + amp, p2.y, color);

  sem_post(&grx_mutex);
}

/* ------------------------------------------------------------------ */

void bidir_bar_display(point p1, int width, int height, int border, float var, float max, int color, char *name)
{
  int background = BLACK;
  int amp = 0;
  point p2;

  p2.x = p1.x + width;
  p2.y = p1.y + height;

  sem_wait(&grx_mutex);

  grx_text(name, p1.x, p1.y + height + 3, color, background);
  grx_rect(p1.x - 1, p1.y - 1, p2.x + 1, p2.y + 1, border);

  grx_box(p1.x, p1.y, p2.x, p2.y, BLACK);
  amp = round( var * (float)((p2.x - p1.x)/2) / max );
  if (amp >= 0)
    grx_box((p1.x+p2.x)/2, p1.y, ((p1.x+p2.x)/2)+amp, p2.y, color);
  else
    grx_box((p1.x+p2.x)/2+amp, p1.y, ((p1.x+p2.x)/2), p2.y, color);
  grx_line((p1.x+p2.x)/2, p1.y-2, (p1.x+p2.x)/2, p2.y+2, border);

  sem_post(&grx_mutex);
}

/* ------------------------------------------------------------------ */

void cmd_display()
{
  point p1;

  p1.x = TRACK_X1;
  p1.y = TRACK_Y2+3;

  sem_wait(&grx_mutex);
  grx_rect(p1.x,   p1.y,   p1.x+CMD_WIDTH,   p1.y+CMD_HEIGHT,   BLUE);
  grx_rect(p1.x+1, p1.y+1, p1.x+CMD_WIDTH-1, p1.y+CMD_HEIGHT-1, CYAN);
  grx_rect(p1.x+2, p1.y+2, p1.x+CMD_WIDTH-2, p1.y+CMD_HEIGHT-2, LIGHTBLUE);
  grx_text("## Another Unuseful Track simulatOr ##",
           p1.x+8, p1.y+8, YELLOW, BLACK);
  grx_text("## -------------------------------- ##",
           p1.x+8, p1.y+16, YELLOW, BLACK);
  grx_text("Marco Dallera", p1.x+8, p1.y+24, GREEN, BLACK);
  grx_text("marchicchio@libero.it", p1.x+120, p1.y+24, GREEN, BLACK);
  grx_text("Marco Fiocca", p1.x+8, p1.y+32, GREEN, BLACK);
  grx_text("marqinho@tiscalinet.it", p1.x+120, p1.y+32, GREEN, BLACK);

  grx_text("Command keys            ", p1.x+8, p1.y+48, LIGHTBLUE, BLACK);
  grx_text("------------------------", p1.x+8, p1.y+56, LIGHTBLUE, BLACK);
  grx_text("h      create a HARD car", p1.x+8, p1.y+64, CYAN, BLACK);
  grx_text("s      create a SOFT car", p1.x+8, p1.y+72, CYAN, BLACK);
  grx_text("ENTER  exit to DOS",       p1.x+8, p1.y+80, CYAN, BLACK);

  sem_post(&grx_mutex);

}

/* ------------------------------------------------------------------ */