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

Commit

Permalink
Merge branch 'release/v0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndereAndi committed May 18, 2024
2 parents 2839324 + 9365043 commit b319065
Show file tree
Hide file tree
Showing 240 changed files with 31,562 additions and 7,342 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,41 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.18

- name: Build
run: go build -v ./...

- name: Lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@master
with:
version: latest
skip-pkg-cache: true
skip-build-cache: true

- name: Test
run: go test -race -v -coverprofile=coverage.out -covermode=atomic ./...
run: go test -race -v -coverprofile=coverage_temp.out -covermode=atomic ./...

- name: Remove mocks and cmd from coverage
run: grep -v -e "/cemd/mocks/" -e "/cemd/cmd/" coverage_temp.out > coverage.out

- name: Send coverage
uses: shogo82148/actions-goveralls@v1
uses: coverallsapp/github-action@v2
with:
file: coverage.out

- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
# we let the report trigger content trigger a failure using the GitHub Security features.
args: '-no-fail -fmt sarif -out results.sarif ./...'
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
path-to-profile: coverage.out
# Path to SARIF file relative to the root of the repository
sarif_file: results.sarif
58 changes: 58 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m

# include test files or not, default is true
tests: true

# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
modules-download-mode: readonly

# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
formats:
- format: colored-line-number

linters:
enable:
- bodyclose
- errcheck
- errorlint
- gocheckcompilerdirectives
- gochecknoinits
- gochecksumtype
- goconst
- gofmt
- gosimple
- gosec
- govet
- nilerr
- nilnil
- staticcheck
- typecheck
- unused
- whitespace

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- errcheck
- goconst
- gosec

# checking for errors in defers seldom makes sense...
- source: "^\\s*defer\\s"
linters:
- errcheck
- staticcheck
25 changes: 25 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
with-expecter: true
inpackage: false
dir: "{{ .InterfaceDir }}/../mocks"
mockname: "{{.InterfaceName}}"
outpkg: "mocks"
filename: "{{.InterfaceName}}.go"
all: true
packages:
github.com/enbility/cemd/api:
github.com/enbility/cemd/cem:
github.com/enbility/cemd/uccevc:
github.com/enbility/cemd/ucevcc:
github.com/enbility/cemd/ucevcem:
github.com/enbility/cemd/ucevsecc:
github.com/enbility/cemd/ucevsoc:
github.com/enbility/cemd/uclpc:
github.com/enbility/cemd/uclpcserver:
github.com/enbility/cemd/uclpp:
github.com/enbility/cemd/uclppserver:
github.com/enbility/cemd/ucmgcp:
github.com/enbility/cemd/ucmpc:
github.com/enbility/cemd/ucopev:
github.com/enbility/cemd/ucoscev:
github.com/enbility/cemd/ucvabd:
github.com/enbility/cemd/ucvapd:
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Andreas Linde
Copyright (c) 2022-2024 Andreas Linde

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
49 changes: 26 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
# cemd

