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.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndereAndi committed Dec 6, 2022
2 parents 85bebf3 + f696078 commit b845860
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 56 deletions.
1 change: 1 addition & 0 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- dev
- main
pull_request:
workflow_call:

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# cemd

[![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)
[![Go report](https://goreportcard.com/badge/github.com/enbility/cemd)](https://goreportcard.com/report/github.com/enbility/cemd)

The goal is to provide an EEBUS CEM implementation

## Introduction
Expand Down
9 changes: 3 additions & 6 deletions cem/cem.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@ package cem

import (
"github.com/enbility/cemd/emobility"
"github.com/enbility/cemd/scenarios"
"github.com/enbility/eebus-go/logging"
"github.com/enbility/eebus-go/service"
"github.com/enbility/eebus-go/spine"
)

// Generic CEM implementation
type CemImpl struct {
siteConfig *scenarios.SiteConfig
service *service.EEBUSService
emobilityScenario *emobility.EmobilityScenarioImpl
}

func NewCEM(siteConfig *scenarios.SiteConfig, serviceDescription *service.ServiceDescription, serviceHandler service.EEBUSServiceHandler, log logging.Logging) *CemImpl {
func NewCEM(serviceDescription *service.Configuration, serviceHandler service.EEBUSServiceHandler, log logging.Logging) *CemImpl {
cem := &CemImpl{
siteConfig: siteConfig,
service: service.NewEEBUSService(serviceDescription, serviceHandler),
service: service.NewEEBUSService(serviceDescription, serviceHandler),
}

cem.service.SetLogging(log)
Expand All @@ -36,7 +33,7 @@ func (h *CemImpl) Setup(enableEmobility bool) error {

// Setup the supported usecases and features
if enableEmobility {
h.emobilityScenario = emobility.NewEMobilityScenario(h.siteConfig, h.service)
h.emobilityScenario = emobility.NewEMobilityScenario(h.service)
h.emobilityScenario.AddFeatures()
h.emobilityScenario.AddUseCases()
}
Expand Down
15 changes: 7 additions & 8 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

"github.com/enbility/cemd/cem"
"github.com/enbility/cemd/scenarios"
"github.com/enbility/eebus-go/logging"
"github.com/enbility/eebus-go/service"
"github.com/enbility/eebus-go/spine/model"
Expand All @@ -20,10 +19,10 @@ type DemoCem struct {
cem *cem.CemImpl
}

func NewDemoCem(siteConfig *scenarios.SiteConfig, serviceDescription *service.ServiceDescription) *DemoCem {
func NewDemoCem(configuration *service.Configuration) *DemoCem {
demo := &DemoCem{}

demo.cem = cem.NewCEM(siteConfig, serviceDescription, demo, demo)
demo.cem = cem.NewCEM(configuration, demo, demo)

return demo
}
Expand Down Expand Up @@ -114,22 +113,22 @@ func main() {

ifaces := []string{os.Args[5]}

serviceDescription, err := service.NewServiceDescription(
configuration, err := service.NewConfiguration(
"Demo",
"Demo",
"HEMS",
"123456789",
model.DeviceTypeTypeEnergyManagementSystem,
portValue,
certificate)
certificate,
230)
if err != nil {
fmt.Println("Service data is invalid:", err)
return
}
serviceDescription.SetInterfaces(ifaces)
configuration.SetInterfaces(ifaces)

siteConfig := scenarios.NewSiteConfig(230.0)
demo := NewDemoCem(siteConfig, serviceDescription)
demo := NewDemoCem(configuration)
if err := demo.Setup(); err != nil {
fmt.Println("Error setting up cem: ", err)
return
Expand Down
13 changes: 5 additions & 8 deletions emobility/emobility.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package emobility

import (
"github.com/enbility/cemd/scenarios"
"github.com/enbility/eebus-go/features"
"github.com/enbility/eebus-go/service"
"github.com/enbility/eebus-go/spine"
Expand Down Expand Up @@ -137,8 +136,7 @@ type EmobilityI interface {
type EMobilityImpl struct {
entity *spine.EntityLocalImpl

siteConfig *scenarios.SiteConfig
service *service.EEBUSService
service *service.EEBUSService

evseEntity *spine.EntityRemoteImpl
evEntity *spine.EntityRemoteImpl
Expand All @@ -160,14 +158,13 @@ type EMobilityImpl struct {
var _ EmobilityI = (*EMobilityImpl)(nil)

// Add E-Mobility support
func NewEMobility(siteConfig *scenarios.SiteConfig, service *service.EEBUSService, details service.ServiceDetails) *EMobilityImpl {
func NewEMobility(service *service.EEBUSService, details service.ServiceDetails) *EMobilityImpl {
ski := util.NormalizeSKI(details.SKI)

emobility := &EMobilityImpl{
siteConfig: siteConfig,
service: service,
entity: service.LocalEntity(),
ski: ski,
service: service,
entity: service.LocalEntity(),
ski: ski,
}
spine.Events.Subscribe(emobility)

Expand Down
2 changes: 1 addition & 1 deletion emobility/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (e *EMobilityImpl) EVPowerPerPhase() ([]float64, error) {
if theValue, exists := currents[phase]; exists {
value = theValue
}
data[phase] = value * e.siteConfig.Voltage()
data[phase] = value * e.service.Configuration.Voltage()
}
}

Expand Down
6 changes: 3 additions & 3 deletions emobility/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ type EmobilityScenarioImpl struct {

var _ scenarios.ScenariosI = (*EmobilityScenarioImpl)(nil)

func NewEMobilityScenario(siteConfig *scenarios.SiteConfig, service *service.EEBUSService) *EmobilityScenarioImpl {
func NewEMobilityScenario(service *service.EEBUSService) *EmobilityScenarioImpl {
return &EmobilityScenarioImpl{
ScenarioImpl: scenarios.NewScenarioImpl(siteConfig, service),
ScenarioImpl: scenarios.NewScenarioImpl(service),
remoteDevices: make(map[string]*EMobilityImpl),
}
}
Expand Down Expand Up @@ -131,7 +131,7 @@ func (e *EmobilityScenarioImpl) RegisterEmobilityRemoteDevice(details service.Se
return em
}

emobility := NewEMobility(e.SiteConfig, e.Service, details)
emobility := NewEMobility(e.Service, details)
e.remoteDevices[details.SKI] = emobility
return emobility
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ module github.com/enbility/cemd

go 1.18

require github.com/enbility/eebus-go v0.1.0
require github.com/enbility/eebus-go v0.1.1

require (
github.com/miekg/dns v1.1.50 // indirect
github.com/ahmetb/go-linq/v3 v3.2.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/holoplot/go-avahi v1.0.1 // indirect
github.com/libp2p/zeroconf/v2 v2.2.0 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/rickb777/date v1.20.1 // indirect
github.com/rickb777/plural v1.4.1 // indirect
gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
github.com/ahmetb/go-linq/v3 v3.2.0 h1:BEuMfp+b59io8g5wYzNoFe9pWPalRklhlhbiU3hYZDE=
github.com/ahmetb/go-linq/v3 v3.2.0/go.mod h1:haQ3JfOeWK8HpVxMtHHEMPVgBKiYyQ+f1/kLZh/cj9U=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/enbility/eebus-go v0.0.0-20221205131802-d7cf1fd3edcc h1:YuvqFzLzk9AcW4kIgzwq6wWnQJQoUpPdrhOzIU5ppJw=
github.com/enbility/eebus-go v0.0.0-20221205131802-d7cf1fd3edcc/go.mod h1:7p6MLHfv7TiCJ4neB7hQYK90mIdYqAMic8WOwYXVG+Y=
github.com/enbility/eebus-go v0.1.0 h1:FTgw6K1YDnuTrk60Djr6wCNc2hViSmdORU9JHQ4F85E=
github.com/enbility/eebus-go v0.1.0/go.mod h1:7p6MLHfv7TiCJ4neB7hQYK90mIdYqAMic8WOwYXVG+Y=
github.com/enbility/eebus-go v0.1.1 h1:biM/QbbudAAneUBnyxeEAoqY99jYCMxklB4wwOeC2V8=
github.com/enbility/eebus-go v0.1.1/go.mod h1:7p6MLHfv7TiCJ4neB7hQYK90mIdYqAMic8WOwYXVG+Y=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
Expand Down
27 changes: 3 additions & 24 deletions scenarios/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,11 @@ type ScenariosI interface {
}

type ScenarioImpl struct {
SiteConfig *SiteConfig
Service *service.EEBUSService
Service *service.EEBUSService
}

func NewScenarioImpl(siteConfig *SiteConfig, service *service.EEBUSService) *ScenarioImpl {
func NewScenarioImpl(service *service.EEBUSService) *ScenarioImpl {
return &ScenarioImpl{
SiteConfig: siteConfig,
Service: service,
Service: service,
}
}

// Generic site specific data
type SiteConfig struct {
// This is useful when e.g. power values are not available and therefor
// need to be calculated using the current values
voltage float64
}

// Create a new site config
// voltage of the electrical installation
func NewSiteConfig(voltage float64) *SiteConfig {
return &SiteConfig{
voltage: voltage,
}
}

func (s *SiteConfig) Voltage() float64 {
return s.voltage
}

0 comments on commit b845860

Please sign in to comment.