Chinaunix首页 | 论坛 | 博客
  • 博客访问: 221351
  • 博文数量: 25
  • 博客积分: 4085
  • 博客等级: 上校
  • 技术积分: 585
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-30 02:09
文章分类

全部博文(25)

文章存档

2011年(1)

2009年(2)

2008年(22)

我的朋友

分类: 系统运维

2008-03-28 11:44:44

Illidan.modeler@gmail.com
Northern Capital, Republic of Pandaria

op_ima_obj_pos_query_proc_set
()


Abstract

Sets a callback to return the position of a mobile site that is not following a trajectory or vector.


Details

The callback is a custom procedure that computes the latitude, longitude, and altitude of a site given a requested time and the previous position and time. The requested time can be the current simulation time or some future time. The callback prototype is:

typedef void
(*SimT_Ima_Obj_Position_Query_Proc)(SimT_Objid site_id,
void * state_ptr, double prev_time, double prev_latitude,
double prev_longitude, double prev_altitude_in_meters,
double request_time, double * lat_ptr, double * long_ptr,
double * alt_in_meters_ptr);

Purpose

Normally, the Simulation Kernel uses whatever position was last set for nodes that aren't following a trajectory or vector. This KP registers a callback for a specific mobile site (node or subnet) that enables the Simulation Kernel to obtain an exact position whenever needed.


Experiment


A node is made to use op_ima_obj_pos_query_proc_set.





src represents simple_source.pr.m while pos uses  op_ima_obj_pos_query_proc_set to set the callback. The callback is defined as


void straight_line_ascend (SimT_Objid site_id, void * site_ptr,
    double prev_time, double prev_latitude, double prev_longitude,
    double prev_altitude, double cur_time, double * lat_ptr,
    double * long_ptr, double * alt_in_meters_ptr)
    {
    /* increase altitude 1 meter/second */
    *alt_in_meters_ptr = prev_altitude + (cur_time-prev_time) * 1.0;
    
    *lat_ptr = prev_latitude + (cur_time-prev_time) *1.0;
    
    *long_ptr = prev_longitude + (cur_time-prev_time) *1.0;
    
    op_prg_text_output("lat=%lf, long=%lf, alt=%lf\n",
        *lat_ptr, *long_ptr, *alt_in_meters_ptr);
    
    }



If src generates traffic, the callback is called and the position is printed.

lat=11.000000, long=11.000000, alt=11.000000
lat=12.000000, long=12.000000, alt=12.000000
lat=13.000000, long=13.000000, alt=13.000000
lat=14.000000, long=14.000000, alt=14.000000
lat=15.000000, long=15.000000, alt=15.000000
lat=16.000000, long=16.000000, alt=16.000000
lat=17.000000, long=17.000000, alt=17.000000
lat=18.000000, long=18.000000, alt=18.000000
lat=19.000000, long=19.000000, alt=19.000000


If src does not generate traffic, the callback is not called and you cannot see the textual output above.

If fact, the arguments in the callback, namely prev_time, curr_time, are the time points at which the packets are sent. If you set different inter-arrival time parameter for src, these two arguments will have different values, hence different output from that shown above.
阅读(1112) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~