Commit 5bcefbf 1 parent e9f1aeb commit 5bcefbf Copy full SHA for 5bcefbf
File tree 8 files changed +71
-5
lines changed
8 files changed +71
-5
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,21 @@ Automated use cases:
15
15
The Hub contains a Protocol, and can utilise modules
16
16
A device contains a protocol, and can utilise modules
17
17
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
+
18
33
## TODO:
19
34
20
35
1 . 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
+
1
3
from standalone_modules .shed_pi_module_utils .data_submission import (
2
4
ReadingSubmissionService ,
3
5
)
@@ -7,14 +9,30 @@ class BaseProtocol:
7
9
def __init__ (self , submission_service : ReadingSubmissionService ):
8
10
self .submission_service = submission_service
9
11
10
- def stop (self ):
12
+ def start (self ) -> None :
13
+ """
14
+ Start any services or logic on demand
15
+ """
11
16
...
12
17
13
- def startup (self ):
18
+ def stop (self ) -> None :
19
+ """
20
+ Stop any services or logic on demand
21
+ """
14
22
...
15
23
16
- def run (self ):
17
- raise NotImplementedError
24
+ def startup (self ) -> None :
25
+ """
26
+ Run at startup
27
+ """
28
+ ...
18
29
19
- def shutdown (self ):
30
+ def shutdown (self ) -> None :
31
+ """
32
+ Run at destruction
33
+ """
20
34
...
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