Skip to content
This repository was archived by the owner on Jun 29, 2024. It is now read-only.

Commit b319065

Browse files
committed
Merge branch 'release/v0.5.0'
2 parents 2839324 + 9365043 commit b319065

File tree

240 files changed

+31562
-7342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+31562
-7342
lines changed

.github/workflows/default.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,41 @@ jobs:
1515

1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v4
1919

2020
- name: Set up Go
21-
uses: actions/setup-go@v2
21+
uses: actions/setup-go@v5
2222
with:
2323
go-version: ^1.18
2424

2525
- name: Build
2626
run: go build -v ./...
2727

2828
- name: Lint
29-
uses: golangci/golangci-lint-action@v3
29+
uses: golangci/golangci-lint-action@master
3030
with:
3131
version: latest
3232
skip-pkg-cache: true
3333
skip-build-cache: true
3434

3535
- name: Test
36-
run: go test -race -v -coverprofile=coverage.out -covermode=atomic ./...
36+
run: go test -race -v -coverprofile=coverage_temp.out -covermode=atomic ./...
37+
38+
- name: Remove mocks and cmd from coverage
39+
run: grep -v -e "/cemd/mocks/" -e "/cemd/cmd/" coverage_temp.out > coverage.out
3740

3841
- name: Send coverage
39-
uses: shogo82148/actions-goveralls@v1
42+
uses: coverallsapp/github-action@v2
43+
with:
44+
file: coverage.out
45+
46+
- name: Run Gosec Security Scanner
47+
uses: securego/gosec@master
48+
with:
49+
# we let the report trigger content trigger a failure using the GitHub Security features.
50+
args: '-no-fail -fmt sarif -out results.sarif ./...'
51+
- name: Upload SARIF file
52+
uses: github/codeql-action/upload-sarif@v3
4053
with:
41-
path-to-profile: coverage.out
54+
# Path to SARIF file relative to the root of the repository
55+
sarif_file: results.sarif

.golangci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
run:
2+
# timeout for analysis, e.g. 30s, 5m, default is 1m
3+
timeout: 5m
4+
5+
# include test files or not, default is true
6+
tests: true
7+
8+
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
9+
# If invoked with -mod=readonly, the go command is disallowed from the implicit
10+
# automatic updating of go.mod described above. Instead, it fails when any changes
11+
# to go.mod are needed. This setting is most useful to check that go.mod does
12+
# not need updates, such as in a continuous integration and testing system.
13+
# If invoked with -mod=vendor, the go command assumes that the vendor
14+
# directory holds the correct copies of dependencies and ignores
15+
# the dependency descriptions in go.mod.
16+
modules-download-mode: readonly
17+
18+
# output configuration options
19+
output:
20+
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
21+
formats:
22+
- format: colored-line-number
23+
24+
linters:
25+
enable:
26+
- bodyclose
27+
- errcheck
28+
- errorlint
29+
- gocheckcompilerdirectives
30+
- gochecknoinits
31+
- gochecksumtype
32+
- goconst
33+
- gofmt
34+
- gosimple
35+
- gosec
36+
- govet
37+
- nilerr
38+
- nilnil
39+
- staticcheck
40+
- typecheck
41+
- unused
42+
- whitespace
43+
44+
issues:
45+
# Excluding configuration per-path, per-linter, per-text and per-source
46+
exclude-rules:
47+
# Exclude some linters from running on tests files.
48+
- path: _test\.go
49+
linters:
50+
- errcheck
51+
- goconst
52+
- gosec
53+
54+
# checking for errors in defers seldom makes sense...
55+
- source: "^\\s*defer\\s"
56+
linters:
57+
- errcheck
58+
- staticcheck

