Create an instance of SystemPerformanceManager within ConstrainedDeviceApp and invoke the manager's start / stop methods within the app's start / stop methods.
Review the README
Please see README.md for further information on, and use of, this content.
License for embedded documentation and source codes: PIOT-DOC-LIC
Estimated effort may vary greatly
The estimated level of effort for this exercise shown in the 'Estimate' section below is a very rough approximation. The actual level of effort may vary greatly depending on your development and test environment, experience with the requisite technologies, and many other factors.
Actions
NOTE: The implementation examples depicted here are only one way to implement the requirements listed. Your own implementation may vary of course.
NOTE 2: All of the following instructions relate to the ConstrainedDeviceApp.
Within ConstrainedDeviceApp, import the SystemPerformancManager module and class:
from programmingtheiot.cda.system.SystemPerformanceManager import SystemPerformanceManager
Create a class-scoped instance of SystemPerformanceManager within the ConstrainedDeviceApp constructor called sysPerfManager as follows:
self.sysPerfManager = SystemPerformanceManager()
Edit the startApp() method to include a call to self.sysPerfManager.startManager().
Edit the stopApp() method to include a call to self.sysPerfManager.stopManager().
self.sysPerfMgr.stopManager()
logging.info("CDA stopped with exit code %s.", str(code))
**Estimate**
- Small
**Tests**
- Integration tests (in ./src/test/python/programmingtheiot/part01/integration)
- Run ./app/ConstrainedDeviceAppTest. Integration test should pass and generate output similar to the following:
Finding files... done.
Importing test modules ... done.
Description
SystemPerformanceManager
withinConstrainedDeviceApp
and invoke the manager's start / stop methods within the app's start / stop methods.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.
NOTE 2: All of the following instructions relate to the
ConstrainedDeviceApp
.ConstrainedDeviceApp
, import theSystemPerformancManager
module and class:SystemPerformanceManager
within theConstrainedDeviceApp
constructor calledsysPerfManager
as follows:self.sysPerfManager = SystemPerformanceManager()
startApp()
method to include a call toself.sysPerfManager.startManager()
.Edit the
stopApp()
method to include a call toself.sysPerfManager.stopManager()
.def startApp(self): logging.info("Starting CDA...")
def stopApp(self, code: int): logging.info("CDA stopping...")
Finding files... done. Importing test modules ... done.
2020-07-20 10:23:00,146:INFO:Initializing CDA... 2020-07-20 10:23:00,147:INFO:Loading configuration... 2020-07-20 10:23:00,260:INFO:Starting CDA... 2020-07-20 10:23:00,260:INFO:Started SystemPerformanceManager. 2020-07-20 10:23:00,260:INFO:CDA started. 2020-07-20 10:23:00,260:INFO:CDA stopping... 2020-07-20 10:23:00,260:INFO:Stopped SystemPerformanceManager. 2020-07-20 10:23:00,260:INFO:CDA stopped with exit code 0.
Ran 1 test in 0.115s
OK