|
272 | 272 | "\n", |
273 | 273 | "from viam.components.sensor import Sensor\n", |
274 | 274 | "from viam.logging import getLogger\n", |
| 275 | + "from viam.utils import SensorReading\n", |
275 | 276 | "\n", |
276 | 277 | "LOGGER = getLogger(__name__)\n", |
277 | 278 | "\n", |
278 | 279 | "\n", |
279 | 280 | "class MySensor(Sensor):\n", |
280 | 281 | " # Subclass the Viam Sensor component and implement the required functions\n", |
281 | | - " async def get_readings(self, extra: Optional[Dict[str, Any]] = None, **kwargs) -> Mapping[str, Any]:\n", |
| 282 | + " async def get_readings(self, extra: Optional[Dict[str, Any]] = None, **kwargs) -> Mapping[str, SensorReading]:\n", |
282 | 283 | " with open(\"/proc/net/wireless\") as wifi_stats:\n", |
283 | 284 | " content = wifi_stats.readlines()\n", |
284 | 285 | " wifi_signal = [x for x in content[2].split(\" \") if x != \"\"]\n", |
|
368 | 369 | "# ADD `Sequence` FROM `typing`.\n", |
369 | 370 | "from typing import Sequence\n", |
370 | 371 | "\n", |
| 372 | + "from viam.utils import SensorReading\n", |
| 373 | + "\n", |
371 | 374 | "class MySensor(Sensor):\n", |
372 | 375 | " # ADD A VALIDATOR FUNCTION \n", |
373 | 376 | " @classmethod\n", |
|
395 | 398 | " multiplier = 1.0\n", |
396 | 399 | " self.multiplier = multiplier\n", |
397 | 400 | "\n", |
398 | | - " async def get_readings(self, extra: Optional[Dict[str, Any]] = None, **kwargs) -> Mapping[str, Any]:\n", |
| 401 | + " async def get_readings(self, extra: Optional[Dict[str, Any]] = None, **kwargs) -> Mapping[str, SensorReading]:\n", |
399 | 402 | " with open(\"/proc/net/wireless\") as wifi_stats:\n", |
400 | 403 | " content = wifi_stats.readlines()\n", |
401 | 404 | " result = [x for x in content[2].split(\" \") if x != \"\"]\n", |
|
1031 | 1034 | "\n", |
1032 | 1035 | "from viam.components.sensor import Geometry, Sensor\n", |
1033 | 1036 | "from viam.rpc.server import Server\n", |
| 1037 | + "from viam.utils import SensorReading\n", |
1034 | 1038 | "\n", |
1035 | 1039 | "\n", |
1036 | 1040 | "class MySensor(Sensor):\n", |
1037 | | - " async def get_readings(self, extra: Optional[Dict[str, Any]] = None, **kwargs) -> Mapping[str, Any]:\n", |
| 1041 | + " async def get_readings(self, extra: Optional[Dict[str, Any]] = None, **kwargs) -> Mapping[str, SensorReading]:\n", |
1038 | 1042 | " with open(\"/proc/net/wireless\") as wifi_stats:\n", |
1039 | 1043 | " content = wifi_stats.readlines()\n", |
1040 | 1044 | " wifi_signal = [x for x in content[2].split(\" \") if x != \"\"]\n", |
|
1485 | 1489 | "name": "python", |
1486 | 1490 | "nbconvert_exporter": "python", |
1487 | 1491 | "pygments_lexer": "ipython3", |
1488 | | - "version": "3.11.4 (main, Jun 20 2023, 17:23:00) [Clang 14.0.3 (clang-1403.0.22.14.1)]" |
| 1492 | + "version": "3.11.6 (main, Oct 2 2023, 20:46:14) [Clang 14.0.3 (clang-1403.0.22.14.1)]" |
1489 | 1493 | }, |
1490 | 1494 | "vscode": { |
1491 | 1495 | "interpreter": { |
|
0 commit comments