Ejemplo n.º 1
0
Archivo: ref-util.c Proyecto: mpw/p2
void
kref_util_array (char *container)
{
  /* Step 1:  set values for ref parameters */

  pnum = get_path_num(container);
  cnum = get_param_num(container);
  realm_param = get_realm_param(container);

  /* Step 2: generate the right code  - assume that there is no
     array field that is basic to a cursor */

  if (has_container_arg) {
    if (unknown_fld) {
      if (unknown_idx)
        out("P2_rf = terminal_vstring(\"(%%s).%%s%%d[%%s]\", %s->expr, %s,"
            "te->layerno, %s);", container, field_val, index_val);
      else
        out("P2_rf = terminal_vstring(\"(%%s).%%s%%d[%s]\", %s->expr, %s,"
            "te->layerno);", index_val, container, field_val);
    }
    else {
      if (unknown_idx)
        out("P2_rf = terminal_vstring(\"(%%s).%s%%d[%%s]\", %s->expr,"
            "te->layerno, %s);", field_val, container, index_val);
      else
        out("P2_rf = terminal_vstring(\"(%%s).%s%%d[%s]\", %s->expr,"
            "te->layerno);", field_val, index_val, container);
    }
  }
  else {
    if (unknown_fld) {
      if (unknown_idx) 
        out("P2_rf = terminal_vstring(\"(%%s).%%s%%d[%%s]\", cursor%d->cont, %s,"
            "te->layerno, %s);", pnum, field_val, index_val);
      else
        out("P2_rf = terminal_vstring(\"(%%s).%%s%%d[%s]\", cursor%d->cont, %s,"
            "te->layerno);", index_val, pnum, field_val);
    }
    else {
      if (unknown_idx)
        out("P2_rf = terminal_vstring(\"(%%s).%s%%d[%%s]\", cursor%d->cont,"
            "te->layerno, %s);", field_val, pnum, index_val);
      else
        out("P2_rf = terminal_vstring(\"(%%s).%s%%d[%s]\", cursor%d->cont,"
            "te->layerno);", field_val, index_val, pnum);
    }
  }

  /* Step 3: remember this is not a cursor or object field that
     is being referenced */

  cursor_field = FALSE;
  obj_field    = FALSE;
}
Ejemplo n.º 2
0
Archivo: ref-util.c Proyecto: mpw/p2
void
ref_util_array (char *cursor)
{ 
  /* Step 1: Initialize lhs variable (to the value of the field that
     is being referenced). */

  if (unknown_fld) {
    if (unknown_idx)
      out("sprintf(P2_lhs,\"%%s%%d[%%s]\", %s, te->layerno, %s);",
          field_val, index_val);
    else
      out("sprintf(P2_lhs,\"%%s%%d[%s]\", %s, te->layerno);",
          field_val, index_val);
  }
  else {
    if (unknown_idx)
      out("sprintf(P2_lhs,\"%s%%d[%%s]\", te->layerno, %s);",
          field_val, index_val);
    else 
      out("sprintf(P2_lhs,\"%s%%d[%s]\", te->layerno);",
          field_val, index_val);
  }

  /* Step 2: Initialize variables for update. */

  cnum = get_param_num(cursor);
  pnum = get_path_num(cursor);
  realm_param = get_realm_param(cursor);

  /* Step 3: Assume that basic fields of cursors are not arrays
     and generate the appropriate terminals. */

  if (is_cursor_field(field_val)) {
    cursor_field = TRUE;
    obj_field    = FALSE;
    out("P2_rf = terminal_vstring(\"(%%s).%%s\", %s->expr, P2_lhs);");
  }
  else {

    /* must be a reference to an element field */

    cursor_field = FALSE;
    obj_field    = FALSE;
    if (call_below(REF_OP, pnum)) {
      out("P2_rf = call_down(te, %d, REF_OP, 2, %s, P2_lhs);",
          pnum, cursor);
    }
    else {
      out("P2_rf = terminal_vstring(\"(%%s).obj->%%s\", %s->expr, P2_lhs);",
          cursor);
    }
    strcpy(rf_field, "P2_lhs");
  }
}
Ejemplo n.º 3
0
Archivo: ref-util.c Proyecto: mpw/p2
void
kref_util (char *container)
{  
  /* Step 1:  set values for ref parameters */

  pnum = get_path_num(container);
  cnum = get_param_num(container);
  realm_param = get_realm_param(container);

  /* Step 2: generate the right code */

  if (force_field_ref)
  {
    /* This feature is not used in any existing layer. (JAT) */
    assert(unknown_fld);
    out("P2_rf = terminal_vstring(\"(%%s).%%s\", %s->expr, %s);",
        container, field_val);
  }
  else
  {
    if (has_container_arg)
    {
      if (unknown_fld) 
        out("P2_rf = terminal_vstring(\"(%%s).%%s%%d\", %s->expr, %s,"
            "te->layerno);", container, field_val);
      else
        if (is_basic_container_field(field_val))
          out("P2_rf = terminal_vstring(\"(%%s).%s\", %s->expr);",
              field_val, container);
        else
          out("P2_rf = terminal_vstring(\"(%%s).%s%%d\", %s->expr,"
              "te->layerno);", field_val, container);
    }
    else
    {
      if (unknown_fld) 
        out("P2_rf = terminal_vstring(\"(%%s).%%s%%d\", cursor%d->cont, %s,"
            "te->layerno);", pnum, field_val);
      else
        out("P2_rf = terminal_vstring(\"(%%s).%s%%d\", cursor%d->cont,"
            "te->layerno);", field_val, pnum);
    }
  }

  /* Step 3: remember this is not a cursor or object field that
     is being referenced */

  cursor_field = FALSE;
  obj_field    = FALSE;
}
Ejemplo n.º 4
0
Archivo: ref-util.c Proyecto: mpw/p2
int
get_path_num (char *s)
{
  int i = get_param_num(s);
  return(path[i]);
}
Ejemplo n.º 5
0
Archivo: ref-util.c Proyecto: mpw/p2
void
ref_util (char *cursor)
{
  cnum = get_param_num(cursor);
  pnum = get_path_num(cursor);
  realm_param = get_realm_param(cursor);
  
  if (force_field_ref)
  {
    if (unknown_fld)
      out("P2_rf = terminal_vstring(\"(%%s).%%s\", %s->expr, %s);",
          cursor, field_val);
    else
      out("P2_rf = terminal_vstring(\"(%%s).%s%%d\", %s->expr, te->layerno);",
          field_val, cursor);
    cursor_field = TRUE;
    obj_field    = FALSE;
  }
  else
    if (!unknown_fld && is_cursor_field(field_val))
    {
      cursor_field = TRUE;
      if (strcmp(field_val, "obj") == 0)
        obj_field = TRUE;
      else 
        obj_field = FALSE;
      if (is_basic_cursor_field(field_val))
        out("P2_rf = terminal_vstring(\"(%%s).%s\", %s->expr);",
            field_val, cursor);
      else
        out("P2_rf = terminal_vstring(\"(%%s).%s%%d\", %s->expr, te->layerno);",
            field_val, cursor);
    }
    else
    {
      /* must be a reference to an element field */

      cursor_field = FALSE;
      obj_field    = FALSE;
      if (call_below(REF_OP, pnum))
      {
        if (unknown_fld)
        {
          out("{"
              "char id[MAX_IDENT_LEN];"
              "strcpy(id,%s);", field_val); 
          out("P2_rf = call_down(te, %d, REF_OP, 2, %s, id);", pnum, cursor);
          out("}");
        }
        else
        {
          out("{"
              "char id[MAX_IDENT_LEN];"
              "sprintf(id,\"%s%%d\",te->layerno);", field_val);
          out("P2_rf = call_down(te, %d, REF_OP, 2, %s, id);", pnum, cursor);
          out("}");
        }
      }
      else
      {
#if 0
        if (!unknown_fld)
          out("P2_rf = terminal_vstring(\"(%%s).obj->%%s\", %s->expr, field_val);",
              cursor);
        else
#else
        if (!unknown_fld)
          out("P2_rf = terminal_vstring(\"(%%s).obj->%s%%d\", %s->expr, te->layerno);",
              field_val, cursor);
        else
#endif
          out("P2_rf = terminal_vstring(\"(%%s).obj->%%s\", %s->expr, %s);",
              cursor, field_val);
      }
    }
  strcpy(rf_field, field_val);
}
Ejemplo n.º 6
0
int8_t  gsnr_param_set(uint8_t gsnr_cal_step,int32_t AcceV_x,int32_t AcceV_y,int32_t AcceV_z,int32_t AcceAhead_x,int32_t AcceAhead_y,int32_t AcceAhead_z)
{

    int err;

    cfg_param_t *cfg_param;

    uint16_t mode;

    uint8_t param_num;

    cfg_param_t all_param[4];

    
    drv_fls_read(PARAM_ADDR_CUSTOM,(uint8_t*)&all_param[0],sizeof(cfg_param_t));
    drv_fls_read(PARAM_ADDR_HIGHWAY,(uint8_t*)&all_param[1],sizeof(cfg_param_t));
    drv_fls_read(PARAM_ADDR_MOUNTAIN,(uint8_t*)&all_param[2],sizeof(cfg_param_t));
    drv_fls_read(PARAM_ADDR_CITY,(uint8_t*)&all_param[3],sizeof(cfg_param_t));
    
    
    
    drv_fls_read(PARAM_MODE_ADDR,(uint8_t *)&mode,sizeof(uint16_t));

    param_num = get_param_num(mode);

    osal_printf("mode is %04X\n",mode);

    cfg_param = &all_param[param_num];

    cfg_param->gsnr.gsnr_cal_step = gsnr_cal_step;
    cfg_param->gsnr.AcceV_x = AcceV_x;
    cfg_param->gsnr.AcceV_y = AcceV_y;
    cfg_param->gsnr.AcceV_z = AcceV_z;
    cfg_param->gsnr.AcceAhead_x = AcceAhead_x;
    cfg_param->gsnr.AcceAhead_y = AcceAhead_y;
    cfg_param->gsnr.AcceAhead_z = AcceAhead_z;

    memcpy((uint8_t*)&cms_param,(uint8_t*)cfg_param,sizeof(cfg_param_t));


    rt_kprintf("gsnr is setting .....please don't power off!\n");
        
    drv_fls_erase(PARAM_SECTOR);
    drv_fls_write(PARAM_FLAG_ADDR,param_init_words,sizeof(param_init_words));
    drv_fls_write(PARAM_MODE_ADDR,(uint8_t *)&mode,sizeof(uint16_t));
    drv_fls_write(PARAM_ADDR_CUSTOM,(uint8_t*)&all_param[0],sizeof(cfg_param_t));
    drv_fls_write(PARAM_ADDR_HIGHWAY,(uint8_t*)&all_param[1],sizeof(cfg_param_t));
    drv_fls_write(PARAM_ADDR_MOUNTAIN,(uint8_t*)&all_param[2],sizeof(cfg_param_t));
    err = drv_fls_write(PARAM_ADDR_CITY,(uint8_t*)&all_param[3],sizeof(cfg_param_t));

    if(err == -1)
        rt_kprintf("gsnr param setting failed!!!\n");
    else
        rt_kprintf("gsnr param setting success!\n");


    cfg_param = NULL;


    return 0;

}
Ejemplo n.º 7
0
int param_set(uint8_t param, int32_t value)
{

    int err;

    cfg_param_t *cfg_param;

    uint16_t mode;

    uint8_t param_num;

    cfg_param_t all_param[4];

    
    drv_fls_read(PARAM_ADDR_CUSTOM,(uint8_t*)&all_param[0],sizeof(cfg_param_t));
    drv_fls_read(PARAM_ADDR_HIGHWAY,(uint8_t*)&all_param[1],sizeof(cfg_param_t));
    drv_fls_read(PARAM_ADDR_MOUNTAIN,(uint8_t*)&all_param[2],sizeof(cfg_param_t));
    drv_fls_read(PARAM_ADDR_CITY,(uint8_t*)&all_param[3],sizeof(cfg_param_t));
    
    
    
    drv_fls_read(PARAM_MODE_ADDR,(uint8_t *)&mode,sizeof(uint16_t));

    param_num = get_param_num(mode);

    osal_printf("mode is %04X\n",mode);

    cfg_param = &all_param[param_num];


    if(param == 29){
        if((value < 1)&&(value > 13)){
            rt_kprintf("wrong channel!\n\n");
            return -1;
        }
    }

   if(param == 30){
        if((value != 1)&&(value != 2)&&(value != 6)){
            rt_kprintf("param of Txrate is just 1,2,6\n\n");
            return -1;
        }

   }
                
    switch(param){

    case 0:
        if(value > 9999){
                rt_kprintf("invalid  ID!!\n");
                return -1;
        }    
        cfg_param->pid[0] = value/1000;
        cfg_param->pid[1] = (value%1000)/100;
        cfg_param->pid[2] = ((value%1000)%100)/10;
        cfg_param->pid[3] =    ((value%1000)%100)%10;
        break;

    case 1:
        cfg_param->vam.bsm_hops = value;
        break;
    case 2:
        cfg_param->vam.bsm_boardcast_mode = value;
        break;        
    case 3:
        cfg_param->vam.bsm_boardcast_saftyfactor = value;
        break;
    case 4:
        cfg_param->vam.bsm_pause_mode = value;
        break;
    case 5:
        cfg_param->vam.bsm_pause_hold_time = value;
        break;
    case 6:
        cfg_param->vam.bsm_boardcast_period = value;
        break;
        
    case 7:
        cfg_param->vam.evam_hops = value;
        break;
    case 8:
        cfg_param->vam.evam_broadcast_type = value;
        break;
    case 9:
        cfg_param->vam.evam_broadcast_peroid = value;
        break;            


        
    case 10:
        cfg_param->vsa.danger_detect_speed_threshold = value;
        break;
    case 11:
        cfg_param->vsa.lane_dis = value;
        
        break;            
    case 12:
        cfg_param->vsa.crd_saftyfactor = value;
        break;
    case 13:
        cfg_param->vsa.crd_oppsite_speed = value;
        break;
    case 14:
        cfg_param->vsa.crd_oppsite_rear_speed = value;
        break;
    case 15:
        cfg_param->vsa.crd_rear_distance = value;
        break;

        
    case 16:
        cfg_param->vsa.ebd_mode = value;
        break;
    case 17:
        cfg_param->vsa.ebd_acceleration_threshold = value;
        break;            
    case 18:
        cfg_param->vsa.ebd_alert_hold_time = value;
        break;

    case 19:
        cfg_param->gsnr.gsnr_cal_step = value;
        break;
    case 20:
        cfg_param->gsnr.gsnr_cal_thr = value;
        break;
    case 21:
        cfg_param->gsnr.gsnr_ebd_thr = value;
        break;
    case 22:
        cfg_param->gsnr.gsnr_ebd_cnt = value;
        break;

    case 23:
        cfg_param->gsnr.AcceV_x = value;
        break;
    case 24:
        cfg_param->gsnr.AcceV_y = value;
        break;
    case 25:
        cfg_param->gsnr.AcceV_z = value;
        break;
    case 26:
        cfg_param->gsnr.AcceAhead_x = value;
        break;
    case 27:
        cfg_param->gsnr.AcceAhead_y = value;
        break;
    case 28:
        cfg_param->gsnr.AcceAhead_z = value;
        break;

        
    case 29:
        cfg_param->wnet.channel = value;
        break;

    case 30:
        cfg_param->wnet.txrate = value;
        break;
        
    case 31:
        cfg_param->print_xxx = value;
        break;
        
    case 32:
        cfg_param->voc.fg_volume = value;
        break;
    case 33:
        cfg_param->voc.bg_volume = value;
        break;
    case 34:
        cfg_param->voc.speed = value;
        break;
        
    default:          
        rt_kprintf("invalid  parameter  number!!\n");
        break;

    }

    memcpy((uint8_t*)&cms_param,(uint8_t*)cfg_param,sizeof(cfg_param_t));


    rt_kprintf("param is setting .....please don't power off!\n");
        
    drv_fls_erase(PARAM_SECTOR);
    drv_fls_write(PARAM_FLAG_ADDR,param_init_words,sizeof(param_init_words));
    drv_fls_write(PARAM_MODE_ADDR,(uint8_t *)&mode,sizeof(uint16_t));
    
    drv_fls_write(PARAM_ADDR_CUSTOM,(uint8_t*)&all_param[0],sizeof(cfg_param_t));
    drv_fls_write(PARAM_ADDR_HIGHWAY,(uint8_t*)&all_param[1],sizeof(cfg_param_t));
    drv_fls_write(PARAM_ADDR_MOUNTAIN,(uint8_t*)&all_param[2],sizeof(cfg_param_t));
    err = drv_fls_write(PARAM_ADDR_CITY,(uint8_t*)&all_param[3],sizeof(cfg_param_t));

    if(err == -1){
        rt_kprintf("parameter writing process error!!!\n");
    }
    else{
        rt_kprintf("parameter set success!\n");
    }

    cfg_param = NULL;

    return 0;

}