File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,21 @@ Automated use cases:
1515The Hub contains a Protocol, and can utilise modules
1616A device contains a protocol, and can utilise modules
1717
18+ Decisions to be made:
19+
20+ 1 . Proposed change of device and module layout:
21+ A Device contains a bunch of modules, a module contains a bunch of components
22+ - Device (RPI, Arduino)
23+ - Module (AM2302)
24+ - Glue to connect modules to the device!
25+ - Cons:
26+ - Configuration complexity
27+ - Pros:
28+ - Reusable modules 2 modules for one data record - Temp and Humidity
29+ - Modules are small and can contain their own tests
30+ - Naming of the glue? That is currently modules, could make a new dir for components that are self
31+ contained!
32+
1833## TODO:
1934
20351 . Fix: Bug: The script startup gets an incorrect time (Hasn't yet got the internet time)
Original file line number Diff line number Diff line change 1+ # Template Module
Original file line number Diff line number Diff line change 1+ from standalone_modules .shed_pi_module_utils .base_protocol import BaseProtocol
2+ from standalone_modules .shed_pi_module_utils .data_submission import (
3+ ReadingSubmissionService ,
4+ )
5+ from standalone_modules .shed_pi_module_utils .utils import logger
6+
7+
8+ class DeviceProtocol (BaseProtocol ):
9+ def __init__ (self , submission_service : ReadingSubmissionService ):
10+ ...
11+
12+ def stop (self ):
13+ logger .info ("Stopping device protocol" )
14+
15+ def start (self ):
16+ logger .info ("Starting device protocol" )
17+
18+
19+ def main ():
20+ # The Submission service is used to record any module data
21+ submission_service = ReadingSubmissionService ()
22+ device = DeviceProtocol (submission_service = submission_service )
23+
24+ try :
25+ device .startup ()
26+ device .start ()
27+ finally :
28+ device .shutdown ()
29+
30+
31+ if __name__ == "__main__" :
32+ main ()
Original file line number Diff line number Diff line change 1+ from warnings import deprecated
2+
13from standalone_modules .shed_pi_module_utils .data_submission import (
24 ReadingSubmissionService ,
35)
@@ -7,14 +9,30 @@ class BaseProtocol:
79 def __init__ (self , submission_service : ReadingSubmissionService ):
810 self .submission_service = submission_service
911
10- def stop (self ):
12+ def start (self ) -> None :
13+ """
14+ Start any services or logic on demand
15+ """
1116 ...
1217
13- def startup (self ):
18+ def stop (self ) -> None :
19+ """
20+ Stop any services or logic on demand
21+ """
1422 ...
1523
16- def run (self ):
17- raise NotImplementedError
24+ def startup (self ) -> None :
25+ """
26+ Run at startup
27+ """
28+ ...
1829
19- def shutdown (self ):
30+ def shutdown (self ) -> None :
31+ """
32+ Run at destruction
33+ """
2034 ...
35+
36+ @deprecated ("Deprecated run method is replaced by start" )
37+ def run (self ) -> None :
38+ raise NotImplementedError
You can’t perform that action at this time.
0 commit comments