1
1
package democem
2
2
3
3
import (
4
+ "fmt"
5
+ "time"
6
+
7
+ "github.com/enbility/cemd/api"
4
8
"github.com/enbility/cemd/cem"
5
9
"github.com/enbility/cemd/ucevsecc"
6
10
"github.com/enbility/cemd/uclpcserver"
@@ -10,13 +14,16 @@ import (
10
14
11
15
type DemoCem struct {
12
16
cem * cem.Cem
17
+
18
+ remoteSki string
13
19
}
14
20
15
- func NewDemoCem (configuration * eebusapi.Configuration ) * DemoCem {
16
- demo := & DemoCem {}
21
+ func NewDemoCem (configuration * eebusapi.Configuration , remoteSki string ) * DemoCem {
22
+ demo := & DemoCem {
23
+ remoteSki : remoteSki ,
24
+ }
17
25
18
- noLogging := & logging.NoLogging {}
19
- demo .cem = cem .NewCEM (configuration , demo , demo .deviceEventCB , noLogging )
26
+ demo .cem = cem .NewCEM (configuration , demo , demo .deviceEventCB , demo )
20
27
21
28
return demo
22
29
}
@@ -29,10 +36,77 @@ func (d *DemoCem) Setup() error {
29
36
lpcs := uclpcserver .NewUCLPC (d .cem .Service , d .entityEventCB )
30
37
d .cem .AddUseCase (lpcs )
31
38
39
+ if err := lpcs .SetLoadControlLimit (api.LoadLimit {
40
+ IsChangeable : true ,
41
+ IsActive : false ,
42
+ Value : 0 ,
43
+ }); err != nil {
44
+ logging .Log ().Debug (err )
45
+ }
46
+ if err := lpcs .SetContractualConsumptionNominalMax (22000 ); err != nil {
47
+ logging .Log ().Debug (err )
48
+ }
49
+ if err := lpcs .SetFailsafeConsumptionActivePowerLimit (4300 , true ); err != nil {
50
+ logging .Log ().Debug (err )
51
+ }
52
+ if err := lpcs .SetFailsafeDurationMinimum (time .Hour * 2 , true ); err != nil {
53
+ logging .Log ().Debug (err )
54
+ }
55
+
32
56
evsecc := ucevsecc .NewUCEVSECC (d .cem .Service , d .entityEventCB )
33
57
d .cem .AddUseCase (evsecc )
34
58
59
+ d .cem .Service .RegisterRemoteSKI (d .remoteSki , true )
60
+
35
61
d .cem .Start ()
36
62
37
63
return nil
38
64
}
65
+
66
+ // Logging interface
67
+
68
+ func (d * DemoCem ) Trace (args ... interface {}) {
69
+ d .print ("TRACE" , args ... )
70
+ }
71
+
72
+ func (d * DemoCem ) Tracef (format string , args ... interface {}) {
73
+ d .printFormat ("TRACE" , format , args ... )
74
+ }
75
+
76
+ func (d * DemoCem ) Debug (args ... interface {}) {
77
+ d .print ("DEBUG" , args ... )
78
+ }
79
+
80
+ func (d * DemoCem ) Debugf (format string , args ... interface {}) {
81
+ d .printFormat ("DEBUG" , format , args ... )
82
+ }
83
+
84
+ func (d * DemoCem ) Info (args ... interface {}) {
85
+ d .print ("INFO " , args ... )
86
+ }
87
+
88
+ func (d * DemoCem ) Infof (format string , args ... interface {}) {
89
+ d .printFormat ("INFO " , format , args ... )
90
+ }
91
+
92
+ func (d * DemoCem ) Error (args ... interface {}) {
93
+ d .print ("ERROR" , args ... )
94
+ }
95
+
96
+ func (d * DemoCem ) Errorf (format string , args ... interface {}) {
97
+ d .printFormat ("ERROR" , format , args ... )
98
+ }
99
+
100
+ func (d * DemoCem ) currentTimestamp () string {
101
+ return time .Now ().Format ("2006-01-02 15:04:05" )
102
+ }
103
+
104
+ func (d * DemoCem ) print (msgType string , args ... interface {}) {
105
+ value := fmt .Sprintln (args ... )
106
+ fmt .Printf ("%s %s %s" , d .currentTimestamp (), msgType , value )
107
+ }
108
+
109
+ func (d * DemoCem ) printFormat (msgType , format string , args ... interface {}) {
110
+ value := fmt .Sprintf (format , args ... )
111
+ fmt .Println (d .currentTimestamp (), msgType , value )
112
+ }
0 commit comments