1# ISensorInterface 2 3 4## 概述 5 6提供Sensor设备基本控制操作接口。 7 8操作包括获取传感器设备信息、订阅/取消订阅传感器数据、使能/去使能传感器、设置传感器模式、设置传感器精度、量程等可选配置接口定义。 9 10**起始版本:** 4.0 11 12**相关模块:**[HdiSensor](_hdi_sensor_v11.md) 13 14 15## 汇总 16 17 18### Public 成员函数 19 20| 名称 | 描述 | 21| -------- | -------- | 22| [GetAllSensorInfo](#getallsensorinfo) ([out] struct [HdfSensorInformation](_hdf_sensor_information_v11.md)[] info) | 获取当前系统中所有类型的传感器信息。 | 23| [Enable](#enable) ([in] int sensorId) | 根据传感器设备类型标识使能传感器信息列表里存在的设备,只有数据订阅者使能传感器后,才能获取订阅的传感器数据。 | 24| [Disable](#disable) ([in] int sensorId) | 根据传感器设备类型标识去使能传感器信息列表里存在的设备。 | 25| [SetBatch](#setbatch) ([in] int sensorId,[in] long samplingInterval, [in] long reportInterval) | 设置指定传感器的数据上报模式,不同的工作模式,上报数据的方式不同。 | 26| [SetMode](#setmode) ([in] int sensorId, [in] int mode) | 设置指定传感器数据上报模式。 | 27| [SetOption](#setoption) ([in] int sensorId, [in] unsigned int option) | 设置指定传感器量程、精度等可选配置。 | 28| [Register](#register) ([in] int groupId, [in] [ISensorCallback](interface_i_sensor_callback_v11.md) callbackObj) | 订阅者注册传感器数据回调函数,系统会将获取到的传感器数据上报给订阅者。 | 29| [Unregister](#unregister) ([in] int groupId, [in] [ISensorCallback](interface_i_sensor_callback_v11.md) callbackObj) | 订阅者取消注册传感器数据回调函数。 | 30| [ReadData](#readdata) ([in] int sensorId, [out] struct [HdfSensorEvents](_hdf_sensor_events_v11.md)[] event) | 获取小系统中的传感器事件数据。 | 31 32 33## 成员函数说明 34 35 36### Disable() 37 38``` 39ISensorInterface::Disable ([in] int sensorId) 40``` 41 42**描述** 43 44 45根据传感器设备类型标识去使能传感器信息列表里存在的设备。 46 47**起始版本:** 2.2 48 49**参数:** 50 51| 名称 | 描述 | 52| -------- | -------- | 53| sensorId | 唯一标识一个传感器设备类型,详见[HdfSensorTypeTag](_hdi_sensor_v11.md#hdfsensortypetag)。 | 54 55**返回:** 56 57如果操作成功,则返回0。 58 59如果操作失败,则返回负值。 60 61 62### Enable() 63 64``` 65ISensorInterface::Enable ([in] int sensorId) 66``` 67 68**描述** 69 70 71根据传感器设备类型标识使能传感器信息列表里存在的设备,只有数据订阅者使能传感器后,才能获取订阅的传感器数据。 72 73**起始版本:** 2.2 74 75**参数:** 76 77| 名称 | 描述 | 78| -------- | -------- | 79| sensorId | 唯一标识一个传感器设备类型,详见[HdfSensorTypeTag](_hdi_sensor_v11.md#hdfsensortypetag)。 | 80 81**返回:** 82 83如果操作成功,则返回0。 84 85如果操作失败,则返回负值。 86 87 88### GetAllSensorInfo() 89 90``` 91ISensorInterface::GetAllSensorInfo ([out] struct HdfSensorInformation[] info) 92``` 93 94**描述** 95 96 97获取当前系统中所有类型的传感器信息。 98 99**起始版本:** 2.2 100 101**参数:** 102 103| 名称 | 描述 | 104| -------- | -------- | 105| info | 输出系统中注册的所有传感器信息,一种类型传感器信息包括传感器名字、设备厂商、 固件版本号、硬件版本号、传感器类型编号、传感器标识、最大量程、精度、功耗,详见[HdfSensorInformation](_hdf_sensor_information_v11.md)。 | 106 107**返回:** 108 109如果操作成功,则返回0。 110 111如果操作失败,则返回负值。 112 113 114### ReadData() 115 116``` 117ISensorInterface::ReadData ([in] int sensorId, [out] struct HdfSensorEvents[] event ) 118``` 119 120**描述** 121 122 123获取小系统中的传感器事件数据。 124 125**起始版本: **4.0 126 127**参数:** 128 129| 名称 | 描述 | 130| -------- | -------- | 131| sensorId | 表示传感器ID。有关详细信息。 | 132| event | 表示系统中传感器事件数据的矢量。 传感器事件数据包括传感器ID、传感器算法版本、数据生成时间等,数据选项(如测量范围和精度)、数据报 告模式、数据地址和数据长度。有关详细信息,请参阅[HdfSensorEvents](_hdf_sensor_events_v11.md)。 | 133 134**返回:** 135 136如果操作成功,则返回0。 137 138如果操作失败,则返回负值。 139 140 141### Register() 142 143``` 144ISensorInterface::Register ([in] int groupId, [in] ISensorCallback callbackObj ) 145``` 146 147**描述** 148 149 150订阅者注册传感器数据回调函数,系统会将获取到的传感器数据上报给订阅者。 151 152**起始版本:** 2.2 153 154**参数:** 155 156| 名称 | 描述 | 157| -------- | -------- | 158| groupId | 传感器组ID。 groupId枚举值范围为128-160,表示已订阅医疗传感器服务,只需成功订阅一次,无需重复订阅。 groupId枚举值范围不在128-160之间,这意味着传统传感器已订阅,只需成功订阅一次,无需重复订阅。 | 159| callbackObj | 要注册的回调函数,详见[ISensorCallback](interface_i_sensor_callback_v11.md)。 | 160 161**返回:** 162 163如果操作成功,则返回0。 164 165如果操作失败,则返回负数。 166 167 168### SetBatch() 169 170``` 171ISensorInterface::SetBatch ([in] int sensorId, [in] long samplingInterval, [in] long reportInterval ) 172``` 173 174**描述** 175 176 177设置指定传感器的数据上报模式,不同的工作模式,上报数据的方式不同。 178 179**起始版本:** 2.2 180 181**参数:** 182 183| 名称 | 描述 | 184| -------- | -------- | 185| sensorId | 唯一标识一个传感器设备类型,详见[HdfSensorTypeTag](_hdi_sensor_v11.md#hdfsensortypetag)。 | 186| samplingInterval | 设置指定传感器的数据采样间隔,单位纳秒。 | 187| reportInterval | 表示传感器数据上报间隔,单位纳秒。 | 188 189**返回:** 190 191如果操作成功,则返回0。 192 193如果操作失败,则返回负值。 194 195 196### SetMode() 197 198``` 199ISensorInterface::SetMode ([in] int sensorId, [in] int mode ) 200``` 201 202**描述** 203 204 205设置指定传感器数据上报模式。 206 207**起始版本:** 2.2 208 209**参数:** 210 211| 名称 | 描述 | 212| -------- | -------- | 213| sensorId | 唯一标识一个传感器设备类型,详见[HdfSensorTypeTag](_hdi_sensor_v11.md#hdfsensortypetag)。 | 214| mode | 传感器的数据上报模式,详见[HdfSensorModeType](_hdi_sensor_v10.md#hdfsensormodetype)。 | 215 216**返回:** 217 218如果操作成功,则返回0。 219 220如果操作失败,则返回负数。 221 222 223### SetOption() 224 225``` 226ISensorInterface::SetOption ([in] int sensorId, [in] unsigned int option ) 227``` 228 229**描述** 230 231 232设置指定传感器量程、精度等可选配置。 233 234**起始版本:** 2.2 235 236**参数:** 237 238| 名称 | 描述 | 239| -------- | -------- | 240| sensorId | 唯一标识一个传感器设备类型,详见[HdfSensorTypeTag](_hdi_sensor_v11.md#hdfsensortypetag)。 | 241| option | 表示要设置的选项,如测量范围和精度。 | 242 243**返回:** 244 245如果操作成功,则返回0。 246 247如果操作失败,则返回负数。 248 249 250### Unregister() 251 252``` 253ISensorInterface::Unregister ([in] int groupId, [in] ISensorCallback callbackObj ) 254``` 255 256**描述** 257 258 259订阅者取消注册传感器数据回调函数。 260 261**起始版本:** 2.2 262 263**参数:** 264 265| 名称 | 描述 | 266| -------- | -------- | 267| groupId | 传感器组ID。 groupId枚举值范围为128-160,表示已订阅医疗传感器服务。只需成功取消订阅一次,无需重复取消订阅。 groupId枚举值范围不在128-160之间,这意味着传统传感器已订阅。并且成功取消订阅。 | 268| callbackObj | 要取消注册的回调函数,详见[ISensorCallback](interface_i_sensor_callback_v11.md)。 | 269 270**返回:** 271 272如果操作成功,则返回0。 273 274如果操作失败,则返回负数。 275