.mockery.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
with-expecter: true
2+
inpackage: false
3+
dir: "{{ .InterfaceDir }}/../mocks"
4+
mockname: "{{.InterfaceName}}"
5+
outpkg: "mocks"
6+
filename: "{{.InterfaceName}}.go"
7+
all: true
8+
packages:
9+
github.com/enbility/cemd/api:
10+
github.com/enbility/cemd/cem:
11+
github.com/enbility/cemd/uccevc:
12+
github.com/enbility/cemd/ucevcc:
13+
github.com/enbility/cemd/ucevcem:
14+
github.com/enbility/cemd/ucevsecc:
15+
github.com/enbility/cemd/ucevsoc:
16+
github.com/enbility/cemd/uclpc:
17+
github.com/enbility/cemd/uclpcserver:
18+
github.com/enbility/cemd/uclpp:
19+
github.com/enbility/cemd/uclppserver:
20+
github.com/enbility/cemd/ucmgcp:
21+
github.com/enbility/cemd/ucmpc:
22+
github.com/enbility/cemd/ucopev:
23+
github.com/enbility/cemd/ucoscev:
24+
github.com/enbility/cemd/ucvabd:
25+
github.com/enbility/cemd/ucvapd:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Andreas Linde
3+
Copyright (c) 2022-2024 Andreas Linde
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
11
# cemd
22

