1
1
package cem
2
2
3
3
import (
4
- "github.com/enbility/eebus-go/api"
4
+ "github.com/enbility/cemd/api"
5
+ eebusapi "github.com/enbility/eebus-go/api"
5
6
"github.com/enbility/eebus-go/service"
6
7
"github.com/enbility/ship-go/logging"
7
8
"github.com/enbility/spine-go/model"
8
9
)
9
10
10
11
// Generic CEM implementation
11
- type CemImpl struct {
12
- Service api .ServiceInterface
12
+ type Cem struct {
13
+ Service eebusapi .ServiceInterface
13
14
14
15
Currency model.CurrencyType
16
+
17
+ usecases []api.UseCaseInterface
15
18
}
16
19
17
- func NewCEM (serviceDescription * api .Configuration , serviceHandler api .ServiceReaderInterface , log logging.LoggingInterface ) * CemImpl {
18
- cem := & CemImpl {
20
+ func NewCEM (serviceDescription * eebusapi .Configuration , serviceHandler eebusapi .ServiceReaderInterface , log logging.LoggingInterface ) * Cem {
21
+ cem := & Cem {
19
22
Service : service .NewService (serviceDescription , serviceHandler ),
20
23
Currency : model .CurrencyTypeEur ,
21
24
}
@@ -25,19 +28,27 @@ func NewCEM(serviceDescription *api.Configuration, serviceHandler api.ServiceRea
25
28
return cem
26
29
}
27
30
28
- // Set up the supported usecases and features
29
- func (h * CemImpl ) Setup () error {
30
- if err := h .Service .Setup (); err != nil {
31
- return err
32
- }
31
+ var _ api.CemInterface = (* Cem )(nil )
33
32
34
- return nil
33
+ // Set up the eebus service
34
+ func (h * Cem ) Setup () error {
35
+ return h .Service .Setup ()
35
36
}
36
37
37
- func (h * CemImpl ) Start () {
38
+ // Start the EEBUS service
39
+ func (h * Cem ) Start () {
38
40
h .Service .Start ()
39
41
}
40
42
41
- func (h * CemImpl ) Shutdown () {
43
+ // Shutdown the EEBUS servic
44
+ func (h * Cem ) Shutdown () {
42
45
h .Service .Shutdown ()
43
46
}
47
+
48
+ // Add a use case implementation
49
+ func (h * Cem ) AddUseCase (usecase api.UseCaseInterface ) {
50
+ h .usecases = append (h .usecases , usecase )
51
+
52
+ usecase .AddFeatures ()
53
+ usecase .AddUseCase ()
54
+ }
0 commit comments