[![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)
[![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)
[![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4)](https://godoc.org/github.com/enbility/cemd)
[![Coverage Status](https://coveralls.io/repos/github/enbility/cemd/badge.svg?branch=dev)](https://coveralls.io/github/enbility/cemd?branch=dev)
[![Coverage Status](https://coveralls.io/repos/github/enbility/cemd/badge.svg?branch=main)](https://coveralls.io/github/enbility/cemd?branch=main)
[![Go report](https://goreportcard.com/badge/github.com/enbility/cemd)](https://goreportcard.com/report/github.com/enbility/cemd)
[![CodeFactor](https://www.codefactor.io/repository/github/enbility/cemd/badge)](https://www.codefactor.io/repository/github/enbility/cemd)

The goal is to provide an EEBUS CEM implementation

## Introduction

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).

These EEBUS use cases are already supported:

- E-Mobility:

- EVSE Commissioning and Configuration V1.0.1
- EV Commissioning and Configuration V1.0.1
- EV Charging Electricity Measurement V1.0.1
- EV State Of Charge V1.0.0 RC1
- Optimization of Self Consumption During EV Charging V1.0.1b
- Overload Protection by EV Charging Current Curtailment V1.0.1b

These use cases are currently planned to be supported in the future:

- E-Mobility:

- Coordinated EV Charging V1.0.1
- EV Charging Summary V1.0.1

More use cases and scenarios will hopefully follow in the future as well.
## Packages

- `api`: API interface definitions
- `cem`: Central CEM implementation which needs to be used by a HEMS implementation
- `cmd`: Example project
- `uccevc`: Use Case Coordinated EV Charging V1.0.1
- `ucevcc`: Use Case EV Commissioning and Configuration V1.0.1
- `ucevcem`: Use Case EV Charging Electricity Measurement V1.0.1
- `ucevsecc`: Use Case EVSE Commissioning and Configuration V1.0.1
- `ucevsoc`: Use Case EV State Of Charge V1.0.0 RC1
- `uclpc`: Use Case Limitation of Power Consumption V1.0.0 as a Energy Guard
- `uclpcserver`: Use Case Limitation of Power Consumption V1.0.0 as a Controllable System
- `ucmgcp`: Use Case Monitoring of Grid Connection Point V1.0.0
- `ucmpc`: Use Case Monitoring of Power Consumption V1.0.0 as a Monitoring Appliance
- `ucopev`: Use Case Overload Protection by EV Charging Current Curtailment V1.0.1b
- `ucoscev`: Use Case Optimization of Self Consumption During EV Charging V1.0.1b
- `ucvabd`: Use Case Visualization of Aggregated Battery Data V1.0.0 RC1 as a Visualization Appliance
- `ucvapd`: Use Case Visualization of Aggregated Photovoltaic Data V1.0.0 RC1 as a Visualization Appliance
- `util`: various internal helpers

## Usage

Run the following command to see all the options:

```sh
Usage: go run cmd/main.go <serverport> <remoteski> <certfile> <keyfile>
Usage: go run cmd/main.go
```

Example certificate and key files are located in the keys folder
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.

### Explanation

Expand Down
70 changes: 70 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package api

import (
spineapi "github.com/enbility/spine-go/api"
"github.com/enbility/spine-go/model"
)

//go:generate mockery

// Device event callback
//
// Used by CEM implementation
type DeviceEventCallback func(ski string, device spineapi.DeviceRemoteInterface, event EventType)

// Entity event callback
//
// Used by Use Case implementations
type EntityEventCallback func(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event EventType)

// Implemented by CEM
type CemInterface interface {
// Setup the EEBUS service
Setup() error

// Start the EEBUS service
Start()

// Shutdown the EEBUS service
Shutdown()

// Add a use case implementation
AddUseCase(usecase UseCaseInterface)
}

// Implemented by each Use Case
type UseCaseInterface interface {
// provide the usecase name
UseCaseName() model.UseCaseNameType

// add the features
AddFeatures()

// add the use case
AddUseCase()

// update availability of the use case
UpdateUseCaseAvailability(available bool)

// returns if the entity supports the usecase
//
// possible errors:
// - ErrDataNotAvailable if that information is not (yet) available
// - and others
IsUseCaseSupported(remoteEntity spineapi.EntityRemoteInterface) (bool, error)
}

type ManufacturerData struct {
DeviceName string `json:"deviceName,omitempty"`
DeviceCode string `json:"deviceCode,omitempty"`
SerialNumber string `json:"serialNumber,omitempty"`
SoftwareRevision string `json:"softwareRevision,omitempty"`
HardwareRevision string `json:"hardwareRevision,omitempty"`
VendorName string `json:"vendorName,omitempty"`
VendorCode string `json:"vendorCode,omitempty"`
BrandName string `json:"brandName,omitempty"`
PowerSource string `json:"powerSource,omitempty"`
ManufacturerNodeIdentification string `json:"manufacturerNodeIdentification,omitempty"`
ManufacturerLabel string `json:"manufacturerLabel,omitempty"`
ManufacturerDescription string `json:"manufacturerDescription,omitempty"`
}
Loading

0 comments on commit b319065

Please sign in to comment.