op_td_get_dbl()
摘要
从指定的传输数据属性中获取一个 double 值。
语法
op_td_get_dbl (pkptr, tda_index)
| 参数 | 类型 | 说明 |
|---|---|---|
pkptr |
Packet* |
指向所关注数据包的指针 |
tda_index |
int |
所关注的传输数据属性的数字索引。该 TDA 必须是 double 类型。 [该值是一个整数代码,指定要访问的传输数据属性。该参数的预定义值列于“Transmission Data Attribute“ 第 28 页。用户定义的传输信息可以从大于预定义属性所占最大索引的任意属性索引处获取(假设该属性此前已被赋值)。最大的预定义属性索引为 OPC_TDA_PT_MAX_INDEX(点对点管道)、OPC_TDA_BU_MAX_INDEX(总线管道)和 OPC_TDA_RA_MAX_INDEX(无线管道)。] |
返回类型
double
指定传输数据属性的值。
示例
摘自:示例模型(models/std/base);管道模型(dra_chanmatch)。
/* Obtain transmitting channel attributes. */
tx_freq = op_td_get_dbl (pkptr, OPC_TDA_RA_TX_FREQ);
tx_bw = op_td_get_dbl (pkptr, OPC_TDA_RA_TX_BW);
tx_drate = op_td_get_dbl (pkptr, OPC_TDA_RA_TX_DRATE);
tx_code = op_td_get_dbl (pkptr, OPC_TDA_RA_TX_CODE);
tx_mod = op_td_get_ptr (pkptr, OPC_TDA_RA_TX_MOD);
/* Obtain receiving channel attributes. */
rx_freq = op_td_get_dbl (pkptr, OPC_TDA_RA_RX_FREQ);
rx_bw = op_td_get_dbl (pkptr, OPC_TDA_RA_RX_BW);
rx_drate = op_td_get_dbl (pkptr, OPC_TDA_RA_RX_DRATE);
rx_code = op_td_get_dbl (pkptr, OPC_TDA_RA_RX_CODE);
rx_mod = op_td_get_ptr (pkptr, OPC_TDA_RA_RX_MOD);
/* For non-overlapping bands, the packet has no effect... */
if ((tx_freq > rx_freq + rx_bw) || (tx_freq + tx_bw < rx_freq))
{
op_td_set_int (pkptr, OPC_TDA_RA_MATCH_STATUS, OPC_TDA_RA_MATCH_IGNORE);
}
详情
在调用该内核过程之前,请确认相关 TDA 已被设置。可以使用 op_td_is_set() 判断 TDA 是否已设置。
传输数据属性用于在仿真内核与各级收发器管道阶段之间传递链路建模数据。Td 包的内核过程提供了用于操作传输数据属性的基本操作(设置和获取)。管道阶段模型的基本格式是一个 C 文件,其中包含一个与文件同名的单一函数(例如,基础收发器管道阶段模型 dra_power 存储在文件 dra_power.ps.c 中,并实现为 C 函数 dra_power())。在大多数阶段中,该函数的唯一参数是指向该阶段所操作数据包的指针。C 函数中的语句通常执行以下一系列活动:
- 从数据包的传输数据中提取属性(通过内核过程 op_td_get_dbl()、op_td_get_int()、op_td_get_int64() 和 op_td_get_ptr())。
- 执行表征链路模型相应阶段的计算(通常是数值处理与逻辑处理的组合)。
- 将新计算出的属性赋值给数据包的传输数据(通过内核过程 op_td_set_dbl()、op_td_set_int()、op_td_set_int64() 和 op_td_set_ptr())。
用途
提供了一种从传输数据中获取属性值的机制,该传输数据与通过链路模型收发器管道各阶段的每个数据包相关联。该内核过程用于从指定数据包的传输数据块中访问单个 double 属性值。
错误
- 可恢复错误:
<type>类型的 TDA(<name>)无法使用 'op_td_get_dbl' 获取。 - 程序中止:段违例。(由于无效的数据包指针或格式错误的数据包)
- 程序中止:数据包指针为 NIL。
- 程序中止:数据包指针指向已销毁的数据包(
<pk_id>)。 - 程序中止:Tda 索引(
<tda_index>)超出数据包(<pk_id>)的范围。 - 程序中止:Tda(
<tda_name>)在数据包(<pk_id>)中未赋值。
参考
- 使用内核过程 op_td_get_int() 或 op_td_get_int64() 获取整型传输数据属性的值
- 使用内核过程 op_td_get_ptr() 获取指针传输数据属性的值
- 使用内核过程 op_td_set_int() 或 op_td_set_int64() 为整型传输数据属性赋值
- 使用内核过程 op_td_set_dbl() 为 double 传输数据属性赋值
- 使用内核过程 op_td_set_ptr() 为指针传输数据属性赋值
- 使用内核过程 op_td_is_set() 判断传输数据属性是否已赋值