Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed

#include <stdlib.h>
#include "kernel/kern.h"
#include "kernel/func.h"
#include "ll/i386/x-dos.h"
#include "modules/cabs.h"
#include "modules/hartport.h"
#include "string.h"
#include <math.h>
#include <drivers/glib.h>
#include <drivers/keyb.h>
#include <drivers/pxc.h>

//#include "modules/pi.h"
//#include "modules/nop.h"

//#define PI
//#define CAMERA_X
//#define TIMEJET  //e` incompatibile con PLOTIMG on
//#define DATAPLANT
/*//#define SOFTCARR
//#define SOFTTRACK   unused!!!!
*/

#define SOFTPROG
#define PLOTIMG  // e` incompatibile con TIMEJET on (???perche`?)

#define FRAMEGRABBER_ON
#define JET_ON


/*
 * WCET, Periods and Models
 */


/* define if you want NRT or SOFT... */


// dipendono dalla macchina !!!!

#define TASK_TYPE SOFT

// SOFT + HARD tasks !!!!!!!!!!!!!!!!!!

/*
// TASK carrello 
#ifdef SOFTCARR      //  SOFT   
//#define WCET_CARRELLO    240   //460
//#define PERIOD_CARRELLO  1200 
#else                  //  HARD  
#define WCET_CARRELLO    600//500 
//#define PERIOD_CARRELLO  1800//1800   
#endif

// TASK tracking 
#ifdef SOFTTRACK      //  SOFT   
//#define WCET_TRACKING     7200  //5000
//#define PERIOD_TRACKING  12000
#else                  //  HARD   
#define WCET_TRACKING    10000 //10000
//#define PERIOD_TRACKING  22200 //30000
#endif
*/

#ifdef SOFTPROG
extern long int PERIOD_CARRELLO, WCET_CARRELLO, PERIOD_TRACKING, WCET_TRACKING;
#else
#define WCET_CARRELLO    600//500
#define WCET_TRACKING    10000 //10000
extern long int PERIOD_CARRELLO , PERIOD_TRACKING;
#endif







/*+ altri TASKS   +*/

// TIMEJET non viene attivato nei run.Incompatibile con i tasks JETCTRL
#define WCET_TIMEJET     900
#define PERIOD_TIMEJET  2000


#define WCET_DESIGN    4000 // 4000
#define PERIOD_DESIGN  100000 // 50000


#define WCET_CAMERA    5000  // 5000  
#define PERIOD_CAMERA 100000 // 50000 

#define WCET_JETCTRL      1000
#define WCET_JETDUMMY    WCET_JETCTRL   
#define WCET_JETSLIDE     WCET_JETCTRL

#define PERIOD_JETCTRL  100000
#define PERIOD_JETDUMMY 100000
#define PERIOD_JETSLIDE 100000


/*   controllo stuffs  */


struct  Data_cab1 {
        float   rif;
        int     imp;
};
struct  Data_cab2 {
        float   x;
        float   y;
} ;

struct Parametri{
  float GUAD[4];
  float COST;
  float NOISE;
  float WCUT;
  float WCUT1;
  float OFFSVAL;
  int DEADLINE;
  int SCAN;
  float XTRASL;
};

extern mutex_t mutex, mutexadc;
extern CAB cab1, cab2;
extern struct Parametri prm;

void app_mutex_init(mutex_t *);

int da_motor(float v);
float v2x(float v);
float v2theta(float v);
float bass1(float u);
float bass2(float u);
float bass3(float u);
float bass4(float u);
float  dx(float u);
float  dth(float u);








/* scenario */
#define SCENARIO_NLABEL 16


/*
 * Global Stuffs 
 */

/* graphic mutex... */
extern mutex_t mutex;

/* useful colors... */
int white;
int black;
int red;
int gray;
int green;
int blue;

void init_jetcontrol();

void init_framegrabber();

/*
 *
 * JETCONTROL stuffs
 *
 */

#define JET_NTASK   13
#define JET_Y_NAME  480  //500

#define DUMMY_PID    1

#define JET_DUMMY_WIDTH    210
#define JET_DUMMY_HEIGHT    40

/* the point (x, y) is the top left corner */
#define JET_DUMMY_X        60
#define JET_DUMMY_Y        514

#define JET_SLIDE_WIDTH     50
#define JET_SLIDE_X        (384+200)


/*
 *
 * FRAMEGRABBER stuffs
 *
 */

// if defined... object black on a white background
#ifndef __BLACK_ON_WHITE
#define __BLACK_ON_WHITE
#endif

#define ABS_NUM(a) ((a >= 0) ? a : -a)
#define MIN_NUM(a, b) ((a < b) ? a : b)
#define MAX_NUM(a, b) ((a > b) ? a : b)


// Cols and rows  of the framegrabber image
#define N_COL     384 //   384
#define N_ROW        288
#define N_BPS        8   // Bits per pixel
#define N_GRIGI     256

#define N_FRAMES    20 //  100

/* pixel of the video image */
#define IMG_COL 230    //  230 //256
#define IMG_ROW 160   // 160 //192

/* position of the video image */
#define IMG_X   500  //   644  // 384
#define IMG_Y   32   // 200     // 32

// I singoli pixel sono caratteri a 8 bit
typedef unsigned char TPixel;

typedef struct {
  int x1, y1;
  int x2, y2;
  int xb, yb;
  TIME time_stamp;
} TDataObj;

typedef struct {
  int found;
  int top_frame;
  int vx,vy;
  int predx;
  int predy;
  TDataObj current;
} TTracking;


float distance(unsigned int x1, unsigned int y1,
               unsigned int x2, unsigned int y2);

char scan_all_frame(TDataObj *data, TPixel *in_frame);

char scan_window_frame(TDataObj *data, TPixel *in_frame,  \
                unsigned int xc, unsigned int yc, int border, int border_y);
void threshold_up_function(KEY_EVT key);
void threshold_down_function(KEY_EVT key);
void border_up_function(KEY_EVT key);
void border_down_function(KEY_EVT key);
void tracking(int top_frame, int *track_x, int *track_y, int *int_vx, int *int_vy, int time_to);
TASK elab_image_TASK(void);