programming-the-iot / book-exercise-tasks

This repo is for issues / tasks ONLY. All programming and related exercises for each chapter of 'Programming the Internet of Things' are listed here.
Other
11 stars 12 forks source link

PIOT-CDA-02-005: Create module - SystemCpuUtilTask #23

Open labbenchstudios opened 4 years ago

labbenchstudios commented 4 years ago

Description

Review the README

Estimated effort may vary greatly

Actions

NOTE: The implementation examples depicted here are only one way to implement the requirements listed. Your own implementation may vary of course.

import programmingtheiot.common.ConfigConst as ConfigConst

from programmingtheiot.cda.system.BaseSystemUtilTask import BaseSystemUtilTask

- Create a class within the module named `SystemCpuUtilTask`. This will extend `BaseSystemUtilTask`.
- In the constructor, add the following:
`super(SystemCpuUtilTask, self).__init__(name = ConfigConst.CPU_UTIL_NAME, typeID = ConfigConst.CPU_UTIL_TYPE)`
- BaseSystemUtilTask defines a template method named `getTelemetryValue(self) -> float:`. Implement this in `SystemCpuUtilTask` as follows:
  - `return psutil.cpu_percent()`
```python
def __init__(self):
    super(SystemCpuUtilTask, self).__init__(name = ConfigConst.CPU_UTIL_NAME, typeID = ConfigConst.CPU_UTIL_TYPE)

def getTelemetryValue(self) -> float:
    return psutil.cpu_percent()

Estimate

Tests

dbeavers commented 1 year ago

You might want to add: import programmingtheiot.common.ConfigConst as ConfigConst to the example code section.

labbenchstudios commented 1 year ago

Updated.