op_ev_time()
摘要
获取指定事件计划发生的时间。
语法
op_ev_time (evhandle)
| 参数 | 类型 | 说明 |
|---|---|---|
evhandle |
Evhandle |
标识该事件的事件句柄 [事件句柄可以从本包中的多个内核过程获取,例如 op_ev_current()、op_ev_seek_time() 和 op_ev_next(),以及 op_intrpt_schedule_self() 等其他内核过程。] |
返回类型
double
指定事件计划发生的仿真时间。
该双精度浮点数表示仿真时间,以秒为单位,从仿真开始时刻起算。如果发生可恢复错误,将返回 OPC_TIME_INVALID。
示例
/* Determine if any interrupts on the Q_LEN statwire are scheduled */
/* to occur in the next five seconds. */
stat_intrpt_found = 0;
time_boundary = op_sim_time () + 5.0;
event = op_ev_next (op_ev_current ());
while (op_ev_valid (event))
{
/* If the event is after the time boundary, then quit looking. */
if (op_ev_time (event) > time_boundary)
break;
/* If it is a statwire intrpt on the Q_LEN statwire, note it and break out. */
if ((op_ev_type (event) == OPC_INTRPT_STAT) &&
(op_ev_stat (event) == Q_LEN_STATWIRE))
{
stat_intrpt_found = 1;
break;
}
/* Didn’t match, so try the next local event. */
event = op_ev_next_local (event);
}
详情
返回值为双精度浮点数,表示与指定事件关联的时间值。注意 op_ev_time (op_ev_current ()) 等价于 op_sim_time()。
注意: 如果 “sim_time_quantum“ 偏好的值不为 0.0,则返回的仿真时间将是指定量子值的整数倍。
用途
提供了一种确定事件计划发生时间的机制。
错误
- 程序中止:段错误。(由于格式错误的事件句柄)
- 可恢复错误:事件句柄指向的事件无效或当前未被计划。
参考
- 使用内核过程 op_ev_valid() 判断 Evhandle 是否有效
- 使用内核过程 op_ev_type() 确定事件的类型
- 使用内核过程 op_ev_code() 确定自中断、远程中断或组播中断的代码
- 使用内核过程 op_ev_strm() 确定与流中断关联的数据流索引
- 使用内核过程 op_ev_stat() 确定与统计中断关联的输入统计量索引