3-
[![Build Status](https://github.com/enbility/cemd/actions/workflows/default.yml/badge.svg?branch=dev)](https://github.com/enbility/cemd/actions/workflows/default.yml/badge.svg?branch=dev)
3+
[![Build Status](https://github.com/enbility/cemd/actions/workflows/default.yml/badge.svg?branch=main)](https://github.com/enbility/cemd/actions/workflows/default.yml/badge.svg?branch=main)
44
[![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4)](https://godoc.org/github.com/enbility/cemd)
5-
[![Coverage Status](https://coveralls.io/repos/github/enbility/cemd/badge.svg?branch=dev)](https://coveralls.io/github/enbility/cemd?branch=dev)
5+
[![Coverage Status](https://coveralls.io/repos/github/enbility/cemd/badge.svg?branch=main)](https://coveralls.io/github/enbility/cemd?branch=main)
66
[![Go report](https://goreportcard.com/badge/github.com/enbility/cemd)](https://goreportcard.com/report/github.com/enbility/cemd)
7+
[![CodeFactor](https://www.codefactor.io/repository/github/enbility/cemd/badge)](https://www.codefactor.io/repository/github/enbility/cemd)
78

89
The goal is to provide an EEBUS CEM implementation
910

1011
## Introduction
1112

1213
This library provides a foundation to implement energy management solutions using the [eebus-go](https://github.com/enbility/eebus-go) library. It is designed to be included either directly into go projects, or it will be able to run as a daemon for other systems interact with (to be implemented).
1314

14-
These EEBUS use cases are already supported:
15-
16-
- E-Mobility:
17-
18-
- EVSE Commissioning and Configuration V1.0.1
19-
- EV Commissioning and Configuration V1.0.1
20-
- EV Charging Electricity Measurement V1.0.1
21-
- EV State Of Charge V1.0.0 RC1
22-
- Optimization of Self Consumption During EV Charging V1.0.1b
23-
- Overload Protection by EV Charging Current Curtailment V1.0.1b
24-
25-
These use cases are currently planned to be supported in the future:
26-
27-
- E-Mobility:
28-
29-
- Coordinated EV Charging V1.0.1
30-
- EV Charging Summary V1.0.1
31-
32-
More use cases and scenarios will hopefully follow in the future as well.
15+
## Packages
16+
17+
- `api`: API interface definitions
18+
- `cem`: Central CEM implementation which needs to be used by a HEMS implementation
19+
- `cmd`: Example project
20+
- `uccevc`: Use Case Coordinated EV Charging V1.0.1
21+
- `ucevcc`: Use Case EV Commissioning and Configuration V1.0.1
22+
- `ucevcem`: Use Case EV Charging Electricity Measurement V1.0.1
23+
- `ucevsecc`: Use Case EVSE Commissioning and Configuration V1.0.1
24+
- `ucevsoc`: Use Case EV State Of Charge V1.0.0 RC1
25+
- `uclpc`: Use Case Limitation of Power Consumption V1.0.0 as a Energy Guard
26+
- `uclpcserver`: Use Case Limitation of Power Consumption V1.0.0 as a Controllable System
27+
- `ucmgcp`: Use Case Monitoring of Grid Connection Point V1.0.0
28+
- `ucmpc`: Use Case Monitoring of Power Consumption V1.0.0 as a Monitoring Appliance
29+
- `ucopev`: Use Case Overload Protection by EV Charging Current Curtailment V1.0.1b
30+
- `ucoscev`: Use Case Optimization of Self Consumption During EV Charging V1.0.1b
31+
- `ucvabd`: Use Case Visualization of Aggregated Battery Data V1.0.0 RC1 as a Visualization Appliance
32+
- `ucvapd`: Use Case Visualization of Aggregated Photovoltaic Data V1.0.0 RC1 as a Visualization Appliance
33+
- `util`: various internal helpers
3334

3435
## Usage
3536

37+
Run the following command to see all the options:
38+
3639
```sh
37-
Usage: go run cmd/main.go <serverport> <remoteski> <certfile> <keyfile>
40+
Usage: go run cmd/main.go
3841
```
3942

40-
Example certificate and key files are located in the keys folder
43+
Example certificate and key files are located in the keys folder. If no certificate and key are provided in the options, new ones will be generated in the current folder.
4144

4245
### Explanation
4346

api/api.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package api
2+
3+
import (
4+
spineapi "github.com/enbility/spine-go/api"
5+
"github.com/enbility/spine-go/model"
6+
)
7+
8+
//go:generate mockery
9+
10+
// Device event callback
11+
//
12+
// Used by CEM implementation
13+
type DeviceEventCallback func(ski string, device spineapi.DeviceRemoteInterface, event EventType)
14+
15+
// Entity event callback
16+
//
17+
// Used by Use Case implementations
18+
type EntityEventCallback func(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event EventType)
19+
20+
// Implemented by CEM
21+
type CemInterface interface {
22+
// Setup the EEBUS service
23+
Setup() error
24+
25+
// Start the EEBUS service
26+
Start()
27+
28+
// Shutdown the EEBUS service
29+
Shutdown()
30+
31+
// Add a use case implementation
32+
AddUseCase(usecase UseCaseInterface)
33+
}
34+
35+
// Implemented by each Use Case
36+
type UseCaseInterface interface {
37+
// provide the usecase name
38+
UseCaseName() model.UseCaseNameType
39+
40+
// add the features
41+
AddFeatures()
42+
43+
// add the use case
44+
AddUseCase()
45+
46+
// update availability of the use case
47+
UpdateUseCaseAvailability(available bool)
48+
49+
// returns if the entity supports the usecase
50+
//
51+
// possible errors:
52+
// - ErrDataNotAvailable if that information is not (yet) available
53+
// - and others
54+
IsUseCaseSupported(remoteEntity spineapi.EntityRemoteInterface) (bool, error)
55+
}
56+
57+
type ManufacturerData struct {
58+
DeviceName string `json:"deviceName,omitempty"`
59+
DeviceCode string `json:"deviceCode,omitempty"`
60+
SerialNumber string `json:"serialNumber,omitempty"`
61+
SoftwareRevision string `json:"softwareRevision,omitempty"`
62+
HardwareRevision string `json:"hardwareRevision,omitempty"`
63+
VendorName string `json:"vendorName,omitempty"`
64+
VendorCode string `json:"vendorCode,omitempty"`
65+
BrandName string `json:"brandName,omitempty"`
66+
PowerSource string `json:"powerSource,omitempty"`
67+
ManufacturerNodeIdentification string `json:"manufacturerNodeIdentification,omitempty"`
68+
ManufacturerLabel string `json:"manufacturerLabel,omitempty"`
69+
ManufacturerDescription string `json:"manufacturerDescription,omitempty"`
70+
}

0 commit comments

Comments
 (0)