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